mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-22 07:58:02 +00:00
mcp: session states coloured by what they need, green for working (#8265)
* mcp: session states in the colours of what they need: green working, orange waiting in the chat, red idle * mcp: the space after waiting for you in the tests * mcp: a session with a background command shows working in the background
This commit is contained in:
1 parent
e283e5f3d4
commit
b5ee352c8f
7 files changed
+42
-39
No files matched your search
@@ -576,18 +576,20 @@ Only you see this link: it never enters Claude's context or tool results. Scan t
|
||||
After the first owner joins, Claude posts the list of sessions in the Main group, after its greeting:
|
||||
|
||||
```
|
||||
🟠 3 · simplex-chat: working
|
||||
🔵 6 · website: waiting for you, 2 approvals
|
||||
🔵 7 · docs: waiting for you in Claude Code
|
||||
🟢 8 · app: idle
|
||||
🟢 3 · simplex-chat: working
|
||||
🟠 6 · website: waiting for you, 2 approvals
|
||||
⛔️ 7 · docs: waiting for you in Claude Code
|
||||
🔴 8 · app: idle
|
||||
⚙️ 9 · api: working in the background
|
||||
⚪ Not running: 5 · bio, 4 · notes, 2 · openclaw, 1 · first
|
||||
```
|
||||
|
||||
- A session is running while its Claude Code runs, or while cards wait for a decision in its group. Each running session has a line, by number:
|
||||
- `🔵 N · NAME: waiting for you, K approvals`: K cards wait in the session's group. A tool-use card counts only while Claude Code shows its permission dialog, or while Claude Code's state can't be read.
|
||||
- `🔵 N · NAME: waiting for you in Claude Code`: Claude Code waits for an answer in its own window, such as a dialog.
|
||||
- `🟠 N · NAME: working`: Claude Code works on a turn, or a subagent works for it.
|
||||
- `🟢 N · NAME: idle`: Claude Code waits for the next prompt, also while a background command runs.
|
||||
- A session is running while its Claude Code runs, or while cards wait for a decision in its group. Each running session has a line, by number. Green is the state to keep:
|
||||
- `🟢 N · NAME: working`: Claude Code works on a turn, or a subagent works for it.
|
||||
- `🟠 N · NAME: waiting for you, K approvals`: K cards wait in the session's group, for a decision in the chat. A tool-use card counts only while Claude Code shows its permission dialog, or while Claude Code's state can't be read.
|
||||
- `⛔️ N · NAME: waiting for you in Claude Code`: Claude Code waits for an answer in its own window, such as a dialog, which the chat can't give.
|
||||
- `⚙️ N · NAME: working in the background`: Claude Code waits for the next prompt while a background command runs. The command's end starts a turn without a prompt.
|
||||
- `🔴 N · NAME: idle`: Claude Code waits for the next prompt, and nothing runs.
|
||||
- `▶️ N · NAME: running`: Claude Code's state can't be read.
|
||||
- The last line names every other session of the data folder, newest first. Without any session, the list is `No sessions.`
|
||||
- The states are Claude Code's own: the plugin reads them from Claude Code's record of its process, `sessions/PID.json` in `CLAUDE_CONFIG_DIR` or `~/.claude`.
|
||||
|
||||
@@ -245,7 +245,7 @@ In a session started as in step 2 above:
|
||||
- The plugin's folder had no `node_modules/.package-lock.json`.
|
||||
- With the same keys in `.claude/settings.json` of the folder, and without `--settings`, the run had no tool of the plugin.
|
||||
19. Start Claude Code as in step 2 with an empty data folder and a machine name: `SIMPLEX_MCP_HOME=/tmp/simplex-mcp-fresh SIMPLEX_MCP_MACHINE=laptop claude --plugin-dir /tmp/simplex-plugin --dangerously-load-development-channels plugin:simplex@inline`. Exit it before the QR code shows. Start it again the same way. The QR code shows within seconds, for the group "Claude Control - laptop". Stop that service: `kill $(cat /tmp/simplex-mcp-fresh/service.lock)`.
|
||||
20. With the session of step 2 running and a second session started as in step 2 in another folder, the Main group shows the list of sessions, one line for each. Ask Claude to run `sleep 20` with Bash: its line shows 🟠 working. Send `Run ls with Bash.` in its group: the line shows 🔵 waiting for you, 1 approval; tap `/approve N`, and it shows 🟠 working, then 🟢 idle when the turn ends. Press Esc during a turn: the line shows 🟢 idle within 2 seconds, although Claude Code runs no Stop hook. Ask Claude to ask you a question with AskUserQuestion: the line shows 🔵 waiting for you in Claude Code. Exit the second Claude Code: its session moves into the last line, `⚪ Not running: `. `/sessions` replies with the same text.
|
||||
20. With the session of step 2 running and a second session started as in step 2 in another folder, the Main group shows the list of sessions, one line for each. Ask Claude to run `sleep 20` with Bash: its line shows 🟢 working. Send `Run ls with Bash.` in its group: the line shows 🟠 waiting for you, 1 approval; tap `/approve N`, and it shows 🟢 working, then 🔴 idle when the turn ends. Press Esc during a turn: the line shows 🔴 idle within 2 seconds, although Claude Code runs no Stop hook. Ask Claude to run `sleep 60` with Bash in the background: after its turn ends, the line shows ⚙️ working in the background until the command ends. Ask Claude to ask you a question with AskUserQuestion: the line shows ⛔️ waiting for you in Claude Code. Exit the second Claude Code: its session moves into the last line, `⚪ Not running: `. `/sessions` replies with the same text.
|
||||
21. Send `Read README.md, say what you are doing before each step, and then summarize it in 30 lines.` in the group. An empty message from Claude appears at once, as a reply to your message, with typing dots. Claude's first remark or step fills it, and each later remark and the answer appear from their first line, growing by whole lines, at most every 3 seconds. The steps' lines appear between them. Each message ends without an edited mark. The answer's message ends with `Done in`, the turn's time and tokens in small print, and the chat list shows the answer. In the terminal, Claude's text appears by whole lines.
|
||||
22. Send `Name a fruit.` in the group, and after the answer edit that message to `Name a vegetable.` Claude answers with a vegetable, as a reply to your message. In the transcript, the second tag has the same `item` as the first and `edited="true"`. Edit it into `/list`, and nothing happens. Turn on live mode in the app, type `Name a colour.` slowly, and send it. Claude answers once, after you send it, and the transcript has one tag with `Name a colour.`
|
||||
23. Stop the service: `kill $(cat /tmp/simplex-mcp-test/service.lock)`.
|
||||
@@ -735,10 +735,11 @@ Posts:
|
||||
|
||||
| Part | Text | Condition |
|
||||
|---|---|---|
|
||||
| a running session | `🔵 N · NAME: waiting for you, K approvals`, `1 approval` for one | K pending cards of the session, without those cancelled by a stop. A tool-use card counts while Claude Code's state is `waiting` or unknown |
|
||||
| | `🔵 N · NAME: waiting for you in Claude Code` | no card; attached; state `waiting` |
|
||||
| | `🟠 N · NAME: working` | no card; attached; state `busy` |
|
||||
| | `🟢 N · NAME: idle` | no card; attached; state `idle` or `shell` |
|
||||
| a running session | `🟠 N · NAME: waiting for you, K approvals`, `1 approval` for one | K pending cards of the session, without those cancelled by a stop. A tool-use card counts while Claude Code's state is `waiting` or unknown |
|
||||
| | `⛔️ N · NAME: waiting for you in Claude Code` | no card; attached; state `waiting` |
|
||||
| | `🟢 N · NAME: working` | no card; attached; state `busy` |
|
||||
| | `🔴 N · NAME: idle` | no card; attached; state `idle` |
|
||||
| | `⚙️ N · NAME: working in the background` | no card; attached; state `shell` |
|
||||
| | `▶️ N · NAME: running` | no card; attached; no record path, no record file, or another state |
|
||||
| the other sessions | `⚪ Not running: N · NAME, N · NAME, K older sessions`, newest first | sessions without a card and without an attachment, or all of them while the service stops |
|
||||
| no session | `No sessions.` | |
|
||||
|
||||
@@ -1691,18 +1691,18 @@ sequenceDiagram
|
||||
CC->>R: status busy
|
||||
D->>N: every 2 s: readRecord, the session attached
|
||||
N->>R: read status
|
||||
D->>M: showList: 🟠 N · NAME: working, then the not running line
|
||||
D->>M: showList: 🟢 N · NAME: working, then the not running line
|
||||
M->>C: no list yet, an owner in the group: apiSendMessages #35;M, priority -1
|
||||
M->>C: apiSetGroupCustomData #35;M {simplexMcpMain: true, simplexMcpList: {item, at}}
|
||||
C->>O: the list
|
||||
CC->>R: status waiting, a permission dialog
|
||||
CC->>S: permission_request
|
||||
S->>D: POST /permission
|
||||
D->>M: showList: 🔵 N · NAME: waiting for you, 1 approval
|
||||
D->>M: showList: 🟠 N · NAME: waiting for you, 1 approval
|
||||
M->>C: apiUpdateChatItem #35;M item
|
||||
C->>O: the list edited, no alert
|
||||
CC->>R: status idle
|
||||
D->>M: showList: 🟢 N · NAME: idle
|
||||
D->>M: showList: 🔴 N · NAME: idle
|
||||
M->>C: apiUpdateChatItem #35;M item
|
||||
Note over D,M: the list 23 hours old, or its edit refused
|
||||
M->>C: apiSendMessages #35;M the new list, priority -1, and its item saved
|
||||
|
||||
@@ -65,10 +65,10 @@ const listCheckMs = 2_000
|
||||
const recordReadMs = 1_000
|
||||
// spec: spec/api.md#list-of-sessions
|
||||
const claudeStates = new Map<string, [string, string]>([
|
||||
["waiting", ["🔵", "waiting for you in Claude Code"]],
|
||||
["busy", ["🟠", "working"]],
|
||||
["idle", ["🟢", "idle"]],
|
||||
["shell", ["🟢", "idle"]],
|
||||
["waiting", ["⛔️", "waiting for you in Claude Code"]],
|
||||
["busy", ["🟢", "working"]],
|
||||
["idle", ["🔴", "idle"]],
|
||||
["shell", ["⚙️", "working in the background"]],
|
||||
])
|
||||
// spec: spec/api.md#list-of-sessions
|
||||
const unknownState: [string, string] = ["▶️", "running"]
|
||||
@@ -263,7 +263,7 @@ export class Session {
|
||||
const state = claudeStates.get(this.claudeStatus ?? "")
|
||||
const dialog = state === undefined || this.claudeStatus === "waiting"
|
||||
const cards = this.actions.pending().filter(({tool, interrupted}) => !interrupted && (dialog || tool !== "permission")).length
|
||||
if (cards > 0) return `🔵 ${this.displayName}: waiting for you, ${cards} approval${cards === 1 ? "" : "s"}`
|
||||
if (cards > 0) return `🟠 ${this.displayName}: waiting for you, ${cards} approval${cards === 1 ? "" : "s"}`
|
||||
if (!this.attached) return undefined
|
||||
const [emoji, text] = state ?? unknownState
|
||||
return `${emoji} ${this.displayName}: ${text}`
|
||||
|
||||
@@ -255,17 +255,17 @@ test("the Main group shows every session in one list, the running ones with thei
|
||||
await until(() => attached.length === 1)
|
||||
const owner = await client.request<OwnerState>("GET", "/link")
|
||||
const invitations = joinSessionGroups(alice, ["1 · one", "2 · two"])
|
||||
const working = received(alice.chat, ({chatItem}) => chatItem.meta.itemText === "🟠 1 · one: working\n⚪ Not running: 2 · two")
|
||||
const working = received(alice.chat, ({chatItem}) => chatItem.meta.itemText === "🟢 1 · one: working\n⚪ Not running: 2 · two")
|
||||
const mainGroupId = await joinByLink(alice, owner.link!)
|
||||
const list = await working
|
||||
expect(list.chatInfo).toMatchObject({type: "group", groupInfo: {groupId: mainGroupId}})
|
||||
await invitations
|
||||
const edited = (text: string): Promise<T.AChatItem> => updated(alice.chat, inGroup(mainGroupId, ({chatItem}) => chatItem.meta.itemId === list.chatItem.meta.itemId && chatItem.meta.itemText === text))
|
||||
const waiting = edited("🔵 1 · one: waiting for you, 1 approval\n⚪ Not running: 2 · two")
|
||||
const waiting = edited("🟠 1 · one: waiting for you, 1 approval\n⚪ Not running: 2 · two")
|
||||
writeFileSync(record, JSON.stringify({status: "waiting", waitingFor: "permission prompt"}))
|
||||
await client.request("POST", "/permission", {id: one, requestId: "abcde", toolName: "Bash", description: "Run shell command", inputPreview: "ls"})
|
||||
await waiting
|
||||
const idle = edited("🟢 1 · one: idle\n⚪ Not running: 2 · two")
|
||||
const idle = edited("🔴 1 · one: idle\n⚪ Not running: 2 · two")
|
||||
writeFileSync(record, JSON.stringify({status: "idle"}))
|
||||
await idle
|
||||
const ended = edited("⚪ Not running: 2 · two, 1 · one")
|
||||
|
||||
@@ -2606,7 +2606,7 @@ describe("Main group", () => {
|
||||
expect(chat.invitations.at(-1)).toEqual({groupId: 21, viaGroupId: 10, groupMemberId: 3, memberRole: T.GroupMemberRole.Owner})
|
||||
})
|
||||
|
||||
it("posts the list of every session after the greeting, silent, and edits it as Claude Code's records and the cards change: working, waiting for you, waiting for you in Claude Code, idle, and the ⚪ line after an exit", async () => {
|
||||
it("posts the list of every session after the greeting, silent, and edits it as Claude Code's records and the cards change: working, waiting for you, waiting for you in Claude Code, idle, working in the background, and the ⚪ line after an exit", async () => {
|
||||
const chat = new FakeChat()
|
||||
const hub = await hubWith(chat, [self])
|
||||
const one = await openSession(hub, id1, stored(1, "one"))
|
||||
@@ -2631,15 +2631,15 @@ describe("Main group", () => {
|
||||
await hub.showSessions()
|
||||
return chat.updates.length === edits ? undefined : chat.updates.at(-1)!.text
|
||||
}
|
||||
expect(await shows("busy")).toBe("🟠 1 · one: working\n⚪ Not running: 2 · two")
|
||||
expect(await shows("busy")).toBe("🟢 1 · one: working\n⚪ Not running: 2 · two")
|
||||
expect(chat.updates.at(-1)).toMatchObject({chatId: 10, itemId: list})
|
||||
expect(await shows("busy")).toBeUndefined()
|
||||
expect(await shows("waiting")).toBe("🔵 1 · one: waiting for you in Claude Code\n⚪ Not running: 2 · two")
|
||||
expect(await shows("waiting")).toBe("⛔️ 1 · one: waiting for you in Claude Code\n⚪ Not running: 2 · two")
|
||||
one.permission({id: id1, requestId: "abcde", toolName: "Bash", description: "Run shell command", inputPreview: "ls"})
|
||||
expect(await shows("waiting")).toBe("🔵 1 · one: waiting for you, 1 approval\n⚪ Not running: 2 · two")
|
||||
expect(await shows("busy")).toBe("🟠 1 · one: working\n⚪ Not running: 2 · two")
|
||||
expect(await shows("idle")).toBe("🟢 1 · one: idle\n⚪ Not running: 2 · two")
|
||||
expect(await shows("shell")).toBeUndefined()
|
||||
expect(await shows("waiting")).toBe("🟠 1 · one: waiting for you, 1 approval\n⚪ Not running: 2 · two")
|
||||
expect(await shows("busy")).toBe("🟢 1 · one: working\n⚪ Not running: 2 · two")
|
||||
expect(await shows("idle")).toBe("🔴 1 · one: idle\n⚪ Not running: 2 · two")
|
||||
expect(await shows("shell")).toBe("⚙️ 1 · one: working in the background\n⚪ Not running: 2 · two")
|
||||
one.endPermissions()
|
||||
one.onLine = undefined
|
||||
expect(await shows("idle")).toBe("⚪ Not running: 2 · two, 1 · one")
|
||||
@@ -2656,18 +2656,18 @@ describe("Main group", () => {
|
||||
one.onLine = () => undefined
|
||||
one.permission({id: id1, requestId: "abcde", toolName: "Bash", description: "Run shell command", inputPreview: "ls"})
|
||||
two.requestMode("host")
|
||||
expect(hub.sessionsText()).toBe("🔵 1 · one: waiting for you, 1 approval\n🔵 2 · two: waiting for you, 1 approval")
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: waiting for you, 1 approval\n🟠 2 · two: waiting for you, 1 approval")
|
||||
one.record = join(root, "claude-1.json")
|
||||
writeFileSync(one.record, JSON.stringify({status: "busy"}))
|
||||
await hub.showSessions()
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: working\n🔵 2 · two: waiting for you, 1 approval")
|
||||
expect(hub.sessionsText()).toBe("🟢 1 · one: working\n🟠 2 · two: waiting for you, 1 approval")
|
||||
writeFileSync(one.record, JSON.stringify({status: "compacting"}))
|
||||
await hub.showSessions()
|
||||
expect(hub.sessionsText()).toBe("🔵 1 · one: waiting for you, 1 approval\n🔵 2 · two: waiting for you, 1 approval")
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: waiting for you, 1 approval\n🟠 2 · two: waiting for you, 1 approval")
|
||||
one.permission({id: id1, requestId: "fghij", toolName: "Write", description: "Write a file", inputPreview: "a.txt"})
|
||||
writeFileSync(one.record, JSON.stringify({status: "waiting"}))
|
||||
await hub.showSessions()
|
||||
expect(hub.sessionsText()).toBe("🔵 1 · one: waiting for you, 2 approvals\n🔵 2 · two: waiting for you, 1 approval")
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: waiting for you, 2 approvals\n🟠 2 · two: waiting for you, 1 approval")
|
||||
let stopped = false
|
||||
const stopping = hub.stop().then(() => (stopped = true))
|
||||
await until(() => chat.updates.filter(({chatId}) => chatId === 10).at(-1)?.text === "⚪ Not running: 2 · two, 1 · one")
|
||||
@@ -2688,10 +2688,10 @@ describe("Main group", () => {
|
||||
expect(hub.sessionsText()).toBe("▶️ 1 · one: running")
|
||||
writeFileSync(one.record, JSON.stringify({status: "busy"}))
|
||||
await hub.showSessions()
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: working")
|
||||
expect(hub.sessionsText()).toBe("🟢 1 · one: working")
|
||||
writeFileSync(one.record, '{"pid": 100, "sta')
|
||||
await hub.showSessions()
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: working")
|
||||
expect(hub.sessionsText()).toBe("🟢 1 · one: working")
|
||||
writeFileSync(one.record, JSON.stringify({status: "compacting"}))
|
||||
await hub.showSessions()
|
||||
expect(hub.sessionsText()).toBe("▶️ 1 · one: running")
|
||||
@@ -2720,7 +2720,7 @@ describe("Main group", () => {
|
||||
await hub.showSessions()
|
||||
expect(Date.now() - started).toBeLessThan(3_000)
|
||||
expect(opened).toHaveBeenCalledTimes(1)
|
||||
expect(hub.sessionsText()).toBe("🟠 1 · one: working")
|
||||
expect(hub.sessionsText()).toBe("🟢 1 · one: working")
|
||||
})
|
||||
|
||||
it("deletes a new list whose item it could not save and posts it again at the next render, and does not send a text the core refused as too large again until the text changes", async () => {
|
||||
|
||||
Reference in new issue
Block a user