Repository navigation
Route the desktop app through run(extensions, context) with no extensions in core - #3393
Conversation
Code Review SummaryReview Type: Initial Review (medium effort: high-confidence findings only) Verdict: APPROVE (no blockers; the smoke-test criterion still needs a real-device pass, see the requirements check and Improvement 3). The change does what #3306 asks, and the startup semantics are preserved. I compared the old
Requirements Check (issue #3306)
Coordinator criterion (points 2 and 3). FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
What is good
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment - GitHub blocks self-approval). Full findings in the review comment above.
Address-review summary (round 1)Review: the pragmatic review above, verdict APPROVE with no blockers. Fixes are in e8e9f0c. Addressed (6 of 8 items)
Skipped, with reasoning
Verification after the fixes
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: This round changed comments, rustdoc and two test assertions. No production logic changed (the non-test code diff is comments and doc text only), and each new assertion was mutation-checked. |
…ins from one list run() now takes AppExtensions and the app crate's Tauri context, and does what main.rs and run() did between them: redirect stdio in a Windows release build, build the tokio runtime and hand it to Tauri, register core's plugins, apply the extension with assemble(), then add core's setup, menu handler and commands. main.rs is a single call with AppExtensions::none(). Core's plugins are one list, extensions::core_plugins. run registers them through it and assemble reads the names an extension plugin may not reuse off it, replacing the hand-kept CORE_PLUGIN_NAMES constant. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ocument the plugin constructor invariant - run_redirects_stdio_before_the_runtime_starts now includes the cfg(all(windows, not(debug_assertions))) attribute in its needle, since no PR check compiles the Windows-only call. - run_sets_the_async_runtime_before_building_the_app also pins that the app is built inside runtime.block_on. - core_plugins' rustdoc states that building the list must have no effects: it is built once to read names and again to register. - assemble's rustdoc no longer links to a crate-private function. - The redirect comment and run's rustdoc no longer claim more than they can: the caller's arguments are evaluated before run, and Tauri panics if its runtime is already initialised when run sets its own. Skipped: asserting that opener and dialog are listed. That would add a second hand-kept list of plugin names, and the check that a window capability names only registered plugins belongs with the capability move. Co-Authored-By: Claude Sonnet 5 <[email protected]>
e8e9f0c to
f1856c9
Compare
Closes #3306
Part of #3322 (Tauri extension points for the desktop app), under the Pro/core boundary epic #3298.
What changed
nodespace_app_lib::runis nowrun(extensions: AppExtensions, context: tauri::Context<tauri::Wry>)and does everythingmain.rsandrundid between them, in this order:main.rs, same#[cfg(all(windows, not(debug_assertions)))]gate);tauri::async_runtime::setwith it;runtime.block_on, so the main thread stays inside the runtime while the event loop runs;assemble(builder, extensions);contextand runs the loop.main.rskeeps thewindows_subsystemattribute and its DO NOT REMOVE comment, and is one call:run(AppExtensions::none(), tauri::generate_context!()).tokiois dropped fromnodespace-app'sCargo.toml(nothing else in the crate used it), which removes one line fromCargo.lock.The rustdoc on
runis the app-crate contract in generic wording: call it from a plainfn main(not inside a tokio runtime), and the app crate must calltauri_build::build()andgenerate_context!(), keepwindows_subsystem, callnodespace_app_build::drop_unstaged_bundle_entries()first, depend directly on every plugin crate the window capability names, and use core's Tauri and tonic versions.The coordinator's acceptance criterion: one source for core's plugins
Core's plugin registrations and the names
assembleprotects now come from one function,extensions::core_plugins, in registration order (single-instance first, then opener, then dialog).register_core_plugins(builder)registers that list;runcalls it and registers no plugin itself.core_plugin_names()reads the names off the same list, andassembleuses it. The hand-keptCORE_PLUGIN_NAMESconstant is gone, so a plugin added to core is protected from a same-named extension plugin the moment it is added, with no second list to update.run_registers_core_plugins_only_through_the_shared_listfails if anyone adds a.plugin(call torundirectly.Deviations from the issue text
run_apphelper instead of one bigblock_on(async move { ... }). The app build (tracing, shutdown token, builder chain, the ~400-line setup closure, the command list) moves unchanged into a privaterun_app, andruncallsruntime.block_on(async move { run_app(extensions, context) }). The order and semantics are what the issue specifies. Wrapping the chain in the async block would re-indent about 600 lines, hide the real change in the diff, and risk rustfmt silently giving up on the nested closure.run_appsits betweenrunandhandle_run_event, so the source-text suites and the new tests still read it as part ofrun.assembleafter the dialog plugin" is now "register_core_pluginsbeforeassemble". The dialog plugin registration lives incore_plugins, not inrun, because of the criterion above. The test pinsregister_core_plugins(beforelet builder = assemble(builder, extensions);before.setup(.generate_context!()is evaluated as an argument torun, so before the runtime is built rather than insideblock_on. It only builds aContextvalue and does not touch the async runtime.core_plugin_names_match_the_plugins_core_registershand-mirrored the plugin list, which is the second source this PR removes. It is replaced bycore_plugin_names_are_uniqueandsingle_instance_plugin_is_the_first_core_plugin.Every anchor the existing source-text suites search for (
== quit_id {,app.manage(shutdown_token_for_setup.clone());...Window <-> database pin registry, thegraceful_shutdownandpersist_window_geometryslices) is byte-identical and those suites pass unchanged, as dorelaunch_testsandshutdown_tests.For the reviewer: the only Windows-only code is the stdio redirect hunk. It moved from
main.rstorunverbatim; the call lost itsnodespace_app_lib::prefix because it is now inside that crate, and the comment's reference to "the attribute above" now says the app crate'smain.rs. A macOS check cannot compile it, so please read it.Ratchet delta
scripts/check-pro-boundary.ts: no marker count changes (before and after are identical on every marker), no baseline is edited and none is raised. No added line contains a marker word. The check passes in the push check.Tests and mutation checks
New source-text tests in
run_wiring_tests(lib.rs) and changed tests inextensions/fixture_tests.rs. Each was mutation-checked individually: break the path, confirm the test fails (as a test failure, not a compile error), restore.run_assembles_extensions_after_core_plugins_and_before_setupassembleassemblemoved after.setup(run_registers_core_plugins_only_through_the_shared_listrunrun_sets_the_async_runtime_before_building_the_appasync_runtime::setmoved after the builder is createdruntime.block_onrun_redirects_stdio_before_the_runtime_startscfggate loosened (dropsnot(debug_assertions))run_builds_with_the_callers_context.build(context)no longer presentruncore_plugin_names_are_uniquesingle_instance_plugin_is_the_first_core_pluginextension_plugin_named_like_a_core_plugin_is_not_registered(now driven bycore_plugin_names)assemblereserves no namescore_plugin_namesreturns an empty list (guards against a vacuous pass)Verification run:
cargo clippy -p nodespace-app-lib -p nodespace-app --all-targets -- -D warnings -D clippy::unused-async: clean.cargo fmt --check: clean.cargo test --lib --bins -p nodespace-app-lib -p nodespace-app: 252 passed, 0 failed.NODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=dummy cargo check -p nodespace-app: passes.bun run test:changed(rust and scripts tiers): passed.Not done: the free-app smoke test
The issue's manual smoke test (launch, default database, create and edit a node, File/Edit/View menus, Quit from the menu, Cmd+Q and tray Quit, close-window flush, second launch hands off, update check) was not run, for two reasons.
app.nodespace.daemon.dev) whose daemon opens the real~/.nodespacedatabase. Launchd does not inherit an isolatedNODESPACE_HOME, so it cannot be run against an isolated database from a shared dev Mac.It needs one real-device pass with
bun run dev:tauri. What it exercises that no test here does: real Wry startup order, the single-instance handoff (the plugin now comes fromcore_plugins), and the quit and flush paths.🤖 Generated with Claude Code