calva icon indicating copy to clipboard operation
calva copied to clipboard

Support auto-cljs-build-switching

Open enigma opened this issue 8 months ago • 1 comments

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

  1. 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"]}}}

  2. Start both builds npx shadow-cljs -d watch :app :server, run node path/to/server.js and then connect Calva.

  3. Open src/app/core.cljs → evaluate form → works (build = :app).

  4. Open src/server/core.cljs → evaluate form → either fail or will print in the :app repl because it's still connected to the :app repl.

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

enigma avatar Jun 21 '25 11:06 enigma

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.

PEZ avatar Jun 21 '25 11:06 PEZ