Skip to content

Reuse shared Copilot lifecycle helpers [6/7] - #23079

Merged
sergiou87 merged 1 commit into
developmentfrom
sergiou87-shared-copilot-operations
Nov 4, 2026
Merged

sergiou87 merged 1 commit into
developmentfrom
sergiou87-shared-copilot-operations

Conversation

@sergiou87

@sergiou87 sergiou87 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

No issue closed. Depends on #22991 and targets sergiou87-assisted-commit-push so the diff contains only this follow-up.

Stack

Merge in order, starting with 1. Each PR builds on the preceding PR.

  1. #22971 - Repository-scoped assisted commit UX
  2. #22976 - Selected snapshots and validated Git transactions
  3. #22977 - Constrained Copilot-assisted commit planning
  4. #22986 - Awaited local runs and recovery
  5. #22991 - Optional push and push-only retry
  6. #23079 - Shared Copilot lifecycle helpers (this PR)
  7. #23081 - Assisted commit architecture documentation

Description

  • Reuse awaitCancellableCopilotOperation for ordinary commit-message model discovery, client/session setup, and response waiting, and for conflict-resolution client/session setup. Remove the duplicate store-level cancellation implementation; preserve caller-specific cancellation errors and dispose late-created resources exactly once, reporting cleanup failures.
  • Extract ordinary SDK response handling into sendCopilotMessageRequest, using the existing typed session adapter. Preserve SDK sendAndWait timeouts and error policy: nonbilling session errors are logged, and 402 billing metadata replaces SDK rejections without overriding successful responses.
  • Keep feature policy separate: planning still waits for send acknowledgment and session idle, selects primary assistant messages, and fails on session errors; conflict resolution retains reasoning streaming/flushing, authoritative final messages, timeout/retry stages, and session ownership. Shared cancellation does not cancel another consumer's token renewal or model discovery. Authentication, model/effort selection, and prompts remain unchanged by this refactor.
  • Preserve the base branch's SDK-native global/repository instruction loading. No Desktop discovery, instruction-file copying, temporary instruction configuration, scoped-body reinjection, or instruction RPC adapters are reintroduced. SDK-native loading and precedence remain SDK-owned; configured MCP processes may start during initialization even though model tools remain disabled. This is not an OS sandbox or a guarantee that MCP processes cannot start.
  • Add regression coverage for cancellation before/during setup, late disposal and failures, listener cleanup, billing behavior, planner event ordering, and conflict reasoning/teardown.

Validation

Completed after rebasing the single shared-helper commit onto test-organization parent 103dbef8734b223060c13cc88a4e9d663e19ffbc. Validated head: 2f46f2655ef0c0325b92b97d2ad8b9a8df6d7231.

  • yarn test app/test/unit/copilot-operation-test.ts app/test/unit/stores/copilot-store-test.ts app/test/unit/stores/copilot-store-credentials-test.ts app/test/unit/stores/copilot-assisted-commit-test.ts app/test/unit/copilot-assisted-commit-sdk-test.ts app/test/unit/copilot-conflict-resolution-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/copilot-sdk-auth-test.ts app/test/unit/stores/assisted-commit-selection-test.ts app/test/unit/stores/assisted-commit-recovery-test.ts app/test/unit/stores/assisted-commit-cancellation-test.ts app/test/unit/stores/assisted-commit-completion-test.ts app/test/unit/stores/assisted-commit-run-test.ts app/test/unit/stores/assisted-commit-run-hooks-test.ts app/test/unit/stores/assisted-commit-upstream-integration-test.ts app/test/unit/stores/assisted-commit-reader-publication-test.ts app/test/unit/git/clone-test.ts app/test/unit/git/repository-operation-test.ts app/test/unit/repository-state-cache-test.ts app/test/unit/ui/repository-settings-test.tsx — passed, 527 tests. Includes shared lifecycle coverage and all reorganized behavior suites.
  • yarn lint:fix — passed; no additional working-tree changes.
  • yarn tsc --noEmit — passed with strict declaration checking, without skipLibCheck.
  • yarn lint — passed.
  • GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=safe.bareRepository GIT_CONFIG_VALUE_0=all yarn test — full suite passed: 3,222 passed, 2 skipped, 0 failed. The process-only override accommodates the known CLI-injected safe.bareRepository=explicit restriction; no repository or global Git configuration was changed. Historical yarn test app/test/unit/git/push-test.ts app/test/unit/git/rev-parse-test.ts execution independently reproduced the four unrelated bare-fixture failures (24 passed, 4 failed).
  • Manual validation of existing Copilot-based features
  • Adversarial review with different models

Team-authored review

Evidence: Check validation above. No visual artifact is applicable to this backend-only change.

Review path: Lightweight review. The author has assessed the change and evidence.

Screenshots

N/A — lifecycle refactor with no UI changes.

Release notes

Notes: no-notes

@sergiou87
sergiou87 added this pull request to stack #22992 October 26, 2026 13:19
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from a6c51c8 to 50f1473 Compare October 26, 2026 16:07
Copilot AI balanced review requested due to automatic review settings October 26, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues were identified in the lifecycle refactor, and focused regression coverage supports the preserved cancellation, error, and cleanup behavior.

No open issues 🎉

What changed in this PR

This follow-up consolidates Copilot lifecycle handling in shared helpers, reducing duplication while preserving distinct behavior for commit messages, assisted-commit planning, and conflict resolution.

Changes:

  • Reuse shared cancellation handling for model discovery and client/session setup, including late-resource cleanup.
  • Extract ordinary response waiting while preserving SDK timeouts, billing errors, and caller-owned teardown.
  • Add regression coverage for cancellation, listener cleanup, planner ordering, and conflict-resolution responses.
File Description
app/​test/​unit/​stores/​copilot-store-test.ts Adds conflict reasoning, response, timeout, and teardown coverage.
app/​test/​unit/​copilot-operation-test.ts Tests shared cancellation, billing behavior, and planner event ordering.
app/​src/​lib/​stores/​copilot-store.ts Replaces duplicate lifecycle logic with shared helpers.
app/​src/​lib/​copilot-operation.ts Adds shared response handling and supports synchronous late disposal.

Review effort: Balanced

@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from 50f1473 to dcfb126 Compare October 27, 2026 00:48
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from dcfb126 to 9f68da9 Compare October 27, 2026 16:54
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from 9f68da9 to 1e84e39 Compare October 27, 2026 21:33
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from 1e84e39 to 4900c8d Compare October 28, 2026 08:05
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from 4900c8d to 4db6af7 Compare October 28, 2026 13:53
@sergiou87 sergiou87 changed the title Reuse shared Copilot lifecycle helpers Reuse shared Copilot lifecycle helpers [6/7] Oct 28, 2026
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch 3 times, most recently from 5cd6e2a to 78764af Compare October 29, 2026 12:23
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch 2 times, most recently from f19a2f6 to 6594855 Compare October 29, 2026 15:57
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch 2 times, most recently from 86e77f6 to f79a05d Compare November 3, 2026 16:11
Base automatically changed from sergiou87-assisted-commit-push to development November 3, 2026 17:14
Use the shared cancellable waiter for commit-message and conflict-resolution setup, preserving feature-specific cancellation errors and late resource cleanup. Keep ordinary SDK response handling separate from planner completion and conflict streaming policies. Add regression coverage for cancellation, cleanup, billing, event ordering, and streaming teardown.

Copilot-Session: 6c22d26f-43f2-4fed-b187-bb89e0453cf8
@sergiou87
sergiou87 force-pushed the sergiou87-shared-copilot-operations branch from f79a05d to e77acb9 Compare November 3, 2026 17:14
@sergiou87
sergiou87 marked this pull request as ready for review November 3, 2026 20:30
@sergiou87
sergiou87 requested a review from a team as a code owner November 3, 2026 20:30
@sergiou87
sergiou87 enabled stacked auto-merge November 3, 2026 20:38
@sergiou87
sergiou87 merged commit d0a1906 into development Nov 4, 2026
44 checks passed
@sergiou87
sergiou87 deleted the sergiou87-shared-copilot-operations branch November 4, 2026 17:59
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.

3 participants