Repository navigation
Implementation: multi-session mecatui window (#2058) - #2104
Draft
jtenniswood wants to merge 14 commits into
Draft
jtenniswood wants to merge 14 commits into
jtenniswood wants to merge 14 commits into
Conversation
…tree identity ADR 0374 Decisions 1-3: CreateSession.new_worktree, create_worktrees capability, worktree-v1 revisions reattached by path, and derived server-created ownership. Adds the remaining #2058 proto fields. Co-authored-by: Mecatl <[email protected]>
ADR 0374 Decision 4: DeleteSession.stop_active (lease-gated, bounded wait) and remove_worktree (server-created, unshared, clean, never --force, branch kept), inventory remove_worktree capability, HTTP optional delete body, and the session_stop_timeout error code. Co-authored-by: Mecatl <[email protected]>
Client half of the ADR 0374 / #2058 interface contract: CreateSessionRequest with NewWorktree (sent as new_worktree) via CreateSessionWith, DeleteSession options (stop_active, remove_worktree) and worktree outcome, and projection of ServerCapabilities.create_worktrees plus the session-inventory remove_worktree capability and reason. Existing callers keep plain-delete behaviour. Co-authored-by: Mecatl <[email protected]>
Implements Scenario 4 of the multi-session mecatui plan (#2058, ADR 0374): ui.NewWindow is the program root and holds one unchanged per-session Model per window session. Session commands are re-tagged (including tea.Batch and tea.Sequence children) so every message returns to its session and background sessions keep draining their Converse streams; Bubble Tea program commands pass through and a session's quit is handled by the window. Input reaches the active session only; window size and terminal theme or capability messages reach every session. Terminal title, status-line source, and lifecycle-hook writes are scoped to the active session, and the window owns the single status-source listener. The rebindable `Sessions` action (default ←) opens the window list on an empty prompt with no overlay or modal; rows show status, title (plus the ADR 0285 handle on duplicates), and worktree branch, with an `o` action and hint for /sessions. Opening a chat from /sessions adds it to the window (or switches to it), a background approval ask badges the footer, and quitting with other running or awaiting sessions asks once. Co-authored-by: Mecatl <[email protected]>
…ndow list Scenarios 5 and 6 of the multi-session window plan (ADR 0374, #2058). In the ← window list, n starts a session on the default placement and w starts one in a fresh server-created worktree (NewWorktree), both through the normal create flow, switching to it. w is shown and live only when the server advertises create_worktrees; a failed create removes its row, returns to the originating session and shows the error in the list. d asks for confirmation and deletes with stop_active, so a running or awaiting session is stopped first; the deleted row closes only its own session model. Deleting the active row switches to the next one, and deleting the last opens a new default session. When the inventory row reports remove_worktree, the confirmation also offers "delete and remove worktree" and explains that ignored files are deleted and the branch is kept. A refusal keeps the row; a post-stop retained worktree is reported as "chat deleted, worktree kept" with the reason in plain words. Co-authored-by: Mecatl <[email protected]>
AC6.3 of the multi-session window plan (ADR 0374, #2058). user-docs/mecatui/sessions.md gains "Work with several sessions in one window": the ← list with its statuses, labels, the /sessions hint and o, n and w new sessions including where server-created worktrees live and which deployments offer them, deletion with d and the worktree-removal rules (server-created, unshared, clean, never forced, branch kept), and the quit confirmation. keybindings.md documents the remappable Sessions action (default left) and the quit confirmation. The AGENTS.md placement bullet and the architecture "Server-owned session placement" section describe new_worktree, worktree-v1 path reattach, and derived ownership. grpc-schema.md is regenerated for the ADR 0374 fields. Co-authored-by: Mecatl <[email protected]>
…d delete body, branch display Panel-review fixes for the multi-session window (#2058): - Inventory no longer runs git per row: PlacementWorktreeRemover gains WorktreeServerCreated, a path-shape-only (Lstat/EvalSymlinks) listing check; WorktreeOwnership (with the git status cleanliness check) runs only at delete time. Hardened git runs with GIT_OPTIONAL_LOCKS=0. - The optional delete/clear/fork JSON body is capped at 16 KiB (413). - The server-generated mecatl/<name> branch is exempt from the display slash ban, so CreateSession/GetSession placement carries it. - keyedMutex is generic; worktree path locks reuse it. - Worktree removal after delete runs cancel-detached and bounded; re-check and removal failures reach the placement diagnostic, path-redacted. - Test git helpers run with a controlled environment (no ambient GIT_*). - Lease positive proofs for stop_active delete. Co-authored-by: Mecatl <[email protected]>
…w, forced-rollback exception For #2058: POST /v1/sessions lists new_worktree and its 412 refusal; the delete, clear, and fork routes document the 16 KiB body cap (413). ADR 0027 gains List 1 row 93 for the mecatui window's per-session models, and row 90, ADR 0374, and deployment-and-hardening note that create-failure rollback is the only forced worktree removal. ADR 0374 maps the stop timeout to HTTP 504 session_stop_timeout. Fix the dangling no-FS sentence in AGENTS.md. Co-authored-by: Mecatl <[email protected]>
… period, old-server delete fallback Panel review of the multi-session window (#2058): - Route untagged messages fail-closed: only terminal input, broadcasts, window messages, and tea.ResumeMsg reach a session; anything else is dropped instead of falling through to the active session. A real tea.Program test proves a background tea.Sequence lands on its session. - Give the host lifecycle hook one window-wide busy period: Start when the first session becomes busy, Stop when the last ends, approvals forwarded for every session. - On a server without create_worktrees (pre stop_active), a refused delete cancels the session's own run and retries a plain delete. - Exercise mouse and focus routing with real messages; cover an awaiting background session in the quit confirmation and the refusal notice being replaced; factor the per-index model update and use slices.Clone. Refs #2058 Co-authored-by: Mecatl <[email protected]>
Refs #2058 Co-authored-by: Mecatl <[email protected]>
- Make the configured-root stale-revision assertion use a revision that is really stale. The pre-commit sibling HEAD is the shared initial commit, which the root's exact-HEAD match legitimately accepts when the root path matches the git worktree listing (Linux CI); macOS hid it via /var symlinks. - Add create_worktrees to the SDK ServerCapabilities descriptor guard. - Drop the link to the ADR deleted on main. Co-authored-by: Mecatl <[email protected]>
jtenniswood
force-pushed
the
impl/tui-multi-session
branch
from
October 6, 2026 14:10
c869781 to
e194491
Compare
The window session list now fills the screen: a header with the default
checkout's label, status filter tabs with counts (tab/shift+tab), a table
of Sessions / Status / Updated, and a details column for the selected
session (last message, placement, model, tokens, latest prompt), stacked
under the table in a narrow terminal. Updated tracks when a session's
status or newest transcript card last changed. The main footer leads with
the session list key ("← sessions") inside the window.
Co-authored-by: Mecatl <[email protected]>
Rules separate the header and tabs, the table, any notice or delete confirmation, and the footer; a vertical rule divides the table from the details column, and rules separate the details' sections. Co-authored-by: Mecatl <[email protected]>
The selected row is a solid highlight bar: bold warning-coloured (yellow) text on the theme's selection background across the table. Details section titles use the primary text colour and their content the muted grey. ctrl+c in the list quits at once (asking first only when other sessions are running or awaiting approval) instead of arming the session's double-press guard; the list footer shows it. Co-authored-by: Mecatl <[email protected]>
This branch was successfully deployed
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.
Summary
Implements the multi-session mecatui window from #2058. One window holds several sessions,
←on an empty prompt opens a session list, sessions can start in a fresh server-created worktree, and sessions can be stopped and deleted from the list, optionally removing their worktree.PlacementBindRequest.NewWorktree) under$XDG_STATE_HOME/mecatl/worktrees/…on branchmecatl/<name>, with a worktree identity that survives commits (Revision: "worktree-v1", reattached by path). Stop-and-delete with optionalremove_worktree(PlacementWorktreeRemover), which never forces and keeps the branch. The only forced removal is create-failure rollback, and it discards only the worktree that the failing create just added.CreateSessionRequest.new_worktree,ServerCapabilities.create_worktrees, andDeleteSession{stop_active, remove_worktree}. HTTP maps a stop timeout to504withsession_stop_timeout.CreateSessionRequest.NewWorktree;DeleteSession(ctx, id, DeleteSessionOptions{StopActive, RemoveWorktree}), with a cancel-then-delete fallback for older servers.NewWindow(Deps)becomes the program root. Each session model gets its own scoped context, status-line source, terminal title and lifecycle hooks, so background sessions can't change what the active one shows. The newSessionskey action (default←) is remappable, and the main footer leads with← sessions.tab/shift+tab), and a table of Sessions / Status / Updated beside a details column for the selected session (last message, placement, model, tokens, latest prompt), with divider lines between sections. The details stack under the table in narrow terminals. The selected row is a yellow bar on the theme's selection background; detail titles use the text colour and their content the muted grey. Updated tracks when a session's status or newest message last changed. List keys:enterswitch,nnew,wworktree,ddelete,oopen saved,escclose, andctrl+cquits at once (asking first when other sessions are active).user-docs/mecatui/sessions.md,keybindings.md, and the deployment hardening notes.Rebased onto current
main. Since #2105 removed ADRs and acceptance plans, the plan commit (ADR 0374 anddocs/acceptance/tui-multi-session.md) and the ADR 0027 inventory rows were dropped. The worktree placement rule is recorded inAGENTS.mdinstead.Issue relationship
Closes #2058
Type of change
Test plan
Baseline checks
task lint): 0 issues.task test): run on macOS. 17 tests fail, and all 17 fail identically on a cleanorigin/mainworktree on the same machine (macOS socket-path bounds, the/var→/private/varsymlink, TLS test key size, and microVM dev bundles), so none comes from this change. Every test in the packages this PR touches passes otherwise.task test:race): not run locally; left to CI.go run ./cmd/mecademo)task docs): 0 broken links or anchors.task site:build): not run locally; left to CI.engine/changes.Also ran
task generate(no drift) and the TypeScript SDK suite (362 tests pass).User-facing change
Press
←on an empty prompt to see every session in the window. You can switch between them without stopping any, start new sessions (optionally in their own worktree), and delete finished ones. Seeuser-docs/mecatui/sessions.md#work-with-several-sessions-in-one-window.Special notes for reviewers
tea.Batch/tea.Sequence. Messages that can't be routed are dropped rather than misdelivered (cmd/mecatui/ui/session_window.go).TestTUIMultiSession_Scenario1_LegacyRevisionReattachespreviously failed on Linux CI because its "stale" revision was the shared initial commit, which is also the root's current HEAD. The test now uses a revision that is really stale. macOS hid the problem because the unresolved/varpath never matched the worktree listing.create_worktreesis added to the SDK descriptor guard but not projected into the SDK's publicServerCapabilities, following themcp_refreshprecedent.git worktree liststill shows it.