-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Background
The Copilot SDK includes session persistence capabilities that allow SDK applications to list and reconnect to existing Copilot sessions. Recent SDK updates have enhanced this with:
- Session context tracking (v0.1.24) -
SessionContextwith working directory, git root, repository, and branch info - Session filtering (v0.1.24) -
listSessions()can filter by context fields in PR #427 by Jeremy Moseley - Improved session management - Better object disposal and lifecycle handling in PR #481 by Steve Sanderson
These capabilities enable applications to reconnect to orphaned sessions after crashes or interruptions.
Related SDK commits:
- Expose session context, add filtering, and context_changed event
- Fix ObjectDisposedException when disposing session after client.StopAsync()
Proposal
Implement session persistence and recovery in Planeteer to allow resuming interrupted executions:
- Session ID tracking: Store Copilot session IDs in the persisted plan when execution starts
- Graceful shutdown: On normal exit or Ctrl+C, properly dispose sessions and mark tasks as interrupted
- Recovery on restart: When loading a plan with incomplete tasks, detect orphaned sessions using
listSessions()with repository context filtering - Resume option: Offer users the choice to resume from orphaned sessions or start fresh execution
- Session cleanup: Provide a way to dispose orphaned sessions that are no longer needed
Implementation points:
- Extend
Taskmodel with optionalsessionId?: stringfield - Save plan JSON after each task completion (incremental persistence)
- On load, check for tasks with
status: 'running'and associated session IDs - Use
listSessions({ filter: { repository, branch } })to find orphaned sessions - Add "Resume" option in execute screen if orphaned sessions are detected
Benefit
Session persistence makes Planeteer more robust and production-ready:
- Crash recovery: Users can resume work after unexpected crashes, network issues, or terminal closures
- Long-running executions: For plans with many tasks, users can stop and resume execution across multiple sessions
- Resource management: Prevents accumulation of orphaned Copilot sessions consuming resources
- Professional UX: Matches user expectations from CI/CD and build tools that support resumable operations
- Debugging: Users can inspect the state of failed executions and retry specific tasks
Acceptance Criteria
- Add
sessionId?: stringfield toTaskinterface insrc/models/plan.ts - Update
src/services/executor.tsto store session IDs when creating agent sessions - Implement incremental plan persistence - save plan JSON after each task completes or fails
- On plan load, detect tasks with
status: 'running'and check if their sessions still exist usinglistSessions() - Display orphaned sessions in execute screen with options: "Resume", "Start Fresh", "Clean Up"
- Implement graceful shutdown handler (SIGINT/Ctrl+C) to dispose active sessions and mark tasks as interrupted
- Add session cleanup utility to dispose orphaned sessions by repository context
- Update SDK dependency to
^0.1.24or later to ensure session context filtering is available - Add unit tests for session recovery logic
- Document session persistence behavior in README
AI generated by Weekly Enhancement Suggestions
Reactions are currently unavailable