feat: support temp_script_refs in wmill dev for local relative imports#9554
Draft
hugocasa wants to merge 2 commits into
Draft
feat: support temp_script_refs in wmill dev for local relative imports#9554hugocasa wants to merge 2 commits into
hugocasa wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploying windmill with
|
| Latest commit: |
d9213b0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://feda0d79.windmill.pages.dev |
| Branch Preview URL: | https://hugo-win-2038-support-temp-s.windmill.pages.dev |
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.
Summary
Fixes WIN-2038.
When using
wmill dev, previews of scripts/flows with relative imports to scripts that haven't been deployed yet (or have local edits) failed or used stale deployed code, because the dev page'srunScriptPreview/runFlowPreviewcalls didn't includetemp_script_refs. This was already supported inwmill script preview,wmill flow preview, andwmill app devviabuildPreviewTempScriptRefs().This PR computes the refs at
wmill devstartup (mirroring thewmill app devsnapshot pattern), sends them through the WebSocket → browser chain, and plumbs them into the preview API calls.Design note: unlike
wmill app dev, the previewed item inwmill devcan change at runtime (path picker /loadWmPath), so there is no single anchor node to filter refs by. Instead a new{ kind: "all" }target onbuildPreviewTempScriptRefsreturns the refs for all locally-diverged scripts (uploaded once at startup), and the same map rides on every preview run. This is a superset of the per-target map for any node, and the backend only looks up the imports it actually needs, so extra entries are inert. It also means imports added live in the dev page editor still resolve, as long as the target script existed at startup.Known limitation (same as
wmill app dev): the refs are a startup snapshot — restartwmill devto pick up later edits to imported workspace scripts. This is surfaced in the startup log line.Changes
cli/src/utils/dependency_tree.ts: newgetAllTempScriptRefs()returning path → contentHash for every uploaded node.cli/src/commands/generate-metadata/generate-metadata.ts:buildPreviewTempScriptRefsaccepts{ kind: "all" }(no anchor node; tree-wide refs).cli/src/commands/dev/dev.ts: computes the refs once at startup (graceful degradation on older backends without/raw_temp), addstemp_script_refstoLastEditScript/LastEditFlowand to all four WS message construction sites (loadPaths/loadWmPath× script / flow).frontend/src/lib/components/Dev.svelte: stores the refs from WS messages; passes them on script Test runs; exposes them to the flow editor tree via a new optionaldevTempScriptRefsgetter onFlowEditorContext. Flow refs are deliberately kept outside the flow object so the flow.yaml round-trip back to the CLI is never polluted.frontend/src/lib/components/flows/types.ts: optionaldevTempScriptRefsonFlowEditorContext(only set by the dev page; regular flow editor unaffected).frontend/src/lib/components/JobLoader.svelte:runPreviewtakes optionaltempScriptRefs→temp_script_refsin the request body.frontend/src/lib/components/flows/utils.svelte.ts+FlowPreviewContent.svelte: whole-flow / up-to previews pass the refs toJobService.runFlowPreview.frontend/src/lib/components/ModuleTest.svelte: single-step (rawscript) tests in the dev page pass the refs too.cli/test/dependency_tree_unit.test.ts: unit tests forgetAllTempScriptRefs(all-uploaded, partial, superset-of-per-node semantics).Test plan
UNIT_ONLY=1 bun test test/*_unit*— 856 pass (includes 3 new tests).bunx tsc --noEmitincli/— no new errors (pre-existing errors untouched).npm run checkinfrontend/— 0 errors.f/devtest/lib.ts(never deployed) andf/devtest/main.tsimporting./lib.ts; ranwmill dev→ startup logsResolved 2 locally-edited script(s) for preview relative imports; script Test on the dev page returnshello from LOCAL lib, worldand the/jobs/run/previewrequest body containstemp_script_refs.../lib.ts— Test flow succeeds withhello from LOCAL lib, flowworld;/jobs/run/preview_flowbody containstemp_script_refs; the flow.yaml written back by the dev round-trip contains notemp_script_refskey./raw_temp:wmill devprints the yellow fallback warning and previews still run against deployed versions (not exercised locally — degradation path is the existing sharedbuildPreviewTempScriptRefscatch).Screenshots
Script preview on the dev page resolving a relative import from a never-deployed local script:
Flow preview with an inline script importing the same local lib:
🤖 Generated with Claude Code
Summary by cubic
Adds
temp_script_refstowmill devso script and flow previews resolve relative imports from local, not-yet-deployed files. Fixes WIN-2038 to eliminate stale code in dev previews.wmill devstartup usingbuildPreviewTempScriptRefs({ kind: "all" }), send via WS, and include in all preview runs (scripts, flows, module tests).getAllTempScriptRefs; include refs inLastEditScript/LastEditFlowand WS messages; graceful fallback on older backends without/raw_temp.JobService.runPreview/runFlowPreview; exposedevTempScriptRefsinFlowEditorContextwithout touchingflow.yaml.getAllTempScriptRefs.wmill devto pick up later edits to imported workspace scripts.Written for commit d9213b0. Summary will update on new commits.