Skip to content

Automate browser based workflows with AI

feat(SKY-11890): persist edit-class studio pane layout (#7112)

Celal Zamanoğlu8ab0db16d1ee
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.test.tsx
index 584b20053..d27aff4ae 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.test.tsx
@@ -6,6 +6,7 @@ import { MemoryRouter } from "react-router-dom";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { useStudioFirstRunStore } from "@/store/StudioFirstRunStore";
+import { useStudioShellStore } from "@/store/StudioShellStore";
import { StudioPaneDefaultsProvider } from "./StudioPaneDefaults";
import { useStudioPaneDefaults } from "./StudioPaneDefaultsContext";
@@ -76,6 +77,7 @@ beforeEach(() => {
coachMarkSeen: false,
narrowNudgeSeen: false,
});
+ useStudioShellStore.getState().reset();
toastMock.mockReset();
});
@@ -196,3 +198,131 @@ describe("narrow-viewport nudge", () => {
expect(useStudioFirstRunStore.getState().coachMarkSeen).toBe(true);
});
});
+
+// GestureLearningProbe calls togglePane with and without the learn flag so
+// tests can verify which writes reach the store.
+function GestureLearningProbe() {
+ const { panes, togglePane } = useStudioPanes();
+ return (
+ <div>
+ <output data-testid="panes">{panes.join(",")}</output>
+ <button onClick={() => togglePane("editor", { learn: true })}>
+ gesture-toggle-editor
+ </button>
+ <button onClick={() => togglePane("overview")}>
+ system-toggle-overview
+ </button>
+ </div>
+ );
+}
+
+function renderGestureStudio({
+ path = "/workflows/wpid_1/studio",
+ hasBlocks = true,
+}: { path?: string; hasBlocks?: boolean } = {}) {
+ return render(
+ <MemoryRouter initialEntries={[path]}>
+ <StudioPaneDefaultsProvider hasBlocks={hasBlocks}>
+ <GestureLearningProbe />
+ </StudioPaneDefaultsProvider>
+ </MemoryRouter>,
+ );
+}
+
+describe("gesture learning — edit-class writes reach the store", () => {
+ test("a gesture toggle on an edit URL learns the resulting layout", () => {
+ renderGestureStudio();
+ fireEvent.click(screen.getByText("gesture-toggle-editor"));
+ // default built-agent: copilot,browser,editor → toggle closes editor → copilot,browser
+ expect(useStudioShellStore.getState().paneLayouts["edit"]).toEqual([
+ "copilot",
+ "browser",
+ ]);
+ });
+
+ test("a system (non-gesture) toggle does NOT update the store", () => {
+ renderGestureStudio({
+ path: "/workflows/wpid_1/studio?panes=copilot,browser,overview",
+ });
+ fireEvent.click(screen.getByText("system-toggle-overview"));
+ expect(useStudioShellStore.getState().paneLayouts["edit"]).toBeUndefined();
+ });
+
+ test("a gesture on a run URL learns the run class", () => {
+ renderGestureStudio({
+ path: "/workflows/wpid_1/studio?wr=wr_1&panes=copilot,browser,overview",
+ });
+ fireEvent.click(screen.getByText("gesture-toggle-editor"));
+ expect(useStudioShellStore.getState().paneLayouts["run"]).toBeDefined();
+ expect(useStudioShellStore.getState().paneLayouts["edit"]).toBeUndefined();
+ });
+
+ test("a gesture on a block-iterate URL (wr+bl) does not learn any class", () => {
+ renderGestureStudio({
+ path: "/workflows/wpid_1/studio?wr=wr_1&bl=block_1&panes=copilot,browser,overview",
+ });
+ fireEvent.click(screen.getByText("gesture-toggle-editor"));
+ expect(useStudioShellStore.getState().paneLayouts).toEqual({});
+ });
+});
+
+describe("restore from learned edit layout", () => {
+ test("a built agent restores the last learned edit layout", () => {
+ // Pre-seed the store as if the user previously arranged their panes.
+ useStudioShellStore.getState().setPaneLayout("edit", ["editor", "browser"]);
+
+ renderStudio({ hasBlocks: true });
+ expect(panesText()).toBe("editor,browser");
+ });
+
+ test("an empty agent ignores the learned layout and always shows factory default", () => {
+ useStudioShellStore.getState().setPaneLayout("edit", ["editor", "browser"]);
+
+ renderStudio({ hasBlocks: false });
+ expect(panesText()).toBe("copilot,browser");
+ });
+
+ test("an explicit ?panes= beats the learned layout", () => {
+ useStudioShellStore.getState().setPaneLayout("edit", ["editor", "browser"]);
+
+ renderStudio({ path: "/workflows/wpid_1/studio?panes=overview" });
+ expect(panesText()).toBe("overview");
+ });
+
+ test("a deep-link run URL beats the learned layout", () => {
+ useStudioShellStore.getState().setPaneLayout("edit", ["editor", "browser"]);
+
+ renderStudio({ path: "/workflows/wpid_1/studio?wr=wr_1" });
+ expect(panesText()).toBe("copilot,browser,overview");
+ });
+
+ test("a learned layout with an unknown pane id is sanitized to known ids only", () => {
+ // Inject a stale persisted layout that contains a no-longer-valid id.
+ useStudioShellStore.setState({
+ paneLayouts: {
+ edit: ["editor", "bogus" as never, "browser"],
+ },
+ });
+
+ renderStudio({ hasBlocks: true });
+ expect(panesText()).toBe("editor,browser");
+ });
+
+ test("a learned layout that becomes all-unknown falls back to the factory default", () => {
+ useStudioShellStore.setState({
+ paneLayouts: { edit: ["bogus" as never] },
+ });
+
+ renderStudio({ hasBlocks: true });
+ expect(panesText()).toBe("copilot,browser,editor");
+ });
+
+ test("a corrupted non-array learned layout falls back without throwing", () => {
+ useStudioShellStore.setState({
+ paneLayouts: { edit: "corrupt" as never },
+ });
+
+ renderStudio({ hasBlocks: true });
+ expect(panesText()).toBe("copilot,browser,editor");
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx
index f7d69d030..9a8dbf817 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx
@@ -3,6 +3,7 @@ import { useLocation } from "react-router-dom";
import { toast } from "@/components/ui/use-toast";
import { useStudioFirstRunStore } from "@/store/StudioFirstRunStore";
+import { useStudioShellStore } from "@/store/StudioShellStore";
import { liveSearch } from "./liveSearch";
import {
@@ -10,6 +11,7 @@ import {
fitPanesToWidth,
panesFitWidth,
resolveOpenPanes,
+ STUDIO_PANE_IDS,
type StudioPaneId,
} from "./panes";
import {
@@ -18,12 +20,33 @@ import {
type PaneWrite,
} from "./StudioPaneDefaultsContext";
+// Drop unknown ids and duplicates; return null when the result is empty/invalid.
+function sanitizeLearnedPanes(
+ raw: StudioPaneId[] | undefined,
+): readonly StudioPaneId[] | null {
+ // Guard the localStorage boundary: corrupted/foreign values may not be arrays.
+ if (!Array.isArray(raw) || raw.length === 0) return null;
+ const seen = new Set<string>();
+ const result: StudioPaneId[] = [];
+ for (const id of raw) {
+ if ((STUDIO_PANE_IDS as readonly string[]).includes(id) && !seen.has(id)) {
+ seen.add(id);
+ result.push(id);
+ }
+ }
+ return result.length > 0 ? result : null;
+}
+
/**
* First-visit pane policy for one studio mount. The state-aware default and
* the narrow-viewport clamp are both latched exactly once (the shell remounts
* per workflow via its key), so panes never reshuffle after first paint. The
* blocks signal is synchronous — the shell only mounts with the workflow
* loaded — so the latch decides from real data, never a placeholder.
+ *
+ * Built agents restore the user's last edit-class pane arrangement; empty
+ * agents always start on the factory prompt-and-watch default (deliberate
+ * first-run experience).
*/
export function StudioPaneDefaultsProvider({
hasBlocks,
@@ -34,9 +57,15 @@ export function StudioPaneDefaultsProvider({
}) {
const location = useLocation();
- const [defaultPanes] = useState<readonly StudioPaneId[]>(() =>
- defaultPanesForWorkflowState({ hasBlocks }),
- );
+ const [defaultPanes] = useState<readonly StudioPaneId[]>(() => {
+ if (!hasBlocks) {
+ return defaultPanesForWorkflowState({ hasBlocks });
+ }
+ const learnedEdit = sanitizeLearnedPanes(
+ useStudioShellStore.getState().paneLayouts["edit"],
+ );
+ return learnedEdit ?? defaultPanesForWorkflowState({ hasBlocks });
+ });
const [initialPanes] = useState<readonly StudioPaneId[]>(() =>
resolveOpenPanes(liveSearch(location.search), defaultPanes),
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx
index 0c3837c78..ee68cacf1 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx
@@ -77,7 +77,7 @@ export function StudioPaneToggles() {
if (id === "browser" && !panes.includes("browser")) {
clearBrowserActivity();
}
- togglePane(id);
+ togglePane(id, { learn: true });
};
const paneBlockedByDeletion = (id: StudioPaneId) =>
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx
index fd1d8f647..ebe6fb4af 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx
@@ -636,7 +636,7 @@ function StudioStage(props: StudioWorkspaceProps) {
// The ✕ unmounts with its pane, so hand focus back to the pane's toggle.
const closeWithFocus = (id: StudioPaneId) => {
- closePane(id);
+ closePane(id, { learn: true });
document.getElementById(studioTabId(id))?.focus();
};
@@ -647,7 +647,7 @@ function StudioStage(props: StudioWorkspaceProps) {
if (panesListEqual(next, panes)) {
return;
}
- setPanesOrder(next);
+ setPanesOrder(next, { learn: true });
setReorderAnnouncement(
`${STUDIO_PANE_META[movedId].label} pane moved to position ${
next.indexOf(movedId) + 1
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioStageLauncher.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioStageLauncher.tsx
index e73f0677a..3230ffbc0 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioStageLauncher.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioStageLauncher.tsx
@@ -26,7 +26,7 @@ export function StudioStageLauncher() {
if (id === "browser") {
clearBrowserActivity();
}
- openPane(id);
+ openPane(id, { learn: true });
};
return (
diff --git a/skyvern-frontend/src/routes/workflows/studio/panes.test.ts b/skyvern-frontend/src/routes/workflows/studio/panes.test.ts
index 175c9934a..9e30c4e63 100644
--- a/skyvern-frontend/src/routes/workflows/studio/panes.test.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/panes.test.ts
@@ -9,6 +9,7 @@ import {
STUDIO_PANE_MIN_WIDTH,
defaultPanesForWorkflowState,
fitPanesToWidth,
+ layoutClassForSearch,
panesFitWidth,
panesFromDeepLink,
panesListEqual,
@@ -413,3 +414,37 @@ describe("panesWithoutDeletedBlocked", () => {
expect(DELETED_WORKFLOW_BLOCKED_PANES).toEqual(["copilot", "editor"]);
});
});
+
+describe("layoutClassForSearch", () => {
+ test("no params → edit class", () => {
+ expect(layoutClassForSearch("")).toBe("edit");
+ });
+
+ test("?panes= only → edit class (URL params other than wr/bl don't matter)", () => {
+ expect(layoutClassForSearch("?panes=copilot,browser")).toBe("edit");
+ });
+
+ test("?wr= without ?bl= → run class", () => {
+ expect(layoutClassForSearch("?wr=wr_123")).toBe("run");
+ });
+
+ test("?wr= with ?bl= → null (block-iterate, never learned)", () => {
+ expect(layoutClassForSearch("?wr=wr_123&bl=block_1")).toBeNull();
+ });
+
+ test("?bl= alone (no wr) → null", () => {
+ expect(layoutClassForSearch("?bl=block_1")).toBeNull();
+ });
+
+ test("?wr= with unrelated params → run class", () => {
+ expect(layoutClassForSearch("?wr=wr_123&panes=copilot")).toBe("run");
+ });
+
+ test("?active= without ?wr= → run class (same run test as panesFromDeepLink)", () => {
+ expect(layoutClassForSearch("?active=act_1")).toBe("run");
+ });
+
+ test("?active= with ?bl= → null", () => {
+ expect(layoutClassForSearch("?active=act_1&bl=block_1")).toBeNull();
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/studio/panes.ts b/skyvern-frontend/src/routes/workflows/studio/panes.ts
index 8382d794a..8e73fda73 100644
--- a/skyvern-frontend/src/routes/workflows/studio/panes.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/panes.ts
@@ -1,5 +1,18 @@
export type StudioPaneId = "copilot" | "editor" | "browser" | "overview";
+// "edit" = no run in URL; "run" = run present, no block label; null = block-iterate (never learned).
+export type StudioLayoutClass = "edit" | "run";
+
+export function layoutClassForSearch(search: string): StudioLayoutClass | null {
+ const params = new URLSearchParams(search);
+ if (params.get("bl") !== null) return null;
+ // Same run test as panesFromDeepLink: ?active= is a run reference too.
+ if (params.get("wr") !== null || params.get("active") !== null) {
+ return "run";
+ }
+ return "edit";
+}
+
export const STUDIO_PANE_IDS: readonly StudioPaneId[] = [
"copilot",
"editor",
diff --git a/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts b/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts
index 055e79d91..71cd7fb1c 100644
--- a/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts
@@ -5,8 +5,11 @@ import {
type NavigateOptions,
} from "react-router-dom";
+import { useStudioShellStore } from "@/store/StudioShellStore";
+
import { liveSearch } from "./liveSearch";
import {
+ layoutClassForSearch,
panesListEqual,
panesWithoutDeletedBlocked,
resolveOpenPanes,
@@ -19,6 +22,13 @@ import {
import { useStudioPaneDefaults } from "./StudioPaneDefaultsContext";
import { useStudioWorkflowDeletedAt } from "./StudioShellContext";
+type ApplyPanesOptions = Pick<NavigateOptions, "state"> & {
+ // When true the resulting pane list is stored as the learned default for this
+ // layout class (edit/run). System writes leave this unset so they never
+ // overwrite a user's last-chosen arrangement.
+ learn?: boolean;
+};
+
/**
* Pane state lives in the URL (?panes=), so the open set and its order are
* shareable and can never drift from navigation. Writes merge against the live
@@ -30,6 +40,7 @@ export function useStudioPanes() {
const navigate = useNavigate();
const { defaultPanes, clamp, notePaneWrite } = useStudioPaneDefaults();
const workflowDeleted = useStudioWorkflowDeletedAt() !== null;
+ const setPaneLayout = useStudioShellStore((s) => s.setPaneLayout);
// The mount-time viewport clamp only masks the exact pane list the URL
// carried at mount; any other list means someone navigated, so present it
@@ -66,7 +77,7 @@ export function useStudioPanes() {
const applyPanes = useCallback(
(
compute: (current: StudioPaneId[]) => StudioPaneId[],
- options?: Pick<NavigateOptions, "state">,
+ options?: ApplyPanesOptions,
) => {
const search = liveSearch(location.search);
const current = resolveLivePanes();
@@ -77,8 +88,14 @@ export function useStudioPanes() {
notePaneWrite({ previous: current, next });
navigate(
{ search: searchWithPanes(search, next) },
- { replace: true, ...options },
+ { replace: true, state: options?.state },
);
+ if (options?.learn && next.length > 0 && !workflowDeleted) {
+ const cls = layoutClassForSearch(search);
+ if (cls !== null) {
+ setPaneLayout(cls, next);
+ }
+ }
},
[
navigate,
@@ -86,22 +103,25 @@ export function useStudioPanes() {
resolveLivePanes,
notePaneWrite,
workflowDeleted,
+ setPaneLayout,
],
);
const togglePane = useCallback(
- (id: StudioPaneId) => applyPanes((current) => togglePaneIn(current, id)),
+ (id: StudioPaneId, opts?: Pick<ApplyPanesOptions, "learn">) =>
+ applyPanes((current) => togglePaneIn(current, id), opts),
[applyPanes],
);
const openPane = useCallback(
- (id: StudioPaneId, options?: Pick<NavigateOptions, "state">) =>
+ (id: StudioPaneId, options?: ApplyPanesOptions) =>
applyPanes((current) => withPaneOpen(current, id), options),
[applyPanes],
);
const closePane = useCallback(
- (id: StudioPaneId) => applyPanes((current) => withPaneClosed(current, id)),
+ (id: StudioPaneId, opts?: Pick<ApplyPanesOptions, "learn">) =>
+ applyPanes((current) => withPaneClosed(current, id), opts),
[applyPanes],
);
@@ -115,7 +135,7 @@ export function useStudioPanes() {
// Reorder-only write (drag-and-drop / keyboard move): the live URL keeps
// deciding WHICH panes are open; `order` only decides where they sit.
const setPanesOrder = useCallback(
- (order: readonly StudioPaneId[]) =>
+ (order: readonly StudioPaneId[], opts?: Pick<ApplyPanesOptions, "learn">) =>
applyPanes((current) => {
const next = order.filter(
(id, index) => current.includes(id) && order.indexOf(id) === index,
@@ -126,7 +146,7 @@ export function useStudioPanes() {
}
}
return next;
- }),
+ }, opts),
[applyPanes],
);
diff --git a/skyvern-frontend/src/store/StudioShellStore.test.ts b/skyvern-frontend/src/store/StudioShellStore.test.ts
index 0577f4ce7..848d4425e 100644
--- a/skyvern-frontend/src/store/StudioShellStore.test.ts
+++ b/skyvern-frontend/src/store/StudioShellStore.test.ts
@@ -17,7 +17,7 @@ describe("StudioShellStore", () => {
expect(useStudioShellStore.getState().pipMinimized).toBe(false);
});
- test("persists only PiP and pane-width shell state", () => {
+ test("persists PiP, pane widths, and pane layouts", () => {
useStudioShellStore.getState().setPipMinimized(true);
const raw = localStorage.getItem(STUDIO_SHELL_STORAGE_KEY);
@@ -25,6 +25,7 @@ describe("StudioShellStore", () => {
expect(JSON.parse(raw!).state).toEqual({
pipMinimized: true,
paneWidths: {},
+ paneLayouts: {},
});
});
@@ -46,6 +47,23 @@ describe("StudioShellStore", () => {
).toBe(false);
});
+ test("migrates v1 → v2: keeps paneWidths, adds paneLayouts: {}", async () => {
+ localStorage.setItem(
+ STUDIO_SHELL_STORAGE_KEY,
+ JSON.stringify({
+ state: { pipMinimized: true, paneWidths: { copilot: 400 } },
+ version: 1,
+ }),
+ );
+
+ await useStudioShellStore.persist.rehydrate();
+
+ const state = useStudioShellStore.getState();
+ expect(state.pipMinimized).toBe(true);
+ expect(state.paneWidths).toEqual({ copilot: 400 });
+ expect(state.paneLayouts).toEqual({});
+ });
+
test("merges and persists pane widths; reset clears them", () => {
useStudioShellStore.getState().setPaneWidths({ copilot: 412 });
useStudioShellStore.getState().setPaneWidths({ editor: 350.4 });
@@ -82,4 +100,58 @@ describe("StudioShellStore", () => {
copilot: 320,
});
});
+
+ test("setPaneLayout stores the layout for the given class", () => {
+ useStudioShellStore
+ .getState()
+ .setPaneLayout("edit", ["copilot", "editor", "browser"]);
+
+ expect(useStudioShellStore.getState().paneLayouts["edit"]).toEqual([
+ "copilot",
+ "editor",
+ "browser",
+ ]);
+ const raw = localStorage.getItem(STUDIO_SHELL_STORAGE_KEY);
+ expect(JSON.parse(raw!).state.paneLayouts).toEqual({
+ edit: ["copilot", "editor", "browser"],
+ });
+ });
+
+ test("setPaneLayout ignores empty lists", () => {
+ useStudioShellStore
+ .getState()
+ .setPaneLayout("edit", ["copilot", "browser"]);
+ useStudioShellStore.getState().setPaneLayout("edit", []);
+
+ expect(useStudioShellStore.getState().paneLayouts["edit"]).toEqual([
+ "copilot",
+ "browser",
+ ]);
+ });
+
+ test("setPaneLayout overwrites a previous value for the same class", () => {
+ useStudioShellStore
+ .getState()
+ .setPaneLayout("edit", ["copilot", "browser"]);
+ useStudioShellStore.getState().setPaneLayout("edit", ["editor", "browser"]);
+
+ expect(useStudioShellStore.getState().paneLayouts["edit"]).toEqual([
+ "editor",
+ "browser",
+ ]);
+ });
+
+ test("setPaneLayout keeps classes independent", () => {
+ useStudioShellStore
+ .getState()
+ .setPaneLayout("edit", ["copilot", "browser"]);
+ useStudioShellStore
+ .getState()
+ .setPaneLayout("run", ["browser", "overview"]);
+
+ expect(useStudioShellStore.getState().paneLayouts).toEqual({
+ edit: ["copilot", "browser"],
+ run: ["browser", "overview"],
+ });
+ });
});
diff --git a/skyvern-frontend/src/store/StudioShellStore.ts b/skyvern-frontend/src/store/StudioShellStore.ts
index fb33370ff..b113a3196 100644
--- a/skyvern-frontend/src/store/StudioShellStore.ts
+++ b/skyvern-frontend/src/store/StudioShellStore.ts
@@ -1,6 +1,10 @@
import { create } from "zustand";
import { persist, createJSONStorage } from "zustand/middleware";
+import {
+ type StudioLayoutClass,
+ type StudioPaneId,
+} from "@/routes/workflows/studio/panes";
import { sanitizePaneWidth, type PaneWidths } from "@/store/paneWidths";
type StudioShellState = {
@@ -8,16 +12,23 @@ type StudioShellState = {
// User-pinned pane widths (px) from divider drags; per user, NOT in the URL
// so shared ?panes= links never impose someone else's widths.
paneWidths: PaneWidths;
+ // Last user-gesture pane list per layout class; used to restore defaults.
+ paneLayouts: Partial<Record<StudioLayoutClass, StudioPaneId[]>>;
setPipMinimized: (minimized: boolean) => void;
togglePip: () => void;
setPaneWidths: (widths: PaneWidths) => void;
resetPaneWidths: () => void;
+ setPaneLayout: (
+ cls: StudioLayoutClass,
+ panes: readonly StudioPaneId[],
+ ) => void;
reset: () => void;
};
const DEFAULTS = {
pipMinimized: false,
paneWidths: {} as PaneWidths,
+ paneLayouts: {} as Partial<Record<StudioLayoutClass, StudioPaneId[]>>,
};
export const STUDIO_SHELL_STORAGE_KEY = "skyvern.studioShell";
@@ -47,25 +58,46 @@ export const useStudioShellStore = create<StudioShellState>()(
paneWidths: sanitizePaneWidths({ ...state.paneWidths, ...widths }),
})),
resetPaneWidths: () => set({ paneWidths: {} }),
+ setPaneLayout: (cls, panes) => {
+ if (panes.length === 0) return;
+ set((state) => ({
+ paneLayouts: { ...state.paneLayouts, [cls]: [...panes] },
+ }));
+ },
reset: () => set(DEFAULTS),
}),
{
name: STUDIO_SHELL_STORAGE_KEY,
storage: createJSONStorage(() => localStorage),
// v0 also persisted copilotCollapsed; pane visibility now lives in the URL.
- version: 1,
+ // v2 adds paneLayouts for per-class layout memory.
+ version: 2,
migrate: (persisted) => {
const state = persisted as
- | { pipMinimized?: unknown; paneWidths?: unknown }
+ | {
+ pipMinimized?: unknown;
+ paneWidths?: unknown;
+ paneLayouts?: unknown;
+ }
| undefined;
return {
pipMinimized: Boolean(state?.pipMinimized),
paneWidths: sanitizePaneWidths(state?.paneWidths),
+ // Inner pane id arrays are not sanitized here; sanitizeLearnedPanes
+ // in StudioPaneDefaults.tsx drops stale ids at read time.
+ paneLayouts:
+ state?.paneLayouts !== null &&
+ typeof state?.paneLayouts === "object"
+ ? (state.paneLayouts as Partial<
+ Record<StudioLayoutClass, StudioPaneId[]>
+ >)
+ : {},
};
},
partialize: (state) => ({
pipMinimized: state.pipMinimized,
paneWidths: state.paneWidths,
+ paneLayouts: state.paneLayouts,
}),
},
),