mcp: step lines in small print, with their duration and without the check mark (#8196)

* mcp: step lines end with their duration in small print, without the check mark

* mcp: the whole step line in small print

* mcp: a ! in a step line shows as ǃ, so the whole line stays in small print
This commit is contained in:
Evgeny @ SimpleX Chat authored and GitHub committed 2026-11-14 12:58:50 +00:00
1 parent 159428a973
commit 73483e5f46
7 files changed
+45 -38

No files matched your search

+1 -1
View File
@@ -667,7 +667,7 @@ With the channel, a message from a member of a session's group, other than `User
- Agent: `🤖 Agent: ` and the agent's description;
- another tool: `🔧 TOOL`, and `: ` with the first of its description, query, URL, file path, path, pattern and command that is not blank.
The line is a live message while the step runs. When the step ends, Claude completes it with ✅, with ❌ for a failure or ⏹️ for an interruption, and with the step's duration, such as `💻 Run the tests ✅ 2.0 s`. Claude Code reports the end of a command or an agent run in the background when it is started, so its line is completed with `(in background)`, such as `💻 Run the tests (in background)`; its completion is posted later as the line of its notification. The completed line has no edited mark. A step refused at approval has no end; its line is completed without an outcome when the turn ends, when a prompt starts the next turn, or when the session ends. A line still live 23 hours after its start is completed without an outcome, because SimpleX allows edits of a message for 24 hours; the step's later end is posted as a new line. The text of a step is cut at 200 characters. Tool uses of subagents and of this plugin get no line.
The line is a live message while the step runs. The whole line is in small print. When the step ends, Claude completes it with the step's duration, after ❌ for a failure or ⏹️ for an interruption, such as `!- 💻 Run the tests 2.0 s!`. A `!` in the text of a step is shown as `ǃ`, which looks the same, because `!` would end the small print. Claude Code reports the end of a command or an agent run in the background when it is started, so its line is completed with `(in background)`, such as `!- 💻 Run the tests (in background)!`; its completion is posted later as the line of its notification. The completed line has no edited mark. A step refused at approval has no end; its line is completed without an outcome when the turn ends, when a prompt starts the next turn, or when the session ends. A line still live 23 hours after its start is completed without an outcome, because SimpleX allows edits of a message for 24 hours; the step's later end is posted as a new line. The text of a step is cut at 200 characters. Tool uses of subagents and of this plugin get no line.
- Claude marks the turn's empty live message, its texts and answers, the lines of steps, and the lines of Claude Code's own prompts, of summaries of the context and of model and effort switches as silent. The answer's last message, with its line, is important, so a turn alerts once, at its end. When the line completes a live message or the turn's empty live message, the edit marks it important; SimpleX apps alert for such an edit once they support it. A SimpleX app that supports silent messages shows them without an alert; other apps alert for them as for any message.
- A text too long for one message is posted as several messages, each as long as a message can be, measured as for `send`. The first part of an answer carries the quote. A part without a quote holds up to 14,962 Latin, 7,481 Cyrillic or 4,987 CJK characters. A prompt or an answer over 250,000 characters is cut there and ends with `…`.
- The `reply` tool sends a file to the group at once, without approval, with its text as the caption, under the file rules of `send`. It returns the file's message as `item`. A caption too long for a message with the file's preview is refused with `text: too long for a message with this TYPE; shorten it.`
+1 -1
View File
@@ -205,7 +205,7 @@ In a session started as in step 2 above:
1. At the session start, Claude Code shows `SimpleX MCP: scan this QR code with the SimpleX app and tap Join to supervise your agents in "Claude Control":`, a QR code and the link. Ask Claude which link was shown at the session start. Claude doesn't know it. If Claude Code refuses `plugin:simplex@inline` with the development flag, checks 3, 5, 6, 7, 8 and 21 wait for the published plugin and `plugin:simplex@simplex-chat`.
2. Scan the QR code in the SimpleX app and tap Join. In "Claude Control", tap the invitation to "1 · <folder>" and join it.
3. Send `Reply with the word ready.` in "1 · <folder>". The answer comes from Claude, as a reply to your message. In an app that shows peer types in groups, Claude has the agent placeholder, three dots, and `User` the person placeholder.
4. Type a prompt in the terminal. It appears in the group from `User`, and the answer appears from Claude. Record whether a prompt from the group also appears from `User`, because Claude Code's documentation does not say whether a channel prompt runs the UserPromptSubmit hook. Ask Claude to run `sleep 5` with Bash in the background. When the task ends, its notification does not appear from `User`; Claude posts a line that starts with ✅ instead. Ask Claude to start a background agent that replies with one word, and to schedule a one-time prompt with CronCreate two minutes ahead. Each appears as one line from Claude. While Claude runs a foreground command, type a prompt in the terminal: it appears from `User`. Ask Claude to read a file and run `sleep 12` with Bash. A line from Claude appears for each step when it starts, `📖 Read PATH` and `💻 ...`, shown as live while the step runs, and each is completed with ✅ and its duration, `12 s` for the sleep, without an edited mark. With an app that supports silent messages, the lines, the notes and Claude's texts do not alert, and an answer posted as a new message, with its end line, does.
4. Type a prompt in the terminal. It appears in the group from `User`, and the answer appears from Claude. Record whether a prompt from the group also appears from `User`, because Claude Code's documentation does not say whether a channel prompt runs the UserPromptSubmit hook. Ask Claude to run `sleep 5` with Bash in the background. When the task ends, its notification does not appear from `User`; Claude posts a line that starts with ✅ instead. Ask Claude to start a background agent that replies with one word, and to schedule a one-time prompt with CronCreate two minutes ahead. Each appears as one line from Claude. While Claude runs a foreground command, type a prompt in the terminal: it appears from `User`. Ask Claude to read a file and run `sleep 12` with Bash. A line from Claude appears for each step when it starts, `📖 Read PATH` and `💻 ...`, shown as live while the step runs, all in small print, and each is completed with its duration, `12 s` for the sleep, without ✅ and without an edited mark. With an app that supports silent messages, the lines, the notes and Claude's texts do not alert, and an answer posted as a new message, with its end line, does.
5. Send `Count from 1 to 300, one number per line.` in the group, and at once send `Reply with the word two.` The second prompt waits in Claude Code's queue. Claude quotes the first message in the answer with the numbers, and the second message in the answer `two`. Neither prompt appears from `User`. The hub chooses the quote of each answer by the start times of the Stop and UserPromptSubmit hooks, and this check confirms that. Then reply to Claude's answer of check 3 with `Say it again in capitals.` Claude answers in capitals with the word of check 3, as a reply to your message. Send a photo, and reply to it with `What is in this photo?` In the transcript, the tag of the first reply contains `reply_to_from="Claude"`, and its content starts with `> ` and that answer; the content of the second starts with `> image: ` and the photo's file name.
6. React 👍 to Claude's answer of check 3. Claude answers as a reply to that answer, and `User` posts nothing. In the transcript, the tag has `reply_to` equal to `item`, and its content is `> ` and that answer, with 👍 on the next line. Remove the reaction, and nothing happens. Send `Count from 1 to 300, one number per line.`, and react ❤ to that message while Claude counts. Claude answers the reaction in the next turn, as a reply to that message.
7. Send `//help` in the group. A one-line message that starts with `/` is a command of the group, so Claude replies `Unknown command.`, and the session gets nothing. Send `!git status`. The session gets it as a prompt, and Claude answers it. Claude Code never runs a command from a channel prompt. Claude Code 2.1.319 was checked on 2026-11-08 with a test channel. It ran neither a command nor a shell command from a channel prompt that started with `/` or `!`, and it passed the text to Claude in the `<channel>` tag. After `/model sonnet`, the model was unchanged, and after `!echo`, no file was written. In the code of Claude Code 2.1.322, a channel message is queued as a prompt with `skipSlashCommands` set. Claude may act on such a text with its tools, such as Bash, under the tool-use approval of check 8.
+1 -1
View File
@@ -1184,7 +1184,7 @@ A tool hook sends `step` with `tool_use_id` as `id` ([`turn`, `stepOf`, `stepTex
| Agent | `🤖 Agent: ` and `description` |
| another tool | `🔧 TOOL`, and `: ` with the first of `description`, `query`, `url`, `file_path`, `path`, `pattern` and `command` that is not blank |
At PreToolUse, `step` is `{id, text}`. At PostToolUse and PostToolUseFailure, it is `{id, text: "TEXT OUTCOME DURATION", end: true}`. OUTCOME is ✅ for PostToolUse, ⏹️ for PostToolUseFailure with `is_interrupt` true, and ❌ for another PostToolUseFailure. DURATION, from `duration_ms` rounded to whole milliseconds, is `N ms` below 1 s, and otherwise rounded down: `N.N s` below 10 s, `N s` below 1 min, `M min S s` below 1 h and `H h M min` from 1 h; without `duration_ms` it is left out with its space. The PostToolUse of a tool use whose `run_in_background` is true is `TEXT (in background)`: Claude Code ends such a tool use when it starts the command or the agent, and the completion is reported by a task notification. A tool hook without `tool_use_id` or `tool_name`, with `agent_id`, of a subagent, or of a tool whose name starts with `mcp__plugin_simplex_simplex__` sends nothing. The matcher of the tool hooks is `*`, and the hook skips the plugin's tools: Claude Code 2.1.322 tests a matcher as a JavaScript regular expression locally, and with another engine in a cloud session, which refuses some patterns with `This hook's matcher cannot be tested in a cloud session: it has to be rewritten.` (`uTr`, binary offset 291099155).
At PreToolUse, `step` is `{id, text: "!- TEXT!"}`. At PostToolUse and PostToolUseFailure, it is `{id, text: "!- TEXT OUTCOME DURATION!", end: true}`. Both are in small print; each `!` of TEXT is replaced with `ǃ` (U+01C3), which looks the same, because `!` would end the small print. OUTCOME is left out with its space for PostToolUse, ⏹️ for PostToolUseFailure with `is_interrupt` true, and ❌ for another PostToolUseFailure. DURATION, from `duration_ms` rounded to whole milliseconds, is `N ms` below 1 s, and otherwise rounded down: `N.N s` below 10 s, `N s` below 1 min, `M min S s` below 1 h and `H h M min` from 1 h; without `duration_ms` it is left out with its space. The PostToolUse of a tool use whose `run_in_background` is true is `!- TEXT (in background)!`: Claude Code ends such a tool use when it starts the command or the agent, and the completion is reported by a task notification. A tool hook without `tool_use_id` or `tool_name`, with `agent_id`, of a subagent, or of a tool whose name starts with `mcp__plugin_simplex_simplex__` sends nothing. The matcher of the tool hooks is `*`, and the hook skips the plugin's tools: Claude Code 2.1.322 tests a matcher as a JavaScript regular expression locally, and with another engine in a cloud session, which refuses some patterns with `This hook's matcher cannot be tested in a cloud session: it has to be rewritten.` (`uTr`, binary offset 291099155).
The PostCompact hook reads `type`, `subtype`, `isSidechain`, `timestamp` and `compactMetadata` of the transcript's entries with `"compact_boundary"`, and decodes a tail only when its bytes contain that text. It takes the last entry of type `system` and subtype `compact_boundary` without `isSidechain`, whose `timestamp` is no earlier than 60 s before the hook started and no later than 5 s after it. Claude Code writes that entry during a turn with the records of its next request, and after `/compact` or in an idle session at once, so the hook reads the last 4 MiB of the transcript up to 120 times, 1 s apart. An input with `agent_id`, the compaction of a subagent since Claude Code 2.1.323, is not read, and nothing is sent for it or without such an entry. The note is `⚙️ Context summarised `, then `on request` for `trigger` `manual` and `automatically` otherwise, then `: PRE → POST tokens` when `preTokens` and `postTokens` are numbers, in the compact notation of `Intl.NumberFormat`, such as `968K` ([`eventFields`, `compactionNote`, `recentBoundary`, `compactionReads`, `compactionReadFactor`, `compactionAge`, `compactionSkew`, `compactionTailBytes`, `boundaryMarker`, `tokenCount`](../src/hook.ts)).
+1 -1
View File
@@ -1496,7 +1496,7 @@ sequenceDiagram
N->>N: steps += (id, at, text, the promise of the item's ID)
C->>O: Claude: 💻 Run the tests, live, silent
CC->>HK: PostToolUse {tool_use_id, duration_ms: 2018}
HK->>D: POST /turn {step: {id, text: "💻 Run the tests ✅ 2.0 s", end: true}}
HK->>D: POST /turn {step: {id, text: "!- 💻 Run the tests 2.0 s!", end: true}}
D->>N: turn, steps -= id
N->>C: apiUpdateChatItem #35;G item, the final text, live off
C->>O: the line updated, without an edited mark
+9 -4
View File
@@ -438,10 +438,15 @@ function peerName(origin: Origin): string {
function stepOf({tool_use_id: id, tool_name: tool, agent_id: agent, hook_event_name: event, tool_input: fields = {}, cwd, is_interrupt: interrupted, duration_ms: ms}: TurnInput): Step | undefined {
if (id === undefined || tool === undefined || agent !== undefined || tool.startsWith(pluginTools)) return undefined
const text = shortened(stepText(tool, fields, cwd))
if (event === "PreToolUse") return {id, text}
if (event === "PostToolUse" && fields.run_in_background === true) return {id, text: `${text} (in background)`, end: true}
const outcome = event === "PostToolUse" ? "✅" : interrupted === true ? "⏹️" : "❌"
return {id, text: `${text} ${outcome}${ms === undefined ? "" : ` ${duration(ms)}`}`, end: true}
if (event === "PreToolUse") return {id, text: small(text)}
if (event === "PostToolUse" && fields.run_in_background === true) return {id, text: small(`${text} (in background)`), end: true}
const outcome = event === "PostToolUse" ? "" : interrupted === true ? " ⏹️" : " ❌"
return {id, text: small(`${text}${outcome}${ms === undefined ? "" : ` ${duration(ms)}`}`), end: true}
}
// spec: spec/architecture.md#hook-stepof
function small(text: string): string {
return `!- ${text.replaceAll("!", "ǃ")}!`
}
// spec: spec/architecture.md#hook-stepof
@@ -492,10 +492,10 @@ test("the hooks post a prompt typed in the terminal as User, also the session's
await until(() => attached.length === 6)
expect((attached[5] as {prompt: {text: string}}).prompt.text).toBe("> Tests pass.\n🚀")
const bash = {tool_name: "Bash", tool_input: {command: "npm test", description: "Run the tests"}, tool_use_id: "toolu_1"}
const started = received(alice.chat, message("💻 Run the tests", "Claude"))
const started = received(alice.chat, message("!- 💻 Run the tests!", "Claude"))
await hook({hook_event_name: "PreToolUse", cwd: "/p", ...bash})
expect((await started).chatItem.meta.itemLive).toBe(true)
const ended = updated(alice.chat, inGroup(groupId, ({chatItem}) => chatItem.meta.itemText === "💻 Run the tests ✅ 2.0 s"))
const ended = updated(alice.chat, inGroup(groupId, ({chatItem}) => chatItem.meta.itemText === "!- 💻 Run the tests 2.0 s!"))
await hook({hook_event_name: "PostToolUse", cwd: "/p", ...bash, tool_response: {stdout: "ok"}, duration_ms: 2018})
const {meta: finalized} = (await ended).chatItem
expect([finalized.itemLive, finalized.itemEdited]).toEqual([false, false])
@@ -597,24 +597,26 @@ describe("turn hooks", () => {
await started("TodoWrite", {todos: [{content: "Test", status: "pending"}]})
await started("NotebookEdit", {description: " \n", notebook_path: "/p/app/a.ipynb", url: "https://example.com/a"})
await started("Task", {description: `Review‮ ${"x".repeat(300)}`})
expect(requests[0]).toEqual({method: "POST", route: "/turn", body: {id, pid: 4321, at: 1, effort: "high", step: {id: "toolu_Bash", text: "💻 Run the tests"}}})
await started("Bash", {description: "Say hi!", command: "echo hi"})
expect(requests[0]).toEqual({method: "POST", route: "/turn", body: {id, pid: 4321, at: 1, effort: "high", step: {id: "toolu_Bash", text: "!- 💻 Run the tests!"}}})
expect(steps(requests)).toEqual([
{id: "toolu_Bash", text: "💻 Run the tests"},
{id: "toolu_Bash", text: "💻 git status"},
{id: "toolu_Read", text: "📖 Read src/hook.ts"},
{id: "toolu_Edit", text: "✏️ Edit /etc/hosts"},
{id: "toolu_Write", text: "📝 Write rfcs/2026-09-11-proof-of-work.md"},
{id: "toolu_Read", text: "📖 Read /p/app-old/src/hook.ts"},
{id: "toolu_WebFetch", text: "🌐 Fetch https://spec.torproject.org/hspow-spec/common-protocol.html"},
{id: "toolu_WebSearch", text: '🔎 Search "hs_pow.c" tor source'},
{id: "toolu_Agent", text: "🤖 Agent: Review pass 6 usage stats"},
{id: "toolu_ToolSearch", text: "🔧 ToolSearch: select:Monitor"},
{id: "toolu_Glob", text: "🔍 Glob **/*.ts in src"},
{id: "toolu_Grep", text: "🔍 Grep endSteps in src/hub.ts"},
{id: "toolu_Grep", text: "🔍 Grep TODO"},
{id: "toolu_TodoWrite", text: "🔧 TodoWrite"},
{id: "toolu_NotebookEdit", text: "🔧 NotebookEdit: https://example.com/a"},
{id: "toolu_Task", text: `🔧 Task: Review ${"x".repeat(199 - [..."🔧 Task: Review "].length)}…`},
{id: "toolu_Bash", text: "!- 💻 Run the tests!"},
{id: "toolu_Bash", text: "!- 💻 git status!"},
{id: "toolu_Read", text: "!- 📖 Read src/hook.ts!"},
{id: "toolu_Edit", text: "!- ✏️ Edit /etc/hosts!"},
{id: "toolu_Write", text: "!- 📝 Write rfcs/2026-09-11-proof-of-work.md!"},
{id: "toolu_Read", text: "!- 📖 Read /p/app-old/src/hook.ts!"},
{id: "toolu_WebFetch", text: "!- 🌐 Fetch https://spec.torproject.org/hspow-spec/common-protocol.html!"},
{id: "toolu_WebSearch", text: '!- 🔎 Search "hs_pow.c" tor source!'},
{id: "toolu_Agent", text: "!- 🤖 Agent: Review pass 6 usage stats!"},
{id: "toolu_ToolSearch", text: "!- 🔧 ToolSearch: select:Monitor!"},
{id: "toolu_Glob", text: "!- 🔍 Glob **/*.ts in src!"},
{id: "toolu_Grep", text: "!- 🔍 Grep endSteps in src/hub.ts!"},
{id: "toolu_Grep", text: "!- 🔍 Grep TODO!"},
{id: "toolu_TodoWrite", text: "!- 🔧 TodoWrite!"},
{id: "toolu_NotebookEdit", text: "!- 🔧 NotebookEdit: https://example.com/a!"},
{id: "toolu_Task", text: `!- 🔧 Task: Review ${"x".repeat(199 - [..."🔧 Task: Review "].length)}…!`},
{id: "toolu_Bash", text: "!- 💻 Say hiǃ!"},
])
})
@@ -640,17 +642,17 @@ describe("turn hooks", () => {
await turn(JSON.stringify({session_id: id, hook_event_name: "PreToolUse", tool_input: bash, tool_use_id: "toolu_1"}), {}, client, 0, 1)
await turn(JSON.stringify({session_id: id, hook_event_name: "PostToolUse", tool_name: "Bash", tool_input: bash, duration_ms: 5}), {}, client, 0, 1)
expect(steps(requests)).toEqual([
{id: "toolu_Bash", text: "💻 Run the tests ✅ 2.0 s", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ❌ 39 ms", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ⏹️ 4 min 12 s", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ✅ 42 s", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ✅ 1 h 5 min", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ✅", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ✅ 42 ms", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ✅ 2.0 s", end: true},
{id: "toolu_Bash", text: "💻 Run the tests (in background)", end: true},
{id: "toolu_Agent", text: "🤖 Agent: Review (in background)", end: true},
{id: "toolu_Bash", text: "💻 Run the tests ❌ 12 ms", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests 2.0 s!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests ❌ 39 ms!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests ⏹️ 4 min 12 s!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests 42 s!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests 1 h 5 min!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests 42 ms!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests 2.0 s!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests (in background)!", end: true},
{id: "toolu_Agent", text: "!- 🤖 Agent: Review (in background)!", end: true},
{id: "toolu_Bash", text: "!- 💻 Run the tests ❌ 12 ms!", end: true},
])
expect(ensured()).toBe(11)
})