Skip to content

Commit f3f5d8b

Browse files
t3dotggclaude
andcommitted
fix(web): migration falls back to a surviving surface when the active one is dropped
An open [diff, plan] panel with plan active would migrate to an open panel with no active surface, rendering empty. Fall back to the first survivor. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent b2fd0d9 commit f3f5d8b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎apps/web/src/rightPanelStore.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe("rightPanelStore", () => {
130130
},
131131
"env-1:thread-B": {
132132
isOpen: true,
133-
activeSurfaceId: null,
133+
activeSurfaceId: "diff",
134134
surfaces: [{ id: "diff", kind: "diff" }],
135135
},
136136
},

‎apps/web/src/rightPanelStore.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export function migratePersistedRightPanelState(persistedState: unknown): {
229229
];
230230
})
231231
: [];
232-
const activeSurfaceId = surfaces.some(
232+
const persistedActiveSurfaceId = surfaces.some(
233233
(surface) => surface.id === validThreadState?.activeSurfaceId,
234234
)
235235
? (validThreadState?.activeSurfaceId ?? null)
@@ -240,7 +240,12 @@ export function migratePersistedRightPanelState(persistedState: unknown): {
240240
surfaces.length > 0 &&
241241
(typeof validThreadState?.isOpen === "boolean"
242242
? validThreadState.isOpen
243-
: activeSurfaceId !== null);
243+
: persistedActiveSurfaceId !== null);
244+
// An open panel needs an active surface: if migration dropped
245+
// the persisted one (e.g. plan was active), fall back to the
246+
// first survivor instead of rendering an open empty panel.
247+
const activeSurfaceId =
248+
persistedActiveSurfaceId ?? (isOpen ? (surfaces[0]?.id ?? null) : null);
244249
return [threadKey, { isOpen, surfaces, activeSurfaceId }];
245250
},
246251
),

0 commit comments

Comments
 (0)