cotabby icon indicating copy to clipboard operation
cotabby copied to clipboard

Key-event prefix tracker as fallback when AX prefix is unavailable

Open Jam-Cai opened this issue 7 months ago • 1 comments

Some apps (Electron/Chromium, games, certain web text surfaces) don't expose AX text values reliably. FocusSnapshotResolver walks AX for prefix text; when the walk yields nothing usable, we lose the ability to suggest. Maintain a per-field prefix buffer driven by the existing CGEventTap keyDown stream, used as a fallback when the AX prefix is empty.

Acceptance

  • [ ] When AX prefix is unavailable for a focused editable field, key-event-reconstructed prefix is used as the request's prefixText.
  • [ ] Buffer clears on: focus change, arrow-key navigation, selection change, paste, undo.
  • [ ] Buffer never leaks across focused fields.
  • [ ] Config flag to disable the fallback entirely.
  • [ ] Unit tests cover keyDown handling, backspace, enter, focus reset.

Parent: #16

Jam-Cai avatar Apr 22 '26 17:04 Jam-Cai

@Jam-Cai I talked to GPT about this and I'm not sure if this would be something we should implement.

If the AXI prefix is unavalaible because teh AX tree yields nothing, then we would probably not be able to derive caret position anyways. So if we did fallback to CGEvent key stream, then it's not usable since we don't know where to place the caret.

In regards to the child ticket for Chromium AX wake, think this is something we can still add as it would help in the cases to wake up tree. Closing this ticket for now, LMK what you think

FuJacob avatar Apr 28 '26 17:04 FuJacob