[PR #6617] fix: improve permission dialog responsiveness and keyboard handling #12004

Closed
opened 2026-02-16 18:16:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6617

State: closed
Merged: No


Summary

Fixes the issue where the input box becomes unresponsive when the permission dialog appears during heavy workloads.

  • Add ready guard to prevent keyboard event processing before component is fully mounted
  • Blur focused elements on mount to prevent keyboard conflicts with the prompt textarea
  • Use setTimeout instead of requestAnimationFrame for more reliable diff rendering deferral

Root Cause

The issue was a race condition where:

  1. The permission prompt's useKeyboard handler activated immediately while other components were still transitioning
  2. Multiple keyboard handlers competed for events during the transition
  3. requestAnimationFrame only deferred one frame, which wasn't enough for complex diffs

Changes

permission.tsx:

  • Added ready signal that only becomes true after 50ms delay, ensuring keyboard handling waits for component stabilization
  • Added explicit blur of any focused element on mount to prevent conflicts
  • Changed diff rendering deferral from requestAnimationFrame to setTimeout(fn, 16) for more reliable UI stabilization

Related Issues

  • Fixes #6616 - UI becomes unresponsive when tool permission dialog appears
  • Related to #5820 - Autocomplete dropdown conflicts with permission dialog
  • Related to #3846 - No response to user input
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6617 **State:** closed **Merged:** No --- ## Summary Fixes the issue where the input box becomes unresponsive when the permission dialog appears during heavy workloads. - Add ready guard to prevent keyboard event processing before component is fully mounted - Blur focused elements on mount to prevent keyboard conflicts with the prompt textarea - Use `setTimeout` instead of `requestAnimationFrame` for more reliable diff rendering deferral ## Root Cause The issue was a race condition where: 1. The permission prompt's `useKeyboard` handler activated immediately while other components were still transitioning 2. Multiple keyboard handlers competed for events during the transition 3. `requestAnimationFrame` only deferred one frame, which wasn't enough for complex diffs ## Changes **permission.tsx:** - Added `ready` signal that only becomes true after 50ms delay, ensuring keyboard handling waits for component stabilization - Added explicit blur of any focused element on mount to prevent conflicts - Changed diff rendering deferral from `requestAnimationFrame` to `setTimeout(fn, 16)` for more reliable UI stabilization ## Related Issues - Fixes #6616 - UI becomes unresponsive when tool permission dialog appears - Related to #5820 - Autocomplete dropdown conflicts with permission dialog - Related to #3846 - No response to user input
yindo added the pull-request label 2026-02-16 18:16:56 -05:00
yindo closed this issue 2026-02-16 18:16:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12004