From d4f17209a645bc9b870f25b29aca0e5b9efbd5c2 Mon Sep 17 00:00:00 2001 From: tdwd <111124579+tdwd@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:51:45 +0100 Subject: [PATCH 1/3] Accept a version from a claude that printed and exited 0 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. --- docs/architecture.md | 5 +++-- internal/ui/agentinfo.go | 7 +++++-- internal/ui/agentinfo_test.go | 10 ++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 67b204d..ec432e2 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -388,8 +388,9 @@ relative path finds the same file. That check runs as a command off the UI's goroutine, bounded by `versionTimeout`, plus `WaitDelay` for a wrapper's child that still holds the -output pipe. The timeout kills the process it started, not that process's own -children. A failure is shown with the first line `claude` wrote to stderr, and a +output pipe. A process that printed and exited 0 has answered, even when that +child makes the read end in an error. The timeout kills the process it started, +not that process's own children. A failure is shown with the first line `claude` wrote to stderr, and a timeout says so rather than reading as a crash. The answer replaces the notice only if that notice is still the one from the same start, counted by `Model.starts`, because two starts in one directory set identical notices. It diff --git a/internal/ui/agentinfo.go b/internal/ui/agentinfo.go index a71d49a..8bb8a52 100644 --- a/internal/ui/agentinfo.go +++ b/internal/ui/agentinfo.go @@ -110,8 +110,11 @@ func claudeInfo(isClaude bool, agentPath, dir string) string { cmd.Env = agent.ScrubbedEnv() cmd.WaitDelay = versionWaitDelay out, err := cmd.Output() - // A pipe a child still held is not a failure when the version arrived. - if err != nil && !(errors.Is(err, exec.ErrWaitDelay) && len(out) > 0) { + // A process that printed and exited 0 answered, whatever happened to the + // pipe after: a child of it holding stdout open ends the read by WaitDelay + // or by the timeout, and either one reports an error over a good answer. + answered := len(out) > 0 && cmd.ProcessState != nil && cmd.ProcessState.Success() + if err != nil && !answered { reason := err.Error() var exit *exec.ExitError switch { diff --git a/internal/ui/agentinfo_test.go b/internal/ui/agentinfo_test.go index 1a672db..44956a6 100644 --- a/internal/ui/agentinfo_test.go +++ b/internal/ui/agentinfo_test.go @@ -287,3 +287,13 @@ func TestAClaudeFoundOnlyRelativelySaysSo(t *testing.T) { t.Errorf("notice = %q, want it to name the relative PATH entry", notice) } } + +// TestOutputFromAFailedRunIsNotAVersion: a claude that printed and then +// failed did not answer, whatever it printed first. +func TestOutputFromAFailedRunIsNotAVersion(t *testing.T) { + fakeBin(t, map[string]string{"cathode": "#!/bin/sh\nexec /bin/sleep 30\n", + "claude": claudeWith("echo 2.0.9; exit 4")}) + if _, notice := startedWith(t, "cathode"); !strings.Contains(notice, "could not read the version") { + t.Errorf("notice = %q, want the failed run reported", notice) + } +} From bc8b024117501bfc4b78f83daa22db578ac5414c Mon Sep 17 00:00:00 2001 From: tdwd <111124579+tdwd@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:51:45 +0100 Subject: [PATCH 2/3] Switch a session's agent from its edit form, or when it exits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- README.md | 16 +++-- docs/architecture.md | 11 +++- internal/ui/actions.go | 3 +- internal/ui/agentpick.go | 46 ++++++++++++++ internal/ui/agentpick_test.go | 111 ++++++++++++++++++++++++++++++++++ internal/ui/form_test.go | 18 +++--- internal/ui/formfields.go | 17 +++--- internal/ui/formsession.go | 32 ++++++---- internal/ui/keys.go | 4 +- internal/ui/pane.go | 3 + internal/ui/picker.go | 1 + internal/ui/pickerctl.go | 12 ++-- internal/ui/rename.go | 28 +++++++-- internal/ui/runner.go | 16 ++++- internal/ui/sweep_test.go | 15 +++-- 15 files changed, 283 insertions(+), 50 deletions(-) create mode 100644 internal/ui/agentpick.go create mode 100644 internal/ui/agentpick_test.go diff --git a/README.md b/README.md index 69f46be..79162e8 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ the arrows keep working inside `claude`. | `↵` | open / attach | | `n` | new session | | `a` | add project | -| `e` | rename the focused project or session | +| `e` | edit the focused project, or a session's title and agent | | `x` | end session — close and keep the worktree, or delete both. In the session view, `x` on a running agent only stops it, and a second `x` ends the session | | `c` | connect this session to one on another project | | `K` / `J`, or `⇧↑` / `⇧↓` | move the selected session up / down its project's list | @@ -140,8 +140,8 @@ ssh -t 'tmux new -A -s deck deck' `x` and `c` act on the selected session, so they need the sessions column to have focus — `tab` or a click moves it there, and the focused column carries -the accent border. `e` reads the same focus and renames whichever of the two -the cursor is on. `↵` opens from either column. +the accent border. `e` reads the same focus and edits whichever of the two the +cursor is on. `↵` opens from either column. The mouse works on the dashboard. A click on a project or a session puts the cursor and the focus on it, and a second click on the same row opens it, as @@ -169,7 +169,7 @@ its worktree belongs to that project's repository. | `^g K` / `^g J` | move this session up / down its project's list | | `^g` and a number | jump straight to that session | | `^g n` | new session | -| `^g e` | rename this session | +| `^g e` | edit this session: its title and agent | | `^g x` | stop the agent, or end a stopped session as `x` does | | `^g esc` | detach from the pane | | `^g ↵` | attach to the pane | @@ -268,6 +268,14 @@ session remembers what it started, so changing the default never relabels a session that is already running. `-agent` overrides the default for one run and takes any program that talks to a terminal, listed or not. +A session can switch agent later. Its `e` form has the same **Agent** field, and +the new agent runs from the session's next start; one already running keeps +going until `x` stops it. When an agent exits — you quit it, or it crashed — `↵` +on the session opens the agent list on that agent: `↵` again restarts it, and +choosing another starts that one instead and keeps it for the session. The +worktree, branch and title stay the same, and in an isolated session `claude` +picks its conversation back up if you switch back to it. + Only `claude` reports exact turn status, and only `claude` and `cathode` are handed a coordination config. Anything else runs perfectly well in a pane, with status inferred from output and no sibling awareness. diff --git a/docs/architecture.md b/docs/architecture.md index ec432e2..060cf01 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1020,8 +1020,15 @@ every later key went to the agent, which never clears the fault line, so it stayed on screen. The pane says what to do next, because the banner only said what had happened. -`↵` runs `attach`, which already restarts an exited runner rather than -refusing. The hint promises a resumed conversation only when one is coming: +`↵` runs `attach`, which on an exited runner opens the agent list +(`openAgentPicker`) on the agent that exited rather than refusing: `↵` again +restarts it, and another choice starts that one and becomes the session's +agent. Quitting an agent is often the step before trying a different one, and +restarting the same one unasked made that a trip through the edit form. A +session that has not run this time starts straight away, as it always did; +its `e` form switches the agent ahead of a start. The list's rows are the +Agent field's own choices (`agentField`), so the form and the list cannot +offer different programs. The hint promises a resumed conversation only when one is coming: `willResume` is the one predicate `agentArgsFor` reads to decide `--continue`, so the sentence and the argv cannot disagree. diff --git a/internal/ui/actions.go b/internal/ui/actions.go index 199ae13..b7fae63 100644 --- a/internal/ui/actions.go +++ b/internal/ui/actions.go @@ -72,7 +72,8 @@ func (m Model) commitForm() (tea.Model, tea.Cmd) { f.fields[editFieldDescription].value(), ) case formEditSession: - return m.renameSession(f.subject, f.fields[editSessionFieldTitle].value()) + return m.editSession(f.subject, f.fields[editSessionFieldTitle].value(), + f.fields[editSessionFieldAgent].value()) case formNewSession: return m.newSession( f.fields[sessionFieldProject].value(), diff --git a/internal/ui/agentpick.go b/internal/ui/agentpick.go new file mode 100644 index 0000000..a179f82 --- /dev/null +++ b/internal/ui/agentpick.go @@ -0,0 +1,46 @@ +package ui + +// Choosing which agent a session runs when it starts again: the agent list +// as a picker, and starting the one chosen. The session's edit form changes +// the same field ahead of time; formsession.go builds that. + +import ( + tea "github.com/charmbracelet/bubbletea" + + "github.com/tripledownab/deck/internal/store" +) + +// openAgentPicker asks which agent to start a session with, on its current +// one so ↵ ↵ restarts what was running. The rows are the Agent field's own +// choices, so the list and the form cannot offer different programs. +func (m Model) openAgentPicker(sess *store.Session) (tea.Model, tea.Cmd) { + choices := agentField(sess.Agent, "").choices + rows := make([]pickerRow, 0, len(choices)) + for _, c := range choices { + rows = append(rows, pickerRow{id: c.value, label: c.label, desc: c.help}) + } + m.pickerSubject = sess.ID + m.picker = newPicker(pickAgent, "Start "+sessionLabel(*sess)+" with", rows, sess.Agent) + return m, nil +} + +// agentPicked starts the session with the agent chosen, and keeps the choice +// as the session's agent, so the next start runs it too. +// +// It resolves the session from pickerSubject, as endPicked does, so the +// choice lands on the session the list was opened for. A failed save is +// reported and the agent still starts: the user asked for it, and the session +// in memory says what is running. +func (m Model) agentPicked(choice string) (tea.Model, tea.Cmd) { + sess := m.state.Session(m.pickerSubject) + if sess == nil { + return m, nil + } + if sess.Agent != choice { + sess.Agent = choice + if err := m.state.Save(); err != nil { + m.fault = err + } + } + return m.start(sess) +} diff --git a/internal/ui/agentpick_test.go b/internal/ui/agentpick_test.go new file mode 100644 index 0000000..6d27fc6 --- /dev/null +++ b/internal/ui/agentpick_test.go @@ -0,0 +1,111 @@ +package ui + +// Switching a session's agent: ahead of time from its edit form, and from the +// list ↵ opens once its agent has exited. Fake programs on a PATH the test +// owns stand in for the agents, as in agentinfo_test.go. + +import ( + "path/filepath" + "strings" + "testing" + + tea "github.com/charmbracelet/bubbletea" + "github.com/tripledownab/deck/internal/store" +) + +// oneSession is a model on the session view with one session running agent. +func oneSession(t *testing.T, agentCmd string) (Model, *store.Session) { + t.Helper() + t.Setenv("XDG_STATE_HOME", t.TempDir()) + st := &store.State{} + p := st.AddProject(store.Project{Name: "demo", Path: t.TempDir()}) + sess := st.AddSession(store.Session{ProjectID: p.ID, Name: "s", Title: "work", Agent: agentCmd, Dir: t.TempDir()}) + m := sized(New(st, agentCmd, nil), 120, 30) + m.screen = screenSession + t.Cleanup(func() { m.Close() }) + return m, sess +} + +// TestTheEditFormSwitchesTheAgent: saved, and said to wait for the next +// start — with a pointer at x when the old agent is still running. +func TestTheEditFormSwitchesTheAgent(t *testing.T) { + m, sess := oneSession(t, "claude") + + next, _ := m.editSession(sess.ID, "work", "cathode") + m = next.(Model) + saved, err := store.Load() + if err != nil { + t.Fatal(err) + } + if got := saved.Session(sess.ID).Agent; got != "cathode" { + t.Errorf("saved agent = %q, want cathode", got) + } + if !strings.Contains(m.notice, "will start cathode next time") || strings.Contains(m.notice, "x stops") { + t.Errorf("notice = %q, want the switch said to wait for the next start", m.notice) + } + + m.runners[sess.ID] = startAgent(t, sess.Dir, "") + next, _ = m.editSession(sess.ID, "work", "codex") + if notice := next.(Model).notice; !strings.Contains(notice, "x stops the one running now") { + t.Errorf("with an agent running, notice = %q", notice) + } + + next, _ = next.(Model).editSession(sess.ID, "retitled", "codex") + if notice := next.(Model).notice; notice != "renamed to retitled" { + t.Errorf("a title-only edit said %q", notice) + } +} + +// TestPickingAnotherAgentAfterAnExitStartsIt: ↵ on the exited agent opens the +// list on it, and choosing another starts that one and keeps it. +func TestPickingAnotherAgentAfterAnExitStartsIt(t *testing.T) { + m, sess := oneSession(t, "claude") + exited := startAgent(t, sess.Dir, "exit 0") // bash, so before PATH is replaced + waitExited(t, exited) + m.runners[sess.ID] = exited + bin := fakeBin(t, map[string]string{"claude": fakeClaude, "cathode": "#!/bin/sh\nexec /bin/sleep 30\n"}) + + m = sendKey(m, tea.KeyMsg{Type: tea.KeyEnter}) + if m.picker == nil || m.picker.kind != pickAgent || m.picker.selected() != "claude" { + t.Fatalf("↵ on an exited agent did not open the agent list on claude: %+v", m.picker) + } + m = sendKey(m, tea.KeyMsg{Type: tea.KeyDown}) + if m.picker.selected() != "cathode" { + t.Fatalf("the row after claude is %q; the test aims at cathode", m.picker.selected()) + } + m = sendKey(m, tea.KeyMsg{Type: tea.KeyEnter}) + t.Cleanup(func() { m.Close() }) + + r := m.runners[sess.ID] + if r == nil || r == exited || r.Path() != filepath.Join(bin, "cathode") { + t.Fatalf("runner after picking cathode = %v", r) + } + saved, err := store.Load() + if err != nil { + t.Fatal(err) + } + if got := saved.Session(sess.ID).Agent; got != "cathode" { + t.Errorf("saved agent = %q, want the one picked kept", got) + } +} + +// TestEscapingTheAgentListStartsNothing: the list is a question, and esc +// leaves the exited agent and the session's choice as they were. +func TestEscapingTheAgentListStartsNothing(t *testing.T) { + // cathode, not the first row, so a list that opened on its first row + // rather than on the session's agent would show. + m, sess := oneSession(t, "cathode") + exited := startAgent(t, sess.Dir, "exit 0") + waitExited(t, exited) + m.runners[sess.ID] = exited + + m = sendKey(m, tea.KeyMsg{Type: tea.KeyEnter}) + if m.picker == nil || m.picker.selected() != "cathode" { + t.Fatalf("the list did not open on the session's agent: %+v", m.picker) + } + m = sendKey(m, tea.KeyMsg{Type: tea.KeyDown}) + m = sendKey(m, tea.KeyMsg{Type: tea.KeyEsc}) + if m.picker != nil || m.runners[sess.ID] != exited || sess.Agent != "cathode" { + t.Errorf("esc changed something: picker %v, agent %q", m.picker, sess.Agent) + } +} diff --git a/internal/ui/form_test.go b/internal/ui/form_test.go index 047c86b..b7b2e72 100644 --- a/internal/ui/form_test.go +++ b/internal/ui/form_test.go @@ -359,7 +359,7 @@ func TestRenameSessionKeepsTheSameSession(t *testing.T) { m.form = editSessionForm(first) m.listIx = 1 // the cursor moves after the form opens - next, _ := m.renameSession(m.form.subject, "rewrite the lexer") + next, _ := m.editSession(m.form.subject, "rewrite the lexer", first.Agent) got := next.(Model).state if got.Sessions[0].Title != "rewrite the lexer" { @@ -399,7 +399,7 @@ func TestRenameSessionShowsSiblingsTheNewTitle(t *testing.T) { } m := New(st, "bash", nil).WithCoordinator(c) - if _, cmd := m.renameSession(renamed.ID, "rewrite the lexer"); cmd != nil { + if _, cmd := m.editSession(renamed.ID, "rewrite the lexer", renamed.Agent); cmd != nil { t.Fatalf("rename returned a command: %v", cmd) } @@ -531,22 +531,26 @@ func TestRenameInTheSessionView(t *testing.T) { } } -// TestEditSessionFormPrefillsTheTitle pins the one field and the subject. The +// TestEditSessionFormPrefillsTheTitle pins the fields and the subject. The // heading carries the generated name because the title is the field being -// replaced, so it cannot also be what says which session this is. +// replaced, so it cannot also be what says which session this is. The agent +// opens on the session's own, so saving a new title changes nothing else. func TestEditSessionFormPrefillsTheTitle(t *testing.T) { - sess := &store.Session{ID: "s1", Name: "swift-otter-aaaa", Title: "wire up the parser"} + sess := &store.Session{ID: "s1", Name: "swift-otter-aaaa", Title: "wire up the parser", Agent: "cathode"} f := editSessionForm(sess) if f.subject != "s1" { t.Errorf("subject = %q, want the session id", f.subject) } - if len(f.fields) != 1 { - t.Fatalf("fields = %d, want only the title", len(f.fields)) + if len(f.fields) != 2 { + t.Fatalf("fields = %d, want the title and the agent", len(f.fields)) } if got := f.fields[editSessionFieldTitle].value(); got != "wire up the parser" { t.Errorf("title field = %q", got) } + if got := f.fields[editSessionFieldAgent].value(); got != "cathode" { + t.Errorf("agent field = %q, want the session's own agent", got) + } if !strings.Contains(f.title, "swift-otter-aaaa") { t.Errorf("heading = %q, want the generated name in it", f.title) } diff --git a/internal/ui/formfields.go b/internal/ui/formfields.go index ec37459..3c2d421 100644 --- a/internal/ui/formfields.go +++ b/internal/ui/formfields.go @@ -60,21 +60,22 @@ var agentChoices = []choice{ help: "Runs in the pane. No coordination tools, status from pane activity."}, } -// agentField builds the Agent choice, preselected on the one in use. +// agentField builds the Agent choice, preselected on the one in use. help is +// what choosing means where the field appears: the next session's default on +// the new-session form, this session's next start on its edit form. // -// An agent that is not one of the two known ones came from -agent, and is -// offered first: a form that cannot express the state it opened in would -// silently change the agent the moment you submitted it. -func agentField(agent string) field { - f := field{kind: fieldChoice, label: "Agent", - help: "Remembered as the default for the next session."} +// An agent that is not in agentChoices — from -agent, or a hand-edited state +// file — is offered first: a form that cannot express the state it opened in +// would silently change the agent the moment you submitted it. +func agentField(agent, help string) field { + f := field{kind: fieldChoice, label: "Agent", help: help} for i, c := range agentChoices { if c.value == agent { f.choices, f.selected = agentChoices, i return f } } - f.choices = append([]choice{{label: agent, value: agent, help: "From -agent."}}, agentChoices...) + f.choices = append([]choice{{label: agent, value: agent, help: "Not in the list; kept as it is."}}, agentChoices...) return f } diff --git a/internal/ui/formsession.go b/internal/ui/formsession.go index 36a42b4..23edc1c 100644 --- a/internal/ui/formsession.go +++ b/internal/ui/formsession.go @@ -52,7 +52,7 @@ func newSessionForm(projects []choice, selected int, canWorktree bool, agent str {label: "Project directory", value: "cwd", help: "Runs in the repo itself. Simple, but two sessions here fight over the working tree."}, }}, - agentField(agent), + agentField(agent, "Remembered as the default for the next session."), }, } // Start on the title: the project is usually already right, and typing is @@ -77,16 +77,21 @@ func titleField(value string) field { help: "Shown on the sidebar card. Not sent to the agent."} } -// The rename form's only field. Named for the same reason the others are: -// commitForm reads it positionally. -const editSessionFieldTitle = 0 +// The edit form's fields. Named for the same reason the others are: +// commitForm reads them positionally. +const ( + editSessionFieldTitle = iota + editSessionFieldAgent +) -// editSessionForm renames a session that already exists. +// editSessionForm edits a session that already exists: its title and the +// agent it runs. // -// The title is the only field, because it is the only name a session has that -// nothing else is built on. Name and Branch are in the worktree path and in -// git, so editing them here would rename neither and leave both pointing at a -// session that no longer claims them. +// The title is the only name offered, because it is the only one nothing else +// is built on. Name and Branch are in the worktree path and in git, so editing +// them here would rename neither and leave both pointing at a session that no +// longer claims them. The agent is a program to start, not a name anything +// records, so it can change freely; it applies at the agent's next start. // // The generated name is in the heading rather than in a field: it says which // row this form was opened on, which the title alone cannot once it is being @@ -94,10 +99,13 @@ const editSessionFieldTitle = 0 func editSessionForm(sess *store.Session) *form { f := &form{ kind: formEditSession, - title: "Rename " + sess.Name, - hint: "↵ or ^s save · esc cancel", + title: "Edit " + sess.Name, + hint: "tab/↑↓ field · ←/→ choose · ↵ next · ^s save · esc cancel", subject: sess.ID, - fields: []field{titleField(sess.Title)}, + fields: []field{ + titleField(sess.Title), + agentField(sess.Agent, "Takes effect the next time this session's agent starts."), + }, } f.focus(editSessionFieldTitle) return f diff --git a/internal/ui/keys.go b/internal/ui/keys.go index 7fa8b06..e8021f8 100644 --- a/internal/ui/keys.go +++ b/internal/ui/keys.go @@ -67,7 +67,7 @@ func defaultKeys() keyMap { SwitchCol: key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "switch column (dashboard)")), NewSession: key.NewBinding(key.WithKeys("n"), key.WithHelp("n", "new session")), AddProject: key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "add project")), - Rename: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "rename the focused project or session")), + Rename: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "edit the focused project, or a session's title and agent")), Delete: key.NewBinding(key.WithKeys("x"), key.WithHelp("x", "end session")), Connect: key.NewBinding(key.WithKeys("c"), key.WithHelp("c", "connect to a session elsewhere")), Theme: key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "theme")), @@ -77,7 +77,7 @@ func defaultKeys() keyMap { Dashboard: key.NewBinding(key.WithKeys("d"), key.WithHelp("^g d", "dashboard")), Sessions: key.NewBinding(key.WithKeys("s"), key.WithHelp("^g s", "sessions")), NewSessCmd: key.NewBinding(key.WithKeys("n"), key.WithHelp("^g n", "new session")), - RenameCmd: key.NewBinding(key.WithKeys("e"), key.WithHelp("^g e", "rename this session")), + RenameCmd: key.NewBinding(key.WithKeys("e"), key.WithHelp("^g e", "edit this session: title and agent")), StopSessCmd: key.NewBinding(key.WithKeys("x"), key.WithHelp("^g x", "stop the agent, or end a stopped session")), ThemeCmd: key.NewBinding(key.WithKeys("t"), key.WithHelp("^g t", "theme")), HelpCmd: key.NewBinding(key.WithKeys("?"), key.WithHelp("^g ?", "this help")), diff --git a/internal/ui/pane.go b/internal/ui/pane.go index 59ecbb1..637931e 100644 --- a/internal/ui/pane.go +++ b/internal/ui/pane.go @@ -50,10 +50,13 @@ func (m Model) renderPane(width, height int) string { // An exited agent is a dead end without this line. The banner says // what happened; nothing said what to do about it, and the key that // fixes it is the same ↵ the closed-session placeholder advertises. + // ↵ opens the agent list on this agent (attach), so the same key + // restarts it or switches to another. hint := "Press ↵ to start " + sess.Agent + " again" if willResume(sess) { hint += ", resuming the conversation" } + hint += ", or to pick another agent" if gone { hint = "Its worktree is gone. " + goneHint } diff --git a/internal/ui/picker.go b/internal/ui/picker.go index bf76e15..438a87d 100644 --- a/internal/ui/picker.go +++ b/internal/ui/picker.go @@ -20,6 +20,7 @@ const ( pickConnect pickEndSession pickQuit + pickAgent ) // picker is a modal list: a title, rows, a cursor. diff --git a/internal/ui/pickerctl.go b/internal/ui/pickerctl.go index 14c4568..941ad67 100644 --- a/internal/ui/pickerctl.go +++ b/internal/ui/pickerctl.go @@ -90,16 +90,20 @@ func (m Model) openEndSessionPicker(sess *store.Session) (tea.Model, tea.Cmd) { func (m Model) pickerKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { commit, cancel := m.picker.update(msg) - // Connecting previews nothing: a link is a change to the store, and - // applying one as the cursor moves would write a record for every session - // scrolled past. So it acts on commit only, and cancel just closes. - if m.picker.kind == pickConnect { + // Connecting and choosing an agent preview nothing: a link is a change to + // the store, and an agent is a process to start, so acting as the cursor + // moves would write a record or start an agent for every row scrolled + // past. They act on commit only, and cancel just closes. + if kind := m.picker.kind; kind == pickConnect || kind == pickAgent { switch { case cancel: m.picker = nil case commit: id := m.picker.selected() m.picker = nil + if kind == pickAgent { + return m.agentPicked(id) + } return m.connectPicked(id) } return m, nil diff --git a/internal/ui/rename.go b/internal/ui/rename.go index 537a619..ad178a4 100644 --- a/internal/ui/rename.go +++ b/internal/ui/rename.go @@ -1,7 +1,8 @@ package ui // Renaming projects and sessions: from the dashboard, from the session view, -// and by a session's own agent through the title tool. +// and by a session's own agent through the title tool. A session's edit form +// also switches the agent it runs, which is applied here with its title. // Registering a project is projects.go and creating a session is sessions.go; // this is only the second name either gets. @@ -11,6 +12,8 @@ import ( "path/filepath" tea "github.com/charmbracelet/bubbletea" + + "github.com/tripledownab/deck/internal/agent" ) // errSessionGone is setTitle finding no session by that id. A form reports it, @@ -88,16 +91,33 @@ func (m Model) renameProject(id, name, description string) (tea.Model, tea.Cmd) return m, nil } -// renameSession applies the session rename form. +// editSession applies the session edit form: its title, and the agent its +// next start runs. // -// By id rather than by cursor position, for the reason renameProject is. -func (m Model) renameSession(id, title string) (tea.Model, tea.Cmd) { +// By id rather than by cursor position, for the reason renameProject is. The +// agent is set before setTitle saves, so one save writes both. A running agent +// is left running — stopping it is a separate decision with its own key — and +// the notice says the switch waits for the next start. +func (m Model) editSession(id, title, agentCmd string) (tea.Model, tea.Cmd) { + sess := m.state.Session(id) + if sess == nil { + m.formProblem(errSessionGone) + return m, nil + } + switched := sess.Agent != agentCmd + sess.Agent = agentCmd if err := m.setTitle(id, title); err != nil { m.formProblem(err) return m, nil } m.form = nil m.notice = "renamed to " + title + if switched { + m.notice = title + " will start " + agentCmd + " next time" + if r := m.runners[id]; r != nil && r.Status() != agent.Exited { + m.notice += " — x stops the one running now" + } + } return m, nil } diff --git a/internal/ui/runner.go b/internal/ui/runner.go index 909506d..08020e7 100644 --- a/internal/ui/runner.go +++ b/internal/ui/runner.go @@ -9,20 +9,32 @@ import ( "github.com/tripledownab/deck/internal/agent" "github.com/tripledownab/deck/internal/coord" + "github.com/tripledownab/deck/internal/store" ) -// attach starts the agent if it is not running, then hands it the keyboard. +// attach hands the keyboard to the selected session's agent, starting it if +// it has never run. An agent that has exited is asked about first: quitting +// one is often the step before trying another, so ↵ there opens the agent +// list (openAgentPicker), already on the one that exited. func (m Model) attach() (tea.Model, tea.Cmd) { sess := m.currentSession() if sess == nil { return m, nil } - if r, ok := m.runners[sess.ID]; ok && r.Status() != agent.Exited { + if r, ok := m.runners[sess.ID]; ok { + if r.Status() == agent.Exited { + return m.openAgentPicker(sess) + } m.attached = true m.screen = screenSession return m, nil } + return m.start(sess) +} +// start runs a session's agent and hands it the keyboard. An exited runner in +// its place is replaced. +func (m Model) start(sess *store.Session) (tea.Model, tea.Cmd) { w, h := m.paneSize() r, err := agent.Start(agent.Config{ Command: sess.Agent, diff --git a/internal/ui/sweep_test.go b/internal/ui/sweep_test.go index 53e035d..dbc8c4a 100644 --- a/internal/ui/sweep_test.go +++ b/internal/ui/sweep_test.go @@ -143,9 +143,16 @@ func TestExitedAgentReleasesTheKeyboard(t *testing.T) { t.Error("still attached to an agent that exited; every key goes to a dead PTY") } - // And now the chrome key that restarts it actually reaches a handler. + // And now the chrome key that restarts it actually reaches a handler. It + // asks which agent first, on the one that exited, so ↵ ↵ restarts it. next, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter}) - if got := next.(Model).runners[sess.ID]; got == r { + if next.(Model).picker == nil { + t.Fatal("enter on an exited agent did not ask which agent to start") + } + next, _ = next.(Model).Update(tea.KeyMsg{Type: tea.KeyEnter}) + restarted := next.(Model) + t.Cleanup(func() { restarted.Close() }) + if got := restarted.runners[sess.ID]; got == nil || got == r { t.Error("enter did not start a new process; the session is unrecoverable") } } @@ -172,8 +179,8 @@ func TestExitedPaneSaysHowToRestart(t *testing.T) { if !strings.Contains(pane, "the agent exited") { t.Errorf("pane does not report the exit:\n%s", pane) } - if !strings.Contains(pane, "to start bash again") { - t.Errorf("pane does not say how to restart:\n%s", pane) + if !strings.Contains(pane, "to start bash again") || !strings.Contains(pane, "pick another agent") { + t.Errorf("pane does not say how to restart or switch:\n%s", pane) } } From 08e175408f7baa25e16086ac6533850380bfb49d Mon Sep 17 00:00:00 2001 From: tdwd <111124579+tdwd@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:11:57 +0100 Subject: [PATCH 3/3] Label a session by what runs, and keep only a pick that started 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. --- README.md | 17 +++++---- docs/architecture.md | 20 ++++++---- internal/agent/executable.go | 5 +++ internal/ui/agentinfo.go | 18 ++++++--- internal/ui/agentinfo_test.go | 27 ++++++++++++++ internal/ui/agentpick.go | 24 ++++++++---- internal/ui/agentpick_test.go | 70 ++++++++++++++++++++++++++++++++++- internal/ui/chrome.go | 13 +++++-- internal/ui/dashboard.go | 4 +- internal/ui/pane.go | 5 +++ internal/ui/rename.go | 7 +++- 11 files changed, 174 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 79162e8..8f5cb71 100644 --- a/README.md +++ b/README.md @@ -264,17 +264,20 @@ the Agent field with its four choices](assets/deck-new-session.png) The new-session form has an **Agent** field — `claude`, `cathode`, `codex`, `gemini` — and the last choice becomes the default for the next session. Each -session remembers what it started, so changing the default never relabels a -session that is already running. `-agent` overrides the default for one run and +session remembers its own agent, so changing the default never changes a +session that already exists. `-agent` overrides the default for one run and takes any program that talks to a terminal, listed or not. A session can switch agent later. Its `e` form has the same **Agent** field, and the new agent runs from the session's next start; one already running keeps -going until `x` stops it. When an agent exits — you quit it, or it crashed — `↵` -on the session opens the agent list on that agent: `↵` again restarts it, and -choosing another starts that one instead and keeps it for the session. The -worktree, branch and title stay the same, and in an isolated session `claude` -picks its conversation back up if you switch back to it. +going, and keeps its name in the session's bar, until it is stopped. When an +agent exits — you quit it, or it crashed — `↵` on the session opens the agent +list on that agent: `↵` again restarts it, and choosing another starts that one +instead and keeps it for the session, once it has started. The worktree, branch +and title stay the same. Starting `claude` in an isolated session continues the +latest `claude` conversation in that worktree, and cathode's backend writes its +conversations there too, so after a switch from `cathode` that may be the one +cathode was having. Only `claude` reports exact turn status, and only `claude` and `cathode` are handed a coordination config. Anything else runs perfectly well in a pane, with diff --git a/docs/architecture.md b/docs/architecture.md index 060cf01..64c2c16 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -39,10 +39,14 @@ That split is why the agent is a **choice, not a build-time decision**: `claude`, `cathode`, `codex`, `gemini`, or anything else that talks to a terminal works unchanged. -Each session records the program it started (`store.Session.Agent`), and the -new-session form picks it. That is what keeps a running session honestly -labelled after the default changes, and it is why nothing reads the agent from -the model at attach time. `settings.Agent` remembers the last choice as the +Each session records the program it starts (`store.Session.Agent`). The +new-session form picks it, and the session's edit form and the list `↵` opens on +an exited agent change it. It is read when the agent starts, never from the +model's default, which is what keeps one session's program independent of the +next form's choice. What is in the pane is labelled from the runner +(`Runner.Command`), not from the record: a switch made while an agent runs waits +for the next start, and until then the record names the next program and the +runner names the current one. `settings.Agent` remembers the last choice as the default for the next form; `-agent` overrides it for one run and is the way to name a program the form does not list. A session recorded before the field existed is filled in once by `store.Load`, so no reader has to guess. @@ -388,9 +392,11 @@ relative path finds the same file. That check runs as a command off the UI's goroutine, bounded by `versionTimeout`, plus `WaitDelay` for a wrapper's child that still holds the -output pipe. A process that printed and exited 0 has answered, even when that -child makes the read end in an error. The timeout kills the process it started, -not that process's own children. A failure is shown with the first line `claude` wrote to stderr, and a +output pipe. A process that printed and exited 0 has answered (`answered`), +even when the read ends in an error: that child's open pipe, or a timeout that +fires as the process exits, before it is collected. The timeout kills the +process it started, not that process's own children. A failure is shown with +the first line `claude` wrote to stderr, and a timeout says so rather than reading as a crash. The answer replaces the notice only if that notice is still the one from the same start, counted by `Model.starts`, because two starts in one directory set identical notices. It diff --git a/internal/agent/executable.go b/internal/agent/executable.go index 0898c20..63975f0 100644 --- a/internal/agent/executable.go +++ b/internal/agent/executable.go @@ -16,6 +16,11 @@ import ( // Path is the file the agent runs. See Runner.path. func (r *Runner) Path() string { return r.path } +// Command is the command the agent was started with, as given. A session's +// own record says what its next start runs, which a switch can change while +// this process is still the one in the pane. +func (r *Runner) Command() string { return r.cfg.Command } + // checkCommandFile refuses a command named by path that is missing or a // directory, with that reason. exec would refuse it too, but at fork as // "permission denied" for a directory. The path is handed to the kernel as diff --git a/internal/ui/agentinfo.go b/internal/ui/agentinfo.go index 8bb8a52..8586845 100644 --- a/internal/ui/agentinfo.go +++ b/internal/ui/agentinfo.go @@ -14,6 +14,7 @@ package ui import ( "context" "errors" + "os" "os/exec" "path/filepath" "strings" @@ -110,11 +111,7 @@ func claudeInfo(isClaude bool, agentPath, dir string) string { cmd.Env = agent.ScrubbedEnv() cmd.WaitDelay = versionWaitDelay out, err := cmd.Output() - // A process that printed and exited 0 answered, whatever happened to the - // pipe after: a child of it holding stdout open ends the read by WaitDelay - // or by the timeout, and either one reports an error over a good answer. - answered := len(out) > 0 && cmd.ProcessState != nil && cmd.ProcessState.Success() - if err != nil && !answered { + if err != nil && !answered(out, cmd.ProcessState) { reason := err.Error() var exit *exec.ExitError switch { @@ -160,3 +157,14 @@ func printable(s string) string { return r }, s) } + +// answered reports whether a version check that ended in an error answered +// anyway: it printed and exited 0. Two errors arrive over a good answer. A +// child of the process holding stdout open ends the read by WaitDelay. And a +// timeout that fires as the process exits, before Wait has collected it, +// reports a kill though the process had already exited 0 — seen once in +// eight runs of TestAWedgedCheckIsBounded on a loaded machine, and not +// reproduced by an independent run of thirty. +func answered(out []byte, state *os.ProcessState) bool { + return len(out) > 0 && state != nil && state.Success() +} diff --git a/internal/ui/agentinfo_test.go b/internal/ui/agentinfo_test.go index 44956a6..a17a695 100644 --- a/internal/ui/agentinfo_test.go +++ b/internal/ui/agentinfo_test.go @@ -6,6 +6,7 @@ package ui import ( "os" + "os/exec" "path/filepath" "strings" "testing" @@ -297,3 +298,29 @@ func TestOutputFromAFailedRunIsNotAVersion(t *testing.T) { t.Errorf("notice = %q, want the failed run reported", notice) } } + +// TestAnsweredIsTheExitAndTheOutput pins the rule claudeInfo applies when the +// read ends in an error: printed and exited 0 is an answer, and nothing else +// is. Real states, from running a shell that exits each way. +func TestAnsweredIsTheExitAndTheOutput(t *testing.T) { + state := func(code string) *os.ProcessState { + cmd := exec.Command("/bin/sh", "-c", "exit "+code) + _ = cmd.Run() + return cmd.ProcessState + } + ok, failed := state("0"), state("3") + for _, tc := range []struct { + out string + state *os.ProcessState + want bool + }{ + {"2.0.9", ok, true}, + {"2.0.9", failed, false}, + {"", ok, false}, + {"2.0.9", nil, false}, + } { + if got := answered([]byte(tc.out), tc.state); got != tc.want { + t.Errorf("answered(%q, %v) = %v, want %v", tc.out, tc.state, got, tc.want) + } + } +} diff --git a/internal/ui/agentpick.go b/internal/ui/agentpick.go index a179f82..b0c7432 100644 --- a/internal/ui/agentpick.go +++ b/internal/ui/agentpick.go @@ -28,19 +28,27 @@ func (m Model) openAgentPicker(sess *store.Session) (tea.Model, tea.Cmd) { // as the session's agent, so the next start runs it too. // // It resolves the session from pickerSubject, as endPicked does, so the -// choice lands on the session the list was opened for. A failed save is -// reported and the agent still starts: the user asked for it, and the session -// in memory says what is running. +// choice lands on the session the list was opened for. The choice is kept +// only if that agent started: one that is not installed, or a worktree that is +// gone, leaves the session's agent as it was, and start reports why. A save +// that fails after a good start is reported, and the agent keeps running. func (m Model) agentPicked(choice string) (tea.Model, tea.Cmd) { sess := m.state.Session(m.pickerSubject) if sess == nil { return m, nil } - if sess.Agent != choice { - sess.Agent = choice - if err := m.state.Save(); err != nil { - m.fault = err + before, prev := m.runners[sess.ID], sess.Agent + sess.Agent = choice + next, cmd := m.start(sess) + nm := next.(Model) + if r := nm.runners[sess.ID]; r == nil || r == before { + sess.Agent = prev + return nm, cmd + } + if choice != prev { + if err := nm.state.Save(); err != nil { + nm.fault = err } } - return m.start(sess) + return nm, cmd } diff --git a/internal/ui/agentpick_test.go b/internal/ui/agentpick_test.go index 6d27fc6..28f689a 100644 --- a/internal/ui/agentpick_test.go +++ b/internal/ui/agentpick_test.go @@ -40,13 +40,13 @@ func TestTheEditFormSwitchesTheAgent(t *testing.T) { if got := saved.Session(sess.ID).Agent; got != "cathode" { t.Errorf("saved agent = %q, want cathode", got) } - if !strings.Contains(m.notice, "will start cathode next time") || strings.Contains(m.notice, "x stops") { + if !strings.Contains(m.notice, "will start cathode next time") || strings.Contains(m.notice, "keeps running") { t.Errorf("notice = %q, want the switch said to wait for the next start", m.notice) } m.runners[sess.ID] = startAgent(t, sess.Dir, "") next, _ = m.editSession(sess.ID, "work", "codex") - if notice := next.(Model).notice; !strings.Contains(notice, "x stops the one running now") { + if notice := next.(Model).notice; !strings.Contains(notice, "bash keeps running until it is stopped") { t.Errorf("with an agent running, notice = %q", notice) } @@ -109,3 +109,69 @@ func TestEscapingTheAgentListStartsNothing(t *testing.T) { t.Errorf("esc changed something: picker %v, agent %q", m.picker, sess.Agent) } } + +// TestAnExitedAgentIsNotSaidToKeepRunning: an exited runner is still in the +// map, and a notice saying it keeps running would be false. +func TestAnExitedAgentIsNotSaidToKeepRunning(t *testing.T) { + m, sess := oneSession(t, "claude") + exited := startAgent(t, sess.Dir, "exit 0") + waitExited(t, exited) + m.runners[sess.ID] = exited + + next, _ := m.editSession(sess.ID, "work", "codex") + if notice := next.(Model).notice; strings.Contains(notice, "keeps running") { + t.Errorf("notice = %q about an agent that has exited", notice) + } +} + +// TestBothChangesAreSaid: a title and an agent changed together are both +// reported, rather than the agent replacing the rename. +func TestBothChangesAreSaid(t *testing.T) { + m, sess := oneSession(t, "claude") + next, _ := m.editSession(sess.ID, "new title", "codex") + if notice := next.(Model).notice; !strings.Contains(notice, "renamed to new title") || !strings.Contains(notice, "codex") { + t.Errorf("notice = %q, want both the rename and the switch", notice) + } +} + +// TestARunningSessionIsLabelledByWhatRuns: a switch waits for the next start, +// so until then the context bar names the program in the pane, and the +// exited pane does not promise to start the new one "again". +func TestARunningSessionIsLabelledByWhatRuns(t *testing.T) { + m, sess := oneSession(t, "bash") + r := startAgent(t, sess.Dir, "exit 0") + m.runners[sess.ID] = r + next, _ := m.editSession(sess.ID, "work", "codex") + m = next.(Model) + + if bar := m.contextBar(); !strings.Contains(bar, "bash") || strings.Contains(bar, "codex") { + t.Errorf("context bar = %q, want the running bash, not the pending codex", bar) + } + waitExited(t, r) + if pane := m.renderPane(100, 12); strings.Contains(pane, "start codex again") || !strings.Contains(pane, "start codex") { + t.Errorf("exited pane after a switch:\n%s", pane) + } +} + +// TestAPickThatFailsToStartIsNotKept: an agent that is not installed leaves +// the session's agent as it was, so the next ↵ does not offer it as current. +func TestAPickThatFailsToStartIsNotKept(t *testing.T) { + m, sess := oneSession(t, "claude") + exited := startAgent(t, sess.Dir, "exit 0") + waitExited(t, exited) + m.runners[sess.ID] = exited + fakeBin(t, map[string]string{"claude": fakeClaude}) // no codex + + m.pickerSubject = sess.ID + next, _ := m.agentPicked("codex") + m = next.(Model) + if m.fault == nil { + t.Fatal("starting a missing agent reported nothing") + } + if sess.Agent != "claude" { + t.Errorf("session agent = %q after a failed start, want claude kept", sess.Agent) + } + if saved, err := store.Load(); err == nil && saved.Session(sess.ID) != nil && saved.Session(sess.ID).Agent == "codex" { + t.Error("the failed choice was saved") + } +} diff --git a/internal/ui/chrome.go b/internal/ui/chrome.go index 04d0299..71d5d62 100644 --- a/internal/ui/chrome.go +++ b/internal/ui/chrome.go @@ -60,8 +60,15 @@ func (m Model) contextBar() string { left := " " + s.Muted.Render(name+" / ") + s.Title.Render(sess.Name) + // What is in the pane, which is the runner's command until the next start: + // a switch from the edit form waits for that, and labelling the old process + // with the new name would call it something it is not. + agentLabel := sess.Agent + if r := m.runners[sess.ID]; r != nil { + agentLabel = r.Command() + } var right []string - right = append(right, s.Muted.Render(sess.Agent)) + right = append(right, s.Muted.Render(agentLabel)) if r := m.runners[sess.ID]; r != nil { right = append(right, s.Muted.Render(shortDuration(r.Uptime()))) } @@ -93,7 +100,7 @@ func (m Model) commandHint() string { return truncateStyled(line, m.width) } pairs := [][2]string{ - {"d", "dashboard"}, {"j/k", "switch"}, {"K/J", "move"}, {"1…", "jump"}, {"n", "new"}, {"e", "rename"}, + {"d", "dashboard"}, {"j/k", "switch"}, {"K/J", "move"}, {"1…", "jump"}, {"n", "new"}, {"e", "edit"}, {"x", "stop/end"}, {"↵", "attach"}, {"esc", "detach"}, {"?", "help"}, {"q", "quit"}, {"^g", "literal"}, } @@ -120,7 +127,7 @@ func (m Model) sessionFooter() string { if m.attached { return s.Footer.Render(" ^g for commands · ^g d dashboard · ^g j/k switch session · ^g n new · ^g ? help") } - return s.Footer.Render(" ↑/↓ session · ↵ attach · n new · e rename · x stop/end · d dashboard · ? help · q quit") + return s.Footer.Render(" ↑/↓ session · ↵ attach · n new · e edit · x stop/end · d dashboard · ? help · q quit") } // spread puts left and right on one line separated by padding, so the right diff --git a/internal/ui/dashboard.go b/internal/ui/dashboard.go index f049232..33746a6 100644 --- a/internal/ui/dashboard.go +++ b/internal/ui/dashboard.go @@ -94,7 +94,7 @@ func (m Model) dashboardFooter() string { // list they step into the detail column, and saying "section" there was // the footer describing the bug rather than the behaviour. if m.focus == colContent { - return s.Footer.Render(" ↑/↓ session · ←/→ section · tab projects · ↵ open · n new · e rename · x close · ? help · q quit") + return s.Footer.Render(" ↑/↓ session · ←/→ section · tab projects · ↵ open · n new · e edit · x close · ? help · q quit") } - return s.Footer.Render(" ↑/↓ project · tab sessions · ↵ open · n new · a add project · e rename · ? help · q quit") + return s.Footer.Render(" ↑/↓ project · tab sessions · ↵ open · n new · a add project · e edit · ? help · q quit") } diff --git a/internal/ui/pane.go b/internal/ui/pane.go index 637931e..dc2c4f9 100644 --- a/internal/ui/pane.go +++ b/internal/ui/pane.go @@ -52,7 +52,12 @@ func (m Model) renderPane(width, height int) string { // fixes it is the same ↵ the closed-session placeholder advertises. // ↵ opens the agent list on this agent (attach), so the same key // restarts it or switches to another. + // After a switch from the edit form the next start runs another + // program than the one that exited, and "again" would be false. hint := "Press ↵ to start " + sess.Agent + " again" + if r.Command() != sess.Agent { + hint = "Press ↵ to start " + sess.Agent + } if willResume(sess) { hint += ", resuming the conversation" } diff --git a/internal/ui/rename.go b/internal/ui/rename.go index ad178a4..c5ada30 100644 --- a/internal/ui/rename.go +++ b/internal/ui/rename.go @@ -104,7 +104,7 @@ func (m Model) editSession(id, title, agentCmd string) (tea.Model, tea.Cmd) { m.formProblem(errSessionGone) return m, nil } - switched := sess.Agent != agentCmd + switched, renamed := sess.Agent != agentCmd, sess.Title != title sess.Agent = agentCmd if err := m.setTitle(id, title); err != nil { m.formProblem(err) @@ -114,8 +114,11 @@ func (m Model) editSession(id, title, agentCmd string) (tea.Model, tea.Cmd) { m.notice = "renamed to " + title if switched { m.notice = title + " will start " + agentCmd + " next time" + if renamed { + m.notice = "renamed to " + title + "; it will start " + agentCmd + " next time" + } if r := m.runners[id]; r != nil && r.Status() != agent.Exited { - m.notice += " — x stops the one running now" + m.notice += "; " + r.Command() + " keeps running until it is stopped" } } return m, nil