From f99eb5b399873c315f98e20594b9b7104e3f569d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 05:42:23 +0000 Subject: [PATCH 1/2] test(web): a quick click on another sidebar thread opens it (#40715) Fails on main: the row ignores any click with detail > 1, and macOS keeps counting quick clicks across different rows. Co-Authored-By: Claude Opus 5.5 --- .../src/components/Sidebar.browser.test.tsx | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index 1a0b4c588d64c..467be79ce906d 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -329,6 +329,49 @@ 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 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"); From 24a2b20eb8b55a8b9e47fd70de46c9b0f0ba61b8 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 05:50:12 +0000 Subject: [PATCH 2/2] fix(web): quick clicks on different sidebar threads open each one macOS keeps counting quick clicks across rows, so the second and third fast clicks arrived with detail 2 and 3 and the sidebar dropped them. Only skip the trailing click when it lands on the thread already open, which is the second half of a real double-click to rename. Fixes #40715 Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/Sidebar.browser.test.tsx | 8 ++++++++ apps/web/src/components/Sidebar.tsx | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index 467be79ce906d..1fb930f55fabc 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -361,6 +361,14 @@ describe("sidebar thread click", () => { ); 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 })); diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e9d45a5c1fd84..2a8dcdff50d86 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);