Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ import {
buddyTerminalUiState,
useBuddyChatShortcuts,
useBuddyPage,
useBuddyPanelsOffered,
useBuddyQueuedRunCount,
useBuddyWindowInView,
useBuddyHermesControls,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
),
);
Expand Down Expand Up @@ -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),
),
);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -3383,6 +3386,8 @@ export default function ChatView(props: ChatViewProps) {
onToggleTerminal: toggleTerminalVisibilityStable,
onToggleThreadPanel: toggleThreadPanelStable,
onToggleRightPanel: toggleRightPanelStable,
showTerminalControl: buddyPanels,
showRightPanelControl: buddyPanels,
} satisfies PanelLayoutControlsProps;
const panelToggleControls = (
<PanelLayoutControls
Expand Down
9 changes: 8 additions & 1 deletion apps/web/src/lazurio/BuddySurface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ import { pageRecordOf } from "./buddySurfacePage";
import { useLinkedUnlistedProjectIds } from "./unlistedRows";
import { BUDDY_WORKING_ROW, buddyConversationRows, buddyFailureOf } from "./buddySurfaceTimeline";
import { prefersCzech } from "./threadTabs";
import { buddyHostOfWindow, buddyWindowInView } from "./buddySurfaceFrame";
import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout";
import { buddyHostOfWindow, buddyPanelsOffered, buddyWindowInView } from "./buddySurfaceFrame";
import { useBuddyFrame } from "./useBuddyFrame";

type BuddyConfig = { readonly lazurioBuddy?: true; readonly lazurioBuddyOrigin?: string } | null;
Expand Down Expand Up @@ -101,6 +102,12 @@ 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 {
const narrow = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
return buddyPanelsOffered(buddyHostOfWindow(window) !== null, narrow);
}

/** Buddy's surface, read outside React when a command runs: false until the config is known. */
export const isBuddySurfaceNow = (): boolean =>
isBuddySurfaceConfig(appAtomRegistry.get(primaryServerConfigAtom));
Expand Down
18 changes: 17 additions & 1 deletion apps/web/src/lazurio/buddySurfaceFrame.test.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions apps/web/src/lazurio/buddySurfaceFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]';

Expand Down
9 changes: 6 additions & 3 deletions scripts/lazurio-release-contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 : <ReopenClosedViewShortcut \/>\}/);
// 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+<ChatTerminalDrawers\n/);
NodeAssert.equal(chat.match(/<ChatTerminalDrawers\b/g)?.length, 1);
NodeAssert.match(
chat,
/\n\s+const rightPanelState = useRightPanelStore\(\(state\) =>\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/);
Expand Down
Loading