Skip to content

Fix timer lifecycle and terminal readiness cleanup #146

@dhilgaertner

Description

@dhilgaertner

Problem

Two correctness issues:

  1. Timer leak: IssueTracker.timer is invalidated in stop() but there's no deinit that calls stop(). If the IssueTracker is deallocated without explicit stop(), the timer leaks (weak self prevents crashes but the timer keeps firing).

  2. Terminal readiness cleanup: When a session is deleted (SessionService.deleteSession), appState.terminalReadiness entries for that session's terminals are not cleaned up, leading to stale entries accumulating over time.

  3. Hard-coded 5s shell readiness delay in TerminalManager.surfaceDidCreate() — a TODO in the code documents this should use actual readiness detection.

Proposed Improvement

  1. Add deinit to IssueTracker that calls stop()
  2. Clean up terminalReadiness and autoLaunchTerminals entries in deleteSession()
  3. (Lower priority) Replace 5s delay with a probe-based readiness check

Effort

Low (30 min for items 1–2; item 3 is a separate medium effort).

Files Affected

  • Sources/Crow/App/IssueTracker.swift (add deinit)
  • Sources/Crow/App/SessionService.swift (cleanup in deleteSession)
  • Packages/CrowTerminal/Sources/CrowTerminal/TerminalManager.swift (readiness probe — future)

Priority: 9/10

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrefactorCode refactoring and cleanup

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions