From 8deb3b3de1f5e6e2c27d5f92d16c02f220ce2f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= <16311043+immakermatty@users.noreply.github.com> Date: Fri, 20 Nov 2026 21:49:18 +0000 Subject: [PATCH 1/8] feat(lazurio): Buddy's small window offers neither the right panel nor the terminal In a Lazurio host's frame narrower than the inline right panel's width (the small window the person moves about), the chat offers neither the right panel nor the terminal drawer, and draws neither. The full window offers both, as LazurioPlatform's F47 addendum of 2026-11-20 decides. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 9 +++++++-- apps/web/src/lazurio/BuddySurface.tsx | 9 ++++++++- apps/web/src/lazurio/buddySurfaceFrame.test.ts | 18 +++++++++++++++++- apps/web/src/lazurio/buddySurfaceFrame.ts | 7 +++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 788a82b22825..12d3fd434da9 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -190,6 +190,7 @@ import { buddyTerminalUiState, useBuddyChatShortcuts, useBuddyPage, + useBuddyPanelsOffered, useBuddyQueuedRunCount, useBuddyWindowInView, useBuddyHermesControls, @@ -604,6 +605,8 @@ export default function ChatView(props: ChatViewProps) { // default and the chat is only the conversation; Buddy's window on the shared server is a whole // T3 thread (GEN4). const buddySurface = useBuddyHermesControls(environmentId); + // Lazurio overlay: Buddy's small window offers neither the right panel nor the terminal. + const buddyPanels = useBuddyPanelsOffered(); // The page Buddy is asked from travels with the person's next message (buddySurfacePage.ts). const buddyPage = useBuddyPage(environmentId); const buddyInView = useBuddyWindowInView(environmentId); @@ -799,7 +802,7 @@ export default function ChatView(props: ChatViewProps) { // (BuddySurface.tsx). Read inside the selector, as the right panel's state below is. const terminalUiState = useTerminalUiStateStore((state) => buddyTerminalUiState( - buddySurface, + buddySurface || !buddyPanels, selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef), ), ); @@ -1112,7 +1115,7 @@ export default function ChatView(props: ChatViewProps) { // changed on every render and looped as soon as the panel opened. const rightPanelState = useRightPanelStore((state) => buddyRightPanelState( - buddySurface, + buddySurface || !buddyPanels, selectThreadRightPanelState(state.byThreadKey, activeThreadRef), ), ); @@ -3383,6 +3386,8 @@ export default function ChatView(props: ChatViewProps) { onToggleTerminal: toggleTerminalVisibilityStable, onToggleThreadPanel: toggleThreadPanelStable, onToggleRightPanel: toggleRightPanelStable, + showTerminalControl: buddyPanels, + showRightPanelControl: buddyPanels, } satisfies PanelLayoutControlsProps; const panelToggleControls = ( isBuddySurfaceConfig(appAtomRegistry.get(primaryServerConfigAtom)); diff --git a/apps/web/src/lazurio/buddySurfaceFrame.test.ts b/apps/web/src/lazurio/buddySurfaceFrame.test.ts index 8c5d5d000e8c..26934886057a 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.test.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.test.ts @@ -1,6 +1,11 @@ import { describe, expect, it } from "vite-plus/test"; -import { buddyHostOfWindow, buddyWindowInView, startBuddyFrame } from "./buddySurfaceFrame"; +import { + buddyHostOfWindow, + buddyPanelsOffered, + buddyWindowInView, + startBuddyFrame, +} from "./buddySurfaceFrame"; const HOST = "https://launchpad.example-person.lazurio.io"; // What the host sends after the frame's ready, about its own Environment. @@ -136,6 +141,17 @@ describe("Buddy's frame", () => { ).toBe(true); }); + it("offers the right panel and the terminal in the full window and in neither in the small one", () => { + const { win } = frameWindow(); + const framed = buddyHostOfWindow(win) !== null; + // The small window the person moves about: too narrow, so neither panel. + expect(buddyPanelsOffered(framed, true)).toBe(false); + // Full screen on a computer: both. + expect(buddyPanelsOffered(framed, false)).toBe(true); + // Chat on its own page, also a narrow one, keeps T3's own layout. + expect(buddyPanelsOffered(false, true)).toBe(true); + }); + it("talks to nobody outside a host's frame", () => { const { win, posted, key } = frameWindow({ host: "https://example.com" }); const frame = startBuddyFrame(win); diff --git a/apps/web/src/lazurio/buddySurfaceFrame.ts b/apps/web/src/lazurio/buddySurfaceFrame.ts index 20c0ab79b854..41fa715ba508 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.ts @@ -38,6 +38,13 @@ export const buddyWindowInView = ( heardContext: boolean, ): boolean => !framed || shown === true || (shown === null && heardContext); +/** + * Whether Buddy's window offers the right panel and the terminal: not in a host's frame too narrow + * for them, where the right panel would only cover the conversation (the small window). The full + * window offers both (LazurioPlatform F47, addendum of 2026-11-20). + */ +export const buddyPanelsOffered = (framed: boolean, narrow: boolean): boolean => !framed || !narrow; + /** An open menu, dialog or list inside the surface takes Escape before the frame does. */ const ESCAPE_TAKERS = '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]'; From 11e42c5ce3e70a92ccdbf2622eda6ad297954750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= <16311043+immakermatty@users.noreply.github.com> Date: Fri, 20 Nov 2026 21:56:10 +0000 Subject: [PATCH 2/8] fix(lazurio): Buddy's small window leaves the panels' keys to the browser A key for the right panel or the terminal no longer toggles their stored state in the small window, where neither is drawn, so neither appears by itself when the window grows to full screen (T3 RELEASE's note on eea9e16f). Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 12d3fd434da9..c6117dadbcce 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2797,9 +2797,9 @@ export default function ChatView(props: ChatViewProps) { } }); - // Lazurio overlay (plan DEV-6676): Buddy's surface has no terminal or right panel, so their keys - // stay the browser's there (buddySurfaceControls.ts). - useBuddyChatShortcuts(buddySurface, { + // Lazurio overlay (plan DEV-6676): Buddy's surface, and his small window, have no terminal or right + // panel, so their keys stay the browser's there (buddySurfaceControls.ts). + useBuddyChatShortcuts(buddySurface || !buddyPanels, { enabled: activeThreadId !== null && !backgroundThread, embedded, composerElement: composerOverlayElement, From 4d966bbe9fb38732a6bd75435b65b523a5f4c0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= <16311043+immakermatty@users.noreply.github.com> Date: Fri, 20 Nov 2026 22:08:48 +0000 Subject: [PATCH 3/8] test(lazurio): the release contract pins Buddy's small window seams Co-Authored-By: Claude Opus 5.5 --- scripts/lazurio-release-contract.test.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/lazurio-release-contract.test.mjs b/scripts/lazurio-release-contract.test.mjs index e7a8162b3f07..f233689d1595 100644 --- a/scripts/lazurio-release-contract.test.mjs +++ b/scripts/lazurio-release-contract.test.mjs @@ -3450,25 +3450,28 @@ NodeTest.test("Buddy's chat reads like a chat with a friend through its seams", ); NodeAssert.match( chat, - /\n\s+useBuddyChatShortcuts\(buddySurface, \{\n\s+enabled: activeThreadId !== null && !backgroundThread,/, + /\n\s+useBuddyChatShortcuts\(buddySurface \|\| !buddyPanels, \{\n\s+enabled: activeThreadId !== null && !backgroundThread,/, ); NodeAssert.doesNotMatch(chat, /\buseChatShortcuts\(/); NodeAssert.doesNotMatch(chat, /activeTasksProgress|activeComposerTask/); NodeAssert.match(root, /\{buddySurface \? null : \}/); + // Buddy GEN4's small window offers neither panel either (LazurioPlatform F47, addendum of + // 2026-11-20): `buddyPanels` from `useBuddyPanelsOffered`. + NodeAssert.match(chat, /\n\s+const buddyPanels = useBuddyPanelsOffered\(\);\n/); // Root decision 0210, addendum of HumanAndMachines/Lazurio#648: Buddy's surface shows neither T3's // terminal nor its right panel. Their states are read closed inside the stores' selectors (outside, // the React Compiler leaves what reads them unmemoized and the panel re-rendered until React error // 301), no thread tabs are followed, code blocks get no Run in terminal, links open in a new tab. NodeAssert.match( chat, - /\n\s+const terminalUiState = useTerminalUiStateStore\(\(state\) =>\n\s+buddyTerminalUiState\(\n\s+buddySurface,\n\s+selectThreadTerminalUiState\(state\.terminalUiStateByThreadKey, routeThreadRef\),\n/, + /\n\s+const terminalUiState = useTerminalUiStateStore\(\(state\) =>\n\s+buddyTerminalUiState\(\n\s+buddySurface \|\| !buddyPanels,\n\s+selectThreadTerminalUiState\(state\.terminalUiStateByThreadKey, routeThreadRef\),\n/, ); NodeAssert.equal(chat.match(/\bselectThreadTerminalUiState\(/g)?.length, 1); NodeAssert.match(chat, /\{embedded \|\| buddySurface \? null : \(\n\s+\n\s+buddyRightPanelState\(\n\s+buddySurface,\n\s+selectThreadRightPanelState\(state\.byThreadKey, activeThreadRef\),\n/, + /\n\s+const rightPanelState = useRightPanelStore\(\(state\) =>\n\s+buddyRightPanelState\(\n\s+buddySurface \|\| !buddyPanels,\n\s+selectThreadRightPanelState\(state\.byThreadKey, activeThreadRef\),\n/, ); NodeAssert.equal(chat.match(/\bselectThreadRightPanelState\(/g)?.length, 1); NodeAssert.match(chat, /\n\s+const rightPanelOpen = rightPanelState\.isOpen;\n/); From ed7ec2a741208ea63a22c0948ca3d30ea01320ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= <16311043+immakermatty@users.noreply.github.com> Date: Sat, 21 Nov 2026 07:15:34 +0000 Subject: [PATCH 4/8] docs(lazurio): Buddy's narrow full-screen window without panels is an interim step Co-Authored-By: Claude Opus 5.5 --- apps/web/src/lazurio/buddySurfaceFrame.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/lazurio/buddySurfaceFrame.ts b/apps/web/src/lazurio/buddySurfaceFrame.ts index 41fa715ba508..9f70d83dff7b 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.ts @@ -40,8 +40,8 @@ export const buddyWindowInView = ( /** * Whether Buddy's window offers the right panel and the terminal: not in a host's frame too narrow - * for them, where the right panel would only cover the conversation (the small window). The full - * window offers both (LazurioPlatform F47, addendum of 2026-11-20). + * for them (the small window). Interim: the decision offers them full screen on a phone too, which + * width cannot tell; Lazurio/LazurioPlatform#1139 has the host send the window's mode. */ export const buddyPanelsOffered = (framed: boolean, narrow: boolean): boolean => !framed || !narrow; From ca02f54d72a25a7cf5c0bc44dab033ae40b08d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= <16311043+immakermatty@users.noreply.github.com> Date: Sat, 21 Nov 2026 07:55:05 +0000 Subject: [PATCH 5/8] feat(lazurio): Buddy's full-screen window offers the panels by the host's size, the right panel over the whole window The host tells the frame the size its window shows (lazurio.buddy.layout, LazurioPlatform#1139), so the panels follow the window's mode, not its width: both in the full-screen window, also a phone's, neither in the small one. An older Lazurio never says, and the width rule of the small window stays for it. In the full-screen window the right panel opens over the whole window, on T3's own maximize; its control goes back to the conversation, so does Escape before the frame would make the window small, and no panel opens by itself over Buddy's conversation. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 32 +++++--- .../components/chat/PanelLayoutControls.tsx | 7 +- apps/web/src/lazurio/BuddySurface.tsx | 67 ++++++++++++++--- .../web/src/lazurio/buddySurfaceFrame.test.ts | 75 ++++++++++++++++--- apps/web/src/lazurio/buddySurfaceFrame.ts | 55 +++++++++++--- apps/web/src/lazurio/buddySurfaceProtocol.ts | 22 ++++++ .../buddySurfaceTheme.browser.test.tsx | 1 + apps/web/src/lazurio/useBuddyFrame.ts | 3 + scripts/lazurio-release-contract.test.mjs | 20 +++-- 9 files changed, 238 insertions(+), 44 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index c6117dadbcce..80af0bff068b 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -190,7 +190,8 @@ import { buddyTerminalUiState, useBuddyChatShortcuts, useBuddyPage, - useBuddyPanelsOffered, + useBuddyPanelEscape, + useBuddyPanels, useBuddyQueuedRunCount, useBuddyWindowInView, useBuddyHermesControls, @@ -605,8 +606,9 @@ export default function ChatView(props: ChatViewProps) { // default and the chat is only the conversation; Buddy's window on the shared server is a whole // T3 thread (GEN4). const buddySurface = useBuddyHermesControls(environmentId); - // Lazurio overlay: Buddy's small window offers neither the right panel nor the terminal. - const buddyPanels = useBuddyPanelsOffered(); + // Lazurio overlay: Buddy's small window offers neither the right panel nor the terminal, and in his + // full-screen window the right panel opens over the whole window (BuddySurface.tsx). + const buddyPanels = useBuddyPanels(); // The page Buddy is asked from travels with the person's next message (buddySurfacePage.ts). const buddyPage = useBuddyPage(environmentId); const buddyInView = useBuddyWindowInView(environmentId); @@ -802,7 +804,7 @@ export default function ChatView(props: ChatViewProps) { // (BuddySurface.tsx). Read inside the selector, as the right panel's state below is. const terminalUiState = useTerminalUiStateStore((state) => buddyTerminalUiState( - buddySurface || !buddyPanels, + buddySurface || !buddyPanels.offered, selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef), ), ); @@ -1115,8 +1117,9 @@ export default function ChatView(props: ChatViewProps) { // changed on every render and looped as soon as the panel opened. const rightPanelState = useRightPanelStore((state) => buddyRightPanelState( - buddySurface || !buddyPanels, + buddySurface || !buddyPanels.offered, selectThreadRightPanelState(state.byThreadKey, activeThreadRef), + buddyPanels.wholeWindow, ), ); const shouldUsePlanSidebarSheet = prefersPlanSidebarSheet && rightPanelState.maximized !== true; @@ -2084,7 +2087,12 @@ export default function ChatView(props: ChatViewProps) { const activeRunningTurnId = activeRuntime?.activeRunId ?? null; useProactivePanels({ threadRef: isServerThread && !embedded ? activeThreadRef : null, - enabled: settings.proactivePanelsEnabled && !shouldUsePlanSidebarSheet && !embedded, + // Lazurio overlay: nothing opens by itself over Buddy's conversation in his window. + enabled: + settings.proactivePanelsEnabled && + !shouldUsePlanSidebarSheet && + !embedded && + !buddyPanels.framed, settingsHydrated: clientSettingsHydrated, threadDetailLoading, runningTurnId: activeRunningTurnId, @@ -2483,6 +2491,7 @@ export default function ChatView(props: ChatViewProps) { onDiffPanelOpen, closeRightPanelSurface, }); + useBuddyPanelEscape(buddyPanels.wholeWindow && rightPanelOpen, toggleRightPanelStable); const pullRequestSurfaceAvailable = supportsPullRequests && pullRequestPanelTarget !== null; const { acknowledgeActiveThreadWoke, @@ -2799,7 +2808,7 @@ export default function ChatView(props: ChatViewProps) { // Lazurio overlay (plan DEV-6676): Buddy's surface, and his small window, have no terminal or right // panel, so their keys stay the browser's there (buddySurfaceControls.ts). - useBuddyChatShortcuts(buddySurface || !buddyPanels, { + useBuddyChatShortcuts(buddySurface || !buddyPanels.offered, { enabled: activeThreadId !== null && !backgroundThread, embedded, composerElement: composerOverlayElement, @@ -3386,8 +3395,8 @@ export default function ChatView(props: ChatViewProps) { onToggleTerminal: toggleTerminalVisibilityStable, onToggleThreadPanel: toggleThreadPanelStable, onToggleRightPanel: toggleRightPanelStable, - showTerminalControl: buddyPanels, - showRightPanelControl: buddyPanels, + showTerminalControl: buddyPanels.offered, + showRightPanelControl: buddyPanels.offered, } satisfies PanelLayoutControlsProps; const panelToggleControls = ( {panelToggleControls} diff --git a/apps/web/src/components/chat/PanelLayoutControls.tsx b/apps/web/src/components/chat/PanelLayoutControls.tsx index 7252ead1d0fb..e5a810870c33 100644 --- a/apps/web/src/components/chat/PanelLayoutControls.tsx +++ b/apps/web/src/components/chat/PanelLayoutControls.tsx @@ -143,11 +143,13 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({ export const RightPanelMaximizeControl = memo(function RightPanelMaximizeControl({ maximized, onToggle, + restoreLabel, }: { maximized: boolean; onToggle: () => void; + restoreLabel?: string | undefined; }) { - const label = maximized ? "Restore panel size" : "Maximize panel"; + const label = maximized ? (restoreLabel ?? "Restore panel size") : "Maximize panel"; return ( void; + /** Lazurio overlay: what restoring the maximized panel means where it differs (Buddy's window). */ + readonly restoreLabel?: string | undefined; readonly children: ReactNode; }) { const { rightPanelOpen, maximized } = props; @@ -248,6 +252,7 @@ export function WorkspaceTitlebarControls(props: { ) : null} diff --git a/apps/web/src/lazurio/BuddySurface.tsx b/apps/web/src/lazurio/BuddySurface.tsx index 45124e7d70e9..e779d9a688bf 100644 --- a/apps/web/src/lazurio/BuddySurface.tsx +++ b/apps/web/src/lazurio/BuddySurface.tsx @@ -62,7 +62,13 @@ import { useLinkedUnlistedProjectIds } from "./unlistedRows"; import { BUDDY_WORKING_ROW, buddyConversationRows, buddyFailureOf } from "./buddySurfaceTimeline"; import { prefersCzech } from "./threadTabs"; import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout"; -import { buddyHostOfWindow, buddyPanelsOffered, buddyWindowInView } from "./buddySurfaceFrame"; +import { + BUDDY_ESCAPE_TAKERS, + buddyHostOfWindow, + buddyPanelOverWholeWindow, + buddyPanelsOffered, + buddyWindowInView, +} from "./buddySurfaceFrame"; import { useBuddyFrame } from "./useBuddyFrame"; type BuddyConfig = { readonly lazurioBuddy?: true; readonly lazurioBuddyOrigin?: string } | null; @@ -102,10 +108,44 @@ export function useBuddyWindowInView(environmentId: string): boolean { return buddyWindowInView(framed, shown, context !== null); } -/** Whether the right panel and the terminal are offered here: not in Buddy's small window. */ -export function useBuddyPanelsOffered(): boolean { +/** + * Buddy's window's panels: `offered` the right panel and the terminal, never in his small window; + * `wholeWindow` the right panel opens over the whole window, as Matěj decided on 2026-11-21, with + * `backLabel` on its control back to the conversation. Elsewhere T3's own layout. + */ +export function useBuddyPanels() { + const framed = buddyHostOfWindow(window) !== null; const narrow = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY); - return buddyPanelsOffered(buddyHostOfWindow(window) !== null, narrow); + const { mode } = useBuddyFrame(framed); + const czech = useCzech(framed); + const offered = buddyPanelsOffered(framed, mode, narrow); + return { + framed, + offered, + wholeWindow: framed && offered, + backLabel: TEXT[czech ? "cs" : "en"].backToConversation, + }; +} + +/** + * Escape over the right panel that covers Buddy's window goes back to the conversation, before the + * frame would make the window small (buddySurfaceFrame.ts). A field or a dialog keeps its own. + */ +export function useBuddyPanelEscape(active: boolean, back: () => void) { + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- listens to the window's keys while the panel covers it. + useEffect(() => { + if (!active) return; + const onKeyDown = (event: KeyboardEvent) => { + if (event.key !== "Escape" || event.isComposing) return; + if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return; + const target = event.target instanceof HTMLElement ? event.target : null; + if (target?.closest("input, textarea, select, [contenteditable='true']")) return; + if (document.querySelector(BUDDY_ESCAPE_TAKERS) !== null) return; + back(); + }; + window.addEventListener("keydown", onKeyDown); + return () => window.removeEventListener("keydown", onKeyDown); + }, [active, back]); } /** Buddy's surface, read outside React when a command runs: false until the config is known. */ @@ -140,6 +180,7 @@ function useCzech(buddy: boolean): boolean { const TEXT = { cs: { fullscreen: "Na celou obrazovku", + backToConversation: "Zpět k rozhovoru", panel: "Zmenšit do panelu", close: "Zavřít", days: "Dny", @@ -160,6 +201,7 @@ const TEXT = { }, en: { fullscreen: "Full screen", + backToConversation: "Back to the conversation", panel: "Back to the panel", close: "Close", days: "Days", @@ -465,13 +507,18 @@ export const buddyTerminalUiState = (buddy: boolean, state: TerminalUiState): Te type RightPanelState = ReturnType; /** - * The thread's right panel as the chat reads it: in Buddy's surface closed and empty, whatever the - * thread holds (a panel opened on it earlier, a link followed into it, a page an agent showed), - * since Buddy's chat is only the conversation (root decision 0210, addendum of - * HumanAndMachines/Lazurio#648). The stored panel stays as it is. As T3's elsewhere. + * The thread's right panel as the chat reads it: closed and empty in Buddy's surface, which is only + * the conversation (root decision 0210, addendum of HumanAndMachines/Lazurio#648); maximized over + * his whole window (`wholeWindow`). The stored panel stays as it is. As T3's elsewhere. */ -export const buddyRightPanelState = (buddy: boolean, state: RightPanelState): RightPanelState => - buddy ? selectThreadRightPanelState({}, null) : state; +export const buddyRightPanelState = ( + buddy: boolean, + state: RightPanelState, + wholeWindow = false, +): RightPanelState => { + if (buddy) return selectThreadRightPanelState({}, null); + return wholeWindow ? buddyPanelOverWholeWindow(state) : state; +}; /** The chat's shortcuts, without those Buddy's surface has no use for there. */ export function useBuddyChatShortcuts(buddy: boolean, input: ChatShortcutsInput) { diff --git a/apps/web/src/lazurio/buddySurfaceFrame.test.ts b/apps/web/src/lazurio/buddySurfaceFrame.test.ts index 26934886057a..bb22be115daa 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.test.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vite-plus/test"; import { buddyHostOfWindow, + buddyPanelOverWholeWindow, buddyPanelsOffered, buddyWindowInView, startBuddyFrame, @@ -22,7 +23,13 @@ const personalContext = { }; /** A frame's window as far as the frame uses it: its parent, its ancestors and its listeners. */ -function frameWindow(options: { readonly host?: string; readonly openMenu?: boolean } = {}) { +function frameWindow( + options: { + readonly host?: string; + readonly openMenu?: boolean; + readonly panelOverWindow?: boolean; + } = {}, +) { const posted: Array<{ readonly message: unknown; readonly origin: string }> = []; const listeners = new Map void>(); const parent = { @@ -33,7 +40,11 @@ function frameWindow(options: { readonly host?: string; readonly openMenu?: bool location: { ancestorOrigins: [options.host ?? HOST] }, document: { referrer: "", - querySelector: () => (options.openMenu === true ? {} : null), + querySelector: (selector: string) => + options.openMenu === true || + (options.panelOverWindow === true && selector.includes("maximized-away")) + ? {} + : null, }, addEventListener: (type: string, listener: (event: unknown) => void) => listeners.set(type, listener), @@ -74,12 +85,18 @@ describe("Buddy's frame", () => { expect(frame.layout()).toBe("panel"); }); - it("leaves Escape to an open menu, a modifier or an input method", () => { + it("leaves Escape to an open menu, a panel over the window, a modifier or an input method", () => { const menu = frameWindow({ openMenu: true }); startBuddyFrame(menu.win); menu.key(); expect(layouts(menu.posted)).toEqual([]); + // Escape over the panel goes back to the conversation first (BuddySurface.tsx). + const panel = frameWindow({ panelOverWindow: true }); + startBuddyFrame(panel.win).requestLayout("fullscreen"); + panel.key(); + expect(layouts(panel.posted)).toEqual(["fullscreen"]); + const { win, posted, key } = frameWindow(); startBuddyFrame(win); key({ shiftKey: true }); @@ -141,15 +158,55 @@ describe("Buddy's frame", () => { ).toBe(true); }); - it("offers the right panel and the terminal in the full window and in neither in the small one", () => { + it("takes the size the host's window shows, also one the host chose itself, and drops a defect", () => { + const { win, posted, key, receive } = frameWindow(); + const frame = startBuddyFrame(win); + expect(frame.mode()).toBeNull(); + // The launcher opened the remembered full screen: one Escape leaves it. + receive({ type: "lazurio.buddy.layout", v: 1, mode: "fullscreen" }); + expect(frame.mode()).toBe("fullscreen"); + key(); + expect(layouts(posted)).toEqual(["panel"]); + for (const defect of [ + { type: "lazurio.buddy.layout", v: 2, mode: "panel" }, + { type: "lazurio.buddy.layout", v: 1, mode: "huge" }, + { type: "lazurio.buddy.layout", v: 1, mode: "panel", extra: true }, + ]) + receive(defect); + receive({ type: "lazurio.buddy.layout", v: 1, mode: "panel" }, "https://example.com"); + receive({ type: "lazurio.buddy.layout", v: 1, mode: "panel" }, HOST, {}); + expect(frame.mode()).toBe("fullscreen"); + receive({ type: "lazurio.buddy.layout", v: 1, mode: "closed" }); + expect(frame.mode()).toBe("closed"); + expect(frame.layout()).toBe("panel"); + }); + + it("offers the panels in the full-screen window, also a phone's, and never in the small one", () => { const { win } = frameWindow(); const framed = buddyHostOfWindow(win) !== null; - // The small window the person moves about: too narrow, so neither panel. - expect(buddyPanelsOffered(framed, true)).toBe(false); - // Full screen on a computer: both. - expect(buddyPanelsOffered(framed, false)).toBe(true); + // As the host says: full screen on a phone or a computer offers both, the small window neither. + expect(buddyPanelsOffered(framed, "fullscreen", true)).toBe(true); + expect(buddyPanelsOffered(framed, "fullscreen", false)).toBe(true); + expect(buddyPanelsOffered(framed, "panel", true)).toBe(false); + expect(buddyPanelsOffered(framed, "closed", false)).toBe(false); + // An older host never says: a frame too narrow for the panels reads as the small window. + expect(buddyPanelsOffered(framed, null, true)).toBe(false); + expect(buddyPanelsOffered(framed, null, false)).toBe(true); // Chat on its own page, also a narrow one, keeps T3's own layout. - expect(buddyPanelsOffered(false, true)).toBe(true); + expect(buddyPanelsOffered(false, null, true)).toBe(true); + }); + + it("reads the right panel over the whole window as maximized, the same object for the same state", () => { + const stored: { isOpen: boolean; surfaces: string[]; maximized?: true } = { + isOpen: true, + surfaces: [], + }; + const whole = buddyPanelOverWholeWindow(stored); + expect(whole).toEqual({ isOpen: true, surfaces: [], maximized: true }); + expect(buddyPanelOverWholeWindow(stored)).toBe(whole); + expect(stored).toEqual({ isOpen: true, surfaces: [] }); + const maximized = { isOpen: true, maximized: true as const }; + expect(buddyPanelOverWholeWindow(maximized)).toBe(maximized); }); it("talks to nobody outside a host's frame", () => { diff --git a/apps/web/src/lazurio/buddySurfaceFrame.ts b/apps/web/src/lazurio/buddySurfaceFrame.ts index 9f70d83dff7b..1b55423eb27b 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.ts @@ -1,11 +1,12 @@ /** * Lazurio overlay (root decision 0210, plan DEV-6676): Buddy's surface as the frame of the bubble - * (buddySurfaceProtocol.ts). The host draws no controls over the frame and sees no keys inside it, - * so Escape asks for the panel unless something in the surface took it (the composer's editor marks - * every Escape handled, so that alone does not count). The frame keeps the size it asked for last. + * (buddySurfaceProtocol.ts). The host sees no keys inside the frame, so Escape asks for the panel + * unless something in the surface took it (the composer's editor marks every Escape handled, so that + * alone does not count). The frame keeps the size it asked for or the host said last. */ import { acceptBuddyContext, + acceptBuddyLayout, acceptBuddyShown, type BuddyContext, type BuddyLayout, @@ -18,10 +19,12 @@ export interface BuddyFrame { /** The page around the frame, a host of the bubble; null outside a frame or another page. */ readonly hostOrigin: string | null; readonly context: () => BuddyContext | null; - /** The size the frame asked for last; the panel until it asks. */ + /** The size the frame asked for or the host said last; the panel until either. */ readonly layout: () => Exclude; /** Whether the host's window shows the frame; null until the host says (an older Lazurio never does). */ readonly shown: () => boolean | null; + /** The size the host's window shows; null until the host says (an older Lazurio never does). */ + readonly mode: () => BuddyLayout | null; readonly subscribe: (listener: () => void) => () => void; readonly requestLayout: (mode: BuddyLayout) => void; readonly stop: () => void; @@ -39,14 +42,37 @@ export const buddyWindowInView = ( ): boolean => !framed || shown === true || (shown === null && heardContext); /** - * Whether Buddy's window offers the right panel and the terminal: not in a host's frame too narrow - * for them (the small window). Interim: the decision offers them full screen on a phone too, which - * width cannot tell; Lazurio/LazurioPlatform#1139 has the host send the window's mode. + * Whether Buddy's window offers the right panel and the terminal: in his full-screen window, never in + * the small one (LazurioPlatform F47, addendum of 2026-11-20). Before the host says its size (an older + * Lazurio), a frame too narrow for the panels reads as the small window. */ -export const buddyPanelsOffered = (framed: boolean, narrow: boolean): boolean => !framed || !narrow; +export const buddyPanelsOffered = ( + framed: boolean, + mode: BuddyLayout | null, + narrow: boolean, +): boolean => !framed || (mode === null ? !narrow : mode === "fullscreen"); + +const overWholeWindow = new WeakMap(); + +/** + * A thread's right panel read as covering the whole window, its stored size untouched; the same + * object for the same state, since the chat reads it inside a store selector. + */ +export function buddyPanelOverWholeWindow(state: T): T { + if (state.maximized === true) return state; + let whole = overWholeWindow.get(state) as T | undefined; + if (whole === undefined) { + whole = { ...state, maximized: true }; + overWholeWindow.set(state, whole); + } + return whole; +} /** An open menu, dialog or list inside the surface takes Escape before the frame does. */ -const ESCAPE_TAKERS = '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]'; +export const BUDDY_ESCAPE_TAKERS = + '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]'; +/** So does a right panel over the whole window: Escape there goes back to the conversation. */ +const ESCAPE_TAKERS = `${BUDDY_ESCAPE_TAKERS}, [data-chat-column-maximized-away="true"]`; /** The host page around this one, if a host of the bubble frames it; read without side effects. */ export const buddyHostOfWindow = (win: Window): string | null => @@ -59,6 +85,7 @@ export function startBuddyFrame(win: Window): BuddyFrame { let context: BuddyContext | null = null; let layout: Exclude = "panel"; let shown: boolean | null = null; + let mode: BuddyLayout | null = null; const listeners = new Set<() => void>(); const notify = () => { for (const listener of listeners) listener(); @@ -85,6 +112,15 @@ export function startBuddyFrame(win: Window): BuddyFrame { notify(); return; } + const nowMode = acceptBuddyLayout(received, hostOrigin); + if (nowMode !== null) { + if (nowMode === mode) return; + mode = nowMode; + // The host's size is the one to leave from, also after it changed the size by itself. + if (nowMode !== "closed") layout = nowMode; + notify(); + return; + } const nowShown = acceptBuddyShown(received, hostOrigin); if (nowShown === null || nowShown === shown) return; shown = nowShown; @@ -113,6 +149,7 @@ export function startBuddyFrame(win: Window): BuddyFrame { context: () => context, layout: () => layout, shown: () => shown, + mode: () => mode, subscribe: (listener) => { listeners.add(listener); return () => listeners.delete(listener); diff --git a/apps/web/src/lazurio/buddySurfaceProtocol.ts b/apps/web/src/lazurio/buddySurfaceProtocol.ts index 9772d3cc148a..eb6a490bbac9 100644 --- a/apps/web/src/lazurio/buddySurfaceProtocol.ts +++ b/apps/web/src/lazurio/buddySurfaceProtocol.ts @@ -293,6 +293,28 @@ export function acceptBuddyShown( return data.shown; } +/** + * The frame's side of the host's `lazurio.buddy.layout` (LazurioPlatform#1139): the size the host's + * window shows, which the host also changes by itself; from the same parent and origin as a context. + */ +export function acceptBuddyLayout( + event: { readonly data: unknown; readonly origin: string; readonly fromParent: boolean }, + hostOrigin: string | null, +): BuddyLayout | null { + if (event.fromParent !== true) return null; + if (buddyHostEnvironment(hostOrigin) === null || event.origin !== hostOrigin) return null; + const data = event.data; + if ( + !isPlain(data) || + !hasOnly(data, ["type", "v", "mode"]) || + data.type !== BUDDY_MESSAGE.layout || + data.v !== BUDDY_PROTOCOL_VERSION || + !isOneOf(BUDDY_LAYOUTS, data.mode) + ) + return null; + return data.mode; +} + export const buddyReady = () => ({ type: BUDDY_MESSAGE.ready, v: BUDDY_PROTOCOL_VERSION }); /** A request for the window's size; null for a size there is none of. */ diff --git a/apps/web/src/lazurio/buddySurfaceTheme.browser.test.tsx b/apps/web/src/lazurio/buddySurfaceTheme.browser.test.tsx index cbf2a1692531..a8bb45c60f79 100644 --- a/apps/web/src/lazurio/buddySurfaceTheme.browser.test.tsx +++ b/apps/web/src/lazurio/buddySurfaceTheme.browser.test.tsx @@ -21,6 +21,7 @@ vi.mock(import("./useBuddyFrame"), async (original) => ({ context: frame.context, layout: "panel" as const, shown: null, + mode: null, requestLayout: () => {}, }), })); diff --git a/apps/web/src/lazurio/useBuddyFrame.ts b/apps/web/src/lazurio/useBuddyFrame.ts index f4806175352a..a05fe1d256bc 100644 --- a/apps/web/src/lazurio/useBuddyFrame.ts +++ b/apps/web/src/lazurio/useBuddyFrame.ts @@ -21,6 +21,7 @@ const NO_FRAME: Omit = { context: () => null, layout: () => "panel", shown: () => null, + mode: () => null, subscribe: () => () => {}, requestLayout: () => {}, }; @@ -31,11 +32,13 @@ export function useBuddyFrame(buddy: boolean) { const context = useSyncExternalStore(current.subscribe, current.context, () => null); const layout = useSyncExternalStore(current.subscribe, current.layout, () => "panel" as const); const shown = useSyncExternalStore(current.subscribe, current.shown, () => null); + const mode = useSyncExternalStore(current.subscribe, current.mode, () => null); return { framed: current.hostOrigin !== null, context, layout, shown, + mode, requestLayout: current.requestLayout, }; } diff --git a/scripts/lazurio-release-contract.test.mjs b/scripts/lazurio-release-contract.test.mjs index f233689d1595..ca10b5ae41d1 100644 --- a/scripts/lazurio-release-contract.test.mjs +++ b/scripts/lazurio-release-contract.test.mjs @@ -3450,28 +3450,38 @@ NodeTest.test("Buddy's chat reads like a chat with a friend through its seams", ); NodeAssert.match( chat, - /\n\s+useBuddyChatShortcuts\(buddySurface \|\| !buddyPanels, \{\n\s+enabled: activeThreadId !== null && !backgroundThread,/, + /\n\s+useBuddyChatShortcuts\(buddySurface \|\| !buddyPanels\.offered, \{\n\s+enabled: activeThreadId !== null && !backgroundThread,/, ); NodeAssert.doesNotMatch(chat, /\buseChatShortcuts\(/); NodeAssert.doesNotMatch(chat, /activeTasksProgress|activeComposerTask/); NodeAssert.match(root, /\{buddySurface \? null : \}/); // Buddy GEN4's small window offers neither panel either (LazurioPlatform F47, addendum of - // 2026-11-20): `buddyPanels` from `useBuddyPanelsOffered`. - NodeAssert.match(chat, /\n\s+const buddyPanels = useBuddyPanelsOffered\(\);\n/); + // 2026-11-20), and in his full-screen window the right panel covers the whole window, Escape goes + // back to the conversation and nothing opens by itself (LazurioPlatform#1139): `useBuddyPanels`. + NodeAssert.match(chat, /\n\s+const buddyPanels = useBuddyPanels\(\);\n/); + NodeAssert.match( + chat, + /\n\s+useBuddyPanelEscape\(buddyPanels\.wholeWindow && rightPanelOpen, toggleRightPanelStable\);\n/, + ); + NodeAssert.match(chat, /\n\s+!embedded &&\n\s+!buddyPanels\.framed,\n/); + NodeAssert.match( + chat, + /onToggleMaximized=\{\n\s+buddyPanels\.wholeWindow \? toggleRightPanelStable : toggleRightPanelMaximizedStable\n\s+\}\n\s+restoreLabel=\{buddyPanels\.wholeWindow \? buddyPanels\.backLabel : undefined\}/, + ); // Root decision 0210, addendum of HumanAndMachines/Lazurio#648: Buddy's surface shows neither T3's // terminal nor its right panel. Their states are read closed inside the stores' selectors (outside, // the React Compiler leaves what reads them unmemoized and the panel re-rendered until React error // 301), no thread tabs are followed, code blocks get no Run in terminal, links open in a new tab. NodeAssert.match( chat, - /\n\s+const terminalUiState = useTerminalUiStateStore\(\(state\) =>\n\s+buddyTerminalUiState\(\n\s+buddySurface \|\| !buddyPanels,\n\s+selectThreadTerminalUiState\(state\.terminalUiStateByThreadKey, routeThreadRef\),\n/, + /\n\s+const terminalUiState = useTerminalUiStateStore\(\(state\) =>\n\s+buddyTerminalUiState\(\n\s+buddySurface \|\| !buddyPanels\.offered,\n\s+selectThreadTerminalUiState\(state\.terminalUiStateByThreadKey, routeThreadRef\),\n/, ); NodeAssert.equal(chat.match(/\bselectThreadTerminalUiState\(/g)?.length, 1); NodeAssert.match(chat, /\{embedded \|\| buddySurface \? null : \(\n\s+\n\s+buddyRightPanelState\(\n\s+buddySurface \|\| !buddyPanels,\n\s+selectThreadRightPanelState\(state\.byThreadKey, activeThreadRef\),\n/, + /\n\s+const rightPanelState = useRightPanelStore\(\(state\) =>\n\s+buddyRightPanelState\(\n\s+buddySurface \|\| !buddyPanels\.offered,\n\s+selectThreadRightPanelState\(state\.byThreadKey, activeThreadRef\),\n\s+buddyPanels\.wholeWindow,\n/, ); NodeAssert.equal(chat.match(/\bselectThreadRightPanelState\(/g)?.length, 1); NodeAssert.match(chat, /\n\s+const rightPanelOpen = rightPanelState\.isOpen;\n/); From 19800f3c1babb483b6273cb05964f839fe26d2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= <16311043+immakermatty@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:19:53 +0000 Subject: [PATCH 6/8] fix(lazurio): Buddy's way back to the conversation is Lazurio's own control, and a hidden sheet no longer takes Escape T3's PanelLayoutControls is upstream's and off the fork's allowlist, so the control back from the right panel over the whole window is Lazurio's BuddyBackToConversation beside the panel toggles, and T3's maximize control stays as it is. A narrow window keeps T3's closed sheets mounted as hidden dialogs. They took Escape, so on a phone Escape neither went back to the conversation nor made the window small. Only an open menu, dialog or list the person sees takes Escape now (buddyEscapeTaken). Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 11 +++++----- .../components/chat/PanelLayoutControls.tsx | 7 +----- apps/web/src/lazurio/BuddySurface.tsx | 22 +++++++++++++++++-- .../web/src/lazurio/buddySurfaceFrame.test.ts | 11 ++++++---- apps/web/src/lazurio/buddySurfaceFrame.ts | 21 +++++++++++++----- scripts/lazurio-release-contract.test.mjs | 2 +- 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 80af0bff068b..0ac34440ab5b 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -184,6 +184,7 @@ import { useLazurioThreadTabs, } from "../lazurio/LazurioEnvironmentBrowser"; import { + BuddyBackToConversation, BuddyThreadDetailsPanel, buddyRightPanelState, buddyRuntimeMode, @@ -3407,15 +3408,15 @@ export default function ChatView(props: ChatViewProps) { const threadPanelHeaderControl = ; const panelLayoutControls = ( + {buddyPanels.wholeWindow && rightPanelOpen ? ( + + ) : null} {panelToggleControls} ); diff --git a/apps/web/src/components/chat/PanelLayoutControls.tsx b/apps/web/src/components/chat/PanelLayoutControls.tsx index e5a810870c33..7252ead1d0fb 100644 --- a/apps/web/src/components/chat/PanelLayoutControls.tsx +++ b/apps/web/src/components/chat/PanelLayoutControls.tsx @@ -143,13 +143,11 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({ export const RightPanelMaximizeControl = memo(function RightPanelMaximizeControl({ maximized, onToggle, - restoreLabel, }: { maximized: boolean; onToggle: () => void; - restoreLabel?: string | undefined; }) { - const label = maximized ? (restoreLabel ?? "Restore panel size") : "Maximize panel"; + const label = maximized ? "Restore panel size" : "Maximize panel"; return ( void; - /** Lazurio overlay: what restoring the maximized panel means where it differs (Buddy's window). */ - readonly restoreLabel?: string | undefined; readonly children: ReactNode; }) { const { rightPanelOpen, maximized } = props; @@ -252,7 +248,6 @@ export function WorkspaceTitlebarControls(props: { ) : null} diff --git a/apps/web/src/lazurio/BuddySurface.tsx b/apps/web/src/lazurio/BuddySurface.tsx index e779d9a688bf..c649998fb517 100644 --- a/apps/web/src/lazurio/BuddySurface.tsx +++ b/apps/web/src/lazurio/BuddySurface.tsx @@ -63,7 +63,7 @@ import { BUDDY_WORKING_ROW, buddyConversationRows, buddyFailureOf } from "./budd import { prefersCzech } from "./threadTabs"; import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout"; import { - BUDDY_ESCAPE_TAKERS, + buddyEscapeTaken, buddyHostOfWindow, buddyPanelOverWholeWindow, buddyPanelsOffered, @@ -127,6 +127,24 @@ export function useBuddyPanels() { }; } +/** In Buddy's window, the way from the right panel over the whole window back to the conversation. */ +export function BuddyBackToConversation(props: { + readonly label: string; + readonly onBack: () => void; +}) { + return ( + + ); +} + /** * Escape over the right panel that covers Buddy's window goes back to the conversation, before the * frame would make the window small (buddySurfaceFrame.ts). A field or a dialog keeps its own. @@ -140,7 +158,7 @@ export function useBuddyPanelEscape(active: boolean, back: () => void) { if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return; const target = event.target instanceof HTMLElement ? event.target : null; if (target?.closest("input, textarea, select, [contenteditable='true']")) return; - if (document.querySelector(BUDDY_ESCAPE_TAKERS) !== null) return; + if (buddyEscapeTaken(document)) return; back(); }; window.addEventListener("keydown", onKeyDown); diff --git a/apps/web/src/lazurio/buddySurfaceFrame.test.ts b/apps/web/src/lazurio/buddySurfaceFrame.test.ts index bb22be115daa..e9d2b3dc9c36 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.test.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.test.ts @@ -40,11 +40,14 @@ function frameWindow( location: { ancestorOrigins: [options.host ?? HOST] }, document: { referrer: "", + // As the DOM does, it also finds the hidden dialog below. querySelector: (selector: string) => - options.openMenu === true || - (options.panelOverWindow === true && selector.includes("maximized-away")) - ? {} - : null, + selector.includes("maximized-away") ? (options.panelOverWindow === true ? {} : null) : {}, + // A narrow window keeps a closed sheet mounted as a hidden dialog. + querySelectorAll: () => [ + { checkVisibility: () => false }, + ...(options.openMenu === true ? [{ checkVisibility: () => true }] : []), + ], }, addEventListener: (type: string, listener: (event: unknown) => void) => listeners.set(type, listener), diff --git a/apps/web/src/lazurio/buddySurfaceFrame.ts b/apps/web/src/lazurio/buddySurfaceFrame.ts index 1b55423eb27b..0500da70e523 100644 --- a/apps/web/src/lazurio/buddySurfaceFrame.ts +++ b/apps/web/src/lazurio/buddySurfaceFrame.ts @@ -68,11 +68,19 @@ export function buddyPanelOverWholeWindow