Skip to content

Split the desktop Tauri crate and add ADR-082's Tauri extension points #3322

Closed as not planned
8 of 8 issues completed
Closed as not planned

Description

@mstomar125

Goal

Give core's desktop app the Tauri-level extension points that ADR-082 (proposed) §3 defines. An app crate outside core, meaning the Pro app crate in nodespace-sync under ADR-081 (proposed), can then build the desktop app from core's library and add:

Core's own app crate passes AppExtensions::none(), so the free app behaves exactly as it does today.

#3322 is the anchor for moving the Pro Tauri layer out of core (#3336) and for removing edition branching (#3357). #3322 deletes no Pro code.

Context (verified at main af8ddb6)

There is no seam today

  • packages/desktop-app/src-tauri is one package, nodespace-app:
    • lib nodespace_app_lib, with crate-type = ["staticlib", "cdylib", "rlib"];
    • bin nodespace-app.
  • A crate that depended on it would run its build.rs, whose tauri_build::build() fails a release build without staged sidecars. It would also get core's generate_context!(), which run() expands itself (src/lib.rs 862).
  • src/main.rs builds a tokio runtime and calls nodespace_app_lib::run() (29). run() (src/lib.rs 311-870) is one tauri::Builder chain:
    • plugins: 343-353;
    • .setup: 354-671;
    • .on_menu_event: 672-698;
    • .invoke_handler(generate_handler![…]): 699-861;
    • .build: 862;
    • app.run: 869.
  • The Pro code that Move the Pro Tauri layer out of core: pro_* commands, ProClient, proto, update source #3336 moves out sits in exactly these places:
    • the 27 commands::pro_sync::* entries (lib.rs 710-736);
    • the Pro probe in the startup task (lib.rs 607-635);
    • ProClient::rebind after a wedged-channel rebuild (commands/nodes.rs 600-605);
    • the Pro release source in update_check.rs: PRO_LATEST_URL (34-42), the is_pro_build() branch (116-124), and pro_version_from_json / fetch_pro_latest_version (158-194).

Tauri facts that shape the design

Checked in the vendored tauri 2.11.2, tauri-build 2.6.2, tauri-codegen 2.6.2 and tauri-utils 2.9.2:

  1. One handler and one setup. A Builder holds one invoke handler and one setup closure, and a second call replaces the first (app.rs 1650, 1765). Extension commands therefore arrive as Tauri plugins, each with its own handler.
  2. Plugin commands are ACL-checked. They are invoked as plugin:<name>|<cmd> and always checked (webview/mod.rs 1823). The app crate grants them in its own capability; core's capabilities never name them.
  3. Duplicate names replace silently. Registering a second plugin with an existing name silently replaces the first (plugin.rs 880-885).
  4. Plugin setup comes first. It runs inside Builder::build, before the app's own setup, which runs right after the config windows are created (app.rs 2513-2524). Core's managed GrpcClient and shutdown token don't exist yet when a plugin's setup runs.
  5. The calling crate owns the config. generate_context!() and tauri_build::build() read tauri.conf.json, capabilities and ACL manifests of the crate that calls them.
    • tauri_build also emits the desktop/mobile cfg aliases (tauri-build lib.rs 206-210, 476-477). Core's #[cfg(desktop)] single-instance guard relies on them.
    • It reads permission files only from the calling crate's direct dependencies.
  6. Runtime capabilities can panic. Manager::add_capability (feature dynamic-acl, on by default) resolves a capability against the app's ACL manifests at run time. It panics on an unknown permission (ipc/authority.rs 174-179).
  7. The context is runtime-generic. generate_context!() produces a Context<R>, so a test can build the real app config on MockRuntime.

A constraint the ADR sketch doesn't mention

ADR-082 sketches assemble<R: Runtime> as holding "core's plugins and commands, the extension plugins, the hook state and core's setup". Two things stop that:

  • At least 17 non-Pro core commands take tauri::AppHandle or tauri::WebviewWindow, which are Wry-typed. Examples: probe_and_recover_channel, check_for_update_command, pin_window_database, and the onboarding and import commands.
  • Core's setup calls daemon_setup::ensure_daemon_running(&AppHandle), which would install and start a real launchd service if a test ran it.

So in this plan:

  • assemble is runtime-generic and applies the extension half: extension plugins, hook state and the update source;
  • run() applies core's own plugins, commands and setup around it, on Wry.

MockRuntime tests drive everything an extension contributes through assemble. Making core's commands generic is out of scope (see open questions).

Migration constraint

sync builds the Pro GUI from core's current HEAD, with bunx tauri build --config src-tauri/tauri.pro.conf.json:

  • it stages into src-tauri/binaries and src-tauri/resources/models;
  • the bundle's executable is nodespace-app.

Every #3322 PR keeps all of these where they are, and passes a Pro-mode compile check.

Design (ADR-082 (proposed) §3)

Crate layout after #3303 and #3305

Package (path) Crate Holds
nodespace-app-lib (packages/desktop-app/app-lib) nodespace_app_lib, rlib Everything under today's src/ except main.rs; the tests/it Tauri-seam suite; test-support; the Pro proto compile step until #3335
nodespace-app (packages/desktop-app/src-tauri) bin nodespace-app main.rs, build.rs, tauri.conf.json, tauri.pro.conf.json (until #3354), capabilities/ (until #3308), icons, binaries/, resources/
nodespace-app-build (packages/desktop-app/app-build) nodespace_app_build drop_unstaged_bundle_entries and sync_stale_sidecar: build helpers any app crate uses as a build dependency

There is no separate extension-API crate. An extension app crate depends on nodespace-app-lib, and nothing in core depends on the extension, so there is no cycle.

The extension API

Item Added by
EXTENSION_API_VERSION: (u32, u32) = (1, 0) #3304
AppExtensions<R>::none(), ::plugin(P) #3304
assemble(builder, extensions) #3304; extended by #3307, #3320, #3347
run(extensions, context) #3306
on_daemon_ready(task), with DaemonReady { app, grpc, shutdown } #3307
on_channel_rebuilt(hook) #3307
update_source(UpdateSource { latest: LatestVersionSource, download_url }) #3320
daemon_profile(DaemonProfile) #3347 (the type comes from #3346 and lives in nodespace_app_lib)
Core's window capability, added by the library at startup #3308
The Rust version equals the TypeScript version, and a fixture change must bump it #3321

When each contribution runs

  • Plugins. assemble registers them after core's single-instance, opener and dialog plugins. Their setup runs before core's setup. A name that collides with a core plugin or an earlier extension plugin is logged and skipped.
  • Daemon-ready tasks. Spawned, not awaited, once per process, from core's startup task. They run after ensure_daemon_running returns (healthy or not) and after the watcher and token stream are wired.
  • Channel-rebuilt hooks. Awaited one at a time in probe_and_recover_channel, after GrpcClient::reconnect() and before the re-probe. Each hook has a 2-second timeout. A timeout or panic is logged, and recovery continues.
  • Update source. Held as managed state. The startup update check and check_for_update_command read it.

Sub-issues (in order)

Key Title Depends on
#3303 Split the desktop Tauri crate into an app-lib library and a thin app crate NodeSpaceAI/nodespace-docs#90 (ADR-082), #3299
#3305 Move the bundle-staging build helpers into a nodespace-app-build crate #3303
#3304 Add AppExtensions with Tauri-plugin support and a runtime-generic assemble() #3303
#3306 Route the desktop app through run(extensions, context) with no extensions in core #3304, #3305
#3307 Add daemon-ready tasks and a channel-rebuilt hook to AppExtensions #3306
#3320 Let an app built on core supply its update source through AppExtensions #3306, #3319
#3308 Have the app library add core's window capability at startup #3306
#3321 Enforce EXTENSION_API_VERSION: Rust matches TypeScript, fixture changes bump it #3307, #3320, #3308, #3315

DAG: NodeSpaceAI/nodespace-docs#90 (ADR-082) + #3299 → #3303 → {#3305, #3304} → #3306 → {#3307, #3320 (+#3319), #3308} → #3321 (+#3315).

The keys are not in execution order:

#3307, #3320 and #3308 can run in parallel. They all touch run(), AppExtensions or assemble, so whichever merges later rebases.

Notes for downstream issues

Acceptance criteria (parent)

  • The library/app split, the build-helper crate and the entry points in the tables above exist in core, and a test covers each one.
  • Using only the documented API, a test extension driven through assemble on MockRuntime can do each of the following, and each is a test:
    • register a Tauri plugin whose command is callable through IPC once granted;
    • manage state;
    • run plugin setup;
    • spawn a daemon-ready task that reaches the daemon on the shared channel;
    • receive a working channel after a wedged-channel rebuild;
    • replace the update source.
  • Core's app crate passes AppExtensions::none(), and the free app is unchanged:
    • startup;
    • the menus;
    • Quit from the menu, Cmd+Q, the tray and window close;
    • the single-instance handoff;
    • the update check;
    • channel recovery;
    • dialogs and links.
  • Core still compiles in Pro mode (NODESPACE_PRO_SUPABASE_URL and NODESPACE_PRO_ANON_KEY set) after every sub-issue.
  • sync's current build-pro-dmg.sh flow still works: the app crate is still at src-tauri, and nodespace-app is still the package and bin name.
  • EXTENSION_API_VERSION is equal in Rust and TypeScript, and a test enforces it.
  • No new Pro, sync, tenant or Supabase wording lands in core. scripts/check-pro-boundary.ts passes after every sub-issue, and its baselines never rise.
  • Code comments cite ADRs, never GitHub issue numbers.

Dependencies

Out of scope

Self-assign each sub-issue when you pick it up. Never assign at creation (core CLAUDE.md).


Plan key: C2 (pro-boundary DAG).

🤖 Generated with Claude Code

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions