Skip to content

feat(chat): show who wrote a note on the note bubble - #15917

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
chenmingwei23:feat/transcript-note-source-label-15508
Oct 4, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
chenmingwei23:feat/transcript-note-source-label-15508

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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}/note renders as a bare reconcile-note bubble. 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

  • Rendering an attribution for a DASHBOARD-token caller (a conductor, a cron, or a human posting on the dashboard token). Those carry an empty authenticated app identity, so the note is treated as the user's own and gets no author pill — the same bubble a reader sees today. Attribution here is scoped to app-token callers on purpose: that is the only identity the server can vouch for, and the whole point of this change is that the label cannot be spoofed. A visibly "claimed" label for dashboard callers is a separate follow-up.
  • Displaying the caller's body source field 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.
  • The calling session's key for the session_set_note tool (feat(mcp): session_set_color tints a session the caller created #15428 is still open). This PR covers the /note HTTP caller's authenticated identity, which exists today.
  • Changing the drain frame the model sees ([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 meta carries only noteSession; 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.

  • Backend, chat_handlers.post_slot_note: the visible label display_source is stamped from request_app — the app identity the app-token auth middleware sets from the validated token record — NOT from body["source"]. An app can therefore only ever be attributed as itself; app A posting source="Kiro" still renders as app-a. A dashboard user carries an empty request_app and 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 onto meta.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 immediate slot.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).
  • Backend, slot_buffers: serialize_deferred_notes persists source; sanitize_restored_deferred_notes validates 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_notes stamps appLabel onto the delivered row only when the restored source is 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.
  • Frontend, pages/ChatPage.tsx and app-sdk/messageRenderers.tsx: a note row's author rides the existing meta.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, so stripAppEnvelope leaves it byte for byte.
  • i18n: no new key — the note reuses components.mcpApp.from_app.

Backwards compatibility

Compatible. The hold key source and the row key appLabel are additive: an older held note persisted without source restores with an empty label, and a rehydrated row without appLabel renders 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 — app app-a posting source="Kiro" renders app-a on meta.appLabel, asserted != "Kiro" (test_app_cannot_spoof_another_apps_name); a dashboard user gets no author pill even with a body source; 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 preserves source; 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 the appLabel pill, with no noteSource/from_note wiring. website/src/test/AppSdkMessageRenderersCov80.test.tsx: a note row with meta.appLabel renders the author pill; a note row with no app identity renders none.
  • Existing test/test_deferred_note_persistence.py and test/test_security_posture.py (the redactor-omission and stale-allowlist guards — slot_buffers is 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 AppWindow icon plus "Sent by the {app} app" (components.mcpApp.from_app), with the from_app_tooltip on hover — exactly the pill an app-origin message already shows, because the backend stamps meta.appLabel = request_app rather than a separate noteSource. Three cases are shown: (1) an app-token note, (2) the same note held during a running turn and then flushed (carries the same appLabel, 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 !cronLabel guard, 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 in transcriptRenderers.test.tsx and messageRenderers cov.

Current note attribution in light and dark: an app-token note shows the "Sent by the {app} app" pill with the AppWindow icon; a flushed held note shows the same pill; a dashboard-caller note shows no pill

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

  • 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

Contribution License Agreement

I confirm this contribution is made under the terms of the project's Contribution License Agreement.

@chenmingwei23
chenmingwei23 requested a review from a team October 1, 2026 15:41
@chenmingwei23
chenmingwei23 requested a review from a team as a code owner October 1, 2026 15:41
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 94af9a0 to 5c0c6a4 Compare October 1, 2026 15:43
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • Harness evidence, not the real transcript. The description says "Rendered … in a faithful harness". The images (temp-screenshots/note-source-label/pill-*.png) show the existing "Sent by the board-sync app" pill above the note bubble, in light and dark, plus the case where a note gets no pill. The diff changes no production TSX: it reuses the ChatPage.tsx:4171 / messageRenderers.tsx:590 pill. That means the pill's real spacing among ordinary chat rows, and a long app slug wrapping (up to MAX_SOURCE_LABEL_LEN), have not been shown in the live UI. Severity: low. Every app-written note shows this pill, but it is an existing pattern, so a defect would be cosmetic. Fix: attach one live ChatPage screenshot of an app-token note.
  • The pill shows the raw app slug ("board-sync"), not a display name, because appLabel = request_app. This matches the existing app-inject pill, so it is consistent. Check that it reads acceptably for real app ids that contain / or long slugs; the pill keeps only the part before the first / (split('/')[0]).

[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 .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 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf via the fork AI-review pipeline — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

An app's slug is cut to the 64-char cap meant for the free-text source, so apps with 65–120-char names silently get no pill. The constant aliases are a second spelling.

Not justified as shipped

  • Item 4 — inherited: the 64-char/control-char bound was written for caller-supplied source text ("Defense-in-depth: the real free-form surface is content"). This PR applies it to a trusted slug, and its own description says "a slug may be up to 120 chars". The check if len(display_source) > MAX_SOURCE_LABEL_LEN ...: display_source = "" then removes attribution for those apps, which is exactly what the Goal promises them.
    Subtraction: delete the admit-side recheck of display_source and cut the restore bound down to the slug's own import cap. Don't reuse the free-text label cap.
    Clears when: an app named with 65–120 characters keeps its pill both at admit and after restore, or the description names why those apps should lose attribution.
  • Item 5 — duplicate of slot_buffers.MAX_SOURCE_LABEL_LEN / SOURCE_LABEL_CTRL_RE: the lines _MAX_SOURCE_LEN = MAX_SOURCE_LABEL_LEN and _SOURCE_CTRL_RE = SOURCE_LABEL_CTRL_RE keep two names for one constant in chat_handlers.py. Grepping _MAX_SOURCE_LEN|_SOURCE_CTRL_RE finds 4 uses of the aliases, while the new code calls the imported names directly.
    Subtraction: delete both aliases and point the 4 uses in _normalize_source at the imported names.
    Clears when: the aliases are gone.

What this change ships

Inventory (6 items) — 4 justified

Intent: let someone reading the transcript see which app wrote a note, shown on the note bubble itself (ADDITION).

  1. A note posted with an app token now shows "Sent by app {X}" on the bubble — justified
  2. A note held during a running turn keeps its author through persistence and gets the pill when flushed — justified
  3. A tampered persisted author label is reset to no pill on restore — justified
  4. Apps with names longer than 64 characters get no pill — inherited
  5. The source-length bound moves to slot_buffers and chat_handlers keeps alias names — duplicate of slot_buffers constants
  6. Screenshots committed under temp-screenshots/note-source-label/ — justified

[FIRST-PRINCIPLES-REVIEWED] 30d8383

Description read

[DESCRIPTION-READ] f3405a154cef578a75c76c7770f4c4564fdabe287727874bedf55a32041bb558

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 30d8383

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Update docs/app-kit/api-reference.md § Notes in this PR to say the bubble names the authenticated app, never the body's source.

[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 .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 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 30d8383

@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 1, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 5c0c6a4 to 967e911 Compare October 1, 2026 18:02
@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 1, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 967e911 to e7a9043 Compare October 1, 2026 23:46
@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from e7a9043 to 9533091 Compare October 2, 2026 02:01
@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 9533091 to 2287959 Compare October 2, 2026 02:49
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 2, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 2, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

@iamwhatever Thanks — this was the right call. Fixed in 7848032cc794bdd4b5e454e6d3322c7c282f1d5c, point by point:

1. Stamp from the authenticated caller, not body['source'].
The visible label is now display_source = request_app (the identity the app-token auth middleware stamps from the validated token record), set in api_chat_slot_note. body['source'] no longer reaches the pill — it is still read, but only for the internal drain-frame cap bucket ([Background context from "..."]), which is the pre-existing /context trusted-caller boundary, not an author attribution. A dashboard user carries an empty request_app and gets no author pill. The deferred hold carries the same request_app, so a held note flushes the same spoof-proof identity.

2. Drop the free-text source path and the redaction it needed.
With the label bound to a trusted, slug-shaped identity, there is nothing caller-controlled left to redact:

  • Removed the two-pass redact_caller_text helper from slot_buffers.py (and its redact_credentials / redact_exfiltration_urls / normalize_for_scanning imports) — it was only ever called on the source label.
  • Admit path no longer redacts/normalizes the label; restore path validates it structurally only (type + ≤64 chars + no control char → else ""), since on-disk metadata is still a trust boundary.
  • Removed dashboard/slot_buffers.py from NON_EGRESS_REDACTION_MODULES in security_posture.py — it no longer calls any redactor, so test_allowlist_has_no_stale_entries would otherwise fail. The posture suite (omission + stale-allowlist) is green.

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.
test/test_note_source_label.py::TestImmediatePath::test_app_cannot_spoof_another_apps_name: app app-a posts source="Kiro"; the row's noteSource is "app-a" and asserted != "Kiro". Plus test_label_is_the_authenticated_app_identity, test_dashboard_user_gets_no_author_pill, and the deferred-path equivalents. The test harness now runs a middleware that stamps request["app"] from an X-Test-App header (standing in for the auth middleware), so a test can post as an app or as a dashboard user.

4. Test for the ChatPage.tsx:4172 pill.
website/src/test/transcriptRenderers.test.tsx — "ChatPage note pill reads meta.noteSource verbatim, gated on isNoteRow" — pins that the pill reads m.meta?.noteSource (the backend-stamped identity), is gated on isNoteRow, and renders through components.mcpApp.from_note with no client-side author derivation. The existing messageRenderers render test still covers the shared renderer.

Verified on 7848032cc: 14 note tests + 91 posture/persistence pass; 114 frontend tests pass; black(py312)/isort/flake8/mypy clean.

@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 2, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 7848032 to 3414b9b Compare October 2, 2026 17:20
@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 2, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 3414b9b to 79a96df Compare October 2, 2026 17:39
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

@iamwhatever Re your CHANGES_REQUESTED review — the authenticated-caller fix is in, now at 79a96df30d49c45f746632b8e10fe4671f69d8d0. Recap plus one follow-up fix on this head:

  1. Stamp from the authenticated caller, not the body — the pill label is display_source = request_app (the app-token auth middleware's validated identity); body['source'] no longer reaches the pill (it survives only as the internal drain-frame cap bucket). Dashboard user → empty request_app → no author pill. Deferred holds carry request_app too.
  2. Dropped the free-text path + its redaction — removed the two-pass redact_caller_text helper and its imports from slot_buffers.py; the restore path validates the stored identity structurally only; removed dashboard/slot_buffers.py from the security_posture redactor-sink allowlist (it no longer calls a redactor). Net subtraction.
  3. Anti-spoof test — test_app_cannot_spoof_another_apps_name: app app-a posting source="Kiro" renders noteSource == "app-a", asserted != "Kiro".
  4. ChatPage pill test — transcriptRenderers.test.tsx pins the pill reads meta.noteSource verbatim, gated on isNoteRow.

New on 79a96df30 — a GPT 5.6 BLOCKING finding caught a real edge the c466 change opened: an app slug can be up to 120 chars (MAX_APP_NAME_CHARS), so an over-length identity was stamped unbounded, persisted verbatim, then collapsed to "" by the restore sanitizer (>MAX_SOURCE_LABEL_LEN) — the app would silently lose its pill after restart. Fixed by applying the SAME structural bound (MAX_SOURCE_LABEL_LEN + SOURCE_LABEL_CTRL_RE, both already imported) at the admit stamp, so what admit stamps always survives restore unchanged. Added test_over_length_app_identity_is_bounded_consistently (admit stamps "", persists "", restore keeps "" — no attribution dropped).

Verified on 79a96df30: 15 note tests + 91 posture/persistence pass; 114 frontend tests pass; black(py312)/isort/flake8/mypy clean; comment-history gate green. Re-requesting your review.

@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 2, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/transcript-note-source-label-15508 branch from 79a96df to 17d770b Compare October 3, 2026 06:39
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

@iamwhatever Rebased onto current main (139de6ec) to pick up the frontend-test fix #16227 — no change to the attribution logic. The authenticated-caller fix you requested is unchanged and live on the new head: the pill is stamped from request_app (the auth-middleware app identity), never body['source']; the free-text path and its two-pass redaction are gone; test_app_cannot_spoof_another_apps_name and the ChatPage.tsx pill-wiring test remain green. New head 17d770b4183a3f1559a0fef9799551118a80474e.

@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 3, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

@iamwhatever — addressed on 942f5bff183f0bc5eb6f71b66a7bbd77daa1441f.

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:

  • Authenticated caller, not body['source'] — the note's author is stamped from request_app (the app-token auth middleware's validated identity), never from body['source']. An app can only ever be attributed as itself; app-a posting source="Kiro" renders app-a.
  • Reuse the existing app-label pill — instead of a new noteSource meta key + from_note string + StickyNote pill, the row now stamps meta.appLabel = request_app, so the note is attributed through the same "Sent by app {X}" pill (components.mcpApp.from_app) an app inject row already uses. Deleted noteSource, the from_note key from all 13 locales, and both StickyNote pills. Net subtraction.
  • Drop the redaction that free text needed — removed the two-pass redact_caller_text helper and its imports; the restore path validates the stored label structurally only (type + length + control-char). slot_buffers is no longer a redactor caller, so it's dropped from the security_posture sink-allowlist (the stale-allowlist guard confirms this).
  • Spoof test — test_app_cannot_spoof_another_apps_name: app-a posts source="Kiro"; the row's meta.appLabel == "app-a", asserted != "Kiro". The harness stamps request["app"] via an X-Test-App middleware so a test posts as an app or a dashboard user.
  • Pill render — AppSdkMessageRenderersCov80.test.tsx: a note row with meta.appLabel renders the author pill; one with no app identity renders none. transcriptRenderers.test.tsx pins the ChatPage attribution rides appLabel, with no noteSource/from_note wiring.

Verified on 942f5bff18: 15 note + 91 posture/persistence + 114 renderer + 101 i18n tests pass; black/isort/flake8/mypy/tsc clean. Re-requesting your review.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

UX Review addressed on 30d8383ac1771bb3a37ecf4d0022cf59d28eeaaf — the screenshot was stale against the shipped design; refreshed to the current render path and the body corrected.

Blocker — "the screenshot shows a pill this diff does not render": correct. The old pill-light-dark.png showed the dropped noteSource / "Note from {source}" design with a file icon. I retook it from the current render path (messageRenderers.tsx:589-590, ChatPage.tsx:4169-4170): a note posted with an app token now rides the existing app pill — AppWindow icon + "Sent by the board-sync app" (components.mcpApp.from_app), with the from_app_tooltip on hover — because the backend stamps meta.appLabel = request_app. The mock reproduces the exact production markup, utility classes and theme variables (bg-warn-subtle, text-muted, ring-warn/30) in light and dark. Committed under temp-screenshots/note-source-label/ (pill-light-dark.png + per-pane pill-dark.png / pill-light.png).

Evidence gap — app-written note bubble: closed. Case (1) in the image shows a reconcile-note row carrying meta.appLabel="board-sync" → the "Sent by the board-sync app" pill with the AppWindow icon, light and dark, with the tooltip text called out below each pane.

Evidence gap — note held during a running turn: closed. Case (2) shows the flushed held note. The deferred-flush path (slot_buffers.py) stamps the same meta.appLabel, so the delivered row renders the identical pill — shown side by side with the immediate case to make the parity explicit.

Description contradiction — "sits beside the cron and app pills" vs the !cronLabel guard: fixed. The body no longer claims the pill sits beside a cron pill. It now states plainly that the pill is under the !cronLabel guard, so a cron-origin note shows the cron pill instead; the app pill is for app-token notes. (It is the same pill app-origin messages already show, not a new one beside it.)

Suggestion — from_app_tooltip wording on a note: noted. The tooltip ("Kiro treats it as the app's words, not yours") still holds for an app-token note: the model does receive the note as the app's injected content ([Background context from "…"]), i.e. the app's words rather than the user's — which is exactly what the tooltip warns. Giving notes a distinct tooltip is a reasonable follow-up, but it would fork a shared string for a wording nuance; I've left the shared tooltip to keep the one authenticated-identity surface, and I'm happy to split it in a follow-up if you'd prefer note-specific copy.

Re-requesting review. Head 30d8383ac1, mergeable.

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

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

  1. Apps with names of 65–120 characters never get a pill. chat_handlers.py:15716 collapses display_source to "" when it is longer than MAX_SOURCE_LABEL_LEN (64). That cap was written for free-text source, 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.
  2. Leftover aliases _MAX_SOURCE_LEN = MAX_SOURCE_LABEL_LEN and _SOURCE_CTRL_RE = SOURCE_LABEL_CTRL_RE at chat_handlers.py:14947-14948. These are two names for one constant. Point _normalize_source at the imported names.
  3. Comment problems.
    • chat_handlers.py:15693 still calls the pill the "Note from ..." pill; it is "Sent by app {X}".
    • The same block says the redact_caller_text and 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-407 has a broken sentence: "...the admit path produces it: the shared The stored source...".
  4. The app-token test uses a stub middleware. A test that runs the real token_auth app-token path into /note would pin the authenticated-identity claim end to end.
  5. Docs. docs/app-kit/api-reference.md:765 (§ Notes) does not say that the bubble names the authenticated app and never the body source. App authors read this page, so it is worth one sentence there. The design bot raised the same point.
  6. PR body overstates the frontend change. It says pages/ChatPage.tsx and app-sdk/messageRenderers.tsx changed, but neither file is in the diff; the existing pill is reused. Related: when appLabel is set, the content goes through stripAppEnvelope, so a note body that literally starts with [MCP app message from "..."]\n would lose that line on display. That is cosmetic, but the "byte for byte" claim is not strictly true.
  7. Committed screenshots. The three temp-screenshots/note-source-label/*.png files are committed. Check whether the repo wants them in-tree.

Fail-open / fail-closed

  • If request_app is empty (dashboard token, cron, conductor), no appLabel is 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 source that is tampered (not a string, too long, or containing a control character) collapses to "". Fail-closed.
  • A legacy held entry with no source restores 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.py and the new test. Removing import re from chat_handlers.py is safe; no re. uses remain.
  • Tests. test/test_note_source_label.py plus test/test_deferred_note_persistence.py: 53 passed. The vitest files AppSdkMessageRenderersCov80.test.tsx and transcriptRenderers.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 a reconcile-note row as an MCP-app row, so adding appLabel changes only the pill.
  • Spec. docs/system-specs/modules/session.md does 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 --short was 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 iamwhatever 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.

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.

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

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transcript notes: show who wrote a note on the note bubble

3 participants