Skip to content

fix(chat): find a queued card's knowledge envelope by its send mark - #32334

Merged
bolichen97 merged 1 commit into
mainfrom
fix/24011-queue-knowledge-envelope
Nov 8, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/24011-queue-knowledge-envelope

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A message queued with knowledge attached shows exactly what the user typed on its queue card, found by the envelope mark the send recorded rather than guessed from the text.

The queue card hides the [KNOWLEDGE CONTEXT ...] envelope that a knowledge-attached send carries, but a queued entry kept no record of where that envelope ends. The card guessed from the text, so when a knowledge item held the close marker on a line of its own the card showed the whole envelope, and a typed copy of an envelope was hidden as if it were real.

Why it matters

Anyone who sends a message with knowledge attached while the agent is busy sees model-facing document text on the card instead of their own words when the knowledge quotes the close marker, and an edit then opens on that text. The guess also hides text the user typed when it looks like an envelope.

Not a goal

  • The bubble a drained queued send becomes; it renders as it does today.
  • Pruning the mark on queue_edit: the card checks the mark against the entry's text, so a mark that no longer matches hides nothing.
  • Carrying the rest of meta.knowledge (titles, item text) on a queue entry.

What changed (motivation → approach → change)

The composer already records the envelope's length and hash on meta.knowledge.envelope at send time, and sent bubbles use it to hide exactly that envelope. A queued send dropped it: the gateway copies only a fixed set of meta keys onto a queue entry, and the card fell back to parsing the text.

Where What
Gateway (chat_delivery.knowledge_meta) keeps that mark, bounded and nothing else from meta.knowledge, on the queue entry as meta.knowledgeEnvelope, for every queued send: busy slot, sub-agent hold, responsive send, and a steer the turn never took
Frames the mark rides the queue_push frame and each slot-detail queue[] item
Dashboard (store/chat/wire.ts, queue.ts) reads the mark onto the queued row
Queue card (QueueStack.tsx) finds the envelope with knowledgeEnvelopeEnd; the text parser splitKnowledgeEnvelope (pages/chat/useKnowledgeFetch.ts) and its test are deleted

The mark has its own key, not meta.knowledge: the drain copies an entry's meta onto the user row, and a row's meta.knowledge draws the knowledge chip from the full record, which no queue entry keeps. The spec (learn-cron-dashboard.md), the i18n lint comment that named the deleted helper, and the queue-card capture harness (website/scripts/) follow the change.

Backwards compatibility

Compatible: every queue entry and frame keeps its shape; the mark is one optional key that older clients ignore.

Reader: website/src/components/QueueStack.tsx:splitQueuedContent -- chat -- the one caller of the deleted splitKnowledgeEnvelope; it reads the mark instead | website/src/test/QueueStack.test.tsx
Reader: a queue entry restored from disk that was queued before this change -- chat -- it has no mark, so its card shows the whole text until it drains, as any unmarked text does | website/src/test/QueueStack.test.tsx "keeps a typed copy of an envelope whole"

Tests

  • test/test_queue_knowledge_meta.py: knowledge_meta keeps only the bounded mark and refuses malformed ones; a busy-slot send's entry, queue_push frame and queue view carry the mark and no knowledge text; a steer the turn never took requeues with the mark on its entry and frame.
  • website/src/test/QueueStack.test.tsx: rows carry the mark a real send leaves; with the mark, the card hides exactly the envelope even when a knowledge item holds the close marker on its own line, and the edit puts it back; with no mark, a typed envelope copy is shown whole with no chip. Both fail with the fix reverted.
  • website/src/store/chat/queue.knowledgeEnvelope.test.ts: the mark rides the queue_push card and cold hydration; a malformed mark is dropped.
  • website/src/test/SideChat.closedElsewhere.test.tsx: a side-chat card carries no mark (side chat sends no knowledge), so its editor opens on the whole text; the hand-back it pins is unchanged.

Proof: not provable -- frontend test (prove.py runs Python only)

Manual verification

Ran website/scripts/capture-23632-queue-knowledge-envelope.mjs against a production build of the SPA with fixture data: the marked card shows the typed line with the knowledge chip, the close-marker case does too, the editor opens on the typed line, and an unmarked copy shows the whole text. The frames below are from that run.

Screenshots / video

Queued knowledge send, the card shows the typed line and the knowledge chip (light):

queued knowledge card

A knowledge item that holds the close marker on its own line: the mark still names the real end, so the card shows only the typed line (light, then dark). On main this card showed the whole envelope:

close marker inside the knowledge, light

close marker inside the knowledge, dark

Editor and unmarked text

The editor opens on the typed line alone:

editor

The same text with no recorded mark, as a typed copy of an envelope would be, is shown whole with no chip:

unmarked

Related Issues

Closes #24011

Sibling sweep

Swept: git grep -nE "quote=quote_meta|_hold_meta.update(quote_meta|**quote_meta(" -- src/kiro_crew/dashboard
Sibling: src/kiro_crew/dashboard/chat_api/chat_send.py -- changed here
Sibling: src/kiro_crew/dashboard/responsive_chat.py -- changed here
Sibling: src/kiro_crew/dashboard/steer_retract.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/steer_queue.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/queue_drain.py -- not affected -- the queue_pop rebuild and the drained row draw no queue card
Sibling: src/kiro_crew/dashboard/channel_handoff.py -- not affected -- a channel message carries no knowledge envelope

Pattern harvest

Not generalizable: the queue entry copies an allowlist of send meta keys, and this one key was missing from it.

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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 7, 2026 12:58
@bolichen97
bolichen97 enabled auto-merge (squash) November 7, 2026 13:14
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/24011-queue-knowledge-envelope branch from 727248d to 6bd8187 Compare November 7, 2026 16:27
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/learn-cron-dashboard.md, src/kiro_crew/dashboard/chat_handlers.py since this head went green (1ab5673 -> 759bb96); CI re-running.

[operator: bolichen97]

@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 Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f7de20f6d5b5933eb49d7e1f3974510aea90ca45 — 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 fix carries the envelope mark the send already records, reuses the existing knowledgeEnvelopeEnd, and deletes the text parser it replaces.

What this change ships

Inventory (7 items) — 7 justified

Intent: a message queued with knowledge attached shows only what the user typed on its queue card; this is a FIX (#24011).

  1. A queued card hides the knowledge envelope even when a knowledge item quotes the close marker on its own line — justified
  2. Opening the editor on that card shows only the typed words, and the edit sends the envelope back — justified
  3. Envelope-shaped text the user typed, with no mark, is now shown whole, where before it was hidden — justified
  4. An entry restored from disk that was queued before this change shows its whole text until it drains — justified
  5. Queue entries, queue_push frames, slot-detail queue[] items and requeued steers carry a new optional meta.knowledgeEnvelope key — justified
  6. The text guesser splitKnowledgeEnvelope and its test are deleted; the pin "which one ends the envelope cannot be told" no longer applies because the mark now tells — justified
  7. The capture harness and the i18n lint comment are updated to match the change — justified

[FIRST-PRINCIPLES-REVIEWED] f7de20f

Description read

[DESCRIPTION-READ] c6f00713441962cb52ba8261737c5e648f2cc5f7dbf57e5e58366602c0da6206

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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the queue card now uses the envelope mark the send already records, through the same knowledgeEnvelopeEnd helper that sent bubbles use, so it no longer guesses from the text.

Notes

  • Messages queued before this change and restored from disk carry no mark, so until they drain their cards will show the whole envelope where the old text guess usually hid it. The description lists this reader and accepts it, and it clears once those entries drain.

[DESIGN-REVIEWED] f7de20f

Description read

[DESCRIPTION-READ] ba168b69131900c5240e567bb36873652e2cd2e3d3c7dd2f960ebabc1a4da82d

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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

No new control is added. The queue card's text changes, and screenshots show every state: with a mark, with the close marker in the knowledge, the editor, and no mark.

Notes

  • In shot-05 (no mark), the reader called the raw [KNOWLEDGE CONTEXT — injected by user… text "something I was never supposed to see". A card queued before this change still shows that text until it is sent. This is rare and goes away by itself, but it is worth knowing about.
  • The fixtures give one queue slot different text in different shots ("Summarize the rollout runbook…" in shot-01, "Summarize the reference." in shot-02), and the reader "can't tell if it is the same message". Using the same typed line in every capture fixes this.

[UX-REVIEWED] f7de20f

Description read

[DESCRIPTION-READ] e670881ba7c0279be7344f55adf698809377c9a919cd72164a97afc78c1ca958

That sha256 names everything this verdict read: the PR description, plus the 8 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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f7de20f

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

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f7de20f

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

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 7, 2026
buluoray
buluoray previously approved these changes Nov 7, 2026

@buluoray buluoray 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.

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

APPROVE at 6bd8187.

What it does for users: a message sent with knowledge attached while the agent is busy now shows only what the user typed on its queue card, even when a knowledge item holds the close marker on its own line, and the editor opens on those typed words. The card finds the envelope by the length and hash the composer recorded at send time instead of parsing the text.

Evidence

  • Gateway: knowledge_meta (dashboard/chat_delivery.py:1595) keeps only the bounded mark ({len, hash}) and refuses malformed shapes; it is stamped on the queue entry and its queue_push frame (chat_delivery.py:1387), on the slot-detail view (chat_delivery.py:1718), on the requeued steer, the sub-agent hold, the responsive send and the steer take-back. No knowledge text leaves meta.knowledge.
  • Dashboard: QueueStack.tsx:82 asks the existing knowledgeEnvelopeEnd (utils/knowledgeEnvelope.ts:18), which hides the envelope only when the recorded length lands on a line end and the hash matches, so a typed copy of an envelope, or an edit that no longer matches, is shown whole. stripQuoteBlock already strips the blank lines after a quote, so the quote + knowledge case lines up with the mark. Cold hydration picks the mark up through the rest spread in store/chat/queue.ts, and the push path through queueEntryKnowledgeEnvelope.
  • Tests: test_queue_knowledge_meta.py 4 passed; QueueStack.test.tsx, queue.knowledgeEnvelope.test.ts and SideChat.closedElsewhere.test.tsx 85 passed.
  • Mutations (one at a time, tree clean after each): passing undefined as the mark in QueueStack.tsx reddened 10 tests, among them "hides exactly the recorded envelope when a knowledge item holds the close marker on its own line"; skipping meta.update(knowledge) in queue_for_next_turn reddened test_busy_slot_entry_frame_and_queue_view_carry_the_mark.
  • CI: 90 success, 10 skipped, 1 failure. The failure is macOS Backend Tests shard 6, test_cloud_ssm_cov80.py::TestInstallCommandHint::test_deb_one_liner_reaches_sudo_only_on_a_matching_download (BSD sha256sum), which is not in this diff and is tracked as flaky in #32526. PR Readiness is green; UX, Design and First-Principles reviews PASS and both AI review lanes report no blocking findings. git merge-tree against current main is clean.

Source-only: the sub-agent hold path in chat_send.py and the steer take-back in steer_retract.py were read, not exercised by a test I ran.

Follow-ups (non-blocking)

  • A queued entry restored from disk that was queued before this change has no mark, so after the upgrade its card shows the whole envelope until it drains, where main hid it by parsing. The PR body states this; it is transient and limited to entries already queued at upgrade time.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Hold: this head now conflicts with main. GitHub reports CONFLICTING, and a local merge-tree against 727392d conflicts in chat_send.py, chat_delivery.py, responsive_chat.py, store/chat/queue.ts and store/chat/wire.ts. Those files overlap with #31441, which merged after this head went green. Please rebase. A new head needs a fresh review.

The change itself looks sound to me. The gateway keeps only the bounded {len, hash} mark (

def knowledge_meta(meta: object) -> dict[str, dict[str, Any]]:
). The card hides the envelope only when that mark matches the text (
let end = knowledgeEnvelopeEnd(afterQuote, m.meta?.knowledgeEnvelope)
). The mark survives queue_edit (
_edit_attachments = attachment_meta(entry.get("meta")) if entry is not None else {}
).

AI findings judged non-blocking

  • Design Review, restored pre-change entries show the whole envelope: stated in the PR body, transient, and limited to entries already queued at upgrade time.
  • UX Review, the unmarked fallback looks broken: the same transient case. A typed envelope copy is shown as typed by design.

The red macOS shard 6 test (test_cloud_ssm_cov80.py, BSD sha256sum) is outside this diff and tracked in #32526. Reviewed SHA 6bd8187.

— crew-pr-reviewer (r149)

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard/chat_api/chat_send.py, src/kiro_crew/dashboard/chat_delivery.py, src/kiro_crew/dashboard/responsive_chat.py, website/src/store/chat/queue.ts, website/src/store/chat/wire.ts since this head went green (759bb96 -> 95695ba); CI re-running.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 7, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The red Backend Tests shards 5 and 6 (Linux and Windows), and the Coverage Gate that fails closed behind them, are main's, not this diff's. The same three node ids fail with the same assertions on main's own run at c3b50d3 (https://github.com/kirodotdev/KiroCrew/actions/runs/42413945602):

  • test/test_held_note_turn_starts.py::test_every_turn_start_flushes_the_hold_or_is_listed and ::test_every_listed_turn_start_still_skips_the_flush (the slack/gateway_runtime/nudge_dashboard_fire.py rows)
  • test/test_dashboard_server_composition_contract.py::test_the_lazy_imports_stay_inside_the_functions_that_need_them (136 == 135)

This PR touches neither file. #32606 re-pins both. This PR waits for it, then rebases onto it and re-runs CI.

A send that waits in the queue lost the knowledge envelope mark the
composer records on meta.knowledge.envelope, so the queue card guessed
the envelope from the wire text: it showed the whole text when a
knowledge item held the close marker on its own line, and hid a typed
copy of an envelope as if it were real.

The gateway now keeps that mark, bounded and nothing else, on the queue
entry as meta.knowledgeEnvelope (busy, hold, responsive and requeued
steer paths), and sends it on queue_push and the slot-detail queue. The
card finds the envelope with knowledgeEnvelopeEnd, and the text-parsing
splitKnowledgeEnvelope is gone.

Closes #24011
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/learn-cron-dashboard.md and the Backend shard 5 and 6 tests since this head ran (284cbd7 -> f7de20f, onto 752c0b9, which carries #32606); CI re-running. The rebase was clean and the patch is unchanged. Local gate, local GPT and local Opus review passed on this patch.

@bolichen97
bolichen97 force-pushed the fix/24011-queue-knowledge-envelope branch from 284cbd7 to f7de20f Compare November 8, 2026 05:07
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 8, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at the author's request: PR Readiness passed on f7de20f, all five review lanes report no blocking finding on this head, no deep review of this head found a code defect, and no one else has an open change request.

@bolichen97
bolichen97 merged commit 790b725 into main Nov 8, 2026
100 of 102 checks passed
@bolichen97
bolichen97 deleted the fix/24011-queue-knowledge-envelope branch November 8, 2026 08:12
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
bolichen97 added a commit that referenced this pull request Nov 9, 2026
…32334)

A send that waits in the queue lost the knowledge envelope mark the
composer records on meta.knowledge.envelope, so the queue card guessed
the envelope from the wire text: it showed the whole text when a
knowledge item held the close marker on its own line, and hid a typed
copy of an envelope as if it were real.

The gateway now keeps that mark, bounded and nothing else, on the queue
entry as meta.knowledgeEnvelope (busy, hold, responsive and requeued
steer paths), and sends it on queue_push and the slot-detail queue. The
card finds the envelope with knowledgeEnvelopeEnd, and the text-parsing
splitKnowledgeEnvelope is gone.

Closes #24011

(cherry picked from commit 790b725)

Backport note: the durable marker and the queued_work parameter that
sit beside these lines on main come from feat #31441, which is not on
release, so each of the six conflicts keeps release's side and adds only
the knowledge envelope part: queue_for_next_turn takes only the
knowledge parameter and stamps it on the push before release's own
broadcast; the idle-hold push, responsive_chat.accept, queue.ts and
wire.ts add only the knowledgeEnvelope field (no durable). The
learn-cron-dashboard spec adds only the knowledge envelope paragraph,
not the queue editor hold paragraph from #30549.
bolichen97 added a commit that referenced this pull request Nov 9, 2026
…32334)

A send that waits in the queue lost the knowledge envelope mark the
composer records on meta.knowledge.envelope, so the queue card guessed
the envelope from the wire text: it showed the whole text when a
knowledge item held the close marker on its own line, and hid a typed
copy of an envelope as if it were real.

The gateway now keeps that mark, bounded and nothing else, on the queue
entry as meta.knowledgeEnvelope (busy, hold, responsive and requeued
steer paths), and sends it on queue_push and the slot-detail queue. The
card finds the envelope with knowledgeEnvelopeEnd, and the text-parsing
splitKnowledgeEnvelope is gone.

Closes #24011

(cherry picked from commit 790b725)

Backport note: the durable marker and the queued_work parameter that
sit beside these lines on main come from feat #31441, which is not on
release, so each of the six conflicts keeps release's side and adds only
the knowledge envelope part: queue_for_next_turn takes only the
knowledge parameter and stamps it on the push before release's own
broadcast; the idle-hold push, responsive_chat.accept, queue.ts and
wire.ts add only the knowledgeEnvelope field (no durable). The
learn-cron-dashboard spec adds only the knowledge envelope paragraph,
not the queue editor hold paragraph from #30549.
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.

chat: carry meta.knowledge on queue entries so the queue card can use the envelope fingerprint

4 participants