Repository navigation
test(terminal): pin the two conditions that keep macOS period substitution out - #15393
Conversation
📝 WalkthroughWalkthroughAdded a happy-dom Vitest suite for terminal IME forwarding. The suite tests space and letter key claiming, committed text, helper textarea clearing after Merge Risk: ⚪ Minimal · up to This PR adds tests and documentation around existing terminal input handling without changing product behavior. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts (1)
113-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce the explanatory comments.
Keep the
#11504rationale, but move detailed history and measurements to the issue or test documentation.
src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts#L113-L118: replace the six-line predicate explanation with one concise reason.src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts#L358-L361: replace the four-line clearing explanation with one concise reason.src/renderer/src/components/terminal-pane/terminal-ime-forwarder-space-claim.test.ts#L2-L20: reduce the file header to a short statement of the tested contract.Proposed concise comments
- // Space and letters must stay eligible. Claiming them is what blanks the helper textarea - // before macOS can read a preceding word, which is the only thing suppressing `#11504` - the - // system rewriting a double space into ". " and handing the period to the pty. That - // suppression is a side effect of this predicate rather than a decision, so narrowing it - // back toward punctuation would return the bug. Pinned by - // terminal-ime-forwarder-space-claim.test.ts. + // Keep plain text keys eligible to prevent macOS `#11504`. ... - // Clear the helper textarea so the committed text doesn't accumulate. Also load-bearing: - // macOS decides an automatic period substitution from the characters already in the field, - // so emptying it is what keeps `#11504` from firing. Measured - with this line removed and - // everything else held constant, `hi` + two spaces reaches the pty as `hi. `. + // Clear committed text to prevent macOS `#11504`.-/** - * Pins the two properties that keep `#11504` from firing, because neither is a decision anyone - * made and both are one refactor away from being undone. - * ... - */ +/** Verifies the key claim and textarea clearing that prevent macOS `#11504`. */As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2168c204-68c7-46f5-b6dd-7f4a8c613a2c
📒 Files selected for processing (2)
src/renderer/src/components/terminal-pane/terminal-ime-forwarder-space-claim.test.tssrc/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
…ution out macOS rewrites a double space into ". " and hands the period to the pty. Orca is not immune to that: a plain Chromium textarea in the Electron version pinned here does substitute, measured on hardware with real key events, and spellcheck="false" does not prevent it. What prevents it is that the forwarder claims a plain space keydown and then empties the helper textarea, so the text system never sees the word preceding the space. Neither half was a decision. Before 01bcc8d the claim predicate excluded space, letters and digits, the field accumulated, and the substitution fired on real hardware. That commit widened the predicate for unrelated reasons - IME commit survival and kitty encoding - and suppressed this as a side effect it never mentions. The predicate already declines on modifiers and during composition, so a later narrowing would return the bug with nothing to catch it. This does not test the substitution, which a unit environment cannot produce. It tests the two conditions measured to suppress it. Verified non-vacuous: narrowing the predicate back toward punctuation fails three of the four, and removing the blanking fails the fourth. Refs #11504
341380a to
8fbf3cf
Compare
…ution out (stablyai#15393) macOS rewrites a double space into ". " and hands the period to the pty. Orca is not immune to that: a plain Chromium textarea in the Electron version pinned here does substitute, measured on hardware with real key events, and spellcheck="false" does not prevent it. What prevents it is that the forwarder claims a plain space keydown and then empties the helper textarea, so the text system never sees the word preceding the space. Neither half was a decision. Before 01bcc8d the claim predicate excluded space, letters and digits, the field accumulated, and the substitution fired on real hardware. That commit widened the predicate for unrelated reasons - IME commit survival and kitty encoding - and suppressed this as a side effect it never mentions. The predicate already declines on modifiers and during composition, so a later narrowing would return the bug with nothing to catch it. This does not test the substitution, which a unit environment cannot produce. It tests the two conditions measured to suppress it. Verified non-vacuous: narrowing the predicate back toward punctuation fails three of the four, and removing the blanking fails the fourth. Refs stablyai#11504
…ution out (stablyai#15393) macOS rewrites a double space into ". " and hands the period to the pty. Orca is not immune to that: a plain Chromium textarea in the Electron version pinned here does substitute, measured on hardware with real key events, and spellcheck="false" does not prevent it. What prevents it is that the forwarder claims a plain space keydown and then empties the helper textarea, so the text system never sees the word preceding the space. Neither half was a decision. Before 01bcc8d the claim predicate excluded space, letters and digits, the field accumulated, and the substitution fired on real hardware. That commit widened the predicate for unrelated reasons - IME commit survival and kitty encoding - and suppressed this as a side effect it never mentions. The predicate already declines on modifiers and during composition, so a later narrowing would return the bug with nothing to catch it. This does not test the substitution, which a unit environment cannot produce. It tests the two conditions measured to suppress it. Verified non-vacuous: narrowing the predicate back toward punctuation fails three of the four, and removing the blanking fails the fourth. Refs stablyai#11504
…ution out (stablyai#15393) macOS rewrites a double space into ". " and hands the period to the pty. Orca is not immune to that: a plain Chromium textarea in the Electron version pinned here does substitute, measured on hardware with real key events, and spellcheck="false" does not prevent it. What prevents it is that the forwarder claims a plain space keydown and then empties the helper textarea, so the text system never sees the word preceding the space. Neither half was a decision. Before 6be88a6 the claim predicate excluded space, letters and digits, the field accumulated, and the substitution fired on real hardware. That commit widened the predicate for unrelated reasons - IME commit survival and kitty encoding - and suppressed this as a side effect it never mentions. The predicate already declines on modifiers and during composition, so a later narrowing would return the bug with nothing to catch it. This does not test the substitution, which a unit environment cannot produce. It tests the two conditions measured to suppress it. Verified non-vacuous: narrowing the predicate back toward punctuation fails three of the four, and removing the blanking fails the fourth. Refs stablyai#11504
Refs #11504. Tests and comments only — no behaviour change.
The situation
macOS rewrites a double space into
". "and hands the period to the pty. #11504 reported exactly that, and it reproduced on hardware at v1.4.161.It does not reproduce today. But Orca is not immune — it is protected by accident.
Measured on a real Mac with synthetic CGEvents and the pty bytes hexdumped:
So the platform substitutes, the harness is sound, and something in Orca is stopping it. Also worth recording:
spellcheck="false"does not block it — xterm's attributes were never the protection.What is actually protecting us
Two things, neither of them deliberate:
Proven causally — same configuration, blanking as the only variable, alternating runs:
Why this needs pinning
Before
01bcc8dca24the claim predicate wasisAsciiPunctuationKey, commented as printable ASCII "excluding space (0x20), digits and letters". Space was never claimed, the field accumulated, and the substitution fired.01bcc8dca24widened it to every single-character key for unrelated reasons — IME commit survival and kitty encoding. It never mentions #11504, and the blanking comment is about accumulation.The predicate already declines on ctrl/alt/meta and during composition. Narrowing it further is a natural thing for future IME work to do, and nothing today would notice that #11504 came back.
What this adds
It does not test the substitution itself — a unit environment cannot produce it. It tests the two conditions measured to suppress it.
Non-vacuous, verified
Full
terminal-panesuite: 3,672 passing.Why not the real fix
The deliberate fix — opting Orca out of
NSAutomaticPeriodSubstitutionEnabledin its own defaults domain — exists and works, but it is app-wide: AppKit offers no per-field or per-webContentsscope for this rule, and it latches at process start so it cannot be a setting. It would disable double-space→period in every Orca text field, including the issue editors and agent chat inputs.That is a real regression for prose typing, in exchange for a symptom that does not currently occur. The trade is not worth it while the accidental protection holds — but the protection should be guarded rather than left to luck, which is what this does.