Skip to content

fix(cli): preserve attached run output - #46896

Open
rekram1-node wants to merge 1 commit into
devfrom
attach-output
Open

fix(cli): preserve attached run output#46896
rekram1-node wants to merge 1 commit into
devfrom
attach-output

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Issue for this PR

Found during live CLI testing. Related to the local-run fix in #31389.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

run --attach can exit 0 before printing the final answer because the prompt request finishes before its event reader catches up.

After a successful attached request, cancel/drain the event reader and replay missing output from the saved messages for that prompt. Reuse the existing renderer and deduplicate completed parts. This adds one history read per attached prompt/command, but does not depend on receiving an idle event. Local runs and immediate request-error handling stay unchanged.

How did you verify your code works?

  • Subprocess tests cover normal streaming, a connected stream withholding every event, tool/reasoning ordering, resumed sessions, commands, and request errors.
  • bun test test/cli/run/run-process.test.ts --rerun-each 3: 48 passed.
  • bun typecheck, Prettier, and git diff --check passed.
  • Live Anthropic and Bedrock Opus 5 read-tool runs both emitted the exact saved final answer and exactly one final step_finish, using isolated databases.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant