Repository navigation
Split the desktop Tauri crate into an app-lib library and a thin app crate - #3379
Conversation
Pragmatic code review (medium), initial reviewReview type: Initial Review. Recommendation: APPROVE. Code Review SummaryNo Critical or Important issues, and no behavior change outside the forced What was verified against the code:
FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Requirements Check (issue acceptance criteria)
Recommendation: APPROVE. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (medium): APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.
b930962 to
9c22d66
Compare
Address-review summaryPushed Addressed (3 of 5 items, all comment-only):
Skipped (2):
Checks run on the change: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: the three fixes are comment and comment-adjacent text only, with no logic, manifest or build-script change. The review found no Critical or Important issues and recommended APPROVE. |
Pure git mv, no content change: src-tauri/src (except main.rs), tests, test-support and proto now live under packages/desktop-app/app-lib. The workspace does not build at this commit; the next commit adds the manifests and wiring. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…rate nodespace-app-lib (packages/desktop-app/app-lib) is an rlib holding every module the app ran, the Tauri-seam tests and test-support. run() now takes the tauri::Context, so generate_context!() expands in main.rs of the nodespace-app crate that owns tauri.conf.json. The library's build.rs takes over the Pro proto step and defines the desktop/mobile cfg aliases that only tauri_build used to provide; desktop_cfg_alias_is_set guards the single- instance plugin against losing them silently. Co-Authored-By: Claude Sonnet 5 <[email protected]>
rust:test:* and test-app-units.ts build and run nodespace-app-lib's unit tests, the merge gate's Tauri-seam stage runs -p nodespace-app-lib --test it, gate-scope classifies packages/desktop-app/app-lib/ as Rust so test:changed does not skip Rust for it, and refresh-pro-proto writes the vendored proto into app-lib/proto. Comments that named src-tauri/src or src-tauri/tests now name app-lib. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
… items tray.rs pointed at nodespace-app for daemon_setup and quit_wiring_tests, which now live in nodespace-app-lib; the workspace version comment lists the new member; test-gate.ts no longer calls app-lib's unit target a lib/bin pair. Co-Authored-By: Claude Sonnet 5 <[email protected]>
9c22d66 to
3c981e2
Compare
Closes #3303
Summary
Splits the desktop Tauri crate in two so an app crate outside core can depend on core's desktop library without running core's build script or embedding core's config and frontend (ADR-082 §3.1, proposed).
nodespace-app-libatpackages/desktop-app/app-lib: cratenodespace_app_lib,rlibonly. Holds every module that was undersrc-tauri/src/exceptmain.rs, thetests/itTauri-seam suite,test-support, and the vendored Pro proto with its compile step.nodespace-appstays atpackages/desktop-app/src-tauri(package name, bin name,default-run, hard-codedversion,devtoolsfeature unchanged). Holdsmain.rs,build.rs,build_support.rs, bothtauri*.conf.json,capabilities/,icons/,binaries/,resources/,gen/.The moves are their own commit (
git mv, 53 renames, 0 content changes) so history follows the files. The only code change the split forces:run()now takes thetauri::Context<tauri::Wry>, andmain.rsexpandsgenerate_context!()in the crate that ownstauri.conf.json.Commits
Move the desktop Tauri library sources into app-lib: puregit mv. The workspace does not build at this commit.Split the desktop Tauri crate...: manifests, bothbuild.rs,run(context),main.rs, test-support paths, the new test.Point the test tooling and path comments at app-lib: package.json, scripts, vite config, CLAUDE.md tree, comments.packages/daemon/src/tray.rs, the workspace version comment, and atest-gate.tscomment.What the split had to preserve
desktop/mobilecfg aliases. Onlytauri_builddefines them, and the library no longer calls it.app-lib/build.rsmirrors tauri-build'scfg_aliasexactly (checked against tauri-build 2.6.2lib.rs). Without it#[cfg(desktop)](the single-instance guard) compiles out silently. New testdesktop_cfg_alias_is_setguards it.tauri-plugin-openerandtauri-plugin-dialogstay direct dependencies ofnodespace-app. Verified the risk is real: droppingtauri-plugin-openerfrom the app crate fails its build withPermission opener:default not found(manifest restored).tauri_winreslinks the resource through embed-resource'srustc-link-arg-bins, so it only ever applied to the bin. The library's unit-test binaries never had it, so nothing regresses there.CARGO_MANIFEST_DIRpaths inskill_setup.rs,daemon_setup.rsand test-support'sworkspace_root()still resolve becauseapp-libsits at the same depth assrc-tauri. The two that break (build_support.rs#[path]and the sidecar fallback) are fixed.Cargo.lockgains only thenodespace-app-libentry and moves dependencies between the two package entries. No external crate version changes;cargo check --lockedpasses.Deviations from the issue text
build_support.rsmodule doc and test-support's comment explained the#[path]include as a dependency cycle back ontonodespace-app. That is no longer true (test-support now depends onnodespace-app-lib), so both are reworded to the actual reason: the app crate is binary-only and itsbuild.rscan't take test-support as a build dependency. Comment-only.src-tauri/build.rs: one comment said "Seemainonset_var", pointing at the proto block that moved out. Reworded in place so it doesn't dangle.clippy::assertions_on_constantsfires onassert!(cfg!(desktop))under-D warnings, and lint suppression is off the table. The test bindscfg!(desktop)to a local first.packages/desktop-app/src-taurimentions (packages/cli/src/commands/skill.rs,packages/daemon/src/services/node_service.rs,packages/nodespace-types/src/lib.rs) named the Tauri command layer, so they now sayapp-lib. Comment-only.scripts/gate-stage.ts,scripts/gate-scope.tsandscripts/test-app-units.tsdoc text updated to saynodespace-app-lib.src-tauri/src/types.rsin nodespace-types' module doc, and a stalesrc-tauri/src/bin/dev-proxy.rsinbrowser-sync-service.test.ts), andsrc-tauri/history.txt, a stray tracked SQL history file that predates this and isn't part of a move..github/workflowsneeded changes: the release workflow's paths (src-tauri/binaries,resources/models, the rust-cache workspace entry) all still exist.Verification
Test counts, before (main at
af8ddb61) vs after, compared by test name:--lib --bins(app + test-support)tests::cfg_alias_tests::desktop_cfg_alias_is_set)-p nodespace-app-lib --test it#[ignore]that was already ignored)cargo check -p nodespace-app-lib -p nodespace-appand--locked: pass.cargo clippy -p nodespace-app-lib -p nodespace-app -p nodespace-app-test-support --all-targets -- -D warnings -D clippy::unused-async: clean.cargo fmtclean.NODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=dummy cargo check -p nodespace-app: passes. Theoption_env!reads live inapp-lib/src/daemon_setup.rsand are picked up from the same build environment.cargo test --lib --bins -p nodespace-app-lib -p nodespace-app -p nodespace-app-test-support -- --test-threads=2: 233 passed.NODESPACED_TEST_BINset to a freshly builtnodespaced: 45 passed, 0 failed, 1 ignored.cargo build -p nodespace-app --bin nodespace-applinks;cargo metadatashowsnodespace-app-libwith only anrliblib target andnodespace-appwith only the bin; the built binary embeds the Tauri context.bun run test:changed(every tier, sincepackage.jsonand gate files changed): frontend, scripts, skill, browser andrust:testall pass.rust:testruns the 233 app-lib unit tests, sobun run rust:testcovers the library.bun run quality:scripts:fix,bun run --cwd packages/desktop-app quality:fix,bun run --cwd packages/skill quality:fix: clean.git grep -n -e 'src-tauri/src/' -e 'src-tauri/tests' -e 'src-tauri/test-support'returns only the two historical mentions above.Mutation checks
desktop_cfg_alias_is_set: commented outcfg_alias("desktop", !mobile)inapp-lib/build.rs-> the test fails with its message (and rustc warnsunexpected cfg condition name: desktop); restored -> passes.packages/desktop-app/app-lib/src/lib.rs: removed"packages/desktop-app/app-lib/"fromRUST_DIRS-> that case fails (bun test scripts/gate-scope.test.ts: 24 pass, 1 fail); restored -> 25 pass.Ratchet (
scripts/check-pro-boundary.ts)The ratchet is not on
mainyet. I ran the in-flight version from the #3299 worktree against this tree: all 12 counts equal their baselines (delta 0 everywhere; moves keep the counts, and the two Pro-proto comments I moved intoapp-libwere deleted fromsrc-tauriin the same PR). NoBASELINESedit is needed. It should be re-run once it lands.Not run here, and why
bun run dev:taurismoke test and the "edit an app-lib comment and see it rebuild" check. The app's setup runskill_stale_daemon_sync()andensure_daemon_runningunconditionally, which writes a launchd plist, bootstraps or boots out the dev-variant job, and restarts the dev daemon. On this shared Mac that would hit whatever dev daemon is running, andHOMEisolation doesn't isolate launchd's per-user domain. I didn't want to do that unattended. On the watch question: Tauri CLI's dev watcher watches the app's tauri dir plus the workspace path dependencies of the app crate plusbuild.additionalWatchFolders(upstreaminterface/rust.rs), andnodespace-app-libis a workspace path dependency ofnodespace-app, so I expect app-lib edits to rebuild without addingadditionalWatchFolders. That is unverified empirically; whoever runs the smoke test should confirm it and add"../app-lib"if not.bun run --cwd packages/desktop-app tauri:buildand the bundle contents check. Release profile islto = trueandcodegen-units = 1, on a machine that was at load 10+ with other Rust agents.tauri.conf.json,build.rs's sidecar staging,resources/andexternalBinare all unmoved and still owned by the app crate, so bundle contents should be identical, but that hasn't been observed.bunx tauri build --config src-tauri/tauri.pro.conf.json): every path it uses is unchanged; only the Pro-mode compile check above was run.Downstream
Anything citing
packages/desktop-app/src-tauri/src/...,src-tauri/tests/itor the proto step insrc-tauri/build.rsnow finds it underapp-lib/. Library tests run as-p nodespace-app-lib; for the app crate use--bins(cargo test --lib -p nodespace-appnow errors with "no library targets"). Git follows the renames, and they are in their own commit, so in-flight branches touchingsrc-tauri/srcshould rebase cleanly.🤖 Generated with Claude Code