Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .roadmap/features/f-keymap-rename-tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Shipped (#338): `rename-tab`, bound to ⌘⇧I on macOS (Terminal.app's *Edit
Title*) and Ctrl+Shift+I elsewhere, a chord a legacy-encoded terminal program
cannot tell from Ctrl+I (Tab). It opens the field a double-click opens, filled
with the tab's current name, and reports `inert` / `no-context` with no tab
open. Over MCP the field can be opened and abandoned with `escape`, not
committed: `enter` on a rename is #246.
open. Over MCP, `enter` commits the field and `escape` abandons it, using the
same commit message as the widget submit (#246).
9 changes: 3 additions & 6 deletions .roadmap/features/f-mcp-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ PR. It also accumulates rather than stopping at the first
failure: a sweep that names one offender reads as *and the rest are fine*,
which is the assumption that let this one through. Tidy-first prerequisite:
`PaneRename` announced itself as `session-rename` in its own `label()`, in the
MCP reply, and in the tests — the code was the only name that disagreed. Left
open on purpose: `enter` reaches neither rename over MCP, since both commit
through the widget's `on_submit`, which no synthesised key event touches. That
is a missing capability, not a parked surface — `escape` always gets the
keyboard back — so it is a separate ticket (#246) rather than a passenger on
this fix
MCP reply, and in the tests — the code was the only name that disagreed. Both
rename handlers now route `enter` to their existing commit messages, while
the widget submit callbacks remain in place for human input (#246).
16 changes: 6 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,10 @@ carry is modifiers: the event lost its `modifiers` field in #311 as dead
weight, and it comes back as one type shared with `KeyMods` when a caller
needs it, not before.

**Still open.** Two features and one defect: `F-mcp-attach` (#267 — the bridge
is reachable only from a session termherd spawned, so the launcher itself cannot
drive it), the pointer at termherd's own chrome (#301 — the sidebar, tabs and
gutters still have no mouse), and `enter` on the two renames (#246). None of the
three blocks another.
**Still open.** Two features: `F-mcp-attach` (#267 — the bridge is reachable
only from a session termherd spawned, so the launcher itself cannot drive it)
and the pointer at termherd's own chrome (#301 — the sidebar, tabs and gutters
still have no mouse). Neither blocks the other.
The list leaves out the bridge's hardening defects (#284, #293). A third
defect, the copy chord overwriting a mouse-mode program's own clipboard write
with termherd's last copy (#316), is fixed: the shell keeps no copy cache any
Expand Down Expand Up @@ -392,11 +391,8 @@ below: it is honest because `arm_overlay`'s `match` is compiler-checked, so a
new variant cannot slip past it. (**#236**, the sibling defect that left every
session on `starting`, is fixed — see the wait rung above.)

One gap remains and is **not** a variant of this: `enter` reaches neither rename
through MCP, because both commit via the widget's `on_submit`, which a
synthesised key event never touches. That is a missing capability rather than a
parked surface — a caller can always `escape` and start over — so it is tracked
separately, as #246.
Both rename overlays now route `enter` to their existing commit messages,
alongside the widget's `on_submit` path for human input (#246).

**Looks like a contradiction, is not.** `docs/ARCHITECTURE.md` §15 lists an
`mcp` crate as *deferred (Unsure)*. That is a **different feature** —
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ with "it worked".

`escape` leaves **every** prompt, which is what keeps an agent from parking the
app on one it cannot answer; a sidebar rename used to be the exception
([#237]). `enter` confirms the confirmation prompts, but commits neither
rename — those go through a widget callback no synthesised event reaches
([#237]). `enter` confirms confirmation prompts and commits both inline
renames. The rename fields use the same commit path for MCP and widget submit
([#246]).

Three follow-ups remain: `enter` on the renames ([#246]), reaching the bridge
from outside a session termherd spawned — the launcher cannot drive it today
([#267]) — and the pointer at TermHerd's own interface ([#301]): it reaches a
session's terminal, and through it a program reading the mouse, but not yet
the sidebar, tabs or gutters.
Two follow-ups remain: reaching the bridge from outside a session termherd
spawned — the launcher cannot drive it today ([#267]) — and the pointer at
TermHerd's own interface ([#301]): it reaches a session's terminal, and
through it a program reading the mouse, but not yet the sidebar, tabs or
gutters.

### The stdio server (manual)

Expand Down
13 changes: 5 additions & 8 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,8 @@ Shipped (#338): `rename-tab`, bound to ⌘⇧I on macOS (Terminal.app's *Edit
Title*) and Ctrl+Shift+I elsewhere, a chord a legacy-encoded terminal program
cannot tell from Ctrl+I (Tab). It opens the field a double-click opens, filled
with the tab's current name, and reports `inert` / `no-context` with no tab
open. Over MCP the field can be opened and abandoned with `escape`, not
committed: `enter` on a rename is #246.
open. Over MCP, `enter` commits the field and `escape` abandons it, using the
same commit message as the widget submit (#246).

<a id="f-mcp-agent-loop"></a>

Expand Down Expand Up @@ -1451,12 +1451,9 @@ PR. It also accumulates rather than stopping at the first
failure: a sweep that names one offender reads as *and the rest are fine*,
which is the assumption that let this one through. Tidy-first prerequisite:
`PaneRename` announced itself as `session-rename` in its own `label()`, in the
MCP reply, and in the tests — the code was the only name that disagreed. Left
open on purpose: `enter` reaches neither rename over MCP, since both commit
through the widget's `on_submit`, which no synthesised key event touches. That
is a missing capability, not a parked surface — `escape` always gets the
keyboard back — so it is a separate ticket (#246) rather than a passenger on
this fix
MCP reply, and in the tests — the code was the only name that disagreed. Both
rename handlers now route `enter` to their existing commit messages, while
the widget submit callbacks remain in place for human input (#246).

<a id="f-mcp-live-bridge"></a>

Expand Down
38 changes: 38 additions & 0 deletions crates/app/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4578,6 +4578,44 @@ mod key_routing {
);
}

#[test]
fn enter_commits_a_tab_rename_through_the_keyboard_router() {
let (mut shell, _pty) = shell_with_terminal();
let _ = shell.update(Message::StartTabRename(0));
let _ = shell.update(Message::TabRenameInput("new title".to_owned()));

assert_eq!(
press_chord(&mut shell, "enter"),
PressStep::Overlay("tab-rename".to_owned())
);
assert!(shell.keyboard_owner().is_none());
assert_eq!(shell.core.workspace.tabs[0].display_title(), "new title");
}

#[test]
fn enter_commits_a_session_rename_through_the_keyboard_router() {
let (mut shell, _pty) = empty_shell();
let _ = shell.update(Message::StartRename {
session: OPEN_ID.to_owned(),
current: "old title".to_owned(),
});
let _ = shell.update(Message::RenameInput("new title".to_owned()));

assert_eq!(
press_chord(&mut shell, "enter"),
PressStep::Overlay("session-rename".to_owned())
);
assert!(shell.keyboard_owner().is_none());
assert_eq!(
shell
.core
.metadata
.get(OPEN_ID)
.and_then(|meta| meta.title.as_deref()),
Some("new title")
);
}

#[test]
fn every_overlay_that_owns_the_keyboard_can_be_left_from_the_keyboard() {
// The invariant this bug broke, stated once for the whole ladder rather
Expand Down
32 changes: 17 additions & 15 deletions crates/app/src/shell/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,14 @@ impl Shell {
event: &keyboard::Event,
) -> (KeyVerdict, Task<Message>) {
let (verdict, task) = match owner {
KeyboardOwner::TabRename => (None, self.tab_rename_key(event)),
KeyboardOwner::SessionRename => (None, self.session_rename_key(event)),
KeyboardOwner::TabRename => (
None,
self.rename_key(event, Message::CancelTabRename, Message::CommitTabRename),
),
KeyboardOwner::SessionRename => (
None,
self.rename_key(event, Message::CancelRename, Message::CommitRename),
),
KeyboardOwner::Quit => (None, self.quit_confirm_key(event)),
KeyboardOwner::TabClose(index) => (None, self.tab_close_confirm_key(event, index)),
KeyboardOwner::Archive => (None, self.archive_confirm_key(event)),
Expand All @@ -417,21 +423,17 @@ impl Shell {
(verdict.unwrap_or(KeyVerdict::Overlay(owner.label())), task)
}

/// Escape abandons a tab rename; Enter and a blur commit it elsewhere, so
/// every other key is swallowed.
fn tab_rename_key(&mut self, event: &keyboard::Event) -> Task<Message> {
fn rename_key(
&mut self,
event: &keyboard::Event,
cancel: Message,
commit: Message,
) -> Task<Message> {
if is_escape(event) {
return self.update(Message::CancelTabRename);
return self.update(cancel);
}
Task::none()
}

/// Escape abandons a session rename — the outcome a blur already gives it,
/// where a tab rename commits. The field owns every other key: it is a live
/// text input, and Enter reaches it through the widget.
fn session_rename_key(&mut self, event: &keyboard::Event) -> Task<Message> {
if is_escape(event) {
return self.update(Message::CancelRename);
if is_enter(event) {
return self.update(commit);
}
Task::none()
}
Expand Down
18 changes: 6 additions & 12 deletions docs/src/mcp/keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ they are *overlay* keys, bound to no action. Without them an agent that armed a
close confirmation would have no way to answer it, and would park the app until
a human intervened.

The two are not equally complete, and the difference matters to a caller.
**`escape` leaves every prompt** — that is what guarantees an agent can always
back out. **`enter` confirms the confirmation prompts but commits neither
rename**, because both commit through a widget callback no synthesised event
reaches ([#246](https://github.com/Termherd/termherd/issues/246)).
back out. **`enter` confirms confirmation prompts and commits both inline
renames.** Menus and pickers handle it themselves, as described below.

The corollary: **an open overlay consumes an MCP press exactly as it consumes a
keypress.** The step reports which prompt ate it, so a caller learns why its
Expand Down Expand Up @@ -76,14 +74,10 @@ selection, and `copy` runs on it.

- On **`quit-confirm`**, `enter` quits the app — killing every session and the
connection you are speaking over, and dropping a modified doc's edits.
- **`session-rename`** (the sidebar's inline ✎ field) does not commit on
`enter`, and neither does **`tab-rename`**: both commit through the widget's
own submit, which a synthesised key event never reaches. `rename-tab` opens
the tab's field from MCP, but only a human can commit it. `escape` abandons
either — so you can always back out and start over — but committing a rename
over MCP
is a missing capability, tracked as
[#246](https://github.com/Termherd/termherd/issues/246).
- **`session-rename`** (the sidebar's inline ✎ field) and **`tab-rename`** both
commit on `enter`; `escape` abandons either edit. MCP and the widget submit
use the same commit messages. When a rename targets a live Claude session,
committing may open `claude-command-confirm` for `/rename`.
- **`tab-menu`** (opened by `open-tab-menu`, or a human's right-click on a
tab) answers `up`, `down` and `enter` itself, so unlike the renames it is
fully drivable: `enter` closes the menu and runs the selected entry exactly
Expand Down
3 changes: 1 addition & 2 deletions docs/src/mcp/live-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,9 @@ A worked example, from inside a session TermHerd launched:

## What is still open

Three follow-ups, and they are independent of each other:
Two follow-ups, and they are independent of each other:

| Gap | Issue |
| --- | --- |
| `enter` commits neither rename over MCP — see [Driving the keyboard](./keyboard.md). | [#246](https://github.com/Termherd/termherd/issues/246) |
| The bridge is reachable only from a session termherd spawned, so the launcher itself cannot drive it — see [Two surfaces](./index.md). | [#267](https://github.com/Termherd/termherd/issues/267) |
| No pointer at TermHerd's own interface: the sidebar, the tab strip, a split gutter. | [#301](https://github.com/Termherd/termherd/issues/301) |
Loading