Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
feat: add ability to create a new thread in the current project with shift+click and show shortcut in tooltip (#5994)
Utkarsh Patil752acbf6549e
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.tsindex bfe4162cd..94e78c021 100644--- a/apps/web/src/components/Sidebar.logic.test.ts+++ b/apps/web/src/components/Sidebar.logic.test.ts@@ -32,6 +32,7 @@ import {sortThreadsForSidebar,sortProjectsForSidebar,sortScopedProjectsForSidebar,+ shouldCreateNewThreadInCurrentProject,THREAD_JUMP_HINT_SHOW_DELAY_MS,} from "./Sidebar.logic";import {@@ -410,6 +411,21 @@ describe("isTrailingDoubleClick", () => {});});+describe("shouldCreateNewThreadInCurrentProject", () => {+ it("creates directly on shift+click in a multi-project setup", () => {+ expect(shouldCreateNewThreadInCurrentProject(true, 2)).toBe(true);+ });++ it("opens the picker on a plain click in a multi-project setup", () => {+ expect(shouldCreateNewThreadInCurrentProject(false, 2)).toBe(false);+ });++ it("creates directly on any click with a single project", () => {+ expect(shouldCreateNewThreadInCurrentProject(false, 1)).toBe(true);+ expect(shouldCreateNewThreadInCurrentProject(true, 1)).toBe(true);+ });+});+describe("orderItemsByPreferredIds", () => {it("keeps preferred ids first, skips stale ids, and preserves the relative order of remaining items", () => {const ordered = orderItemsByPreferredIds({diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.tsindex cae26f5d6..9b1db5cb4 100644--- a/apps/web/src/components/Sidebar.logic.ts+++ b/apps/web/src/components/Sidebar.logic.ts@@ -274,6 +274,17 @@ export function isTrailingDoubleClick(detail: number): boolean {return detail > 1;}+// Shift+click on the new thread button creates directly in the current+// project, skipping the command palette's project picker. With a single+// project there is nothing to pick, so a plain click already creates+// immediately and the modifier changes nothing.+export function shouldCreateNewThreadInCurrentProject(+ shiftKey: boolean,+ projectGroupCount: number,+): boolean {+ return shiftKey || projectGroupCount <= 1;+}+export function orderItemsByPreferredIds<TItem, TId>(input: {items: readonly TItem[];preferredIds: readonly TId[];diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex 76d678cb3..41e964a7e 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -131,6 +131,7 @@ import {resolveSettledTimestamp,resolveSidebarThreadStatus,searchSidebarThreadsByTitle,+ shouldCreateNewThreadInCurrentProject,resolveWorkingStartedAt,sortLogicalProjectsForSidebar,sortPinnedThreadsForSidebar,@@ -3164,29 +3165,39 @@ export default function Sidebar() {// falling back to the top project) — same resolution the command palette// uses. The command palette already offers a "New thread in..." submenu// for multi-project setups.- const handleNewThreadClick = useCallback(() => {- // One project: nothing to pick, create immediately.- if (projectGroups.length <= 1) {+ const handleNewThreadClick = useCallback(+ (event?: ReactMouseEvent) => {+ // One project: nothing to pick, create immediately. Shift+click creates+ // directly in the current project even with several projects, skipping+ // the palette picker.+ if (shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, projectGroups.length)) {+ if (isMobile) setOpenMobile(false);+ void startNewThreadFromContext({+ activeDraftThread: newThreadContext.activeDraftThread,+ activeThread: newThreadContext.activeThread ?? undefined,+ defaultProjectRef: newThreadContext.defaultProjectRef,+ handleNewThread: newThreadContext.handleNewThread,+ });+ return;+ }if (isMobile) setOpenMobile(false);- void startNewThreadFromContext({- activeDraftThread: newThreadContext.activeDraftThread,- activeThread: newThreadContext.activeThread ?? undefined,- defaultProjectRef: newThreadContext.defaultProjectRef,- handleNewThread: newThreadContext.handleNewThread,- });- return;- }- if (isMobile) setOpenMobile(false);- openCommandPalette({ open: "new-thread-in" });- }, [isMobile, newThreadContext, projectGroups.length, setOpenMobile]);+ openCommandPalette({ open: "new-thread-in" });+ },+ [isMobile, newThreadContext, projectGroups.length, setOpenMobile],+ );// The button mirrors chat.new: in multi-project setups both route through// the command palette's "New thread in..." picker, and in single-project- // setups both create immediately. chat.newLocal always creates directly, so- // it is only a correct label when chat.new is unbound.+ // setups both create immediately. In multi-project setups the label is only+ // the picker's shortcut: falling back to chat.newLocal would advertise the+ // same shortcut for both the picker and direct create. In single-project+ // setups both commands create directly, so chat.newLocal is a valid+ // fallback. The second tooltip line (multi-project only) advertises+ // shift+click and its keyboard twin chat.newLocal for direct create.const newThreadShortcutLabel =shortcutLabelForCommand(keybindings, "chat.new") ??- shortcutLabelForCommand(keybindings, "chat.newLocal");+ (projectGroups.length <= 1 ? shortcutLabelForCommand(keybindings, "chat.newLocal") : undefined);+ const newThreadInProjectShortcutLabel = shortcutLabelForCommand(keybindings, "chat.newLocal");return (<><SidebarChromeHeader isElectron={isElectron} />@@ -3264,9 +3275,25 @@ export default function Sidebar() {/></TooltipTrigger><TooltipPopup side="right">- {newThreadShortcutLabel- ? `New thread (${newThreadShortcutLabel})`- : "New thread"}+ {projectGroups.length > 1 ? (+ <span className="flex flex-col gap-0.5">+ <span>+ {newThreadShortcutLabel+ ? `New thread (${newThreadShortcutLabel})`+ : "New thread"}+ </span>+ <span className="text-muted-foreground">+ New thread in current project: Shift+click+ {newThreadInProjectShortcutLabel+ ? ` (${newThreadInProjectShortcutLabel})`+ : ""}+ </span>+ </span>+ ) : newThreadShortcutLabel ? (+ `New thread (${newThreadShortcutLabel})`+ ) : (+ "New thread"+ )}</TooltipPopup></Tooltip></div>