Introducing a new way to review your PRs.

Read the announcement

fwdai / rowel

🔑 Local-first Secrets Manager

View on GitHub

23 documents · Updated Oct 9, 2026

docs / workspace-and-sync

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:

MetadataPurposeScope
NameLabels the workspace in the picker and settingsTravels with the vault when renamed
Vault IDIdentifies the remote vault after sync has established oneUsed to avoid restoring the same vault twice
Sync statusShows whether the workspace has a Drive connection on this deviceRead live from the workspace's own connection
Item countGives a locked workspace a last-known sizeStored on this device and can be stale
ColorStyles the workspace tileStored 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:

  1. The frontend asks native code to select the workspace.
  2. Native code closes the current session and records the new active workspace.
  3. If the target key is already available on the device, native code opens the target vault and the frontend returns to the main view.
  4. 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.
  5. 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.

OperationLocal resultRemote result
CreateAdds an empty workspace and opens itInherits the active account when one exists, then gets its own vault pack on the first run
Restore from DriveDownloads a selected pack into a new workspaceKeeps that workspace connected to the account
Restore from accountAdds a remote-only vault without another sign-inUses the active workspace's existing account connection
Delete locallyRemoves the workspace from this deviceLeaves its Drive pack available for later restore
Delete everywhereRemoves the workspace from this deviceRemoves 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:

StateMeaningUser signal
LocalNo provider is connectedChanges stay on this device
WaitingA provider is connected but no successful run is recordedThe app does not claim that the vault is current
SyncingA run is activeA progress ring shows work in progress
SuccessfulA run completed and has a success timeA success badge and last-sync time are available
FailedThe last connection or run failedA 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 SyncStatus complete 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

TriggerConsequenceGuard
A workspace switch starts during a sync or path-sensitive Drive flowCredentials or files can be used for the wrong workspaceNative code rejects the switch while the relevant flow is busy
A late app-status probe replaces a newer sync eventThe indicator shows stale connection or run stateThe frontend keeps the snapshot with the higher sequence value
A Google account contains other vaults but not the active vaultThe app could create an unrelated pack beside the account's existing vaultsAdoption is refused and the account's vaults are offered for restore
A remote pack is deleted on another deviceThis workspace can no longer sync to its account copyRuns stop and Settings offers local deletion of the stranded workspace
A workspace changes while Google is probing a pending accountCredentials can be sealed under the wrong vaultAdoption compares the saved workspace and vault identity again before writing tokens
A write arrives while a run is activeThe new change may not be included in the active snapshotThe run leaves one rerun request and launches it after releasing the claim
The last workspace is selected for deletionThe installation would have no vault to openNative deletion rejects the operation
A remote deletion fails before local deletionA retry could lose the only local credentials for the remote actionRemote removal runs first and local files stay in place on failure
A crash interrupts local workspace deletionRegistry and vault files can point to different workspace setsA journal lets launch recovery undo an uncommitted move or finish a committed one
A workspace's vault name changes on another deviceThe registry and header can keep showing the old labelSync emits a rename event and the frontend re-probes app status

Key files

FileWhy to read it
src/…/types.tsDefines the workspace metadata that crosses the native/frontend boundary.
src/…/workspace.tsShows how the frontend coordinates selection, creation, restore, and deletion.
src/…/app.tsShows active-session cleanup, sync scheduling, status ordering, and remote workspace state.
src/…/sync.tsDefines the sync status contract and user actions exposed to the frontend.
src/…/events.tsMaps native workspace and sync events to visible frontend state.
src/…/WorkspaceList.tsxShows how workspace state, remote deletion, and selection feedback appear in Settings.
src/…/RemoteVaults.tsxShows the restore path for vaults found in the connected account.
src/…/state.tsDefines the user-facing meaning of each sync state.
src-tauri/…/workspace.rsDefines the native workspace registry, metadata state, and delete recovery.
src-tauri/…/workspace.rsCoordinates native workspace selection, restore, rename, and deletion.
src-tauri/…/sync.rsCoordinates provider connection, account adoption, run scheduling, and sync feedback.
src-tauri/…/mod.rsConnects the Drive provider to the sync engine and publishes remote workspace choices.
src-tauri/…/engine.rsExplains the pull, merge, and push behavior that makes devices converge.