@devries-cameron20 / t3code Mirror · read-only / commits / 42d2387285
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, 06:00 UTC

fix(web): right-clicking a sidebar search result now opens its thread actions (#31545)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Nawfal Ahmed committed Nov 20, 2026 at 00:29 UTC 42d2387285eea2e4cb34bab29e64f78f65a8b3b2
5 files changed +50 -4
apps/web/src/components/Sidebar.drag.browser.test.tsx
+1
@@ -128,6 +128,7 @@ it("keeps focus in the search box when a click picks a search result", async ()
128 searchQuery="invoice"
129 onHighlight={() => {}}
130 onSelect={onSelect}
131 + onContextMenu={() => {}}
132 onFileDropThreads={() => {}}
133 />
134 </ul>
apps/web/src/components/Sidebar.tsx
+22 -3
@@ -2607,17 +2607,30 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2607 );
2608
2609 const handleThreadContextMenu = useStableCallback(
2610 - (threadRef: ScopedThreadRef, position: { x: number; y: number }, source: ContextMenuSource) => {
2610 + (
2611 + threadRef: ScopedThreadRef,
2612 + position: { x: number; y: number },
2613 + source: ContextMenuSource,
2614 + fromSearch = false,
2615 + ) => {
2616 void (async () => {
2617 const api = readLocalApi();
2618 if (!api) return;
2619 const threadKey = scopedThreadKey(threadRef);
2620 const selectionState = useThreadSelectionStore.getState();
2616 - if (selectionState.hasSelection() && selectionState.selectedThreadKeys.has(threadKey)) {
2621 + // Search results are not selectable rows, so they always act on their own thread.
2622 + if (
2623 + !fromSearch &&
2624 + selectionState.hasSelection() &&
2625 + selectionState.selectedThreadKeys.has(threadKey)
2626 + ) {
2627 await handleMultiSelectContextMenu(position, source);
2628 return;
2629 }
2620 - const thread = threadByKeyRef.current.get(threadKey);
2630 + // Search results also reach threads in collapsed shelves, which are not rendered rows.
2631 + const thread =
2632 + threadByKeyRef.current.get(threadKey) ??
2633 + searchableThreads.find((candidate) => threadShellKey(candidate) === threadKey);
2634 if (!thread) return;
2635 const threadWorkspacePath =
2636 thread.worktreePath ??
@@ -2671,6 +2684,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2684 canShareWithGuestAtom(threadRef.environmentId),
2685 ),
2686 canTurnIntoProject: canTurnThreadIntoProject(threadRef),
2687 + canRename: !fromSearch,
2688 supports: {
2689 settlement: configLoaded,
2690 autoSettleOptOut: supportsAutoSettleOptOut,
@@ -2897,6 +2911,10 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2911 })();
2912 },
2913 );
2914 + const handleSearchResultContextMenu = useStableCallback(
2915 + (threadRef: ScopedThreadRef, position: { x: number; y: number }, source: ContextMenuSource) =>
2916 + handleThreadContextMenu(threadRef, position, source, true),
2917 + );
2918
2919 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to window keydown for thread navigation shortcuts using the current thread list
2920 useEffect(() => {
@@ -3284,6 +3302,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3302 searchMatchQuery={threadSearch.query}
3303 onHighlight={() => setActiveSearchResultIndex(index)}
3304 onSelect={() => selectThreadSearchResult(thread)}
3305 + onContextMenu={handleSearchResultContextMenu}
3306 onFileDropThreads={handleThreadFileDrop}
3307 />
3308 );
apps/web/src/components/sidebar/SidebarThreadRow.tsx
+13
@@ -1777,6 +1777,11 @@ export const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props
1777 searchMatchQuery?: string;
1778 onHighlight: () => void;
1779 onSelect: () => void;
1780 + onContextMenu: (
1781 + threadRef: ScopedThreadRef,
1782 + position: { x: number; y: number },
1783 + source: ContextMenuSource,
1784 + ) => void;
1785 onFileDropThreads: (threadRef: ScopedThreadRef, files: File[]) => void;
1786 }) {
1787 const messages = useMessages();
@@ -1881,6 +1886,14 @@ export const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props
1886 event.preventDefault();
1887 }}
1888 onClick={props.onSelect}
1889 + onContextMenu={(event) => {
1890 + event.preventDefault();
1891 + props.onContextMenu(
1892 + threadRef,
1893 + { x: event.clientX, y: event.clientY },
1894 + contextMenuSourceOf(event),
1895 + );
1896 + }}
1897 className={cn(
1898 "group/sidebar-row group/v2-row flex min-h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 py-1 text-left text-sm outline-none",
1899 props.isHighlighted || props.isRouteActive
apps/web/src/components/threadActionMenu.logic.test.ts
+5
@@ -74,4 +74,9 @@ describe("buildThreadActionMenuItems", () => {
74 expect(items.find((item) => item.id === "archive")?.disabled).toBe(true);
75 expect(items.find((item) => item.id === "turn-into-project")?.disabled).toBe(true);
76 });
77 +
78 + it("disables only rename where no inline title editor exists", () => {
79 + const items = buildThreadActionMenuItems({ ...baseState, canRename: false });
80 + expect(items.filter((item) => item.disabled).map((item) => item.id)).toEqual(["rename"]);
81 + });
82 });
apps/web/src/components/threadActionMenu.logic.ts
+9 -1
@@ -96,6 +96,8 @@ export function buildDraftActionMenuItems(
96 export interface ThreadActionMenuState {
97 readonly canOperate: boolean;
98 readonly canFind?: boolean;
99 + /** False where no inline title editor is rendered, such as sidebar search results. */
100 + readonly canRename?: boolean;
101 readonly branch: string | null;
102 readonly projectFilter: {
103 readonly label: string;
@@ -198,7 +200,13 @@ export function buildThreadActionMenuItems(
200 },
201 ]
202 : []),
201 - { id: "rename", label: resolve(msg("Rename thread")), icon: "pencil", separatorBefore: true },
203 + {
204 + id: "rename",
205 + label: resolve(msg("Rename thread")),
206 + icon: "pencil",
207 + disabled: state.canRename === false,
208 + separatorBefore: true,
209 + },
210 ...(state.supports.titleRegeneration
211 ? [
212 {