Skip to content

fix(desktop): prevent terminal rerender when archiving task#60

Merged
oxwen11 merged 1 commit intomainfrom
fix-terminal-render
Feb 3, 2026
Merged

fix(desktop): prevent terminal rerender when archiving task#60
oxwen11 merged 1 commit intomainfrom
fix-terminal-render

Conversation

@iamdin
Copy link
Collaborator

@iamdin iamdin commented Feb 2, 2026

Problem

When archiving a task, other terminals were experiencing rendering issues due to unnecessary component rerenders and disposal.

Root Cause

  1. Only the currently selected worktree was being removed from openedWorktreeIds, leaving stale IDs for other worktrees of the archived task
  2. invalidateQueries(workspace.key()) triggered a refetch, causing worktreesByRepository to update and openedWorktrees array to be recalculated, leading to TerminalPanel unmounting and remounting

Solution

  1. Clean up all worktrees of the archived task from both openedWorktreeIds and activeTerminalId state
  2. Use optimistic cache update instead of invalidating workspace query to avoid triggering refetch and preventing unnecessary rerenders
  3. Add clearActiveTerminalId method to terminal slice for proper state cleanup

Changes

  • apps/desktop/src/renderer/src/App.tsx: Updated archiveTaskMutation to clean up all archived task worktrees and use optimistic update
  • apps/desktop/src/renderer/src/stores/slices/terminal-slice.ts: Added clearActiveTerminalId method

This ensures terminal instances remain stable when archiving tasks, preventing the disposal and recreation that was causing rendering issues.

- Clean up all worktrees belonging to archived task, not just selected one
- Use optimistic cache update to avoid workspace query refetch
- Add clearActiveTerminalId to properly clean terminal state
- Prevents unnecessary terminal disposal and recreation

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@oxwen11 oxwen11 merged commit 2a9acd2 into main Feb 3, 2026
1 check 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.

2 participants