diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index 1a0b4c588d64..1fb930f55fab 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -329,6 +329,57 @@ describe("sidebar thread rename", () => { ); }); +describe("sidebar thread click", () => { + // regression: #40715 macOS counts quick clicks on different rows, so the next row got detail 2 and was ignored + it("opens another thread when the click arrives with a double-click count", async () => { + const activeProject = project("active"); + const threads = [threadShell(activeProject.id, 0), threadShell(activeProject.id, 1)]; + const routeThreadRef: ScopedThreadRef = { + environmentId: activeProject.environmentId, + threadId: threads[0]!.id, + }; + vi.mocked(useProjects).mockReturnValue([activeProject]); + vi.mocked(useQuietThreadShells).mockReturnValue(threads); + vi.mocked(useThreadRouteTarget).mockReturnValue({ kind: "server", threadRef: routeThreadRef }); + vi.mocked(useHandleNewThread).mockReturnValue({ + activeDraftThread: null, + activeThread: null, + defaultProjectRef: { + environmentId: activeProject.environmentId, + projectId: activeProject.id, + }, + defaultProjectFallbackReady: true, + handleNewThread: vi.fn().mockResolvedValue(null), + routeDraftId: null, + routeThreadRef, + }); + await using screen = await render( + + + , + { router: "/local/thread-0" }, + ); + const navigate = vi.spyOn(screen.router!, "navigate").mockResolvedValue(undefined); + + const openRow = screen.getByText("Thread 0").first().element(); + await act(() => { + openRow.dispatchEvent( + new MouseEvent("click", { bubbles: true, cancelable: true, detail: 2 }), + ); + }); + expect(navigate).not.toHaveBeenCalled(); + + const row = screen.getByText("Thread 1").first().element(); + await act(() => { + row.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true, detail: 2 })); + }); + + expect(navigate).toHaveBeenCalledWith( + expect.objectContaining({ params: expect.objectContaining({ threadId: "thread-1" }) }), + ); + }); +}); + describe("sidebar thread menu", () => { it("tells the menu whether the keyboard opened it", async () => { const activeProject = project("active"); diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e9d45a5c1fd8..2a8dcdff50d8 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -1612,7 +1612,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve rangeSelectTo(threadKey, orderedThreadKeysRef.current); return; } - if (isTrailingDoubleClick(event.detail)) { + // macOS keeps counting quick clicks across rows, so only the open row's trailing click is a double-click. + if (isTrailingDoubleClick(event.detail) && routeThreadKey === threadKey) { return; } navigateToThread(threadRef);