fix: suppress ora spinner when --json is used#960
Conversation
When --json is passed, ora spinners wrote progress text to stderr, which broke JSON parsing for AI agents that combine stdout+stderr. Conditionally skip spinner creation in status, instructions, and templates commands. Closes #957
|
Task completed. I'll start by reviewing the PR changes to understand what was modified. Powered by 1Code |
📝 WalkthroughWalkthroughConditionally disable Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
alfred-openspec
left a comment
There was a problem hiding this comment.
Looks good. This is the right fix surface for #957: skip spinner creation in JSON mode rather than trying to scrub stderr after the fact, and the added tests cover the agent-facing commands that matter. CI is green; the only thing still pending was CodeRabbit when I reviewed.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/workflow/instructions.ts (1)
63-63: Optional cleanup: avoid duplicate spinner stop in throw paths.You can remove the pre-throw
spinner?.stop()calls and rely on the catch block to stop once, which slightly simplifies control flow.Also applies to: 73-73, 92-92
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/workflow/instructions.ts` at line 63, Remove the duplicate pre-throw spinner stops: locate occurrences of "spinner?.stop()" immediately before throwing an error in this file (the instances at the shown location and the other two reported occurrences) and delete those pre-throw calls so that only the catch block performs spinner?.stop(), ensuring the spinner is stopped exactly once; keep the catch/finally spinner stop logic intact (e.g., the existing catch/finally in the surrounding function that currently handles spinner?.stop()).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/commands/workflow/instructions.ts`:
- Line 63: Remove the duplicate pre-throw spinner stops: locate occurrences of
"spinner?.stop()" immediately before throwing an error in this file (the
instances at the shown location and the other two reported occurrences) and
delete those pre-throw calls so that only the catch block performs
spinner?.stop(), ensuring the spinner is stopped exactly once; keep the
catch/finally spinner stop logic intact (e.g., the existing catch/finally in the
surrounding function that currently handles spinner?.stop()).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b9476404-e54b-49f0-b9ac-ccd0331d9152
📒 Files selected for processing (5)
src/commands/workflow/instructions.tssrc/commands/workflow/status.tssrc/commands/workflow/templates.tstest/cli-e2e/basic.test.tstest/commands/artifact-workflow.test.ts
Summary
oraspinner creation when--jsonflag is passed instatus,instructions,instructions apply, andtemplatescommands--jsoncommandsCloses #957
Test plan
openspec status --change <name> --json 2>&1 | jq .parses cleanlyopenspec instructions <artifact> --change <name> --json 2>&1 | jq .parses cleanlyopenspec instructions apply --change <name> --json 2>&1 | jq .parses cleanlyopenspec templates --json 2>&1 | jq .parses cleanlyopenspec list --json 2>&1 | jq .parses cleanlyopenspec schemas --json 2>&1 | jq .parses cleanlybasic.test.ts,artifact-workflow.test.ts)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests