Repository navigation
feat(chat): show who wrote a note on the note bubble - #15917
iamwhatever merged 1 commit into
Conversation
94af9a0 to
5c0c6a4
Compare
UX Review (Opus 5.5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has looked at the note-bubble author pill, and the screenshots come from a harness built to mimic the page, not the live chat page. Watch
[UX-REVIEWED] 30d8383 Description read[DESCRIPTION-READ] 758099de67561dc1c65ced0a0e744b93f2a54a1c6f3d1094b5781cd1de306a59 That sha256 names everything this verdict read: the PR description, plus the 6 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 |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS An app's slug is cut to the 64-char cap meant for the free-text Not justified as shipped
What this change shipsInventory (6 items) — 4 justifiedIntent: let someone reading the transcript see which app wrote a note, shown on the note bubble itself (ADDITION).
[FIRST-PRINCIPLES-REVIEWED] 30d8383 Description read[DESCRIPTION-READ] f3405a154cef578a75c76c7770f4c4564fdabe287727874bedf55a32041bb558 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Update [DESIGN-REVIEWED] 30d8383 Description read[DESCRIPTION-READ] f2b3af8358e9a9fa133a42a3432fcb2081e15119f0f65a1fd0e34fd3b81f0980 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
5c0c6a4 to
967e911
Compare
967e911 to
e7a9043
Compare
e7a9043 to
9533091
Compare
9533091 to
2287959
Compare
|
@iamwhatever Thanks — this was the right call. Fixed in 1. Stamp from the authenticated caller, not 2. Drop the free-text source path and the redaction it needed.
Net: −57 lines; the change is a subtraction, as you anticipated. Note content keeps its pre-existing exfil→credential redaction unchanged — this PR only ever added a label. 3. Test that a caller cannot spoof another app's name. 4. Test for the Verified on |
7848032 to
3414b9b
Compare
3414b9b to
79a96df
Compare
|
@iamwhatever Re your CHANGES_REQUESTED review — the authenticated-caller fix is in, now at
New on Verified on |
79a96df to
17d770b
Compare
|
@iamwhatever Rebased onto current |
|
@iamwhatever — addressed on Following your trust finding and the first-principles review that reached the same conclusion, I subtracted the parallel note pill rather than keep a second attribution mechanism:
Verified on |
|
UX Review addressed on Blocker — "the screenshot shows a pill this diff does not render": correct. The old Evidence gap — app-written note bubble: closed. Case (1) in the image shows a Evidence gap — note held during a running turn: closed. Case (2) shows the flushed held note. The deferred-flush path ( Description contradiction — "sits beside the cron and app pills" vs the Suggestion — Re-requesting review. Head |
buluoray
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Reviewed at head 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf (single commit, base 139de6ecc0).
Prior human review — iamwhatever, CHANGES_REQUESTED at c9aa127
| Finding at c9aa127 | Status at 30d8383 |
|---|---|
Pill label taken from caller-controlled body["source"], so app A can post source="Kiro" and be shown as Kiro |
Fixed. src/kiro_crew/dashboard/chat_handlers.py:15715 sets display_source = request_app, and request_app = request.get("app", "") is read before the body (handler, ~15670). request["app"] is written only by the auth middleware in token_auth.py (3030/3102/3199/3552). The body source now feeds only the drain-frame cap bucket (_normalize_source(...) or "note"). Mutation M1 (switching back to the body source) turns 4 tests red, including test_app_cannot_spoof_another_apps_name. |
| Reuse the authenticated app pill rather than a separate "Note from" pill | Fixed. The immediate row (chat_handlers.py:15874) and the flushed held row (slot_buffers.py:811) both stamp meta.appLabel. Both renderers (ChatPage.tsx:4170 and messageRenderers.tsx:590) already draw components.mcpApp.from_app from that key. There is no new key and no new string. |
The two-pass redact_caller_text and the sink-allowlist entry can go |
Fixed. The diff against main adds no label redaction, and slot_buffers adds no redactor call. |
| Add a test that posts with an app token | Addressed, with a stand-in. test/test_note_source_label.py:44-60 installs a middleware that sets request["app"] from a header. The handler reads it the same way it does in production, but the real token middleware is not exercised. Acceptable; see follow-up 4. |
Add a test for the ChatPage.tsx:4172 pill |
Partly addressed. messageRenderers gets real render tests: one for a note with appLabel, one for a note without. The ChatPage test (transcriptRenderers.test.tsx:536) is a regex over the source file and already passes on main, so it guards the shape of the code, not this change. Non-blocking. |
None of the reviewer's logic findings is still open.
Blocking
None.
Non-blocking follow-ups
- Apps with names of 65–120 characters never get a pill.
chat_handlers.py:15716collapsesdisplay_sourceto""when it is longer thanMAX_SOURCE_LABEL_LEN(64). That cap was written for free-textsource, but app names may be up to 120 characters. The failure is fail-closed: the bubble looks the same as it does today, and admit and restore agree. Still, those apps miss the PR's stated goal. Suggest a label bound equal to the app-name cap, or truncation, in place of the free-text cap. The first-principles bot raised the same point. - Leftover aliases
_MAX_SOURCE_LEN = MAX_SOURCE_LABEL_LENand_SOURCE_CTRL_RE = SOURCE_LABEL_CTRL_REatchat_handlers.py:14947-14948. These are two names for one constant. Point_normalize_sourceat the imported names. - Comment problems.
chat_handlers.py:15693still calls the pill the "Note from ..." pill; it is "Sent by app {X}".- The same block says the
redact_caller_textand sink-allowlist entries "drop out with this change". They never existed on main, so the sentence only makes sense against the earlier revision. slot_buffers.py:~405-407has a broken sentence: "...the admit path produces it: the shared The stored source...".
- The app-token test uses a stub middleware. A test that runs the real
token_authapp-token path into/notewould pin the authenticated-identity claim end to end. - Docs.
docs/app-kit/api-reference.md:765(§ Notes) does not say that the bubble names the authenticated app and never the bodysource. App authors read this page, so it is worth one sentence there. The design bot raised the same point. - PR body overstates the frontend change. It says
pages/ChatPage.tsxandapp-sdk/messageRenderers.tsxchanged, but neither file is in the diff; the existing pill is reused. Related: whenappLabelis set, the content goes throughstripAppEnvelope, so a note body that literally starts with[MCP app message from "..."]\nwould lose that line on display. That is cosmetic, but the "byte for byte" claim is not strictly true. - Committed screenshots. The three
temp-screenshots/note-source-label/*.pngfiles are committed. Check whether the repo wants them in-tree.
Fail-open / fail-closed
- If
request_appis empty (dashboard token, cron, conductor), noappLabelis stamped and the bubble shows no pill, as today. Fail-closed. - A label that is too long or contains a control character collapses to
""and shows no pill. Fail-closed. - A restored
sourcethat is tampered (not a string, too long, or containing a control character) collapses to"". Fail-closed. - A legacy held entry with no
sourcerestores as"". Fail-closed. - No path can show a caller-chosen name: the only writer of the label is
request_app.
What I verified
- Static checks. flake8 is clean on
chat_handlers.py,slot_buffers.pyand the new test. Removingimport refromchat_handlers.pyis safe; nore.uses remain. - Tests.
test/test_note_source_label.pyplustest/test_deferred_note_persistence.py: 53 passed. The vitest filesAppSdkMessageRenderersCov80.test.tsxandtranscriptRenderers.test.tsx: 114 passed. - Row classification. I traced every reader of
meta.appLabel(chat_utils.py:3873,chat_runner.py:6508,chat_delivery.py:1214, the queue store,QueueStack). None of them reclassifies areconcile-noterow as an MCP-app row, so addingappLabelchanges only the pill. - Spec.
docs/system-specs/modules/session.mddoes not describe note row meta, so there is no stale spec text. - Mutations. For each one I backed up the file, applied the change, ran the two Python test files above, then restored the file.
git status --shortwas clean afterwards.
| Mutation | Tests that turned red |
|---|---|
M1: label from body["source"] instead of request_app |
test_app_cannot_spoof_another_apps_name, test_label_is_the_authenticated_app_identity, test_dashboard_user_gets_no_author_pill, test_held_note_carries_identity_and_flush_stamps_it |
| M2: drop the admit length/control-char bound | test_over_length_app_identity_is_bounded_consistently |
M3: drop "source" from the held-note dict |
test_held_note_carries_identity_and_flush_stamps_it, test_held_dashboard_note_carries_no_identity, test_over_length_app_identity_is_bounded_consistently |
M4: drop the immediate-row appLabel |
test_app_cannot_spoof_another_apps_name, test_label_is_the_authenticated_app_identity |
M5: drop source from serialize_deferred_notes |
test_serialize_then_sanitize_preserves_source |
| M6a: drop the restore length bound | test_oversized_source_collapses_to_empty |
| M6b: drop the restore control-char check | test_control_character_source_collapses_to_empty |
M6c: drop the restore isinstance check |
test_non_string_source_collapses_to_empty, test_legacy_entry_without_source_restores_blank, plus 10 restore tests in test_deferred_note_persistence.py |
M7: drop the flush appLabel stamp |
test_held_note_carries_identity_and_flush_stamps_it |
Every guard the PR adds has at least one test that fails without it.
Not verified: I did not run mypy or the full suite. The real app-token middleware was not driven through /note, and I did not render the UI live.
iamwhatever
left a comment
There was a problem hiding this comment.
Re-reviewed at 30d8383; the trust problem is fixed. The pill now uses the authenticated caller (request_app, chat_handlers.py:15715), never body['source'], through the existing meta.appLabel 'Sent by app' pill on both the immediate and deferred-flush paths, and the two-pass redactor is gone. Restoring the body-source line fails four tests in test_note_source_label.py, including the spoof test. Optional follow-ups: the 64-char label cap hides the pill for app names of 65-120 chars; fix the stale 'Note from ...' comment (chat_handlers.py:15693) and the broken sentence near slot_buffers.py:405; drop the _MAX_SOURCE_LEN / _SOURCE_CTRL_RE aliases and the committed temp-screenshots; the ChatPage test is a source regex that already passes on main. Clearing my request.
Problem / Motivation
Goal: A reader of the transcript can see which app wrote a note on the note bubble itself.
A note posted through
POST /api/chat/slots/{slot}/noterenders as a barereconcile-notebubble. The model is told the source ([Background context from "board-sync"]), but a person reading the transcript cannot tell which app wrote the note — the bubble carries no visible attribution.Why it matters
Notes are how out-of-band actors narrate state into a chat. When several apps write into the same transcript, an unattributed bubble forces the reader to guess the author from the prose. The endpoint accepts app tokens, so the attribution must be trustworthy: a free-text label would let one app post another app's name and have the bubble present it as the author. Binding the label to the authenticated caller turns an anonymous breadcrumb into a spoof-proof, auditable one — what a human scanning a busy pipeline chat needs.
Not a goal
sourcefield as the author. It is caller-controlled free text an app token could set to anyone's name, so it never reaches the pill; it is still read only for the internal drain-frame cap bucket.session_set_notetool (feat(mcp): session_set_color tints a session the caller created #15428 is still open). This PR covers the/noteHTTP caller's authenticated identity, which exists today.[Background context from "..."]). This PR only adds the visible label.What changed (motivation → approach → change)
Observed symptom → the note bubble shows no author. Root cause → the visible row's
metacarries onlynoteSession; no trustworthy author identity is stamped onto the row. The fix stamps the AUTHENTICATED caller identity on every write path and renders it through the SAME app-label pill an app inject row already uses — no new note-only pill.chat_handlers.post_slot_note: the visible labeldisplay_sourceis stamped fromrequest_app— the app identity the app-token auth middleware sets from the validated token record — NOT frombody["source"]. An app can therefore only ever be attributed as itself; app A postingsource="Kiro"still renders asapp-a. A dashboard user carries an emptyrequest_appand gets no pill. Because the label is a trusted, slug-shaped identity rather than caller-controlled free text, it needs no credential/exfil redaction. It is bounded with the same length + control-char check the restore sanitizer applies (MAX_SOURCE_LABEL_LEN,SOURCE_LABEL_CTRL_RE), so an over-length app name (a slug may be up to 120 chars) is bounded identically at admit and on restore — the admit/restore pair cannot drift and an app never silently loses its pill after a restart. The row stamps this value ontometa.appLabel— the same key an app inject row uses — so the existing "Sent by app {X}" pill (components.mcpApp.from_app) attributes the note, with no parallel meta key. The immediateslot.append(...)and the held-note dict both carry it. The note content runs through the exfiltration → credential redaction pair only (a note carries a label, not a rewritten body).slot_buffers:serialize_deferred_notespersistssource;sanitize_restored_deferred_notesvalidates it structurally on the on-disk trust boundary — a non-string, an over-length value, or one carrying a control character collapses to""(no pill) — the stored value is a trusted authenticated identity, not free text, so it carries no redaction.flush_deferred_notesstampsappLabelonto the delivered row only when the restoredsourceis non-empty, so a note held during a running turn is attributed through the same pill once flushed, just like an immediate one. The source-label bound constants (MAX_SOURCE_LABEL_LEN,SOURCE_LABEL_CTRL_RE) live here once and are imported by the writer, so the admit and restore bounds cannot drift.pages/ChatPage.tsxandapp-sdk/messageRenderers.tsx: a note row's author rides the existingmeta.appLabel→ "Sent by app {X}" pill (AppWindow icon), beside the existing cron (Clock) and app pills — no separate note pill, meta key or icon is added. The inject branch derives no client-side author; a note's content is not an app envelope, sostripAppEnvelopeleaves it byte for byte.components.mcpApp.from_app.Backwards compatibility
Compatible. The hold key
sourceand the row keyappLabelare additive: an older held note persisted withoutsourcerestores with an empty label, and a rehydrated row withoutappLabelrenders no pill. No field is rejected, renamed or removed; the persisted shape only grows one optional key, which every reader already tolerates. A note from a dashboard caller carries no label and renders no pill, the same bubble a reader sees today. The user-visible pill text is the existing "Sent by app {X}", not a new string.Tests
test/test_note_source_label.py(new, 15 tests): the label is the authenticated app identity, not the body (test_label_is_the_authenticated_app_identity); an app CANNOT spoof another app's name — appapp-apostingsource="Kiro"rendersapp-aonmeta.appLabel, asserted!= "Kiro"(test_app_cannot_spoof_another_apps_name); a dashboard user gets no author pill even with a bodysource; an over-length app identity is bounded identically at admit and on restore so no attribution is dropped after a restart (test_over_length_app_identity_is_bounded_consistently); note content keeps its exfil → credential redaction and a legitimate ZWJ emoji body survives admission and restore unchanged; a held note carries the authenticated identity and the flush stamps it; the serialize→sanitize round-trip preservessource; and a non-string / oversized / control-character persisted source each collapses to""on the on-disk trust boundary.website/src/test/transcriptRenderers.test.tsx: the ChatPage note attribution rides theappLabelpill, with nonoteSource/from_notewiring.website/src/test/AppSdkMessageRenderersCov80.test.tsx: a note row withmeta.appLabelrenders the author pill; a note row with no app identity renders none.test/test_deferred_note_persistence.pyandtest/test_security_posture.py(the redactor-omission and stale-allowlist guards —slot_buffersis not a redactor caller, so it is correctly absent from the allowlist) pass; i18n catalog-parity, key-reference and pseudolocale gates pass.Manual verification
Rendered the note bubble with the new pill in a faithful harness (the exact pill utility classes, light and dark) and confirmed it sits beside the cron and app pills with consistent styling, and that a dashboard-caller note renders no pill at all — see Screenshots. The live wiring is covered by the render tests above.
Screenshots / video
Representative render of the current attribution path, in light and dark, using the production utility classes and strings. A note posted with an app token now rides the existing app pill — the
AppWindowicon plus "Sent by the {app} app" (components.mcpApp.from_app), with thefrom_app_tooltipon hover — exactly the pill an app-origin message already shows, because the backend stampsmeta.appLabel = request_apprather than a separatenoteSource. Three cases are shown: (1) an app-token note, (2) the same note held during a running turn and then flushed (carries the sameappLabel, so the pill is identical), and (3) a note from a dashboard caller with no authenticated identity, which renders no pill. Note: the pill sits under the!cronLabelguard, so a cron-origin note shows the cron pill instead — the app pill is for app-token notes. This is a mock harness reproducing the exact production markup/classes/strings (no running gateway in this environment); the live render path is unit-tested intranscriptRenderers.test.tsxandmessageRendererscov.Related Issues
Fixes #15508
Pattern harvest
Not generalizable: this is a one-off attribution gap on one row type — a trustworthy author identity (
request_app) was already available at the handler and simply was not stamped onto the visible row. No wider class of missing-provenance rows is implied.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
I confirm this contribution is made under the terms of the project's Contribution License Agreement.