Repository navigation
feat(chat): open crew sessions as a window onto the peer's own slot - #16757
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check: the only callers of What this change shipsInventory (10 items) — 10 justifiedIntent: let someone driving a remote crew see and act on the crew's real session (approvals, running state, continue/regenerate/rewind) instead of a stale local copy. ADDITION (RFC wave 3,
[FIRST-PRINCIPLES-REVIEWED] d20a0d6 Description read[DESCRIPTION-READ] 65b437e5e7ac52a098f561577da6a108bb06166853d79c5a9cfeac5b0b3c8466 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Crew rows now open a second, cut-down chat surface, so crew sessions lose attachments, voice, split view and pickers until #16774 lands. Watch
[DESIGN-REVIEWED] d20a0d6 Description read[DESCRIPTION-READ] 4eb3c8576745865cb133f4e7dc49c35bab89c9aa7bab7d4dd2c65ee6d5423ab8 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ human override accepted@iamwhatever overrode this lane for |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsBlocks nothing; one advisory finding: a failed rewind can lose the user's edited text. FINDING — website/src/pages/chat/crew-window/CrewChatWindow.tsx:448 — Suppose a rewind fails after its window has closed or switched to another session. The mutation-level [OPUS-REVIEWED] d20a0d6 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
b1d9f1a to
0c59c00
Compare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
0c59c00 to
21c0922
Compare
buluoray
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Reviewed at d20a0d6.
Nothing blocking survived verification. I read the decisive lines at head and mutated each new guard against its directly related test file. I did not run the full suite. CI at this head: 90 pass, 8 skipped, 0 failing. All six AI review lanes are green; UX passes on the author's recorded override. Auto-merge is off, and no human review has been posted yet.
What I verified
Isolation: a window reaches nothing the owner could not already reach.
- This PR adds no backend route. Every call the window makes goes through the existing
ANY /api/instances/{id}/proxy/{path}. That route still requires a positively identified owner (src/kiro_crew/dashboard/handlers_instances.py:2512,is_owner_dashboard_requestafter_guard). The path is still rebuilt from vetted segments and checked against_PROXY_ALLOWED_PREFIXES(api/chat,api/stream), and the PR does not touch either. Result: a crew window cannot read or write any peer slot or memory store beyond what the hub owner's manager-held credential already grants. The new embedded/embed/chat?crew=&key=entry is a non-owner surface, but it still hits the same server gate, so an app or Slack-invited embed gets a 403. This is fail-closed. - No local slot or memory store is created.
createRemoteChatMutation(website/src/pages/chat-sidebar/create.ts:254) POSTsapi/chat/slotson the peer with onlymemory_mode. It sends noagent, so this hub's roster name (possibly a private crewmate) is never bound on the peer. The send body is{message, slot}(CrewChatWindow.tsx:166) and carries no agent or member either.memory_modecomes fromresolveDefaultMemoryMode, which falls back totemporarywhen the config read fails (website/src/api/queryClient.ts:202-209). That is fail-closed on the privacy boundary. - Every peer reply is redacted before it reaches the browser (the new behaviour):
- JSON is buffered and decoded, then every string, keys included, goes through
redact_peer_text(handlers_instances.py:2424-2449,2594-2625). - SSE events are framed with CR/CRLF normalised, a held CR at a chunk edge, and a split BOM.
data:lines are joined before redaction, the way the browser joins them (2468,2647-2681). - Anything the redactor cannot walk is refused, never forwarded raw:
RecursionErrorandValueError(2437,2449), a JSON reply over the cap (2600), and an SSE event over the cap (2655,2669). All of these are fail-closed. - I also checked the SSE field reordering. Non-data lines are emitted before the joined data line. A bare
dataline (no colon) can change only where whitespace newlines fall. A JSON string cannot span a raw newline, so the reorder cannot hide a secret from the redactor.
- JSON is buffered and decoded, then every string, keys included, goes through
No double dispatch of a turn.
- The window sends exactly one
POST api/chat?ws=1per send. On the peer,ws=1returns JSON at once (chat_handlers.py:1406,1735), and a busy slot takes the existing queue branch. Nothing here calls a local/api/chat, and the relay path is untouched. send()returns early onaction.isPending, the draft is cleared at dispatch, and the Send button is disabled while pending (CrewChatWindow.tsx:161-173,301).- A failed send merges back into the draft through
mergeRecoveredDraftand is not re-sent automatically. - Approvals carry
request_id,request_midandorigin: native(:180-186), so the peer's strict check rejects a stale card. - Session shortcuts act on the shown window only (
website/src/hooks/useKeyboardShortcuts.ts:1058), and Cmd+D split is refused while a window is shown (ChatPage.tsxsplit handler). The local pane under the window is madeinert(crewWindowStore.ts:126-144), so a hidden local approval cannot be reached.
Removed code has no remaining callers. I grepped website/src, website/scripts and docs for adoptFailureText, adoptPeerSession, onAdoptPeerSession, capture-adopt-error-reason, and the removed i18n keys adopt_failed, adopt_target_unknown and opening_session_locally. None is referenced outside the locale catalogs, which drop them too. The only hit is a stale comment (see follow-ups). The backend adopt route is intentionally kept for wave 4.
Mutation results. Each mutation was restored afterwards, and the tree was confirmed clean.
| Guard | Named test that went red |
|---|---|
RecursionError changed to pass the reply through |
1 test in TestProxyRedactsPeerReplies (test_too_deeply_nested_json_is_refused_not_forwarded) |
ValueError changed to pass the reply through |
test_json_python_cannot_decode_is_refused_not_forwarded |
| JSON BOM strip removed | test_a_leading_bom_cannot_hide_an_escaped_secret |
| JSON size cap disabled | test_oversized_json_is_refused_not_forwarded |
| SSE event cap disabled | test_a_completed_event_over_the_cap_is_dropped |
| SSE BOM strip removed | 1 test in TestRedactSseEvent |
SSE data: join changed to per-line redaction |
2 tests, including test_secret_split_over_data_lines_behind_an_escape_is_redacted |
| SSE CR/CRLF normalisation in the chunk loop removed | none (the EOF tail normalisation masks it) |
| Keyboard crew-window guard | Alt+Shift+W closes an open crew window, never the local session under it (+1) |
coverSiblings |
makes the covered local pane inert, so an unseen local approval is unreachable |
versionOk read gate |
reads and drives nothing on a peer a release apart (+1) |
| Failed-send recovery | restores a failed send into an empty composer (+3) |
| Rewind withheld on redacted text | offers no rewind on a message the hub redacted |
Create: moved check |
does not yank the view onto the new crew session when the user moved meanwhile |
| Create: version check | refuses a crew create across a version mismatch before minting anything |
Approval requires request_mid |
none |
send() isPending early return |
none (the disabled button and the cleared draft also cover it) |
| Embedded frame reads its own URL, not the tab's store | none |
Non-blocking follow-ups
-
Test gaps on four guards. Each of these survived its mutation:
- The in-loop CR normalisation: add a test where CR-framed events must be emitted before EOF.
- The
request_midrequirement for showing approval buttons. - The
isPendingearly return on Enter. - The embedded-frame scope in
ChatPage.tsx:771.
The code itself is correct on all four.
-
Stale comment.
website/src/pages/chat-sidebar/sessionSources.ts:161still says live peer rows "adopt (seeadoptPeerSessionin ChatSidebar)". That function is gone; the rows now open a crew window. -
Dead frontend options. The
instanceIdandadoptRemoteSlotoptions oncreateSlot(website/src/store/chat/lifecycle.ts:43,68,76,94), and the matchingcreateChatSlotparams, no longer have a frontend caller. Remove them with wave 4, or note that they are kept on purpose. -
Stale row copy.
pages.chatSidebar.not_open_here_yet("On {{name}} — click to open here") still describes the adopt model. A click now opens a window onto the peer and nothing is opened "here". -
Rewind edit can be lost. If a rewind fails after its window has been unmounted, the user's edit is lost (opus advisory). The peer transcript is unaffected. This is tracked in #16774.
Bot concern dispositions
- Design: CONCERNS (second chat implementation; a stream cut off past the cap with no reason given). I checked both: the duplication is the RFC's accepted interim step and is tracked in #16774, and the cut-off is fail-closed by design (feed-lost notice plus Retry). Neither gates this PR.
- Opus advisory: a failed rewind loses the edit. Confirmed. It only loses the user's unsent edit, never peer state, so it is a follow-up (item 5), not a gate.
- Opus advisory (earlier head): SSE pending buffer rescanned per chunk. Confirmed the cost is bounded by
PROXY_REDACT_BUFFER_MAX_BYTES. Performance only, so not a gate. - GPT (earlier head): drafts not saved to sessionStorage. Confirmed fixed at head:
writeCrewDraftcallsdraftStore.save(crewWindowStore.ts:110). - UX: copy and label nits, human override recorded for this SHA. These are wording only, with no behaviour defect, so they do not gate.
- First Principles, Security Scope, GPT, Opus: PASS. These agree with my own reading of the owner gate and the redaction paths.
Problem / Motivation
Goal: A chat on a connected crew is the crew's own session: opening it shows the crew's live transcript, and every action (send, stop, approve, continue, regenerate, rewind) reaches the crew.
Today a crew chat is a local copy of the crew's session. The two copies disagree:
Why it matters
Anyone running sessions on a remote crew hits all three. An approval that never arrives stalls the turn. A false "Turn interrupted" invites a resend that runs the work twice.
Not a goal
remote_relay.py,remote_bound_refusal, adopt backfill). That is wave 4 of the RFC; existing relay slots keep working._PROXY_ALLOWED_PREFIXES(api/chat,api/stream), owner-only.What changed (motivation → approach → change)
Implements wave 3 of the RFC
docs/request-for-change/rfc-remote-crew-sidebar.md("Window view"), accepted in #16699./api/instances/{id}/proxy/api/chat/..., and send, stop, approve, continue, regenerate and rewind call the crew's own routes. Running state is the crew's own flag, so a reload mid-turn shows it running. The crew'sapi/streamis held only while the window is open; finished rows trigger one throttled re-read, and a lost feed shows a notice with Retry. A crew failing theversion_matchcheck gets a notice and no reads or actions. Session shortcuts act on the shown window, never the hidden local session (website/src/hooks/useKeyboardShortcuts.ts). The header reads "On " and says in plain view that closing does not stop the crew. The transcript scrolls under the composer, a<Glass thickness="thin">dock, per the recorded layout and glass decisions.approveroute withorigin: native,request_idand the row'srequest_mid, so a stale or reused id is refused; an approval without a row id gets no buttons and a notice that it is waiting, to be answered on the crew's own dashboard.version_match, then creates the session on the crew through the proxy and opens the window. No local slot is created, and a user who moved during the create is not pulled onto it. The memory-mode default rides the create; no agent is sent.redact_peer_textchain: a JSON body as one decoded document, an SSE event with its line ends normalised and itsdata:lines joined first; a leading BOM is dropped before either is read. A reply or event overPROXY_REDACT_BUFFER_MAX_BYTES, or nested too deep to walk, is refused, never forwarded raw./embed/chat?crew=&key=; an embedded chat frame shows one only when its URL names it.crewPeerGet/crewPeerPostinwebsite/src/api/client/instances.ts; the cap insrc/kiro_crew/instances/constants.py;pages.chat.crewWindow.*keys in every catalog underwebsite/src/i18n/locales/; the feature map rows indocs/feature-map/README.mdand the proxy row indocs/system-specs/modules/instances.md;website/src/store/switchSlotCallsiteClassification.test.tsdrops the adopt call site.adoptFailureText, three i18n keys) andwebsite/scripts/capture-adopt-error-reason.mjs. The backend adopt route stays for wave 4.Backwards compatibility
Compatible: relay slots created before this change still run through the relay. A crew on an older version is refused at create time with a message naming both versions.
Breaking: a crew row and "New chat on crew" now open the crew window, not a relay slot in the full chat page. That window has no attachments, voice, split view, pickers or rich tool rows yet. Remedy: #16774 reuses the main composer and row renderers.
Reader: website/src/pages/ChatSidebar.tsx:SessionRow peer-row click -- chat -- now opens the crew window instead of adopting;
ChatSidebar.instanceSessionsMerge.test.tsx"opens the peer session as a window, creating no local slot"Reader: website/src/pages/chat-sidebar/create.ts:createRemoteChatMutation -- chat -- mints on the crew;
ChatSidebar.createMenu.test.tsx"lists each connected crew and creates the session on the one picked"Reader: website/scripts/capture-adopt-error-reason.mjs -- release (dev capture) -- deleted with the surface it shot
Reader: src/kiro_crew/dashboard/handlers_instances.py:api_instances_proxy -- chat -- JSON and SSE bodies are redacted, shape kept;
TestProxyRedactsPeerRepliesTests
test/test_instances.py::TestRedactSseEvent: a key split across twodata:lines behind a\uescape is redacted, and CR line ends split across chunks are framed before redaction.test/test_instances.py::TestProxyRedactsPeerReplies: a planted AWS key is gone from a JSON body split across chunks, from a key hidden behind a JSON\uescape, and from SSE frames cut mid-secret, with event framing intact; an oversized JSON reply is refused withproxy_reply_too_large.website/src/test/CrewChatWindow.test.tsx: approve sendsrequest_id+request_mid+origin: nativeto the crew route; no card for a coordinator approval with no row id; after a reload the crew's running turn shows "Running on…", not "Turn interrupted"; continue / regenerate / rewind / send / stop call the crew routes and never the local ones, and continue renders the crew's answer; the crew feed is opened only while the window is open; a lost feed is shown with Retry; text typed during an in-flight send survives its success, a failed send merges back beside newer text, a draft survives switching sessions, and a failed rewind retries as a rewind; a version-mismatched crew gets no reads, feed or actions.ChatSidebar.instanceSessionsMerge.test.tsx: a host with no chat pane receives the crew row instead of the store.test/test_instances.py::TestRedactSseEvent: a completed event over the cap is dropped, not forwarded.test/test_instances.py::TestProxyRedactsPeerReplies: the forwarded content types are pinned to exactly the two with a redaction path.ChatSidebar.createMenu.test.tsx: New chat on crew mints on the crew and opens the window; a version mismatch is refused before any create; no agent is sent.ChatSidebar.instanceSessionsMerge.test.tsx: a crew row click opens the window, creates no local slot, and marks that row active.Manual verification
Ran the built SPA against fixtures with
website/scripts/capture-crew-chat-window.mjs. It asserts that opening the crew row creates no local slot, that the window shows the crew's running turn, its pending approval and the redacted text, and that Approve reaches the crew route withrequest_mid. Not run against a live crew over a real tunnel.Screenshots / video
Crew window: the crew's running turn, its pending approval, and a planted key rendered redacted.
Related Issues
Closes #10618
Closes #14585
Part of #6180
Checklist