Skip to content

Drop host-AX-publish ceiling to 60ms now that swallow bug is fixed#383

Merged
FuJacob merged 1 commit into
mainfrom
chore/lower-ax-publish-delay
May 28, 2026
Merged

Drop host-AX-publish ceiling to 60ms now that swallow bug is fixed#383
FuJacob merged 1 commit into
mainfrom
chore/lower-ax-publish-delay

Conversation

@FuJacob

@FuJacob FuJacob commented May 28, 2026

Copy link
Copy Markdown
Owner

Now that #382 makes the accept tap fail-open, the long publish wait no longer masks an input-swallow bug. Dropping the ceiling from 400ms to 60ms keeps post-divergence predictions snappy.

Greptile Summary

Reduces the AX-publish wait ceiling in pollForHostPublish from 400ms to 60ms, relying on the fail-open accept tap added in #382 to ensure keystrokes are never swallowed regardless of AX timing. With hostPublishPollIntervalMs = 30, the new ceiling allows exactly one async retry (at ~30ms wall time) before the loop falls back to generating against whatever AX state is current.

  • Ceiling reduction: hostPublishWaitCeilingMs drops 400 → 60ms; Chrome contenteditable fields on busy pages that publish AX after 30ms will now receive predictions against pre-keystroke text more often, which is explicitly accepted as a quality tradeoff for snappier predictions.
  • Poll-loop coupling: The ceiling and poll interval are now tightly coupled (60ms ceiling / 30ms interval = exactly one retry); a future increase of the poll interval to ≥ 60ms would silently eliminate all async retries — worth documenting on the constant.

Confidence Score: 4/5

Safe to merge; the one-line constant change is well-reasoned and the poll-loop fallback ensures predictions always fire even if AX never updates.

The change is minimal and intentional. The only gap is a now-stale comment on hostPublishPollIntervalMs that still cites "default 80ms" — a value that would exceed the new 60ms ceiling and eliminate all async retries if someone tried to match it. That is a documentation hazard, not a current defect.

The poll-interval comment at lines 184–187 in SuggestionCoordinator+Input.swift is the only part worth revisiting.

Important Files Changed

Filename Overview
Cotabby/App/Coordinators/SuggestionCoordinator+Input.swift Drops hostPublishWaitCeilingMs from 400ms to 60ms; with the 30ms poll interval this yields exactly one async AX retry before giving up — the poll-interval comment still references "default 80ms" which now exceeds the ceiling and would eliminate all retries if used.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Keystroke received via CGEvent tap] --> B[schedulePredictionAfterHostPublishDelay]
    B --> C[Snapshot baseline: text, elementID, selectionLocation]
    C --> D[pollForHostPublish\nelapsedMs = 0]
    D --> E[focusModel.refreshNow\nsynchronous AX read]
    E --> F{AX snapshot\nchanged?}
    F -- Yes --> G[schedulePrediction]
    F -- No --> H["nextElapsed = elapsedMs + 30ms\n(hostPublishPollIntervalMs)"]
    H --> I{"nextElapsed < 60ms?\n(hostPublishWaitCeilingMs)"}
    I -- "Yes (0+30=30 < 60)" --> J[asyncAfter 30ms]
    J --> K[pollForHostPublish\nelapsedMs = 30]
    K --> L[focusModel.refreshNow]
    L --> M{AX snapshot\nchanged?}
    M -- Yes --> G
    M -- "No: 30+30=60 >= 60\n(ceiling hit)" --> G
    I -- "No (fires immediately if\npollInterval >= ceiling)" --> G
    style G fill:#4CAF50,color:#fff
    style I fill:#FF9800,color:#fff
Loading

Comments Outside Diff (1)

  1. Cotabby/App/Coordinators/SuggestionCoordinator+Input.swift, line 184-187 (link)

    P2 The hostPublishPollIntervalMs comment says it is the "same order of magnitude as the focus poll itself (default 80ms)" — but with the ceiling now at 60ms, any poll interval at or above 60ms would cause the ceiling guard (nextElapsed < hostPublishWaitCeilingMs) to fire immediately on the first tail-call, giving zero async retries. Even using the 80ms value mentioned in the comment would silently eliminate all polling. The comment should be updated to reflect the new ceiling so future maintainers know the two constants are tightly coupled.

    Fix in Codex Fix in Claude Code

Fix All in Codex Fix All in Claude Code

Reviews (1): Last reviewed commit: "Drop host-AX-publish ceiling to 60ms now..." | Re-trigger Greptile

@FuJacob FuJacob merged commit 2ba6548 into main May 28, 2026
4 checks passed
@FuJacob FuJacob deleted the chore/lower-ax-publish-delay branch May 28, 2026 16:12
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