Skip to content

Commit c5f4c91

Browse files
tyulyukovclaude
andcommitted
fix(sidebar): handle undefined sidebarProjectGroupingOverrides on stale settings
readClientSettings() loads client-settings.json as a raw JSON blob without running the schema decoder, so users with pre-upgrade settings files have no sidebarProjectGroupingOverrides key. Dereferencing it with bracket access threw "Cannot read properties of undefined (reading '\${envId}:\${path}')" and blocked the app from opening. - resolveProjectGroupingMode: optional-chain the overrides record and fall back to DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE when the mode itself is missing - openProjectGroupingDialog: optional-chain the overrides lookup - Grouping-rule Select "global default" label falls back to the default mode when settings.sidebarProjectGroupingMode is missing Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6673ca8 commit c5f4c91

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

apps/web/src/components/Sidebar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { CSS } from "@dnd-kit/utilities";
3939
import {
4040
type ContextMenuItem,
4141
DEFAULT_MODEL_BY_PROVIDER,
42+
DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE,
4243
type DesktopUpdateState,
4344
type EnvironmentId,
4445
ProjectId,
@@ -1266,7 +1267,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
12661267
const overrideKey = deriveProjectGroupingOverrideKey(member);
12671268
setProjectGroupingTarget(member);
12681269
setProjectGroupingSelection(
1269-
projectGroupingSettings.sidebarProjectGroupingOverrides[overrideKey] ?? "inherit",
1270+
projectGroupingSettings.sidebarProjectGroupingOverrides?.[overrideKey] ?? "inherit",
12701271
);
12711272
},
12721273
[projectGroupingSettings.sidebarProjectGroupingOverrides],
@@ -2089,7 +2090,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
20892090
<SelectTrigger className="w-full" aria-label="Project grouping rule">
20902091
<SelectValue>
20912092
{projectGroupingSelection === "inherit"
2092-
? `Use global default (${PROJECT_GROUPING_MODE_LABELS[projectGroupingSettings.sidebarProjectGroupingMode]})`
2093+
? `Use global default (${PROJECT_GROUPING_MODE_LABELS[projectGroupingSettings.sidebarProjectGroupingMode ?? DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE]})`
20932094
: PROJECT_GROUPING_MODE_LABELS[projectGroupingSelection]}
20942095
</SelectValue>
20952096
</SelectTrigger>

apps/web/src/logicalProject.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { scopedProjectKey, scopeProjectRef } from "@marcode/client-runtime";
2-
import type { ScopedProjectRef, SidebarProjectGroupingMode } from "@marcode/contracts";
2+
import {
3+
DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE,
4+
type ScopedProjectRef,
5+
type SidebarProjectGroupingMode,
6+
} from "@marcode/contracts";
37
import { normalizeProjectPathForComparison } from "./lib/projectPaths";
48
import type { Project } from "./types";
59

@@ -70,8 +74,9 @@ export function resolveProjectGroupingMode(
7074
settings: ProjectGroupingSettings,
7175
): SidebarProjectGroupingMode {
7276
return (
73-
settings.sidebarProjectGroupingOverrides[deriveProjectGroupingOverrideKey(project)] ??
74-
settings.sidebarProjectGroupingMode
77+
settings.sidebarProjectGroupingOverrides?.[deriveProjectGroupingOverrideKey(project)] ??
78+
settings.sidebarProjectGroupingMode ??
79+
DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE
7580
);
7681
}
7782

0 commit comments

Comments
 (0)