Skip to content

fix: persist agent pane type to prevent config loss on rebind#51

Closed
DmitryBMsk wants to merge 2 commits intostandardagents:mainfrom
DmitryBMsk:fix/persist-agent-pane-type
Closed

fix: persist agent pane type to prevent config loss on rebind#51
DmitryBMsk wants to merge 2 commits intostandardagents:mainfrom
DmitryBMsk:fix/persist-agent-pane-type

Conversation

@DmitryBMsk
Copy link
Copy Markdown

Summary

Agent panes created via createPane() were missing the explicit type: 'worktree' field in the persisted config. When tmux pane IDs became stale (e.g., after session restart or pane rebinding failure), these typeless panes could be misclassified during the rebindAndFilterPanes() cycle and silently dropped from dmux.config.json.

Root cause: createPane() builds the DmuxPane object without setting type, even though the type definition defaults to 'worktree' for backward compatibility. The filtering logic in usePaneSync.ts checks pane.type === 'shell' to decide whether to remove stale panes, but legacy agent panes with type: undefined fall through ambiguously.

Changes

  • src/utils/paneCreation.ts — Set type: 'worktree' explicitly when creating new agent panes
  • src/hooks/usePaneLoading.ts — Add migration in loadPanesFromFile() to backfill type for legacy panes based on worktreePath/agent presence
  • src/hooks/usePaneSync.ts — Harden rebindAndFilterPanes() shell-pane detection to also handle legacy panes without explicit type field

Test plan

  • Existing test suite passes (4 pre-existing failures on main unrelated to this change)
  • TypeScript type check passes (tsc --noEmit)
  • Create agent pane → verify type: 'worktree' appears in dmux.config.json
  • Restart dmux session → verify agent panes are preserved in config
  • Kill and recreate tmux pane → verify agent pane rebinds correctly

Agent panes created via createPane() were missing the explicit
`type: 'worktree'` field. When tmux pane IDs became stale (session
restart, pane rebinding failure), these typeless panes could be
misclassified or silently dropped from the config.

Changes:
- Set `type: 'worktree'` explicitly in createPane() for all new panes
- Add migration in loadPanesFromFile() to backfill type for legacy
  panes based on worktreePath/agent presence
- Harden rebindAndFilterPanes() shell-pane detection to also handle
  legacy panes without explicit type field
- Migration logic now uses only worktreePath (not agent) to determine
  worktree type — conflict-resolution panes have agent but no
  worktreePath and must be classified as shell panes
- Add explicit type: 'worktree' to attachAgent and reopenWorktree
  pane creation paths for complete coverage
- Align isShellPane fallback detection in usePaneSync with same logic
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.

2 participants