Repository navigation
Description
Part of #3322 (Tauri extension points for the desktop app).
Summary
Replace nodespace_app_lib::run(context) (from #3303) with pub fn run(extensions: AppExtensions, context: tauri::Context<tauri::Wry>) (ADR-082 (proposed) §3.2). run() now does everything main.rs and run() do today, in this order:
- redirects stdio in Windows release builds;
- builds the tokio runtime and hands it to Tauri;
- registers core's plugins;
- calls
assemble(builder, extensions); - applies core's setup, menu handler and commands;
- builds with
contextand runs the loop.
Core's main.rs becomes a single call with AppExtensions::none(). The free app behaves exactly as before.
Context
src-tauri/src/main.rs, after #3303, contains:
- the
windows_subsystemattribute (1-2), which must stay in the binary crate (ADR-082 §3.7, item 2); - the Windows release stdio redirect (17-18);
- the runtime build and
tauri::async_runtime::set(20-26); runtime.block_on(async { nodespace_app_lib::run(tauri::generate_context!()) }).
run() in app-lib/src/lib.rs (311-870 at af8ddb6, before #3303 moved it):
- builds the builder with
single-instancefirst (343-349), thenopeneranddialog(352-353); - then applies
.setup,.on_menu_event,.invoke_handlerand.build(context).
Today run() runs inside runtime.block_on, so the main thread is inside the tokio runtime while the event loop runs. Keep that.
The source-text suites in lib.rs search for fixed anchors inside run() and must keep passing unchanged:
quit_wiring_tests:== quit_id {, andapp.manage(shutdown_token_for_setup.clone());…Window <-> database pin registry;graceful_shutdown_stops_daemon_tests;window_geometry_capture_tests.
Scope
app-lib/src/lib.rs
pub fn run(extensions: AppExtensions, context: tauri::Context<tauri::Wry>), in this order:
#[cfg(all(windows, not(debug_assertions)))] daemon_setup::redirect_gui_stdio_to_log_files();, moved frommain.rswith its comment.- Build the multi-thread runtime, then call
tauri::async_runtime::set(runtime.handle().clone()). - Wrap everything that follows in
runtime.block_on(async move { … }). - Tracing init and the shutdown token (unchanged).
- The builder with single-instance first, then
openeranddialog(unchanged). let builder = assemble(builder, extensions);..setup(…),.on_menu_event(…)and.invoke_handler(…)(unchanged)..build(context)andapp.run(…)(unchanged).
Rustdoc on run, in generic wording with no product names:
runmust be called from a plainfn main, not inside a tokio runtime.- It lists what an app crate must do (ADR-082 §3.7):
- call
tauri_build::build()inbuild.rsandgenerate_context!()inmain; - keep the
windows_subsystemattribute inmain.rs; - call
nodespace_app_build::drop_unstaged_bundle_entries()(Move the bundle-staging build helpers into a nodespace-app-build crate #3305) beforetauri_build::build(); - depend directly on every Tauri plugin crate that core's window capability names;
- use the same Tauri and tonic versions as core's lockfile.
- call
Keep every text anchor listed above byte-identical.
src-tauri/src/main.rs
Keep lines 1-2 and their DO NOT REMOVE comment. The rest becomes:
fn main() {
nodespace_app_lib::run(nodespace_app_lib::AppExtensions::none(), tauri::generate_context!())
}Remove tokio from src-tauri/Cargo.toml if nothing else in the crate uses it.
Out of scope
- New hooks (Add daemon-ready tasks and a channel-rebuilt hook to AppExtensions #3307, Let an app built on core supply its update source through AppExtensions #3320, Let an app built on core supply its DaemonProfile via AppExtensions::daemon_profile #3347).
- The capability move (Have the app library add core's window capability at startup #3308).
- Making core's commands runtime-generic.
Steps
- Run the CLAUDE.md startup sequence. Self-assign at pickup; the worktree is
issue-<N>-run-with-extensions. - Move the runtime and stdio setup into
run, and callassemble. - Simplify
main.rs. - Add the tests below.
- Run
bun run quality:fix, thenbun run test:changed. - Smoke-test with
bun run dev:tauri, against the dev daemon and socket, never a real user database.
Acceptance criteria
-
run(extensions, context)is the only entry point, and its rustdoc covers the app-crate contract. -
main.rscontains thewindows_subsystemattribute and a singlerun(AppExtensions::none(), tauri::generate_context!())call. - Inside
run,assemble(builder, extensions)comes after the dialog plugin and before.setup(. A test pins this. - The runtime is set before the builder is created. A test pins this.
- Every existing
lib.rssource-text suite,relaunch_testsandshutdown_testspass unchanged. - Free-app smoke test:
- the app launches and opens the default database;
- you can create and edit a node;
- the File, Edit and View menus work;
- Quit from the menu, Cmd+Q and tray Quit each close the app and stop the daemon;
- closing the window flushes and exits;
- a second launch hands off to the running instance;
- the update check runs, with no banner when current.
- The Pro-mode compile check passes.
-
bun run scripts/check-pro-boundary.tspasses.BASELINESare 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 source-text tests go in a run_wiring_tests module in lib.rs. Each slices from pub fn run( to fn handle_run_event, so the tests' own literals are never in range:
run_assembles_extensions_after_core_plugins_and_before_setuprun_sets_the_async_runtime_before_building_the_apprun_builds_with_the_callers_context:.build(context)is present, and thegenerate_context!macro name is absent. Build the searched string withconcat!.
Mutation-check each new test: break the code path it covers, confirm the test fails, then restore.
cargo test --lib --bins -p nodespace-app-lib -p nodespace-app -- --test-threads=2
cargo clippy -p nodespace-app-lib -p nodespace-app --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 run test:changed
bun run dev:tauri
Dependencies
- Add AppExtensions with Tauri-plugin support and a runtime-generic assemble() #3304
- Move the bundle-staging build helpers into a nodespace-app-build crate #3305: the rustdoc names its build helper.
Risks and rollback
- Startup order. The order is: stdio redirect, then the runtime, then
async_runtime::set, then the builder. Tauri must see the custom runtime before anything spawns. - Windows-only code. A macOS PR check can't compile it, so the reviewer reads the
#[cfg(windows)]hunk. It is a move, not an edit. - Rollback: revert. Add AppExtensions with Tauri-plugin support and a runtime-generic assemble() #3304 stays harmless on its own.
Plan key: C2.2 (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
mstomar125 commentedon Sep 30, 2026
Coordinator note from #3304's review: when
run()is routed throughassemble()here, derive core's own plugin registrations andextensions::CORE_PLUGIN_NAMESfrom one shared source (so a new core plugin can't be added torun()without the collision guard knowing its name). Treat that as an acceptance criterion.mstomar125 commentedon Sep 30, 2026
Completed in #3393 (merged). Auto-close did not fire; closing manually.