Skip to content

fix: prevent duplicate tmux panes from rapid arrow key navigation#138

Merged
bborn merged 2 commits intomainfrom
task/272-using-arrow-keys-on-task-detail-view-som
Jan 12, 2026
Merged

fix: prevent duplicate tmux panes from rapid arrow key navigation#138
bborn merged 2 commits intomainfrom
task/272-using-arrow-keys-on-task-detail-view-som

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 12, 2026

Summary

  • Fixed issue where using arrow keys quickly to navigate between tasks in detail view caused duplicate/overlapping tmux panes
  • Added taskTransitionInProgress flag to prevent concurrent task transitions

Problem

When arrow keys were pressed rapidly to change tasks, multiple task transition operations could happen simultaneously. This caused tmux pane cleanup (breakTmuxPanes()) and creation (joinTmuxPanes()) operations to interleave, resulting in duplicate or overlapping panes.

The race condition occurred because:

  1. First arrow key press triggers cleanup of current task's panes (async tmux operations)
  2. Second arrow key press (before first completes) triggers another cleanup
  3. Both pane join operations can occur while cleanup is still in progress
  4. Result: duplicate panes in inconsistent states

Solution

Added a taskTransitionInProgress boolean flag to the AppModel that:

  • Ignores arrow key presses while a transition is already in progress
  • Gets set to true when starting a task switch (on Up/Down arrow key press)
  • Gets reset to false when the new task is fully loaded (in taskLoadedMsg handler)

This ensures only one task transition occurs at a time, eliminating the race condition.

Changes

  • internal/ui/app.go: Added taskTransitionInProgress flag and guard checks in arrow key handlers

Test plan

  • Build succeeds with no compilation errors
  • Manual testing: Rapidly press arrow keys in task detail view and verify no duplicate panes appear
  • Verify normal navigation still works smoothly

🤖 Generated with Claude Code

bborn and others added 2 commits January 12, 2026 09:53
The startResumableSession function was requiring a worktree path,
which prevented resuming sessions for tasks that use the main project
directory. Now it uses getWorkdir() which falls back to the project
directory when no worktree exists.

Also improved the file-based session lookup fallback to use getWorkdir()
instead of only checking WorktreePath, ensuring compatibility with both
worktree-based and non-worktree tasks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When using arrow keys quickly to navigate between tasks in detail view,
multiple task transitions could happen simultaneously, causing tmux pane
cleanup and creation operations to interleave. This resulted in
duplicate/overlapping panes.

The fix adds a taskTransitionInProgress flag that:
- Ignores arrow key presses while a transition is in progress
- Gets set when starting a task switch (on arrow key press)
- Gets reset when the new task is fully loaded (taskLoadedMsg handler)

This ensures only one task transition occurs at a time, preventing
the race condition that caused duplicate panes.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bborn bborn merged commit 8dc921d into main Jan 12, 2026
3 checks passed
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