Skip to content

test(terminal): pin the two conditions that keep macOS period substitution out - #15393

Merged
nwparker merged 1 commit into
mainfrom
nwparker/pin-11504-space-claim
Aug 20, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/pin-11504-space-claim

Conversation

@nwparker

@nwparker nwparker commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

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:

Orca 1.4.184           h i SPACE SPACE  ->  6869 2020 0a   "hi  "   no period
plain Chromium textarea, same Electron  ->  "hi. "
native NSTextView control, same keys    ->  "hi. "

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:

  1. The forwarder claims a plain space keydown.
  2. A claimed commit empties the helper textarea, so the text system never reads the word preceding the space.

Proven causally — same configuration, blanking as the only variable, alternating runs:

no blanking  ->  "hi. "        blanked  ->  "hi  "

Why this needs pinning

Before 01bcc8dca24 the claim predicate was isAsciiPunctuationKey, commented as printable ASCII "excluding space (0x20), digits and letters". Space was never claimed, the field accumulated, and the substitution fired.

01bcc8dca24 widened 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

  • Four tests pinning both halves.
  • A comment on the predicate and on the blanking, each saying what depends on them.

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

mutant result
predicate narrowed back toward punctuation 3 of 4 fail
blanking removed 1 of 4 fails

Full terminal-pane suite: 3,672 passing.

Why not the real fix

The deliberate fix — opting Orca out of NSAutomaticPeriodSubstitutionEnabled in its own defaults domain — exists and works, but it is app-wide: AppKit offers no per-field or per-webContents scope 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.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added a happy-dom Vitest suite for terminal IME forwarding. The suite tests space and letter key claiming, committed text, helper textarea clearing after ab input, and control-chord exclusion. The suite also mocks canvas measurement and cleans up terminals and DOM state. Expanded comments document the broad single-character claiming predicate and the textarea-clearing behavior that prevents committed text accumulation and macOS automatic period substitution.

Merge Risk: ⚪ Minimal · up to 34138

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and rationale, but it omits most required template sections, including visual proof, testing checklist, AI disclosure, review, notes, and checklist. Add the required template sections and complete or mark them as not applicable, including visual proof, testing details, review, compatibility notes, checklist, and author information.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal tests and the macOS period-substitution conditions they protect.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts (1)

113-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce the explanatory comments.

Keep the #11504 rationale, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ec6bbf and 341380a.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-ime-forwarder-space-claim.test.ts
  • src/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
@nwparker
nwparker force-pushed the nwparker/pin-11504-space-claim branch from 341380a to 8fbf3cf Compare August 19, 2026 05:10
@nwparker
nwparker merged commit feaebab into main Aug 20, 2026
94 of 97 checks passed
@nwparker
nwparker deleted the nwparker/pin-11504-space-claim branch August 20, 2026 10:08
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…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
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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
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