π OpenHands: AI-Driven Development
fix(conversation): open the drawer at phone width for agent and file-link tab requests (#18045)
Engel Nyst016af2ddde14
diff --git a/__tests__/components/features/conversation/agent-status.test.tsx b/__tests__/components/features/conversation/agent-status.test.tsxindex d5dab269e8..0f6a57f9df 100644--- a/__tests__/components/features/conversation/agent-status.test.tsx+++ b/__tests__/components/features/conversation/agent-status.test.tsx@@ -236,6 +236,18 @@ describe("AgentStatus", () => {expect(setShouldShownAgentLoading).toHaveBeenCalledWith(true);});+ it("clears its loading report when it unmounts so the phone panel page does not keep a stale loading overlay", () => {+ const { setShouldShownAgentLoading, unmount } = renderAgentStatus({+ agentState: AgentState.LOADING,+ executionStatus: null,+ });+ expect(setShouldShownAgentLoading).toHaveBeenLastCalledWith(true);++ unmount();++ expect(setShouldShownAgentLoading).toHaveBeenLastCalledWith(false);+ });+it("forwards the active conversation to sub-conversation polling", () => {const { handleResumeAgent, handleStop, rerender } = renderAgentStatus({conversationId: "conversation-42",diff --git a/__tests__/components/features/conversation/conversation-mobile-panel-page.test.tsx b/__tests__/components/features/conversation/conversation-mobile-panel-page.test.tsxindex b5220b2ab0..10b01ea122 100644--- a/__tests__/components/features/conversation/conversation-mobile-panel-page.test.tsx+++ b/__tests__/components/features/conversation/conversation-mobile-panel-page.test.tsx@@ -1,4 +1,4 @@-import { render, screen, fireEvent } from "@testing-library/react";+import { render, screen, fireEvent, within } from "@testing-library/react";import { describe, it, expect, vi } from "vitest";import { useConversationStore } from "#/stores/conversation-store";@@ -7,6 +7,12 @@ vi.mock("#/components/features/conversation/conversation-tabs/conversation-tabs",() => ({ ConversationTabs: () => <div data-testid="conversation-tabs" /> }),);+vi.mock(+ "#/components/features/conversation/conversation-tabs/conversation-planner-build-bar",+ () => ({+ ConversationPlannerBuildBar: () => <div data-testid="planner-build-bar" />,+ }),+);vi.mock("#/components/features/conversation/conversation-tabs/conversation-tab-content/conversation-tab-content",() => ({ ConversationTabContent: () => <div data-testid="tab-content" /> }),@@ -29,4 +35,17 @@ describe("ConversationMobilePanelPage", () => {expect(onNavigateBack).toHaveBeenCalledTimes(1);});++ it("renders the planner build bar below the fixed-height top bar, not inside it", () => {+ render(<ConversationMobilePanelPage onNavigateBack={vi.fn()} />);++ const topBar = screen.getByTestId("conversation-mobile-panel-top");+ const buildBar = screen.getByTestId("planner-build-bar");++ expect(within(topBar).queryByTestId("planner-build-bar")).toBeNull();+ expect(+ topBar.compareDocumentPosition(buildBar) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ });});diff --git a/__tests__/components/features/conversation/conversation-tabs.test.tsx b/__tests__/components/features/conversation/conversation-tabs.test.tsxindex f4d73f3620..901a6ddde6 100644--- a/__tests__/components/features/conversation/conversation-tabs.test.tsx+++ b/__tests__/components/features/conversation/conversation-tabs.test.tsx@@ -449,6 +449,24 @@ describe("ConversationTabs localStorage behavior", () => {).toBeDisabled();});+ it("leaves the build bar out of the compact tab row, which sits in the fixed-height phone top bar", () => {+ setActiveTabState("planner");+ useConversationStore.setState({+ planContent: "# Plan content",+ });++ render(<ConversationTabs variant="compact" />, {+ wrapper: createWrapper(REAL_CONVERSATION_ID),+ });++ expect(+ screen.getByTestId("conversation-tab-planner"),+ ).toBeInTheDocument();+ expect(+ screen.queryByTestId("planner-tab-build-button"),+ ).not.toBeInTheDocument();+ });+it("calls the build handler when the build button is clicked", async () => {const user = userEvent.setup();setActiveTabState("planner");diff --git a/__tests__/hooks/use-conversation-panel-route.test.tsx b/__tests__/hooks/use-conversation-panel-route.test.tsxnew file mode 100644index 0000000000..cd09d5b5fe--- /dev/null+++ b/__tests__/hooks/use-conversation-panel-route.test.tsx@@ -0,0 +1,121 @@+import { act, render, screen } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { MemoryRouter, Route, Routes, useLocation } from "react-router";+import { useConversationPanelRoute } from "#/hooks/use-conversation-panel-route";+import { handleCanvasUIAction } from "#/services/canvas-ui";+import { useConversationStore } from "#/stores/conversation-store";+import type { CanvasUIAction } from "#/types/agent-server/core";++const CONVERSATION_ID = "conv-1";+const CHAT_PATH = `/conversations/${CONVERSATION_ID}`;+const PANEL_PATH = `${CHAT_PATH}/panel`;+const PHONE_WIDTH = 390;+const DESKTOP_WIDTH = 1440;++function setWindowWidth(width: number) {+ Object.defineProperty(window, "innerWidth", {+ writable: true,+ configurable: true,+ value: width,+ });+ window.dispatchEvent(new Event("resize"));+}++function Probe() {+ const showsMobilePanelPage = useConversationPanelRoute(CONVERSATION_ID);+ const location = useLocation();+ return (+ <div>+ <span data-testid="path">{location.pathname}</span>+ <span data-testid="mobile-panel-page">+ {String(showsMobilePanelPage)}+ </span>+ </div>+ );+}++function renderAt(path: string) {+ return render(+ <MemoryRouter initialEntries={[path]}>+ <Routes>+ <Route path="/conversations/:conversationId" element={<Probe />} />+ <Route+ path="/conversations/:conversationId/panel"+ element={<Probe />}+ />+ </Routes>+ </MemoryRouter>,+ );+}++function openTerminalFromAgent() {+ act(() => {+ handleCanvasUIAction(+ {+ kind: "CanvasUIAction",+ command: "open_tab",+ tab: "terminal",+ } as CanvasUIAction,+ CONVERSATION_ID,+ );+ });+}++describe("useConversationPanelRoute", () => {+ const originalInnerWidth = window.innerWidth;++ beforeEach(() => {+ localStorage.clear();+ useConversationStore.setState({+ selectedTab: "files",+ isRightPanelShown: false,+ hasRightPanelToggled: false,+ });+ });++ afterEach(() => {+ setWindowWidth(originalInnerWidth);+ });++ it("opens the panel page at phone width when the agent reveals a tab", () => {+ setWindowWidth(PHONE_WIDTH);+ renderAt(CHAT_PATH);++ openTerminalFromAgent();++ expect(screen.getByTestId("path")).toHaveTextContent(PANEL_PATH);+ expect(screen.getByTestId("mobile-panel-page")).toHaveTextContent("true");+ expect(useConversationStore.getState().selectedTab).toBe("terminal");+ });++ it("keeps the desktop chat route and opens the side drawer instead", () => {+ setWindowWidth(DESKTOP_WIDTH);+ renderAt(CHAT_PATH);++ openTerminalFromAgent();++ expect(screen.getByTestId("path")).toHaveTextContent(CHAT_PATH);+ expect(screen.getByTestId("path")).not.toHaveTextContent("/panel");+ expect(useConversationStore.getState().isRightPanelShown).toBe(true);+ });++ it("keeps the full-screen panel page at phone width", () => {+ setWindowWidth(PHONE_WIDTH);+ renderAt(PANEL_PATH);++ expect(screen.getByTestId("path")).toHaveTextContent(PANEL_PATH);+ expect(screen.getByTestId("mobile-panel-page")).toHaveTextContent("true");+ });++ it("falls back to the split layout with the drawer open when the panel page widens to desktop", () => {+ setWindowWidth(PHONE_WIDTH);+ renderAt(PANEL_PATH);++ act(() => setWindowWidth(DESKTOP_WIDTH));++ expect(screen.getByTestId("path")).not.toHaveTextContent("/panel");+ expect(screen.getByTestId("path")).toHaveTextContent(CHAT_PATH);+ expect(screen.getByTestId("mobile-panel-page")).toHaveTextContent("false");+ expect(useConversationStore.getState().isRightPanelShown).toBe(true);+ });+});diff --git a/__tests__/services/canvas-ui.test.ts b/__tests__/services/canvas-ui.test.tsindex 133e8c8429..2ace07d5f8 100644--- a/__tests__/services/canvas-ui.test.ts+++ b/__tests__/services/canvas-ui.test.ts@@ -6,11 +6,19 @@ import {CANVAS_UI_CLIENT_TOOL_NAME,LEGACY_CANVAS_UI_TOOL_NAME,} from "#/constants/canvas-ui";-import { handleCanvasUIAction, openWorkspaceFile } from "#/services/canvas-ui";+import {+ handleCanvasUIAction,+ openWorkspaceFile,+ subscribeToPanelReveal,+} from "#/services/canvas-ui";import { useConversationStore } from "#/stores/conversation-store";import { useFilesTabStore } from "#/stores/files-tab-store";import type { CanvasUIAction } from "#/types/agent-server/core";import { isCanvasUIActionEvent } from "#/types/agent-server/type-guards";+import {+ getConversationState,+ setConversationState,+} from "#/utils/conversation-local-storage";// Helper: build a CanvasUIAction without repeating the literal `kind`// discriminator in every test case.@@ -20,6 +28,7 @@ function action(overrides: Partial<CanvasUIAction>): CanvasUIAction {describe("handleCanvasUIAction", () => {beforeEach(() => {+ localStorage.clear();ConversationService.setCurrentConversation(null);useConversationStore.setState({selectedTab: null,@@ -63,7 +72,36 @@ describe("handleCanvasUIAction", () => {expect(useFilesTabStore.getState().selectedPath).toBeNull();});+ it("open_tab persists the agent's tab for the conversation, as a user tab click does", () => {+ handleCanvasUIAction(+ action({ command: "open_tab", tab: "terminal" }),+ "conv-1",+ );++ expect(getConversationState("conv-1").selectedTab).toBe("terminal");+ });++ it("asks panel-reveal subscribers to show the drawer until they unsubscribe", () => {+ const onReveal = vi.fn();+ const unsubscribe = subscribeToPanelReveal(onReveal);++ handleCanvasUIAction(+ action({ command: "open_tab", tab: "terminal" }),+ "conv-1",+ );+ expect(onReveal).toHaveBeenCalledTimes(1);++ unsubscribe();+ handleCanvasUIAction(+ action({ command: "navigate_to_file", path: "src/calc.py" }),+ "conv-1",+ );+ expect(onReveal).toHaveBeenCalledTimes(1);+ });+it("open_tab ignores unknown tab values and surfaces a warning for debuggability", () => {+ const onReveal = vi.fn();+ const unsubscribe = subscribeToPanelReveal(onReveal);const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});try {@@ -74,8 +112,10 @@ describe("handleCanvasUIAction", () => {expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("not_a_tab"),);+ expect(onReveal).not.toHaveBeenCalled();} finally {warnSpy.mockRestore();+ unsubscribe();}});@@ -133,6 +173,7 @@ describe("handleCanvasUIAction", () => {describe("openWorkspaceFile", () => {beforeEach(() => {+ localStorage.clear();ConversationService.setCurrentConversation(null);useConversationStore.setState({selectedTab: null,@@ -151,6 +192,7 @@ describe("openWorkspaceFile", () => {id: "conv-1",workspace: { working_dir: "/Users/me/project" },} as never);+ setConversationState("conv-1", { selectedTab: "terminal" });openWorkspaceFile("/Users/me/project/test.md");@@ -159,6 +201,7 @@ describe("openWorkspaceFile", () => {expect(useFilesTabStore.getState().selectedPath).toBe("test.md");expect(useFilesTabStore.getState().selectedConversationId).toBe("conv-1");expect(useFilesTabStore.getState().openPaths).toEqual(["test.md"]);+ expect(getConversationState("conv-1").selectedTab).toBe("files");});});diff --git a/src/components/features/chat/chat-interface.tsx b/src/components/features/chat/chat-interface.tsxindex 0ff6f9516a..fe6394c33d 100644--- a/src/components/features/chat/chat-interface.tsx+++ b/src/components/features/chat/chat-interface.tsx@@ -141,8 +141,9 @@ export function ChatInterface() {// Global keyboard shortcut for Build button (Cmd+Enter / Ctrl+Enter)// This is placed here instead of PlanPreview to avoid duplicate listeners// when multiple PlanPreview components exist in the chat.- // Gated on the same conditions as the Build button (ConversationTabs'- // `isBuildDisabled`) so it cannot fire outside the plan flow.+ // Gated on the same conditions as the Build button+ // (ConversationPlannerBuildBar's `isBuildDisabled`) so it cannot fire+ // outside the plan flow.React.useEffect(() => {if (isAgentRunning || conversationMode !== "plan" || !planContent) {return undefined;diff --git a/src/components/features/controls/agent-status.tsx b/src/components/features/controls/agent-status.tsxindex c7f5cb4ba0..77e565995e 100644--- a/src/components/features/controls/agent-status.tsx+++ b/src/components/features/controls/agent-status.tsx@@ -101,6 +101,14 @@ export function AgentStatus({setShouldShownAgentLoading(!!shouldShownAgentLoading);}, [shouldShownAgentLoading, setShouldShownAgentLoading]);+ // This status is the flag's only writer, and the phone panel page renders+ // the drawer without it. Clear the flag on unmount so a value captured while+ // the chat was still connecting cannot cover the panel's tab content.+ useEffect(+ () => () => setShouldShownAgentLoading(false),+ [setShouldShownAgentLoading],+ );+useEffect(() => {if (!isTransientCheckStatus) {setShouldRenderDoneStatus(true);diff --git a/src/components/features/conversation/conversation-main/conversation-mobile-panel-page.tsx b/src/components/features/conversation/conversation-main/conversation-mobile-panel-page.tsxindex f003e89511..db46fc11a2 100644--- a/src/components/features/conversation/conversation-main/conversation-mobile-panel-page.tsx+++ b/src/components/features/conversation/conversation-main/conversation-mobile-panel-page.tsx@@ -9,6 +9,7 @@ import {import { useConversationStore } from "#/stores/conversation-store";import { ConversationTabContent } from "../conversation-tabs/conversation-tab-content/conversation-tab-content";import { ConversationTabs } from "../conversation-tabs/conversation-tabs";+import { ConversationPlannerBuildBar } from "../conversation-tabs/conversation-planner-build-bar";export function ConversationMobilePanelPage({onNavigateBack,@@ -65,6 +66,8 @@ export function ConversationMobilePanelPage({</div></div></div>+ {/* Below the fixed-height top bar, which already draws the divider. */}+ <ConversationPlannerBuildBar className="border-t-0 border-b" /><div className="flex min-h-0 flex-1 flex-col bg-surface"><ConversationTabContent /></div>diff --git a/src/components/features/conversation/conversation-tabs/conversation-planner-build-bar.tsx b/src/components/features/conversation/conversation-tabs/conversation-planner-build-bar.tsxnew file mode 100644index 0000000000..602e67b5da--- /dev/null+++ b/src/components/features/conversation/conversation-tabs/conversation-planner-build-bar.tsx@@ -0,0 +1,62 @@+import { useTranslation } from "react-i18next";+import { cn } from "#/utils/utils";+import { I18nKey } from "#/i18n/declaration";+import { useConversationStore } from "#/stores/conversation-store";+import { useSelectConversationTab } from "#/hooks/use-select-conversation-tab";+import { useHandleBuildPlanClick } from "#/hooks/use-handle-build-plan-click";+import { useAgentState, usePlanningAgentState } from "#/hooks/use-agent-state";+import { AgentState } from "#/types/agent-state";+import { Typography } from "#/ui/typography";++/**+ * The Planner tab's Build row, shown below the drawer tab row while the+ * Planner tab is open. Rendered by the desktop drawer header and, at phone+ * width, below the panel page's fixed-height top bar.+ */+export function ConversationPlannerBuildBar({+ className,+}: {+ className?: string;+}) {+ const { t } = useTranslation("openhands");+ const planContent = useConversationStore((state) => state.planContent);+ const { isTabActive } = useSelectConversationTab();+ const { handleBuildPlanClick } = useHandleBuildPlanClick();+ const { curAgentState } = useAgentState();+ const { isPlanningAgentRunning } = usePlanningAgentState();++ if (!isTabActive("planner")) return null;++ const isAgentRunning =+ curAgentState === AgentState.RUNNING ||+ curAgentState === AgentState.LOADING ||+ isPlanningAgentRunning;+ const isBuildDisabled = isAgentRunning || !planContent;++ return (+ <div+ className={cn(+ "flex h-10 min-h-10 shrink-0 items-center border-t border-border pl-2.5 pr-1",+ className,+ )}+ >+ <button+ type="button"+ onClick={handleBuildPlanClick}+ disabled={isBuildDisabled}+ className={cn(+ "flex h-5 min-w-17 items-center justify-center rounded bg-contrast px-2 transition-opacity",+ isBuildDisabled+ ? "cursor-not-allowed opacity-50"+ : "cursor-pointer hover:opacity-90",+ )}+ data-testid="planner-tab-build-button"+ >+ <Typography.Text className="text-[11px] font-normal leading-5 text-contrast-foreground">+ {/* eslint-disable-next-line i18next/no-literal-string */}+ {t(I18nKey.COMMON$BUILD)} ββ©+ </Typography.Text>+ </button>+ </div>+ );+}diff --git a/src/components/features/conversation/conversation-tabs/conversation-tabs.tsx b/src/components/features/conversation/conversation-tabs/conversation-tabs.tsxindex dccda830ff..844461e1d8 100644--- a/src/components/features/conversation/conversation-tabs/conversation-tabs.tsx+++ b/src/components/features/conversation/conversation-tabs/conversation-tabs.tsx@@ -20,13 +20,10 @@ import { ChatActionTooltip } from "../../chat/chat-action-tooltip";import { I18nKey } from "#/i18n/declaration";import { useConversationStore } from "#/stores/conversation-store";import { ConversationTabsContextMenu } from "./conversation-tabs-context-menu";+import { ConversationPlannerBuildBar } from "./conversation-planner-build-bar";import { useConversationId } from "#/hooks/use-conversation-id";import { useSelectConversationTab } from "#/hooks/use-select-conversation-tab";import { useTaskList } from "#/hooks/use-task-list";-import { useHandleBuildPlanClick } from "#/hooks/use-handle-build-plan-click";-import { useAgentState, usePlanningAgentState } from "#/hooks/use-agent-state";-import { AgentState } from "#/types/agent-state";-import { Typography } from "#/ui/typography";import { mobileTopBarIconClassName } from "#/utils/mobile-top-bar-icon-button-classes";export function ConversationTabs({@@ -38,7 +35,7 @@ export function ConversationTabs({isPanelResizing?: boolean;}) {const { conversationId } = useConversationId();- const { setSelectedTab, planContent } = useConversationStore();+ const { setSelectedTab } = useConversationStore();const [isMenuOpen, setIsMenuOpen] = useState(false);@@ -46,9 +43,6 @@ export function ConversationTabs({useConversationLocalStorageState(conversationId);const { hasTaskList } = useTaskList();- const { handleBuildPlanClick } = useHandleBuildPlanClick();- const { curAgentState } = useAgentState();- const { isPlanningAgentRunning } = usePlanningAgentState();const {selectTab,@@ -167,12 +161,6 @@ export function ConversationTabs({const unpinnedSignature = persistedState.unpinnedTabs.join(",");- const isAgentRunning =- curAgentState === AgentState.RUNNING ||- curAgentState === AgentState.LOADING ||- isPlanningAgentRunning;- const isBuildDisabled = isAgentRunning || !planContent;-const tabsRowInnerRef = useRef<HTMLDivElement>(null);const measureRowRef = useRef<HTMLDivElement>(null);const menuRef = useRef<HTMLDivElement>(null);@@ -412,31 +400,9 @@ export function ConversationTabs({</div></div></div>- {isTabActive("planner") && (- <div- className={cn(- "flex h-10 min-h-10 shrink-0 items-center border-t border-border pl-2.5 pr-1",- )}- >- <button- type="button"- onClick={handleBuildPlanClick}- disabled={isBuildDisabled}- className={cn(- "flex h-5 min-w-17 items-center justify-center rounded bg-contrast px-2 transition-opacity",- isBuildDisabled- ? "cursor-not-allowed opacity-50"- : "cursor-pointer hover:opacity-90",- )}- data-testid="planner-tab-build-button"- >- <Typography.Text className="text-[11px] font-normal leading-5 text-contrast-foreground">- {/* eslint-disable-next-line i18next/no-literal-string */}- {t(I18nKey.COMMON$BUILD)} ββ©- </Typography.Text>- </button>- </div>- )}+ {/* At phone width the panel page renders this below its fixed-height+ top bar, where the compact tab row lives. */}+ {variant === "default" && <ConversationPlannerBuildBar />}</>);}diff --git a/src/hooks/use-conversation-panel-route.ts b/src/hooks/use-conversation-panel-route.tsnew file mode 100644index 0000000000..e5be6b53a2--- /dev/null+++ b/src/hooks/use-conversation-panel-route.ts@@ -0,0 +1,43 @@+import React from "react";+import { useMatch, useNavigate } from "react-router";+import { useBreakpoint } from "#/hooks/use-breakpoint";+import { subscribeToPanelReveal } from "#/services/canvas-ui";+import { useConversationStore } from "#/stores/conversation-store";++/**+ * Keeps the conversation drawer's route in step with the viewport. At phone+ * width the drawer is the full-screen `/conversations/:id/panel` page; above+ * the breakpoint it sits beside the chat on `/conversations/:id`.+ *+ * Returns whether to render the full-screen mobile panel page.+ */+export function useConversationPanelRoute(conversationId: string): boolean {+ const isMobile = useBreakpoint();+ const isPanelRoute = Boolean(+ useMatch("/conversations/:conversationId/panel"),+ );+ const navigate = useNavigate();++ // Agent `open_tab` / `navigate_to_file` and chat file links reveal the+ // drawer through canvas-ui. At phone width that means opening the panel page.+ React.useEffect(() => {+ if (!isMobile || isPanelRoute || !conversationId) return undefined;+ return subscribeToPanelReveal(() =>+ navigate(`/conversations/${conversationId}/panel`),+ );+ }, [isMobile, isPanelRoute, conversationId, navigate]);++ // A panel page widened past the breakpoint (or a /panel link opened on+ // desktop) falls back to the split chat | drawer layout with the drawer open.+ // This runs after the panel page's unmount cleanup has closed the drawer.+ React.useEffect(() => {+ if (isMobile || !isPanelRoute || !conversationId) return;+ const { setHasRightPanelToggled, setIsRightPanelShown } =+ useConversationStore.getState();+ setHasRightPanelToggled(true);+ setIsRightPanelShown(true);+ navigate(`/conversations/${conversationId}`, { replace: true });+ }, [isMobile, isPanelRoute, conversationId, navigate]);++ return isPanelRoute && isMobile;+}diff --git a/src/routes/conversation.tsx b/src/routes/conversation.tsxindex 14889dc217..9dfcc65cf8 100644--- a/src/routes/conversation.tsx+++ b/src/routes/conversation.tsx@@ -1,8 +1,9 @@import React from "react";-import { useNavigate, useLocation, useMatch } from "react-router";+import { useNavigate, useLocation } from "react-router";import { useTranslation } from "react-i18next";import { useConversationId } from "#/hooks/use-conversation-id";+import { useConversationPanelRoute } from "#/hooks/use-conversation-panel-route";import { useCommandStore } from "#/stores/command-store";import { useConversationStore } from "#/stores/conversation-store";import { useAgentStore } from "#/stores/agent-store";@@ -34,7 +35,7 @@ import { resumeCloudSandbox } from "#/api/cloud/conversation-service.api";function AppContent() {const { t } = useTranslation("openhands");const { conversationId } = useConversationId();- const panelViewMatch = useMatch("/conversations/:conversationId/panel");+ const showsMobilePanelPage = useConversationPanelRoute(conversationId);const { isTask, taskStatus, taskDetail } = useTaskPollingController();@@ -216,7 +217,7 @@ function AppContent() {<EventHandler><ConversationOverviewDrawerProvider><div data-testid="app-route" className="flex h-full flex-col">- {panelViewMatch ? (+ {showsMobilePanelPage ? (<ConversationMobilePanelPageonNavigateBack={() =>navigate(`/conversations/${conversationId}`)diff --git a/src/services/canvas-ui.ts b/src/services/canvas-ui.tsindex c6b90c8fba..ae9c17e184 100644--- a/src/services/canvas-ui.ts+++ b/src/services/canvas-ui.ts@@ -5,6 +5,7 @@ import {} from "#/stores/conversation-store";import { useFilesTabStore } from "#/stores/files-tab-store";import type { CanvasUIAction } from "#/types/agent-server/core";+import { setConversationState } from "#/utils/conversation-local-storage";import { toFilesTabPath } from "#/utils/path-utils";const VALID_TABS: ReadonlySet<ConversationTab> = new Set<ConversationTab>([@@ -15,16 +16,39 @@ const VALID_TABS: ReadonlySet<ConversationTab> = new Set<ConversationTab>(["tasklist",]);+type PanelRevealListener = () => void;++const panelRevealListeners = new Set<PanelRevealListener>();++/**+ * Subscribe to requests to reveal the conversation drawer. The store flags set+ * below open the desktop side drawer; at phone width the drawer only exists on+ * the `/conversations/:id/panel` route, so the conversation route listens here+ * and navigates there (see `useConversationPanelRoute`).+ */+export function subscribeToPanelReveal(+ listener: PanelRevealListener,+): () => void {+ panelRevealListeners.add(listener);+ return () => {+ panelRevealListeners.delete(listener);+ };+}+// Mirrors src/hooks/use-select-conversation-tab.ts so a non-React caller (the-// WebSocket dispatch) gets the same "reveal the right panel if collapsed"-// behavior as in-app tab switches.-function navigateToTab(tab: ConversationTab) {+// WebSocket dispatch) gets the same "persist the tab and reveal the right+// panel if collapsed" behavior as in-app tab switches.+function navigateToTab(tab: ConversationTab, conversationId: string | null) {const store = useConversationStore.getState();store.setSelectedTab(tab);+ if (conversationId) {+ setConversationState(conversationId, { selectedTab: tab });+ }if (!store.isRightPanelShown) {store.setHasRightPanelToggled(true);store.setIsRightPanelShown(true);}+ panelRevealListeners.forEach((listener) => listener());}function isValidTab(value: string): value is ConversationTab {@@ -57,7 +81,7 @@ export function handleCanvasUIAction(switch (action.command) {case "navigate_to_file":case "show_preview": {- navigateToTab("files");+ navigateToTab("files", conversationId);if (!action.path) return;const workingDir =@@ -73,9 +97,9 @@ export function handleCanvasUIAction(// The in-app VS Code tab was removed β on cloud backends VS Code// now opens in a new browser window via the link in the drawer tab// row. Route agent requests to Files so the drawer still opens.- navigateToTab("files");+ navigateToTab("files", conversationId);} else if (action.tab && isValidTab(action.tab)) {- navigateToTab(action.tab);+ navigateToTab(action.tab, conversationId);} else if (action.tab) {// Surface unknown tab names so they're diagnosable from the browser// console rather than failing silently. Valid tabs are listed in