Skip to content

test(vscode-e2e): add orchestrator E2E foundation for parallel-mode coverage - #1064

Open
easonLiangWorldedtech wants to merge 9 commits into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:feat/view-local-state-base-e2e/orchestrator
Open

test(vscode-e2e): add orchestrator E2E foundation for parallel-mode coverage#1064
easonLiangWorldedtech wants to merge 9 commits into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:feat/view-local-state-base-e2e/orchestrator

Conversation

@easonLiangWorldedtech

@easonLiangWorldedtech easonLiangWorldedtech commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is a follow-up test foundation based on the discussion in #977 (fix(webview): add durable per-view state base). PR #977 introduces the durable per-view state base needed for parallel-mode work, and edelauna requested more real VS Code E2E coverage around the kinds of cross-provider / cross-panel boundaries that mocked unit tests cannot fully exercise.

Instead of putting all complex scenarios into one large commit, this PR adds the E2E foundation in reviewer-friendly slices. The focus here is not to change production orchestration behavior, but to establish durable E2E infrastructure for future parallel-mode work: multi-provider task lifecycles, delegation fan-in/fan-out, nested delegation, cancellation recovery, and resource convergence checks.

Context from #977

#977 fixes the durable per-view state base so sidebar and editor-tab providers can maintain isolated view-local state while still sharing the same extension/global-state boundary. That PR is the root dependency for broader parallel-mode work.

The review feedback on #977 asked for more E2E coverage beyond mocked provider tests, especially around real extension-host behavior. This PR builds on that direction by adding a heavier E2E base that can be reused for future parallel-mode scenarios.

What this PR adds

1. Single-round orchestrator fan-out / fan-in E2E

Adds a baseline orchestrator E2E where a parent orchestrator delegates sequential children to ask, architect, and code modes, then fans their summaries back into the parent completion.

This verifies:

  • child task creation and completion
  • parent / child history linkage
  • delegation completion events
  • final parent aggregation
  • task stack cleanup

2. Repeated delegation stress E2E

Adds a repeated delegation workflow with three rounds of ask / architect / code children, validating that the orchestrator path remains stable across repeated child creation, completion, resume, and final aggregation.

This verifies:

  • nine unique child tasks
  • nine delegation completion events
  • stable childIds
  • per-round mode and summary fidelity
  • final fan-in output
  • stack convergence

3. Resource diagnostics API

Adds a small test-focused diagnostics API exposing stable counters:

  • registered task count
  • current task stack length
  • key lifecycle listener counts

This is intentionally limited to deterministic resource counters rather than noisy heap/RSS thresholds.

4. Resource convergence sentinel

Wires the diagnostics API into the repeated orchestrator E2E so the test hard-gates that resources converge after cleanup.

This verifies:

  • registered task count returns to baseline
  • task stack length returns to baseline / zero
  • listener counts return to baseline after local handlers are removed
  • stale child tasks do not remain registered

5. Nested orchestrator delegation E2E

Adds a nested workflow:

  • top-level orchestrator parent
  • child orchestrator
  • ask/code grandchildren
  • child orchestrator fan-in
  • top-level parent fan-in

This verifies stable delegation ownership across a task tree, not just a single parent-child edge.

6. Cancellation / recovery E2E

Adds coverage for cancelling/interruption of a delegated child and explicit recovery.

This verifies:

  • parent does not prematurely resume or complete when the child is interrupted
  • parent remains in the expected delegated/awaiting state
  • explicit recovery resumes the child and returns the result to the parent
  • final parent completion contains the cancellation recovery summary
  • cleanup and resource diagnostics converge

Normal/unit coverage

Each E2E slice includes normal/unit coverage for the helper or API logic it introduces:

  • orchestrator fixture plan helpers
  • repeated delegation plan generation
  • nested delegation plan matching
  • cancellation/recovery plan matching
  • resource diagnostics convergence helper
  • API resource diagnostics counters

Why this is separate from #977

#977 is the production fix for durable per-view state. This PR is the E2E foundation requested from that review context. Keeping it separate makes the review easier:

  • fix(webview): add durable per-view state base #977 can stay focused on the per-view state base.
  • This PR focuses on heavier E2E infrastructure and future parallel-mode confidence.
  • The commit history is intentionally split into small reviewer-friendly test slices.

Validation

The following validation was run after cherry-picking onto latest main and resolving conflicts:

  • git status --short — clean
  • git diff --name-only --diff-filter=U — no unresolved conflicts
  • git diff --check — passed
  • pnpm --dir apps/vscode-e2e exec vitest run src/fixtures/orchestrator-plan.spec.ts src/fixtures/resource-diagnostics.spec.ts — passed, 23 tests
  • cd src ; npx vitest run extension/__tests__/api-resource-diagnostics.spec.ts — passed, 3 tests
  • pnpm --dir src run check-types — passed
  • pnpm --dir packages/types run check-types — passed

A final targeted VS Code E2E run for orchestrator.test should be run before merge, since this branch was just replayed onto latest main.

Relationship to future work

This PR is intended as the base for more complex parallel-mode E2E testing. It provides reusable orchestration fixtures, resource convergence helpers, and multi-task lifecycle coverage that future PRs can build on when testing real parallel panels/providers.

Summary by CodeRabbit

  • New Features
    • Added getResourceDiagnostics() to inspect resource diagnostics (registered task count, current task-stack length, and per-event listener counts).
  • Tests
    • Added unit-test support for the e2e app with new specs covering resource-diagnostics convergence.
    • Expanded orchestrator e2e coverage with stronger delegation-plan assertions across fan-out, repeated delegation, nested orchestration, and cancellation recovery, plus standardized cleanup/diagnostics checks.
    • Added API#getResourceDiagnostics tests for pruning/ejection of previously registered tasks.
  • CI
    • Updated the mocked e2e workflow to run the new unit-test step earlier.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f1a5142-e0fa-4749-9018-4d0b4add26b8

📥 Commits

Reviewing files that changed from the base of the PR and between 62d3226 and 8ffd934.

📒 Files selected for processing (1)
  • src/extension/api.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/extension/api.ts

📝 Walkthrough

Walkthrough

Adds typed resource diagnostics, reusable orchestrator replay fixtures, delegation-plan unit tests, and end-to-end cleanup validation. Vitest is integrated into the VS Code E2E package and workflow.

Changes

Orchestrator E2E and Resource Diagnostics

Layer / File(s) Summary
Resource diagnostics contract and tracking
packages/types/src/api.ts, src/extension/api.ts, src/extension/__tests__/api-resource-diagnostics.spec.ts, apps/vscode-e2e/src/fixtures/resource-diagnostics.*
Adds diagnostic types and getResourceDiagnostics(), tracks task and listener counts, and validates convergence reporting.
Orchestrator plans and request matching
apps/vscode-e2e/src/fixtures/orchestrator-plan.*
Defines fan-out, repeated, nested, and cancellation-recovery expectations, markers, composed results, and matchers.
Mock orchestration flows
apps/vscode-e2e/src/fixtures/orchestrator.ts, apps/vscode-e2e/src/runTest.ts
Registers shared child-completion and resume fixtures for replay-mode orchestration scenarios.
Orchestrator integration validation
apps/vscode-e2e/src/suite/orchestrator.test.ts, apps/vscode-e2e/vitest.config.ts, apps/vscode-e2e/package.json, .github/workflows/e2e.yml
Adds deterministic cleanup, configuration restoration, convergence checks, and Vitest workflow execution.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OrchestratorTest
  participant OrchestratorTask
  participant LLMock
  participant RooCodeAPI
  OrchestratorTest->>OrchestratorTask: start orchestration scenario
  OrchestratorTask->>LLMock: request child task or resume
  LLMock-->>OrchestratorTask: return delegated step or completion
  OrchestratorTask-->>OrchestratorTest: emit delegation and completion events
  OrchestratorTest->>RooCodeAPI: read final resource diagnostics
  RooCodeAPI-->>OrchestratorTest: return task, stack, and listener counters
Loading

Possibly related PRs

Suggested labels: awaiting-review

Suggested reviewers: taltas

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it misses the required Related GitHub Issue/Closes line and the template’s checklist structure. Add the Related GitHub Issue section with a Closes: # issue link and include the required template headings/checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding orchestrator E2E foundation for parallel-mode coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/extension/api.ts (1)

356-380: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

registeredTaskIds entries are only removed on completed/aborted.

Tasks that end any other way (evicted via clearCurrentTask, interrupted and never resumed, provider disposal) stay in the set for the lifetime of the extension host, so registeredTaskCount never returns to baseline and the E2E convergence assertions can fail intermittently. Consider also pruning on task disposal/eviction (or reconciling against the provider's task registry inside getResourceDiagnostics).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/extension/api.ts` around lines 356 - 380, Ensure registeredTaskIds is
pruned when tasks are disposed or evicted, not only on TaskCompleted and
TaskAborted. Update the TaskCreated lifecycle wiring around
clearCurrentTask/provider disposal or the task’s disposal event to delete
task.taskId, while preserving existing completion and abort cleanup;
alternatively reconcile the set with the provider’s active task registry in
getResourceDiagnostics.
🧹 Nitpick comments (9)
apps/vscode-e2e/src/fixtures/resource-diagnostics.ts (1)

56-62: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the intentional asymmetry.

Skipping the issue when final.currentTaskStackLength === 0 means a shrinking stack is always considered converged; that's non-obvious next to the strict registeredTaskCount check. A one-line comment would prevent someone "fixing" it later.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/fixtures/resource-diagnostics.ts` around lines 56 - 62,
Add a concise comment immediately above the currentTaskStackLength condition
explaining that a final value of zero intentionally treats a shrinking task
stack as converged, distinguishing this behavior from the strict
registeredTaskCount check.
apps/vscode-e2e/src/fixtures/orchestrator-plan.spec.ts (1)

37-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Suite name no longer matches its contents.

This describe now covers repeated, nested, and cancellation-recovery plans too; consider "orchestrator delegation plans" or splitting into per-scenario blocks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/fixtures/orchestrator-plan.spec.ts` at line 37, Update
the describe block currently named “orchestrator fan-out delegation plan” to use
a broader suite name such as “orchestrator delegation plans,” reflecting its
repeated, nested, and cancellation-recovery scenarios.
apps/vscode-e2e/src/fixtures/orchestrator.ts (3)

40-74: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the explicit re-export list with a barrel re-export.

Every symbol is imported and then re-exported verbatim; export * from "./orchestrator-plan" (plus a plain import of what this file actually uses) removes ~35 lines that must be kept in sync whenever the plan module grows.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/fixtures/orchestrator.ts` around lines 40 - 74, Replace
the explicit export list in orchestrator.ts with a barrel re-export from
"./orchestrator-plan". Add or retain a plain import containing only the symbols
this file directly uses, while preserving the existing public exports and
removing the duplicated re-export maintenance.

102-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Three identical child-completion fixture loops.

The fan-out, repeated, and nested grandchild loops differ only in the step array. Extract a small helper (e.g. addChildCompletionFixtures(mock, steps)) and reuse it for all three, and likewise for the resume-expectation loops.

Also applies to: 169-185, 256-272

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/fixtures/orchestrator.ts` around lines 102 - 118, Extract
the duplicated child-completion fixture loop into a helper such as
addChildCompletionFixtures(mock, steps), then reuse it for the fan-out,
repeated, and nested grandchild step arrays. Apply the same extraction and reuse
pattern to the corresponding resume-expectation loops, preserving each loop’s
existing step-specific behavior.

120-121: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a comment explaining the reversed registration order.

[...].reverse() is load-bearing: it registers the most cumulative resume expectations first so earlier (less specific) predicates can't shadow later rounds. That intent isn't recoverable from the code alone, and the same pattern is repeated four times.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/fixtures/orchestrator.ts` around lines 120 - 121, Add an
explanatory comment immediately before the reversed iteration in the
orchestrator resume expectation registration, documenting that reverse order
registers the most cumulative expectations first and prevents less-specific
predicates from shadowing later rounds. Apply the same comment to all four
occurrences of this reversed registration pattern.
apps/vscode-e2e/src/suite/orchestrator.test.ts (2)

122-122: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Baseline diagnostics captured in only two of four tests.

Tests 1 and 3 do the same cleanup but skip the convergence assertion, so a leak introduced by the fan-out or nested flow would only surface (if at all) as a baseline shift in the next test. Consider applying the same baseline/convergence pattern to all four.

Also applies to: 400-400

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/suite/orchestrator.test.ts` at line 122, Apply the
baseline diagnostics and convergence assertion pattern consistently across all
four tests in the orchestrator test suite, including tests 1 and 3. Ensure each
test captures diagnostics before execution, performs its existing cleanup, and
verifies diagnostics converge back to the captured baseline rather than relying
on the next test to detect leaks.

108-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated cleanup block into a helper.

The four finally blocks duplicate listener removal, the stack-drain loop, and (in two of them) the diagnostics convergence wait. Also note while (api.getCurrentTaskStack().length > 0) await api.clearCurrentTask() has no iteration cap — if a task can't be cleared this spins until the mocha timeout instead of failing with a clear message. A shared drainTaskStack(api, { maxAttempts }) + expectDiagnosticsConverged(...) helper would fix both.

Also applies to: 226-254, 386-395, 525-553

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/suite/orchestrator.test.ts` around lines 108 - 117,
Extract the duplicated finally-block cleanup into shared drainTaskStack and
diagnostics-convergence helpers, including listener removal where appropriate.
Update all four cleanup sites around the existing test handlers to use them, and
cap clearCurrentTask attempts via maxAttempts so a non-clearable task fails with
a clear assertion instead of looping until timeout. Preserve diagnostics waiting
only in the cleanup paths that currently require it.
packages/types/src/api.ts (1)

12-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider deriving the union from RooCodeEventName instead of re-typing literals.

These string literals silently duplicate RooCodeEventName values; a rename in the enum would leave this union stale while RESOURCE_DIAGNOSTIC_EVENTS in src/extension/api.ts still type-checks via the as cast.

♻️ Suggested tightening
-export type RooCodeResourceDiagnosticEventName =
-	| "message"
-	| "taskCreated"
-	| "taskStarted"
-	| "taskCompleted"
-	| "taskAborted"
-	| "taskDelegationCompleted"
-	| "taskDelegationResumed"
-	| "taskModeSwitched"
+export type RooCodeResourceDiagnosticEventName = Extract<
+	`${RooCodeEventName}`,
+	| "message"
+	| "taskCreated"
+	| "taskStarted"
+	| "taskCompleted"
+	| "taskAborted"
+	| "taskDelegationCompleted"
+	| "taskDelegationResumed"
+	| "taskModeSwitched"
+>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/types/src/api.ts` around lines 12 - 26, Update
RooCodeResourceDiagnosticEventName to derive its allowed values from
RooCodeEventName rather than duplicating string literals, and ensure
RESOURCE_DIAGNOSTIC_EVENTS remains type-safe without relying on a cast that can
hide renamed or invalid events.
apps/vscode-e2e/src/fixtures/orchestrator-plan.ts (1)

234-247: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The cancellation follow-up tool-call id has no single source of truth. One site reconstructs it by string-replacing "completion_002" → "followup_001", the other hardcodes the literal, so renaming either breaks fixture matching silently.

  • apps/vscode-e2e/src/fixtures/orchestrator-plan.ts#L234-L247: export a ORCHESTRATOR_CANCELLATION_RECOVERY_FOLLOWUP_TOOL_CALL_ID constant and use it in both matchers instead of .replace(...).
  • apps/vscode-e2e/src/fixtures/orchestrator.ts#L344-L361: import that constant and use it as the ask_followup_question tool-call id instead of the inline "call_orchestrator_cancellation_child_followup_001" literal.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/fixtures/orchestrator-plan.ts` around lines 234 - 247,
The cancellation follow-up tool-call ID is duplicated across fixtures. In
apps/vscode-e2e/src/fixtures/orchestrator-plan.ts#L234-L247, export a single
ORCHESTRATOR_CANCELLATION_RECOVERY_FOLLOWUP_TOOL_CALL_ID constant and use it in
both matcher functions instead of reconstructing the value with replace; in
apps/vscode-e2e/src/fixtures/orchestrator.ts#L344-L361, import and use that
constant for the ask_followup_question tool-call ID instead of the inline
literal.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/vscode-e2e/src/fixtures/orchestrator-plan.ts`:
- Line 129: Update ORCHESTRATOR_REPEATED_DELEGATION_FINAL_RESULT to join mapped
rows with a real newline escape, matching the header and the other final-result
constants; preserve the existing row formatting and summary content.

In `@apps/vscode-e2e/src/suite/orchestrator.test.ts`:
- Around line 29-31: Add a suiteTeardown for the “Roo Code Orchestrator” suite
that restores the default OpenRouter configuration after the tests complete. Use
the existing configuration-reset helper or established default-config symbol,
ensuring persisted provider, model, mode, and auto-approval settings do not
affect subsequent suites.

---

Outside diff comments:
In `@src/extension/api.ts`:
- Around line 356-380: Ensure registeredTaskIds is pruned when tasks are
disposed or evicted, not only on TaskCompleted and TaskAborted. Update the
TaskCreated lifecycle wiring around clearCurrentTask/provider disposal or the
task’s disposal event to delete task.taskId, while preserving existing
completion and abort cleanup; alternatively reconcile the set with the
provider’s active task registry in getResourceDiagnostics.

---

Nitpick comments:
In `@apps/vscode-e2e/src/fixtures/orchestrator-plan.spec.ts`:
- Line 37: Update the describe block currently named “orchestrator fan-out
delegation plan” to use a broader suite name such as “orchestrator delegation
plans,” reflecting its repeated, nested, and cancellation-recovery scenarios.

In `@apps/vscode-e2e/src/fixtures/orchestrator-plan.ts`:
- Around line 234-247: The cancellation follow-up tool-call ID is duplicated
across fixtures. In apps/vscode-e2e/src/fixtures/orchestrator-plan.ts#L234-L247,
export a single ORCHESTRATOR_CANCELLATION_RECOVERY_FOLLOWUP_TOOL_CALL_ID
constant and use it in both matcher functions instead of reconstructing the
value with replace; in apps/vscode-e2e/src/fixtures/orchestrator.ts#L344-L361,
import and use that constant for the ask_followup_question tool-call ID instead
of the inline literal.

In `@apps/vscode-e2e/src/fixtures/orchestrator.ts`:
- Around line 40-74: Replace the explicit export list in orchestrator.ts with a
barrel re-export from "./orchestrator-plan". Add or retain a plain import
containing only the symbols this file directly uses, while preserving the
existing public exports and removing the duplicated re-export maintenance.
- Around line 102-118: Extract the duplicated child-completion fixture loop into
a helper such as addChildCompletionFixtures(mock, steps), then reuse it for the
fan-out, repeated, and nested grandchild step arrays. Apply the same extraction
and reuse pattern to the corresponding resume-expectation loops, preserving each
loop’s existing step-specific behavior.
- Around line 120-121: Add an explanatory comment immediately before the
reversed iteration in the orchestrator resume expectation registration,
documenting that reverse order registers the most cumulative expectations first
and prevents less-specific predicates from shadowing later rounds. Apply the
same comment to all four occurrences of this reversed registration pattern.

In `@apps/vscode-e2e/src/fixtures/resource-diagnostics.ts`:
- Around line 56-62: Add a concise comment immediately above the
currentTaskStackLength condition explaining that a final value of zero
intentionally treats a shrinking task stack as converged, distinguishing this
behavior from the strict registeredTaskCount check.

In `@apps/vscode-e2e/src/suite/orchestrator.test.ts`:
- Line 122: Apply the baseline diagnostics and convergence assertion pattern
consistently across all four tests in the orchestrator test suite, including
tests 1 and 3. Ensure each test captures diagnostics before execution, performs
its existing cleanup, and verifies diagnostics converge back to the captured
baseline rather than relying on the next test to detect leaks.
- Around line 108-117: Extract the duplicated finally-block cleanup into shared
drainTaskStack and diagnostics-convergence helpers, including listener removal
where appropriate. Update all four cleanup sites around the existing test
handlers to use them, and cap clearCurrentTask attempts via maxAttempts so a
non-clearable task fails with a clear assertion instead of looping until
timeout. Preserve diagnostics waiting only in the cleanup paths that currently
require it.

In `@packages/types/src/api.ts`:
- Around line 12-26: Update RooCodeResourceDiagnosticEventName to derive its
allowed values from RooCodeEventName rather than duplicating string literals,
and ensure RESOURCE_DIAGNOSTIC_EVENTS remains type-safe without relying on a
cast that can hide renamed or invalid events.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 74f1fbdd-ad35-4be8-92fd-f6758a4553b8

📥 Commits

Reviewing files that changed from the base of the PR and between 569b43d and 4c5c41d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • apps/vscode-e2e/package.json
  • apps/vscode-e2e/src/fixtures/orchestrator-plan.spec.ts
  • apps/vscode-e2e/src/fixtures/orchestrator-plan.ts
  • apps/vscode-e2e/src/fixtures/orchestrator.ts
  • apps/vscode-e2e/src/fixtures/resource-diagnostics.spec.ts
  • apps/vscode-e2e/src/fixtures/resource-diagnostics.ts
  • apps/vscode-e2e/src/runTest.ts
  • apps/vscode-e2e/src/suite/orchestrator.test.ts
  • apps/vscode-e2e/vitest.config.ts
  • packages/types/src/api.ts
  • src/extension/__tests__/api-resource-diagnostics.spec.ts
  • src/extension/api.ts

Comment thread apps/vscode-e2e/src/fixtures/orchestrator-plan.ts Outdated
Comment thread apps/vscode-e2e/src/suite/orchestrator.test.ts

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/e2e.yml:
- Around line 147-150: Move the “Run vscode-e2e unit tests” step using the
test:unit command to immediately after dependency setup, before the VS Code
binary download steps. Preserve its existing condition and command so the
Vitest-only suite runs independently of binary availability.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a81fae15-df62-468f-99ed-482c88a3e340

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5c41d and a9f7e0b.

📒 Files selected for processing (1)
  • .github/workflows/e2e.yml

Comment thread .github/workflows/e2e.yml Outdated
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

Addressed the CodeRabbit review feedback in commit 96bc9787d:

  • Fixed repeated-delegation final-result newline escaping so rows use real newlines.
  • Added a single source of truth for the cancellation recovery follow-up tool-call ID and reused it in matchers/fixtures.
  • Refactored orchestrator fixtures to use a barrel re-export plus shared child-completion and resume-fixture helpers.
  • Documented the reverse resume registration order and resource diagnostics stack convergence asymmetry.
  • Added baseline diagnostics/convergence checks consistently across all orchestrator E2E scenarios and capped task-stack cleanup attempts.
  • Added suiteTeardown to restore the default OpenRouter config after the orchestrator suite.
  • Reconciled registeredTaskIds with the provider task stack in resource diagnostics so evicted/disposed tasks are pruned, with regression coverage.
  • Derived RooCodeResourceDiagnosticEventName from RooCodeEventName and tightened RESOURCE_DIAGNOSTIC_EVENTS typing.
  • Moved the vscode-e2e unit-test CI step before VS Code binary download.

Validation run:

  • pnpm --dir apps/vscode-e2e exec vitest run src/fixtures/orchestrator-plan.spec.ts src/fixtures/resource-diagnostics.spec.ts — passed, 23 tests.
  • cd src; npx vitest run extension/__tests__/api-resource-diagnostics.spec.ts — passed, 4 tests.
  • pnpm --dir src run check-types — passed.
  • pnpm --dir packages/types run check-types — passed.
  • pnpm --dir apps/vscode-e2e run check-types — passed.
  • pnpm --dir src exec eslint --prune-suppressions --max-warnings=0 extension/api.ts extension/__tests__/api-resource-diagnostics.spec.ts — passed.
  • pnpm --dir apps/vscode-e2e exec eslint --max-warnings=0 src/fixtures/orchestrator-plan.ts src/fixtures/orchestrator.ts src/fixtures/resource-diagnostics.ts src/fixtures/orchestrator-plan.spec.ts src/suite/orchestrator.test.ts — passed.
  • pnpm --dir packages/types exec eslint --max-warnings=0 src/api.ts — passed.
  • git diff --check — passed.
  • Commit hook turbo lint — passed.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/extension/api.ts (1)

35-51: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Reconcile registered tasks across every provider being tracked.

registeredTaskIds is shared by all calls to registerListeners(provider), including the separate new-tab provider created at Lines [201]–[202], but getResourceDiagnostics() compares it only with this.sidebarProvider.getCurrentTaskStack(). A task created in another tab can therefore be deleted from diagnostics while still active, causing false resource convergence. Track task IDs with their owning provider and reconcile each provider’s stack, or scope registration and diagnostics to the same provider; add a second-provider regression test.

Also applies to: 270-287

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/extension/api.ts` around lines 35 - 51, Update registeredTaskIds and the
registerListeners/getResourceDiagnostics flow so task ownership is preserved
across every tracked ClineProvider, including the separate new-tab provider.
Reconcile registered task IDs against each owning provider’s getCurrentTaskStack
rather than only sidebarProvider, ensuring active tasks in other tabs remain in
diagnostics. Add a regression test covering registration and reconciliation with
two providers.
🧹 Nitpick comments (1)
apps/vscode-e2e/src/suite/orchestrator.test.ts (1)

29-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse a shared OpenRouter default config helper.

getDefaultOpenRouterConfiguration() and the equivalent reset object in apps/vscode-e2e/src/suite/anthropic-opus-4-7.test.ts duplicate the same provider/model/key/baseUrl selection. Put this default in a shared suite util and import it from both teardowns to avoid drift on keys like openRouterModelId, mode, and auto-approval flags.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/vscode-e2e/src/suite/orchestrator.test.ts` around lines 29 - 43, Extract
getDefaultOpenRouterConfiguration into a shared VS Code E2E suite utility,
preserving its provider, model, API-key, base URL, mode, and approval settings.
Import and reuse that helper in both orchestrator.test.ts and the reset/teardown
configuration in anthropic-opus-4-7.test.ts, removing the duplicated local
default object.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/extension/api.ts`:
- Around line 35-51: Update registeredTaskIds and the
registerListeners/getResourceDiagnostics flow so task ownership is preserved
across every tracked ClineProvider, including the separate new-tab provider.
Reconcile registered task IDs against each owning provider’s getCurrentTaskStack
rather than only sidebarProvider, ensuring active tasks in other tabs remain in
diagnostics. Add a regression test covering registration and reconciliation with
two providers.

---

Nitpick comments:
In `@apps/vscode-e2e/src/suite/orchestrator.test.ts`:
- Around line 29-43: Extract getDefaultOpenRouterConfiguration into a shared VS
Code E2E suite utility, preserving its provider, model, API-key, base URL, mode,
and approval settings. Import and reuse that helper in both orchestrator.test.ts
and the reset/teardown configuration in anthropic-opus-4-7.test.ts, removing the
duplicated local default object.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a7b70ac8-6b1e-4c8a-b233-6f18aeb31dff

📥 Commits

Reviewing files that changed from the base of the PR and between a9f7e0b and 96bc978.

📒 Files selected for processing (9)
  • .github/workflows/e2e.yml
  • apps/vscode-e2e/src/fixtures/orchestrator-plan.spec.ts
  • apps/vscode-e2e/src/fixtures/orchestrator-plan.ts
  • apps/vscode-e2e/src/fixtures/orchestrator.ts
  • apps/vscode-e2e/src/fixtures/resource-diagnostics.ts
  • apps/vscode-e2e/src/suite/orchestrator.test.ts
  • packages/types/src/api.ts
  • src/extension/__tests__/api-resource-diagnostics.spec.ts
  • src/extension/api.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/types/src/api.ts

@easonLiangWorldedtech
easonLiangWorldedtech force-pushed the feat/view-local-state-base-e2e/orchestrator branch from 96bc978 to 62d3226 Compare July 30, 2026 19:36

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/extension/api.ts (1)

270-287: 🗄️ Data Integrity & Integration | 🟠 Major | ⚖️ Poor tradeoff

Keep new-tab task IDs from being pruned here when reporting diagnostics.

startNewTask({ newTab: true }) registers the new ClineProvider and adds its TaskCreated events to the shared registeredTaskIds, but getResourceDiagnostics() still prunes against only this.sidebarProvider.getCurrentTaskStack(). That can remove a new-tab task that emitted TaskCreated before TaskCompleted/TaskAborted, leaving registeredTaskCount inconsistent with the active/new-tab task flow. Track the provider per registered task ID, or query every registered provider’s stack, before pruning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/extension/api.ts` around lines 270 - 287, The getResourceDiagnostics
method currently prunes registeredTaskIds using only the sidebar provider’s
current task stack. Preserve new-tab task IDs by tracking the owning
ClineProvider for each registered task ID or aggregating current task stacks
from every registered provider, then prune only IDs absent from all active
provider stacks while retaining the existing diagnostics counts.
🧹 Nitpick comments (1)
src/extension/api.ts (1)

35-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No compile-time exhaustiveness check between RooCodeResourceDiagnosticEventName and RESOURCE_DIAGNOSTIC_EVENTS. Both files independently enumerate the same 8 diagnostic events; the satisfies check only validates array entries are valid members of the type, not that all members are covered, and the as cast at the consumption site (src/extension/api.ts line 280) would silently hide a future mismatch, producing undefined listener counts instead of a compile error.

  • src/extension/api.ts#L35-L44: derive RESOURCE_DIAGNOSTIC_EVENTS from a Record<RooCodeResourceDiagnosticEventName, true> object literal (e.g., via Object.keys) so omitting or misnaming an event fails to compile, instead of relying solely on the downstream as cast at line 280.
  • packages/types/src/api.ts#L12-L22: keep as the source of truth for the allowed event names; no change needed here beyond ensuring the implementation site enforces exhaustiveness against it.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/extension/api.ts` around lines 35 - 44, The RESOURCE_DIAGNOSTIC_EVENTS
definition in src/extension/api.ts:35-44 lacks compile-time exhaustiveness;
replace the array-only declaration with an exhaustive
Record<RooCodeResourceDiagnosticEventName, true> object and derive the event
list from its keys, while preserving the existing consumption behavior.
packages/types/src/api.ts:12-22 is the source of truth and requires no direct
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/extension/api.ts`:
- Around line 270-287: The getResourceDiagnostics method currently prunes
registeredTaskIds using only the sidebar provider’s current task stack. Preserve
new-tab task IDs by tracking the owning ClineProvider for each registered task
ID or aggregating current task stacks from every registered provider, then prune
only IDs absent from all active provider stacks while retaining the existing
diagnostics counts.

---

Nitpick comments:
In `@src/extension/api.ts`:
- Around line 35-44: The RESOURCE_DIAGNOSTIC_EVENTS definition in
src/extension/api.ts:35-44 lacks compile-time exhaustiveness; replace the
array-only declaration with an exhaustive
Record<RooCodeResourceDiagnosticEventName, true> object and derive the event
list from its keys, while preserving the existing consumption behavior.
packages/types/src/api.ts:12-22 is the source of truth and requires no direct
change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ecd47ded-14dd-4193-9f7d-52096c72d161

📥 Commits

Reviewing files that changed from the base of the PR and between 96bc978 and 62d3226.

📒 Files selected for processing (9)
  • .github/workflows/e2e.yml
  • apps/vscode-e2e/src/fixtures/orchestrator-plan.spec.ts
  • apps/vscode-e2e/src/fixtures/orchestrator-plan.ts
  • apps/vscode-e2e/src/fixtures/orchestrator.ts
  • apps/vscode-e2e/src/fixtures/resource-diagnostics.ts
  • apps/vscode-e2e/src/suite/orchestrator.test.ts
  • packages/types/src/api.ts
  • src/extension/__tests__/api-resource-diagnostics.spec.ts
  • src/extension/api.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/vscode-e2e/src/fixtures/resource-diagnostics.ts

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

Addressed the RooCodeResourceDiagnosticEventName exhaustiveness nit in commit 8ffd934ac.

RESOURCE_DIAGNOSTIC_EVENTS is now derived from an exhaustive Record<RooCodeResourceDiagnosticEventName, true> in src/extension/api.ts, so any future mismatch with the source-of-truth union in packages/types/src/api.ts will fail at compile time instead of being hidden by the downstream listener-count cast.

Validation:

  • pnpm --dir src run check-types — passed
  • pnpm --dir src exec eslint --prune-suppressions --max-warnings=0 extension/api.ts — passed
  • cd src; npx vitest run extension/__tests__/api-resource-diagnostics.spec.ts — passed, 4 tests
  • git diff --check — passed
  • commit hook turbo lint — passed

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants