@devries-cameron20 / t3code Mirror · read-only / commits / e514c36f3c
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 21, 09:45 UTC

fix(web): project picker jump shortcuts follow the filtered rows (#31174)

Julius Marminge committed Nov 16, 2026 at 18:01 UTC e514c36f3ceb08fab77251e7fe2fc610589f0759
2 files changed +76 -2
apps/web/src/components/CommandPalette.browser.test.tsx
+59
@@ -16,7 +16,32 @@ const entities = vi.hoisted(() => ({
16 projects: [] as ReadonlyArray<Project>,
17 threads: [] as ReadonlyArray<Thread>,
18 delegatedUnderParent: new Set<string>() as ReadonlySet<string>,
19 + handleNewThread: vi.fn(async () => undefined),
20 }));
21 +vi.mock("../state/server", async (original) => {
22 + const actual = await original<typeof import("../state/server")>();
23 + const { Atom } = await import("effect/reactivity");
24 + const { compileResolvedKeybindingsConfig } = await import("@t3tools/shared/keybindings");
25 + const { THREAD_JUMP_KEYBINDING_COMMANDS } = await import("@t3tools/contracts");
26 + // The default jump bindings are desktop-only; these hold in the browser too.
27 + const jumpBindings = compileResolvedKeybindingsConfig(
28 + THREAD_JUMP_KEYBINDING_COMMANDS.map((command, index) => ({
29 + key: `mod+${index + 1}`,
30 + command,
31 + })),
32 + );
33 + return { ...actual, primaryServerKeybindingsAtom: Atom.make(jumpBindings) };
34 +});
35 +vi.mock("../hooks/useHandleNewThread", async (original) => {
36 + const actual = await original<typeof import("../hooks/useHandleNewThread")>();
37 + return {
38 + ...actual,
39 + useHandleNewThread: () => ({
40 + ...actual.useHandleNewThread(),
41 + handleNewThread: entities.handleNewThread,
42 + }),
43 + };
44 +});
45 vi.mock("../state/entities", async (original) => ({
46 ...(await original<typeof import("../state/entities")>()),
47 useProjects: () => entities.projects,
@@ -32,6 +57,21 @@ function setup(state: Partial<typeof entities> = {}) {
57 entities.projects = state.projects ?? [];
58 entities.threads = state.threads ?? [];
59 entities.delegatedUnderParent = state.delegatedUnderParent ?? new Set();
60 + entities.handleNewThread.mockClear();
61 +}
62 +
63 +function makeProject(title: string): Project {
64 + return {
65 + id: ProjectId.make(title),
66 + environmentId: EnvironmentId.make("local"),
67 + title,
68 + workspaceRoot: `/work/${title}`,
69 + repositoryIdentity: null,
70 + defaultModelSelection: null,
71 + createdAt: "2026-03-01T00:00:00.000Z",
72 + updatedAt: "2026-03-01T00:00:00.000Z",
73 + scripts: [],
74 + };
75 }
76
77 describe("CommandPalette open intents", () => {
@@ -207,4 +247,23 @@ describe("CommandPalette open intents", () => {
247
248 await vi.waitFor(() => expect(screen.router?.state.location.pathname).toBe("/local/parent"));
249 });
250 +
251 + it("numbers filtered New thread in... rows from 1 and jumps to them", async () => {
252 + using _platform = vi.spyOn(navigator, "platform", "get").mockReturnValue("Linux x86_64");
253 + setup({ projects: [makeProject("server"), makeProject("lima")] });
254 + await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
255 +
256 + openCommandPalette({ open: "new-thread-in" });
257 + await userEvent.fill(page.getByPlaceholder("Search..."), "li");
258 + await expect.element(page.getByRole("option", { name: /server/ })).not.toBeInTheDocument();
259 + await expect.element(page.getByRole("option", { name: /lima/ })).toMatchTextContent("Ctrl+1");
260 + await userEvent.keyboard("{Control>}1{/Control}");
261 +
262 + await vi.waitFor(() =>
263 + expect(entities.handleNewThread).toHaveBeenCalledWith({
264 + environmentId: EnvironmentId.make("local"),
265 + projectId: ProjectId.make("lima"),
266 + }),
267 + );
268 + });
269 });
apps/web/src/components/CommandPalette.tsx
+17 -2
@@ -916,7 +916,7 @@ function OpenCommandPaletteDialog(props: {
916 rowOrderKey("new-thread-in"),
917 true,
918 );
919 - // Jump shortcuts follow the rows as shown, so a pin cannot move a number to another row.
919 + // Root search suggestions copy these numbers; the picker renumbers its shown rows below.
920 const projectJumpItems = new Map(
921 enumerateCommandPaletteItems(
922 openingOrderThreadItems.filter((item) => item.value !== NEW_THREAD_NO_PROJECT_VALUE),
@@ -1827,7 +1827,7 @@ function OpenCommandPaletteDialog(props: {
1827
1828 const isLinkedThreadSearch =
1829 linkedThreadSearch?.linkedThreads !== undefined && deferredQuery === linkedThreadSearch.query;
1830 - const filteredGroups = filterCommandPaletteGroups({
1830 + const searchedGroups = filterCommandPaletteGroups({
1831 activeGroups,
1832 query: deferredQuery,
1833 isInSubmenu: currentView !== null,
@@ -1865,6 +1865,21 @@ function OpenCommandPaletteDialog(props: {
1865 threadMessageItems: isLinkedThreadSearch ? [] : threadMessageItems,
1866 now: searchNow,
1867 });
1868 + // Jump shortcuts number the project rows as shown, so a pin cannot move a number to another row.
1869 + const filteredGroups = searchedGroups.map((group) => {
1870 + if (group.value !== NEW_THREAD_IN_GROUP) return group;
1871 + const jumpItems = new Map(
1872 + enumerateCommandPaletteItems(
1873 + group.items.filter(
1874 + (item): item is CommandPaletteActionItem =>
1875 + item.kind === "action" &&
1876 + item.value !== NEW_THREAD_NO_PROJECT_VALUE &&
1877 + item.value !== addProjectAction.value,
1878 + ),
1879 + ).map((item) => [item.value, item] as const),
1880 + );
1881 + return { ...group, items: group.items.map((item) => jumpItems.get(item.value) ?? item) };
1882 + });
1883
1884 const handleAddProjectForEnvironment = async (input: {
1885 readonly environmentId: EnvironmentId;