Skip to content

feat(copilot): add first-class session detection, resume, model/allow-all config#851

Open
toughhou wants to merge 1 commit into
asheshgoplani:mainfrom
toughhou:feat/copilot-hook-integration
Open

feat(copilot): add first-class session detection, resume, model/allow-all config#851
toughhou wants to merge 1 commit into
asheshgoplani:mainfrom
toughhou:feat/copilot-hook-integration

Conversation

@toughhou
Copy link
Copy Markdown

@toughhou toughhou commented May 2, 2026

Summary

Adds first-class GitHub Copilot CLI integration with session detection, resume support, and model/allow-all configuration — upgrading copilot from pattern-only support to full session-aware lifecycle management.

Motivation

Currently, agent-deck's copilot support is limited to basic tmux patterns for busy/idle detection. The Copilot CLI (copilot v1.0+) supports --resume, --model, --allow-all, and writes session state to ~/.copilot/session-state/<session-id>/events.jsonl. This PR enables agent-deck to:

  1. Detect copilot sessions from disk (scanning events.jsonl for session.start events matching the working directory)
  2. Resume sessions automatically using --resume <session-id> when conversation data exists
  3. Configure model and allow-all via instance fields or ~/.agent-deck.toml config
  4. Propagate session IDs through tmux environment variables for cross-pane awareness

Architecture

Follows the same file-based async detection pattern used by Codex integration:

  • copilot_hooks.go: Core implementation — session detection via ~/.copilot/session-state/ scanning, command builder, async goroutine detector
  • Respects COPILOT_CONFIG_DIR env override for non-standard installations
  • Heuristic conversation detection (events.jsonl > 8KB indicates meaningful conversation)
  • Graceful degradation: if no session found, copilot starts fresh

Changes

New Files

  • internal/session/copilot_hooks.go — Session detection, command building, async detection
  • internal/session/copilot_session_test.go — Comprehensive tests (disk detection, event parsing, command building)
  • docs/feature-copilot/copilot-session-issues-and-improvements.md — Design document

Modified Files

  • internal/session/instance.go — Added CopilotSessionID/Model/AllowAll fields, wired into Start(), PostStartSync(), SyncSessionIDs*(), clearSessionBinding()
  • internal/session/tooloptions.go — Extended CopilotOptions with Model/AllowAll, updated ToArgs()
  • internal/session/userconfig.go — Extended CopilotSettings with DefaultModel/AllowAll (TOML)
  • internal/session/copilot_test.go — Updated existing tests for new config fields
  • internal/tmux/patterns.go — Enhanced copilot busy patterns (Thinking, Generating, Reading, Searching, Running, braille spinner) and prompt patterns

Config Example

[copilot]
default_model = "claude-sonnet-4"
allow_all = true

Testing

  • All 28 copilot-related tests pass (go test ./internal/session/ -run Copilot)
  • All tmux pattern tests pass (go test ./internal/tmux/ -run Pattern)
  • Full build passes (go build ./...)

Closes #556

…-all config

- Add copilot_hooks.go: file-based session detection via ~/.copilot/session-state/
  events.jsonl, command builder with --resume/--model/--allow-all, async detection
- Wire copilot into Instance.Start(), PostStartSync(), SyncSessionIDs*(),
  clearSessionBindingForFreshStart() in instance.go
- Extend CopilotOptions with Model/AllowAll fields and ToArgs() generation
- Extend CopilotSettings with DefaultModel/AllowAll config (TOML)
- Enhance copilot tmux patterns: busy indicators (Thinking, Generating, etc.),
  braille spinner regex, prompt pattern for idle detection
- Add comprehensive tests in copilot_session_test.go and update copilot_test.go

Closes asheshgoplani#556
SaitoJP added a commit to SaitoJP/agent-deck that referenced this pull request May 12, 2026
Merge the changes from PR asheshgoplani#851 and translate the Copilot design note to Japanese.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature req] Add support for GitHub Copilot CLI

1 participant