Skip to content

Commit 12ec17c

Browse files
saphidclaude
andauthored
fix(web): opening a project from the command palette no longer lands in a subagent or side chat (#29891)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent e86dc78 commit 12ec17c

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

‎apps/web/src/components/CommandPalette.browser.test.tsx‎

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
import { describe, expect, it } from "vite-plus/test";
1+
import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
2+
import { describe, expect, it, vi } from "vite-plus/test";
23
import { page } from "vite-plus/test/browser";
34

45
import { render } from "../../test/render";
56
import { openCommandPalette } from "../commandPaletteBus";
67
import { useCommandPaletteStore } from "../commandPaletteStore";
8+
import { makeThreadFixture } from "../test-fixtures";
9+
import type { Project, Thread } from "../types";
710
import { CommandPalette } from "./CommandPalette";
811

9-
function setup() {
12+
const entities = vi.hoisted(() => ({
13+
projects: [] as ReadonlyArray<Project>,
14+
threads: [] as ReadonlyArray<Thread>,
15+
}));
16+
vi.mock("../state/entities", async (original) => ({
17+
...(await original<typeof import("../state/entities")>()),
18+
useProjects: () => entities.projects,
19+
useVisibleThreadShells: () => entities.threads,
20+
}));
21+
22+
function setup(state: { projects?: ReadonlyArray<Project>; threads?: ReadonlyArray<Thread> } = {}) {
1023
useCommandPaletteStore.setState(useCommandPaletteStore.getInitialState(), true);
24+
entities.projects = state.projects ?? [];
25+
entities.threads = state.threads ?? [];
1126
}
1227

1328
describe("CommandPalette open intents", () => {
@@ -30,4 +45,50 @@ describe("CommandPalette open intents", () => {
3045
await expect.element(input).toHaveFocus();
3146
await expect.element(input).toHaveValue("acme");
3247
});
48+
49+
it("opens a searched project's latest listed thread, not a newer subagent", async () => {
50+
const environmentId = EnvironmentId.make("local");
51+
const projectId = ProjectId.make("acme");
52+
const parentId = ThreadId.make("parent");
53+
setup({
54+
projects: [
55+
{
56+
id: projectId,
57+
environmentId,
58+
title: "Acme",
59+
workspaceRoot: "/work/acme",
60+
repositoryIdentity: null,
61+
defaultModelSelection: null,
62+
createdAt: "2026-03-01T00:00:00.000Z",
63+
updatedAt: "2026-03-01T00:00:00.000Z",
64+
scripts: [],
65+
},
66+
],
67+
threads: [
68+
makeThreadFixture({
69+
id: parentId,
70+
environmentId,
71+
projectId,
72+
latestUserMessageAt: "2026-03-02T00:00:00.000Z",
73+
}),
74+
makeThreadFixture({
75+
id: ThreadId.make("subagent"),
76+
environmentId,
77+
projectId,
78+
updatedAt: "2026-03-03T00:00:00.000Z",
79+
lineage: {
80+
rootThreadId: parentId,
81+
parentThreadId: parentId,
82+
relationshipToParent: "subagent",
83+
},
84+
}),
85+
],
86+
});
87+
await using screen = await render(<CommandPalette>{null}</CommandPalette>);
88+
89+
openCommandPalette({ query: "Acme" });
90+
await page.getByRole("option", { name: /Acme/ }).first().click();
91+
92+
await vi.waitFor(() => expect(screen.router?.state.location.pathname).toBe("/local/parent"));
93+
});
3394
});

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ import {
212212
type SearchOverlayMode,
213213
} from "./CommandPalette.logic";
214214
import { resolveEnvironmentOptionLabel } from "./BranchToolbar.logic";
215+
import { isSidebarHiddenThread } from "./Sidebar.logic";
215216
import { CommandPaletteContent } from "./CommandPaletteContent";
216217
import {
217218
selectCommandPaletteClientSettings,
@@ -493,7 +494,8 @@ function OpenCommandPaletteDialog(props: {
493494
if (activeThreadReferenceCopyTarget === null) return;
494495
await copyThreadReference(activeThreadReferenceCopyTarget);
495496
};
496-
const threads = useVisibleThreadShells();
497+
// Side chats and subagents open inside their parent, so opening a project never lands on one.
498+
const threads = useVisibleThreadShells().filter((thread) => !isSidebarHiddenThread(thread));
497499
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
498500
const providersByEnvironment = useEnvironmentProviders();
499501
const { changeThemeItem, changeAppearanceItem, themeEditorItem } = useCommandPaletteThemeItems();

0 commit comments

Comments
 (0)