Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix: guard against missing sidebarProjectGroupingOverrides in client settings (#2099)

Julius Marminge549043863a3c
diff --git a/apps/desktop/src/clientPersistence.ts b/apps/desktop/src/clientPersistence.ts
index 183de1a97..ad08a0036 100644
--- a/apps/desktop/src/clientPersistence.ts
+++ b/apps/desktop/src/clientPersistence.ts
@@ -1,8 +1,13 @@
import * as FS from "node:fs";
import * as Path from "node:path";
-import type { ClientSettings, PersistedSavedEnvironmentRecord } from "@t3tools/contracts";
+import {
+ ClientSettingsSchema,
+ type ClientSettings,
+ type PersistedSavedEnvironmentRecord,
+} from "@t3tools/contracts";
import { Predicate } from "effect";
+import * as Schema from "effect/Schema";
interface ClientSettingsDocument {
readonly settings: ClientSettings;
@@ -83,7 +88,15 @@ function toPersistedSavedEnvironmentRecord(
}
export function readClientSettings(settingsPath: string): ClientSettings | null {
- return readJsonFile<ClientSettingsDocument>(settingsPath)?.settings ?? null;
+ const raw = readJsonFile<ClientSettingsDocument>(settingsPath)?.settings;
+ if (!raw) {
+ return null;
+ }
+ try {
+ return Schema.decodeUnknownSync(ClientSettingsSchema)(raw);
+ } catch {
+ return null;
+ }
}
export function writeClientSettings(settingsPath: string, settings: ClientSettings): void {
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 1c66af57b..c3fae158b 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1379,7 +1379,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
const overrideKey = deriveProjectGroupingOverrideKey(member);
setProjectGroupingTarget(member);
setProjectGroupingSelection(
- projectGroupingSettings.sidebarProjectGroupingOverrides[overrideKey] ?? "inherit",
+ projectGroupingSettings.sidebarProjectGroupingOverrides?.[overrideKey] ?? "inherit",
);
},
[projectGroupingSettings.sidebarProjectGroupingOverrides],
diff --git a/apps/web/src/hooks/useSettings.ts b/apps/web/src/hooks/useSettings.ts
index 664d5ee3b..c2301b23a 100644
--- a/apps/web/src/hooks/useSettings.ts
+++ b/apps/web/src/hooks/useSettings.ts
@@ -64,7 +64,7 @@ async function hydrateClientSettings(): Promise<void> {
try {
const persistedSettings = await ensureLocalApi().persistence.getClientSettings();
if (persistedSettings) {
- replaceClientSettingsSnapshot(persistedSettings);
+ replaceClientSettingsSnapshot({ ...DEFAULT_CLIENT_SETTINGS, ...persistedSettings });
}
} catch (error) {
console.error(`${CLIENT_SETTINGS_PERSISTENCE_ERROR_SCOPE} hydrate failed`, error);
diff --git a/apps/web/src/logicalProject.ts b/apps/web/src/logicalProject.ts
index 6b84fa6dc..d30bb60ca 100644
--- a/apps/web/src/logicalProject.ts
+++ b/apps/web/src/logicalProject.ts
@@ -70,7 +70,7 @@ export function resolveProjectGroupingMode(
settings: ProjectGroupingSettings,
): SidebarProjectGroupingMode {
return (
- settings.sidebarProjectGroupingOverrides[deriveProjectGroupingOverrideKey(project)] ??
+ settings.sidebarProjectGroupingOverrides?.[deriveProjectGroupingOverrideKey(project)] ??
settings.sidebarProjectGroupingMode
);
}