-
Notifications
You must be signed in to change notification settings - Fork 499
Fix read_console includeStacktrace parameter behavior #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The includeStacktrace parameter was working backwards - when false, it would return the full message with embedded stack traces, and when true, it would extract the stack trace but the logic was inverted. Changes: - Always extract the first line as the message text - Only populate stackTrace field when includeStacktrace is true - Ensures clean, summary-only messages when includeStacktrace is false - Properly separates stack traces into their own field when requested This matches the expected Unity console behavior where the summary is shown by default, and stack traces are only shown when expanded.
WalkthroughReworked ReadConsole message parsing to always split the log into lines and use the first line as the message. Stack trace is explicitly nulled when includeStacktrace is false. Formatting logic now consistently derives messageOnly from the pre-split lines array. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant ReadConsole
Caller->>ReadConsole: FormatLog(message, includeStacktrace)
activate ReadConsole
Note over ReadConsole: Split message into lines<br/>messageOnly = lines[0]
alt includeStacktrace == true
ReadConsole->>ReadConsole: stackTrace = extracted or existing
else includeStacktrace == false
ReadConsole->>ReadConsole: stackTrace = null
end
ReadConsole-->>Caller: (messageOnly, stackTrace, formatted output)
deactivate ReadConsole
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
UnityMcpBridge/Editor/Tools/ReadConsole.cs (1)
314-317: Redundant null assignment.The
stackTracevariable is alreadynullwhenincludeStacktraceisfalsedue to the ternary operator on Line 305. This conditional block has no functional effect.Consider removing the redundant block:
string messageOnly = messageLines.Length > 0 ? messageLines[0] : message; - - // If not including stacktrace, ensure we only show the first line - if (!includeStacktrace) - { - stackTrace = null; - }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
UnityMcpBridge/Editor/Tools/ReadConsole.cs(1 hunks)
🔇 Additional comments (1)
UnityMcpBridge/Editor/Tools/ReadConsole.cs (1)
306-311: LGTM! Consistent message formatting logic.The change ensures that the message field always displays the first line (summary) regardless of the
includeStacktraceparameter, which aligns with the PR objective to fix the inverted behavior. The fallback to the full message when no lines are found is a good safety measure.
The includeStacktrace parameter was working backwards - when false, it would return the full message with embedded stack traces, and when true, it would extract the stack trace but the logic was inverted.
Changes:
This matches the expected Unity console behavior where the summary is shown by default, and stack traces are only shown when expanded.
Should help with #302
Summary by CodeRabbit
Bug Fixes
Refactor
Documentation