Repository navigation
refactor(desktop): one Tauri transport, shared command logic - #1257
Merged
Merged
Conversation
…layer Desktop commands that had their own copy of logic the web RPC already gets from `application/` now call the application layer, so both transports behave the same. The desktop app manages one `Arc<ApplicationState>`; its fields are `Arc`s so the per-field Tauri state shares the same instances. Desktop behaviour the application layer lacked moved into it first: - deleting a connection also removes its query history; a cascading group delete now cleans up secrets, plugin secrets, icons and history of every connection in the group (neither side did that before) - AWS IAM connections never fall back to a stored password, testing one without a token fails with the actionable message, and duplicates do not copy the token - a URI marked as stored in the keychain but missing fails a connect with a clear message - SSH secrets are only kept while the tunnel is enabled, and an empty passphrase field keeps the stored one - an unknown connection id in a test is treated as an ad-hoc connection; the dbConnect step shows host:port Web parity fixes found on the way: - `list_databases` had no RPC route; the connection dialog failed to load databases in the browser - the connection dialog treats a URI that only lives in the keychain as present, so editing a passthrough connection no longer fails with "Connection URI is required" - `create_sqlite_database` moved from the RPC handler into the application layer Also: theme package installs from a path read the archive inside the cancellable install again, `run_connections_backup` returns the same object on both transports, notebooks use the runtime paths, and kubectl calls no longer block the async runtime on desktop.
Tauri commands and everything that needs an AppHandle, a window or Tauri state now live in `src-tauri/src/transport/desktop/`, next to `transport/web`. It is the only module behind the `desktop` feature, so the rest of the crate no longer carries per-item `cfg(feature = "desktop")` or `cfg_attr(..., tauri::command)` attributes. - `transport/desktop/<module>.rs` mirrors the module the code came from; commands the web RPC also calls stay plain functions and get a one-line Tauri wrapper there - `run()` moved from lib.rs with the handler list unchanged (308 commands) - the askpass bridge keeps the app's `RuntimeEvents` instead of a Tauri `AppHandle` - helpers the desktop code needs became `pub(crate)` No behaviour changes. `.rules/rust.md` documents the boundary and CI fails when Tauri shows up outside `transport/desktop`.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Notes
Assumptions and gaps
Files Reviewed (118 files)
Reviewed by claude-sonnet-5.5 · Input: 320 · Output: 10.3K · Cached: 3.5M Review guidance: REVIEW.md from base branch |
None of these 15 registered commands has a caller in the frontend, the e2e suites or the plugin API (plugins must not invoke Tauri commands): list_all_preferences, get_theme, save_blob_to_file, preview_tabularis_import, apply_tabularis_import, export_connections_payload, import_connections_payload, encrypt_export_payload, decrypt_export_payload, open_visual_explain_window, open_json_viewer_window, get_json_viewer_session, complete_json_viewer_session, open_results_window and close_results_window. The JSON viewer and results windows are opened from the frontend, so their Rust session stores (`json_viewer`, `results_window`) were write-only and go too. The driver method `save_blob_to_file` stays; only the command that wrapped it is gone.
Points contributors and their agents at transport/desktop for Tauri code and lists what in-flight branches need to change when they rebase.
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1255 (targets
feat/web-slim). Goal: app and web run the same logic, and Tauri lives in one place instead of behindcfgattributes all over the crate.Five commits, kept apart on purpose (
.rules/rust.mdrule 6):transport::desktop(structure only)list_databasesagainst real Postgres/MySQLAGENTS.md: a notice at the top plus a "Backend layout" section, so contributors and their agents see the new structure. It sits outside the GitNexus-managed block, so re-indexing keeps it.1. Desktop and web share the logic
Before, about 90 desktop commands had their own copy of logic the web RPC already got from
application/. The biggest were connection save/update/duplicate/delete/test at 140 to 240 lines each. Those commands now callapplication/too. The desktop app manages oneArc<ApplicationState>; its fields becameArcs, so the per-field Tauri state and the application layer share the same caches.Desktop behaviour the application layer was missing moved there first, so the desktop app loses nothing and the web gains it:
dbConnectprogress step showshost:port.Web parity gaps fixed on the way:
list_databaseshad no RPC route. The connection dialog could not load the database list in the browser. It now has a route with the same authorization rules astest_connection.create_sqlite_databasemoved from the RPC handler intoapplication/, so both transports use the same code.Smaller fixes:
run_connections_backupreturns the same object on both transports. Thestringbranch inBackupTaband in the contract is gone.QueryHistoryStateis removed; it was an empty marker type.2. One Tauri transport
transport/desktop/<module>.rsmirrors the module the code came from.transport/desktopholds a one-line#[tauri::command]wrapper for each.run()moved fromlib.rsunchanged. It still registers all 308 commands, and the generated inventory confirms the list is unchanged. After commit 4 it registers 293.RuntimeEventsinstead of a TauriAppHandle, soaskpasshas nocfgleft.transport/desktop, the onlydesktopgates are thetransport::desktopdeclaration,async_rtand therun()dispatch inlib.rs.The rule for new code is in
.rules/rust.md(rule 7). CI enforces it with a grep: notauri::ortauri_pluginoutsidetransport/desktop. A Tauri-only change therefore can't break the server build unnoticed.Intentional differences that stay
get_connection_by_idsave_connection_icon, blob/SQL/explain file commands, imports/exportsget_connectionsRemoved dead code
Each of these 15 registered commands was checked with
rg -wacross the repository: no caller inpackages/,web-ui-project/,e2e/or the plugin API. The plugin guide forbids plugins from invoking Tauri commands.list_all_preferencesget_themeget_theme_catalog.save_blob_to_filefetch_blob. The driver method of the same name stays.preview_tabularis_import,apply_tabularis_importpreview_tabularis_import_fileandapply_prepared_tabularis_import.export_connections_payload,import_connections_payload,encrypt_export_payload,decrypt_export_payloadapplication/connection_filesdoes the same work for the file-based flow.open_visual_explain_window--explainCLI path still opens the window throughspawn_visual_explain_window.open_json_viewer_window,get_json_viewer_session,complete_json_viewer_session,open_results_window,close_results_windowWebviewWindow. Their Rust session stores were write-only, so thejson_viewerandresults_windowmodules and theirApplicationStatefields went too.That is about 740 lines.
Verified
cargo test --lib: 2135 passed. Before: 2154.cargo checkwith default features,--features e2e-testing,--no-default-features --bin tabularisand--tests: no new warnings.test:web-resiliencepasses.pnpm test: 7082 passed.web:inventory,web:boundaries,web:packaging,web:docs,web:manual-parity,test:web-contract.list_databasescheck.State<T>a command asks for is managed inrun().--no-default-features,docker/smoke-test.shpasses 8/8, and the image size is unchanged.detect_changesrates both refactor commits "critical". That reflects the number of moved and rerouted symbols. Tauri commands are called by name from the frontend, so the graph does not see those edges.