diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 788a82b228253..c6117dadbccef 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), ), ); @@ -2794,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, @@ -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 8c5d5d000e8c4..26934886057a4 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 20c0ab79b8542..9f70d83dff7b5 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 (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; + /** 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"]'; diff --git a/scripts/lazurio-release-contract.test.mjs b/scripts/lazurio-release-contract.test.mjs index e200562309998..6245dc2360066 100644 --- a/scripts/lazurio-release-contract.test.mjs +++ b/scripts/lazurio-release-contract.test.mjs @@ -3416,25 +3416,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/);