Match T3 Code's sidebar, timeline and composer

Reuse the web app's timeline derivation (turn folds, work groups, live
work), its sidebar sections and status words, steer-by-default sending,
the question panel, decline-with-feedback, and visit/read marking.
This commit is contained in:
Callum Alpass committed 2026-11-02 17:35:56 +11:00
1 parent 4f42407099
commit 2dac4763d2
17 files changed
+986 -428

No files matched your search

+14 -6
View File
@@ -31,23 +31,31 @@ Any mode:
| `pgup`/`pgdn`, `ctrl+u`/`ctrl+d` | scroll the conversation | | `pgup`/`pgdn`, `ctrl+u`/`ctrl+d` | scroll the conversation |
| `ctrl+c` | quit | | `ctrl+c` | quit |
Typing: `enter` sends (queued after the current run if the thread is busy), `shift+enter` or `ctrl+j` adds a newline. Typing: `enter` sends. While the agent is running, `enter` steers it (the message reaches it mid-run) and `alt+enter` queues the message for after the run, as in T3 Code. With an approval pending, a typed message declines it with your feedback. `shift+enter` or `ctrl+j` adds a newline.
Navigation: Navigation:
| Key | Action | | Key | Action |
| --- | --- | | --- | --- |
| `j`/`k`, arrows | next / previous thread (scroll, in `attach`) | | `j`/`k`, arrows | next / previous thread (scroll, in `attach`) |
| `y` / `Y` / `n` | accept / accept for session / decline the pending approval | | `y` / `Y` / `n` | approve / always allow this session / decline the pending approval |
| `e` | expand folded work and long messages | | `1`–`9` | pick an option when the agent asks a question (also in an empty message box) |
| `x` | dismiss the agent's question |
| `e` | expand all folded turns and work groups |
| `o` | load earlier turns |
| `z` | show the Settled and Snoozed sections |
| `/` | filter threads by title or project | | `/` | filter threads by title or project |
| `S` | stop the thread | | `S` | stop the thread |
| `g` / `G` | top / bottom of the conversation | | `g` / `G` | top / bottom of the conversation |
| `q` | quit | | `q` | quit |
The conversation shows your messages and the agent's replies; each run of tool calls and reasoning between them folds into one summary line (`▸ 5 commands · 3 edits`), with the latest step shown while it's running. The layout follows T3 Code's web app, and much of it uses the web app's own code (vendored from upstream):
Threads are grouped into **Needs you** (waiting on an approval), **Running**, and **Recent**. - **Sidebar:** the same sections (Pinned, Active, Working, then Snoozed and Settled folded to a count) and the same status words: `Working 2m`, `Waiting`, `Approval`, `Input`, `Request`, `Limited`, `Failed`, `Done`. Threads that need you are bold.
- **Conversation:** built by the web app's timeline logic. Each finished turn's work folds into one line (`Worked for 3m 12s`), your messages are right-aligned, and a running turn shows its live step and `Working for 12s`.
- **Read state:** opening a thread marks it read after a moment, as the web app does. Set `TUI3_NO_VISIT=1` to turn that off.
Long threads load as a bounded window of recent turns; press `o` for older ones. If the connection drops, tui3 reconnects with backoff and resubscribes.
## How it connects ## How it connects
@@ -70,4 +78,4 @@ Type errors after a bump point at the protocol changes to adapt to.
## Not yet supported ## Not yet supported
Answering agent questions (`user_input` requests), starting new threads, attachments, diffs, and the integrated terminal. Use the T3 Code app for those. Starting new threads, editing queued messages, plan follow-ups, attachments, diffs, and the integrated terminal. Use the T3 Code app for those.
+138
View File
@@ -8,16 +8,24 @@
"@opentui/core": "0.2.7", "@opentui/core": "0.2.7",
"@opentui/react": "0.2.7", "@opentui/react": "0.2.7",
"effect": "4.0.5", "effect": "4.0.5",
"mdast-util-directive": "^3.2.0",
"micromark-extension-directive": "^4.0.0",
"react": "19", "react": "19",
"remark-parse": "^11.0.0",
"zustand": "5.0.11",
}, },
"devDependencies": { "devDependencies": {
"@noble/hashes": "1.8.0",
"@types/bun": "latest", "@types/bun": "latest",
"@types/react": "^19.3.0", "@types/react": "^19.3.0",
"jose": "^6.2.14",
"typescript": "^5.9.0", "typescript": "^5.9.0",
}, },
}, },
}, },
"packages": { "packages": {
"@noble/hashes": ["@noble/hashes@1.8.0", "", {}, "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="],
"@opentui/core": ["@opentui/core@0.2.7", "", { "dependencies": { "bun-ffi-structs": "0.2.2", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2", "yoga-layout": "3.2.1" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.2.7", "@opentui/core-darwin-x64": "0.2.7", "@opentui/core-linux-arm64": "0.2.7", "@opentui/core-linux-x64": "0.2.7", "@opentui/core-win32-arm64": "0.2.7", "@opentui/core-win32-x64": "0.2.7" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-cnN6JcaGC7SeQzobBy/CHzqUAQFtypazuw1CjQBo7WwoOiLMGubt9W5FXeF0zIrSxH2Ed6NLWhPYRg7SD4629Q=="], "@opentui/core": ["@opentui/core@0.2.7", "", { "dependencies": { "bun-ffi-structs": "0.2.2", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2", "yoga-layout": "3.2.1" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.2.7", "@opentui/core-darwin-x64": "0.2.7", "@opentui/core-linux-arm64": "0.2.7", "@opentui/core-linux-x64": "0.2.7", "@opentui/core-win32-arm64": "0.2.7", "@opentui/core-win32-x64": "0.2.7" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-cnN6JcaGC7SeQzobBy/CHzqUAQFtypazuw1CjQBo7WwoOiLMGubt9W5FXeF0zIrSxH2Ed6NLWhPYRg7SD4629Q=="],
"@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.2.7", "", { "os": "darwin", "cpu": "arm64" }, "sha512-CAy6cL3byz2Xf6gFiJHBpcnsp/2ADEWLLOUokVypOyPLcy8GY3sPzlA4pkAjVGQMYQhDj+Y3+SXz4uTLt4AETg=="], "@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.2.7", "", { "os": "darwin", "cpu": "arm64" }, "sha512-CAy6cL3byz2Xf6gFiJHBpcnsp/2ADEWLLOUokVypOyPLcy8GY3sPzlA4pkAjVGQMYQhDj+Y3+SXz4uTLt4AETg=="],
@@ -36,54 +44,184 @@
"@types/bun": ["@types/bun@1.4.4", "", { "dependencies": { "bun-types": "1.4.4" } }, "sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ=="], "@types/bun": ["@types/bun@1.4.4", "", { "dependencies": { "bun-types": "1.4.4" } }, "sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ=="],
"@types/debug": ["@types/debug@4.1.13", "", { "dependencies": { "@types/ms": "*" } }, "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw=="],
"@types/mdast": ["@types/mdast@4.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA=="],
"@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
"@types/node": ["@types/node@26.6.6", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog=="], "@types/node": ["@types/node@26.6.6", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog=="],
"@types/react": ["@types/react@19.3.0", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg=="], "@types/react": ["@types/react@19.3.0", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg=="],
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
"ansi-regex": ["ansi-regex@6.5.0", "", {}, "sha512-zhvbbbdt1kbw7EJ9OQoxmQcuaNR9P5kTj7e/YdmOSU10aHWbycofJxA6jKfoEy3vlLdctOF9ZHaxLtmSm998wQ=="], "ansi-regex": ["ansi-regex@6.5.0", "", {}, "sha512-zhvbbbdt1kbw7EJ9OQoxmQcuaNR9P5kTj7e/YdmOSU10aHWbycofJxA6jKfoEy3vlLdctOF9ZHaxLtmSm998wQ=="],
"bail": ["bail@2.0.2", "", {}, "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw=="],
"bun-ffi-structs": ["bun-ffi-structs@0.2.2", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-N/ZWtyN0piZlrXQT7TO0V+q952orYqkfhXRXM1Hcbb+R3QSiBH4vLnib187Mrs1H7pWIYECAmPeapGYDOMCl+w=="], "bun-ffi-structs": ["bun-ffi-structs@0.2.2", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-N/ZWtyN0piZlrXQT7TO0V+q952orYqkfhXRXM1Hcbb+R3QSiBH4vLnib187Mrs1H7pWIYECAmPeapGYDOMCl+w=="],
"bun-types": ["bun-types@1.4.4", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ=="], "bun-types": ["bun-types@1.4.4", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ=="],
"ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
"character-entities": ["character-entities@2.0.2", "", {}, "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ=="],
"character-entities-html4": ["character-entities-html4@2.1.0", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="],
"character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="],
"character-reference-invalid": ["character-reference-invalid@2.0.1", "", {}, "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="],
"csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="], "csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
"decode-named-character-reference": ["decode-named-character-reference@1.3.0", "", { "dependencies": { "character-entities": "^2.0.0" } }, "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q=="],
"dequal": ["dequal@2.0.3", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
"devlop": ["devlop@1.1.0", "", { "dependencies": { "dequal": "^2.0.0" } }, "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA=="],
"diff": ["diff@9.0.0", "", {}, "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw=="], "diff": ["diff@9.0.0", "", {}, "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw=="],
"effect": ["effect@4.0.5", "", {}, "sha512-BY4/28NlpOd99yzmV741xbVGmp+1U7tks4oB7F/Png64bTa5tm5eCA6W0RiXsnuLDDoJpjfVSo4Dnq4BZb/89Q=="], "effect": ["effect@4.0.5", "", {}, "sha512-BY4/28NlpOd99yzmV741xbVGmp+1U7tks4oB7F/Png64bTa5tm5eCA6W0RiXsnuLDDoJpjfVSo4Dnq4BZb/89Q=="],
"emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="], "emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="],
"extend": ["extend@3.0.2", "", {}, "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="],
"get-east-asian-width": ["get-east-asian-width@1.7.0", "", {}, "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q=="], "get-east-asian-width": ["get-east-asian-width@1.7.0", "", {}, "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q=="],
"is-alphabetical": ["is-alphabetical@2.0.1", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="],
"is-alphanumerical": ["is-alphanumerical@2.0.1", "", { "dependencies": { "is-alphabetical": "^2.0.0", "is-decimal": "^2.0.0" } }, "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw=="],
"is-decimal": ["is-decimal@2.0.1", "", {}, "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="],
"is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="],
"is-plain-obj": ["is-plain-obj@4.1.0", "", {}, "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="],
"jose": ["jose@6.2.14", "", {}, "sha512-3JasLuki1NRLQvY4wCoC37KZk4qxoBx2k2aFqLxT84IezqW0bkJKnNtxnZj/Fu1xsQivoc/lytxaRHJoGLjJ1A=="],
"longest-streak": ["longest-streak@3.1.0", "", {}, "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g=="],
"marked": ["marked@17.0.1", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg=="], "marked": ["marked@17.0.1", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg=="],
"mdast-util-directive": ["mdast-util-directive@3.2.0", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "devlop": "^1.0.0", "mdast-util-from-markdown": "^2.0.0", "mdast-util-to-markdown": "^2.2.0", "micromark-util-character": "^2.0.0", "parse-entities": "^4.0.0", "stringify-entities": "^4.0.0" } }, "sha512-Yxq+hH4pBEmtaLIJyMVcNbtBiCIKzdOK3HvDeM+JAqC8XVAT1e5PUYbHBpwFvQLIJuJfO2zCu7aNUXWoyZLmhw=="],
"mdast-util-from-markdown": ["mdast-util-from-markdown@2.1.0", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-KRLgmPaP2H1ul2bpoJkOS+9pAcDAAj9Nu1mqLnh8NLeJG5tlvj42TH80PIGBpROWlRXLk0lDrWNuZCFy/tsB4A=="],
"mdast-util-phrasing": ["mdast-util-phrasing@4.1.0", "", { "dependencies": { "@types/mdast": "^4.0.0", "unist-util-is": "^6.0.0" } }, "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w=="],
"mdast-util-to-markdown": ["mdast-util-to-markdown@2.2.1", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-character": "^2.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-html-tag-name": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-ThatlCBxG2GE+mljhNSfZPv56d3QrGiRh97jjYgIk80IzS4uU6d7cHAaexCYSAmUCCcOs3grJ07kX3oTGsFUOw=="],
"mdast-util-to-string": ["mdast-util-to-string@4.0.0", "", { "dependencies": { "@types/mdast": "^4.0.0" } }, "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg=="],
"micromark": ["micromark@4.0.3", "", { "dependencies": { "@types/debug": "^4.0.0", "debug": "^4.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-core-commonmark": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-combine-extensions": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-edit-map": "^1.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-sanitize-uri": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw=="],
"micromark-core-commonmark": ["micromark-core-commonmark@2.0.4", "", { "dependencies": { "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-factory-destination": "^2.0.0", "micromark-factory-label": "^2.0.0", "micromark-factory-space": "^2.1.0", "micromark-factory-title": "^2.0.0", "micromark-factory-whitespace": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-edit-map": "^1.0.0", "micromark-util-html-tag-name": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.3" } }, "sha512-wxEeE8v8XVvOrxn1TZj74qYhAtTQsSqufHVS3uNVyT1MupXxhyaHk8/9xDNPh9BmL77QNDgWTkZ3RsYHB2ry7w=="],
"micromark-extension-directive": ["micromark-extension-directive@4.0.0", "", { "dependencies": { "devlop": "^1.0.0", "micromark-factory-space": "^2.0.0", "micromark-factory-whitespace": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "parse-entities": "^4.0.0" } }, "sha512-/C2nqVmXXmiseSSuCdItCMho7ybwwop6RrrRPk0KbOHW21JKoCldC+8rFOaundDoRBUWBnJJcxeA/Kvi34WQXg=="],
"micromark-factory-destination": ["micromark-factory-destination@2.0.1", "", { "dependencies": { "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA=="],
"micromark-factory-label": ["micromark-factory-label@2.0.1", "", { "dependencies": { "devlop": "^1.0.0", "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg=="],
"micromark-factory-space": ["micromark-factory-space@2.1.0", "", { "dependencies": { "micromark-util-character": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-fS8hnLIjnjvdQIj39Geug8wWsR0HrYZ43KShKxNfwT7t2LOHo/LbWZEzEaSOjwtjdCsjoE6syHhonEzW0zv0+Q=="],
"micromark-factory-title": ["micromark-factory-title@2.0.1", "", { "dependencies": { "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw=="],
"micromark-factory-whitespace": ["micromark-factory-whitespace@2.0.1", "", { "dependencies": { "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ=="],
"micromark-util-character": ["micromark-util-character@2.1.1", "", { "dependencies": { "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q=="],
"micromark-util-chunked": ["micromark-util-chunked@2.0.1", "", { "dependencies": { "micromark-util-symbol": "^2.0.0" } }, "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA=="],
"micromark-util-classify-character": ["micromark-util-classify-character@2.0.1", "", { "dependencies": { "micromark-util-character": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q=="],
"micromark-util-combine-extensions": ["micromark-util-combine-extensions@2.0.1", "", { "dependencies": { "micromark-util-chunked": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg=="],
"micromark-util-decode-numeric-character-reference": ["micromark-util-decode-numeric-character-reference@2.0.2", "", { "dependencies": { "micromark-util-symbol": "^2.0.0" } }, "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw=="],
"micromark-util-decode-string": ["micromark-util-decode-string@2.0.1", "", { "dependencies": { "decode-named-character-reference": "^1.0.0", "micromark-util-character": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-symbol": "^2.0.0" } }, "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ=="],
"micromark-util-edit-map": ["micromark-util-edit-map@1.0.0", "", { "dependencies": { "micromark-util-types": "^2.0.0" } }, "sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q=="],
"micromark-util-encode": ["micromark-util-encode@2.0.1", "", {}, "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw=="],
"micromark-util-html-tag-name": ["micromark-util-html-tag-name@2.0.1", "", {}, "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA=="],
"micromark-util-normalize-identifier": ["micromark-util-normalize-identifier@2.0.1", "", { "dependencies": { "micromark-util-symbol": "^2.0.0" } }, "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q=="],
"micromark-util-resolve-all": ["micromark-util-resolve-all@2.0.1", "", { "dependencies": { "micromark-util-types": "^2.0.0" } }, "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg=="],
"micromark-util-sanitize-uri": ["micromark-util-sanitize-uri@2.0.1", "", { "dependencies": { "micromark-util-character": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-symbol": "^2.0.0" } }, "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ=="],
"micromark-util-subtokenize": ["micromark-util-subtokenize@2.1.0", "", { "dependencies": { "devlop": "^1.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA=="],
"micromark-util-symbol": ["micromark-util-symbol@2.0.1", "", {}, "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q=="],
"micromark-util-types": ["micromark-util-types@2.0.3", "", {}, "sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg=="],
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
"parse-entities": ["parse-entities@4.0.2", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="],
"react": ["react@19.3.1", "", {}, "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw=="], "react": ["react@19.3.1", "", {}, "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw=="],
"react-devtools-core": ["react-devtools-core@7.0.1", "", { "dependencies": { "shell-quote": "^1.6.1", "ws": "^7" } }, "sha512-C3yNvRHaizlpiASzy7b9vbnBGLrhvdhl1CbdU6EnZgxPNbai60szdLtl+VL76UNOt5bOoVTOz5rNWZxgGt+Gsw=="], "react-devtools-core": ["react-devtools-core@7.0.1", "", { "dependencies": { "shell-quote": "^1.6.1", "ws": "^7" } }, "sha512-C3yNvRHaizlpiASzy7b9vbnBGLrhvdhl1CbdU6EnZgxPNbai60szdLtl+VL76UNOt5bOoVTOz5rNWZxgGt+Gsw=="],
"react-reconciler": ["react-reconciler@0.33.0", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.0" } }, "sha512-KetWRytFv1epdpJc3J4G75I4WrplZE5jOL7Yq0p34+OVOKF4Se7WrdIdVC45XsSSmUTlht2FM/fM1FZb1mfQeA=="], "react-reconciler": ["react-reconciler@0.33.0", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.0" } }, "sha512-KetWRytFv1epdpJc3J4G75I4WrplZE5jOL7Yq0p34+OVOKF4Se7WrdIdVC45XsSSmUTlht2FM/fM1FZb1mfQeA=="],
"remark-parse": ["remark-parse@11.0.0", "", { "dependencies": { "@types/mdast": "^4.0.0", "mdast-util-from-markdown": "^2.0.0", "micromark-util-types": "^2.0.0", "unified": "^11.0.0" } }, "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA=="],
"scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="], "scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
"shell-quote": ["shell-quote@1.12.0", "", {}, "sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q=="], "shell-quote": ["shell-quote@1.12.0", "", {}, "sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q=="],
"string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="], "string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
"stringify-entities": ["stringify-entities@4.0.4", "", { "dependencies": { "character-entities-html4": "^2.0.0", "character-entities-legacy": "^3.0.0" } }, "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg=="],
"strip-ansi": ["strip-ansi@7.1.2", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA=="], "strip-ansi": ["strip-ansi@7.1.2", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA=="],
"trough": ["trough@2.2.0", "", {}, "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw=="],
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"undici-types": ["undici-types@8.12.3", "", {}, "sha512-EXE4ydL3S76dFb27UFjNVZHTyv/TLdATj/KUe29ptdcg6qXL48J2tZ3126E5kICj5jn781OR+XlVH1N6Mz8jbA=="], "undici-types": ["undici-types@8.12.3", "", {}, "sha512-EXE4ydL3S76dFb27UFjNVZHTyv/TLdATj/KUe29ptdcg6qXL48J2tZ3126E5kICj5jn781OR+XlVH1N6Mz8jbA=="],
"unified": ["unified@11.0.5", "", { "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", "devlop": "^1.0.0", "extend": "^3.0.0", "is-plain-obj": "^4.0.0", "trough": "^2.0.0", "vfile": "^6.0.0" } }, "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA=="],
"unist-util-is": ["unist-util-is@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g=="],
"unist-util-stringify-position": ["unist-util-stringify-position@4.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ=="],
"unist-util-visit": ["unist-util-visit@5.2.0", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0", "unist-util-visit-parents": "^6.1.0" } }, "sha512-fpsYs/VVoZxfGY9/j3FQpZmN8wdLJaV1Pt38AaJNZu9uKIHcFU3halCdBveEq1HGKO1OEfJY65w1zvoFV1b3qQ=="],
"unist-util-visit-parents": ["unist-util-visit-parents@6.1.0", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0" } }, "sha512-vKXxz6O38sKDj1mtx/k2cWvkkFBuYGx6uGrlzBkVeWCRF/F8sdI0j3Wbkz/5rVNRRuVc8UrgRdbCxNhmYXgP3w=="],
"vfile": ["vfile@6.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "vfile-message": "^4.0.0" } }, "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q=="],
"vfile-message": ["vfile-message@4.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="],
"web-tree-sitter": ["web-tree-sitter@0.25.10", "", { "peerDependencies": { "@types/emscripten": "^1.40.0" }, "optionalPeers": ["@types/emscripten"] }, "sha512-Y09sF44/13XvgVKgO2cNDw5rGk6s26MgoZPXLESvMXeefBf7i6/73eFurre0IsTW6E14Y0ArIzhUMmjoc7xyzA=="], "web-tree-sitter": ["web-tree-sitter@0.25.10", "", { "peerDependencies": { "@types/emscripten": "^1.40.0" }, "optionalPeers": ["@types/emscripten"] }, "sha512-Y09sF44/13XvgVKgO2cNDw5rGk6s26MgoZPXLESvMXeefBf7i6/73eFurre0IsTW6E14Y0ArIzhUMmjoc7xyzA=="],
"ws": ["ws@8.22.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g=="], "ws": ["ws@8.22.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g=="],
"yoga-layout": ["yoga-layout@3.2.1", "", {}, "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ=="], "yoga-layout": ["yoga-layout@3.2.1", "", {}, "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ=="],
"zustand": ["zustand@5.0.11", "", { "peerDependencies": { "@types/react": ">=18.0.0", "immer": ">=9.0.6", "react": ">=18.0.0", "use-sync-external-store": ">=1.2.0" }, "optionalPeers": ["@types/react", "immer", "react", "use-sync-external-store"] }, "sha512-fdZY+dk7zn/vbWNCYmzZULHRrss0jx5pPFiOuMZ/5HJN6Yv3u+1Wswy/4MpZEkEGhtNH+pwxZB8OKgUBPzYAGg=="],
"zwitch": ["zwitch@2.0.4", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
"@types/node/undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="], "@types/node/undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
"parse-entities/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="],
"react-devtools-core/ws": ["ws@7.5.13", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-rsKI6xDBFVf4r/x8XyChGK04QR/XHroxs/jUcoWvtEZM8TPU/X/uIY9B1CsSzYws9ZJb/6bbBu7dPhFW00CAoA=="], "react-devtools-core/ws": ["ws@7.5.13", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-rsKI6xDBFVf4r/x8XyChGK04QR/XHroxs/jUcoWvtEZM8TPU/X/uIY9B1CsSzYws9ZJb/6bbBu7dPhFW00CAoA=="],
} }
} }
+7 -1
View File
@@ -16,11 +16,17 @@
"@opentui/core": "0.2.7", "@opentui/core": "0.2.7",
"@opentui/react": "0.2.7", "@opentui/react": "0.2.7",
"effect": "4.0.5", "effect": "4.0.5",
"react": "19" "mdast-util-directive": "^3.2.0",
"micromark-extension-directive": "^4.0.0",
"react": "19",
"remark-parse": "^11.0.0",
"zustand": "5.0.11"
}, },
"devDependencies": { "devDependencies": {
"@noble/hashes": "1.8.0",
"@types/bun": "latest", "@types/bun": "latest",
"@types/react": "^19.3.0", "@types/react": "^19.3.0",
"jose": "^6.2.14",
"typescript": "^5.9.0" "typescript": "^5.9.0"
} }
} }
+5 -5
View File
@@ -2,7 +2,7 @@
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts"; import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
import { T3Session } from "./client/session.ts"; import { T3Session } from "./client/session.ts";
import { findThread, lastActivity, relativeTime, shortId, threadRows } from "./model/threads.ts"; import { findThread, lastActivity, relativeTime, rowTime, shortId, statusLabel, threadRows } from "./model/threads.ts";
const USAGE = `tui3: a terminal client for T3 Code const USAGE = `tui3: a terminal client for T3 Code
@@ -62,13 +62,13 @@ async function connectedSession(): Promise<{ session: T3Session; snapshot: Orche
async function list(json: boolean) { async function list(json: boolean) {
const { session, snapshot } = await connectedSession(); const { session, snapshot } = await connectedSession();
const rows = threadRows(snapshot, { recentLimit: 40 }); const rows = threadRows(snapshot, { settledLimit: 20 });
if (json) { if (json) {
console.log(JSON.stringify(rows.map((row) => ({ id: row.thread.id, title: row.thread.title, project: row.projectName, group: row.group, status: row.thread.status, updatedAt: new Date(lastActivity(row.thread)).toISOString() })), null, 2)); console.log(JSON.stringify(rows.map((row) => ({ id: row.thread.id, title: row.thread.title, project: row.projectName, section: row.section, status: row.status, unread: row.unread, updatedAt: new Date(lastActivity(row.thread)).toISOString() })), null, 2));
} else { } else {
for (const row of rows) { for (const row of rows) {
const mark = row.group === "needs-you" ? "!" : row.group === "running" ? "~" : " "; const status = statusLabel(row)?.text ?? relativeTime(rowTime(row.thread));
console.log(`${mark} ${shortId(row.thread.id)} ${relativeTime(lastActivity(row.thread)).padStart(4)} ${row.projectName.padEnd(20).slice(0, 20)} ${row.thread.title}`); console.log(`${shortId(row.thread.id)} ${row.section.padEnd(8)} ${status.padEnd(12)} ${row.projectName.padEnd(20).slice(0, 20)} ${row.thread.title}`);
} }
} }
await session.stop(); await session.stop();
+24 -10
View File
@@ -14,6 +14,7 @@ import {
} from "@t3tools/contracts"; } from "@t3tools/contracts";
import { applyOrchestrationV2ProjectionEvent } from "@t3tools/client-runtime/state/orchestration-v2-projection"; import { applyOrchestrationV2ProjectionEvent } from "@t3tools/client-runtime/state/orchestration-v2-projection";
import { mergeOlderHistoryIntoProjection } from "@t3tools/client-runtime/state/thread-history-merge"; import { mergeOlderHistoryIntoProjection } from "@t3tools/client-runtime/state/thread-history-merge";
import type { ComposerDispatchMode } from "@t3tools/client-runtime/state/composer-dispatch";
import { boundedSnapshotProjection } from "@t3tools/shared/orchestrationV2BoundedSnapshot"; import { boundedSnapshotProjection } from "@t3tools/shared/orchestrationV2BoundedSnapshot";
import { appendFileSync } from "node:fs"; import { appendFileSync } from "node:fs";
@@ -189,9 +190,12 @@ export class T3Session {
} }
} }
sendMessage(threadId: ThreadId, text: string, mode: "queue" | "steer" = "queue"): Promise<void> { /**
* Sends a message the way the web composer does: "auto" when idle, otherwise
* "steer" (into the active run) or "queue" (after it). See resolveComposerDispatchMode.
*/
sendMessage(threadId: ThreadId, text: string, mode: ComposerDispatchMode = "auto"): Promise<void> {
const commandId = newCommandId(); const commandId = newCommandId();
const running = this.threads.get(threadId)?.state.projection?.runs.findLast((run) => isActiveRun(run.status));
return this.dispatch({ return this.dispatch({
type: "message.dispatch", type: "message.dispatch",
commandId, commandId,
@@ -199,17 +203,29 @@ export class T3Session {
messageId: MessageId.make(commandId), messageId: MessageId.make(commandId),
text, text,
attachments: [], attachments: [],
dispatchMode: ...(mode === "queue" ? { dispatchMode: { type: "queue_after_active" } } : { dispatchMode: { type: "start_immediately" }, deliveryIntent: mode }),
mode === "steer" && running
? { type: "steer_active", targetRunId: running.id }
: { type: "queue_after_active" },
createdBy: "user", createdBy: "user",
creationSource: "web", creationSource: "web",
}); });
} }
respond(threadId: ThreadId, requestId: RuntimeRequestId, decision: ProviderApprovalDecision): Promise<void> { respond(threadId: ThreadId, requestId: RuntimeRequestId, decision: ProviderApprovalDecision, feedback?: string): Promise<void> {
return this.dispatch({ type: "runtime-request.respond", commandId: newCommandId(), threadId, requestId, decision }); return this.dispatch({ type: "runtime-request.respond", commandId: newCommandId(), threadId, requestId, decision, ...(feedback ? { feedback } : {}) });
}
/** Answers a user-input request; answers map question id to an option value, typed text, or several values. */
answer(threadId: ThreadId, requestId: RuntimeRequestId, answers: Record<string, string | readonly string[]>): Promise<void> {
return this.dispatch({ type: "runtime-request.respond", commandId: newCommandId(), threadId, requestId, answers: answers as Record<string, string | string[]> });
}
dismissQuestion(threadId: ThreadId, requestId: RuntimeRequestId): Promise<void> {
return this.dispatch({ type: "thread.user-input.dismiss", commandId: newCommandId(), threadId, requestId });
}
/** Moves the thread's read watermark, as opening it in the web app does. TUI3_NO_VISIT=1 peeks without it. */
visit(threadId: ThreadId): Promise<void> {
if (process.env.TUI3_NO_VISIT === "1") return Promise.resolve();
return this.dispatch({ type: "thread.visit", commandId: newCommandId(), threadId, visitedAt: new Date().toISOString(), opened: true });
} }
/** Stops whatever the thread is running, the way the GUI's stop button does. */ /** Stops whatever the thread is running, the way the GUI's stop button does. */
@@ -352,8 +368,6 @@ export class T3Session {
} }
} }
const isActiveRun = (status: string) => status === "preparing" || status === "starting" || status === "running" || status === "waiting";
const isSocketFailure = (message: string) => /Socket(Close|Open|Generic)?Error|socket/i.test(message); const isSocketFailure = (message: string) => /Socket(Close|Open|Generic)?Error|socket/i.test(message);
const newCommandId = () => CommandId.make(crypto.randomUUID()); const newCommandId = () => CommandId.make(crypto.randomUUID());
+120 -42
View File
@@ -1,66 +1,142 @@
import type { OrchestrationProjectShell, OrchestrationV2ShellSnapshot, OrchestrationV2ThreadShell, ProjectId } from "@t3tools/contracts"; import type { EnvironmentId, OrchestrationProjectShell, OrchestrationV2ShellSnapshot, OrchestrationV2ThreadShell, ProjectId } from "@t3tools/contracts";
import { formatWorkingDurationLabel, presentThreadShell, resolveThreadWorkingStartedAt, type EnvironmentThreadShell } from "@t3tools/client-runtime/state/models";
import { isThreadWorking, sortInboxThreadsByReturn, sortWorkingThreadsBySend } from "@t3tools/client-runtime/state/thread-inbox";
import { effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";
import { sortPinnedThreadsByOrderKey, sortSettledThreads } from "@t3tools/client-runtime/state/thread-sort";
import * as DateTime from "effect/DateTime"; import * as DateTime from "effect/DateTime";
export type ThreadGroup = "needs-you" | "running" | "recent"; /** The web sidebar's sections, in its order. Active has no header unless others show. */
export type Section = "pinned" | "active" | "working" | "snoozed" | "settled";
/** The web sidebar's row status (resolveSidebarThreadStatus). */
export type ThreadStatus = "approval" | "input" | "request" | "waiting" | "working" | "limited" | "failed" | "ready";
export interface ThreadRow { export interface ThreadRow {
readonly thread: OrchestrationV2ThreadShell; readonly thread: OrchestrationV2ThreadShell;
readonly group: ThreadGroup; readonly shell: EnvironmentThreadShell;
readonly section: Section;
readonly status: ThreadStatus;
/** Finished since you last opened it. */
readonly unread: boolean;
readonly projectName: string; readonly projectName: string;
} }
export const GROUP_LABELS: Record<ThreadGroup, string> = { export const SECTION_LABELS: Record<Section, string> = {
"needs-you": "Needs you", pinned: "Pinned",
running: "Running", active: "Active",
recent: "Recent", working: "Working",
snoozed: "Snoozed",
settled: "Settled",
}; };
const ACTIVE_STATUSES = new Set(["preparing", "starting", "running", "waiting"]); export const SECTION_ORDER: readonly Section[] = ["pinned", "active", "working", "snoozed", "settled"];
export function needsUser(thread: OrchestrationV2ThreadShell): boolean { /** Only one server, so any constant id works for presentThreadShell. */
return thread.pendingRuntimeRequest !== null && thread.pendingRuntimeRequest.blocking !== false; const LOCAL_ENVIRONMENT = "local" as EnvironmentId;
export function resolveStatus(shell: EnvironmentThreadShell): ThreadStatus {
if (shell.hasPendingApprovals || shell.pendingSubagentRequest === "approval") return "approval";
if (shell.hasPendingUserInput || shell.pendingSubagentRequest === "user_input") return "input";
if ((shell.pendingGuestMessageCount ?? 0) > 0) return "request";
const runtime = shell.runtime;
if (runtime?.status === "running" && shell.blockedOnThreadWait) return "waiting";
if (runtime && ["preparing", "queued", "starting", "running", "waiting"].includes(runtime.status)) return "working";
if (runtime?.status === "idle") return "waiting";
if (runtime?.status === "failed") return runtime.lastErrorClass === "usage_limit" ? "limited" : "failed";
return "ready";
} }
export function isRunning(thread: OrchestrationV2ThreadShell): boolean { export function hasUnseenCompletion(shell: EnvironmentThreadShell): boolean {
return thread.activeRunId !== null || ACTIVE_STATUSES.has(thread.status); const completedAt = Date.parse(shell.latestRun?.completedAt ?? "");
if (Number.isNaN(completedAt) || !shell.lastVisitedAt) return false;
const visitedAt = Date.parse(shell.lastVisitedAt);
return Number.isNaN(visitedAt) || completedAt > visitedAt;
} }
export function groupOf(thread: OrchestrationV2ThreadShell): ThreadGroup { /** Whether the thread is waiting on you: the rows the web sidebar shows in bold. */
if (needsUser(thread)) return "needs-you"; export function needsAttention(row: Pick<ThreadRow, "status" | "unread">): boolean {
if (isRunning(thread)) return "running"; return row.status === "approval" || row.status === "input" || row.status === "request" || row.status === "failed" || row.status === "limited" || row.unread;
return "recent"; }
/** The sidebar's top-right status word, or null to show the time instead. */
export function statusLabel(row: ThreadRow, now = Date.now()): { readonly text: string; readonly tone: StatusTone } | null {
switch (row.status) {
case "working": {
const label = row.shell.goal?.status === "active" ? "Goal" : "Working";
const since = resolveThreadWorkingStartedAt(row.shell);
return { text: since ? `${label} ${formatWorkingDurationLabel(now - Date.parse(since))}` : label, tone: "info" };
}
case "waiting":
return { text: "Waiting", tone: "muted" };
case "approval":
return { text: "Approval", tone: "warn" };
case "input":
return { text: "Input", tone: "input" };
case "request":
return { text: "Request", tone: "input" };
case "limited":
return { text: "Limited", tone: "warn" };
case "failed":
return { text: "Failed", tone: "bad" };
case "ready":
return row.unread ? { text: "Done", tone: "good" } : null;
}
}
export type StatusTone = "info" | "muted" | "warn" | "input" | "bad" | "good";
/** Threads in the web sidebar's sections and order. Subagent threads stay under their parent, so they're left out. */
export function threadRows(
snapshot: OrchestrationV2ShellSnapshot | null,
options: { readonly query?: string; readonly settledLimit?: number; readonly now?: string } = {},
): ThreadRow[] {
if (!snapshot) return [];
const projects = new Map<ProjectId, OrchestrationProjectShell>(snapshot.projects.map((project) => [project.id, project]));
const query = options.query?.trim().toLowerCase();
const now = options.now ?? new Date().toISOString();
const bySection: Record<Section, EnvironmentThreadShell[]> = { pinned: [], active: [], working: [], snoozed: [], settled: [] };
for (const thread of snapshot.threads) {
if (thread.archivedAt !== null || thread.deletedAt !== null || thread.lineage.relationshipToParent === "subagent") continue;
const projectName = projectLabel(projects.get(thread.projectId));
if (query && !thread.title.toLowerCase().includes(query) && !projectName.toLowerCase().includes(query)) continue;
const shell = presentThreadShell(LOCAL_ENVIRONMENT, thread);
const section: Section = effectiveSnoozed(shell, { now })
? "snoozed"
: shell.settledOverride === "settled"
? "settled"
: shell.pinnedAt != null
? "pinned"
: isThreadWorking(shell)
? "working"
: "active";
bySection[section].push(shell);
}
const sorted: Record<Section, EnvironmentThreadShell[]> = {
pinned: sortPinnedThreadsByOrderKey(bySection.pinned),
active: sortInboxThreadsByReturn(bySection.active),
working: sortWorkingThreadsBySend(bySection.working),
snoozed: bySection.snoozed.toSorted((a, b) => Date.parse(a.snoozedUntil ?? "") - Date.parse(b.snoozedUntil ?? "")),
settled: sortSettledThreads(bySection.settled).slice(0, options.settledLimit ?? 30),
};
return SECTION_ORDER.flatMap((section) =>
sorted[section].map((shell) => ({
thread: shell.source as OrchestrationV2ThreadShell,
shell,
section,
status: resolveStatus(shell),
unread: hasUnseenCompletion(shell),
projectName: projectLabel(projects.get(shell.projectId)),
})),
);
} }
export function lastActivity(thread: OrchestrationV2ThreadShell): number { export function lastActivity(thread: OrchestrationV2ThreadShell): number {
return DateTime.toEpochMillis(thread.updatedAt); return DateTime.toEpochMillis(thread.updatedAt);
} }
const millis = (value: DateTime.Utc | null | undefined) => (value ? DateTime.toEpochMillis(value) : 0); /** The time the sidebar shows: your latest message, else the last update. */
export function rowTime(thread: OrchestrationV2ThreadShell): number {
/** return thread.latestUserMessageAt ? DateTime.toEpochMillis(thread.latestUserMessageAt) : lastActivity(thread);
* Sort key within a group. Active threads update every second while they
* stream, so they sort by something that holds still: when they started
* waiting on you, or when their run began.
*/
export function sortKey(thread: OrchestrationV2ThreadShell, group: ThreadGroup): number {
if (group === "needs-you") return millis(thread.pendingRuntimeRequest?.createdAt) || millis(thread.createdAt);
if (group === "running") return millis(thread.latestRunStartedAt) || millis(thread.latestRunRequestedAt) || millis(thread.createdAt);
return lastActivity(thread);
}
/** Threads in display order: the ones waiting on you, then running, then the most recent. */
export function threadRows(snapshot: OrchestrationV2ShellSnapshot | null, options: { readonly recentLimit?: number; readonly query?: string } = {}): ThreadRow[] {
if (!snapshot) return [];
const projects = new Map<ProjectId, OrchestrationProjectShell>(snapshot.projects.map((project) => [project.id, project]));
const query = options.query?.trim().toLowerCase();
const order: ThreadGroup[] = ["needs-you", "running", "recent"];
const rows = snapshot.threads
.map((thread) => ({ thread, group: groupOf(thread), projectName: projectLabel(projects.get(thread.projectId)) }))
.filter((row) => !query || row.thread.title.toLowerCase().includes(query) || row.projectName.toLowerCase().includes(query))
.sort((a, b) => order.indexOf(a.group) - order.indexOf(b.group) || sortKey(b.thread, b.group) - sortKey(a.thread, a.group) || a.thread.id.localeCompare(b.thread.id));
const limit = options.recentLimit ?? 60;
let recent = 0;
return rows.filter((row) => row.group !== "recent" || recent++ < limit);
} }
export function projectLabel(project: OrchestrationProjectShell | undefined): string { export function projectLabel(project: OrchestrationProjectShell | undefined): string {
@@ -84,8 +160,10 @@ export function shortId(id: string): string {
return id.slice(-8); return id.slice(-8);
} }
/** Compact relative time, like the sidebar's: "now", "45s", "3m", "2h", "4d". */
export function relativeTime(ms: number, now = Date.now()): string { export function relativeTime(ms: number, now = Date.now()): string {
const seconds = Math.max(0, Math.round((now - ms) / 1000)); const seconds = Math.max(0, Math.round((now - ms) / 1000));
if (seconds < 5) return "now";
if (seconds < 60) return `${seconds}s`; if (seconds < 60) return `${seconds}s`;
const minutes = Math.round(seconds / 60); const minutes = Math.round(seconds / 60);
if (minutes < 60) return `${minutes}m`; if (minutes < 60) return `${minutes}m`;
+102
View File
@@ -0,0 +1,102 @@
import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
import {
deriveRunlessWorkStartedAt,
deriveThreadActivityRun,
deriveThreadStructureRuntime,
} from "@t3tools/client-runtime/state/thread-execution";
import { derivePendingThreadRequests, type PendingThreadRequests } from "@t3tools/client-runtime/state/thread-requests";
// The web app's own timeline derivation: tui3 shows the same rows, folds and labels.
import {
computeStableMessagesTimelineRows,
deriveMessagesTimelineRowsWithState,
type MessagesTimelineRow,
type MessagesTimelineRowsInput,
type StableMessagesTimelineRowsState,
} from "../../vendor/t3code/apps/web/src/components/chat/MessagesTimeline.logic.ts";
import {
deriveActiveWorkStartedAt,
derivePhase,
deriveTimelineEntriesFromVisibleTurnItemsWithState,
type TimelineEntriesProjection,
} from "../../vendor/t3code/apps/web/src/session-logic.ts";
export type { MessagesTimelineRow } from "../../vendor/t3code/apps/web/src/components/chat/MessagesTimeline.logic.ts";
export type { WorkLogEntry } from "../../vendor/t3code/apps/web/src/session-logic.ts";
export { liveWorkEntryLabel, workEntryDisplayLabel } from "../../vendor/t3code/apps/web/src/components/chat/MessagesTimeline.logic.ts";
export interface Timeline {
readonly rows: readonly MessagesTimelineRow[];
readonly pending: PendingThreadRequests;
readonly isWorking: boolean;
/** When the current run started working, for "Working for 12s". */
readonly workStartedAt: string | null;
/** Carried into the next build so unchanged rows keep their identity. */
readonly cache: TimelineCache;
}
interface TimelineCache {
readonly entries: TimelineEntriesProjection;
readonly rows: { readonly input: MessagesTimelineRowsInput; readonly rows: MessagesTimelineRow[] };
readonly stable: StableMessagesTimelineRowsState;
readonly expandAll: boolean;
}
/** Answers yes for every id: "expand everything" without knowing the group ids up front. */
class EverySet<T> extends Set<T> {
override has(): boolean {
return true;
}
}
const EVERYTHING = new EverySet<never>();
const NOTHING = new Set<never>();
export function buildTimeline(
projection: OrchestrationV2ThreadProjection,
options: { readonly expandAll: boolean },
previous: Timeline | null,
): Timeline {
const cache = previous?.cache.expandAll === options.expandAll ? previous.cache : null;
const entries = deriveTimelineEntriesFromVisibleTurnItemsWithState(
{
visibleTurnItems: projection.visibleTurnItems,
optimisticMessages: [],
attempts: projection.attempts,
nodes: projection.nodes,
plans: projection.plans,
},
cache?.entries ?? null,
);
const runtime = deriveThreadStructureRuntime(projection);
const latestRun = deriveThreadActivityRun(projection);
const runlessStartedAt = deriveRunlessWorkStartedAt(projection);
const isWorking = derivePhase(runtime) === "running" || runlessStartedAt !== null;
const workStartedAt = deriveActiveWorkStartedAt(latestRun, runtime, null) ?? runlessStartedAt;
const pending = derivePendingThreadRequests(projection);
const expanded = options.expandAll ? EVERYTHING : NOTHING;
const rows = deriveMessagesTimelineRowsWithState(
{
timelineEntries: entries.entries,
pendingApprovalRequestIds: new Set(pending.approvals.map((approval) => approval.requestId)),
latestRun,
runningRunId: runtime?.activeRunId ?? null,
expandedRunIds: expanded,
expandedAttemptIds: expanded,
expandedWorkGroupIds: expanded,
isWorking,
runlessWorkActive: runlessStartedAt !== null,
activeTurnStartedAt: workStartedAt,
turnDiffSummaries: [],
supportsConversationRollback: false,
},
cache?.rows ?? null,
);
const stable = computeStableMessagesTimelineRows(rows.rows, cache?.stable ?? { byId: new Map(), result: [] });
return {
rows: stable.result,
pending,
isWorking,
workStartedAt,
cache: { entries, rows, stable, expandAll: options.expandAll },
};
}
+2 -104
View File
@@ -1,6 +1,6 @@
import type { OrchestrationV2ThreadProjection, OrchestrationV2TurnItem, RuntimeRequestId } from "@t3tools/contracts"; import type { OrchestrationV2TurnItem, RuntimeRequestId } from "@t3tools/contracts";
/** One rendered row of the transcript. Markdown blocks get the markdown renderer; the rest are plain lines. */ /** A turn item as one line or card: the fallback for timeline event rows the web app renders specially. */
export type Block = export type Block =
| { readonly kind: "user"; readonly id: string; readonly text: string } | { readonly kind: "user"; readonly id: string; readonly text: string }
| { readonly kind: "assistant"; readonly id: string; readonly markdown: string; readonly streaming: boolean } | { readonly kind: "assistant"; readonly id: string; readonly markdown: string; readonly streaming: boolean }
@@ -12,110 +12,8 @@ export type Block =
export type Tone = "normal" | "muted" | "good" | "bad" | "warn"; export type Tone = "normal" | "muted" | "good" | "bad" | "warn";
/** Tool calls, reasoning and minor notices: the agent's working, as opposed to what it says. */
export type Step = Extract<Block, { kind: "tool" | "reasoning" | "notice" }>;
/** What the conversation view renders: messages stand alone, runs of work fold into one segment. */
export type Segment =
| Extract<Block, { kind: "user" | "assistant" | "approval" | "question" }>
| { readonly kind: "work"; readonly id: string; readonly steps: readonly Step[]; readonly active: boolean }
| { readonly kind: "alert"; readonly id: string; readonly text: string; readonly tone: Tone };
export interface Transcript {
readonly segments: readonly Segment[];
/** Turn items left out because only the tail is shown. */
readonly hiddenCount: number;
}
const OUTPUT_TAIL_LINES = 3; const OUTPUT_TAIL_LINES = 3;
/** Blocks keyed by turn item object: the projection reducer keeps unchanged items identical. */
const blockCache = new WeakMap<object, Block | null>();
function cachedBlock(item: OrchestrationV2TurnItem, pending: ReadonlySet<string>): Block | null {
// Approval and question blocks depend on request state, not just the item.
if (item.type === "approval_request" || item.type === "user_input_request") return blockFor(item, pending);
let block = blockCache.get(item);
if (block === undefined) {
block = blockFor(item, pending);
blockCache.set(item, block);
}
return block;
}
export function buildTranscript(
projection: OrchestrationV2ThreadProjection,
options: { readonly tail?: number; readonly running?: boolean; readonly previous?: Transcript | null } = {},
): Transcript {
const pending = new Set(projection.runtimeRequests.filter((request) => request.status === "pending").map((request) => request.id as string));
const items = projection.visibleTurnItems;
const tail = options.tail ?? 200;
const start = Math.max(0, items.length - tail);
const segments: Segment[] = [];
let work: Step[] | null = null;
const flushWork = () => {
if (work && work.length > 0) segments.push({ kind: "work", id: `work-${work[0]!.id}`, steps: work, active: false });
work = null;
};
for (let index = start; index < items.length; index++) {
const block = cachedBlock(items[index]!.item, pending);
if (!block) continue;
if (block.kind === "tool" || block.kind === "reasoning" || (block.kind === "notice" && block.tone !== "bad" && block.tone !== "warn")) {
(work ??= []).push(block);
continue;
}
flushWork();
segments.push(block.kind === "notice" ? { kind: "alert", id: block.id, text: block.text, tone: block.tone } : block);
}
flushWork();
const last = segments.at(-1);
if (options.running && last?.kind === "work") segments[segments.length - 1] = { ...last, active: true };
return { segments: reuseUnchanged(segments, options.previous ?? null), hiddenCount: start };
}
/** Keeps the previous segment object when nothing in it changed, so memoized views skip it. */
function reuseUnchanged(segments: Segment[], previous: Transcript | null): Segment[] {
if (!previous) return segments;
const byId = new Map(previous.segments.map((segment) => [segment.id, segment]));
return segments.map((segment) => {
const old = byId.get(segment.id);
return old && sameSegment(old, segment) ? old : segment;
});
}
function sameSegment(a: Segment, b: Segment): boolean {
if (a === b) return true;
if (a.kind !== b.kind) return false;
if (a.kind === "work" && b.kind === "work") {
return a.active === b.active && a.steps.length === b.steps.length && a.steps.every((step, index) => step === b.steps[index]);
}
return shallowEqual(a as unknown as Record<string, unknown>, b as unknown as Record<string, unknown>);
}
function shallowEqual(a: Record<string, unknown>, b: Record<string, unknown>): boolean {
const keys = Object.keys(a);
return keys.length === Object.keys(b).length && keys.every((key) => Object.is(a[key], b[key]) || (Array.isArray(a[key]) && Array.isArray(b[key]) && shallowEqualArray(a[key] as unknown[], b[key] as unknown[])));
}
function shallowEqualArray(a: unknown[], b: unknown[]): boolean {
return a.length === b.length && a.every((value, index) => Object.is(value, b[index]));
}
/** One line describing a folded run of work, e.g. "5 commands · 3 edits · 2 searches". */
export function summarizeWork(steps: readonly Step[]): string {
const counts = new Map<string, number>();
const bump = (label: string) => counts.set(label, (counts.get(label) ?? 0) + 1);
for (const step of steps) {
if (step.kind === "reasoning") continue;
if (step.kind === "notice") bump("update");
else bump(STEP_LABELS[step.icon] ?? "tool call");
}
const parts = [...counts].sort((a, b) => b[1] - a[1]).map(([label, count]) => `${count} ${count === 1 ? label : `${label}s`}`);
return parts.length > 0 ? parts.join(" · ") : "thinking";
}
const STEP_LABELS: Record<string, string> = { $: "command", "✎": "edit", "⌕": "search", "⚙": "tool call", "↳": "subagent", "☐": "plan update" };
export function blockFor(item: OrchestrationV2TurnItem, pending: ReadonlySet<string>): Block | null { export function blockFor(item: OrchestrationV2TurnItem, pending: ReadonlySet<string>): Block | null {
const id = item.id; const id = item.id;
switch (item.type) { switch (item.type) {
+6 -4
View File
@@ -1,6 +1,6 @@
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts"; import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
import { threadRows, type ThreadRow } from "../model/threads.ts"; import { needsAttention, threadRows, type ThreadRow } from "../model/threads.ts";
/** Window option that ties a tmux window to the thread it attaches to. */ /** Window option that ties a tmux window to the thread it attaches to. */
const THREAD_OPTION = "@tui3_thread"; const THREAD_OPTION = "@tui3_thread";
@@ -22,7 +22,7 @@ async function tmux(args: readonly string[], allowFailure = false): Promise<stri
const shellJoin = (parts: readonly string[]) => parts.map((part) => `'${part.replaceAll("'", `'\\''`)}'`).join(" "); const shellJoin = (parts: readonly string[]) => parts.map((part) => `'${part.replaceAll("'", `'\\''`)}'`).join(" ");
export function windowName(row: ThreadRow): string { export function windowName(row: ThreadRow): string {
const mark = row.group === "needs-you" ? "● " : row.group === "running" ? "" : "✓ "; const mark = needsAttention(row) && row.status !== "ready" ? "● " : row.status === "working" || row.status === "waiting" ? "" : "✓ ";
const title = (row.thread.title || "thread").replace(/\s+/g, " "); const title = (row.thread.title || "thread").replace(/\s+/g, " ");
return mark + (title.length > TITLE_WIDTH ? `${title.slice(0, TITLE_WIDTH - 1)}…` : title); return mark + (title.length > TITLE_WIDTH ? `${title.slice(0, TITLE_WIDTH - 1)}…` : title);
} }
@@ -42,8 +42,10 @@ export async function syncTmux(snapshot: OrchestrationV2ShellSnapshot, options:
const [windowId, threadId] = line.split("\t"); const [windowId, threadId] = line.split("\t");
if (windowId && threadId) windows.set(threadId, windowId); if (windowId && threadId) windows.set(threadId, windowId);
} }
const rows = threadRows(snapshot, { recentLimit: 0 }); const all = threadRows(snapshot, { settledLimit: 0 });
const byId = new Map(threadRows(snapshot, { recentLimit: Number.MAX_SAFE_INTEGER }).map((row) => [row.thread.id as string, row])); // A window per thread that's working or waiting on you.
const rows = all.filter((row) => row.section === "working" || row.status === "approval" || row.status === "input" || row.status === "request");
const byId = new Map(all.map((row) => [row.thread.id as string, row]));
let opened = 0; let opened = 0;
for (const row of rows) { for (const row of rows) {
if (windows.has(row.thread.id)) continue; if (windows.has(row.thread.id)) continue;
+199 -61
View File
@@ -1,11 +1,20 @@
import type { KeyEvent, ScrollBoxRenderable, TextareaRenderable } from "@opentui/core"; import type { KeyEvent, ScrollBoxRenderable, TextareaRenderable } from "@opentui/core";
import { useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/react"; import { useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/react";
import { resolveComposerDispatchMode } from "@t3tools/client-runtime/state/composer-dispatch";
import {
buildPendingUserInputAnswers,
resolvePendingUserInputAnswer,
setPendingUserInputCustomAnswer,
togglePendingUserInputOptionSelection,
type PendingUserInputDraftAnswer,
} from "@t3tools/client-runtime/state/pending-user-input";
import type { ProviderApprovalDecision, ThreadId } from "@t3tools/contracts"; import type { ProviderApprovalDecision, ThreadId } from "@t3tools/contracts";
import { useEffect, useMemo, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import type { ShellState, T3Session, ThreadState } from "../client/session.ts"; import type { ShellState, T3Session, ThreadState } from "../client/session.ts";
import { buildTranscript, type Transcript } from "../model/transcript.ts"; import { buildTimeline, type Timeline } from "../model/timeline.ts";
import { isRunning, lastActivity, needsUser, relativeTime, threadRows } from "../model/threads.ts"; import { threadRows, type Section } from "../model/threads.ts";
import { QuestionPanel } from "./QuestionPanel.tsx";
import { colors } from "./theme.ts"; import { colors } from "./theme.ts";
import { ThreadList } from "./ThreadList.tsx"; import { ThreadList } from "./ThreadList.tsx";
import { ThreadView } from "./ThreadView.tsx"; import { ThreadView } from "./ThreadView.tsx";
@@ -15,15 +24,30 @@ type Mode = "input" | "nav" | "filter";
/** Holding j/k skims past threads; only subscribe to one you stop on. */ /** Holding j/k skims past threads; only subscribe to one you stop on. */
const SUBSCRIBE_DELAY_MS = 120; const SUBSCRIBE_DELAY_MS = 120;
/** Opening a thread marks it read once you've stayed this long, as in the web app. */
const VISIT_DELAY_MS = 1_500;
const MAX_COMPOSER_LINES = 6; const MAX_COMPOSER_LINES = 6;
/** Sections folded to a count unless you filter or press z, like the web sidebar's. */
const FOLDED_SECTIONS: readonly Section[] = ["snoozed", "settled"];
const COMPOSER_KEYS = [ const COMPOSER_KEYS = [
{ name: "return", action: "submit" }, { name: "return", action: "submit" },
{ name: "return", shift: true, action: "newline" }, { name: "return", shift: true, action: "newline" },
{ name: "return", meta: true, action: "newline" },
{ name: "j", ctrl: true, action: "newline" }, { name: "j", ctrl: true, action: "newline" },
] as const; ] as const;
const RUNTIME_MODE_LABELS: Record<string, string> = {
"approval-required": "Supervised",
"auto-accept-edits": "Auto-accept edits",
auto: "Auto",
"full-access": "Full access",
};
interface QuestionDraft {
readonly index: number;
readonly answers: Record<string, PendingUserInputDraftAnswer>;
}
export function App(props: { readonly session: T3Session; readonly attachThreadId?: ThreadId }) { export function App(props: { readonly session: T3Session; readonly attachThreadId?: ThreadId }) {
const { session, attachThreadId } = props; const { session, attachThreadId } = props;
const renderer = useRenderer(); const renderer = useRenderer();
@@ -32,20 +56,36 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
const [selectedId, setSelectedId] = useState<ThreadId | undefined>(attachThreadId); const [selectedId, setSelectedId] = useState<ThreadId | undefined>(attachThreadId);
const [mode, setMode] = useState<Mode>(attachThreadId ? "input" : "nav"); const [mode, setMode] = useState<Mode>(attachThreadId ? "input" : "nav");
const [filter, setFilter] = useState(""); const [filter, setFilter] = useState("");
const [expandWork, setExpandWork] = useState(false); const [showFolded, setShowFolded] = useState(false);
const [expandAll, setExpandAll] = useState(false);
const [flash, setFlash] = useState<{ text: string; bad?: boolean } | null>(null); const [flash, setFlash] = useState<{ text: string; bad?: boolean } | null>(null);
const [composerLines, setComposerLines] = useState(1); const [composerLines, setComposerLines] = useState(1);
const [composerEmpty, setComposerEmpty] = useState(true);
const [questionDrafts, setQuestionDrafts] = useState<ReadonlyMap<string, QuestionDraft>>(new Map());
const [now, setNow] = useState(Date.now());
const scrollRef = useRef<ScrollBoxRenderable | null>(null); const scrollRef = useRef<ScrollBoxRenderable | null>(null);
const composerRef = useRef<TextareaRenderable | null>(null); const composerRef = useRef<TextareaRenderable | null>(null);
const drafts = useRef(new Map<string, string>()); const drafts = useRef(new Map<string, string>());
useEffect(() => session.onShell(setShell), [session]); useEffect(() => session.onShell(setShell), [session]);
// Drives "Working for 12s" and the sidebar's durations.
useEffect(() => {
const timer = setInterval(() => setNow(Date.now()), 1_000);
return () => clearInterval(timer);
}, []);
const rows = useMemo(() => threadRows(shell.snapshot, { query: filter }), [shell.snapshot, filter]); const allRows = useMemo(() => threadRows(shell.snapshot, { query: filter }), [shell.snapshot, filter]);
const unfold = showFolded || filter.trim() !== "";
const rows = useMemo(() => (unfold ? allRows : allRows.filter((row) => !FOLDED_SECTIONS.includes(row.section))), [allRows, unfold]);
const collapsed = useMemo(
() => new Map(unfold ? [] : FOLDED_SECTIONS.map((section) => [section, allRows.filter((row) => row.section === section).length] as const)),
[allRows, unfold],
);
// Selection is a thread id, not an index, so the list can reorder underneath it. // Selection is a thread id, not an index, so the list can reorder underneath it.
const selectedIndex = Math.max(0, rows.findIndex((row) => row.thread.id === selectedId)); const selectedIndex = Math.max(0, rows.findIndex((row) => row.thread.id === selectedId));
const threadId = attachThreadId ?? rows[selectedIndex]?.thread.id; const threadId = attachThreadId ?? rows[selectedIndex]?.thread.id;
const threadShell = shell.snapshot?.threads.find((thread) => thread.id === threadId); const threadRow = allRows.find((row) => row.thread.id === threadId);
const threadShell = threadRow?.thread ?? shell.snapshot?.threads.find((thread) => thread.id === threadId);
// Pin the initial selection to a thread, or it would follow whatever sorts first. // Pin the initial selection to a thread, or it would follow whatever sorts first.
useEffect(() => { useEffect(() => {
if (selectedId === undefined && rows[0]) setSelectedId(rows[0].thread.id); if (selectedId === undefined && rows[0]) setSelectedId(rows[0].thread.id);
@@ -65,44 +105,107 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
const [thread, setThread] = useState<ThreadState | null>(null); const [thread, setThread] = useState<ThreadState | null>(null);
useEffect(() => { useEffect(() => {
setThread(null); setThread(null);
if (!watchedId || !shell.serverUrl) return; if (!watchedId || shell.status.type !== "live") return;
return session.watchThread(watchedId, setThread); return session.watchThread(watchedId, setThread);
}, [session, watchedId, shell.serverUrl]); }, [session, watchedId, shell.status.type]);
const running = threadShell ? isRunning(threadShell) && !needsUser(threadShell) : false; const unread = threadRow?.unread === true;
const previousTranscript = useRef<{ id: string; transcript: Transcript } | null>(null); useEffect(() => {
const transcript = useMemo(() => { if (!watchedId || !unread) return;
const timer = setTimeout(() => void session.visit(watchedId).catch(() => {}), VISIT_DELAY_MS);
return () => clearTimeout(timer);
}, [session, watchedId, unread]);
const previousTimeline = useRef<{ id: string; timeline: Timeline } | null>(null);
const timeline = useMemo(() => {
if (!thread?.projection || !watchedId) return null; if (!thread?.projection || !watchedId) return null;
const previous = previousTranscript.current?.id === watchedId ? previousTranscript.current.transcript : null; const previous = previousTimeline.current?.id === watchedId ? previousTimeline.current.timeline : null;
const next = buildTranscript(thread.projection, { running, previous }); const next = buildTimeline(thread.projection, { expandAll }, previous);
previousTranscript.current = { id: watchedId, transcript: next }; previousTimeline.current = { id: watchedId, timeline: next };
return next; return next;
}, [thread?.projection, watchedId, running]); }, [thread?.projection, watchedId, expandAll]);
const pendingRequest = thread?.projection?.runtimeRequests.findLast((request) => request.status === "pending" && request.kind !== "user_input"); const current = watchedId === threadId ? timeline : null;
const pendingApproval = current?.pending.approvals[0];
const pendingInput = current?.pending.userInputs[0];
const questionDraft = pendingInput ? (questionDrafts.get(pendingInput.requestId) ?? { index: 0, answers: {} }) : undefined;
const working = current?.isWorking ?? false;
const say = (text: string, bad = false) => { const say = (text: string, bad = false) => {
setFlash({ text, bad }); setFlash({ text, bad });
setTimeout(() => setFlash((current) => (current?.text === text ? null : current)), 4000); setTimeout(() => setFlash((value) => (value?.text === text ? null : value)), 4000);
}; };
const run = (label: string, action: () => Promise<void>) => { const run = (label: string, action: () => Promise<unknown>) => {
action().then( action().then(
() => say(label), () => say(label),
(error) => say(`${label} failed: ${error instanceof Error ? error.message : String(error)}`, true), (error) => say(`${label} failed: ${error instanceof Error ? error.message : String(error)}`, true),
); );
}; };
const respond = (decision: ProviderApprovalDecision) => { const respond = (decision: ProviderApprovalDecision) => {
if (!threadId || !pendingRequest) return say("Nothing is waiting for approval.", true); if (!threadId || !pendingApproval) return say("Nothing is waiting for approval.", true);
run(decision === "decline" ? "Declined" : "Approved", () => session.respond(threadId, pendingRequest.id, decision)); run(decision === "decline" ? "Declined" : "Approved", () => session.respond(threadId, pendingApproval.requestId, decision));
}; };
const submit = () => { const clearComposer = () => {
const composer = composerRef.current; composerRef.current?.setText("");
const text = composer?.plainText.trim() ?? ""; if (threadId) drafts.current.delete(threadId);
if (!composer || !text || !threadId) return;
composer.setText("");
drafts.current.delete(threadId);
setComposerLines(1); setComposerLines(1);
run(running ? "Queued for after the current run" : "Sent", () => session.sendMessage(threadId, text)); setComposerEmpty(true);
};
/** Moves the question flow on: the next question, or the answers once all are in. */
const advanceQuestion = (draft: QuestionDraft) => {
if (!threadId || !pendingInput) return;
const question = pendingInput.questions[draft.index];
if (!question || resolvePendingUserInputAnswer(question, draft.answers[question.id]) === null) {
setQuestionDrafts((map) => new Map(map).set(pendingInput.requestId, draft));
return say("Pick an option or type an answer.", true);
}
if (draft.index + 1 < pendingInput.questions.length) {
setQuestionDrafts((map) => new Map(map).set(pendingInput.requestId, { ...draft, index: draft.index + 1 }));
return;
}
const answers = buildPendingUserInputAnswers(pendingInput.questions, draft.answers);
if (!answers) return say("Some questions are unanswered.", true);
setQuestionDrafts((map) => new Map(map).set(pendingInput.requestId, draft));
run("Answered", () => session.answer(threadId, pendingInput.requestId, answers));
};
const pickOption = (optionIndex: number) => {
if (!pendingInput || !questionDraft) return;
const question = pendingInput.questions[questionDraft.index];
const option = question?.options[optionIndex];
if (!question || !option) return;
const draft = { ...questionDraft, answers: { ...questionDraft.answers, [question.id]: togglePendingUserInputOptionSelection(question, questionDraft.answers[question.id], option.value ?? option.label) } };
setQuestionDrafts((map) => new Map(map).set(pendingInput.requestId, draft));
// Single choice moves on by itself, after a beat to show the pick.
if (!question.multiSelect) setTimeout(() => advanceQuestion(draft), 200);
};
/** Enter in the composer; `alternate` is alt+enter, which flips steer and queue. */
const submit = (alternate = false) => {
const text = composerRef.current?.plainText.trim() ?? "";
if (!threadId) return;
if (pendingInput && questionDraft) {
const question = pendingInput.questions[questionDraft.index];
if (!question) return;
const answer = text ? setPendingUserInputCustomAnswer(question, questionDraft.answers[question.id], text) : questionDraft.answers[question.id];
clearComposer();
return advanceQuestion({ ...questionDraft, answers: { ...questionDraft.answers, ...(answer ? { [question.id]: answer } : {}) } });
}
if (!text) return;
clearComposer();
if (pendingApproval) {
// As in the web composer: the message declines the request and redirects the agent.
if (pendingApproval.supportsFeedback) return run("Declined with feedback", () => session.respond(threadId, pendingApproval.requestId, "decline", text));
return run("Declined and redirected", () => session.sendMessage(threadId, text, "steer"));
}
const dispatchMode = resolveComposerDispatchMode({ running: working, alternateModifier: alternate });
run(dispatchMode === "queue" ? "Queued" : dispatchMode === "steer" ? "Steered" : "Sent", () => session.sendMessage(threadId, text, dispatchMode));
};
const loadEarlier = () => {
if (!watchedId) return;
session.loadEarlier(watchedId).catch((error) => say(`Could not load earlier turns: ${error instanceof Error ? error.message : String(error)}`, true));
}; };
const quit = () => { const quit = () => {
@@ -121,11 +224,17 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
if (key.name === "pageup" || (key.ctrl && key.name === "u")) return scrollPage(-1), true; if (key.name === "pageup" || (key.ctrl && key.name === "u")) return scrollPage(-1), true;
if (!attachThreadId && ((key.ctrl && key.name === "n") || (key.meta && key.name === "down"))) return move(1), true; if (!attachThreadId && ((key.ctrl && key.name === "n") || (key.meta && key.name === "down"))) return move(1), true;
if (!attachThreadId && ((key.ctrl && key.name === "p") || (key.meta && key.name === "up"))) return move(-1), true; if (!attachThreadId && ((key.ctrl && key.name === "p") || (key.meta && key.name === "up"))) return move(-1), true;
if (mode === "input" && key.meta && key.name === "return") return submit(true), true;
return false; return false;
}; };
useKeyboard((key) => { useKeyboard((key) => {
if (globalKey(key)) return key.preventDefault(); if (globalKey(key)) return key.preventDefault();
const digit = /^[1-9]$/.test(key.name) && !key.ctrl && !key.meta ? Number(key.name) - 1 : -1;
if (digit >= 0 && pendingInput && (mode === "nav" || (mode === "input" && composerEmpty))) {
pickOption(digit);
return key.preventDefault();
}
if (mode === "input" || mode === "filter") { if (mode === "input" || mode === "filter") {
if (key.name === "escape") { if (key.name === "escape") {
setMode("nav"); setMode("nav");
@@ -146,11 +255,18 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
case "g": case "g":
return key.shift ? scroll?.scrollTo(scroll.scrollHeight) : scroll?.scrollTo(0); return key.shift ? scroll?.scrollTo(scroll.scrollHeight) : scroll?.scrollTo(0);
case "e": case "e":
return setExpandWork((value) => !value); return setExpandAll((value) => !value);
case "o":
return loadEarlier();
case "z":
return setShowFolded((value) => !value);
case "y": case "y":
return respond(key.shift ? "acceptForSession" : "accept"); return respond(key.shift ? "acceptForSession" : "accept");
case "n": case "n":
return respond("decline"); return respond("decline");
case "x":
if (threadId && pendingInput?.dismissible) run("Dismissed", () => session.dismissQuestion(threadId, pendingInput.requestId));
return;
case "s": case "s":
if (threadId && key.shift) run("Stop requested", () => session.stopThread(threadId)); if (threadId && key.shift) run("Stop requested", () => session.stopThread(threadId));
return; return;
@@ -165,16 +281,6 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
} }
}); });
const counts = useMemo(() => {
let needs = 0;
let active = 0;
for (const row of threadRows(shell.snapshot, { recentLimit: 0 })) {
if (row.group === "needs-you") needs++;
else if (row.group === "running") active++;
}
return { needs, active };
}, [shell.snapshot]);
const status = const status =
shell.status.type === "error" shell.status.type === "error"
? `error: ${shell.status.message}` ? `error: ${shell.status.message}`
@@ -184,10 +290,28 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
? "reconnecting…" ? "reconnecting…"
: (shell.serverUrl ?? ""); : (shell.serverUrl ?? "");
const listWidth = attachThreadId ? 0 : Math.min(46, Math.max(28, Math.floor(width * 0.3))); const listWidth = attachThreadId ? 0 : Math.min(46, Math.max(28, Math.floor(width * 0.3)));
const subtitle = threadShell
? [threadShell.modelSelection.model === "default" ? "" : threadShell.modelSelection.model, threadShell.branch, relativeTime(lastActivity(threadShell))].filter(Boolean).join(" · ")
: "";
const composerHeight = Math.min(MAX_COMPOSER_LINES, composerLines) + 2; const composerHeight = Math.min(MAX_COMPOSER_LINES, composerLines) + 2;
const placeholder =
mode !== "input"
? "Press i to type"
: pendingApproval
? pendingApproval.supportsFeedback
? "Send feedback to decline this request"
: "Send a message to decline and redirect the agent"
: pendingInput
? "Type your own answer, or leave this blank to use the selected option"
: working
? "Steer the agent (alt+enter to queue instead)"
: "Ask anything";
const footer = threadShell
? [
threadShell.modelSelection.model === "default" ? "" : threadShell.modelSelection.model,
threadShell.interactionMode === "plan" ? "Plan" : "Build",
threadShell.runtimeMode === "full-access" ? "" : (RUNTIME_MODE_LABELS[threadShell.runtimeMode] ?? threadShell.runtimeMode),
]
.filter(Boolean)
.join(" · ")
: "";
return ( return (
<box flexDirection="column" width={width} height={height} backgroundColor={colors.bg}> <box flexDirection="column" width={width} height={height} backgroundColor={colors.bg}>
@@ -195,23 +319,24 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
<text fg={colors.accent}> <text fg={colors.accent}>
<strong>tui3</strong> <strong>tui3</strong>
</text> </text>
<text fg={colors.faint}>{` ${status}`}</text> <text fg={shell.status.type === "live" ? colors.faint : colors.warn}>{` ${status}`}</text>
<box flexGrow={1} />
{counts.needs > 0 ? <text fg={colors.warn}>{`● ${counts.needs} need you `}</text> : null}
<text fg={colors.muted}>{`◐ ${counts.active} running`}</text>
</box> </box>
<box flexDirection="row" flexGrow={1} flexShrink={1} minHeight={0} overflow="hidden"> <box flexDirection="row" flexGrow={1} flexShrink={1} minHeight={0} overflow="hidden">
{attachThreadId ? null : <ThreadList rows={rows} selected={selectedIndex} focused={mode === "nav"} width={listWidth} height={height - 2} filter={filter} />} {attachThreadId ? null : (
<ThreadList rows={rows} collapsed={collapsed} selected={selectedIndex} focused={mode === "nav"} width={listWidth} height={height - 2} filter={filter} now={now} />
)}
<box flexDirection="column" flexGrow={1} minHeight={0}> <box flexDirection="column" flexGrow={1} minHeight={0}>
{threadId ? ( {threadId ? (
<ThreadView <ThreadView
title={threadShell?.title ?? "thread"} project={threadRow?.projectName ?? ""}
subtitle={subtitle} title={threadShell?.title ?? "Thread"}
transcript={watchedId === threadId ? transcript : null} detail={threadShell?.branch ?? ""}
timeline={current}
history={watchedId === threadId ? (thread?.history ?? null) : null}
loading={watchedId !== threadId || thread?.status === "loading"} loading={watchedId !== threadId || thread?.status === "loading"}
error={thread?.error} error={thread?.error}
working={running} workspaceRoot={threadShell?.worktreePath ?? undefined}
expandWork={expandWork} now={now}
scrollRef={scrollRef} scrollRef={scrollRef}
/> />
) : ( ) : (
@@ -219,6 +344,7 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
<text fg={colors.muted}>{shell.snapshot ? "No thread selected." : "Waiting for threads…"}</text> <text fg={colors.muted}>{shell.snapshot ? "No thread selected." : "Waiting for threads…"}</text>
</box> </box>
)} )}
{mode !== "filter" && pendingInput && questionDraft ? <QuestionPanel request={pendingInput} index={questionDraft.index} draft={questionDraft.answers[pendingInput.questions[questionDraft.index]?.id ?? ""]} /> : null}
{mode === "filter" ? ( {mode === "filter" ? (
<box title=" filter " border borderStyle="rounded" borderColor={colors.borderFocused} height={3} flexShrink={0} marginLeft={1} marginRight={1}> <box title=" filter " border borderStyle="rounded" borderColor={colors.borderFocused} height={3} flexShrink={0} marginLeft={1} marginRight={1}>
<input focused placeholder="title or project…" value={filter} onInput={(value: string) => setFilter(value)} onSubmit={() => setMode("nav")} /> <input focused placeholder="title or project…" value={filter} onInput={(value: string) => setFilter(value)} onSubmit={() => setMode("nav")} />
@@ -240,39 +366,51 @@ export function App(props: { readonly session: T3Session; readonly attachThreadI
ref={composerRef} ref={composerRef}
focused={mode === "input"} focused={mode === "input"}
initialValue={drafts.current.get(threadId) ?? ""} initialValue={drafts.current.get(threadId) ?? ""}
placeholder={mode === "input" ? (running ? "Message (queued until the current run finishes)" : "Message") : "Press i to type"} placeholder={placeholder}
placeholderColor={colors.faint} placeholderColor={colors.faint}
textColor={colors.text} textColor={colors.text}
keyBindings={[...COMPOSER_KEYS]} keyBindings={[...COMPOSER_KEYS]}
onSubmit={submit} onSubmit={() => submit()}
onContentChange={() => { onContentChange={() => {
const text = composerRef.current?.plainText ?? ""; const text = composerRef.current?.plainText ?? "";
if (text) drafts.current.set(threadId, text); if (text) drafts.current.set(threadId, text);
else drafts.current.delete(threadId); else drafts.current.delete(threadId);
setComposerLines(Math.max(1, text.split("\n").length)); setComposerLines(Math.max(1, text.split("\n").length));
setComposerEmpty(text.trim() === "");
}} }}
/> />
</box> </box>
) : null} ) : null}
{mode !== "filter" && threadId ? (
<box flexDirection="row" height={1} flexShrink={0} paddingLeft={2} paddingRight={2}>
<text fg={colors.faint}>{footer}</text>
</box>
) : null}
</box> </box>
</box> </box>
<box flexDirection="row" paddingLeft={2} height={1} flexShrink={0}> <box flexDirection="row" paddingLeft={2} height={1} flexShrink={0}>
{flash ? <text fg={flash.bad ? colors.bad : colors.good}>{flash.text}</text> : <text fg={colors.faint}>{hints(mode, Boolean(pendingRequest), Boolean(attachThreadId))}</text>} {flash ? (
<text fg={flash.bad ? colors.bad : colors.good}>{flash.text}</text>
) : (
<text fg={colors.faint}>{hints(mode, { approval: Boolean(pendingApproval), question: Boolean(pendingInput), working, attached: Boolean(attachThreadId) })}</text>
)}
</box> </box>
</box> </box>
); );
} }
function hints(mode: Mode, pending: boolean, attached: boolean): string { function hints(mode: Mode, state: { readonly approval: boolean; readonly question: boolean; readonly working: boolean; readonly attached: boolean }): string {
if (mode === "filter") return "enter done · esc close"; if (mode === "filter") return "enter done · esc close";
if (mode === "input") { if (mode === "input") {
const parts = ["enter send", "shift+enter newline", "esc navigate"]; const parts = [state.working ? "enter steer · alt+enter queue" : "enter send", "shift+enter newline", "esc navigate"];
if (!attached) parts.push("ctrl+n/p switch thread"); if (state.question) parts.unshift("1-9 pick");
if (pending) parts.unshift("approval waiting: esc, then y/n"); if (state.approval) parts.unshift("approval waiting: esc, then y/n");
if (!state.attached) parts.push("ctrl+n/p thread");
return parts.join(" · "); return parts.join(" · ");
} }
const parts = attached ? ["j/k scroll"] : ["j/k threads", "/ filter"]; const parts = state.attached ? ["j/k scroll"] : ["j/k threads", "/ filter", "z settled"];
parts.push("i type", "e expand work", "pgup/pgdn scroll", "S stop", "q quit"); parts.push("i type", "e expand", "o earlier", "S stop", "q quit");
if (pending) parts.unshift("y accept · Y session · n decline"); if (state.question) parts.unshift("1-9 pick · x dismiss");
if (state.approval) parts.unshift("y approve · Y always · n decline");
return parts.join(" · "); return parts.join(" · ");
} }
+42
View File
@@ -0,0 +1,42 @@
import type { ThreadPendingUserInput } from "@t3tools/client-runtime/state/thread-requests";
import { isPendingUserInputOptionSelected, type PendingUserInputDraftAnswer } from "@t3tools/client-runtime/state/pending-user-input";
import { colors } from "./theme.ts";
/**
* The web composer's pending-input panel: header with progress, the question,
* and its options with digit shortcuts. The composer below takes a typed answer.
*/
export function QuestionPanel(props: {
readonly request: ThreadPendingUserInput;
readonly index: number;
readonly draft: PendingUserInputDraftAnswer | undefined;
}) {
const { request, index, draft } = props;
const question = request.questions[index];
if (!question) return null;
const total = request.questions.length;
return (
<box border borderStyle="rounded" borderColor={colors.input} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={1} paddingRight={1}>
<box flexDirection="row">
<text fg={colors.input}>
<strong>{question.header}</strong>
</text>
<box flexGrow={1} />
<text fg={colors.faint}>{total > 1 ? `${index + 1}/${total}` : ""}</text>
</box>
<text fg={colors.text}>{question.question}</text>
{question.options.slice(0, 9).map((option, optionIndex) => {
const selected = isPendingUserInputOptionSelected(question, draft, option.value ?? option.label);
const mark = question.multiSelect ? (selected ? "☑" : "☐") : selected ? "●" : "○";
return (
<box key={option.label} flexDirection="row">
<text fg={selected ? colors.input : colors.faint}>{`${optionIndex + 1} ${mark} `}</text>
<text fg={selected ? colors.text : colors.muted}>{option.label}</text>
<text fg={colors.faint}>{option.description ? ` ${option.description}` : ""}</text>
</box>
);
})}
</box>
);
}
+56 -47
View File
@@ -1,69 +1,78 @@
import { GROUP_LABELS, lastActivity, relativeTime, type ThreadRow } from "../model/threads.ts"; import { needsAttention, relativeTime, rowTime, SECTION_LABELS, statusLabel, type Section, type ThreadRow } from "../model/threads.ts";
import { colors } from "./theme.ts"; import { colors, statusColor } from "./theme.ts";
const STATUS_GLYPH: Record<string, { glyph: string; color: string }> = { /**
"needs-you": { glyph: "●", color: colors.warn }, * The web sidebar as a list: section headers, then two-line rows of
running: { glyph: "◐", color: colors.accent }, * project + status (or time), and the title, bold when it needs you and
failed: { glyph: "✕", color: colors.bad }, * dimmed while it works or once read.
interrupted: { glyph: "◌", color: colors.muted }, */
completed: { glyph: "✓", color: colors.faint }, export function ThreadList(props: {
idle: { glyph: "·", color: colors.faint }, readonly rows: readonly ThreadRow[];
}; /** Sections folded to a header with a count, like the web's Snoozed and Settled. */
readonly collapsed: ReadonlyMap<Section, number>;
function glyphFor(row: ThreadRow) { readonly selected: number;
if (row.group !== "recent") return STATUS_GLYPH[row.group]!; readonly focused: boolean;
return STATUS_GLYPH[row.thread.status] ?? STATUS_GLYPH.idle!; readonly width: number;
} readonly height: number;
readonly filter: string;
export function ThreadList(props: { readonly rows: readonly ThreadRow[]; readonly selected: number; readonly focused: boolean; readonly width: number; readonly height: number; readonly filter: string }) { readonly now: number;
const { rows, selected, focused, width, height } = props; }) {
// Rows take two lines and up to three group headers take one each; keep the selection in view. const { rows, selected, focused, width, height, now } = props;
const visibleCount = Math.max(1, Math.floor((height - 3) / 2)); // Rows take two lines plus a header per section; keep the selection in view.
const visibleCount = Math.max(1, Math.floor((height - 6) / 2));
const start = Math.max(0, Math.min(selected - Math.floor(visibleCount / 2), rows.length - visibleCount)); const start = Math.max(0, Math.min(selected - Math.floor(visibleCount / 2), rows.length - visibleCount));
const windowRows = rows.slice(start, start + visibleCount); const windowRows = rows.slice(start, start + visibleCount);
const titleWidth = Math.max(8, width - 12); const inner = Math.max(8, width - 3);
const now = Date.now(); // Active goes unlabelled when it leads the list, as in the web sidebar.
const labelActive = rows.some((row) => row.section === "pinned");
const lines: React.ReactNode[] = []; const lines: React.ReactNode[] = [];
let previousGroup = start > 0 ? rows[start - 1]?.group : undefined; let previousSection = start > 0 ? rows[start - 1]?.section : undefined;
windowRows.forEach((row, offset) => { windowRows.forEach((row, offset) => {
const index = start + offset; const index = start + offset;
if (row.group !== previousGroup) { if (row.section !== previousSection) {
lines.push( if (row.section !== "active" || labelActive) lines.push(<SectionHeader key={`h-${row.section}`} label={SECTION_LABELS[row.section]} />);
<text key={`h-${row.group}`} fg={row.group === "needs-you" ? colors.warn : colors.muted}> else if (previousSection !== undefined) lines.push(<text key="h-gap"> </text>);
<strong>{GROUP_LABELS[row.group]}</strong> previousSection = row.section;
</text>,
);
previousGroup = row.group;
} }
const { glyph, color } = glyphFor(row);
const isSelected = index === selected; const isSelected = index === selected;
const title = truncate(row.thread.title || "(untitled)", titleWidth); const status = statusLabel(row, now);
const right = status?.text ?? relativeTime(rowTime(row.thread), now);
const left = truncate(row.projectName || "No project", Math.max(4, inner - right.length - 1));
const attention = needsAttention(row);
const recede = !isSelected && (row.status === "working" || row.status === "waiting" || (row.status === "ready" && !row.unread));
const title = truncate(row.thread.title || "New thread", inner);
lines.push( lines.push(
<box key={row.thread.id} flexDirection="row" backgroundColor={isSelected ? (focused ? colors.selectedBg : colors.border) : "transparent"}> <box key={row.thread.id} flexDirection="column" paddingLeft={1} paddingRight={1} backgroundColor={isSelected ? (focused ? colors.selectedBg : colors.panel) : "transparent"}>
<text fg={color}>{` ${glyph} `}</text> <box flexDirection="row">
<box flexGrow={1} flexDirection="column"> <text fg={colors.faint}>{left}</text>
<text fg={isSelected ? colors.text : colors.text}>{title}</text> <box flexGrow={1} />
<text fg={colors.faint}>{truncate(`${row.projectName} · ${relativeTime(lastActivity(row.thread), now)}`, titleWidth)}</text> <text fg={status ? statusColor[status.tone] : colors.faint}>{right}</text>
</box> </box>
<text fg={recede ? colors.muted : colors.text}>{attention ? <strong>{title}</strong> : title}</text>
</box>, </box>,
); );
}); });
const collapsed = [...props.collapsed].filter(([, count]) => count > 0);
return ( return (
<box <box border={["right"]} borderColor={colors.border} width={width} flexShrink={0} overflow="hidden" flexDirection="column">
border={["right"]}
borderColor={colors.border}
width={width}
flexShrink={0}
overflow="hidden"
flexDirection="column"
paddingLeft={0}
>
{props.filter ? <text fg={colors.accent}>{` /${props.filter}`}</text> : null} {props.filter ? <text fg={colors.accent}>{` /${props.filter}`}</text> : null}
{rows.length === 0 ? <text fg={colors.muted}> no threads</text> : lines} {rows.length === 0 ? <text fg={colors.muted}>{props.filter ? " no matches" : " no threads"}</text> : lines}
<box flexGrow={1} />
{collapsed.map(([section, count]) => (
<text key={section} fg={colors.faint}>{` › ${SECTION_LABELS[section]} ${count}`}</text>
))}
</box> </box>
); );
} }
function SectionHeader({ label }: { readonly label: string }) {
return (
<text fg={colors.muted} paddingLeft={1}>
<strong>{label}</strong>
</text>
);
}
function truncate(text: string, width: number): string { function truncate(text: string, width: number): string {
const single = text.replace(/\s+/g, " "); const single = text.replace(/\s+/g, " ");
return single.length > width ? `${single.slice(0, Math.max(0, width - 1))}…` : single; return single.length > width ? `${single.slice(0, Math.max(0, width - 1))}…` : single;
+190 -87
View File
@@ -1,145 +1,248 @@
import type { ScrollBoxRenderable } from "@opentui/core"; import type { ScrollBoxRenderable } from "@opentui/core";
import { formatWorkingDurationLabel } from "@t3tools/client-runtime/state/models";
import { liveThoughtLine, workEntryDisplayIndicatesToolFailure, type ToolGroupSummaryKind } from "@t3tools/client-runtime/work-log/presentation";
import { memo, type RefObject } from "react"; import { memo, type RefObject } from "react";
import { summarizeWork, type Segment, type Step, type Transcript } from "../model/transcript.ts"; import type { ThreadHistory } from "../client/session.ts";
import { liveWorkEntryLabel, workEntryDisplayLabel, type MessagesTimelineRow, type Timeline, type WorkLogEntry } from "../model/timeline.ts";
import { blockFor } from "../model/transcript.ts";
import { colors, getMarkdownStyle, toneColor } from "./theme.ts"; import { colors, getMarkdownStyle, toneColor } from "./theme.ts";
/** The conversation, row for row as the web app derives it (MessagesTimeline.logic). */
export function ThreadView(props: { export function ThreadView(props: {
readonly project: string;
readonly title: string; readonly title: string;
readonly subtitle: string; readonly detail: string;
readonly transcript: Transcript | null; readonly timeline: Timeline | null;
readonly history: ThreadHistory | null;
readonly loading: boolean; readonly loading: boolean;
readonly error?: string | undefined; readonly error?: string | undefined;
readonly working: boolean; readonly workspaceRoot: string | undefined;
readonly expandWork: boolean; readonly now: number;
readonly scrollRef: RefObject<ScrollBoxRenderable | null>; readonly scrollRef: RefObject<ScrollBoxRenderable | null>;
}) { }) {
const { transcript } = props; const { timeline, history } = props;
const last = transcript?.segments.at(-1); const pendingIds = new Set<string>(timeline?.pending.approvals.map((approval) => approval.requestId) ?? []);
// The folded work line already says it's working; otherwise show it at the bottom.
const showWorking = props.working && !(last?.kind === "work" && last.active) && !(last?.kind === "assistant" && last.streaming);
return ( return (
<box flexGrow={1} minHeight={0} flexDirection="column" paddingLeft={1} paddingRight={1}> <box flexGrow={1} minHeight={0} flexDirection="column" paddingLeft={1} paddingRight={1}>
<box flexDirection="row" flexShrink={0} height={1}> <box flexDirection="row" flexShrink={0} height={1}>
<text fg={colors.muted}>{props.project ? `${props.project} / ` : ""}</text>
<text fg={colors.text}> <text fg={colors.text}>
<strong>{props.title}</strong> <strong>{props.title}</strong>
</text> </text>
<text fg={colors.faint}>{props.subtitle ? ` ${props.subtitle}` : ""}</text> <box flexGrow={1} />
<text fg={colors.faint}>{props.detail}</text>
</box> </box>
{props.error ? <text fg={colors.bad} flexShrink={0}>{props.error}</text> : null} {props.error ? <text fg={colors.bad} flexShrink={0}>{props.error}</text> : null}
<scrollbox ref={props.scrollRef} flexGrow={1} flexShrink={1} minHeight={0} stickyScroll stickyStart="bottom"> <scrollbox ref={props.scrollRef} flexGrow={1} flexShrink={1} minHeight={0} stickyScroll stickyStart="bottom">
{props.loading && !transcript ? <text fg={colors.muted}>loading…</text> : null} {props.loading && !timeline ? <text fg={colors.muted}>Loading…</text> : null}
{transcript && transcript.hiddenCount > 0 ? <text fg={colors.faint}>{`… ${transcript.hiddenCount} earlier items`}</text> : null} {history?.hasMore || history?.error ? <LoadEarlier history={history} /> : null}
{transcript?.segments.map((segment) => <SegmentView key={segment.id} segment={segment} expandWork={props.expandWork} />)} {timeline?.rows.map((row) => (
{showWorking ? <text fg={colors.accent} marginTop={1}>◐ working…</text> : null} <Row
key={row.id}
row={row}
pending={row.kind === "event" && pendingIds.has(eventRequestId(row) ?? "")}
workspaceRoot={props.workspaceRoot}
now={row.kind === "working" ? props.now : 0}
workStartedAt={timeline.workStartedAt}
/>
))}
</scrollbox> </scrollbox>
</box> </box>
); );
} }
/** Memoized: unchanged segments keep their object identity across updates, so only what changed re-renders. */ function LoadEarlier({ history }: { readonly history: ThreadHistory }) {
const SegmentView = memo(function SegmentView({ segment, expandWork }: { readonly segment: Segment; readonly expandWork: boolean }) { const label = history.loading ? "Loading earlier turns…" : history.error ? `Could not load earlier turns: ${history.error} (o to retry)` : "Load earlier turns (o)";
switch (segment.kind) { return <Divider label={label} color={history.error ? colors.bad : colors.faint} />;
case "user": { }
const { text, hidden } = expandWork ? { text: segment.text.trim(), hidden: 0 } : clip(segment.text.trim());
function Divider({ label, color }: { readonly label: string; readonly color: string }) {
return ( return (
<box marginTop={1} border={["left"]} borderColor={colors.user} backgroundColor={colors.userBg} paddingLeft={1} paddingRight={1} flexDirection="column"> <box flexDirection="row" marginTop={1}>
<text fg={colors.text}>{text}</text> <box flexGrow={1} border={["bottom"]} borderColor={colors.border} height={1} />
{hidden > 0 ? <text fg={colors.faint}>{`… ${hidden} more lines (e to expand)`}</text> : null} <text fg={color}>{` ${label} `}</text>
<box flexGrow={1} border={["bottom"]} borderColor={colors.border} height={1} />
</box> </box>
); );
} }
case "assistant":
/**
* Memoized: computeStableMessagesTimelineRows keeps unchanged rows identical,
* so a streamed update re-renders only its own rows. `now` is nonzero only for
* the working row, which ticks.
*/
const Row = memo(function Row(props: {
readonly row: MessagesTimelineRow;
readonly pending: boolean;
readonly workspaceRoot: string | undefined;
readonly now: number;
readonly workStartedAt: string | null;
}) {
const { row, workspaceRoot } = props;
switch (row.kind) {
case "message": {
const { message } = row;
if (message.role === "user") return <UserMessage text={message.text} />;
if (message.role === "system") return <text marginTop={1} fg={colors.muted}>{message.text}</text>;
return ( return (
<box marginTop={1} paddingLeft={1}> <box marginTop={1}>
<markdown content={segment.markdown || "…"} syntaxStyle={getMarkdownStyle()} streaming={segment.streaming} conceal /> <markdown content={message.text || "…"} syntaxStyle={getMarkdownStyle()} streaming={message.streaming} conceal />
</box>
);
}
case "turn-fold":
case "attempt-fold":
// The finished turn's work, folded: the web's turn separator.
return (
<box marginTop={1} border={["bottom"]} borderColor={colors.border} flexDirection="row">
<text fg={colors.muted}>{`${row.label} ${row.expanded ? "⌄" : "›"}`}</text>
</box>
);
case "work-toggle":
return (
<box marginTop={1} flexDirection="row">
<text fg={row.hasFailure ? colors.bad : colors.muted}>{`${SUMMARY_GLYPH[row.summaryKind] ?? "•"} ${row.summary} ${row.expanded ? "⌄" : "›"}`}</text>
</box> </box>
); );
case "work": case "work":
return expandWork ? <ExpandedWork steps={segment.steps} /> : <FoldedWork steps={segment.steps} active={segment.active} />;
case "approval":
return ( return (
<box marginTop={1} border borderStyle="rounded" borderColor={segment.pending ? colors.warn : colors.border} flexDirection="column" paddingLeft={1} paddingRight={1}> <box marginTop={row.continuesWorkLog ? 0 : 1} flexDirection="column">
<text fg={segment.pending ? colors.warn : colors.muted}> {row.groupedEntries.map((entry) => (
<strong>{segment.pending ? "Needs approval" : "Approval"}</strong> <WorkEntry key={entry.id} entry={entry} label={row.displayLabel && row.groupedEntries.length === 1 ? row.displayLabel : workEntryDisplayLabel(entry, workspaceRoot)} />
</text>
<text fg={colors.text}>{segment.title}</text>
{segment.detail ? <text fg={colors.muted}>{segment.detail}</text> : null}
{segment.pending ? <text fg={colors.faint}>esc, then y accept · Y accept for session · n decline</text> : null}
</box>
);
case "question":
return (
<box marginTop={1} border borderStyle="rounded" borderColor={segment.pending ? colors.warn : colors.border} flexDirection="column" paddingLeft={1} paddingRight={1}>
<text fg={segment.pending ? colors.warn : colors.muted}>
<strong>{segment.pending ? "Question for you" : "Question"}</strong>
</text>
{segment.questions.map((question, index) => (
<text key={index} fg={colors.text}>{question}</text>
))} ))}
{segment.pending ? <text fg={colors.faint}>Answer this in the T3 Code app for now.</text> : null}
</box> </box>
); );
case "alert": case "work-live":
return <text marginTop={1} paddingLeft={1} fg={toneColor[segment.tone]}>{segment.text}</text>; return (
<box marginTop={1} flexDirection="column">
{row.thought?.detail ? <text fg={colors.faint}>{`∴ ${liveThoughtLine(row.thought.detail)}`}</text> : null}
<text fg={row.active ? colors.info : colors.muted}>{`${row.active ? "◐" : glyphFor(row.entry)} ${liveWorkEntryLabel(row.entry, workspaceRoot, row.active)}`}</text>
</box>
);
case "working": {
const since = props.workStartedAt ? Date.parse(props.workStartedAt) : NaN;
const verb = row.compacting ? "Compacting" : "Working";
return <text marginTop={1} fg={colors.info}>{Number.isFinite(since) ? `◐ ${verb} for ${formatWorkingDurationLabel(props.now - since)}` : `◐ ${verb}…`}</text>;
}
case "thinking":
return <text marginTop={1} fg={colors.faint}>∴ Thinking…</text>;
case "context-compaction":
return <Divider label={row.failed ? `${row.title ?? "Compaction failed"}${row.failure ? `: ${row.failure}` : ""}` : (row.title ?? row.label)} color={row.failed ? colors.bad : colors.faint} />;
case "proposed-plan":
return (
<box marginTop={1} border borderStyle="rounded" borderColor={colors.plan} flexDirection="column" paddingLeft={1} paddingRight={1}>
<text fg={colors.plan}>
<strong>Plan</strong>
</text>
<markdown content={row.proposedPlan.planMarkdown} syntaxStyle={getMarkdownStyle()} conceal />
</box>
);
case "event":
return <EventRow item={row.projectedItem.item} pending={props.pending} />;
case "worktree-setup":
return <text marginTop={1} fg={colors.info}>◐ Setting up worktree…</text>;
default:
// assistant-meta, html-render, mcp-app: nothing a terminal can show.
return null;
} }
}); });
function FoldedWork({ steps, active }: { readonly steps: readonly Step[]; readonly active: boolean }) { const USER_FOLD_LINES = 8;
const latest = active ? steps.at(-1) : undefined; const USER_FOLD_CHARS = 600;
/** The web's user bubble: right-aligned, at most 80% wide, folded past 8 lines or 600 characters. */
function UserMessage({ text }: { readonly text: string }) {
const trimmed = text.trim();
const lines = trimmed.split("\n");
let shown = lines.slice(0, USER_FOLD_LINES).join("\n");
if (shown.length > USER_FOLD_CHARS) shown = `${shown.slice(0, USER_FOLD_CHARS).trimEnd()}…`;
const folded = shown.length < trimmed.length;
return ( return (
<box marginTop={1} paddingLeft={1} flexDirection="column"> <box marginTop={1} alignSelf="flex-end" maxWidth="80%" backgroundColor={colors.userBg} paddingLeft={1} paddingRight={1} flexDirection="column">
<text fg={active ? colors.accent : colors.faint}>{`${active ? "◐" : "▸"} ${summarizeWork(steps)}`}</text> <text fg={colors.text}>{shown}</text>
{latest ? <text fg={colors.muted}>{` ${stepLine(latest)}`}</text> : null} {folded ? <text fg={colors.faint}>{`… ${Math.max(1, lines.length - shown.split("\n").length)} more lines`}</text> : null}
</box> </box>
); );
} }
function ExpandedWork({ steps }: { readonly steps: readonly Step[] }) { function WorkEntry({ entry, label }: { readonly entry: WorkLogEntry; readonly label: string }) {
const failed = workEntryDisplayIndicatesToolFailure(entry);
const tone = failed || entry.tone === "error" ? colors.bad : entry.tone === "thinking" ? colors.faint : colors.muted;
return <text fg={tone}>{`${failed ? "✕" : glyphFor(entry)} ${firstLine(label)}`}</text>;
}
function EventRow({ item, pending }: { readonly item: MessagesTimelineRow extends infer R ? (R extends { kind: "event"; projectedItem: { item: infer I } } ? I : never) : never; readonly pending: boolean }) {
if (item.type === "approval_request" && pending) {
return ( return (
<box marginTop={1} paddingLeft={1} flexDirection="column"> <box marginTop={1} border borderStyle="rounded" borderColor={colors.warn} flexDirection="column" paddingLeft={1} paddingRight={1}>
{steps.map((step) => ( <text fg={colors.warn}>
<box key={step.id} flexDirection="column"> <strong>{approvalTitle(item.requestKind)}</strong>
<text fg={step.kind === "reasoning" ? colors.faint : toneColor[step.tone]}>{stepLine(step)}</text> </text>
{step.kind === "tool" && step.detail ? <text fg={colors.faint}>{indent(step.detail, " ")}</text> : null} {item.prompt ? <text fg={colors.text}>{item.prompt}</text> : null}
</box> {item.reason ? <text fg={colors.muted}>{item.reason}</text> : null}
))} <text fg={colors.faint}>Waiting for approval · y Approve · Y Always allow this session · n Decline</text>
</box> </box>
); );
} }
const block = blockFor(item, new Set());
function stepLine(step: Step): string { if (!block) return null;
switch (step.kind) { switch (block.kind) {
case "tool":
return `${step.icon} ${step.label}`;
case "reasoning":
return `∴ ${firstLine(step.text)}`;
case "notice": case "notice":
return `· ${step.text}`; return <text marginTop={1} fg={toneColor[block.tone]}>{block.text}</text>;
case "tool":
return <text marginTop={1} fg={toneColor[block.tone]}>{`${block.icon} ${block.label}`}</text>;
case "approval":
return <text marginTop={1} fg={colors.muted}>{`Approval requested: ${block.title}`}</text>;
case "question":
return <text marginTop={1} fg={colors.muted}>{block.pending ? "Input requested" : "Answered questions"}</text>;
default:
return null;
} }
} }
const CLIP_LINES = 6; function approvalTitle(kind: string): string {
const CLIP_CHARS = 480; if (kind.includes("command")) return "Command approval";
if (kind.includes("read")) return "File read approval";
if (kind.includes("file")) return "File change approval";
if (kind.includes("access")) return "App access approval";
if (kind.includes("permission")) return "App permission approval";
return "Approval";
}
/** Long prompts (delegation briefs, pasted logs) shrink to their opening lines. */ function eventRequestId(row: Extract<MessagesTimelineRow, { kind: "event" }>): string | undefined {
function clip(text: string): { readonly text: string; readonly hidden: number } { const item = row.projectedItem.item;
const lines = text.split("\n"); return item.type === "approval_request" ? item.requestId : undefined;
let kept = lines.slice(0, CLIP_LINES).join("\n"); }
if (kept.length > CLIP_CHARS) kept = `${kept.slice(0, CLIP_CHARS).trimEnd()}…`;
const keptLines = kept.split("\n").length; /** Terminal stand-ins for the web's lucide icons. */
const hidden = lines.length - keptLines; const SUMMARY_GLYPH: Partial<Record<ToolGroupSummaryKind, string>> = {
return kept.length < text.length ? { text: kept, hidden: Math.max(hidden, 1) } : { text, hidden: 0 }; read: "◉",
edit: "✎",
command: "$",
"code-search": "⌕",
search: "⌕",
browser: "◍",
reasoning: "∴",
"thread-create": "↳",
"agent-tool": "↳",
"pull-request": "⇅",
"dynamic-tool": "⚙",
other: "⚙",
mixed: "•",
};
function glyphFor(entry: WorkLogEntry): string {
if (entry.tone === "thinking" || entry.itemType === "reasoning") return "∴";
if (entry.command) return "$";
if (entry.changedFiles?.length) return "✎";
if (entry.itemType === "subagent") return "↳";
if (entry.itemType === "file_search" || entry.itemType === "web_search") return "⌕";
if (entry.itemType === "todo_list") return "☐";
return "·";
} }
function firstLine(text: string): string { function firstLine(text: string): string {
const line = (text.trim().split("\n")[0] ?? "").replace(/\*\*(.+?)\*\*/g, "$1"); const line = (text.trim().split("\n")[0] ?? "").replace(/\s+/g, " ");
return line.length > 120 ? `${line.slice(0, 117)}…` : line; return line.length > 200 ? `${line.slice(0, 197)}…` : line;
}
function indent(text: string, prefix: string): string {
return text
.split("\n")
.map((line) => prefix + line)
.join("\n");
} }
+14
View File
@@ -1,5 +1,6 @@
import { SyntaxStyle } from "@opentui/core"; import { SyntaxStyle } from "@opentui/core";
import type { StatusTone } from "../model/threads.ts";
import type { Tone } from "../model/transcript.ts"; import type { Tone } from "../model/transcript.ts";
export const colors = { export const colors = {
@@ -17,8 +18,21 @@ export const colors = {
bad: "#f7768e", bad: "#f7768e",
warn: "#e0af68", warn: "#e0af68",
selectedBg: "#283457", selectedBg: "#283457",
/** The web app's sky / indigo / violet status hues. */
info: "#7dcfff",
input: "#bb9af7",
plan: "#c099ff",
} as const; } as const;
export const statusColor: Record<StatusTone, string> = {
info: colors.info,
muted: colors.muted,
warn: colors.warn,
input: colors.input,
bad: colors.bad,
good: colors.good,
};
export const toneColor: Record<Tone, string> = { export const toneColor: Record<Tone, string> = {
normal: colors.text, normal: colors.text,
muted: colors.muted, muted: colors.muted,
+26 -3
View File
@@ -19,12 +19,35 @@ const isCommand = Schema.is(OrchestrationV2Command);
const threadId = ThreadId.make("thread-1"); const threadId = ThreadId.make("thread-1");
describe("commands tui3 dispatches", () => { describe("commands tui3 dispatches", () => {
test("a queued message is a valid message.dispatch", async () => { test("messages dispatch like the web composer: auto, steer or queue", async () => {
const { session, sent } = capturingSession(); const { session, sent } = capturingSession();
await session.sendMessage(threadId, "hello"); await session.sendMessage(threadId, "hello");
expect(sent).toHaveLength(1); await session.sendMessage(threadId, "change course", "steer");
await session.sendMessage(threadId, "after that", "queue");
expect(sent.every(isCommand)).toBe(true);
expect(sent[0]).toMatchObject({ type: "message.dispatch", threadId, text: "hello", dispatchMode: { type: "start_immediately" }, deliveryIntent: "auto" });
expect(sent[1]).toMatchObject({ dispatchMode: { type: "start_immediately" }, deliveryIntent: "steer" });
expect(sent[2]).toMatchObject({ dispatchMode: { type: "queue_after_active" } });
expect(sent[2]).not.toHaveProperty("deliveryIntent");
});
test("declining with feedback, answering and dismissing questions are valid", async () => {
const { session, sent } = capturingSession();
const requestId = RuntimeRequestId.make("req-1");
await session.respond(threadId, requestId, "decline", "use the staging bucket");
await session.answer(threadId, requestId, { q1: "yes", q2: ["a", "b"] });
await session.dismissQuestion(threadId, requestId);
expect(sent.every(isCommand)).toBe(true);
expect(sent[0]).toMatchObject({ decision: "decline", feedback: "use the staging bucket" });
expect(sent[1]).toMatchObject({ type: "runtime-request.respond", answers: { q1: "yes", q2: ["a", "b"] } });
expect(sent[2]).toMatchObject({ type: "thread.user-input.dismiss" });
});
test("a visit is a valid thread.visit", async () => {
const { session, sent } = capturingSession();
await session.visit(threadId);
expect(isCommand(sent[0])).toBe(true); expect(isCommand(sent[0])).toBe(true);
expect(sent[0]).toMatchObject({ type: "message.dispatch", threadId, text: "hello", dispatchMode: { type: "queue_after_active" } }); expect(sent[0]).toMatchObject({ type: "thread.visit", threadId, opened: true });
}); });
test("an approval is a valid runtime-request.respond", async () => { test("an approval is a valid runtime-request.respond", async () => {
+41 -9
View File
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts"; import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
import * as DateTime from "effect/DateTime"; import * as DateTime from "effect/DateTime";
import { findThread, relativeTime, threadRows } from "../src/model/threads.ts"; import { findThread, relativeTime, statusLabel, threadRows } from "../src/model/threads.ts";
const at = (ms: number) => DateTime.makeUnsafe(ms); const at = (ms: number) => DateTime.makeUnsafe(ms);
const thread = (id: string, title: string, updated: number, extra: Record<string, unknown> = {}) => ({ const thread = (id: string, title: string, updated: number, extra: Record<string, unknown> = {}) => ({
@@ -11,7 +11,23 @@ const thread = (id: string, title: string, updated: number, extra: Record<string
projectId: "p1", projectId: "p1",
status: "completed", status: "completed",
activeRunId: null, activeRunId: null,
latestRunId: "run-1",
latestRunRequestedAt: at(updated - 100),
latestRunStartedAt: at(updated - 90),
latestRunCompletedAt: at(updated),
pendingRuntimeRequest: null, pendingRuntimeRequest: null,
latestUserMessageAt: null,
lineage: { relationshipToParent: null, parentThreadId: null },
modelSelection: { instanceId: "codex", model: "gpt" },
archivedAt: null,
deletedAt: null,
settledOverride: null,
settledAt: null,
pinnedAt: null,
lastVisitedAt: at(updated + 1),
hasActionableProposedPlan: false,
interactionMode: "default",
createdAt: at(0),
updatedAt: at(updated), updatedAt: at(updated),
...extra, ...extra,
}); });
@@ -19,21 +35,36 @@ const snapshot = {
projects: [{ id: "p1", title: "tasknotes", workspaceRoot: "/home/me/tasknotes" }], projects: [{ id: "p1", title: "tasknotes", workspaceRoot: "/home/me/tasknotes" }],
threads: [ threads: [
thread("mcp:launch:aaaa1111", "old finished", 1_000), thread("mcp:launch:aaaa1111", "old finished", 1_000),
thread("t-running", "busy one", 2_000, { status: "running", activeRunId: "r1" }), thread("t-running", "busy one", 2_000, { status: "running", activeRunId: "run-1", latestRunCompletedAt: null }),
thread("t-waiting", "wants approval", 500, { status: "running", activeRunId: "r2", pendingRuntimeRequest: { id: "q", kind: "command", createdAt: at(0) } }), thread("t-waiting", "wants approval", 500, { status: "running", activeRunId: "run-1", latestRunCompletedAt: null, pendingRuntimeRequest: { id: "q", kind: "command", createdAt: at(0) } }),
thread("t-new", "newest finished", 3_000), thread("t-new", "newest finished", 3_000, { lastVisitedAt: at(10) }),
thread("t-settled", "put away", 4_000, { settledOverride: "settled", settledAt: at(4_000) }),
thread("t-child", "a subagent", 5_000, { lineage: { relationshipToParent: "subagent", parentThreadId: "t-new" } }),
], ],
} as unknown as OrchestrationV2ShellSnapshot; } as unknown as OrchestrationV2ShellSnapshot;
describe("threadRows", () => { describe("threadRows", () => {
test("orders needs-you, then running, then recent by activity", () => { test("uses the web sidebar's sections and leaves subagents under their parent", () => {
expect(threadRows(snapshot).map((row) => row.thread.id as string)).toEqual(["t-waiting", "t-running", "t-new", "mcp:launch:aaaa1111"]); expect(threadRows(snapshot).map((row) => [row.thread.id as string, row.section])).toEqual([
["t-new", "active"],
["mcp:launch:aaaa1111", "active"],
["t-waiting", "active"],
["t-running", "working"],
["t-settled", "settled"],
]);
}); });
test("filters by title or project and caps recent rows", () => { test("shows the sidebar's status words", () => {
const byId = new Map(threadRows(snapshot).map((row) => [row.thread.id as string, row]));
expect(statusLabel(byId.get("t-waiting")!)?.text).toBe("Approval");
expect(statusLabel(byId.get("t-new")!)?.text).toBe("Done");
expect(statusLabel(byId.get("mcp:launch:aaaa1111")!)).toBeNull();
expect(statusLabel(byId.get("t-running")!, 2_000 + 75_000)?.text).toBe("Working 1m");
});
test("filters by title or project", () => {
expect(threadRows(snapshot, { query: "BUSY" }).map((row) => row.thread.id as string)).toEqual(["t-running"]); expect(threadRows(snapshot, { query: "BUSY" }).map((row) => row.thread.id as string)).toEqual(["t-running"]);
expect(threadRows(snapshot, { query: "tasknotes" })).toHaveLength(4); expect(threadRows(snapshot, { query: "tasknotes" })).toHaveLength(5);
expect(threadRows(snapshot, { recentLimit: 1 }).map((row) => row.group)).toEqual(["needs-you", "running", "recent"]);
}); });
}); });
@@ -46,6 +77,7 @@ describe("findThread", () => {
}); });
test("relativeTime", () => { test("relativeTime", () => {
expect(relativeTime(0, 2_000)).toBe("now");
expect(relativeTime(0, 45_000)).toBe("45s"); expect(relativeTime(0, 45_000)).toBe("45s");
expect(relativeTime(0, 3 * 3600_000)).toBe("3h"); expect(relativeTime(0, 3 * 3600_000)).toBe("3h");
}); });
-49
View File
@@ -27,52 +27,3 @@ describe("blockFor", () => {
expect(blockFor(item({ type: "checkpoint" }), new Set())).toBeNull(); expect(blockFor(item({ type: "checkpoint" }), new Set())).toBeNull();
}); });
}); });
import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
import { buildTranscript, summarizeWork } from "../src/model/transcript.ts";
const projectionOf = (items: OrchestrationV2TurnItem[], pendingIds: string[] = []) =>
({
runtimeRequests: pendingIds.map((id) => ({ id, status: "pending" })),
visibleTurnItems: items.map((entry, position) => ({ position, item: entry })),
}) as unknown as OrchestrationV2ThreadProjection;
let counter = 0;
const turn = (fields: Record<string, unknown>) => item({ id: `i${counter++}`, ...fields });
describe("buildTranscript", () => {
test("folds runs of work between messages into one segment", () => {
const transcript = buildTranscript(
projectionOf([
turn({ type: "user_message", text: "fix it" }),
turn({ type: "command_execution", input: "ls" }),
turn({ type: "reasoning", text: "thinking", streaming: false }),
turn({ type: "file_change", fileName: "a.ts" }),
turn({ type: "assistant_message", text: "done", streaming: false }),
]),
);
expect(transcript.segments.map((segment) => segment.kind)).toEqual(["user", "work", "assistant"]);
const work = transcript.segments[1];
expect(work?.kind === "work" && summarizeWork(work.steps)).toBe("1 command · 1 edit");
});
test("marks trailing work active while the thread runs", () => {
const transcript = buildTranscript(projectionOf([turn({ type: "command_execution", input: "make" })]), { running: true });
expect(transcript.segments[0]).toMatchObject({ kind: "work", active: true });
});
test("errors break out of folded work", () => {
const transcript = buildTranscript(projectionOf([turn({ type: "command_execution", input: "a" }), turn({ type: "error", failure: { message: "boom" } }), turn({ type: "command_execution", input: "b" })]));
expect(transcript.segments.map((segment) => segment.kind)).toEqual(["work", "alert", "work"]);
});
test("reuses unchanged segments so the view can skip them", () => {
const user = turn({ type: "user_message", text: "hi" });
const command = turn({ type: "command_execution", input: "ls" });
const first = buildTranscript(projectionOf([user, command, turn({ type: "assistant_message", text: "He", streaming: true })]));
const second = buildTranscript(projectionOf([user, command, turn({ type: "assistant_message", text: "Hello", streaming: true })]), { previous: first });
expect(second.segments[0]).toBe(first.segments[0]!);
expect(second.segments[1]).toBe(first.segments[1]!);
expect(second.segments[2]).not.toBe(first.segments[2]!);
});
});