Repository navigation
Description
Part of #3322 (Tauri extension points for the desktop app).
Summary
Split packages/desktop-app/src-tauri into two packages. Today it is one package, nodespace-app, with lib nodespace_app_lib and bin nodespace-app.
- Library
nodespace-app-lib, atpackages/desktop-app/app-lib. Cratenodespace_app_lib,rlibonly. It holds:- every module under
src/exceptmain.rs; - the
tests/itTauri-seam suite; test-support;- until Delete the vendored nodespace_pro.proto, its build.rs step and its build-only deps #3335, the vendored Pro proto and its compile step.
- every module under
- App crate
nodespace-app, staying atpackages/desktop-app/src-tauri. It holdsmain.rs,build.rs,build_support.rs(until Move the bundle-staging build helpers into a nodespace-app-build crate #3305),tauri.conf.json,tauri.pro.conf.json,capabilities/,icons/,binaries/,resources/andgen/.
This is a move. The only code change is the one the split forces: generate_context!() must expand in the crate that owns tauri.conf.json, so run() now takes the tauri::Context from main.rs. Behaviour does not change.
This is ADR-082 (proposed) §3.1. It lets an app crate outside core depend on core's desktop library without running core's build script or embedding core's config and frontend.
Context (lines at af8ddb6)
src-tauri/Cargo.toml
[lib](9-11) hascrate-type = ["staticlib", "cdylib", "rlib"], which comes from Tauri's mobile template. There is no mobile target:gen/holds onlyschemas/.[build-dependencies](13-21):tauri-build, the Pro-prototonic-buildandprotoc-bin-vendored, andserde_json.[[bin]](23-25),[features] devtools(33-34),[dependencies](36-68),[dev-dependencies](70-80).
src/lib.rs run() (311-870)
#[cfg_attr(mobile, tauri::mobile_entry_point)](311).#[cfg(desktop)]around the single-instance plugin (344)..build(tauri::generate_context!())(862).
build.rs main() (172-200)
- The Pro proto step (173-192), then
sync_external_bin_staging(),drop_unstaged_bundle_entries()andtauri_build::build().
Two things tauri_build does that the split has to preserve
- The
desktop/mobilecfg aliases (tauri-build 2.6.2lib.rs206-210, 476-477). A library without them compiles#[cfg(desktop)]code out silently, which would drop the single-instance guard. - Permission files, from direct dependencies only.
capabilities/default.jsongrantsopener:defaultanddialog:default.- So the app crate must keep
tauri-plugin-openerandtauri-plugin-dialogas direct dependencies. Otherwisevalidate_capabilitiesfails the build.
Paths built from CARGO_MANIFEST_DIR
These keep working, because app-lib is at the same depth as src-tauri:
skill_setup.rs:source_checkout_installer_candidateand the compiled-installer test (~1349);daemon_setup.rs:pkg_plist_matches_app_plist_tests(~2492);- test-support:
workspace_root()(~379).
Two test-support paths break and must be fixed:
- the sidecar fallback
CARGO_MANIFEST_DIR/../binaries(~517-520); #[path = "../../build_support.rs"](50).
Tooling that names the crate or its paths
- Root
Cargo.tomlmembers (2-12). - Root
package.json:rust:test:build(71) andrust:test:workspace(72). scripts/test-app-units.ts: the cargo call (187-201).scripts/test-gate.ts: the Tauri-seam compile (254) and run (304) stages.scripts/gate-scope.tsRUST_DIRS(35-44). Without an entry, a change underapp-lib/falls into thepackages/desktop-app/branch and counts as frontend-only, sotest:changedwould skip Rust.scripts/refresh-pro-proto.ts: its destination path (~30-35).
What must not move
- sync's Pro build runs
bunx tauri build --config src-tauri/tauri.pro.conf.jsoninpackages/desktop-app. - It stages files into
src-tauri/binariesandsrc-tauri/resources/models. - The bundle executable is
nodespace-app.
All of these stay put. option_env!("NODESPACE_PRO_SUPABASE_URL") in daemon_setup.rs is still evaluated from the same build environment.
Scope
1. Moves (git mv, in their own commit)
src-tauri/src/*exceptmain.rs→app-lib/src/src-tauri/tests/→app-lib/tests/src-tauri/test-support/→app-lib/test-support/src-tauri/proto/→app-lib/proto/
2. New packages/desktop-app/app-lib/Cargo.toml
[package]:name = "nodespace-app-lib",version.workspace = true,edition.workspace = true,publish = false, and a description.[lib]:name = "nodespace_app_lib"andcrate-type = ["rlib"], with a one-line comment saying there is no mobile target.[dependencies]: every entry from today's[dependencies], moved verbatim with its comments.[build-dependencies]:tonic-buildandprotoc-bin-vendored, moved verbatim with their comment.[dev-dependencies]: today's three entries, withnodespace-app-test-support = { path = "test-support" }.
3. New packages/desktop-app/app-lib/build.rs
-
The Pro proto step, moved verbatim from
src-tauri/build.rs. Delete the vendored nodespace_pro.proto, its build.rs step and its build-only deps #3335 deletes it. -
A
cfg_aliashelper that mirrors tauri-build's:- for
desktopandmobile, printcargo:rustc-check-cfg=cfg(<alias>); - print
cargo:rustc-cfg=desktopunlessCARGO_CFG_TARGET_OSisiosorandroid.
Add a comment explaining that
#[cfg(desktop)]guards the single-instance plugin. - for
-
No
tauri_buildcall. The library has notauri.conf.json.
4. Library code (the only edits)
run():- drop the
mobile_entry_pointattribute; - change the signature to
pub fn run(context: tauri::Context<tauri::Wry>); - replace
.build(tauri::generate_context!())with.build(context); - add one doc line saying the app crate supplies the context.
- drop the
test-support/Cargo.toml:nodespace-app-lib = { path = ".." }. The crate namenodespace_app_libis unchanged, so theuselines stay.test-support/src/lib.rs:- change the include to
#[path = "../../../src-tauri/build_support.rs"](Move the bundle-staging build helpers into a nodespace-app-build crate #3305 replaces it); - the sidecar fallback becomes
CARGO_MANIFEST_DIR/../../src-tauri/binaries.
- change the include to
- Comments that name a moved path: update them.
5. App crate packages/desktop-app/src-tauri
Cargo.toml
- Keep
[package], including its hard-codedversion(whichscripts/check-version-sync.tsreads) anddefault-run. - Keep
[[bin]]and[features] devtools. - Remove
[lib]and[dev-dependencies]. [dependencies]:nodespace-app-lib = { path = "../app-lib" };tauri = { version = "2", features = [] }, whichtauri_build's manifest check andgenerate_context!need;tokio = { workspace = true }, becausemain.rsbuilds the runtime;tauri-plugin-opener = "2"andtauri-plugin-dialog = "2", with a comment saying they are here only for their permission files.
[build-dependencies]:tauri-buildandserde_json.
build.rs: delete the Pro proto block, which moved. The rest is unchanged.
src/main.rs: runtime.block_on(async { nodespace_app_lib::run(tauri::generate_context!()) }). Nothing else changes.
6. Workspace and tooling
-
Root
Cargo.tomlmembers: addpackages/desktop-app/app-libandpackages/desktop-app/app-lib/test-support, and droppackages/desktop-app/src-tauri/test-support. -
Root
package.json. The library links Tauri, so it followsnodespace-app's platform handling:rust:test:build: add--exclude nodespace-app-libto the nextest part, and-p nodespace-app-libto thecargo test --lib --binspart;rust:test:workspace: add--exclude nodespace-app-lib.
-
scripts/test-app-units.ts: add-p nodespace-app-liband update the doc. Keep the prerequisite check, because the bin still runstauri_build. -
scripts/test-gate.ts: change both-p nodespace-app --test itto-p nodespace-app-lib --test it, and update their comment. -
scripts/gate-scope.ts: add"packages/desktop-app/app-lib/"toRUST_DIRS. Inscripts/gate-scope.test.ts, addpackages/desktop-app/app-lib/src/lib.rsto the "counts as a Rust input" cases. -
scripts/refresh-pro-proto.ts: set the destination toapp-lib/proto/nodespace_pro.proto. -
packages/desktop-app/vite.config.js: add"**/app-lib/**"toserver.watch.ignored. ESLint and Vitest look only atsrc/, so they need no change. -
Comments that point at
src-tauri/src/…orsrc-tauri/tests/…: point them atapp-lib/…. They are in:packages/cli/src/lib.rs;packages/daemon/tests/it/grpc_round_trip.rs;packages/nodespace-types/src/schema.rs;packages/desktop-app/src/lib/services/backend-adapter.ts;src/tests/e2e/adapter-contract.e2e.ts;src/tests/services/dev-proxy-*.test.ts;packages/dev-tools/src/*;packages/skill/src/install.tsandpackages/skill/README.md;scripts/build-skill.tsandscripts/publish-skill-repo.ts.
Leave historical mentions alone, such as nodespace-types' "previously lived in
src-tauri/src/types.rs". -
CLAUDE.mdrepo tree (~356): addapp-lib/(the Tauri app library: commands, services, entry point), and describesrc-tauri/as the app crate (main.rs,build.rs, config, icons, sidecars). -
scripts/check-pro-boundary.ts(Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299): if it names a moved path in an exclusion list, update it.
Out of scope
AppExtensionsandassemble(Add AppExtensions with Tauri-plugin support and a runtime-generic assemble() #3304), andrun(extensions, context)(Route the desktop app through run(extensions, context) with no extensions in core #3306).- The build-helper crate (Move the bundle-staging build helpers into a nodespace-app-build crate #3305).
- Moving
capabilities/(Have the app library add core's window capability at startup #3308). - Deleting any Pro code (Delete the pro_* commands, ProClient, startup Pro probe and Pro rebind from core #3334, Delete the vendored nodespace_pro.proto, its build.rs step and its build-only deps #3335).
- Renaming the
nodespace-apppackage or bin. sync's scripts and the bundle's executable depend on it.
Steps
- Run the CLAUDE.md startup sequence. Self-assign at pickup; the worktree is
issue-<N>-split-desktop-tauri-crate. - Record the test counts before the split:
cargo test --lib --bins -p nodespace-app -p nodespace-app-test-support -- --list | grep -c ': test';- the same count for
--test it.
- Commit the
git mvmoves on their own. - Commit the manifests, both
build.rsfiles,run(context),main.rsand the test-support paths. - Commit the tooling and comment updates.
- Build, lint and test with the commands below. The test counts must match step 1.
- Run the Pro-mode compile check.
- Smoke-test:
- Run
bun run dev:tauriagainst the dev daemon and socket. While it runs, edit a comment in anapp-libfile and confirm the app rebuilds. If it doesn't, add"../app-lib"tobuild.additionalWatchFoldersintauri.conf.json. - When the shared machine is quiet, run
bun run --cwd packages/desktop-app tauri:build. Check that the bundle containsnodespaced,nodespace,nodespace-skill-installerand the skill resources, and that it launches.
- Run
- Run
bun run scripts/check-pro-boundary.tsandbun run quality:fix, thenbun run test:changed. Gate files changed, so every tier runs: start it when the machine is free.
Acceptance criteria
-
app-libbuildsnodespace_app_libasrlibonly. It has notauri.conf.json, nogenerate_context!and notauri_buildcall. -
src-tauriholds onlysrc/main.rs,build.rs,build_support.rs(until Move the bundle-staging build helpers into a nodespace-app-build crate #3305), the configs,capabilities/,icons/,binaries/,resources/,gen/and.gitignore. - The entry point is
run(context), andmain.rsexpandsgenerate_context!(). - The new test
desktop_cfg_alias_is_set(assertingcfg!(desktop)) passes. Removing the alias fromapp-lib/build.rsmakes it fail. - Every existing unit test and Tauri-seam test passes from its new location, and the counts match step 1.
-
gate-scopeclassifiespackages/desktop-app/app-lib/…as Rust, and a test covers that. -
bun run rust:testruns the library's unit tests. - The merge gate's Tauri-seam stage runs
-p nodespace-app-lib --test it. - The Pro-mode
cargo check -p nodespace-apppasses. - The free-app smoke test passes.
- The
tauri:buildbundle contents are unchanged. -
git grep -n -e 'src-tauri/src/' -e 'src-tauri/tests' -e 'src-tauri/test-support'returns only references tosrc-tauri/src/main.rsand historical mentions. -
bun run scripts/check-pro-boundary.tspasses.BASELINESare unchanged (moves keep the counts), or lowered to the exact new counts wherever this PR removes markers, and no count rises. - No GitHub issue numbers in code comments.
Tests and verification
- New test:
desktop_cfg_alias_is_set, inapp-lib/src/tests.rs. - New case: the
app-libcase ingate-scope.test.ts. - Existing suites all run from their new locations.
Mutation-check each new test: break the code path it covers, confirm the test fails, then restore.
cargo check -p nodespace-app-lib -p nodespace-app
cargo test --lib --bins -p nodespace-app-lib -p nodespace-app -p nodespace-app-test-support -- --test-threads=2
cargo build --bin nodespaced && NODESPACED_TEST_BIN="$PWD/target/debug/nodespaced" cargo test -p nodespace-app-lib --test it -- --test-threads=1
cargo clippy -p nodespace-app-lib -p nodespace-app -p nodespace-app-test-support --all-targets -- -D warnings -D clippy::unused-async
NODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=dummy cargo check -p nodespace-app
bun test scripts/gate-scope.test.ts
bun run scripts/check-pro-boundary.ts
bun run test:changed
Note: cargo test --lib -p nodespace-app on its own now errors with "no library targets". Use --bins for the app crate.
Dependencies
- NodeSpaceAI/nodespace-docs#90 (ADR-082): ADR-082 §3.1 is accepted.
- Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299: the Pro-boundary ratchet exists.
Downstream
#3318, #3319 to #3335, #3346 to #3355, #3360 and #3363 cite packages/desktop-app/src-tauri/src/…, src-tauri/tests/it or src-tauri/build.rs (the proto step). After this PR:
- library code is under
app-lib/src/; - the seam tests are under
app-lib/tests/it; - the Pro proto step is in
app-lib/build.rs; - the library's tests run as
-p nodespace-app-lib.
Find code by symbol.
Risks and rollback
- Rebase churn for in-flight branches. Git follows renames, and the rename is in its own commit. Land quickly, and tell whoever has branches touching
src-tauri/src. - Silently losing
cfg(desktop). The new test guards against it. - ACL permissions. Dropping a plugin dependency from the app crate fails the build loudly, in
validate_capabilities. - The Pro build. Every path it uses is unchanged, and the Pro-mode compile check covers it.
- Rollback: revert the PR.
Plan key: C2.5 (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
mstomar125 commentedon Sep 30, 2026
Completed in #3379 (merged). Auto-close did not fire; closing manually.