Repository navigation
fix(cli): keep line breaks in logs explain text output - #6704
Conversation
`ocx logs explain <id>` passed the pretty-printed route decision to printData as a single entry. printData escapes control characters per entry for terminal safety, so every line break was printed as a literal `\x0a` and the whole decision came out on one line. Pass one entry per line instead; values keep the same terminal-safety escaping, and --json output is unchanged.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe CLI’s human-readable ChangesExplain Output
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change affects human-readable explain output; JSON output remains unchanged, and the added test covers the intended line-break and terminal-escaping behavior. No merge-blocking issue is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Maintainer integration into
|
Summary
ocx logs explain <request-id>(text mode) printed the whole route decision on one line, with every line break shown as a literal\x0a.--jsonwas not affected.explain()insrc/cli/observe.tspassed the pretty-printed JSON toprintDataas a single entry.printDatarunsterminalSafeTextper entry, which escapes\nalong with the other control characters.JSON.stringify(result, null, 2).split("\n")). Values inside the decision keep the same terminal-safety escaping (e.g. C1 controls such as U+009B thatJSON.stringifyleaves raw), and--jsonoutput is unchanged. No otherprintDatacaller passes a multi-line single entry.Before (2.79.0):
After:
Verification
bun test tests/cli/route-explainability.test.ts: 15 pass, 0 fail (49 expect() calls). The new caseCLI logs explain text output keeps line breaks and still escapes valueschecks that text mode prints one console line per JSON line, contains no literal\x0a, and still escapes a raw U+009B inside a value.src/cli/observe.tschange reverted: 0 pass, 1 fail. The received output is the single{\x0a "requestId": ...string.bun run test:changed: 662 pass, 1 skip, 0 fail across 29 files.bun run typecheck: exit 0.bun run privacy:scan: passed.bun run structure:check: passed.bun scripts/file-size-ratchet.ts: passed.git diff --check: clean.bun run testsuite. This is a two-file change (one CLI rendering line plus one test case), andtest:changedcovers the import-connected tests. Full-suite coverage is left to CI.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
logs explainoutput now preserves JSON line breaks and safely escapes terminal control characters. JSON output remains unchanged.