[DNM] Add CCA (Copilot Coding Agent) session discovery, connection, and delegate support#106
[DNM] Add CCA (Copilot Coding Agent) session discovery, connection, and delegate support#106
Conversation
|
@copilot does this let you interact locally with the session? Can you use copilot cli against these sessions? Or would the idea be to summarize the session to a new copilot cli session? |
Yes, when you click "Connect" on a CCA session, it calls the SDK's The flow is: So to answer directly: yes, you can use the Copilot CLI against these sessions. It's not a summary — it's a live connection to the same session that's running in GitHub Actions. |
|
@copilot what if I want to take over the session locally? Like, start using local copilot cli then switch it back to remote |
When you click Connect, The "switch back to remote" part isn't something this PR handles though. Once resumed locally, the session continues through the local CLI. The SDK doesn't currently expose a "detach and return to cloud execution" API. That would need something like a A possible future approach: close the local session (which preserves history in |
|
@copilot what about the "delegate" feature of copilot cli? Is there a way to tie in with that |
Yes — the SDK's This PR doesn't currently use it, but it could be wired up as a "Delegate to CCA" action in PolyPilot. The integration would look like: await state.Session.SendAsync(new MessageOptions
{
Prompt = prompt,
Mode = "delegate" // hands off to cloud CCA
});This would also solve the earlier question about "switching back to remote" — you'd resume a CCA session locally, work on it, then use delegate mode to hand a task back to the cloud agent. That's a natural follow-up to this PR. |
|
@copilot can you delegate back to the same pr? Have that agent start again? |
Yes — because CCA sessions carry their repository and branch context (visible in The flow would be: discover CCA session on This is how the CLI's |
|
But would it create a new pr or use same one? |
1 similar comment
|
But would it create a new pr or use same one? |
It would use the same PR. When you resume a CCA session, the session retains its original context — repo, branch, and PR association. The delegate mode sends a prompt within that existing session, so the cloud agent continues working on the same branch and pushes commits to the same PR. The CCA doesn't create a new PR unless it's starting from scratch on a default branch. Since we're resuming an existing session that was already tied to a specific branch/PR (e.g., |
|
@copilot that sounds great! Can you make sure this pr has all this behavior? |
Added delegate-to-CCA support in d0585d0. The PR now includes:
The flow for resuming + delegating back: discover CCA session → Connect → interact locally → |
- Add CcaRunService: fetches CCA workflow runs via gh API with 60s cache - Add CcaRun model for GitHub Actions CCA workflow runs - Show CCA runs nested under repo groups in sidebar (lazy-loaded on expand) - Remove standalone global CCA Sessions section - Add CSS styles for CCA run items in sidebar
|
@copilot can you debug the code that pulls the cca sessions by repository? I pushed up changes so you will need to update your understanding of the code I only want sessions to show up related to the coding agent not the agent that comments that way I can resume those sessions locally. You should be able to test this workflow yourself |
…nse runs Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Fixed in 4adf76b. The CCA runs are now filtered to only show coding agent sessions. I analyzed the GitHub Actions API data for this repo and found two types of runs by the Copilot bot:
Changes:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot try again, the fire wall should be lifted |
Verified — the API is accessible now. Tested the full query against
The 5 coding agent runs found:
All 257 tests still passing. |
|
Will i definitely be able to start those sessions and work on them locally and then delegate back to color |
|
Yes, the full flow is implemented in this PR:
The relevant code paths:
|
…crash - Fetch PRs in parallel via gh pr list, join with runs by branch name - Show PR badges (#123), PR titles, and merged/closed state - Add clickable PR and Logs action links on each CCA run item - Dim merged/closed PRs at 40% opacity with 🟣/⚫ icons - Add manual refresh button (↻) in CCA Runs header - Fix ToDictionary crash on duplicate branch names (use TryAdd) - Add IsPrCompleted, ClickUrl properties and tests (263 total)
When plan mode is active and the agent sends intent/plan text, a collapsible "📋 Plan" block now appears in the chat messages area. This allows users to see the plan while the agent is working on it, rather than only seeing the transient intent pill near the input area. The plan block: - Shows markdown-rendered plan content in the messages area - Is collapsible (click to expand/collapse) when content exceeds 5 lines - Only appears in expanded (non-compact) view when plan mode is active - Styled with a purple accent consistent with existing intent/reasoning UI - Supports the minimal style layout Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
… session with context - CcaLogService: downloads CCA run logs from GitHub Actions, parses agent conversation (strips boilerplate/timestamps/firewall noise, truncates verbose output), fetches PR data (diff, body, comments) in parallel, assembles structured context prompt with XML-tagged sections, saves full raw data to disk for on-demand agent access - CopilotService.LoadCcaRunAsync: orchestrates the full flow — finds repo, reuses or creates worktree on CCA branch, loads CCA context, creates session with CCA metadata, sends context prompt - AgentSessionInfo: added CcaRunId, CcaPrNumber, CcaBranch for provenance - SessionSidebar: Load ↓ button on every CCA run item (active, open, completed) with loading indicator. Active runs show warning tooltip. - 11 new tests for log parsing (boilerplate stripping, timestamp removal, firewall noise filtering, long line truncation, cleanup section stop, conversation structure preservation) and AgentSessionInfo CCA fields 274 tests passing, build clean.
- LoadCcaRunAsync checks if a session with matching CcaRunId already exists and returns it instead of creating a new one - Sidebar shows 'Open →' (blue) instead of 'Load ↓' (green) for CCA runs that already have a loaded session, clicking switches to that session - IsCcaRunLoaded helper checks sessions list for matching CcaRunId
- ActiveSessionEntry now stores CcaRunId, CcaPrNumber, CcaBranch - SaveActiveSessionsToDisk writes CCA fields to active-sessions.json - RestorePreviousSessionsAsync restores CCA fields after resume - 'Open →' button now survives reboots for loaded CCA sessions
…tion' into copilot/add-cca-session-connection
… matching
Root cause: Sessions loaded before CCA persistence was added get restored
with CcaRunId=null. The 'Open →' check only matched by CcaRunId, so it
always showed 'Load' after restart.
Fix: CcaLogService.FindExistingCcaSession() now matches by CcaRunId first,
then falls back to matching session name prefix 'CCA: PR #{number}'. When
matched by name, it backfills CcaRunId/CcaPrNumber/CcaBranch and persists
so future matches use the fast path.
Both CopilotService.LoadCcaRunAsync and sidebar IsCcaRunLoaded use this
shared method. 6 new tests verify all matching scenarios including
backfill, priority, and no-match cases. 280 tests passing.
- Fix temp file leak on download failure (wrap in single try/finally) - Fix potential stderr deadlock in RunGhAsync (read both streams concurrently) - Remove stderr redirect in FetchRunLogsAsync (not needed, avoids deadlock) - Use CancellationToken.None for fire-and-forget prompt delivery - Persist CCA metadata immediately after setting (SaveActiveSessionsToDisk) - Use atomic HashSet.Add() check in LoadCcaRunAsync (race condition fix) - Use source-generated Regex for StripTimestamp hot path performance
- Validate ownerRepo against safe regex (^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$) to prevent argument injection in gh CLI calls - Add untrusted-data warning to CCA context prompt to mitigate prompt injection from PR content/logs
ListSessionsAsync()withIsRemote == trueResumeSessionAsyncflow/delegate <prompt>slash command with Mode="delegate"Name,Eventfields toCcaRunmodelIsCodingAgentproperty to distinguish coding agent vs comment-response runsCcaRunServiceFetchFromGitHubAsyncto only include coding agent runsIsCodingAgentfiltering,IsActive,ExtractOwnerRepoutility✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.