Skip to content

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

Closed

Description

@Mattheinrichs

What happens

A pane restored from a quick-launch profile whose startup command is the agent launcher comes back like this:

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

The first command takes the terminal, so the second is read by the agent's TUI instead of the shell: the pane opens on the agent's default session, and the resume text sits in its prompt. The session is never resumed.

Two problems, one line

  1. Ordering. withClaudeResume (src/renderer/hooks/claude-resume-command.ts) appends the resume to the surface's own startupCommands, on the documented assumption that those are setup only and that the resume is what launches the agent:

    A quick-launch profile's own commands are setup for the shell (activate a venv, cd somewhere), and claude --resume does not return to the prompt — it takes over the terminal. Anything queued after it would be typed into Claude's input box instead of run by the shell. Setup first, resume last…

    That is right when the commands are setup, and wrong when the pane's command is the launcher — what an agent quick-launch profile produces. Delivery does not change it (env-baked for pwsh, typed elsewhere): the launcher wins the terminal before the next command runs either way.

  2. Identity and flags. The resume is hardcoded per provider as opencode -s <id> / claude --resume <id> / codex resume <id>, ignoring the pane's launcher. In this setup the launcher is opencode2 --server https://code.homenode.stream (an alias/shim), so a resumed pane would run a different binary name and, without --server, connect to the local background service instead of the remote server the session lives on. A resume that loses the launcher's flags opens the wrong session store even when the ordering is right.

Suggested fix

When the pane's own startup command already invokes the same agent, merge the resume into that command instead of appending a new one, keeping its name and flags: opencode2 -s <id> --server <url>, claude --resume <id>, codex resume <id>. Applies to all three providers. If the command cannot be rewritten confidently (a wrapper, npx, a shell function), skipping is better than typing into a TUI.

Environment and evidence

  • wmux 2.28.0, Windows 11, the pane is WSL, the TUI is a client of a remote OpenCode server.
  • The handle was recorded and stamped: wmux agent-state listed ses_ef3c38075ffekagtp702uwPN1k for that surface, and session.json plus the saved/*.json archives carry opencodeSessionId for it (grep -oE '"opencodeSessionId": "ses_[A-Za-z0-9]+"' sessions/session.json sessions/saved/*.json).
  • The two lines above came from a normal close/reopen, with Settings → Workspace → Resume OpenCode sessions on restore on.
  • Related, but independent: the handle reached this pane through the CLI-side plugin half proposed in Resume OpenCode sessions on restore, alongside Claude Code and Codex #290, because a TUI that is a client of a remote server never runs the server-side plugin with a WMUX_SURFACE_ID. The two problems above affect Claude and Codex identically.

Activity

  1. amirlehmam commented on Oct 19, 2026

    @amirlehmam
    Owner

    Fixed by #303 (thanks @Mattheinrichs), released in v2.29.0. When a pane's own startup command launches the same agent, the resume is merged into it and keeps its name and flags (opencode2 --server … -s <id>). When it launches a different agent nothing is typed, and setup-only panes still get the resume appended last.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions