Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix(app): keep diagnostics first in the palette and copy the focused pane's ID

ogsamrat83047a372b3f
diff --git a/apps/app/src/app/lib/diagnostics-bundle.ts b/apps/app/src/app/lib/diagnostics-bundle.ts
index ee1c3a2b..e19e8a29 100644
--- a/apps/app/src/app/lib/diagnostics-bundle.ts
+++ b/apps/app/src/app/lib/diagnostics-bundle.ts
@@ -28,7 +28,8 @@ export type DiagnosticsBundleContext = {
omnirushServerStatus?: OmniRushServerStatus;
omnirushServerUrl?: string;
runtimeWorkspaceId?: string | null;
- selectedSessionId?: string | null;
+ /** The session in the focused pane: the side chat while it has focus. */
+ focusedSession?: { workspaceId: string; sessionId: string } | null;
selectedWorkspaceId?: string | null;
cloudMcpHealth?: unknown;
};
@@ -159,7 +160,8 @@ export function composeDiagnosticsBundleJson(input: DiagnosticsBundleInputs): st
developerMode: context?.developerMode === true,
},
session: {
- id: context?.selectedSessionId?.trim() || null,
+ id: context?.focusedSession?.sessionId ?? null,
+ workspaceId: context?.focusedSession?.workspaceId ?? null,
},
workspace: {
id: context?.selectedWorkspaceId?.trim() || null,
diff --git a/apps/app/src/i18n/locales/en.ts b/apps/app/src/i18n/locales/en.ts
index b09ef834..b4081d94 100644
--- a/apps/app/src/i18n/locales/en.ts
+++ b/apps/app/src/i18n/locales/en.ts
@@ -1221,6 +1221,8 @@ export default {
"session.cmd_new_session_detail": "Start a fresh task in the current workspace",
"session.cmd_new_session_meta": "Create",
"session.cmd_new_session_title": "New session",
+ "session.cmd_session_id_meta": "Copy",
+ "session.cmd_session_id_title": "Session ID",
"session.cmd_diagnostics_copy_title": "Copy diagnostics",
"session.cmd_diagnostics_copy_detail": "Copy a sanitized diagnostics bundle to share when something goes wrong",
"session.cmd_diagnostics_export_title": "Export diagnostics",
@@ -2036,7 +2038,6 @@ export default {
"session_management.pin_session": "Pin session",
"session_management.unpin_session": "Unpin session",
"session_management.copy_session_id": "Copy session ID",
- "session_management.copy_session_id_unavailable": "Open a session to copy its ID",
"session_management.session_id_copied": "Session ID copied",
"session_management.session_id_copy_failed": "Couldn't copy the session ID",
"session_management.open_in_split_view": "Open as side chat",
diff --git a/apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx b/apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx
index 7b7f486f..9bcedbaf 100644
--- a/apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx
+++ b/apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx
@@ -386,10 +386,6 @@ function SessionMenuContent({
{t("workspace_list.rename_session")}
</DropdownMenuItem>
) : null}
- <DropdownMenuItem data-session-menu-copy-id onClick={() => void copySessionId(sessionId)}>
- <Copy className="size-4" />
- {t("session_management.copy_session_id")}
- </DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<Tag className="size-4" />
@@ -653,7 +649,7 @@ type SessionContextMenuProps = {
isArchived: boolean;
};
-export function SessionContextMenu({
+function SessionContextMenu({
children,
sessionId,
workspaceId,
diff --git a/apps/app/src/react-app/domains/session/sidebar/copy-session-id.ts b/apps/app/src/react-app/domains/session/sidebar/copy-session-id.tsx
similarity index 64%
rename from apps/app/src/react-app/domains/session/sidebar/copy-session-id.ts
rename to apps/app/src/react-app/domains/session/sidebar/copy-session-id.tsx
index 8bbefe6e..4d52f315 100644
--- a/apps/app/src/react-app/domains/session/sidebar/copy-session-id.ts
+++ b/apps/app/src/react-app/domains/session/sidebar/copy-session-id.tsx
@@ -1,15 +1,21 @@
+/** @jsxImportSource react */
import { toast } from "@/components/ui/sonner";
import { t } from "@/i18n";
/**
* Put a session ID on the clipboard so it can be shared with support. When
- * the clipboard is unavailable the error toast shows the ID to copy by hand.
+ * the clipboard is unavailable the error toast shows the ID to copy by hand:
+ * it stays until closed, and one click selects the whole ID.
*/
export async function copySessionId(sessionId: string) {
try {
await navigator.clipboard.writeText(sessionId);
toast.success(t("session_management.session_id_copied"));
} catch {
- toast.error(t("session_management.session_id_copy_failed"), { description: sessionId });
+ toast.error(t("session_management.session_id_copy_failed"), {
+ id: "session-id-copy-failed",
+ description: <span className="select-all break-all font-mono">{sessionId}</span>,
+ duration: Infinity,
+ });
}
}
diff --git a/apps/app/src/react-app/shell/command-palette-sessions.ts b/apps/app/src/react-app/shell/command-palette-sessions.ts
index ea0e45ab..e631cee2 100644
--- a/apps/app/src/react-app/shell/command-palette-sessions.ts
+++ b/apps/app/src/react-app/shell/command-palette-sessions.ts
@@ -20,21 +20,25 @@ export function buildCommandPaletteSplitSessions(
));
}
-/** Stays listed without a session so people can find it, but only runs with one. */
+/**
+ * Only offered while a session is focused, like "Find in conversation", so it
+ * can never be the highlighted first result that swallows Enter. "Copy" stays
+ * out of the title so "copy", "debug", "report" and "share" keep leading to the
+ * diagnostics items, even after this item has been used recently.
+ */
export function buildCopySessionIdPaletteItem(
- selectedSessionId: string | null | undefined,
+ focusedSessionId: string | null | undefined,
copy: (sessionId: string) => void,
-): PaletteItem {
- const sessionId = selectedSessionId?.trim();
+): PaletteItem | null {
+ const sessionId = focusedSessionId?.trim();
+ if (!sessionId) return null;
return {
id: "session.copy-id",
- title: t("session_management.copy_session_id"),
- detail: sessionId || t("session_management.copy_session_id_unavailable"),
- searchText: "copy session id identifier share support report issue debug",
- disabled: !sessionId,
- action: () => {
- if (sessionId) copy(sessionId);
- },
+ title: t("session.cmd_session_id_title"),
+ detail: sessionId,
+ meta: t("session.cmd_session_id_meta"),
+ searchText: "copy session id identifier copy id",
+ action: () => copy(sessionId),
};
}
diff --git a/apps/app/src/react-app/shell/session-route.tsx b/apps/app/src/react-app/shell/session-route.tsx
index a3ef4fb0..4d9d1d73 100644
--- a/apps/app/src/react-app/shell/session-route.tsx
+++ b/apps/app/src/react-app/shell/session-route.tsx
@@ -2846,6 +2846,19 @@ export function SessionRoute() {
},
}), [developerMode]);
+ // A focused side chat is the conversation people are looking at, so its ID is
+ // the one to copy and report. It only shows beside the route's own session.
+ const focusedSideChat = useWorkbenchStore((state) => (
+ state.focusedPane === "secondary"
+ && state.primary?.workspaceId === selectedWorkspaceId
+ && state.primary.sessionId === selectedSessionId
+ ? state.secondary
+ : null
+ ));
+ const focusedSession = useMemo(() => (
+ focusedSideChat ?? (selectedSessionId ? { workspaceId: selectedWorkspaceId, sessionId: selectedSessionId } : null)
+ ), [focusedSideChat, selectedSessionId, selectedWorkspaceId]);
+
const buildCommandDiagnosticsBundle = useCallback(() => buildDiagnosticsBundleJson({
anyActiveRuns: activeReloadBlockingSessions.length > 0,
canReloadWorkspace: reloadCoordinator.canReloadWorkspaceEngine,
@@ -2855,7 +2868,7 @@ export function SessionRoute() {
omnirushServerStatus: client ? "connected" : "disconnected",
omnirushServerUrl: baseUrl,
runtimeWorkspaceId: selectedWorkspaceEndpoint?.workspaceId ?? null,
- selectedSessionId,
+ focusedSession,
selectedWorkspaceId,
}), [
activeReloadBlockingSessions.length,
@@ -2863,17 +2876,17 @@ export function SessionRoute() {
canCreateTask,
client,
developerMode,
+ focusedSession,
omnirushServerHostInfoState,
reloadCoordinator.canReloadWorkspaceEngine,
- selectedSessionId,
selectedWorkspaceEndpoint?.workspaceId,
selectedWorkspaceId,
]);
- const copySessionIdPaletteItem = useMemo(() => buildCopySessionIdPaletteItem(selectedSessionId, (sessionId) => {
+ const copySessionIdPaletteItem = useMemo(() => buildCopySessionIdPaletteItem(focusedSession?.sessionId, (sessionId) => {
setCommandPaletteOpen(false);
void copySessionId(sessionId);
- }), [selectedSessionId]);
+ }), [focusedSession?.sessionId]);
const diagnosticsCopyPaletteItem = useMemo<PaletteItem>(() => ({
id: "diagnostics.copy",
@@ -3781,7 +3794,7 @@ export function SessionRoute() {
currentSessionForGroupMove={currentSessionForGroupMove}
currentSessionGroupId={currentSessionGroupId}
onMoveCurrentSessionToGroup={handleMoveCurrentSessionToGroup}
- extraItems={[...currentSessionActionPaletteItems, ...(sessionFindPaletteItem ? [sessionFindPaletteItem] : []), sessionSearchPaletteItem, ...terminalPaletteItems, ...(checkDesktopRestriction({ restriction: "allowControlSettings" }) ? [] : [developerModePaletteItem]), copySessionIdPaletteItem, diagnosticsCopyPaletteItem, diagnosticsExportPaletteItem, nextSessionTabPaletteItem, prevSessionTabPaletteItem, reloadConfigPaletteItem]}
+ extraItems={[...currentSessionActionPaletteItems, ...(sessionFindPaletteItem ? [sessionFindPaletteItem] : []), sessionSearchPaletteItem, ...terminalPaletteItems, ...(checkDesktopRestriction({ restriction: "allowControlSettings" }) ? [] : [developerModePaletteItem]), ...(copySessionIdPaletteItem ? [copySessionIdPaletteItem] : []), diagnosticsCopyPaletteItem, diagnosticsExportPaletteItem, nextSessionTabPaletteItem, prevSessionTabPaletteItem, reloadConfigPaletteItem]}
listAgents={listAgents}
selectedAgent={selectedAgent}
onSelectAgent={setSelectedAgent}
diff --git a/apps/app/tests/command-palette-sessions.test.ts b/apps/app/tests/command-palette-sessions.test.ts
index 752f2551..6f7f93bf 100644
--- a/apps/app/tests/command-palette-sessions.test.ts
+++ b/apps/app/tests/command-palette-sessions.test.ts
@@ -1,10 +1,12 @@
import { describe, expect, test } from "bun:test";
+import { t } from "../src/i18n";
+import type { SessionOption } from "../src/react-app/shell/command-palette";
+import { rankPaletteItems, type PaletteItem } from "../src/react-app/shell/command-palette-search";
import {
buildCommandPaletteSplitSessions,
buildCopySessionIdPaletteItem,
} from "../src/react-app/shell/command-palette-sessions";
-import type { SessionOption } from "../src/react-app/shell/command-palette";
const sessions: SessionOption[] = [
{
@@ -53,27 +55,64 @@ describe("command palette split sessions", () => {
});
describe("command palette Copy session ID", () => {
- test("is enabled with the selected session and copies its ID", () => {
+ test("shows the focused session's ID and copies it", () => {
const copied: string[] = [];
const item = buildCopySessionIdPaletteItem("ses_selected_1", (sessionId) => copied.push(sessionId));
- expect(item.title).toBe("Copy session ID");
- expect(item.disabled).toBe(false);
- expect(item.detail).toBe("ses_selected_1");
- item.action();
+ expect(item?.title).toBe("Session ID");
+ expect(item?.detail).toBe("ses_selected_1");
+ expect(item?.meta).toBe("Copy");
+ item?.action();
expect(copied).toEqual(["ses_selected_1"]);
});
- test("stays listed but disabled until a session is selected", () => {
- for (const selected of [null, undefined, "", " "]) {
- const copied: string[] = [];
- const item = buildCopySessionIdPaletteItem(selected, (sessionId) => copied.push(sessionId));
+ test("is not offered until a session is focused", () => {
+ for (const focused of [null, undefined, "", " "]) {
+ expect(buildCopySessionIdPaletteItem(focused, () => {})).toBeNull();
+ }
+ });
+
+ test("leaves copy, debug, report and share queries to the diagnostics items", () => {
+ // Mirrors the diagnostics items in session-route.tsx.
+ const diagnostics: PaletteItem[] = [
+ {
+ id: "diagnostics.copy",
+ title: t("session.cmd_diagnostics_copy_title"),
+ detail: t("session.cmd_diagnostics_copy_detail"),
+ searchText: "logs share diagnostics debug support bundle troubleshoot copy report issue",
+ action: () => {},
+ },
+ {
+ id: "diagnostics.export",
+ title: t("session.cmd_diagnostics_export_title"),
+ detail: t("session.cmd_diagnostics_export_detail"),
+ searchText: "logs export diagnostics debug support bundle save file json download",
+ action: () => {},
+ },
+ ];
+ const ranked = (sessionId: string, query: string, recentIds: string[] = []) => {
+ const copySessionId = buildCopySessionIdPaletteItem(sessionId, () => {});
+ return rankPaletteItems(query, copySessionId ? [copySessionId, ...diagnostics] : diagnostics, recentIds)
+ .flatMap((group) => group.items.map((item) => item.id));
+ };
+ const sessionId = "ses_5e0a1b2c3d4eAbCdEfGhIjKlMn";
+
+ expect(ranked(sessionId, "copy")).toEqual(["diagnostics.copy", "session.copy-id"]);
+ expect(ranked(sessionId, "debug")).toEqual(["diagnostics.export", "diagnostics.copy"]);
+ expect(ranked(sessionId, "report")).toEqual(["diagnostics.copy", "diagnostics.export"]);
+ expect(ranked(sessionId, "report issue")).toEqual(["diagnostics.copy", "diagnostics.export"]);
+ expect(ranked(sessionId, "share")).toEqual(["diagnostics.copy"]);
+ for (const query of ["session id", "copy session id", "copy id"]) {
+ expect(ranked(sessionId, query)[0]).toBe("session.copy-id");
+ }
- expect(item.id).toBe("session.copy-id");
- expect(item.disabled).toBe(true);
- expect(item.detail).toBe("Open a session to copy its ID");
- item.action();
- expect(copied).toEqual([]);
+ // A recent use does not change that, nor does an ID that spells out the
+ // query words: the ID only matches on the detail line.
+ for (const query of ["copy", "debug", "report", "report issue", "share"]) {
+ expect(ranked(sessionId, query, ["session.copy-id"])).toEqual(ranked(sessionId, query));
+ const ids = ranked("ses_copy_debug_report_issue_share", query, ["session.copy-id"]);
+ expect(ids[0]?.startsWith("diagnostics.")).toBe(true);
+ expect(ids.indexOf("diagnostics.copy")).toBeLessThan(ids.indexOf("session.copy-id"));
}
});
});
diff --git a/apps/app/tests/copy-session-id.test.tsx b/apps/app/tests/copy-session-id.test.tsx
deleted file mode 100644
index d1cbbe06..00000000
--- a/apps/app/tests/copy-session-id.test.tsx
+++ /dev/null
@@ -1,135 +0,0 @@
-/** @jsxImportSource react */
-import { afterEach, expect, mock, test } from "bun:test";
-import { GlobalRegistrator } from "@happy-dom/global-registrator";
-import { act } from "react";
-import { createRoot, type Root } from "react-dom/client";
-
-import type { SidebarContextValue } from "../src/react-app/domains/session/sidebar/app-sidebar-provider";
-
-// The app toaster is not mounted here; record what the menu reports instead.
-const toasts: string[] = [];
-mock.module("@/components/ui/sonner", () => ({
- toast: {
- success: (message: string) => toasts.push(`success:${message}`),
- error: (message: string, options?: { description?: string }) =>
- toasts.push(`error:${message}:${options?.description ?? ""}`),
- },
-}));
-
-if (typeof globalThis.window === "undefined" || typeof globalThis.document === "undefined") {
- GlobalRegistrator.register({ url: "http://localhost/" });
-}
-Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", { configurable: true, value: true });
-
-const copied: string[] = [];
-let clipboardFails = false;
-Object.defineProperty(navigator, "clipboard", {
- configurable: true,
- value: {
- writeText: async (text: string) => {
- if (clipboardFails) throw new Error("clipboard blocked");
- copied.push(text);
- },
- },
-});
-
-const [{ SessionContextMenu }, { SidebarContext }] = await Promise.all([
- import("../src/react-app/domains/session/sidebar/app-sidebar"),
- import("../src/react-app/domains/session/sidebar/app-sidebar-provider"),
-]);
-
-const noop = () => {};
-const sidebarContext: SidebarContextValue = {
- selectedWorkspaceId: "ws-1",
- selectedSessionId: null,
- developerMode: false,
- newTaskDisabled: false,
- connectingWorkspaceId: null,
- workspaceConnectionStateById: {},
- onSelectWorkspace: noop,
- onOpenSession: noop,
- onCreateTaskInWorkspace: noop,
- onCreateSplitTaskInWorkspace: noop,
- onOpenRenameWorkspace: noop,
- onShareWorkspace: noop,
- onRevealWorkspace: noop,
- onRecoverWorkspace: noop,
- onTestWorkspaceConnection: noop,
- onEditWorkspaceConnection: noop,
- onForgetWorkspace: noop,
- expandWorkspace: noop,
- toggleWorkspaceExpanded: noop,
- expandedWorkspaceIds: new Set(),
- sessionNumberShortcutOs: "macos",
- sessionNumberShortcutByTarget: new Map(),
-};
-
-const mounted: { root: Root; container: HTMLElement }[] = [];
-
-afterEach(async () => {
- for (const { root, container } of mounted.splice(0)) {
- await act(async () => root.unmount());
- container.remove();
- }
- toasts.length = 0;
- copied.length = 0;
- clipboardFails = false;
-});
-
-async function waitFor<T>(read: () => T | null, label: string): Promise<T> {
- const deadline = Date.now() + 2_000;
- while (Date.now() < deadline) {
- const value = read();
- if (value) return value;
- await act(async () => {
- await new Promise<void>((resolve) => setTimeout(resolve, 10));
- });
- }
- throw new Error(`Timed out waiting for ${label}`);
-}
-
-async function copyFromSessionMenu(sessionId: string) {
- const container = document.createElement("div");
- document.body.append(container);
- const root = createRoot(container);
- mounted.push({ root, container });
- await act(async () => root.render(
- <SidebarContext.Provider value={sidebarContext}>
- <SessionContextMenu sessionId={sessionId} workspaceId="ws-1" isPinned={false} isArchived={false}>
- <button type="button" data-testid="session-row">Session row</button>
- </SessionContextMenu>
- </SidebarContext.Provider>,
- ));
-
- const row = await waitFor(
- () => container.querySelector<HTMLElement>('[data-testid="session-row"]'),
- "the session row",
- );
- await act(async () => {
- row.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 10, clientY: 10 }));
- });
- const item = await waitFor(
- () => document.body.querySelector<HTMLElement>("[data-session-menu-copy-id]"),
- "the Copy session ID menu item",
- );
- expect(item.textContent).toContain("Copy session ID");
- await act(async () => {
- item.click();
- });
- await waitFor(() => (toasts.length > 0 ? toasts : null), "the copy toast");
-}
-
-test("the sidebar session menu copies the session ID and confirms with a toast", async () => {
- await copyFromSessionMenu("ses_menu_copy_1");
-
- expect(copied).toEqual(["ses_menu_copy_1"]);
- expect(toasts).toEqual(["success:Session ID copied"]);
-});
-
-test("a blocked clipboard still shows the session ID so it can be copied by hand", async () => {
- clipboardFails = true;
- await copyFromSessionMenu("ses_menu_copy_2");
-
- expect(copied).toEqual([]);
- expect(toasts).toEqual(["error:Couldn't copy the session ID:ses_menu_copy_2"]);
-});
diff --git a/apps/app/tests/diagnostics-bundle.test.ts b/apps/app/tests/diagnostics-bundle.test.ts
index cb5a1a42..cef534e0 100644
--- a/apps/app/tests/diagnostics-bundle.test.ts
+++ b/apps/app/tests/diagnostics-bundle.test.ts
@@ -112,29 +112,29 @@ describe("diagnostics bundle", () => {
expect(parsed.omnirushServer.settings.tokenPresent).toBe(false);
});
- test("carries the selected session and workspace IDs for support", () => {
+ test("carries the focused session and selected workspace IDs for support", () => {
const input = baseInputs();
input.context = {
...input.context,
runtimeWorkspaceId: "runtime-ws-1",
- selectedSessionId: "ses_diagnostics_1",
+ focusedSession: { workspaceId: "ws-side-chat", sessionId: "ses_side_chat_1" },
selectedWorkspaceId: "ws-diagnostics-1",
};
const parsed = JSON.parse(composeDiagnosticsBundleJson(input));
- expect(parsed.session).toEqual({ id: "ses_diagnostics_1" });
+ expect(parsed.session).toEqual({ id: "ses_side_chat_1", workspaceId: "ws-side-chat" });
expect(parsed.workspace.id).toBe("ws-diagnostics-1");
expect(parsed.workspace.runtimeWorkspaceId).toBe("runtime-ws-1");
});
- test("reports no session when none is selected", () => {
+ test("reports no session when none is focused", () => {
const input = baseInputs();
- input.context = { ...input.context, selectedSessionId: null, selectedWorkspaceId: "" };
+ input.context = { ...input.context, focusedSession: null, selectedWorkspaceId: "" };
const parsed = JSON.parse(composeDiagnosticsBundleJson(input));
- expect(parsed.session).toEqual({ id: null });
+ expect(parsed.session).toEqual({ id: null, workspaceId: null });
expect(parsed.workspace.id).toBeNull();
});
diff --git a/evals/specs/command-palette-pin-rename.e2e.test.ts b/evals/specs/command-palette-pin-rename.e2e.test.ts
index 4f1ebaef..69a934b1 100644
--- a/evals/specs/command-palette-pin-rename.e2e.test.ts
+++ b/evals/specs/command-palette-pin-rename.e2e.test.ts
@@ -1,3 +1,5 @@
+import { expect } from "vitest";
+import type { Target } from "@omnirush/cdp";
import { spec } from "@omnirush/testkit";
import { paletteSessionActions } from "../worlds/chat.ts";
@@ -6,7 +8,25 @@ const shortcut = process.platform === "darwin" ? "Meta+K" : "Control+K";
const paletteInput = { placeholder: "Search actions, settings, and sessions…" };
const paletteFooter = { text: "Arrow keys to navigate" };
-test("the command palette pins and renames the open session", async ({ world, user, probe, step }) => {
+test("the command palette pins, renames and copies the ID of the open session", async ({ world, user, probe, step }) => {
+ const sessionId = world.session.sessionId;
+ const renamedTitle = "Renamed from the palette";
+ const copySessionIdMenuItem: Target = { role: "menuitem", label: "Copy session ID" };
+ const sessionIdCopied: Target = { text: "Session ID copied" };
+ const highlightedItem = async (title: string) => {
+ const dom = await probe.eventually(() => probe.dom("[data-command-palette-item][data-highlighted]"), {
+ within: 5_000,
+ label: `${title} is the highlighted palette item`,
+ until: (value) => value.elements[0]?.text.startsWith(title) === true,
+ });
+ return dom.elements[0]?.text;
+ };
+ const waitForPaletteClose = () => probe.eventually(() => probe.has("Arrow keys to navigate"), {
+ within: 15_000,
+ label: "command palette closes",
+ until: (open) => !open,
+ });
+
await step("the palette offers Pin session for the open session", async () => {
await user.notSee({ text: "Pinned" });
await user.press(shortcut);
@@ -68,4 +88,58 @@ test("the command palette pins and renames the open session", async ({ world, us
await user.notSee({ text: world.session.title });
await user.screenshot();
});
+
+ await step("the sidebar menu copies the session ID", async () => {
+ await user.rightClick({ text: renamedTitle });
+ await user.click(copySessionIdMenuItem);
+ await user.see(sessionIdCopied);
+ expect(await world.readClipboard()).toBe(sessionId);
+ await user.screenshot();
+ });
+
+ await step("copy still leads to Copy diagnostics, which carries the session ID", async () => {
+ await probe.eventually(() => probe.has("Session ID copied"), {
+ within: 15_000,
+ label: "the sidebar copy toast disappears",
+ until: (shown) => !shown,
+ });
+ await user.press(shortcut);
+ await user.see(paletteInput);
+ await user.type(paletteInput, "copy", { replace: true });
+ await user.see({ role: "option", label: /^Session ID/ });
+ expect(await highlightedItem("Copy diagnostics")).toMatch(/^Copy diagnostics/);
+ await user.screenshot();
+ await user.press("Enter");
+ await user.see({ text: /^Diagnostics copied/ });
+ const bundle: unknown = JSON.parse(await world.readClipboard());
+ expect(bundle).toMatchObject({ session: { id: sessionId, workspaceId: world.workspace.workspaceId } });
+ await waitForPaletteClose();
+ });
+
+ await step("the palette's Session ID item copies the open session's ID", async () => {
+ await user.press(shortcut);
+ await user.see(paletteInput);
+ await user.type(paletteInput, "session id", { replace: true });
+ await user.see({ text: sessionId });
+ expect(await highlightedItem("Session ID")).toMatch(/^Session ID/);
+ await user.screenshot();
+ await user.press("Enter");
+ await user.see(sessionIdCopied);
+ expect(await world.readClipboard()).toBe(sessionId);
+ await waitForPaletteClose();
+ });
+
+ await step("a blocked clipboard keeps the ID on screen, selected in one click", async () => {
+ await world.blockClipboardWrites();
+ await user.rightClick({ text: renamedTitle });
+ await user.click(copySessionIdMenuItem);
+ await user.see({ text: "Couldn't copy the session ID" });
+ await user.see({ text: sessionId });
+ // Outlast sonner's 4 s default lifetime with the pointer away from the toast.
+ await new Promise((resolve) => setTimeout(resolve, 6_000));
+ await user.see({ text: sessionId });
+ await user.click({ text: sessionId });
+ expect(await world.selectedText()).toBe(sessionId);
+ await user.screenshot();
+ });
});
diff --git a/evals/specs/command-palette-search.e2e.test.ts b/evals/specs/command-palette-search.e2e.test.ts
index 91d55009..6bd4d5d9 100644
--- a/evals/specs/command-palette-search.e2e.test.ts
+++ b/evals/specs/command-palette-search.e2e.test.ts
@@ -168,6 +168,23 @@ test("command palette searches settings by alias, navigates, records recents, an
});
}
-
-
+ await step("with no session open, copy leads to Copy diagnostics and no session ID is offered", async () => {
+ await user.press(paletteShortcut);
+ await user.see(paletteInput);
+ await user.type(paletteInput, "copy", { replace: true });
+ await user.see({ role: "option", label: /^Copy diagnostics/ });
+ await user.notSee({ role: "option", label: /^Session ID/ });
+ const highlighted = await probe.eventually(() => probe.dom("[data-command-palette-item][data-highlighted]"), {
+ within: 5_000,
+ label: "Copy diagnostics is the highlighted palette item",
+ until: (dom) => dom.elements[0]?.text.startsWith("Copy diagnostics") === true,
+ });
+ expect(highlighted.elements[0]?.text).toMatch(/^Copy diagnostics/);
+ await user.screenshot();
+ await user.press("Enter");
+ await user.see({ text: /^Diagnostics copied/ });
+ const bundle: unknown = JSON.parse(await world.readClipboard());
+ expect(bundle).toMatchObject({ session: { id: null, workspaceId: null }, workspace: { id: workspaceId } });
+ await waitForPaletteClose();
+ });
});
diff --git a/evals/specs/new-split-session.e2e.test.ts b/evals/specs/new-split-session.e2e.test.ts
index f4b16592..1e6413b8 100644
--- a/evals/specs/new-split-session.e2e.test.ts
+++ b/evals/specs/new-split-session.e2e.test.ts
@@ -230,6 +230,21 @@ test("side chats keep questions, replies, and saved splits attached to their own
await waitSplit(primary, first.secondary);
});
+ await step("with the side chat focused, the palette's Session ID is the side chat's", async () => {
+ await user.click({ placeholder: "Describe your task...", nth: 1 });
+ await probe.eventually(facts, { within: 15_000, label: "the side pane takes focus", until: (value) => value.focused === "secondary" });
+ await user.press(shortcut);
+ await user.see(paletteInput);
+ await user.type(paletteInput, "session id", { replace: true });
+ await user.see({ role: "option", label: /^Session ID/ });
+ const item = await probe.dom('[data-command-palette-item="session.copy-id"]');
+ expect(item.elements[0]?.text).toContain(first.secondary);
+ expect(item.elements[0]?.text).not.toContain(primary);
+ await user.screenshot();
+ await user.press("Escape");
+ await user.notSee(paletteInput);
+ });
+
await step("palette creation replaces the focused side pane without moving the main conversation", async () => {
await using creation = await world.continuity.observeCreation();
await palette("new split", /^Open side chat/);
diff --git a/evals/worlds/chat.ts b/evals/worlds/chat.ts
index 6c36041f..0f83b6c8 100644
--- a/evals/worlds/chat.ts
+++ b/evals/worlds/chat.ts
@@ -220,7 +220,26 @@ export async function paletteSessionActions(seed: Seed) {
const app = await seed.desktop({ name: "command-palette-pin-rename" });
const workspace = await seed.workspace(app, seed.tmpPath("command-palette-pin-rename"));
const session = await seedSessionRetry(seed, app, { title: "Palette pin rename probe" });
- return { app, workspace, session };
+ return {
+ app,
+ workspace,
+ session,
+ async readClipboard() {
+ return seed.evalIn(app, () => navigator.clipboard.readText(), { awaitPromise: true });
+ },
+ async selectedText() {
+ return seed.evalIn(app, () => window.getSelection()?.toString() ?? "");
+ },
+ /** Reject clipboard writes the way a denied clipboard permission does. */
+ async blockClipboardWrites() {
+ await seed.evalIn(app, () => {
+ Object.defineProperty(navigator.clipboard, "writeText", {
+ configurable: true,
+ value: () => Promise.reject(new DOMException("Write permission denied.", "NotAllowedError")),
+ });
+ });
+ },
+ };
}
async function splitPaneQuestions(
diff --git a/evals/worlds/session-shell.ts b/evals/worlds/session-shell.ts
index ea138a4d..b939f75c 100644
--- a/evals/worlds/session-shell.ts
+++ b/evals/worlds/session-shell.ts
@@ -1395,7 +1395,13 @@ export async function pinnedSessions(seed: Seed) {
}
export async function commandPaletteSearch(seed: Seed) {
- return oneWorkspace(seed, `command-palette-search-${Date.now()}`);
+ const world = await oneWorkspace(seed, `command-palette-search-${Date.now()}`);
+ return {
+ ...world,
+ async readClipboard() {
+ return seed.evalIn(world.app, () => navigator.clipboard.readText(), { awaitPromise: true });
+ },
+ };
}
export async function archiveSessions(seed: Seed) {