Skip to content

fix(website): keep emoji whole when truncating remaining labels - #24796

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
IngridMorstrad:fix/emoji-safe-label-truncation-batch
Oct 28, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
IngridMorstrad:fix/emoji-safe-label-truncation-batch

Conversation

@IngridMorstrad

@IngridMorstrad IngridMorstrad commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: No dashboard label, preview or notice listed in #24727 shows a broken � glyph when it cuts text next to an emoji.

Each site below cuts text with a UTF-16 .slice(0, n). When an emoji (or any astral character) straddles the cap, the slice keeps the emoji's high surrogate and drops the low one, so the text ends in a lone surrogate, which renders as �. For example, a browser annotation whose accessible name is 38 ASCII characters followed by 🎉 is labelled aaaa…aaa�….

Why it matters

The broken glyph lands on text the user or an agent wrote: a quoted selection, an annotation label, a memory preview, an agent or cron name, a workflow phase title, an error message, a sub-agent's task. It reads as corruption. The widget action text is also handed to the composer, so a lone surrogate there becomes invalid Unicode in a message the user may send.

Not a goal

What changed (motivation → approach → change)

Symptom: � at the end of a truncated label. Root cause: the UTF-16 slice ends between the two halves of a surrogate pair. Change: every site now cuts with the existing exported sliceCodePoints(s, 0, n) from website/src/components/CommentOverlay.tsx (the helper #24753 uses), so no new copy of the surrogate check is added. When an end edge would split a pair, the helper moves it back one unit. The cut can only get shorter, so every cap still holds. An emoji that ends exactly at the cap is kept. Text without astral characters truncates exactly as before.

  • website/src/hooks/useSelectionComposerAnchor.ts clipQuote: selection notice quote (48).
  • website/src/utils/browserAnnotations.ts truncate: browser annotation label (40).
  • website/src/components/FlyingQuote.tsx: flying quote text (60).
  • website/src/apps/issue-radar/views/GraphView.tsx: focus-tree node title (26) and the jump list <option> (50, same file, same cut).
  • website/src/apps/mochi/panel/approvalActions.ts approvalLabel: approval command line (72).
  • website/src/pages/overview/MemoryRecordsEditor.tsx shortBody: restore button label (40).
  • website/src/pages/chat/SubagentCompletionCard.tsx headline: sub-agent completion task (120). This is the site More dashboard labels can cut an emoji in half when truncated #24727 lists that was previously deferred.
  • website/src/components/chat-input/collapse.tsx collapsedDraftLine: collapsed draft line (120).
  • website/src/components/WidgetFrame.tsx: widget action text handed to the composer (MAX_WIDGET_ACTION_TEXT).
  • website/src/hooks/useAgentSync.ts shortName: scene agent name (45).
  • website/src/hooks/useSceneInteraction.tsx messagePreview: scene tooltip (64).
  • website/src/hooks/themeCss.ts _droppedRuleId: dropped theme rule id in Settings (80).
  • website/src/pages/overview/MemoryCarveCard.tsx: memory row preview, mobile card and table cell (160).
  • website/src/apps/workflows/WorkflowRunTree.tsx: phase title (80), agent label (100), last tool (60), narrator log line (200), both error notices (200), result JSON (2000).

Backwards compatibility

Compatible: every function and component keeps its signature and cap. Output changes only when it used to end in a lone high surrogate, which is invalid UTF-16 that no caller can use.

Removes nothing: the change drops one malformed code unit from a display string and touches no stored data, key, route or public function.

Tests

Each new test sets up a site so that an emoji (🎉 or 😀) straddles the cap, then asserts the exact truncated text and that no lone high surrogate is left. A second case puts the emoji so it ends exactly at the cap and checks it is kept whole.

  • website/src/hooks/useSelectionComposerAnchor.truncate.test.tsx: refusal notice quote, through onRefusedAfterClose.
  • website/src/test/browserAnnotations.truncate.test.ts: annotationLabel.
  • website/src/test/FlyingQuote.truncate.test.tsx: rendered quote text.
  • website/src/apps/issue-radar/views/GraphView.truncate.test.tsx: focus-tree SVG title and jump <option> text.
  • website/src/apps/mochi/test/approvalActions.truncate.test.ts: approvalLabel.
  • website/src/pages/overview/MemoryRecordsEditor.truncate.test.tsx: restore button label.
  • website/src/test/SubagentCompletionCard.test.tsx: added "keeps an emoji whole when the headline cut lands mid-surrogate-pair" (119 ASCII + 😀 straddling the 120-unit cap). It fails on the pre-fix .slice(0, 120) — the headline ends in a lone high surrogate — and passes on sliceCodePoints.
  • website/src/components/chat-input/collapse.truncate.test.tsx: useComposerCollapse().collapsedDraftLine.
  • website/src/components/WidgetFrame.truncate.test.tsx: mc-widget-send detail text.
  • website/src/test/useAgentSync.truncate.test.tsx: cron agent name.
  • website/src/test/useSceneInteraction.truncate.test.ts: messagePreview.
  • website/src/test/themeCss.truncate.test.ts: scopeOverridesCss().droppedRules.
  • website/src/pages/overview/MemoryCarveCard.truncate.test.tsx: mobile card and table cell.
  • website/src/apps/workflows/WorkflowRunTree.truncate.test.tsx: all seven cuts.

TDD for the SubagentCompletionCard site: with the production line reverted to .slice(0, 120) the new test fails (received string ends in \ufffd before the …); with sliceCodePoints it passes. The full SubagentCompletionCard.test.tsx suite (57 tests) and CommentOverlay.test.ts pass.

Local gates on the final tree: tsc -p tsconfig.app.json --noEmit clean, eslint on every changed file clean, node scripts/check-i18n-strings.mjs OK, python3 scripts/check_file_line_cap.py 0 failures.

Manual verification

N/A — unit coverage is enough. Each site's output is a plain string the tests read directly, or through the rendered DOM node the user sees.

Screenshots / video

Why no screenshot: the only rendered change is that a label which used to end in �… now ends in …, at a cap position that needs crafted input to reach, and the tests assert those exact strings.

Design note

The reviewer suggested moving sliceCodePoints (and snapOffPair) out of the React component CommentOverlay.tsx into a pure module under utils/, now that pure modules import it. That is the right home, but the move rewrites an import line in ~15 files across utils/, lib/, hooks/, apps/, pages/ and components/, several of which are being edited by open PRs (e.g. #20493 on CommentOverlay, #16481 / #17525 / #19820 / #19824 / #22674 / #23854 on changed files). Folding it in here would balloon this PR's diff and collide with those PRs on the import lines, so it is tracked as its own refactor in #24983 and left out of this behavioural fix.

Related Issues

Closes #24727
Design-note follow-up: #24983

Sibling sweep

Swept: git grep -nE "\.slice\(0, [^)]+\)( \+ '…'|}…)" -- website/src plus the sites listed on #24727 and its comments
Sibling: website/src/hooks/useSelectionComposerAnchor.ts:36 -- changed here
Sibling: website/src/utils/browserAnnotations.ts:46 -- changed here
Sibling: website/src/components/FlyingQuote.tsx:171 -- changed here
Sibling: website/src/apps/issue-radar/views/GraphView.tsx:248 -- changed here
Sibling: website/src/apps/issue-radar/views/GraphView.tsx:619 -- changed here
Sibling: website/src/apps/mochi/panel/approvalActions.ts:44 -- changed here
Sibling: website/src/pages/overview/MemoryRecordsEditor.tsx:24 -- changed here
Sibling: website/src/pages/chat/SubagentCompletionCard.tsx:47 -- changed here (the site #24727 lists; fixed with a TDD surrogate-pair test)
Sibling: website/src/components/chat-input/collapse.tsx:154 -- changed here
Sibling: website/src/components/WidgetFrame.tsx:302 -- changed here
Sibling: website/src/hooks/useAgentSync.ts:34 -- changed here
Sibling: website/src/hooks/useSceneInteraction.tsx:77 -- changed here
Sibling: website/src/hooks/themeCss.ts:603 -- changed here
Sibling: website/src/pages/overview/MemoryCarveCard.tsx:167 -- changed here
Sibling: website/src/apps/workflows/WorkflowRunTree.tsx:149 -- changed here
Sibling: website/src/lib/sessionTabs.ts:278 -- tracked in #24728
Sibling: website/src/utils/sessionRefs.ts:124 -- tracked in #24728
Sibling: website/src/utils/questionAnswers.ts:35 -- tracked in #24728
Sibling: website/src/pages/chat/TurnNavigationMinimap.tsx -- tracked in #24753
Sibling: website/src/pages/chat/MemoryRecallStrip.tsx:18 -- not affected -- clips a server-minted memory record id, not user or agent text
Sibling: website/src/components/WidgetFrame.tsx:294 -- not affected -- the 64-unit cut is a widget action id, not shown text, and the full id is kept when it is under the cap

Open PRs touch some of these files. #24710 (feat(subagents): name unlabelled runs) rewrites the SubagentCompletionCard.tsx headline line this PR fixes, keeping the same .slice(0, 120) bug; the fix is made here so Closes #24727 is honest, and whichever lands second resolves a trivial conflict on that one line. Others touch changed files but not a changed line: #20757 (SubagentCompletionCard model-fallback, a different region), #10175 (WidgetFrame), #11100 (collapse), #16481 (useAgentSync, useSceneInteraction), #17525 / #19820 / #19824 (GraphView), #22674 (themeCss), #23854 (useSceneInteraction), #20493 (CommentOverlay, imported only).

Pattern harvest

Rule candidate: lint
Pattern: a display string cut with .slice(0, n) followed by an ellipsis, where n can split a UTF-16 surrogate pair. It should go through sliceCodePoints.

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

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of c600ff78683c0321a57464b9b4a875c6dc1aa887 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

This is a narrow fix for invalid UTF-16 that reuses the existing helper. It takes nothing away and changes no visual layout, so no screenshot is needed.

Notes

[DESIGN-REVIEWED] c600ff7

Description read

[DESCRIPTION-READ] b275a71cd1becf85c19b6a040600f9eb412d9df2765aa33eda2ebaf306298dba

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of c600ff78683c0321a57464b9b4a875c6dc1aa887 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. Every site now uses the existing sliceCodePoints helper, so there is no second copy of it. My grep found 13 sibling cuts and the PR fixes 12; the one left truncates an id.

Notes

  • Item 1 — inventory gap: the description lists website/src/pages/overview/MemoryRecordsEditor.truncate.test.tsx, but the patch adds website/src/test/MemoryRecordsEditor.truncate.test.tsx. Only the description is wrong; nothing ships differently.

What this change ships

Inventory (6 items) — 6 justified

Intent: stop truncated dashboard labels from ending in a broken � when the cut lands inside an emoji. This is a FIX.

  1. Truncated labels, previews and notices at 14 sites, listed in More dashboard labels can cut an emoji in half when truncated #24727, no longer end in �… when an emoji straddles the cap — justified
  2. An emoji that ends exactly at the cap is kept whole — justified
  3. The widget action text handed to the composer is no longer invalid Unicode — justified
  4. The workflow run tree's seven cuts (phase, agent, tool, log, errors, result JSON) keep emoji whole — justified
  5. The issue-radar jump list <option> and the memory carve preview, which cut without an ellipsis, also keep emoji whole — justified
  6. New per-site tests pin both the straddling case and the exact-fit case — justified

[FIRST-PRINCIPLES-REVIEWED] c600ff7

Description read

[DESCRIPTION-READ] 60c1dd2c15c177e76b35fdf18fceafd7391c30abbf02555c41f5f5f2fbfd04b9

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of c600ff78683c0321a57464b9b4a875c6dc1aa887 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The diff only changes where existing labels are cut, so an emoji at the cut is no longer split into a broken � glyph. No control, string, layout or state is added or changed.

[UX-REVIEWED] c600ff7

Description read

[DESCRIPTION-READ] d36c1abccbc0556f849ba4554bdd2ce5d41313b6c58724013da2114a5bcd1741

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] c600ff7

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] c600ff7

@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 Oct 27, 2026

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

REQUEST_CHANGES at 673ed34.

The fix is right at every site it touches. Each cut now goes through the existing sliceCodePoints, which only shortens a cut that would split a surrogate pair, so every cap still holds. CI is green.

Two items need tracking or an answer before approval:

  1. This PR says Closes #24727, but one site on that issue's list stays broken: SubagentCompletionCard.tsx (L47) still uses .slice(0, 120). The description defers it to #24710, but #24710's version of that line is name.slice(0, 120), which has the same bug. Fix it here, change Closes to Part of #24727, or open an issue for it and link it in the description.
  2. The Design note has no reply. It suggests moving sliceCodePoints out of the React component file CommentOverlay.tsx into utils/ or lib/, now that pure modules import it. Reply on the PR, do the move, or open an issue and link it.

— crew-pr-reviewer (r129)

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 27, 2026
IngridMorstrad added a commit to IngridMorstrad/KiroCrew that referenced this pull request Oct 27, 2026
Twenty-two dashboard cuts used a UTF-16 .slice(0, n). When an emoji
straddled the cap, the label kept the emoji's lone high surrogate, which
renders as U+FFFD. Each site now cuts with the existing exported
sliceCodePoints from components/CommentOverlay, so the end edge moves off
a surrogate pair and every cap still holds.

Sites: selection notice quote, browser annotation label, flying quote,
issue-radar graph title and jump option, Mochi approval label, memory
restore label, collapsed draft line, widget action text, scene agent name
and tooltip, dropped theme rule id, memory carve previews, the seven
workflow run tree cuts, and the subagent completion card headline task
(pages/chat/SubagentCompletionCard.tsx:47), the last site kirodotdev#24727 lists.

The remaining design note on kirodotdev#24796 — moving sliceCodePoints out of the
CommentOverlay component into utils/ — is tracked in kirodotdev#24983, since the
move rewrites an import line in ~15 files, several edited by open PRs.

Closes kirodotdev#24727
@IngridMorstrad
IngridMorstrad force-pushed the fix/emoji-safe-label-truncation-batch branch from 673ed34 to a477498 Compare October 27, 2026 20:28
@IngridMorstrad

Copy link
Copy Markdown
Contributor Author

Thanks — both addressed in a47749853d:

  1. SubagentCompletionCard.tsx:47 — fixed here so Closes #24727 stays honest. The headline task cut now goes through sliceCodePoints(task, 0, 120). Added a TDD test in SubagentCompletionCard.test.tsx (119 ASCII + 😀 straddling the 120-unit cap): it fails on the old .slice(0, 120) — the headline ends in a lone high surrogate before the … — and passes with the fix. feat(subagents): name unlabelled runs and show the name to the parent agent #24710 rewrites that same line keeping the bug; whichever of us lands second resolves a one-line conflict.

  2. Design note (move sliceCodePoints out of CommentOverlay.tsx) — agreed it belongs in utils/, but the move rewrites an import line in ~15 files, several being edited by open PRs (feat(file-viewer): comment on a box drawn over an image #20493 on CommentOverlay, plus fix: bind every approval decide to an owner-bound target #16481/feat: serve issue radar graph tab for gitlab repos #17525/feat: let issue radar crews work gitlab repos #19820/feat: add gitlab ci failure alerts and ci runs to issue radar #19824/feat(dashboard): add dedicated terminal colors to theme packs #22674/fix(notifications): mark a cron run's note read when its chat is open #23854 on changed files), so folding it in here would balloon the diff and collide on the imports. Tracked as its own refactor in refactor(website): move sliceCodePoints out of the CommentOverlay component into utils/ #24983 and linked in the description.

Local gates green on the final tree (tsc, eslint, i18n, file-line-cap); SubagentCompletionCard.test.tsx (57) and CommentOverlay.test.ts pass.

@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 27, 2026
Twenty-two dashboard cuts used a UTF-16 .slice(0, n). When an emoji
straddled the cap, the label kept the emoji's lone high surrogate, which
renders as U+FFFD. Each site now cuts with the existing exported
sliceCodePoints from components/CommentOverlay, so the end edge moves off
a surrogate pair and every cap still holds.

Sites: selection notice quote, browser annotation label, flying quote,
issue-radar graph title and jump option, Mochi approval label, memory
restore label, collapsed draft line, widget action text, scene agent name
and tooltip, dropped theme rule id, memory carve previews, the seven
workflow run tree cuts, and the subagent completion card headline task
(pages/chat/SubagentCompletionCard.tsx:47), the last site kirodotdev#24727 lists.

The remaining design note on kirodotdev#24796 — moving sliceCodePoints out of the
CommentOverlay component into utils/ — is tracked in kirodotdev#24983, since the
move rewrites an import line in ~15 files, several edited by open PRs.

Closes kirodotdev#24727
@IngridMorstrad
IngridMorstrad force-pushed the fix/emoji-safe-label-truncation-batch branch from a477498 to c600ff7 Compare October 27, 2026 20:46
@IngridMorstrad

Copy link
Copy Markdown
Contributor Author

@github-actions (GPT 6.1 Review) — fixed in c600ff7868.

MemoryCarveCard.truncate.test.tsx openGroupWith now bounds both dependent-query waits explicitly: the findByRole('button', …) and the following findByTestId('memory-carve-mobile-results') each take { timeout: 5_000 } (the repo's convention for chained waits), with a comment naming the store-list (useMemoryStores) → counts-query chain the button depends on, and the entries-query link the rows depend on. The default 1000ms ceiling no longer gates a correct render under loaded workers. File passes; tsc and eslint clean.

@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 Oct 27, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at c600ff7.

Both items from our r129 change request are resolved. SubagentCompletionCard.tsx now cuts through sliceCodePoints (L48) with a regression test, and the helper move is tracked in #24983, whose scope covers it. Every changed site uses the existing helper, which only moves a cut back off a split surrogate pair (CommentOverlay.tsx L156-L166), so every cap still holds. CI is green.

One small item is still open: First Principles notes that the description lists website/src/pages/overview/MemoryRecordsEditor.truncate.test.tsx, but the patch adds website/src/test/MemoryRecordsEditor.truncate.test.tsx. Please correct the path in the description or acknowledge the note on the PR.

— crew-pr-reviewer (r131)

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

APPROVE at c600ff78683c0321a57464b9b4a875c6dc1aa887.

Every changed site now cuts through the existing sliceCodePoints, which only moves an end edge back off a split surrogate pair (CommentOverlay.tsx L156-L166), so each cap still holds and text without astral characters truncates exactly as before. Our r129 items are resolved: SubagentCompletionCard.tsx is fixed with a regression test, and the helper move is tracked in #24983. All checks are green and the GPT and Opus lanes have no findings.

AI findings judged non-blocking

  • First Principles — description names the wrong path for the MemoryRecordsEditor test: a description wording nit; the test ships at website/src/test/MemoryRecordsEditor.truncate.test.tsx.
  • Design — pure modules now import the CommentOverlay.tsx component file: no behaviour or build harm (CI green, no Electron or Node importer of those modules), and the move to utils/ is tracked in #24983 (themeCss.ts L25).

— crew-pr-reviewer (r132)

@iamwhatever
iamwhatever merged commit d152370 into kirodotdev:main Oct 28, 2026
133 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 28, 2026
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.

More dashboard labels can cut an emoji in half when truncated

2 participants