Skip to content

Switch a session's agent from its edit form, or when it exits - #32

Open
tdwd wants to merge 3 commits into
mainfrom
session-agent
Open

tdwd wants to merge 3 commits into
mainfrom
session-agent

Conversation

@tdwd

@tdwd tdwd commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

A session's agent was fixed when the session was made.

  • The session's e form (and ^g e) has the Agent field the new-session form uses. The switch applies at the next start; a running agent keeps going, and keeps its name in the session's bar, until it is stopped.
  • When an agent has exited (ctrl+c, a crash), ↵ opens the agent list on that agent: ↵ again restarts it, another choice starts that one and becomes the session's agent — kept only once it has started. A session that has not run yet starts straight away, as before.
  • The list's rows are the Agent field's own choices, so the two cannot offer different programs.

Three commits: a fix to #29's version check (a claude that printed and exited 0 could be reported as giving no answer), the feature, and fixes from an independent review of it.

Checked: make race passes; each guard was removed in turn and a test went red, except the call site of the version rule, whose race cannot be reproduced on demand — the rule itself is tested. Not tried in a real terminal. -agent-args still go to every agent, which a switch makes easier to trip over; that predates this PR.

tdwd added 3 commits November 17, 2026 18:10
A version read could end in an error after claude had printed its
version and exited successfully, and the footer then said the check got
no answer. WaitDelay ends the read when a wrapper's child keeps stdout
open, and was already accepted. A timeout that fires as the process
exits, before Wait has collected it, reports a kill instead. A process
that printed and exited 0 now counts as having answered, whatever ended
the read.

TestAWedgedCheckIsBounded failed once in eight runs here with the
timeout's message; an independent run of thirty did not reproduce it.
A session's agent was fixed when the session was made. The session's e
form now has the Agent field the new-session form uses, and the switch
applies at the agent's next start; one already running keeps going
until x stops it, and the notice says so.

When an agent has exited, ↵ on the session opens the agent list on that
agent instead of restarting it unasked: ↵ again restarts it, and another
choice starts that one and becomes the session's agent. A session that
has not run this time starts straight away, as before. The list's rows
are the Agent field's own choices, so the two cannot offer different
programs.
Review of the agent switch found:
- the session's bar named the agent the next start will run, so after a
  switch from the edit form it labelled the running process with
  another program's name. It now reads Runner.Command, and the exited
  pane no longer says "start codex again" of a program that never ran;
- a pick from the agent list was saved before the agent started, so one
  that was not installed, or a gone worktree, still became the
  session's agent. It is kept only once the agent starts;
- the version rule is now one tested function, answered.

Also: footers say "e edit", a notice keeps the rename when the agent
changes too, and the docs no longer promise that claude resumes its own
conversation after a switch from cathode, whose backend writes to the
same worktree.
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