Skip to content

feat(chat): draw session_send messages as cards naming the sender - #25470

Merged
KiroCrewCaptain merged 2 commits into
mainfrom
feat/kas-wf-1-session-cards
Nov 5, 2026
Merged

KiroCrewCaptain merged 2 commits into
mainfrom
feat/kas-wf-1-session-cards

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Every message one Crew session sends another (session_send / session_broadcast) names its real sender, taken from gateway-set meta.relay, not from the message text; and the sender's own session_send call reads as a sent message, not a raw tool line.

Why it matters

The receiver's bubble already drops the [sent by session …] line and says "From conductor / From a crew member / From another chat" (lib/crewSeed.ts, UserMessage.tsx), but it does not say which session, gives no way to open it, and reads the sender key out of text a peer controls. The sender's own transcript shows the call as a generic tool line.

Not a goal

  • Any change to who may send, the delivery path, or the [sent by session …] envelope the model reads. It is kept intact.
  • Kiro Workflows. This PR stands alone and is not behind any opt-in.

What changed (motivation → approach → change)

Receiver: the existing user bubble and its "From …" label stay the one renderer and the one sender label. On a row carrying meta.relay, the label adds the sender's initials and title, the title an underlined accent link that opens that session, with the tooltip "Open Slack Code" ("FROM ANOTHER CHAT · SC Slack Code"). The sender is meta.relay.senderKey, never the key the line spells. The [sent by session …] line is dropped from the body by position, never by matching text: the gateway records where it wrote each one as meta.relay.envelope, [start, end) spans in UTF-16 code units (dashboard/relay_spans.py), and withoutRelayEnvelope in pages/chat/sessionRelay.ts cuts exactly those. A merged drain of one sender's queued sends gets one span per send, rebuilt by the drain for the row it writes (and for the queue_pop frame); a row with no spans, written before this field, shows as it always did, through main's parseSessionSeed, and a person's own row is never cut. A host with no session roster or opener (a peer's Crew window, the SDK registry) shows the label alone. The avatar (pages/chat/SenderAvatar.tsx) wears the colour the person gave the sender session in the sidebar (its color_hex, else its color_index in the current palette from utils/sessionColors), and is neutral for a session with no colour; there is no second per-session colour.

Sender: its own session_send tool row draws as the outgoing card, which says its direction in words: "This session · Sent to @Planner", the @Planner tag opening the recipient (tooltip "Open Planner"). Both facts the card states, that the call delivered and which slot it reached, come from the gateway as typed fields, never from the tool's result text. The session_send tool asks for a receipt (receipt: true on POST /api/session-control/send); the route parks {outcome, target} for the calling session under call_input_digest of the target and message it was sent (dashboard/session_send_receipts.py, a directive_queue.Store of its own: the directives' out-of-band mechanism, kept apart from their records because directive_queue.discard retires a whole session bucket and a directive claim reports every record it passes over as a miss). The caller's turn digests the same two arguments of the session_send call it saw (the _meta identity, the permission request or the backend's wire title names the call; Codex and Tool Search argument wrappers are unwrapped; a send naming a crew is left out, since another gateway delivers it), and on that call's completed result claims the receipt and stamps it on the call's own rows as meta.sessionSend (chat_turn/tool_results.py); open tabs get it as a chat_message_update patch. A failed call retires its receipt, so a refused retry cannot wear it. The card appears as soon as that patch lands. While the host withholds its session roster (the gateway is disconnected) the tag is plain text, the same gate the body's session chips use. It appears only for the gateway's own session_send (served by kirocrew-dashboard) once it delivered. A call still running, refused, rejected or denied, or a same-named tool from another MCP server, stays the ordinary tool line, and the @tag opens the slot the gateway resolved (meta.sessionSend.target), not the name the call typed. A row from before the receipt existed stays the tool line.

Where meta.relay comes from: only the gateway's delivery path stamps meta.relay = {senderKey, via, envelope} (session_control_parts/session_messaging.py, session_deliver.py, state_parts/chat_slot.py, chat_delivery.py, with chat_turn/queue_drain.py dropping it when a merged row mixes senders, compared by sender alone so one session's session_send and session_broadcast still merge under its name). POST /api/chat drops a caller-supplied relay with the other gateway-minted keys (RESERVED_ROW_META_KEYS in chat_handlers.py), so no caller can show its text as another session's. Live rows carry it too: a peer's steer on the steer_push frame (read in hooks/websocket/chatStream.ts) and onto its requeued queue entry, and a drained queued peer send on its queue_pop frame (queue_drain.py, rebuilt in store/chat/queue.ts through queueEntryRelay in store/chat/wire.ts, from the frame only). Editing a queued peer send drops its relay (slot_queue_repository.py), since the new words are the editor's. A message the person typed, and older history, has no meta.relay and draws as before.

Frontend: pages/chat/UserMessage.tsx (the label, plus sessions / onSessionOpen props wired from pages/chat/page/transcriptRendering.tsx and pages/chat/transcriptRenderers.tsx), lib/crewSeed.ts, pages/chat/SessionMessageCard.tsx (outgoing only), pages/chat/sessionRelay.ts, one entry in pages/chat/transcriptRenderers.tsx, strings in every locale catalog (i18n/locales/en.manual.json and its translations). A peer's Crew window draws the outgoing row through the store-free default (pinned in test/CrewChatWindow.test.tsx and test/chatRolesParity.contract.test.ts). The feature map gains a row.

Stack

Split out of #25395, which was over the 1 MB review cap. Merge bottom-up. Only a PR based on main gets CI (ci.yml and fast-gate.yml run on pull_request: branches: [main]), so each stacked PR is rebased onto main once the one below it merges. A and the B1a protocol PR do not depend on each other. C2's UI uses A's card, so C2 carries A's commits until A merges.

# PR Branch Base
1 #25470 (this PR) feat/kas-wf-1-session-cards main
2 #25447 feat/kas-wf-2-backend main
3 #25449 feat/kas-wf-2b-engine feat/kas-wf-2-backend
4 #25450 feat/kas-wf-2c-dashboard feat/kas-wf-2b-engine
5 #25459 feat/kas-wf-3-person-holds feat/kas-wf-2c-dashboard
6 #25466 feat/kas-wf-4-frontend feat/kas-wf-3-person-holds
7 #25471 feat/kas-wf-4b-frontend-ui feat/kas-wf-4-frontend

Backwards compatibility

Compatible: the [sent by session …] prefix is still written and still what the receiving model reads; only rows carrying the new meta.relay change how they draw, and the "From …" label reads as before. Rows written before meta.relay.envelope or meta.sessionSend existed draw exactly as on main. POST /api/session-control/send gains an optional receipt field; a caller that omits it is unchanged.

Removes nothing: no key, route, setting or public function is removed or renamed.

Tests

  • test/test_session_send_receipts.py: the route parks a receipt only when the tool asks for one, and the tool asks; the real _run_chat stamps meta.sessionSend on a delivered session_send row and patches open tabs, and stamps nothing for other arguments, a failed call, another server's tool or a refused retry of a failed call; a KAS call named only by its wire title with Tool Search-wrapped arguments still gets its card, and a server-qualified tool name is stamped canonical so the card draws; a crew-qualified send (delivered by another gateway) never registers or takes a local receipt; a permission request that names the call registers it; receipts share the directive mechanism but survive a directive discard; relay_spans counts UTF-16 units and rebuilds spans rather than trusting stored ones.
  • test/test_session_control_send.py: meta.relay (with its envelope span) on the idle-run row, the queued entry, the consumed-steer row, the live steer_push frame, a requeued steer's queue entry and a drained entry's queue_pop frame (only a well-formed record rides it, with spans rebuilt for the popped text); an edited queued peer send loses it; a merged drain keeps one sender across session_send and session_broadcast, with one span per send covering exactly its line, and drops it for two senders.
  • test/test_chat_send_client_meta_survival.py: a caller-supplied meta.relay is dropped at ingress (echo, live row, disk, fetch).
  • test/test_mcp_dashboard_session_send.py: the tool's request carries receipt: true.
  • test/test_state_parts_facade.py: the pinned _ChatSlot.enqueue_or_run_prompt signature gains the relay_meta keyword.
  • test/UserMessage.sessionSeed.test.tsx: the label names the sender title (an underlined accent link with an "Open …" tooltip, bubble-coloured on the accent bubble, and initials by code point, so an emoji title stays whole) from meta.relay, not the key the line spells; a merged drain loses each send line at its recorded span; a body line that only looks like an envelope stays; a row with no spans shows as before; a person's own row is never cut; no roster or opener, or no meta.relay, leaves the label alone; senderInitials.
  • test/SenderAvatar.test.tsx: the avatar wears the sender session's custom colour or palette colour, and is neutral for a session with no colour or a host with no store.
  • test/chatSlice.sessionSendReceipt.test.ts: the receipt patch makes the row the outgoing card linking the resolved key; the live tool result's success text does not.
  • test/chatSlice.queuePopRelay.test.ts: the queue_pop rebuild keeps a valid relay, drops a malformed one, and copies only the sender fields.
  • SessionMessageCard.test.tsx (the visible "This session · Sent to @…" line, the tag's "Open …" tooltip, the tag bounded to the card for a long title, no avatar, clamp, link vs plain), sessionRelay.test.tsx (helpers, including the envelope spans and the receipt read by exact key; the success prose alone, a running or refused send, and another server's session_send stay the tool line; Codex and Tool Search wrappers are unwrapped only for the gateway's tool; a relay row uses the ordinary user entry; an alias-addressed send links to the resolved key; with no roster the tag is plain text), UseWebSocketCoverage.activity.test.tsx (the live steer row keeps a valid relay).
  • Local gates on this head: tsc (tsconfig.app.json), eslint over the changed files, i18n:check, black, mypy over src/kiro_crew; vitest over src/pages/chat and the user-message, queue, receipt, Crew window and roles-parity suites; pytest over the session-control, session-send, queue-drain, directive, steer and chat-runner suites (about 2,900 pass). Each new test was run against the previous code and fails there.

Proof: not provable -- other: feature PR, not a fix; each behaviour has its own test named above.

Manual verification

Rendered the receiver's row through the real UserMessage with the props ChatPage passes (session roster and opener) and the sender's row through the real session_send_tool transcript entry, in a capture page, dark and light, with a long message clamped on the outgoing card. The outgoing meta line is the row time the renderer passes.

Screenshots / video

Received (another session's message, top) and sent (this session's own session_send, bottom), light:

Received and sent session messages, light

The same pair, dark:

Received and sent session messages, dark

Two long messages: the received bubble in full, and a different sent message clamped to two lines with Show more:

Long messages, light

The same sent card after Show more, expanded with Show less:

Long sent card expanded, light

While the gateway is disconnected (the host withholds its session roster): the received bubble keeps the label alone, and the sent card's @Planner is plain text, not a link:

Disconnected, light

A 320px column with 200-character unbroken titles (the rename cap) on both sides: the sender link and the @tag wrap inside the bubble and the card (the capture script also checks each box in the browser):

Narrow column with long titles, light

Related Issues

N/A — no tracking issue, by the owner's choice.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 72b4d421255761edb2e688a6e91d39aec9f97a73 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 72b4d42

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 72b4d421255761edb2e688a6e91d39aec9f97a73 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 72b4d421255761edb2e688a6e91d39aec9f97a73 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The sender comes from fields the gateway sets, and the receipt mechanism reuses directive_queue as a separate store. Rows written before this change keep drawing as they do on main.

Notes

  • The receipt is matched only by a digest of target and message. As the author says, two identical sends in flight at once can swap outcome words. If this card later starts showing things that matter, key the receipt on the tool-call id where a backend provides one.

[DESIGN-REVIEWED] 72b4d42

Description read

[DESCRIPTION-READ] e1b15423bb72bfc30f998ce68d13dd30e315197af9c5305b68a5d2877ba49599

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 72b4d421255761edb2e688a6e91d39aec9f97a73 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The sender now comes from a meta.relay stamp set only by the gateway, which fixes the cause (a sender read from text a peer controls). The directive_queue.Store refactor has two real consumers.

Notes

  • Item 8 — duplicate of website/src/api/sharedCrewUi.ts:165 (principalInitials): senderInitials in lib/crewSeed.ts is the 4th initials helper (pattern function \w*[Ii]nitials: principalInitials, emailInitials, CommentsSidebar.initials, plus this one), and each spells the same first-letter-of-two-words rule differently. Subtraction: pull out the string core of principalInitials (split, first code point of two parts) and call it, then delete senderInitials.

What this change ships

Inventory (10 items) — 9 justified

Intent: a person reading a session's transcript sees which session really sent each peer message and can open it, and sees their own delivered session_send as a sent message. This is an ADDITION.

  1. The receiver's "From …" label adds the sender session's title as a link that opens it — justified
  2. The sender comes from the gateway-set meta.relay, never from the message text — justified
  3. POST /api/chat drops a caller-supplied relay — justified
  4. The [sent by session …] line is cut by spans the gateway records, not by matching text — justified
  5. Live steer, queue-pop, requeued and merged-drain rows carry the sender; an edited queued entry drops it — justified
  6. A delivered session_send draws as "This session · Sent to @x" — justified
  7. A new receipt flag on the send route parks {outcome, target}, claimed by the call's argument digest — justified
  8. A sender avatar with initials in the session's sidebar colour — duplicate of api/sharedCrewUi.ts principalInitials
  9. directive_queue becomes a Store class with a second instance for receipts — justified
  10. New strings in every locale, a feature-map row and a history spec line — justified

[FIRST-PRINCIPLES-REVIEWED] 72b4d42

Description read

[DESCRIPTION-READ] 257805bb74482572b925dc578048ab712354bad43d758f1b0f451be7d6b05689

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 72b4d421255761edb2e688a6e91d39aec9f97a73 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

No blocker. The reader identified both primary controls correctly. The doubts were about the sample names, the side of the screen each message sits on, and wrapping of extreme-length names.

Notes

  • "This session" vs "From another chat": the new sessionMessageCard.this_session string calls the same thing a "session" that the bubble beside it calls a "chat". The blind reader said "Chat and session seem to mean the same thing". Rename it to "This chat" so the card matches the existing "From another chat" label.
  • Long names (shot-06): the reader said "it looks broken" and asked why the "·" after "This session" was "left on its own". The cause is break-all on the sender link and the @tag: an unbroken title wraps to six lines, and the flex-wrap row strands the dot. Truncate both to one line with an ellipsis (the full title already shows in the tooltip), and keep "·" and "Sent to" together so they wrap as one unit.
  • Which side means "sent": the "Sent to" card sits on the left, where incoming messages usually go, and the "From another chat" bubble sits on the right, where your own messages usually go. The reader: "I can't tell which messages are mine and which are someone else's." Add a direction cue to the card, such as an outgoing-arrow icon before "Sent to", so the words aren't the only signal.

[UX-REVIEWED] 72b4d42

Description read

[DESCRIPTION-READ] 833dc07cbbe25fa46650ee7322ca822c90fba64e0b4574468223e10b15eca044

That sha256 names everything this verdict read: the PR description, plus the 9 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 72b4d421255761edb2e688a6e91d39aec9f97a73 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 72b4d42

Verdict parsed from the review's SHA-scoped output markers for commit 72b4d421255761edb2e688a6e91d39aec9f97a73.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 72b4d421255761edb2e688a6e91d39aec9f97a73 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 28, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-1-session-cards branch from c1db9d2 to 22b0eb5 Compare October 28, 2026 23:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 28, 2026
@kyleseaman

kyleseaman commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no

  • The outgoing card reads as a message from someone else span=10768d258b93

fixed in 22b0eb5: the outgoing card now says its direction in visible text, "This session · Sent to @Planner", with the @tag opening the recipient.
The sender is named "This session" instead of its own title (title kept on hover), so it no longer reads as another sender.
The up-left arrow badge is removed; the avatar holds only initials. The former sr-only "Sent to" span is gone because the text is visible.
Evidence gaps and notes: the renderer now passes the row time to the meta line; the description has light and dark pairs plus a long message clamped and expanded, shot from the real renderer entries.
Tests: SessionMessageCard.test.tsx and sessionRelay.test.tsx gain 6 assertions that fail with the fix reverted.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 28, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-1-session-cards branch from 22b0eb5 to 5bf42db Compare October 29, 2026 00:25
@kyleseaman

kyleseaman commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Caller-supplied metadata can impersonate another session span=e704535aaf87

fixed in 5bf42db: relay is now in RESERVED_ROW_META_KEYS (chat_handlers.py), so api_chat drops a caller-supplied meta.relay where request meta enters, before the row, the queue entry and the hold entry.
Only the gateway delivery path (session_messaging -> session_deliver / chat_slot / chat_delivery) mints it.
Test: test_chat_send_client_meta_survival.py sends a forged relay and asserts it is absent on the echo, the live row, the disk row and the fetch; it fails with the key removed from the set.

@kyleseaman

kyleseaman commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Outgoing cards discard the authoritative delivery result span=e704535aaf87

fixed in 5bf42db: the outgoing card now needs the call own success result (meta.output opening with the gateway "Steered / Delivered to / Queued for <key>" line, sessionRelay.readSessionSendResult).
A call still running, refused (Error: ...), rejected or denied has no such result and stays the generic tool line with its status and output disclosure.
The @tag opens the slot key from that result, so an alias- or title-addressed send links to the real slot.
Tests: sessionRelay.test.tsx covers running and refused rows resolving to the tool entry and the alias send linking to the resolved key.

@kyleseaman

kyleseaman commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Steer delivery drops sender metadata on live and requeued paths span=66390df99165

fixed in 5bf42db: steer_push now carries meta.relay for a peer steer, and chatStream.onSteerPush keeps it (validated by readRelay) on the live row.
The relay is also recorded in _steer_attachment_meta, which _requeue_unconsumed_steers already merges into the requeued entry, so the drained row carries it; that map already has every lockstep pop the steer bookkeeping needs.
Tests: test_session_control_send.py (live frame, requeued entry) and UseWebSocketCoverage.test.tsx (live row keeps a valid relay, drops a malformed one).

@kyleseaman

kyleseaman commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no

  • POST /api/chat accepts a caller-supplied meta.relay span=1af914048f4c

fixed in 5bf42db: relay is added to RESERVED_ROW_META_KEYS (chat_handlers.py), so api_chat strips it where client meta enters; the dispatch row, queue entry and drain union only ever see the gateway-minted value.
Test: test_chat_send_client_meta_survival.py posts a forged relay and asserts it is absent on the echo, live row, disk row and fetch.

@kyleseaman

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Outgoing card claims a rejected, denied or running session_send was sent span=f48891814c77

fixed in 5bf42db: the outgoing entry now matches only a call with its own success result (the gateway "Steered / Delivered to / Queued for <key>" line in meta.output).
A rejected or auto-denied call never ran and a running call has no result yet, so each stays the generic tool line, which draws its running, rejected or auto-denied state; a refused send (Error: ...) does too.
Tests: sessionRelay.test.tsx covers a running and a refused row resolving to the tool entry.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 30, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-1-session-cards branch from a3c9347 to b6264ac Compare October 30, 2026 06:33
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Oct 30, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-1-session-cards branch from b6264ac to 787c7c0 Compare November 2, 2026 16:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 2, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-1-session-cards branch from 787c7c0 to f4af7e3 Compare November 2, 2026 17:50
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for human review at f4af7e32384b93f5cdd439c332307adbcc5ad122. I found no defect.

The PR still adds a gateway-trusted sender identity: meta.relay.senderKey is minted on the session_send delivery path (session_messaging.py#L391) and drawn as the message's author, and relay joins RESERVED_ROW_META_KEYS, the ingress strip list (chat_handlers.py#L638-L640). Changes to which identity claim is trusted are reserved for a human reviewer.

What I checked: a forged relay is stripped at POST /api/chat; a merged drain keeps relay only when every entry has the same sender (queue_drain.py#L1043-L1052); an edited queued peer send drops it; the outgoing card needs a delivered session_send from kirocrew-dashboard. Every earlier finding has a matching fix, every lane passes on this head, and checks are green.

AI findings judged non-blocking:

  • Design: per-arm relay stamping instead of one helper. Maintainability only.
  • First Principles items 4, 8, 9: unread sender.key and relay.via, and the avatar's own palette derivation. No behaviour effect.
  • UX: link vs pill styling, "This session" vs "From another chat", the dangling separator at narrow widths. Cosmetic.

To clear: a maintainer confirms the sender-identity and ingress-strip change.

— crew-pr-reviewer (r142)

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Carrying the sender as a gateway-set meta.relay field, reserving relay at POST /api/chat ingress, dropping it on queue edit, and keeping it only when every merged entry shares one sender are all good structural choices. I read every non-locale, non-test hunk at f4af7e3 (backend delivery, steer, queue, drain and ingress paths, plus the frontend relay, card, avatar, store and renderer changes). All 95 checks are green on this head.

Requesting changes for one reason: two parts of the solution still rely on regex over message text, and this repo does not take new regex-based parsing for this kind of decision. Please replace both with structured data.

  1. website/src/pages/chat/sessionRelay.ts, SEND_RESULT_RE. Whether a session_send row draws as the outgoing "Sent to @recipient" card, and which slot key the card links to, is decided by matching the human-readable success line of the tool result (emoji, "Steered" / "Delivered to" / "Queued for", backticked key). That couples the UI to prose wording: any rewording or translation of that line silently turns the card back into a tool line, and the delivered key is scraped rather than read. store/chat/activity.ts uses the same match to decide which live tool output to copy. Suggested approach: have the gateway return the outcome and the resolved slot key as typed fields (for example structured content on the tool result, or meta the gateway stamps on the tool row), and read those fields with an exact key lookup.

  2. website/src/lib/crewSeed.ts, SEED_LINES_RE. This widens the existing SEED_RE to a global multiline pattern and strips every line-start [sent by session ...] line from a relayed row's body. That is marker detection by regex over free text. Since the gateway now proves the delivery through meta.relay, it also knows exactly which envelope lines it prepended. Suggested approach: keep the display body separate from the model-input envelope on the row (for example store the body, or each merged send's body, in meta when the row is written), so the bubble renders that body directly and nothing needs to be stripped from text.

Smaller, non-blocking: SenderAvatar.tsx checks color_hex with a hex regex; if the slot row already carries a validated color, reading it as is would be enough.

Regex this PR does not touch is out of scope for this request. Happy to re-review once the two spots above read structured fields.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The point from my last review is still open on d85e348: both regexes that parse message text are still in the diff.

  • website/src/pages/chat/sessionRelay.ts: SEND_RESULT_RE = /^\s*\u{1F4E8}\s*(?:Steered|Delivered to|Queued for)\s+([^\n]+)/u`, run on the tool's result text to pick the card and its slot key.
  • website/src/lib/crewSeed.ts: SEED_LINES_RE = new RegExp(SEED_RE.source, 'gm'), which widens the seed regex to strip envelope lines on every line of a relayed row.

This repository asks for structured data instead of regex over text. The receiver side already reads the gateway-set meta.relay in readRelay, which is the right shape. Please do the same for the other two:

  1. The sender's card: read the delivered target slot from a structured field of the session_send tool result, such as a typed result field or the call's meta, not from the success prose.
  2. Stripping seed lines: have the gateway record which leading lines of the delivered text are envelope lines, or store the payload apart from the envelope, so the dashboard removes them by position, not by pattern.

Frontend Tests (1) and (4) are red on this head, along with Frontend Coverage Merge and Coverage Gate. The failing tests are ChatPage.dirStaging, ChatSidebar.selectorScope and ArtifactsPageCoverage. I have not judged whether these come from this change; I will look again on the next head. All five AI review lanes pass, and KiroCrewCaptain's auto-merge is left as it is.

@kyleseaman

kyleseaman commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author
  • KAS sends never register a receipt selector span=62ad1c4ffd65

fixed in 0f6714a: a session_send call is identified by its _meta pair, its permission request (note_call in tool_approval._on_permission_request), or the backend's own wire title (@kirocrew-dashboard/session_send, mcp__kirocrew-dashboard__session_send, kirocrew-dashboard_session_send, optional 'Running: ' prefix; never the display title). stamp_result writes the canonical tool_name/mcp_server onto the call's rows and into the live patch, so the card draws. Tests: test_a_kas_send_named_only_by_its_wire_title_gets_its_card, test_a_permission_request_naming_the_tool_registers_the_call, test_a_row_named_by_a_qualified_tool_name_gets_the_canonical_identity (each fails on the previous code).

@kyleseaman

kyleseaman commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Wrapped MCP arguments prevent delivered sends from rendering span=bf1cf45096da

fixed in 0f6714a: parseSessionSend reads the arguments through sessionSendArguments, which unwraps Codex {server, tool, arguments} and Tool Search {tool_id, arguments} only when the wrapper names kirocrew-dashboard / session_send, the same rule as the gateway's session_send_receipts.call_arguments; the serving-server check is unchanged. Test: sessionRelay.test.tsx 'reads the arguments out of a wrapper only when it names the gateway session_send' (fails on the previous code).

@kyleseaman

kyleseaman commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Second park/claim registry span=6c7fa07189fd

fixed in 0f6714a: one mechanism serves both. directive_queue now holds a Store class (records, lock, caps, accepted kinds) and its publish/claim take store=, defaulting to DIRECTIVES, whose behaviour and log text are unchanged; session_send_receipts parks and claims through directive_queue.publish/claim(store=RECEIPTS) with session_directive.call_input_digest, and its own registry and selector digest are gone. The receipts get their own Store instance, not the directives' bucket, because directive_queue.discard retires a whole session bucket when the marker applies a directive and a directive claim reports every record it passes over as a lost directive; test_receipts_share_the_directive_mechanism_but_not_its_records pins that.

@kyleseaman

kyleseaman commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Description contradicts the diff span=1a4557c655a8

fixed in 0f6714a: the What changed section now describes what ships: the receipt (receipt: true on POST /api/session-control/send, meta.sessionSend {outcome, target}, session_send_receipts on directive_queue's Store and call_input_digest), the envelope spans (meta.relay.envelope, relay_spans.py, withoutRelayEnvelope), the fallbacks for older rows, and the tests; sseToolResult and withoutSessionSeeds are no longer mentioned because they no longer carry this feature.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rework. Re-checked at 0f6714a.

Fixed:

  • SEND_RESULT_RE and SEED_LINES_RE are gone.
  • The sender now comes from the gateway-set meta.relay field, not from the message text.
  • relay_spans.py records the envelope positions as [start, end) spans in meta.relay.envelope, and the dashboard drops exactly those spans. The spans are found with an exact str.find of the rebuilt envelope, with no pattern matching. That is the shape we asked for.

One small thing left (same rule): the new senderInitials in website/src/lib/crewSeed.ts parses the title with two new regexes, split(/\s+/) and replace(/^[@#]+/, ''). Our rule is no new regex for parsing text, even small ones. A short loop over code points would do the same job: split on whitespace with Array.from(title) plus a whitespace check, then skip leading @ and # characters by comparing exact characters.

CI is still running on this head (25 checks pending). I'll re-check once that change is in and CI is green.

@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • Remote sends consume matching local delivery receipts span=20c71ac37d5c

fixed in a40f207: a session_send whose unwrapped arguments name a crew is a remote send (mcp_session_crew.run_crew_send delivers it and the local route parks nothing for it). session_send_receipts.call_selector returns None for it and note_call forgets any selector an earlier frame recorded for that id, so it neither registers nor claims a local receipt; with no receipt its row stays the tool line. Test: test_a_send_to_another_crew_never_takes_a_local_receipt (fails on the previous code).

Kyle Seaman added 2 commits November 4, 2026 23:41
A message one session sends another (session_send / session_broadcast)
draws as a card naming its sender instead of a raw "[sent by session ...]"
user bubble, and the sender's own session_send call draws as the outgoing
card with the recipient as an @tag.

The sender comes from meta.relay, which only the gateway's delivery path
stamps (session_messaging, session_deliver, chat_slot, chat_delivery,
queue_drain), never from the message text, so a peer cannot forge it by
typing the envelope. Rows without meta.relay draw as before.
… sender

The outgoing card says its direction in text ("This session · Sent to
@Planner") instead of an outlined avatar and an arrow badge, and both
cards show the row time.

The outgoing card is drawn only for a session_send that delivered, and
both facts come from the gateway as data, never from the tool's result
text. When the session_send tool asks for one (receipt: true),
POST /api/session-control/send parks a receipt ({outcome, target}) for
the calling session under a digest of the target and message it was
sent (session_send_receipts, a directive_queue.Store of its own, keyed
by call_input_digest); the caller's turn claims it by the same arguments
of the session_send call it saw (named by its _meta identity, its
permission request or the backend's wire title; Codex and Tool Search
argument wrappers unwrapped), on that call's completed result, and
stamps it
on the call's own rows as meta.sessionSend (live tabs get it as a
chat_message_update patch). A failed call retires any receipt its
request parked. A call still running, refused, rejected or denied, or a
row from before the receipt, stays the tool line, and the
@tag opens the slot the gateway resolved, not the alias typed.

meta.relay is now gateway-only: api_chat drops it from request meta
(RESERVED_ROW_META_KEYS), so a caller cannot show its text as another
session's. It records where the provenance line sits in the delivered
text (meta.relay.envelope, UTF-16 spans), so the bubble drops it by
position. A drain merging one sender's queued sends rebuilds one span
per send, and the queue_pop frame rebuilds its own; a row without spans
shows as before. A peer's steer carries relay on the live steer_push
frame and onto its requeued queue entry, and a steer still waiting,
requeued or taken back keeps the ordinary bubble that shows that state.
Editing a queued peer send drops its relay, since the new words are the
editor's.

The card drops surface nothing here uses: the needsYou pill and its
string in every catalog, the agent and runName meta, and the
isAnySessionSendTool export.
@kyleseaman

Copy link
Copy Markdown
Contributor Author

@bolichen97 re your review on f4af7e3, both points addressed at 72b4d421255761edb2e688a6e91d39aec9f97a73:

  1. SEND_RESULT_RE is deleted. The gateway now records what a send delivered as typed fields: when the session_send tool asks (receipt: true), POST /api/session-control/send parks {outcome, target} for the calling session, keyed by session_directive.call_input_digest of the target and message it was sent (dashboard/session_send_receipts.py, on directive_queue's Store). The caller's turn claims it by the same arguments of the call it saw, on that call's completed result, and stamps it on the call's own rows as meta.sessionSend; open tabs get it as a chat_message_update patch. sessionRelay.ts reads meta.sessionSend by exact key, and store/chat/activity.ts is back to main's version (it no longer copies tool output for this). A row with no receipt stays the tool line.
    Tests that fail without it: test/test_session_send_receipts.py (test_the_send_route_parks_what_it_delivered, test_the_session_send_tool_asks_for_a_receipt, test_a_delivered_session_send_row_carries_the_receipt, test_a_failed_call_retires_its_receipt_so_a_refused_retry_cannot_wear_it), website/src/test/chatSlice.sessionSendReceipt.test.ts, and sessionRelay.test.tsx (readSessionSendResult: reads nothing from the result text, however it is worded).
  2. SEED_LINES_RE is reverted; main's SEED_RE is untouched. The delivery path records where it wrote each [sent by session …] line as meta.relay.envelope, [start, end) UTF-16 spans (dashboard/relay_spans.py); a drain merging one sender's queued sends rebuilds one span per send, and the queue_pop frame rebuilds its own. withoutRelayEnvelope drops exactly those spans. A row with no spans shows as on main.
    Tests that fail without it: test/test_session_control_send.py (test_idle_delivery_stamps_meta_relay_on_the_user_row, test_a_drained_peer_send_carries_meta_relay_on_its_queue_pop, test_a_merged_drain_of_one_sender_keeps_its_sender_across_delivery_verbs), UserMessage.sessionSeed.test.tsx (span cut, body lookalike kept, no-span fallback), sessionRelay.test.tsx (envelope span validation and withoutRelayEnvelope), test_session_send_receipts.py::test_envelope_spans_count_utf16_units.

The SenderAvatar hex check is gone too: it reads color_hex as the sidebar does (the gateway accepts and restores only #rrggbb).

@kyleseaman

Copy link
Copy Markdown
Contributor Author

@bolichen97 re your review on d85e348, at 72b4d421255761edb2e688a6e91d39aec9f97a73:

  1. Sender's card: the delivered target comes from meta.sessionSend.target, a field the gateway stamps on the session_send row (session_send_receipts.stamp_result), not from the success prose. SEND_RESULT_RE and its result-text unwrapping are deleted.
  2. Seed lines: removed by position. meta.relay.envelope holds the spans the gateway wrote; SEED_LINES_RE is reverted.

The tests that fail without each change are listed in my reply to your first review above. The three frontend failures you saw on d85e348 (ChatPage.dirStaging, ChatSidebar.selectorScope, ArtifactsPageCoverage) were outside this diff. ChatPage.dirStaging failed the same way on 16 other PRs that day; it passed on re-run here, and the race behind it is what #20931 targets.

@kyleseaman

Copy link
Copy Markdown
Contributor Author

@bolichen97 re your review on 0f6714a: senderInitials in website/src/lib/crewSeed.ts no longer uses a regex, at 72b4d421255761edb2e688a6e91d39aec9f97a73. It walks Array.from(title), splits on whitespace (ch.trim() === '') and skips leading @ / # by comparing characters. UserMessage.sessionSeed.test.tsx (senderInitials) now also covers tab, no-break-space and newline separators, a mark after the first character being kept, and a title of marks only. The behaviour matches the old version, so these cases pass on both. I also scanned the PR's added lines: no other regex was added.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving head 72b4d42. This head fixes the one point left open in my last review.

  • The gate shows 97 checks passed, none red, none pending, and no change requests from other reviewers.
  • My last review asked to replace the two senderInitials regexes with a loop over code points. The new senderInitials in crewSeed.ts does that: it walks Array.from(title), splits on ch.trim() === '', and skips leading @ and # by exact character comparison. I searched the saved diff for the earlier names SEND_RESULT_RE and SEED_LINES_RE and for re.compile, new RegExp, split(/ and replace(/, and found no hits in product code. The earlier fixes (sender from meta.relay, envelope removed by recorded spans) were already confirmed at the previous head.
  • The new tests for senderInitials cover two words, one word, a handle, whitespace only, an emoji-first title, tabs and non-breaking spaces.

The existing auto-merge on this PR was set by someone else, and I have left it as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants