The owner chats with an engine member at its tab, with F3 and B1-B3 (#309, PR 4 of 5 of owner/953-chat) #315

Manually merged
terra merged 0 commits from neptunus/309-engine-chat into main 2026-11-30 18:25:11 +00:00
Member

Refs #309 (was GitHub #953). This is PR 4 of 5 landing Raf's owner/953-chat branch, per Saturnus's review REVIEW_2026-11-30_owner-953-chat.

Raf's 11 commits are cherry-picked unchanged (316575bd, 13dfa7bf, e9702371, 39eb636c, 6e05889a, fc143de2, 9d291fe0, f17041f5, cf0597f2, 3efa423c, 365fcffa → beb92cda..cfe212c5).

  • N1: DECIDED 2026-11-30 "Keep all unasked". 39eb636c stays, so the mesh tools run unasked once a mesh is declared.
  • N2: DECIDED 2026-11-30 "Keep it (Recommended)". fc143de2's /allow-always stays, which overrides the "no allow_always" line of #241's threat model.

The review's required fixes, each with a test that was red first:

  • 25fb24eb B1: a bracketed-paste end marker split across two reads still ends the paste. Before, the tab swallowed every later key, Ctrl-C and Ctrl-D included.
  • 13e6ac9d F3: a running tool's command or title is made safe and one line where it is first read. So no escape, OSC or carriage return reaches the pane through the live line, /tools or a failure line.
  • 13e6ac9d B2: the stream cut and the markdown wrap count the member> start, so no row is wider than the pane.
  • 13e6ac9d B3: the pane edge cuts at the last blank outside a bold, italic or code span, so no word is split and no span shows its markers.

Proof at the tip: typecheck, the whole npm run verify, the whole npm test (through run_the_tests_in_a_namespace_of_their_own.sh) and check:private.

Refs #309 (was GitHub #953). This is PR 4 of 5 landing Raf's owner/953-chat branch, per Saturnus's review REVIEW_2026-11-30_owner-953-chat. Raf's 11 commits are cherry-picked unchanged (316575bd, 13dfa7bf, e9702371, 39eb636c, 6e05889a, fc143de2, 9d291fe0, f17041f5, cf0597f2, 3efa423c, 365fcffa → `beb92cda`..`cfe212c5`). - N1: DECIDED 2026-11-30 "Keep all unasked". 39eb636c stays, so the mesh tools run unasked once a mesh is declared. - N2: DECIDED 2026-11-30 "Keep it (Recommended)". fc143de2's `/allow-always` stays, which overrides the "no allow_always" line of #241's threat model. The review's required fixes, each with a test that was red first: - **`25fb24eb` B1:** a bracketed-paste end marker split across two reads still ends the paste. Before, the tab swallowed every later key, Ctrl-C and Ctrl-D included. - **`13e6ac9d` F3:** a running tool's command or title is made safe and one line where it is first read. So no escape, OSC or carriage return reaches the pane through the live line, `/tools` or a failure line. - **`13e6ac9d` B2:** the stream cut and the markdown wrap count the `member> ` start, so no row is wider than the pane. - **`13e6ac9d` B3:** the pane edge cuts at the last blank outside a bold, italic or code span, so no word is split and no span shows its markers. Proof at the tip: typecheck, the whole `npm run verify`, the whole `npm test` (through run_the_tests_in_a_namespace_of_their_own.sh) and check:private.
A line typed at a martha-engine member's tab is a turn of that member's own
session, recorded on A14 as owner_typed; the member's answer streams below it as
it is written, each tool it runs on a line of its own, and the line being typed
stays at the bottom so the next thing can be queued before the answer ends.
/crew and /crew-refresh are still answered by the launcher, and every other
slash command is refused. Ctrl-C stops the running turn; Ctrl-D on an empty line
leaves and stops the member.

The ACP client offers every update to the launch's chat before its own record
reads it, and the turn queue tells the chat when a turn is queued, started and
done. The old "typed turns are not there yet" refusal is gone.

Drops-test: src/start_an_engine_member/the_owners_lines_at_the_tab.node-test.ts :: #927 part 2: a plain line is refused in one line naming /crew and martha#953, and the launcher is asked nothing
Drops-test: src/start_an_engine_member/start_an_engine_member.node-test.ts :: #927 part 2: the owner's lines are told what they get one at a time, in the order typed, and a line whose answer throws does not stop the next
Drops-test: src/start_an_engine_member/start_an_engine_member.node-test.ts :: #927 part 2 DW3, DW4, DW6: at a running engine member's tab, /crew shows the crew and says to a mate, other lines are refused, and the engine is sent no prompt for any of them
The chat hears each ask as it opens and shows the member, the permission, the
key and the exact `martha answer ... allow|reject` line; a listener that throws
does not take the ask with it. `martha start` no longer writes
`<member> started, pid ...` over the chat's own input line: a start whose tab is
a chat already says the member is up and prints no second line.
A call waiting on the owner no longer sends them to another terminal for
`martha answer`: the chat says `permission for <tool> — type /allow or /reject`,
and the answer there writes the same owner_answers.jsonl record `martha answer`
writes before it is applied. One whose record cannot be written is not applied;
one with nothing waiting says so.
A crew that declares a mesh starts the recorded mesh server; its tools are the
crew's own infrastructure, so they now run unasked by their whole engine names,
as the crew's own tools do. The owner's deny and ask rules still hold them,
under the engine's name or `mcp__macula__<tool>`; a launch with no mesh server
hands no such rule, so a tool of a server it never started is still asked.
The chat now prints the command a waiting shell call would run (or the title of
another tool), so the owner decides on what it does, not on a truncated tool
title. While a call waits, `a`/`allow`/`y`/`yes` and `r`/`reject`/`n`/`no`
answer it as the full `/allow`/`/reject` commands do; with nothing waiting they
are ordinary lines for the member.
The ACP client now advertises the engine's status and label notifications, so
the chat prints the engine's notices and progress, the full command of a tool
call, and a check with the first line of its result. `A` (or `/allow-always`)
answers a waiting call and remembers that exact call for the rest of the launch,
with the same owner_answers record as `/allow`; the owner's settings file is
still what outlives it.

Drops-test: src/speak_acp_to_an_agent/the_acp_client.node-test.ts :: the client declares no file or terminal capability, so the agent asks for neither
The chat's opening line now says /help lists the controls instead of naming
three of them, and `/help` prints the whole set in the owner's words: sending a
line, /crew and /crew-refresh, answering a waiting call (a, r, A and their full
commands), Ctrl-C and Ctrl-D, detaching tmux with `martha attach` to come back,
and `martha stop` for the member or the crew. `/quit` (or `/exit`) leaves and
stops the member, as Ctrl-D does.

Two other lines say where that help is: `martha up` ends by pointing at it in a
member's tab, and `martha help` says it in the `attach` line, beside the command
that takes you there.
The chat reads each line of the member's answer as the markdown the engine
writes: bold, italic, inline code and links are drawn with their markers gone,
headings and bullets are set as the text they mark, a fenced block is indented
under a gutter, and a table is laid out to fit the pane. A line too long for
the pane wraps under the one before, two blank lines are shown as one, and a
table is held until its block ends so its columns are sized once. The raw text
is what the session's record keeps; the styling is added after the text has
been made safe, and every styled run closes its own codes.

A tool is now one line when it ends — what ran, the command when there is one,
and the first line of what it returned, with a check or a cross — instead of a
line when it begins and a bare check later; the tool still running is named on
the live line above the owner's own. The engine sends most tool results as
content blocks, which the chat now reads as the result too, so a check has
something to say. Enter on an empty line is no longer sent as a turn.

The chat is handed the launcher's words for `/crew` and `/crew-refresh`, so its
help names them without the slice importing the host.
A tool's result that the engine sends as JSON is shown as the one thing it says
in a line — a header, a message, or the names it lists — instead of the JSON
itself, and a result too long for the line is cut at a word rather than in the
middle of a token. A command still running is named by its start, so the owner
reads what it is doing rather than the end of its arguments.
A tool that worked is no longer written into the conversation: the live line
names the one running, a failure is shown where it happens with what it was and
why, and /tools lists this launch's tools with the first line each returned. The
engine's progress notices are not the owner's line to read either.

A line typed while a permission waits now says it is held until the answer, so
it cannot vanish into a queue the owner cannot see.
The fake engine appends a request as JSON and the helper reads the file while
the launch is writing it, so a line that is still half-written broke the parse
and the test by timing alone. Only lines that end are read; a partial last line
is not a request yet.
A read that ended partway through ESC[201~ left the marker's first bytes in
the paste and looked for the marker only in the next read, so it was never
seen: the tab took every later key as pasted text, Ctrl-C and Ctrl-D included
(Saturnus's review of owner/953-chat, B1). The marker is now looked for in the
whole paste so far. A test splits it at three places, and across a later read.

Refs #309
F3: a running tool's command or title was kept raw and drawn on the live line
and in /tools and a failure line, so an escape, an OSC or a carriage return in
it reached the owner's pane: a prompt-injected member could clear the screen
or paint a fake ask over the real one. The label is now made safe and one line
(a line end shown as ⏎) where it is first read.

B2: the stream cut and the markdown's wrap width ignored the `member> ` start,
so on 80 columns a `supervisor> ` row was wider than the pane, wrapped, and the
live region was miscounted. The cut now measures the row with its start, and
the markdown is given the pane less what the name takes beyond the
continuation, and one column.

B3: at the pane edge the whole line so far was cut, mid-word, and a bold or
code span it held open showed its markers. The edge now cuts at the last blank
outside a span; a line with none is cut whole as before, and a line Martha's
own text interrupts is still cut whole.

Each has a test that was red first (Saturnus's review of owner/953-chat).

Refs #309
terra referenced this pull request from a commit 2026-11-30 17:29:53 +00:00
terra manually merged commit 13e6ac9d9e into main 2026-11-30 18:25:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha!315
No description provided.