Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(web): a Session's dock fullscreen comes back with it (#1128)

lmlihengead8d213b470
diff --git a/changelog/unreleased/2026-10-14-session-dock-fullscreen.md b/changelog/unreleased/2026-10-14-session-dock-fullscreen.md
new file mode 100644
index 00000000..02bbb6eb
--- /dev/null
+++ b/changelog/unreleased/2026-10-14-session-dock-fullscreen.md
@@ -0,0 +1,19 @@
+# A Session's fullscreen panel comes back with it
+
+- **Date:** 2026-10-14
+- **Type:** fix
+- **Scope:** `web`
+
+[中文版](2026-10-14-session-dock-fullscreen.zh.md)
+
+Ported from upstream PenguinHarness (#1128, commit `8f747606`).
+
+Switching away from a Session and back again always showed its dock at the normal size, because the
+fullscreen state was cleared by the switch. Fullscreen is now remembered per dock arrangement, in
+memory: one Session can keep its right dock fullscreen while another keeps its bottom dock
+fullscreen, and a draft carries its fullscreen into the Session created by its first message.
+
+Shared panel width and bottom height keep their behavior. Exiting fullscreen, hiding the dock and
+closing its last tab clear it, and so does pruning the last terminal of an inactive Session before a
+terminal can return there. A reload and the narrow-layout breakpoint start every arrangement at the
+normal size; the localStorage format is unchanged.
diff --git a/changelog/unreleased/2026-10-14-session-dock-fullscreen.zh.md b/changelog/unreleased/2026-10-14-session-dock-fullscreen.zh.md
new file mode 100644
index 00000000..8a31507b
--- /dev/null
+++ b/changelog/unreleased/2026-10-14-session-dock-fullscreen.zh.md
@@ -0,0 +1,17 @@
+# 切回 Session 时,面板仍停在原来的全屏状态
+
+- **Date:** 2026-10-14
+- **Type:** fix
+- **Scope:** `web`
+
+[English](2026-10-14-session-dock-fullscreen.md)
+
+移植自上游 PenguinHarness(#1128,提交 `8f747606`)。
+
+切到别的 Session 再切回来,停靠面板总是普通尺寸 —— 因为切换本身把全屏状态清掉了。现在全屏按**停靠布局**
+记在内存里:一个 Session 可以让右侧停靠栏全屏,另一个同时让底部停靠栏全屏,草稿发出的第一条消息所创建的
+Session 也继承草稿的全屏状态。
+
+跨 Session 共用的面板宽度与底部高度不变。退出全屏、隐藏停靠栏、关掉它的最后一个标签页都会清掉;把某个
+不在前台的 Session 的最后一个终端标签剪掉时也一并清掉,免得终端再回到那里时全屏还挂着。刷新页面与跨越窄屏
+断点仍从普通尺寸开始,localStorage 的格式一字未改。
diff --git a/packages/web/src/features/dock/dock-state.ts b/packages/web/src/features/dock/dock-state.ts
index af6c982d..408f014c 100644
--- a/packages/web/src/features/dock/dock-state.ts
+++ b/packages/web/src/features/dock/dock-state.ts
@@ -35,9 +35,9 @@
* One surface at a time can be FULLSCREEN — the dock grown as far as its own edge goes: the right
* dock over its row (the conversation beside it, with the toolbar above and the bottom dock below
* still in view), the bottom dock or the narrow merged view up to the toolbar (over the row, and
- * the right dock in it). That is the one piece of state here that is transient — in memory, never
- * stored, cleared by a scope switch and by the breakpoint flipping — and it holds only while its
- * surface is on screen with tabs and no dock it COVERS is brought forward (checked after every
+ * the right dock in it). Fullscreen is remembered per arrangement in memory, never stored, so
+ * switching away and back restores it; a reload or the breakpoint flipping clears it. It holds
+ * while its surface is open with tabs and no dock it COVERS is brought forward (checked after every
* mutation, in commit()): the right dock taking the stage under a fullscreen bottom dock drops
* it, so what was asked for is seen rather than opening under the cover.
*
@@ -218,11 +218,11 @@ let scope = NO_SCOPE;
// are on every render path, and one live object per scope keeps switching cheap.
let layout: ScopeLayout = scopes[scope] ?? emptyScope();
/**
- * The surface grown to its fullscreen cover, by the position it renders at ("bottom" for the
- * narrow merged view), or null. In memory only: a reload, a scope switch and the breakpoint
- * flipping all start in the normal layout. The rules live in the fullscreen section below.
+ * Fullscreen follows the arrangement, including a draft handed to its new Session. Weak keys
+ * let evicted scopes go without a second retention list; the storage format stays unchanged.
+ * A reload or breakpoint flip starts every arrangement in the normal layout.
*/
-let fullscreen: DockPosition | null = null;
+let fullscreenByLayout = new WeakMap<ScopeLayout, DockPosition>();
/** Whether a scope's arrangement is worth a storage entry at all. */
function scopeIsEmpty(s: ScopeLayout): boolean {
@@ -353,9 +353,8 @@ function switchScope(target: string, mayHandOver: boolean): void {
}
scope = target;
layout = scopes[scope] ?? emptyScope();
- // Fullscreen belongs to the moment, not to the conversation: a new scope starts in the
- // normal layout even when its own dock would have qualified, and coming back never restores it.
- fullscreen = null;
+ // An inactive scope may have lost its last terminal while another Session was on screen.
+ reconcileFullscreen();
notify();
}
@@ -388,7 +387,7 @@ if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
narrow = event.matches;
// The surfaces are re-cut at the breakpoint (two docks ↔ one merged view), so the surface
// that was fullscreen no longer exists as such; the user re-enters on the new one if wanted.
- fullscreen = null;
+ fullscreenByLayout = new WeakMap();
notify();
});
}
@@ -627,13 +626,14 @@ export function hideView(view: DockView): void {
/** The surface grown to its fullscreen cover ("bottom" for the narrow merged view), or null. */
export function fullscreenDock(): DockPosition | null {
- return fullscreen;
+ return fullscreenByLayout.get(layout) ?? null;
}
/** Whether the merged view is on screen with something in its strip (rather than its picker). */
-function mergedViewHasTabs(): boolean {
+function mergedViewHasTabs(candidate: ScopeLayout): boolean {
return (
- (isDockVisible("bottom") && hasTabs("bottom")) || (isDockVisible("right") && hasTabs("right"))
+ (candidate.bottom.open && candidate.bottom.tabs.length > 0) ||
+ (candidate.right.open && candidate.right.tabs.length > 0)
);
}
@@ -642,9 +642,9 @@ function mergedViewHasTabs(): boolean {
* never fullscreen). Wide, the surface is one dock; narrow, it is the merged view, which only
* exists at the bottom.
*/
-function fullscreenEligible(position: DockPosition): boolean {
- if (narrow) return position === "bottom" && mergedViewHasTabs();
- return isDockVisible(position) && hasTabs(position);
+function fullscreenEligible(position: DockPosition, candidate: ScopeLayout = layout): boolean {
+ if (narrow) return position === "bottom" && mergedViewHasTabs(candidate);
+ return candidate[position].open && candidate[position].tabs.length > 0;
}
/**
@@ -656,10 +656,12 @@ function fullscreenEligible(position: DockPosition): boolean {
* dock opening, being touched or receiving a tab leaves it alone; so does anything within the
* merged view, which is every dock there is. Runs in commit(), after every mutation.
*/
-function reconcileFullscreen(): void {
+function reconcileFullscreen(candidate: ScopeLayout = layout): void {
+ const fullscreen = fullscreenByLayout.get(candidate) ?? null;
if (fullscreen === null) return;
- const coveredTakesStage = !narrow && fullscreen === "bottom" && layout.focus === "right";
- if (!fullscreenEligible(fullscreen) || coveredTakesStage) fullscreen = null;
+ const coveredTakesStage = !narrow && fullscreen === "bottom" && candidate.focus === "right";
+ if (!fullscreenEligible(fullscreen, candidate) || coveredTakesStage)
+ fullscreenByLayout.delete(candidate);
}
/**
@@ -673,8 +675,9 @@ export function setDockFullscreen(position: DockPosition | null): void {
layout.focus = position;
persist();
}
- if (position === fullscreen) return;
- fullscreen = position;
+ if (position === fullscreenDock()) return;
+ if (position === null) fullscreenByLayout.delete(layout);
+ else fullscreenByLayout.set(layout, position);
notify();
}
@@ -789,6 +792,7 @@ export function pruneTerminalTabs(liveIds: ReadonlySet<string>): void {
if (s === layout) continue; // the live scope is pruned below
if (pruneArea(s.right)) changed = true;
if (pruneArea(s.bottom)) changed = true;
+ reconcileFullscreen(s);
}
if (pruneArea(layout.right)) changed = true;
if (pruneArea(layout.bottom)) changed = true;
diff --git a/packages/web/test/dock-state.test.ts b/packages/web/test/dock-state.test.ts
index a9d650c2..9a2736b5 100644
--- a/packages/web/test/dock-state.test.ts
+++ b/packages/web/test/dock-state.test.ts
@@ -33,8 +33,16 @@
* that dock is open with tabs and no dock it covers comes forward: the right dock's cover is its
* own row, so the bottom dock opening or activating leaves it, while the bottom dock's cover
* reaches the right dock, so the right dock opening or activating ends it. Hiding the surface or
- * closing its last tab ends either; switching tabs within it does not. A scope switch ends it
- * too, and it is never stored.
+ * closing its last tab ends either; switching tabs within it does not.
+ * - Given Sessions with different fullscreen docks, switching away and back restores each one's
+ * fullscreen without applying it to a new Session; explicitly exiting stays exited on return.
+ * - Given a fullscreen draft, its first send hands fullscreen to the new Session, but never
+ * overwrites an existing Session's fullscreen. A new draft starts at normal size.
+ * - Given an inactive fullscreen terminal dock, pruning its last shell prevents fullscreen from
+ * returning when that Session is revisited, even if another terminal returns there first.
+ * - Given fullscreen docks, reloading restores their tabs and sizes at normal size.
+ * - Given fullscreen docks in several Sessions, crossing the narrow breakpoint clears all of
+ * them; fullscreen chosen in the merged view still survives switching Sessions.
*/
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { memoryStorage } from "./helpers/storage";
@@ -521,7 +529,7 @@ describe("fullscreen", () => {
expect(dock.fullscreenDock()).toBeNull();
});
- it("is cleared by a scope switch and not restored on return", () => {
+ it("restores each Session's fullscreen independently and remembers an explicit exit", () => {
const a = `scope-fullscreen-a-${scopeSeq}`;
const b = `scope-fullscreen-b-${scopeSeq}`;
dock.setDockScope(b);
@@ -531,22 +539,94 @@ describe("fullscreen", () => {
dock.setDockFullscreen("right");
dock.setDockScope(b); // the same dock is open and touched last here too
expect(dock.fullscreenDock()).toBeNull();
+ dock.openPanel("memory", "bottom");
+ dock.setDockFullscreen("bottom");
+ dock.setDockScope(a);
+ expect(dock.fullscreenDock()).toBe("right");
+ dock.setDockFullscreen(null);
+ dock.setDockScope(b);
+ expect(dock.fullscreenDock()).toBe("bottom");
dock.setDockScope(a);
expect(dock.fullscreenDock()).toBeNull();
});
- it("is never written to storage", () => {
+ it("hands a draft's fullscreen to its new Session without clobbering an existing layout", () => {
+ const draft = dock.currentDockScope();
+ const born = `fullscreen-born-${scopeSeq}`;
+ dock.openPanel("workspace", "right");
+ dock.setDockFullscreen("right");
+ dock.adoptDockScope(born);
+ expect(dock.fullscreenDock()).toBe("right");
+ dock.setDockScope(draft);
+ expect(dock.fullscreenDock()).toBeNull();
+
+ dock.openPanel("memory", "bottom");
+ dock.setDockFullscreen("bottom");
+ dock.adoptDockScope(born);
+ expect(dock.fullscreenDock()).toBe("right");
+ });
+
+ it.each([false, true])(
+ "does not restore fullscreen after an inactive dock's last terminal dies (another returns: %s)",
+ (restoreAnother) => {
+ const owner = dock.currentDockScope();
+ dock.addTerminalTab("fullscreen-terminal", "bottom");
+ dock.setDockFullscreen("bottom");
+ dock.setDockScope(`fullscreen-away-${scopeSeq}`);
+ dock.pruneTerminalTabs(new Set());
+ if (restoreAnother) dock.restoreTerminalTab(owner, "returned-terminal", "bottom");
+ dock.setDockScope(owner);
+ expect(dock.fullscreenDock()).toBeNull();
+ dock.openPanel("memory", "bottom");
+ expect(dock.fullscreenDock()).toBeNull();
+ },
+ );
+
+ it("reloads the dock's tabs and size without restoring fullscreen", async () => {
+ const owner = dock.currentDockScope();
dock.openPanel("workspace", "right");
dock.setDockFullscreen("right");
dock.openPanel("memory", "right"); // a persisted change made while it still covers
expect(dock.fullscreenDock()).toBe("right");
- const stored = JSON.parse(localStorage.getItem("penguin.dock.layout")!) as {
- scopes: Record<string, { right: object; bottom: object }>;
- };
- const entry = stored.scopes[dock.currentDockScope()]!;
- expect(Object.keys(stored).sort()).toEqual(["bottomRatio", "scopes"]);
- expect(Object.keys(entry).sort()).toEqual(["bottom", "focus", "right"]);
- for (const area of [entry.right, entry.bottom])
- expect(Object.keys(area).sort()).toEqual(["active", "open", "tabs"]);
+ dock.setBottomRatio(0.6);
+ vi.resetModules();
+ const reloaded = await import("../src/features/dock/dock-state");
+ reloaded.setDockScope(owner);
+ expect(reloaded.dockTabs("right").map(reloaded.tabKey)).toEqual(["workspace", "memory"]);
+ expect(reloaded.bottomRatio()).toBe(0.6);
+ expect(reloaded.fullscreenDock()).toBeNull();
+ });
+
+ it("clears all Sessions on a breakpoint change and remembers fullscreen in the merged view", async () => {
+ let change = (_event: { matches: boolean }) => {};
+ vi.stubGlobal("window", {
+ matchMedia: () => ({
+ matches: false,
+ addEventListener: (_type: string, listener: typeof change) => {
+ change = listener;
+ },
+ }),
+ });
+ vi.resetModules();
+ const responsive = await import("../src/features/dock/dock-state");
+ const a = `responsive-a-${scopeSeq}`;
+ const b = `responsive-b-${scopeSeq}`;
+ responsive.setDockScope(a);
+ responsive.openPanel("workspace", "right");
+ responsive.setDockFullscreen("right");
+ responsive.setDockScope(b);
+ responsive.openPanel("memory", "bottom");
+ responsive.setDockFullscreen("bottom");
+
+ change({ matches: true });
+ expect(responsive.fullscreenDock()).toBeNull();
+ responsive.setDockScope(a);
+ expect(responsive.fullscreenDock()).toBeNull();
+ responsive.setDockFullscreen("bottom");
+ responsive.setDockScope(b);
+ responsive.setDockScope(a);
+ expect(responsive.fullscreenDock()).toBe("bottom");
+ change({ matches: false });
+ expect(responsive.fullscreenDock()).toBeNull();
});
});