Skip to content

Refactor: move terminal/session lifecycle state from tabs into panes #30

@danshapiro

Description

@danshapiro

Background

PR #8 attempted this refactor but went stale (242 commits behind main). Closing it and reimplementing from scratch.

Problem

The Tab type currently carries terminal lifecycle fields (terminalId, status, mode, shell, resumeSessionId, codingCliSessionId, lastInputAt, etc.) that conceptually belong to the pane system. This creates a dual-update problem where both tab and pane state must be kept in sync, leading to bugs and complexity.

Proposed Changes

Slim the Tab interface down to {id, title, createdAt, titleSetByUser?} and move all terminal/session state into pane content nodes. Key pieces:

  • Slim Tab type: Remove ~12 fields from the Tab interface
  • Atomic tab+pane creation: createTabWithPane thunk to prevent orphaned state
  • Centralized cleanup: closeTabWithCleanup thunk for detach/kill on tab close
  • Pane title tracking: paneTitles + paneTitleSetByUser maps in panes slice, so user renames aren't clobbered by auto-titles
  • SessionPaneContent type: First-class pane content for coding CLI sessions (currently handled via tab fields)
  • buildDefaultPaneContent() helper: Extract default pane logic from TabContent into a shared utility
  • Pane activity cleanup middleware: Clean up terminal activity tracking when panes are removed/swapped
  • Update all consumers: Sidebar, TabBar, ContextMenuProvider, OverviewView, BackgroundSessions, etc. to read from pane layouts instead of tab fields
  • Persistence migration: Bump schema version, migrate cleanly

Reference

The closed PR #8 contains a complete (if stale) implementation that can serve as a reference for the reimplementation.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions