fix(desktop): dedupe optimistic user turns for all wire references, not only images - #75733
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for generalizing the reconciliation rule through the shared wire-reference grammar. The premise is present on current main: apps/desktop/src/app/session/hooks/use-session-actions/utils.ts:406, :418, and :487 normalize only @image: lines, while apps/desktop/src/lib/chat-runtime.ts:229-239 preserves non-image attachment references such as @file: on optimistic turns.
Problems
apps/desktop/src/app/session/hooks/use-session-actions/utils.ts:2fails the required desktop lint gate:perfectionist/sort-importsrequires@/components/assistant-ui/reference-kindsbefore@/hermes. This is the sole lint error reported by the PR CI run.
Suggested changes
- Sort that added import, then rerun
apps/desktoplint. The reconciliation implementation updates all three current image-only comparison sites, and the added tests cover the file case plus the shared wire-kind set.
Automated hermes-sweeper review.
| @@ -1,7 +1,8 @@ | |||
| import { getSession } from '@/hermes' | |||
| import { textWithoutReferenceLines } from '@/components/assistant-ui/reference-kinds' | |||
There was a problem hiding this comment.
This import must sort before @/hermes; PR CI fails apps/desktop / check:lint with perfectionist/sort-imports on this line.
There was a problem hiding this comment.
Fixed in b19ff09: reference-kinds now sorts before @/hermes. check:lint green locally; focused 54/54 and full UI 3182/3182 rerun green on the new head. Thanks for the catch.
|
Salvaged as #77653 with your authorship preserved on all three commits. The bug is real on today's main — the optimistic dedupe strips only @image: lines, so any other reference kind duplicates the user turn (reverting your fix fails 9/54 of your tests, which is exactly the behavioral proof we want). 54/54 + a 298-test sweep green. Thank you! Closing in favor of #77653. |
|
Thanks for the salvage and for re-deriving it on |
What changed
Generalize optimistic versus authoritative user-turn reconciliation from image-only normalization to the centralized wire-reference vocabulary in
reference-kinds.ts.The new
textWithoutReferenceLineshelper removes complete reference-only lines before the existing equality checks. It uses the shared vocabulary for all 8 wire kinds instead of adding a hardcoded@file:path.This fixes the case where an optimistic message stores a reference in
attachmentRefswhile authoritative history inlines the same directive in the body.Fixes #75731
How to test
Install workspace dependencies from the repository root with an engines-compatible npm. The local at-HEAD run used npm 12.0.1:
Run the focused suite at-HEAD:
Result at-HEAD: 54 of 54 tests passed.
Run the full desktop UI gate at-HEAD:
Result at-HEAD: 3182 of 3182 tests passed across 360 files.
The Python wrapper was also run. It reported 56 pre-existing failures across 27 files. This change touches zero Python files, so the Python tree at-HEAD is identical to at-BASE for this range.
Manual reproduction on macOS 26.5.2:
The manual check used the clean production-code commit immediately below at-HEAD; at-HEAD adds tests only. It showed one file prompt bubble after hydration. The file chip moved from below the optimistic bubble to inside the authoritative bubble, confirming that both representations were exercised. An image attachment spot-check added exactly one additional user bubble and remained one bubble after authoritative reload.
Platforms tested
Security impact
None. This changes comparison normalization for renderer message text only. It adds no shell execution, filesystem access or path handling, secret handling, network access, or trust-boundary change.
Reconciliation tradeoff
This keeps the existing visible-text equality tradeoff accepted for images in
d0f5ef704. Two distinct adjacent sends with identical visible text but different references can compare equal after reference-only lines are removed. This change makes that existing rule uniform across the centralized wire vocabulary rather than introducing a second mechanism.Reference identity hardening would change reconciliation semantics and should be evaluated separately with turn identity or ordering signals.