Skip to content

Extract RPC command handlers from AppDelegate #138

@dhilgaertner

Description

@dhilgaertner

Problem

AppDelegate.swift (941 LOC) defines ~20 RPC command handlers as inline closures within startSocketServer() (lines 387–941). Each handler contains parameter validation, state mutation, store persistence, and response construction — all nested inside a dictionary literal. This makes AppDelegate the single hardest file to navigate and test.

Proposed Improvement

Extract each handler (or group of related handlers) into a dedicated RPCHandlers/ directory with focused structs/functions. The handlers for sessions, worktrees, terminals, links, and hooks would each get their own file.

Effort

Medium (2–3 hours). The handlers are already self-contained closures — extraction is mostly mechanical cut-and-paste with parameter threading.

Files Affected

  • Sources/Crow/App/AppDelegate.swift (shrinks by ~550 LOC)
  • New: Sources/Crow/App/RPCHandlers/SessionHandlers.swift
  • New: Sources/Crow/App/RPCHandlers/TerminalHandlers.swift
  • New: Sources/Crow/App/RPCHandlers/WorktreeHandlers.swift
  • New: Sources/Crow/App/RPCHandlers/LinkHandlers.swift
  • New: Sources/Crow/App/RPCHandlers/HookHandlers.swift

Priority: 1/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