Repository navigation
Description
Part of #3322 (Tauri extension points for the desktop app).
Summary
Move core's window capability out of the app crate and into the library.
Today it is src-tauri/capabilities/default.json. It grants window main:
core:default;core:window:allow-destroyandcore:window:allow-close;opener:defaultanddialog:default.
After this PR, the library adds it at startup with Manager::add_capability. Every app crate built on core then gets it without copying the file (ADR-082 (proposed) §3.7, item 5). A core test fails if the capability names a plugin that core's app crate doesn't depend on directly.
Context
- Where capabilities come from today.
tauri_build::build()readscapabilities/**from the crate that calls it, andgenerate_context!()embeds them. Without this change, an app crate outside core would have to copy core's file and keep it in sync. Manager::add_capability. It comes with thedynamic-aclfeature, which Tauri enables by default (tauri/src/lib.rs813).- It resolves permissions against the app's ACL manifests.
- It panics on a permission whose plugin isn't in them (
ipc/authority.rs174-179). - Those manifests come from
tauri_build, which reads only direct dependencies' permission files. That is why Split the desktop Tauri crate into an app-lib library and a thin app crate #3303 kepttauri-plugin-openerandtauri-plugin-dialogas direct dependencies ofsrc-tauri.
- Timing. Tauri creates the config windows and then runs the app's setup, synchronously on the main thread (
app.rs2513-2524). The event loop handles IPC messages only after setup returns. So a capability added at the top of core's setup is in place before any frontend call. - Testing.
generate_context!()produces a runtime-genericContext<R>, so a test in the app crate can build the real config and ACL onMockRuntime.
Scope
- Move the file:
git mv src-tauri/capabilities/default.json app-lib/src/window-capability.json.- Drop the
$schemaline, or point it at../../src-tauri/gen/schemas/desktop-schema.json. - Keep the identifier, windows and permissions unchanged.
- Remove
src-tauri/capabilities/, which is now empty.
- Drop the
- New function, in
app-lib/src/extensions/or a newapp-lib/src/capability.rs:It callspub fn add_core_window_capability<R: tauri::Runtime, M: tauri::Manager<R>>( manager: &M, ) -> tauri::Result<()>
manager.add_capability(include_str!("window-capability.json")). Its rustdoc covers:- what the capability grants;
- that the app crate must depend directly on each plugin crate the capability names;
- that it panics otherwise.
run()'s setup: call it first, before the menu is built, with?.src-tauri/Cargo.toml: add[dev-dependencies]tauri = { version = "2", features = ["test"] }andserde_json, for the tests below.
Out of scope
- Capabilities for extension plugins. The app crate grants those itself.
- Any permission change.
Steps
- Run the CLAUDE.md startup sequence. Self-assign at pickup; the worktree is
issue-<N>-library-window-capability. - Move the file, add the function, and call it from setup.
- Add the tests.
- Smoke-test in dev and in a release bundle. A release build reports an ACL failure only as "not allowed by ACL".
- Run
bun run quality:fix, thenbun run test:changed.
Acceptance criteria
-
src-tauri/capabilities/is gone, and the library adds an identical capability at startup. -
window_capability_names_only_plugins_the_app_crate_depends_onpasses, and fails if a permission such asclipboard-manager:defaultis added. -
window_capability_resolves_against_the_app_crates_aclpasses, and fails for an unknown permission. The test buildsmock_builder(), with a setup that callsadd_core_window_capability, usingtauri::generate_context!()insrc-tauri. - A source-text test shows
add_core_window_capability(is the first call inrun()'s setup, beforeapp.set_menu. - The dev smoke test (
bun run dev:tauri) and a release bundle (bun run --cwd packages/desktop-app tauri:build, on a quiet machine) both show:- nodes load and live updates arrive (
core:event); - Import Folder opens a dialog (
dialog:default); - an external link opens in the browser (
opener:default); - window close and Cmd+Q exit (
core:window:allow-destroyandallow-close).
- nodes load and live updates arrive (
- 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.
Tests and verification
In src-tauri/src/main.rs, add #[cfg(test)] mod tests (it runs under test-app-units' --bins):
window_capability_names_only_plugins_the_app_crate_depends_on:- parse the JSON through
include_str!("../../app-lib/src/window-capability.json"); - map each non-
corepermission prefixxtotauri-plugin-x; - assert each one is a key under
[dependencies]ininclude_str!("../Cargo.toml").
- parse the JSON through
window_capability_resolves_against_the_app_crates_acl
In app-lib/src/lib.rs, add the source-text test above.
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
Risks and rollback
- IPC before setup returns. If a webview could send IPC before setup finishes, early calls would be denied. The smoke test covers startup, and the Context above explains why this doesn't happen.
- Fallback, if a device shows otherwise: keep the file in
src-tauri/capabilities/as well, and record an amendment to ADR-082. - Rollback: revert. The file returns to
src-tauri/capabilities/.
Plan key: C2.7 (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
mstomar125 commentedon Oct 1, 2026
Superseded by #3414 (umbrella against the final ADR-081–085)