Fixes#312210
This is using the old search endpoint. We'll start switching over the new one once it's ready
Co-authored-by: Copilot <copilot@github.com>
* fix: cache CCA disabled results with 5-min TTL to reduce /enabled traffic
The checkCCAEnabled() method previously only cached enabled=true results
(introduced in 19541d79ea). For the majority of users whose repos have CCA
disabled, every provideChatSessionProviderOptions() call bypassed the cache
and hit the jobs/:owner/:repo/enabled CAPI endpoint unconditionally. With
growing adoption, this became significant upstream traffic.
Fix: cache all /enabled results. enabled=true keeps the 30-min TTL.
enabled=false/undefined uses a new 5-min TTL (CCA_DISABLED_CACHE_TTL_MS),
short enough that users who just enabled CCA won't wait long, but long enough
to dramatically reduce repeated calls.
To support the shorter TTL for disabled entries without changing the enabled
TTL, TtlCache.set() now accepts an optional per-entry ttlMs override that
takes precedence over the cache-wide TTL.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: surface unexpected /enabled status codes (e.g. 429) in telemetry
Previously, isCCAEnabled's default case returned { enabled: undefined }
with no statusCode, swallowing 429 rate-limit and 5xx responses.
Changes:
- Widen CCAEnabledResult.statusCode from 401|403|422 to number so
unexpected codes can be propagated
- Return statusCode: response.status in isCCAEnabled's default case
- Add sendTelemetryErrorEvent('copilot.codingAgent.CCAIsEnabledUnexpectedStatus')
in checkCCAEnabled for any status code outside {401, 403, 422}, with
isRateLimited flag for quick 429 filtering in dashboards
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: hoist knownStatusCodes to constant and add GDPR annotation
- Extract CCA_KNOWN_STATUS_CODES to file-level Set to avoid re-creating
it on every call and centralize the list of handled status codes
- Add __GDPR__ comment block for the new
copilot.codingAgent.CCAIsEnabledUnexpectedStatus telemetry error event
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Updated `getGitHubSession` method to require `StrictAuthenticationPresentationOptions` for `createIfNone` and `forceNewSession` parameters, ensuring meaningful context is provided to users.
- Modified various service implementations to include localized detail messages for authentication prompts, improving user experience during sign-in.
- Added a comprehensive usage guide for the `IAuthenticationService`, detailing session types, overloads, and constraints.
- GH MCP Feature doesn't bother user over and over for auth
- Introduced a new `AGENTS.md` file to document authentication service usage and best practices.
* sessions: Add pullRequestMerged metadata for PR status icons
Add `pullRequestMerged` to session metadata so the VS Code session list
can show a git-merge icon for merged PRs vs git-pull-request for open ones.
Changes:
- Add `pullRequestMerged` to `ChatSessionWorktreePropertiesV2` interface
- Cloud provider: derive merged status from `pr.state` in metadata
- CLI provider: propagate merged status through PR detection pipeline
(`detectPullRequestFromGitHubAPI`, retry logic, session item metadata)
- Update tests with `state` field in mock PR objects
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* sessions: Re-check PR merge status periodically
Previously, PR detection was skipped entirely once a pullRequestUrl
existed. This meant pullRequestMerged would never be updated after
the initial detection.
Now the detection pipeline continues re-checking sessions that have
an unmerged PR on a cooldown interval, and only marks detection as
permanently done once the PR is merged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* sessions: Use longer cooldown for PR merge-status re-checks
Sessions that already have a pullRequestUrl but aren't yet merged now
use a 10-minute cooldown (_PR_MERGE_RECHECK_INTERVAL) instead of the
1-minute interval used for initial PR detection. This prevents burning
through the GitHub API rate limit when many sessions have open PRs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* sessions: Add isDraft to GraphQL, replace pullRequestMerged with pullRequestState
Add `isDraft` field to both PR GraphQL queries and to the
`PullRequestSearchItem` interface. Replace the `pullRequestMerged`
boolean with a `pullRequestState` string ('open' | 'closed' | 'merged'
| 'draft') throughout the detection pipeline:
- New `derivePullRequestState()` helper in githubAPI.ts
- `ChatSessionWorktreePropertiesV2.pullRequestState` replaces
`pullRequestMerged`
- CLI and Cloud providers both emit `pullRequestState` in metadata
- `shouldDetectPullRequest` checks for `'merged'` state as terminal
- `processPendingPrDetections` compares state strings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* sessions: Update derivePullRequestState to prioritize terminal states over draft
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update handling of errors in external ingest
Make sure we handle error responses and retries better
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Handle retry-after
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* feat: add GHE (GitHub Enterprise) support for cloud agent
- Add host field to GithubRepoId (defaults to github.com)
- Add rawHost to parseRemoteUrl for SSH alias resolution
- Add toGithubWebUrl helper for constructing host-aware URLs
- Use ICAPIClientService.dotcomAPIURL in GithubRepositoryService
instead of hardcoded https://api.github.com
- Update cloud session error messages and UI links to use repo host
- Support GHE URLs in _normalizeGitUri, remote agent icons, and
github repo search tool
- Add comprehensive tests for GHE URL parsing and host propagation
* fix: make PR fetch resilient in provideChatSessionItems
Wrap individual getPullRequestFromGlobalId calls in try-catch so
a single failure (e.g. PermissiveAuthRequiredError on GHE) doesn't
prevent all other sessions from loading. Log warnings for failures.
* fix: refresh cloud sessions when CAPI URL changes for GHE
Listen to IDomainService.onDidChangeDomains so that when the GHE
Copilot token arrives and updates the CAPI base URL, the sessions
provider clears caches and re-fetches against the correct endpoint.
Previously, the initial session fetch raced with token minting and
hit the default api.githubcopilot.com with a GHE token, getting 401.
Also cleaned up diagnostic retry logic in getAllSessions and kept
useful debug logging for session fetch diagnostics.
* fix: clear chatSessionItemsPromise on refresh to prevent stale results
refresh() was clearing cachedSessionItems but not chatSessionItemsPromise,
so when the CAPI URL changed and triggered a refresh, the old in-flight
promise (which hit the wrong URL) was still returned by subsequent
provideChatSessionItems calls, preventing the re-fetch.
* tidy
* Add telemetry to keep an eye on the number of network requests we're sending
* Fix unreachable code
* Update src/extension/completions-core/vscode-node/lib/src/networking.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix github api call site
* Apply callsite post spread
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan
* Add GraphQL-based partner agent detection with caching
- Add GraphQL queries for fetching assignable actors (suggestedActors and assignableUsers APIs)
- Add getAssignableActors method to IOctoKitService interface
- Implement dynamic partner agent detection in CopilotCloudSessionsProvider
- Add caching mechanism to avoid repeated API calls
- Update known Copilot agent logins based on spec
- Fall back to hardcoded list when API is unavailable
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
* Fix MockOctoKitService to include getAssignableActors method
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
* Use HARDCODED_PARTNER_AGENTS `at` values for partner agents
- Create COPILOT_AGENT_METADATA mapping for known Copilot agent logins
- Look up `at` values from HARDCODED_PARTNER_AGENTS when available
- Preserve the `at` field structure from the hardcoded list
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
* Remove COPILOT_AGENT_METADATA and use HARDCODED_PARTNER_AGENTS directly
- Delete COPILOT_AGENT_METADATA mapping
- Simplify getAvailablePartnerAgents to check HARDCODED_PARTNER_AGENTS directly
- Check if agent ID or name matches assignable actors
- Preserve all fields from HARDCODED_PARTNER_AGENTS including `at` values
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
* polish
* Update src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix auth
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Allow passing in auth behavior into octokit service
Commit 1: Internal refactoring that does not influence behavior at all. It just sets us up to have control over the auth behavior.
* Set `createIfNone: false` to prevent auth prompts in organizationAndEnterpriseAgentProvider (#2636)
* Initial plan
* Change createIfNone to false and remove runWithAuthCheck method
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
* Update src/extension/agents/vscode-node/organizationAndEnterpriseAgentProvider.ts
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
* Fixes the bug
* Another case that should be a non-functional change
* Have service throw welknown error
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Enables the same `no-unexternalized-strings` with have in `vscode` in this repo. This make sure we have a more consistent style across repos and when generating edits
* refactor cloud session class
* pass correct context
* throw errors and fix parameter typo
* remove stale test
* remove debug markdown
* reset confirmations commadn
* some loose ends
* tweaks while rate limited
* update test
* more accurate
* nevermind
* add back cli handleConfirmationData
* nullptr
* restore test
* polish
* this is the pr uri
* polish
* wire up multifilediff part
* check in src/extension/chatSessions/vscode-node/pullRequestFileChangesService.ts
* pass readOnly flag to ChatResponseMultiDiffPart