Skip to content

Harden typing path against character-eat races and AX lag - #1

Merged
sudosebastian merged 1 commit into
mainfrom
cursor/typing-eat-lag-hardening-47af
Jul 24, 2026
Merged

Harden typing path against character-eat races and AX lag#1
sudosebastian merged 1 commit into
mainfrom
cursor/typing-eat-lag-hardening-47af

Conversation

@sudosebastian

@sudosebastian sudosebastian commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Hardens residual AX-lag races that can intermittently eat characters or batch keystrokes: stop stale host-publish generation, refresh before destructive replace/accept, replay Tab when a queued post-exhaustion accept fails, keep the typed-match insertion sentinel in sync, and cut stacked MainActor AX walks on the per-keystroke path.

Validation

Could not run xcodebuild in this Linux cloud environment (no Xcode toolchain). Added/extended unit tests covering:

  • host-publish ceiling miss stands down + late publish schedules + snapshot reuse
  • failed queued post-exhaustion accept replays Tab
  • typed-match advances pendingInsertionConsumedCount
  • automatic typo fix aborts when typeahead diverges before replace

Please run on macOS:

xcodebuild -project Cotabby.xcodeproj -scheme Cotabby -destination 'platform=macOS' build-for-testing \
  -derivedDataPath build/DerivedData

Targeted: SuggestionCoordinatorInputTests, SuggestionCoordinatorAcceptanceTests, SuggestionCoordinatorPredictionTests, SuggestionStateHelperTests.

Linked issues

Refs intermittent character-eat / typing lag reports (reproduction unclear; residual races after FuJacob#376/FuJacob#381/FuJacob#382/FuJacob#668).

Risk / rollout notes

  • Host-publish ceiling miss no longer generates immediately; suggestions may wait for a later AX publish (or the next keystroke). This trades a rare “ignored character” ghost for slightly later suggestions on silent hosts.
  • Accept path now forces refreshNow() inside the consuming tap — correct but adds one AX walk per Tab.
  • Post-exhaustion fail-open replays synthetic Tab to the host; may move focus when regen/accept fails (preferred over silently eating Tab).
Open in Web Open in Cursor 

Stop generating on host-publish ceiling misses (arm late-publish instead),
refresh before destructive replace/accept, replay Tab when a queued
post-exhaustion accept fails, keep the pending-insertion sentinel in sync
with typed-match, reuse fresh AX snapshots during host-publish polls, and
cache per-token spellcheck verdicts.

Co-authored-by: Sebastian <sudosebastian@users.noreply.github.com>
@sudosebastian
sudosebastian merged commit 9bbbdef into main Jul 24, 2026
sudosebastian added a commit that referenced this pull request Jul 24, 2026
…trieval (#5)

* fix(runtime): repair KV trim defer and share prompt budget override

Swift forbids transferring control out of defer, so replace guard/return
with if when finishing a generate. Widen llamaPromptTokenBudgetOverrideIfNeeded
so Input can apply the same shrink on field-entry prewarm.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: bump marketing version to 1.0.1

Keep project.yml and the generated pbxproj in sync so the next XcodeGen
run does not revert the display version.

Co-authored-by: Cursor <cursoragent@cursor.com>

* perf(runtime): skip doomed KV reuse at load and cut first-token stream delay

Catalog hybrid/SWA models now advertise rejectsPartialKVTrims so request #1
already uses the compact prompt budget and skips useless prewarm/trim work.
Deliver the first streamed partial immediately, and accumulate decode text
by appending pieces instead of rebuilding from bytes each token.

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat(context): add writing memory, ambient screen index, and retrieval hooks

Introduce on-device writing-memory and multi-display OCR index models,
settings toggles, fast/accurate OCR levels, and prompt glossary wiring so
retrieved rare terms and screen context can condition completions.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore(context): finish retrieval wiring and layout docs

Keep SOURCE_LAYOUT and prompt renderer tests aligned with the writing-memory
glossary and ambient retrieval surface.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants