Forward CLI extra args only to explicitly requested tasks#332
Merged
branchseer merged 3 commits intomainfrom Apr 14, 2026
Merged
Forward CLI extra args only to explicitly requested tasks#332branchseer merged 3 commits intomainfrom
branchseer merged 3 commits intomainfrom
Conversation
Extra arguments passed after a task name (e.g. `vp run test some-filter`) were forwarded to every task in the execution graph, including tasks pulled in via `dependsOn`. For the common `test -> build` or `check -> build` pattern this meant `build` received caller-specific arguments (filters, file paths, etc.) that only made sense for the requested task. Track which nodes in `TaskExecutionGraph` are explicitly requested — i.e. added by `map_subgraph_to_tasks` (stage 2) — versus those added only via `dependsOn` expansion in `add_dependencies` (stage 3). The planner now applies `extra_args` per-task: requested tasks see the CLI extras; dependency-only tasks get an empty slice. Closes #324
…Graph Address review feedback on the extra-args forwarding fix: - Reword the CHANGELOG entry in plain terms; drop jargon like "requested task" and "build-before-test". - Illustrate the `requested` field on `TaskExecutionGraph` with a concrete `vp run test some-filter` example so the purpose is obvious at a glance.
There was a problem hiding this comment.
Pull request overview
This PR fixes vp run <task> <extra-args...> behavior so that extra CLI args are forwarded only to tasks explicitly requested by the user, and not to tasks that are included solely via dependsOn expansion (fixes #324).
Changes:
- Extend the task query result to track which task nodes were explicitly requested vs. added via
dependsOn. - Apply
extra_argsper task during planning based on that “requested” set, using an empty args slice for dependency-only tasks. - Add a snapshot fixture verifying extra args reach only the requested task and do not reach its
dependsOndependency.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/vite_task_graph/src/query/mod.rs | Changes TaskExecutionGraph to track both the graph and explicitly requested nodes. |
| crates/vite_task_plan/src/plan.rs | Applies extra args per task based on the requested set while building the execution graph. |
| crates/vite_task_plan/tests/plan_snapshots/** | Adds a fixture + snapshots proving extra args aren’t forwarded to dependsOn tasks. |
| CHANGELOG.md | Documents the user-visible behavior change for vp run extra args forwarding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Downgrade broken intra-doc link on `TaskExecutionGraph` to plain backticks: `Self::add_dependencies` resolved against the wrong type (the method lives on `IndexedTaskGraph`), and a private-item link would still trip `-D rustdoc::private-intra-doc-links`. - Hoist `empty_extra_args: Arc<[Str]>` above the per-task planning loop so dep-only tasks share a single empty `Arc` instead of allocating one each.
fengmk2
approved these changes
Apr 14, 2026
Member
fengmk2
left a comment
There was a problem hiding this comment.
bugfix includes breaking changes 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for users
Arguments typed after a task name on
vp runare now forwarded only to that task. Tasks pulled in viadependsOnno longer receive them.Before
Given
vite-task.json:{ "tasks": { "test": { "command": "vitest", "dependsOn": ["build"] }, "build": { "command": "tsc" } } }Running:
…would invoke:
test→vitest some-filter✅build→tsc some-filter❌ —tschas no idea whatsome-filtermeans and fails (or worse, silently interprets it as a source file).After
The same command now invokes:
test→vitest some-filter✅build→tsc✅ — runs with its own config, unaffected by the caller's CLI.This matches the intuitive mental model most users already had: "positional args I type after
testare fortest." It also fixes a subtle cache-invalidation side effect — dependency tasks used to incorporate the caller's extra args into their cache key, sovp run test fooandvp run test bareach produced a distinctbuildcache entry even thoughbuildran identically in both cases. Dependency tasks now cache under a stable key regardless of what the caller typed.Scope
Only explicit
dependsOndependencies are affected. Tasks pulled in via topological (-r,-t) or package-graph expansion still receive the extras, because each of those packages runs the same task name the user typed —vp run -r test some-filterstill forwardssome-filterto every selected package'stest, which is the intended behavior.No config changes or flags are required; the new behavior applies unconditionally.
Implementation notes
TaskExecutionGraph(incrates/vite_task_graph/src/query/mod.rs) changed from atypealias forDiGraphMap<TaskNodeIndex, ()>into a smallpub structwith two public fields: the samegraph, plus arequested: FxHashSet<TaskNodeIndex>tracking the stage-2 (user-requested) nodes.map_subgraph_to_taskspopulatesrequested;add_dependencies(stage 3,dependsOnexpansion) deliberately does not.plan_query_request(incrates/vite_task_plan/src/plan.rs) no longer setsextra_argsglobally on the planning context. Instead, it duplicates the context per task and sets either the realextra_argsor a shared emptyArc<[Str]>based onrequested.contains(&task_index).extra-args-not-forwarded-to-depends-onrecords the observable behavior:test's spawn args and cache key includesome-filter, whilebuild's do not.Fixes #324
https://claude.ai/code/session_01Hay4ywHGNEzjuh1WW5SnBr