Repository navigation
fix(restore): merge the resume into a pane's own agent launcher (#302) - #303
Merged
amirlehmam merged 1 commit intoOct 19, 2026
Conversation
…#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.
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. |
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 runsopencode2 --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: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-monitoris not opencode, andbash -c "opencode …"is left alone.withClaudeResumenow 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
tests/unit/agent-launcher.test.ts(new): recognition (opencode2, quoted paths, runners), the deliberate non-matches (opencode-monitor,bash -c …,npm run opencode), and merge behaviour including "does not mutate the caller's array".tests/unit/claude-resume-command.test.ts: the launcher cases from Restore appends the resume command after a pane's own agent launcher, and hardcodes the binary name, so it lands inside the TUI or connects to the wrong server #302; the existing "resume LAST for setup-only bases" still passes, asserting the old shape is unchanged there.Known limitations
claude --resume old) would gain a second one; that shape is not produced by wmux and is left alone.Ran
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.