Skip to content

Split SessionService into focused services #141

@dhilgaertner

Description

@dhilgaertner

Problem

SessionService.swift (936 LOC) handles: state hydration from JSON store, backward-compatibility migrations, session CRUD, terminal lifecycle (add/close/launch Claude), worktree management, orphaned worktree detection, VS Code integration, and global terminals. The class has 20+ public methods with no clear grouping.

Proposed Improvement

Split into:

  1. SessionService — CRUD operations + state hydration (~300 LOC)
  2. TerminalService — terminal lifecycle, readiness tracking, Claude launching (~300 LOC)
  3. WorktreeService — worktree detection, orphan recovery (~200 LOC)

Effort

Medium-High (3–4 hours). Methods have dependencies on appState and store that need careful threading.

Files Affected

  • Sources/Crow/App/SessionService.swift (shrinks from 936 to ~300 LOC)
  • New: Sources/Crow/App/TerminalService.swift
  • New: Sources/Crow/App/WorktreeService.swift

Priority: 4/10

Metadata

Metadata

Assignees

Labels

refactorCode refactoring and cleanup

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions