fix: pr-bug-scan validated finding from #4658#4741
Conversation
Gate the three unread-clear calls in onTerminalKeyDown so modifier-only/repeat/copy-chord keydowns no longer dismiss sibling-pane attention.
There was a problem hiding this comment.
ℹ️ No critical issues — minor test-coverage observation inline.
Reviewed changes — gates onTerminalKeyDown unread-clearing so that modifier-only key presses, autorepeat, and copy chords (Cmd/Ctrl+C with active selection) no longer dismiss sibling-pane attention dots. This addresses the validated finding from #4658 where typing into pane A would prematurely clear attention for pane B.
- Gate unread clearing in
onTerminalKeyDown— moves the threeclear*Unreadcalls after the escape/Ctrl-C intent checks and adds two early-return guards: one for modifier-only/repeat keydowns, one for copy chords with an active selection.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| // "user is here" signal. Modifier-only presses, autorepeat, and Cmd/Ctrl+C | ||
| // copy chords with an active selection must not dismiss attention on a | ||
| // sibling pane before the user has seen it. | ||
| if ( |
There was a problem hiding this comment.
ℹ️ The modifier-only/repeat guard and copy-chord guard added here have no test coverage. The existing test at pty-connection.test.ts:4860 (clears tab and worktree unread on real keydown) only exercises the happy path with key='a', no modifiers, repeat=false. Consider adding tests for:
- Modifier-only presses (
key='Shift',key='Alt',key='Control',key='Meta') — assert unread is not cleared - Repeat events (
key='a',repeat=true) — assert unread is not cleared - Copy chord with selection (
key='c',ctrlKey=trueormetaKey=true,hasSelection()=true) — assert unread is not cleared
Technical details
# Missing test coverage for `onTerminalKeyDown` guard conditions
## Affected sites
- `src/renderer/src/components/terminal-pane/pty-connection.ts:736-752` — new modifier-only/repeat guard and copy-chord guard
- `src/renderer/src/components/terminal-pane/pty-connection.test.ts:4860-4884` — existing happy-path test, no guard-coverage tests
## Required outcome
- Each guard condition path (modifier-only, repeat, copy-chord) should have a dedicated test asserting that `clearTerminalTabUnread`, `clearTerminalPaneUnread`, and `clearWorktreeUnread` are NOT called.
## Suggested approach
- Dispatch `keydown` events with the guard-triggering properties (e.g. `key='Shift'`, `repeat=true`, or `key='c'` + `ctrlKey=true` + mock `hasSelection()`) and assert the three clear functions were not called, mirroring the pattern of the existing test at line 4860.
Automated fix-PR from pr-bug-scan for parent #4658.
Fixer status:
FIXED_WITH_CODE_PROOFSummary: Gate the three unread-clear calls in onTerminalKeyDown so modifier-only/repeat/copy-chord keydowns no longer dismiss sibling-pane attention.
Blocked proof link:
src/renderer/src/components/terminal-pane/pty-connection.ts:719 onTerminalKeyDown unconditionally calls deps.clearTerminalTabUnread/clearTerminalPaneUnread/clearWorktreeUnread before any guardTypecheck:
skippedProof (from validator)
code_analysiscode_analysisGenerated by
pr-bug-scan(proof-machine architecture). Human approval required before merge.