fix(v3/wake): propagate included Taskfile vars so preconditions expand correctly
Problem
When wake resolves includes:, it clones tasks from the included Taskfile into the parent but silently drops the included file's top-level vars: block. This caused two visible failures:
- Garbled error message —
{{.CROSS_IMAGE}}appeared literally in the error box instead of the image namewails-cross. - Cross-compilation fully broken — The precondition shell command ran as
docker image inspect {{.CROSS_IMAGE}}, which always fails regardless of whether the image exists. So even after runningwails3 task setup:docker, thelinux:build:dockertask would refuse to run.
The same bug affects darwin/Taskfile.yml and windows/Taskfile.yml, which also define CROSS_IMAGE as a top-level var.
Root cause
resolveIncludes in parse/parse.go (line 468) only copies tasks:
for taskName, task := range tfResolved.Tasks {
namespaced := name + ":" + taskName
tf.Tasks[namespaced] = task.Clone() // included file's Vars never propagated
}
mergeVars at execution time has three sources: root tf.Vars, depVars, and task.Vars. None of them contain the included file's CROSS_IMAGE.
Additionally, checkPreconditions was called before mergeVars ran, and used pc.Sh/pc.Msg raw without template expansion — so even if vars had been available, they wouldn't have been applied.
Changes
| File | Change |
|---|---|
parse/parse.go |
Inject included file's top-level Vars into each cloned task's Vars map. Task-own vars have higher priority. |
exec/runner.go |
checkPreconditions now accepts vars map[string]*ast.Var and calls parse.ExpandTemplates on both pc.Sh and pc.Msg. |
exec/exec.go |
Move mergeVars call before checkPreconditions so the merged variable map is available for expansion. |
parse/parse_test.go |
Regression test verifying top-level vars from included files propagate into all cloned tasks, and task-level vars still win. |
Testing
go test ./internal/wake/... # all pass
Summary by CodeRabbit
- Bug Fixes
- Precondition evaluation now has access to merged task and dependency variables
- Precondition failure messages now support variable interpolation
- Top-level variables from included taskfiles are now properly propagated to cloned tasks
[!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_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
Walkthrough
This PR merges included taskfile vars into cloned tasks, uses merged vars during precondition checks, and adds Experimental/Wake documentation with sidebar navigation.
Changes
Variable propagation and Wake docs
| Layer / File(s) | Summary |
|---|---|
Inject included taskfile vars into cloned tasks v3/internal/wake/parse/parse.go, v3/internal/wake/parse/parse_test.go |
resolveIncludes clones each included task into cloned, merges the included taskfile's top-level vars into cloned.Vars with task-local vars taking priority, then stores the result. Regression test asserts CROSS_IMAGE propagates to cloned tasks while OWN_VAR is preserved and injected vars remain deep-copied. |
Precondition evaluation with merged variables v3/internal/wake/exec/exec.go, v3/internal/wake/exec/runner.go |
runTask now computes mergedVars only when preconditions exist and reuses that map after the cache check. checkPreconditions expands precondition failure messages with the provided vars before building the returned error. |
Experimental and Wake documentation docs/astro.config.mjs, docs/src/content/docs/experimental/index.mdx, docs/src/content/docs/experimental/wake.mdx |
The docs sidebar gains an Experimental section, a new Experimental landing page is added, and a Wake page documents the feature's behavior, fallback rules, variables, and feedback links. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
- wailsapp/wails#5612: Shares the same Wake precondition flow changes around merged task vars and template expansion in
checkPreconditions.
Suggested labels
reviewed ✅
Poem
🐇 I hop through vars both near and far,
Through Wake and docs beneath the star,
Includes now bloom with merged delight,
And preconditions read just right,
Experimental paths now shine—
A tidy burrow, all in line!
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| 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 (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | It clearly summarizes the main fix: propagating included Taskfile vars so preconditions expand correctly. |
| Description check | ✅ Passed | It includes a solid summary, root cause, code changes, and testing, though it omits the explicit Fixes # issue reference. |
| 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
- [ ] Commit unit tests in branch
fix/wake-cross-image-var-resolution
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.
Comment @coderabbitai help to get the list of available commands.
Addressed review feedback in 011f37806:
-
Shared mutable state (Copilot inline) — the injected top-level include vars are now deep-copied into each cloned task (matching `Task.Clone`), so in-place mutation by `ResolveVars`/`ResolveAllVarShells` can no longer leak across tasks that share the same included file. The regression test now also asserts distinct pointers and isolation under mutation.
-
`mergeVars` overhead for cached tasks (Copilot low-confidence note) — `mergedVars` is now computed lazily. Tasks with no preconditions that turn out to be up-to-date skip the fixed-point template expansion entirely; preconditions still get the merged map when present, before the up-to-date check.
go test ./internal/wake/... and go vet ./internal/wake/... both pass.
@coderabbitai full review
Full review finished.✅ Action performed
Re-reviewed the current state after merging master. CodeRabbit's full re-review just came back clean (no actionable comments), and the prior bot feedback is all resolved:
- Copilot —
parse.go, shared mutable state: resolved. Included-file vars are now deep-copied (vClone := *v) likeTask.Clone, with a regression assertion (distinct pointers + mutation isolation). Thread resolved. - Copilot —
exec.go,mergeVarsoverhead on cached tasks (low-confidence note): resolved.mergedVarsis computed lazily, so a task with no preconditions that turns out to be up-to-date skips the fixed-point expansion entirely.
One thing worth a reviewer's eye, since the master merge overlapped this code — master independently landed the precondition-templating (.OBFUSCATED) work in the same functions:
runner.go: took master's version (it expandsshbefore the empty-string check); my earlier change became a duplicate line and was dropped.exec.go: kept the lazymergeVars(the response to Copilot's perf note) and folded master's.OBFUSCATEDrationale into the comment. Net behaviour matches master for tasks with preconditions, and additionally skips the merge for preconditionless cached tasks.docs/astro.config.mjs: purely additive — kept master's new Mobile section (incl. "Mobile API") alongside the new Experimental section.
go test ./internal/wake/... passes and the docs build (with link validation) is clean on the merged tree.