Problem
AppState has 15+ optional closure properties (onDeleteSession, onCompleteSession, onAddTerminal, onLaunchClaude, etc.) wired in AppDelegate via weak captures (lines 136–221). This pattern is fragile: closures silently no-op if the captured service deallocates, there's no compile-time guarantee that all callbacks are wired, and the wiring is scattered across 80+ lines of boilerplate.
Proposed Improvement
Define a SessionActionDelegate protocol with required methods. AppDelegate (or a coordinator) conforms to it. AppState holds a single weak delegate reference instead of 15 optional closures. This gives compile-time safety and eliminates the wiring boilerplate.
Effort
Medium (2–3 hours). Mechanical transformation — define protocol, conform, replace closure calls with delegate calls.
Files Affected
Packages/CrowCore/Sources/CrowCore/AppState.swift (remove 15+ closure properties)
Sources/Crow/App/AppDelegate.swift (replace wiring with single delegate assignment)
Packages/CrowUI/Sources/CrowUI/*.swift (views call delegate methods instead of closures)
- New:
Packages/CrowCore/Sources/CrowCore/SessionActionDelegate.swift
Priority: 5/10
Problem
AppStatehas 15+ optional closure properties (onDeleteSession,onCompleteSession,onAddTerminal,onLaunchClaude, etc.) wired in AppDelegate via weak captures (lines 136–221). This pattern is fragile: closures silently no-op if the captured service deallocates, there's no compile-time guarantee that all callbacks are wired, and the wiring is scattered across 80+ lines of boilerplate.Proposed Improvement
Define a
SessionActionDelegateprotocol with required methods. AppDelegate (or a coordinator) conforms to it. AppState holds a single weak delegate reference instead of 15 optional closures. This gives compile-time safety and eliminates the wiring boilerplate.Effort
Medium (2–3 hours). Mechanical transformation — define protocol, conform, replace closure calls with delegate calls.
Files Affected
Packages/CrowCore/Sources/CrowCore/AppState.swift(remove 15+ closure properties)Sources/Crow/App/AppDelegate.swift(replace wiring with single delegate assignment)Packages/CrowUI/Sources/CrowUI/*.swift(views call delegate methods instead of closures)Packages/CrowCore/Sources/CrowCore/SessionActionDelegate.swiftPriority: 5/10