Prevent intermittent TUI input stalls from chord pending state, opencode grabKeys leakage, and watcher refresh churn#930
Conversation
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
|
@copilot Look for other potential causes, I don't think this is the root cause of this specific problem. Leave this fix in place, however. |
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
I investigated additional causes and kept the prior chord timeout fix in place. I found another plausible freeze path: the opencode textarea can keep |
|
@copilot I still don't think that's the problem, though you should keep that fix too. This issue happens sometimes with no interaction from the user. Are there any periodic processes that run automatically in the TUI that might cause this? |
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Yes—there is an automatic background process in the TUI: a filesystem watcher ( |
- Add Risk and Effort rows to MetadataPaneComponent (with '—' placeholder when empty) - Always show Risk/Effort in CLI concise/normal/full/tree formats (with '—' placeholder) - Update tests: row count 9→11, add risk/effort rendering assertions - Add new tests for placeholder and value rendering in TUI and CLI helpers - Update CLI.md and TUI.md docs to mention Risk/Effort always visible Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
…plicates; add test
…plicate key events; add test
…and prefer blessed APIs for grabKeys cleanup
…atSync, ignore transient stat failures (fixes flaky tui integration test)
The TUI could intermittently ignore keyboard input after chord activity (notably
Ctrl-Wsequences), then recover later. This PR now addresses three plausible freeze paths that can suppress keyboard handling while preserving existing key mappings and UX.Root cause 1 addressed: duplicate event dedupe left pending chord state without expiry
src/tui/chords.ts, the duplicate-key path (lastIsSameAsNew) now re-schedules pending timeout instead of returning with a cleared timer.screen.on('keypress')+screen.key(...)coexistence).Root cause 2 addressed: opencode textarea could leave
screen.grabKeysengaged after focus transitionssrc/tui/controller.ts, added best-effort cleanup when leaving opencode textarea contexts:cancel()safely,screen.grabKeys,Ctrl-Wpane switches and opencode close/escape flows) so screen-level key handlers remain responsive.Root cause 3 addressed: background directory watch events could trigger refresh churn without user input
fs.watch-based database refresh insrc/tui/controller.tsnow gates filename-less watch events using JSONL file mtime.filenameis missing, refresh is scheduled only when the data file mtime actually changes, reducing spurious refresh storms from unrelated directory activity.Regression coverage for intermittent freeze patterns
test/tui-chords.test.ts: duplicateCtrl-Wdelivery no longer leaves chord pending state stuck after timeout.test/tui-integration.test.ts: verifiesscreen.grabKeysis released when switching focus from opencode input viaCtrl-Wthenk.test/tui-integration.test.ts: verifies filename-less watch events are ignored when data mtime is unchanged, still refresh when mtime changes, and safely no-op on stat failures.Original prompt
This section details on the original issue you should resolve
<issue_title>TUI unresponsive to keyboard input</issue_title>
<issue_description>
Problem statement
Intermittent TUI freeze: keyboard input is ignored for ~30–60s and then recovers, preventing interactive use. The behaviour is sporadic with no reliable reproduction steps yet.
Users
Example user stories
Success criteria
Constraints
Existing state
Desired change
Related work
Potentially related docs
Potentially related work items
Requested information (to complete triage)
Please provide the following when available (these will directly enable the next triage steps):
npm run tuior./bin/opencode tui).Immediate triage commands (copy/paste for WSL)
TUI_CHORD_DEBUG=1 npm run tui # or your TUI start command
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.