Skip to content

Forward CLI extra args only to explicitly requested tasks#332

Merged
branchseer merged 3 commits intomainfrom
claude/fix-issue-324-PMzKS
Apr 14, 2026
Merged

Forward CLI extra args only to explicitly requested tasks#332
branchseer merged 3 commits intomainfrom
claude/fix-issue-324-PMzKS

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented Apr 14, 2026

What changes for users

Arguments typed after a task name on vp run are now forwarded only to that task. Tasks pulled in via dependsOn no longer receive them.

Before

Given vite-task.json:

{
  "tasks": {
    "test": { "command": "vitest", "dependsOn": ["build"] },
    "build": { "command": "tsc" }
  }
}

Running:

vp run test some-filter

…would invoke:

  • testvitest some-filter
  • buildtsc some-filter ❌ — tsc has no idea what some-filter means and fails (or worse, silently interprets it as a source file).

After

The same command now invokes:

  • testvitest some-filter
  • buildtsc ✅ — 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 test are for test." It also fixes a subtle cache-invalidation side effect — dependency tasks used to incorporate the caller's extra args into their cache key, so vp run test foo and vp run test bar each produced a distinct build cache entry even though build ran identically in both cases. Dependency tasks now cache under a stable key regardless of what the caller typed.

Scope

Only explicit dependsOn dependencies 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-filter still forwards some-filter to every selected package's test, which is the intended behavior.

No config changes or flags are required; the new behavior applies unconditionally.


Implementation notes

  • TaskExecutionGraph (in crates/vite_task_graph/src/query/mod.rs) changed from a type alias for DiGraphMap<TaskNodeIndex, ()> into a small pub struct with two public fields: the same graph, plus a requested: FxHashSet<TaskNodeIndex> tracking the stage-2 (user-requested) nodes.
  • map_subgraph_to_tasks populates requested; add_dependencies (stage 3, dependsOn expansion) deliberately does not.
  • plan_query_request (in crates/vite_task_plan/src/plan.rs) no longer sets extra_args globally on the planning context. Instead, it duplicates the context per task and sets either the real extra_args or a shared empty Arc<[Str]> based on requested.contains(&task_index).
  • New plan snapshot fixture extra-args-not-forwarded-to-depends-on records the observable behavior: test's spawn args and cache key include some-filter, while build's do not.

Fixes #324

https://claude.ai/code/session_01Hay4ywHGNEzjuh1WW5SnBr

claude added 2 commits April 14, 2026 10:03
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.
@branchseer branchseer requested a review from Copilot April 14, 2026 10:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_args per 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 dependsOn dependency.

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.
@branchseer branchseer requested a review from fengmk2 April 14, 2026 10:43
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

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

bugfix includes breaking changes 😄

@branchseer branchseer merged commit 65504c9 into main Apr 14, 2026
9 checks passed
@branchseer branchseer deleted the claude/fix-issue-324-PMzKS branch April 14, 2026 14:45
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.

Proposal: do not forward extra vp run arguments to dependsOn tasks by default

4 participants