Skip to content

fix(cli): do not re-run a handoff when the TUI restarts after an update - #1178

Draft
sosidudku1 wants to merge 1 commit into
mainfrom
fix/ato-1413-handoff-once
Draft

sosidudku1 wants to merge 1 commit into
mainfrom
fix/ato-1413-handoff-once

Conversation

@sosidudku1

Copy link
Copy Markdown
Collaborator

Careful tier: touches logic outside the UI, please review closely.

What

After a self-update, the terminal restarts itself as atomic-agent tui with the TUI's own arguments, instead of replaying the original command line. --session is kept, so it lands back on the same chat. --send is dropped, since that message was already sent.

New pure helper selfUpdateRelaunchArgs in src/tui/tui-args.ts, used by the restart block in src/tui/tui-command.ts.

Why

atomic-agent handoff opens the TUI in the same process. The restart after an update replayed process.argv (handoff --from ...), so the handoff ran a second time: the transcript was imported again and a second identical continuation chat appeared. A plain tui --send X had the same flaw and sent X twice.

How it was verified

Not yet checked on the second Mac: this draft waits for one combined build, test, smoke and e2e run together with the other open fixes.

Static checks so far:

  • New cases in src/tui/tui-args.test.ts (handoff argv on plain node and SEA, plain tui launch with a dash-led value). On the old code the relaunch args would be handoff --from claude, so they fail.
  • Read-only review of every entry path (bare launch, tui, handoff), the value-flag list against parseTuiArgs, and the timing of --send versus the restart.
  • Scope guard and attribution check: clean.

Known narrow edge: if the turn is aborted before it was ever dispatched (still waiting for a local model switch at restart time), the continuation prompt is not re-sent. Much rarer than the duplicate chat it replaces.

atag handoff opens the TUI in the same process, so the post-update
restart replayed process.argv ("handoff --from ...") and imported the
transcript again as a second identical chat. Relaunch as `tui` with the
TUI's own args instead, keep --session so it lands on the same chat,
and drop --send since that message was already sent.

This branch has not been deployed

No deployments
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