fix: cloud switch retry and encrypted catalog availability handling

- Fix cloud environment switch showing ON for error/offline states, which
  blocked retry since React Native Switch only fires onValueChange on
  transitions. The switch now only shows ON for connected/connecting/
  reconnecting states, allowing users to toggle ON to retry from error
  or offline states.

- Fix DesktopConnectionCatalogStore.get returning an empty Option when
  an encrypted catalog exists but safe storage is unavailable. This
  silently hid the catalog and risked overwriting it. Now fails with
  ElectronSafeStorageAvailabilityError so callers can surface the issue
  instead of treating it as an empty catalog.
This commit is contained in:
Cursor Agent committed 2026-06-21 21:34:09 +00:00
1 parent 38f46e6971
commit b2af107f91
2 files changed
+10 -2

No files matched your search

@@ -300,7 +300,11 @@ export const layer = Layer.effect(
return yield* migrateLegacyCatalog;
}
if (!(yield* safeStorage.isEncryptionAvailable)) {
return Option.none<string>();
return yield* new ElectronSafeStorage.ElectronSafeStorageAvailabilityError({
cause: new Error(
"Safe storage encryption is unavailable; cannot decrypt the existing connection catalog",
),
});
}
const decrypted = yield* decodeSecretBytes(document.value.encryptedCatalog).pipe(
Effect.flatMap(safeStorage.decryptString),
@@ -255,7 +255,11 @@ function ConnectedCloudEnvironmentRow(props: {
props.onDisconnect();
}}
onToggleError={props.onToggleError}
value={props.environment.connectionState !== "available"}
value={
props.environment.connectionState === "connected" ||
props.environment.connectionState === "connecting" ||
props.environment.connectionState === "reconnecting"
}
/>
);
}