@devries-cameron20 / t3code Mirror · read-only / commits / 12ec17ce4c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 05:45 UTC

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 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 17:24 UTC 12ec17ce4c6481a8ea1049dedd78d0e56bc48aec
2 files changed +66 -3
apps/web/src/components/CommandPalette.browser.test.tsx
+63 -2
@@ -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";
3 import { page } from "vite-plus/test/browser";
4
5 import { render } from "../../test/render";
6 import { openCommandPalette } from "../commandPaletteBus";
7 import { useCommandPaletteStore } from "../commandPaletteStore";
8 +import { makeThreadFixture } from "../test-fixtures";
9 +import type { Project, Thread } from "../types";
10 import { CommandPalette } from "./CommandPalette";
11
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> } = {}) {
23 useCommandPaletteStore.setState(useCommandPaletteStore.getInitialState(), true);
24 + entities.projects = state.projects ?? [];
25 + entities.threads = state.threads ?? [];
26 }
27
28 describe("CommandPalette open intents", () => {
@@ -30,4 +45,50 @@ describe("CommandPalette open intents", () => {
45 await expect.element(input).toHaveFocus();
46 await expect.element(input).toHaveValue("acme");
47 });
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 + });
94 });
apps/web/src/components/CommandPalette.tsx
+3 -1
@@ -212,6 +212,7 @@ import {
212 type SearchOverlayMode,
213 } from "./CommandPalette.logic";
214 import { resolveEnvironmentOptionLabel } from "./BranchToolbar.logic";
215 +import { isSidebarHiddenThread } from "./Sidebar.logic";
216 import { CommandPaletteContent } from "./CommandPaletteContent";
217 import {
218 selectCommandPaletteClientSettings,
@@ -493,7 +494,8 @@ function OpenCommandPaletteDialog(props: {
494 if (activeThreadReferenceCopyTarget === null) return;
495 await copyThreadReference(activeThreadReferenceCopyTarget);
496 };
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));
499 const keybindings = useAtomValue(primaryServerKeybindingsAtom);
500 const providersByEnvironment = useEnvironmentProviders();
501 const { changeThemeItem, changeAppearanceItem, themeEditorItem } = useCommandPaletteThemeItems();