Skip to content

tasks: fall back to untyped lookup for task handles - #346950

Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 7 commits into
mainfrom
agents/address-copilot-feedback-draft-pr-918b180b
Draft

Dmitriy Vasyura (dmitrivMS) wants to merge 7 commits into
mainfrom
agents/address-copilot-feedback-draft-pr-918b180b

Conversation

@dmitrivMS

@dmitrivMS Dmitriy Vasyura (dmitrivMS) commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #336152

Follow-up to #336159

Retry task-handle resolution without activating unrelated providers when the typed lookup misses. A task definition's type can differ from its provider registration type, so the fallback resolves the handle from tasks already known to the task service. The known-task lookup preserves workspace and user-task matching, and the fallback remains skipped when workspace trust was denied. Task matching consistently ranks extension tasks last and preserves order among equal ranks.

Testing

  • pnpm run build-fast --client-only — passed.
  • scripts\test.bat --run src/vs/workbench/api/test/browser/mainThreadTask.test.ts --run src/vs/workbench/contrib/tasks/test/browser/abstractTaskService.test.ts — passed (23 tests), covering typed lookup/fallback behavior, denied trust, workspace/user precedence in both getTask lookup phases, and stable equal-rank ordering.
  • pnpm run typecheck-client — passed.
  • pnpm run eslint -- src/vs/workbench/contrib/tasks/test/browser/abstractTaskService.test.ts — passed.
  • pnpm run compile — passed before these follow-up changes.
  • Code OSS runtime check — earlier change verified typed task execution and a mismatched definition-type fallback; the later known-only fallback and ordering refinements were validated with focused unit tests.

A task definition's type can differ from its provider registration type, so retry an unfiltered lookup only when the typed lookup misses. Cover both task execution API paths.

Co-authored-by: Copilot <[email protected]>
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added bug Issue identified by VS Code Team member as probable bug tasks Task system issues labels Nov 9, 2026
Copilot AI balanced review requested due to automatic review settings November 9, 2026 11:21
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch and removed bug Issue identified by VS Code Team member as probable bug labels Nov 9, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.146 when merged.

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.

🟡 Changes recommended

The task-resolution fallback can immediately reopen the workspace trust prompt after the user cancels it because it treats a trust-denied lookup as a missing task.

1 open issue
What changed in this PR

This follow-up to #336159 restores task-handle resolution when a task’s definition type differs from its provider registration type, while keeping typed lookup as the first attempt.

Changes:

  • Add a shared untyped fallback for $getTaskExecution and $executeTask when typed lookup misses.
  • Add focused regression tests for both entry points.
File Description
src/​vs/​workbench/​api/​test/​browser/​mainThreadTask.test.ts Tests typed lookup misses followed by successful untyped resolution.
src/​vs/​workbench/​api/​browser/​mainThreadTask.ts Shares fallback lookup logic between task execution entry points.

Review effort: Balanced

Task lookup returns undefined when workspace trust is denied. Avoid the untyped retry unless the workspace is trusted, preventing a second trust prompt.

Co-authored-by: Copilot <[email protected]>

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.

🟡 Changes recommended

The new cases lack successful typed-lookup assertions for both operations, so they would miss a regression that unnecessarily activates every task provider.

1 open issue
1 resolved since last review

Review effort: Max

Verify both task execution APIs return a task from the typed lookup without issuing an unfiltered retry.

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 6cde0f16 Current: 7f23b483

Changed (1)

chat/aiCustomizations/aiCustomizationManagementEditor/DiscoverSearchLoading/Light
Before After
before after

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.

🔵 Needs a closer look

The untyped task-resolution retry can activate unrelated task-provider extensions for mismatched provider types or stale handles, reintroducing the reported activation overhead.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Avoid activating unrelated providers during task lookup fallback

src/​vs/​workbench/​api/​browser/​mainThreadTask.ts:654

When a provider task's definition type differs from its registered type, this untyped retry activates unrelated task-provider extensions, restoring the activation cost reported in #336152. Stale handles can incur the same cost before failing with "Task not found". Resolve the fallback against already-registered providers, for example through getKnownTasks(), while preserving the existing ID, workspace, and user-task matching.

1 resolved since last review

Review effort: Max

Resolve typed task-handle misses from tasks already known to the service, preserving workspace and user-task matching without activating unrelated providers.

Co-authored-by: Copilot <[email protected]>

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.

🟡 Changes recommended

The comparator can make selection among non-extension tasks sort-dependent, and the denied-trust test can pass even if the trust guard is removed.

2 open issues

Review effort: Max

Use a consistent two-argument comparator to rank extension tasks last while preserving order among equal ranks. Strengthen denied-trust tests to ensure known-task fallback is not called.

Co-authored-by: Copilot <[email protected]>

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.

🟡 Changes recommended

The changed getTask ordering lacks tests for equal-rank workspace/user matches in both lookup phases, leaving command-selection precedence unverified for callers such as debug task execution.

2 open issues
2 resolved since last review

Review effort: Max

Exercise workspace-versus-user task selection in both getTask lookup phases and use matching non-extension tasks in the known-task precedence test.

Co-authored-by: Copilot <[email protected]>

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.

🔵 Needs a closer look

Human judgment is needed to assess whether the changed workspace-versus-user task precedence, which can alter debug preLaunchTask selection, is intentional.

No open issues 🎉

2 resolved since last review

Review effort: Max

@dmitrivMS Dmitriy Vasyura (dmitrivMS) removed the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tasks Task system issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

executeTask() activates *all* extensions with a task provider when the task came from fetchTasks()

2 participants