Repository navigation
fix(mobile): keep terminal caret visible without focus - #10101
Conversation
📝 WalkthroughWalkthroughThe terminal WebView now configures both active and inactive xterm cursors with a visible bar style. The initialization-surface tests capture terminal constructor options, clean up registered window listeners after each test, and verify that repeated surface replacement messages create terminals with both cursor styles set to 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d3ef89a8-73bc-4f79-b6fc-812cc99b7853
📥 Commits
Reviewing files that changed from the base of the PR and between c445f26 and 2c28633662c76d8a1c887c56cf82acbf330d77b9.
📒 Files selected for processing (2)
mobile/src/terminal/terminal-webview-html.tsmobile/src/terminal/terminal-webview-init-surface.test.ts
| let registeredWindowListeners: RegisteredWindowListener[] | ||
| let terminalOptions: TerminalOptions[] | ||
| let terminals: TerminalStub[] | ||
| let writeCallbacks: Array<() => void> | ||
|
|
||
| beforeEach(() => { | ||
| animationFrames = [] | ||
| registeredWindowListeners = [] | ||
| terminalOptions = [] | ||
| terminals = [] | ||
| writeCallbacks = [] | ||
| const addWindowEventListener = window.addEventListener.bind(window) | ||
| vi.spyOn(window, 'addEventListener').mockImplementation((( | ||
| type: string, | ||
| listener: EventListenerOrEventListenerObject, | ||
| options?: boolean | AddEventListenerOptions | ||
| ) => { | ||
| registeredWindowListeners.push({ type, listener, options }) | ||
| addWindowEventListener(type, listener, options) | ||
| }) as typeof window.addEventListener) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Clean up document listeners between tests.
XTERM_HTML registers a message handler on document as well as window (Lines 1862-1864), but this harness only records and removes window listeners. Later tests that dispatch document-level messages can invoke stale IIFE handlers and leak prior terminals. Track both targets and remove both in afterEach.
Also applies to: 133-138
2c28633 to
3828a09
Compare
|
Thanks so much for this, @bbingz — keep terminal caret visible without focus. Reviewed, rebased on latest |
fix(mobile): keep terminal caret visible without focus
Summary
On the mobile terminal, the text caret disappeared because xterm is permanently "inactive" while the native keyboard input owns focus; this restores a visible caret.
ELI5
When typing in the phone terminal, the little blinking cursor was invisible, so you couldn't tell where your text would go. This makes the cursor show up again.
Root cause & fix
On mobile, the native
TextInputowns keyboard focus, so xterm is always in its "inactive" state. WithcursorInactiveStyle: 'none', the caret was hidden in that state — permanently, on mobile. The fix changescursorInactiveStylefrom'none'to'bar'interminal-webview-html.ts, keeping the caret visible while xterm still honors application-driven cursor hiding (DECTCEM), so full-screen TUIs that intentionally hide the cursor are unaffected.Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
mobile/src/terminal/terminal-webview-html.ts(fix) andmobile/src/terminal/terminal-webview-init-surface.test.ts(test). Clean rebase ontoorigin/main.1 passedtest file,2 passedtests.keeps xterm's inactive cursor visible across replacement surfacescovers all 3 init surfaces (desktop, phone-resize, phone-scrollback).origin/main(keeping the test) fails, proving the test captures the bug:oxlint src/terminal/terminal-webview-html.tsexits 0.Trade-offs
None — pure fix.
Regression risk
Zero-regression: only the mobile WebView
cursorInactiveStylevalue changes, affecting caret style solely in the inactive state. Application-driven cursor hiding (DECTCEM) is independent and still honored, so TUIs that hide the cursor render identically. Non-affected paths are byte-identical, and the passing test proves the intended behavior across all three replacement surfaces. This is mobile-only; no Electron/desktop path changes.Credit to @bbingz for the original fix. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.