Skip to content

Fixed mode switching becoming unreliable while Claude Code is actively working - #149

Merged
oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/mode-switch-instability
Jun 1, 2026
Merged

oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/mode-switch-instability

Conversation

@oleg68

@oleg68 oleg68 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed Shift+Tab mode switching (e.g. Auto → Plan) failing when Claude Code is actively generating output
  • Root cause: multiple Shift+Tab keystrokes accumulated in CC's input buffer and were processed all at once, causing the target mode (PLAN) to flash for ~0 ms before being overridden by the next queued tab
  • Fix: replaced fixed-interval polling with a "wait for concrete mode change" approach — the next Shift+Tab is only sent after the current one's effect is observed on screen (or after a 1500 ms timeout)

Test plan

  • Start a long-running Claude Code prompt (e.g. "write a large file")
  • While Claude is actively working (spinner visible), switch the mode selector from Auto to Plan
  • Verify the selector settles on Plan and the terminal footer shows ⏸ plan mode on
  • Repeat for other transitions: Default→Plan, Plan→Auto, Auto→Default
  • Verify mode switching also works correctly when Claude is idle (READY state)

🤖 Generated with Claude Code

…y working

The edit-mode selector (Shift+Tab cycling) failed to reach the target mode
when Claude Code was generating output. Root cause: the plugin was sending
multiple Shift+Tab keystrokes too quickly, causing them to accumulate in
CC's input buffer. CC then processed them all at once, flying past the
target mode with the intermediate PLAN indicator visible for ~0 ms.

Fix: replaced the fixed-interval polling loop in trySendShiftTabsUntilMode
with a "wait for concrete mode change" approach. Each Shift+Tab is now sent
only after observing a concrete (non-empty) mode change caused by the
previous tab, or after a 1500 ms timeout. This prevents accumulation: at
most one tab is in the buffer at any time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@oleg68
oleg68 merged commit 30b00db into nbplugins:main Jun 1, 2026
3 checks passed
@oleg68
oleg68 deleted the bugfix/mode-switch-instability branch June 1, 2026 18:59
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