Support auto-cljs-build-switching
Calva currently lets me manually switch between two running shadow-cljs builds (:app for the browser, :server for a Node-based service) via the status-bar toggle or by evaluating but it does not change the active build automatically when I jump between files that belong to different builds. Unlike what happens with clj projects.
Reproduction steps
-
Create a single shadow-cljs.edn with two builds:
{:builds {:app {:target :browser :source-paths ["src/app"]} :server {:target :node-script :source-paths ["src/server"]}}}
-
Start both builds
npx shadow-cljs -d watch :app :server, runnode path/to/server.jsand then connect Calva. -
Open src/app/core.cljs → evaluate form → works (build = :app).
-
Open src/server/core.cljs → evaluate form → either fail or will print in the
:apprepl because it's still connected to the:apprepl.
If you manually switch to :server it will print on the node ... terminal.
Expected behaviour
Calva should automatically switch the active shadow-cljs build (and thus the CLJS REPL it clones) based on the file I am editing—ideally by matching the file’s path to the :source-paths configured for each build.
Actual behaviour
The build remains whatever was last selected; manual switching is required each time. Why it matters
See discussion at https://clojurians.slack.com/archives/CBE668G4R/p1750499391908279
Thanks for this issue! I think it would be great if Calva behaved like you suggest. The problem is that this part of Calva is very messy, and very stateful, so it is not the easiest feature to get in there. But with some focused time, we should be able to get it done.