Skip to content

Keep composer typing fast in long drafts with quotes - #1460

Merged
dylanplayer merged 1 commit into
mainfrom
codevisor/tiramisu-composer-perf
Nov 23, 2026
Merged

dylanplayer merged 1 commit into
mainfrom
codevisor/tiramisu-composer-perf

Conversation

@dylanplayer

Copy link
Copy Markdown
Member

Typing in the composer rebuilt the whole draft on every keystroke to find quote badges, and macOS laid out the whole draft to measure the composer's height.

What changes

  • QuotedTextSync (CodevisorUI), shared by macOS and iOS: it watches the text storage, follows badges through the edited range, and caches the draft. The per-platform full rescans are gone.
  • The height and caret bookkeeping compare a revision number instead of the whole text, and caret changes no longer trigger SwiftUI updates.
  • macOS measures the composer's height by laying out only up to its max height.
  • TranscriptQuotedPrompt gets fast paths: placeholder counting with memchr, and no work when there are no quotes.
  • Several quotes added at once are one undo step on macOS too, matching iOS.

Measured (median ms per keystroke, Debug build)

Draft macOS before → after iOS before → after
10 KB 8.8 → 0.9 4.1 → 2.2
100 KB 67 → 1.2 18 → 2.6
100 KB + 3 badges 70 → 1.3 19 → 3.1

Verified

  • Tophat on macOS and the iOS simulator: grow, scroll, shrink, 200-line paste, Add to Chat, badge backspace/undo, send, prompt history, slash palette.
  • Full Swift suite passes, including new QuotedTextSyncTests.

🤖 Generated with Claude Code

Typing re-read and rebuilt the whole draft on every keystroke to find
quote badges, and macOS laid out the entire draft to measure the
composer's height. A shared tracker on the text storage now follows
badges through each edit, so a keystroke costs about the same whatever
the draft's length, and the height measurement lays out only what fits.
Typing in a 100 KB draft drops from about 70 ms to about 1 ms per
keystroke on macOS and from about 20 ms to about 3 ms on iOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dylanplayer
dylanplayer merged commit a097a42 into main Nov 23, 2026
@dylanplayer
dylanplayer deleted the codevisor/tiramisu-composer-perf branch November 23, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant