Workspaces and synchronization
Workspaces give one Rowel installation several separate encrypted vaults. Each workspace can stay on the device or sync its own vault with Google Drive, while the app presents one active workspace at a time. The frontend selects workspaces and shows state; native code opens vaults, owns credentials, performs sync, and reports the result.
This page complements Vault data and sync, Vault lifecycle and persistence, and Import, export, and backup.
Workspace model
Workspace identity
A workspace is a separate encrypted database with its own vault identity. An installation starts with one primary workspace, and additional workspaces are optional. Only one vault is open at a time, so changing the active workspace also changes which entries, sync account, and session data the app uses. New workspaces use the device master password; a restored workspace keeps the password of the vault it came from.
The workspace registry holds the information needed before a vault is unlocked. Its metadata has different scopes:
| Metadata | Purpose | Scope |
|---|---|---|
| Name | Labels the workspace in the picker and settings | Travels with the vault when renamed |
| Vault ID | Identifies the remote vault after sync has established one | Used to avoid restoring the same vault twice |
| Sync status | Shows whether the workspace has a Drive connection on this device | Read live from the workspace's own connection |
| Item count | Gives a locked workspace a last-known size | Stored on this device and can be stale |
| Color | Styles the workspace tile | Stored on this device only |
The registry is descriptive metadata, not the vault itself. A missing registry still represents the normal single-primary-workspace case. The frontend therefore treats registry data and live sync state as related but different facts.
References: src/…/types.ts• L189-220 src-tauri/…/workspace.rs• L27-53 src/…/about.ts• L5-41
Workspace selection
The workspace picker is the common selector on the main shell and the lock screen. It shows the active workspace as the current chip and keeps the other workspaces in the menu. A single-workspace installation does not need the picker.
Selection follows one of two paths:
- The frontend asks native code to select the workspace.
- Native code closes the current session and records the new active workspace.
- If the target key is already available on the device, native code opens the target vault and the frontend returns to the main view.
- If the target has not been opened on this device, native code emits the normal vault-locked result and the frontend shows that workspace's lock screen.
- The frontend refreshes its app status so the name, metadata, biometric gate, and active workspace change together.
This diagram shows how selection reaches either an open vault or the target lock screen.
flowchart LR
A[Workspace picker] --> B[Select workspace]
B --> C{Target key available?}
C -->|Yes| D[Open target vault]
C -->|No| E[Show target lock screen]
D --> F[Refresh app status]
E --> F
F --> G[Render target metadata and session]
The frontend allows one switch at a time and blocks a switch while a sync or path-sensitive Drive flow is active. A keyless account probe may still be waiting when the user changes workspaces, so native adoption checks that the workspace and vault are still the same before it seals credentials. This prevents a network result for one workspace from being attached to another.
References: src/…/workspace.ts• L32-70 src-tauri/…/workspace.rs• L50-232 src-tauri/…/sync.rs• L104-149 src/…/workspaces.test.tsx• L36-64
Remote Drive integration
Drive account connection
Google Drive is an optional provider for the active workspace. A connection starts with a keyless browser consent flow and an account probe. Native code lists the encrypted Rowel vaults in the account before it seals the returned credentials under the open workspace's key. This keeps account inspection separate from committing a connection to a vault.
The account can be adopted when it is empty or already contains this workspace's vault. If it contains only other vaults, the app does not create an unrelated pack beside them. Instead, it offers those vaults as restore choices. This keeps one Google account as the set of vaults that the connected devices share.
Connection state is held by the workspace. Two workspaces can use the same Google account while keeping separate credentials and separate remote vault files. Disconnecting removes this workspace's local connection; it does not remove the remote pack or revoke Google's account-wide grant.
References: src/…/sync.ts• L47-81 src-tauri/…/sync.rs• L46-113 src-tauri/…/sync.rs• L115-198 src-tauri/…/sync.rs• L236-266
Remote workspace discovery
After a successful sync, native code compares the vaults in the account with the workspaces on this device. Vaults that are remote-only become restore choices in Settings under the connected account. The list belongs to the active workspace's account and is cleared when that workspace is locked or changed.
Restoring a remote-only vault creates a new local workspace. It uses the remote vault's own password, keeps the account connection, and opens the restored workspace when the operation succeeds. No second sign-in is needed because the active workspace already supplied the account connection.
References: src/…/events.ts• L35-56 src/…/app.ts• L85-91 src/…/RemoteVaults.tsx• L9-59 src-tauri/…/workspace.rs• L507-577
Synchronization operations
Sync lifecycle
Synchronization exchanges one encrypted snapshot for the active vault. A run first reads the matching remote pack, merges remote changes into the local vault, and then uploads a new snapshot when the two sides differ. The merge is designed to converge: a device that loses an upload race can pull the newer snapshot on its next run and combine the states rather than silently discard local work.
Runs can start from a manual action, a local change, a new connection, or an unlock. The frontend delays automatic sync for a short period after a write so a group of saves becomes one run. Native code permits only one run at a time and keeps a follow-up request when a write arrives during an active run. All run requests use the same launcher, including manual sync and the first run after connection, so two runs cannot select different remote packs for one vault.
This diagram shows how one sync request becomes a remote read, a merge, and an optional upload.
flowchart LR
A[Unlock, connect, manual request, or local change] --> B[Start one run]
B --> C[Read matching Drive pack]
C --> D[Merge remote state]
D --> E{Local and remote differ?}
E -->|Yes| F[Upload encrypted snapshot]
E -->|No| G[Finish without upload]
F --> H[Publish sync result]
G --> H
H --> I[Refresh entries and remote workspace list]
The remote pack keeps the vault data encrypted. The provider can read enough account metadata to list and select packs, but the vault contents are opened with the vault's own key.
References: src/…/app.ts• L264-334 src-tauri/…/sync.rs• L269-291 src-tauri/…/sync.rs• L540-705 src-tauri/…/mod.rs• L218-269 src-tauri/…/engine.rs• L147-220 src-tauri/…/pack.rs• L1-18
Workspace lifecycle operations
Workspace creation, restore, and deletion change both local workspace state and possible remote state. They therefore use the same native boundary as switching and prevent overlapping sync work.
| Operation | Local result | Remote result |
|---|---|---|
| Create | Adds an empty workspace and opens it | Inherits the active account when one exists, then gets its own vault pack on the first run |
| Restore from Drive | Downloads a selected pack into a new workspace | Keeps that workspace connected to the account |
| Restore from account | Adds a remote-only vault without another sign-in | Uses the active workspace's existing account connection |
| Delete locally | Removes the workspace from this device | Leaves its Drive pack available for later restore |
| Delete everywhere | Removes the workspace from this device | Removes the pack and marks it deleted so another device does not upload it again |
The last workspace cannot be deleted. If the active workspace is deleted, the app ends its session and lands on a surviving workspace's lock screen. A failed remote deletion happens before local removal, so the user can retry while the local workspace still has the credentials needed for the request. Local file moves are staged and journaled, which lets launch recovery either restore the old layout or finish a deletion that was already recorded.
References: src/…/workspace.ts• L16-78 src/…/workspace.ts• L73-166 src-tauri/…/workspace.rs• L257-384 src-tauri/…/workspace.rs• L507-747 src-tauri/…/workspace.rs• L875-1055 src-tauri/…/workspace.rs• L56-263
Synchronization feedback
Sync status
The backend sends a complete sync snapshot for every connection, run, disconnect, and failure transition. The frontend stores that snapshot instead of rebuilding state from a sequence of smaller events. The snapshot tells the UI whether the workspace is configured, waiting for consent, running, failed, and when a run last succeeded. Disconnect clears the old success time so the UI does not present an earlier connection as current.
The launch probe also carries sync status. Each snapshot has a sequence value so a late probe cannot replace a newer event with older state. This matters during workspace switches because the status for the workspace being left can arrive after the new workspace has become active.
References: src/…/sync.ts• L10-34 src/…/events.ts• L28-44 src/…/app.ts• L140-172 src/…/events.ts• L37-58 src-tauri/…/sync.rs• L454-537
User-facing sync states
The header indicator gives the user a persistent view of where the active vault lives and what its latest sync means. Its state is derived from the backend snapshot in this order:
| State | Meaning | User signal |
|---|---|---|
| Local | No provider is connected | Changes stay on this device |
| Waiting | A provider is connected but no successful run is recorded | The app does not claim that the vault is current |
| Syncing | A run is active | A progress ring shows work in progress |
| Successful | A run completed and has a success time | A success badge and last-sync time are available |
| Failed | The last connection or run failed | A failure badge shows readable error detail |
A successful merge can also refresh the visible entry list and archive. A sync can report that another device renamed the active workspace, in which case the frontend re-reads app status so the header and workspace list use the new name. If another device deleted the remote pack, runs stop and Settings offers local deletion of the stranded workspace.
References: src/…/state.ts• L4-49 src/…/index.tsx• L16-58 src/…/WorkspaceList.tsx• L31-81 src/…/events.ts• L41-58
Frontend and native workspace boundaries
Frontend responsibilities
The frontend owns presentation and short-lived interaction state. It reads workspace and sync snapshots from the app store, sends typed commands for user actions, and reacts to native events by refreshing the relevant view or replacing the entry list.
The frontend does not decide which remote pack belongs to a vault. It also does not open encrypted databases, hold the provider's durable credentials, or infer sync state from whether a button was clicked. Those facts come from native responses and events. It also does not attach a pending account probe to a new workspace after a switch; native code owns that identity check.
References: src/…/workspace.ts• L1-120 src/…/sync.ts• L1-81 src/…/app.ts• L239-277 src/…/events.ts• L37-70 src-tauri/…/sync.rs• L104-198
Native responsibilities
Native workspace code owns vault paths, workspace registry changes, password checks, session transitions, deletion recovery, and the rules that keep workspace operations apart from sync. Native sync code owns provider consent, pending-account adoption, encrypted credentials, remote pack selection, pull-and-merge work, uploads, run exclusion, and complete status events.
The boundary is asynchronous. Commands start work and return control to the UI; native code reports progress and results through typed events. The frontend can therefore remain responsive while Drive or vault work runs, while still receiving one authoritative status for the active workspace.
References: src-tauri/…/workspace.rs• L1-24 src-tauri/…/sync.rs• L1-26 src-tauri/…/sync.rs• L540-705 src-tauri/…/mod.rs• L1-18 src-tauri/…/workspace.rs• L1-11 src-tauri/…/workspace.rs• L117-263
Change checklist
When these files or sections are changed, remember to consider these:
- Keep workspace metadata scope aligned: names and vault IDs support cross-device behavior, while colors and item counts must remain device-local.
- Keep the workspace picker, lock-screen landing, and app-status refresh in step when a workspace command can end in either an open vault or a lock screen.
- Keep
SyncStatuscomplete across the native event, launch probe, store ordering, and header indicator. A partial transition can show an old workspace's result on the new workspace. - Keep remote-only vault discovery tied to the active workspace's account and clear it when that workspace session ends.
- Keep connection adoption separate from account probing. An account that contains only other vaults must remain a restore offer rather than create a second unrelated pack.
- Keep a pending account probe bound to both the workspace and vault that started it. A workspace switch during the probe must not seal credentials into the new workspace.
- Keep every run request behind the single run claim and preserve one rerun request for writes that arrive during a run.
- Keep local deletion and remote deletion ordered so a failed Drive request does not remove the local credentials needed for retry.
- Keep the local delete journal consistent with the registry decision so launch recovery can distinguish an uncommitted move from a committed delete.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A workspace switch starts during a sync or path-sensitive Drive flow | Credentials or files can be used for the wrong workspace | Native code rejects the switch while the relevant flow is busy |
| A late app-status probe replaces a newer sync event | The indicator shows stale connection or run state | The frontend keeps the snapshot with the higher sequence value |
| A Google account contains other vaults but not the active vault | The app could create an unrelated pack beside the account's existing vaults | Adoption is refused and the account's vaults are offered for restore |
| A remote pack is deleted on another device | This workspace can no longer sync to its account copy | Runs stop and Settings offers local deletion of the stranded workspace |
| A workspace changes while Google is probing a pending account | Credentials can be sealed under the wrong vault | Adoption compares the saved workspace and vault identity again before writing tokens |
| A write arrives while a run is active | The new change may not be included in the active snapshot | The run leaves one rerun request and launches it after releasing the claim |
| The last workspace is selected for deletion | The installation would have no vault to open | Native deletion rejects the operation |
| A remote deletion fails before local deletion | A retry could lose the only local credentials for the remote action | Remote removal runs first and local files stay in place on failure |
| A crash interrupts local workspace deletion | Registry and vault files can point to different workspace sets | A journal lets launch recovery undo an uncommitted move or finish a committed one |
| A workspace's vault name changes on another device | The registry and header can keep showing the old label | Sync emits a rename event and the frontend re-probes app status |
Key files
| File | Why to read it |
|---|---|
| src/…/types.ts | Defines the workspace metadata that crosses the native/frontend boundary. |
| src/…/workspace.ts | Shows how the frontend coordinates selection, creation, restore, and deletion. |
| src/…/app.ts | Shows active-session cleanup, sync scheduling, status ordering, and remote workspace state. |
| src/…/sync.ts | Defines the sync status contract and user actions exposed to the frontend. |
| src/…/events.ts | Maps native workspace and sync events to visible frontend state. |
| src/…/WorkspaceList.tsx | Shows how workspace state, remote deletion, and selection feedback appear in Settings. |
| src/…/RemoteVaults.tsx | Shows the restore path for vaults found in the connected account. |
| src/…/state.ts | Defines the user-facing meaning of each sync state. |
| src-tauri/…/workspace.rs | Defines the native workspace registry, metadata state, and delete recovery. |
| src-tauri/…/workspace.rs | Coordinates native workspace selection, restore, rename, and deletion. |
| src-tauri/…/sync.rs | Coordinates provider connection, account adoption, run scheduling, and sync feedback. |
| src-tauri/…/mod.rs | Connects the Drive provider to the sync engine and publishes remote workspace choices. |
| src-tauri/…/engine.rs | Explains the pull, merge, and push behavior that makes devices converge. |