Skip to content

Commit ca0c8b4

Browse files
fix(web): open project picker from boring sidebar
1 parent 5211acf commit ca0c8b4

4 files changed

Lines changed: 73 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,10 +2842,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
28422842
const showJumpHints = useThreadJumpHintsVisible(shouldShowJumpHintsNow);
28432843

28442844
const handleNewThreadClick = (event?: ReactMouseEvent) => {
2845-
if (
2846-
boringSidebarEnabled ||
2847-
shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, projectGroups.length)
2848-
) {
2845+
if (shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, projectGroups.length)) {
28492846
if (isMobile) setOpenMobile(false);
28502847
void startNewThreadFromContext({
28512848
activeDraftThread: newThreadContext.activeDraftThread,
@@ -3045,7 +3042,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30453042
newThreadDisabled={projects.length === 0}
30463043
newThreadShortcutLabel={newThreadShortcutLabel}
30473044
newThreadInProjectShortcutLabel={newThreadInProjectShortcutLabel}
3048-
showNewThreadInProjectHint={!boringSidebarEnabled && projectGroups.length > 1}
3045+
showNewThreadInProjectHint={projectGroups.length > 1}
30493046
searchInputRef={threadSearchInputRef}
30503047
searchQuery={threadSearchQuery}
30513048
onSearchQueryChange={(value) => {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { DEFAULT_CLIENT_SETTINGS, EnvironmentId, ProjectId } from "@t3tools/contracts";
2+
import type { AnyRouter } from "@tanstack/react-router";
3+
import { describe, expect, it, vi } from "vite-plus/test";
4+
5+
import * as commandPalette from "../commandPaletteBus";
6+
import * as settings from "../hooks/useSettings";
7+
import * as threadActions from "../lib/chatThreadActions";
8+
import * as entities from "../state/entities";
9+
import type { Project } from "../types";
10+
import { installChatRouteCommands } from "./chatRouteCommands";
11+
import * as dispatcher from "./dispatcher";
12+
13+
function project(id: string): Project {
14+
return {
15+
id: ProjectId.make(id),
16+
environmentId: EnvironmentId.make("local"),
17+
title: id,
18+
workspaceRoot: `/projects/${id}`,
19+
repositoryIdentity: null,
20+
defaultModelSelection: null,
21+
createdAt: "2026-01-01T00:00:00.000Z",
22+
updatedAt: "2026-01-01T00:00:00.000Z",
23+
scripts: [],
24+
};
25+
}
26+
27+
describe("new thread commands", () => {
28+
it.each([
29+
{ mode: "normal", count: 2, command: "chat.new", picker: true },
30+
{ mode: "boring", count: 2, command: "chat.new", picker: true },
31+
{ mode: "boring", count: 1, command: "chat.new", picker: false },
32+
{ mode: "legacy", count: 2, command: "chat.new", picker: false },
33+
{ mode: "boring", count: 2, command: "chat.newLocal", picker: false },
34+
] as const)("$mode sidebar, $count projects, $command: picker=$picker", (scenario) => {
35+
using _settings = vi.spyOn(settings, "getClientSettings").mockReturnValue({
36+
...DEFAULT_CLIENT_SETTINGS,
37+
boringSidebarEnabled: scenario.mode === "boring",
38+
legacySidebarEnabled: scenario.mode === "legacy",
39+
});
40+
using _projects = vi
41+
.spyOn(entities, "readProjects")
42+
.mockReturnValue([project("active"), project("idle")].slice(0, scenario.count));
43+
using openPicker = vi.spyOn(commandPalette, "openCommandPalette").mockImplementation(() => {});
44+
using startLocal = vi.spyOn(threadActions, "startNewThreadFromContext").mockResolvedValue(true);
45+
using register = vi.spyOn(dispatcher, "registerCommands").mockReturnValue(() => {});
46+
const router = { state: { matches: [] } } as unknown as AnyRouter;
47+
using stack = new DisposableStack();
48+
stack.defer(installChatRouteCommands(router));
49+
const commands = register.mock.calls[0]![0];
50+
const event = {
51+
preventDefault: vi.fn(),
52+
stopPropagation: vi.fn(),
53+
} as unknown as KeyboardEvent;
54+
55+
commands[scenario.command]!(event);
56+
57+
if (scenario.picker) {
58+
expect(openPicker).toHaveBeenCalledWith({ open: "new-thread-in" });
59+
expect(startLocal).not.toHaveBeenCalled();
60+
} else {
61+
expect(openPicker).not.toHaveBeenCalled();
62+
expect(startLocal).toHaveBeenCalledOnce();
63+
}
64+
});
65+
});

‎apps/web/src/shortcuts/chatRouteCommands.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,8 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
117117
void scratch.startScratchThread(environmentId);
118118
},
119119
"chat.new": (event) => {
120-
// The boring sidebar's folders already show the context, so it starts in
121-
// the current project like the legacy sidebar did.
122-
const { boringSidebarEnabled, legacySidebarEnabled } = getClientSettings();
123-
if (!boringSidebarEnabled && !legacySidebarEnabled && readProjectGroupCount() > 1) {
120+
const { legacySidebarEnabled } = getClientSettings();
121+
if (!legacySidebarEnabled && readProjectGroupCount() > 1) {
124122
claim(event);
125123
openCommandPalette({ open: "new-thread-in" });
126124
return;

‎docs/user/thread-sidebar.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ need a separate branch and working directory.
55

66
## Start a thread
77

8-
On web and desktop, a new thread keeps the current project and carries your model
9-
and mode selections, unless the destination project has its own model default.
8+
On web and desktop, **New thread** opens the project picker when you have multiple
9+
projects in the default or project-grouped sidebar. **Shift-click** to start in
10+
the current project, or use a project's own new-thread action. A new thread carries
11+
your model and mode selections, unless the destination project has its own model default.
1012
Its branch and workspace mode come from your configured defaults. To continue in
1113
an existing worktree, use **New thread in this worktree** from the branch toolbar.
1214

0 commit comments

Comments
 (0)