Skip to content

fix(restore): merge the resume into a pane's own agent launcher (#302) - #303

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
Mattheinrichs:fix/302-merge-resume-into-launcher
Oct 19, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
Mattheinrichs:fix/302-merge-resume-into-launcher

Conversation

@Mattheinrichs

Copy link
Copy Markdown
Contributor

Fixes #302.

A pane's startup commands can be setup (nvm use, cd packages/app) or the agent launch itself — a quick-launch profile that runs opencode2 --server https://…. The resume was appended in both cases, on the documented assumption that it is always "setup first, resume last". When the command IS the launcher that inverts:

opencode2 --server https://code.homenode.stream     <- the profile's command
opencode -s ses_ef3c38075ffekagtp702uwPN1k          <- appended by restore

The launcher takes the terminal, so the resume line is read by the agent's TUI: the pane opens on the agent's default session and the text sits in its prompt. The appended line is also hardcoded to the canonical name, so it loses the launcher's flags — here --server https://…, the server the session actually lives on.

What this changes

  • src/renderer/hooks/agent-launcher.ts (new, pure): finds the last startup command that launches a resumable agent. Recognises the canonical names, absolute paths, Windows script extensions, package runners (npx -y opencode, pnpm dlx codex) and the numbered-alias convention (opencode2). Exact match otherwise: opencode-monitor is not opencode, and bash -c "opencode …" is left alone.
  • withClaudeResume now merges the resume into that command when it launches the same agent (opencode2 --server … -s <id>, claude --model sonnet --resume <id>, codex --yolo resume <id>), drops the resume when the pane launches a different agent, and keeps the old append when every command is setup. The once-per-surface guard now spends itself only when something is actually typed, so a skipped surface keeps its handle.

Tests

Known limitations

  • A launcher behind an unrecognised wrapper (a shell script of your own) still falls back to appending, so the TUI-swallowed case can survive there. Merging into a command we cannot identify would mean rewriting somebody else's argv.
  • A startup command that already carries a resume (claude --resume old) would gain a second one; that shape is not produced by wmux and is left alone.

Ran

npx vitest run tests/unit/agent-launcher.test.ts tests/unit/claude-resume-command.test.ts   # 45 passed
npx tsc --noEmit -p tsconfig.json                                                          # clean
npx eslint src/renderer/hooks/agent-launcher.ts src/renderer/hooks/claude-resume-command.ts

The full unit suite in this container has pre-existing environment failures (node-pty native module absent, Windows-path expectations on Linux) that do not touch these files.

…#302)

A pane's startup commands can be setup ("nvm use") or the agent launch
itself — a quick-launch profile that runs `opencode2 --server <url>`. The
resume was appended in both cases, on the assumption it is always "setup
first, resume last". When the command IS the launcher that inverts: the
launcher takes the terminal, so the appended line is read by the agent's
TUI — the pane opens on the default session and the text sits in its
prompt. The appended command is also hardcoded to the canonical name, so
it drops the launcher's flags (here `--server <url>`, the server the
session lives on).

agent-launcher.ts finds the last startup command that launches a resumable
agent: canonical names, paths, Windows script extensions, package runners
(`npx -y opencode`) and the numbered-alias convention (`opencode2`) —
exact match otherwise, so `opencode-monitor` is not opencode. The resume is
merged into that command when it launches the same agent, dropped when it
launches a different one, and appended as before when every command is
setup.
@amirlehmam
amirlehmam merged commit c9e528c into amirlehmam:master Oct 19, 2026
@amirlehmam

Copy link
Copy Markdown
Owner

Merged, thanks @Mattheinrichs — this ships in v2.29.0.

Reviewed and ran the full suite on Windows with #305 merged on top (4808 passing). The narrow recognition is the right call: rewriting argv we can't identify would be the worse failure, and keeping the handle unspent when nothing is typed is a nice touch.

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

Labels

None yet

Projects

None yet

2 participants