Skip to content

Commit 44f8826

Browse files
committed
chore: update logic to be mac specific
1 parent b724251 commit 44f8826

3 files changed

Lines changed: 15 additions & 32 deletions

File tree

apps/web/src/components/Sidebar.logic.test.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { describe, expect, it } from "vitest";
22

33
import {
44
hasUnseenCompletion,
5-
isContextMenuPointerDown,
65
resolveThreadRowClassName,
76
resolveThreadStatusPill,
87
shouldClearThreadSelectionOnMouseDown,
@@ -64,35 +63,6 @@ describe("shouldClearThreadSelectionOnMouseDown", () => {
6463
});
6564
});
6665

67-
describe("isContextMenuPointerDown", () => {
68-
it("treats secondary-button pointerdown as a context-menu gesture", () => {
69-
expect(
70-
isContextMenuPointerDown({
71-
button: 2,
72-
ctrlKey: false,
73-
}),
74-
).toBe(true);
75-
});
76-
77-
it("treats ctrl-primary-click as a context-menu gesture", () => {
78-
expect(
79-
isContextMenuPointerDown({
80-
button: 0,
81-
ctrlKey: true,
82-
}),
83-
).toBe(true);
84-
});
85-
86-
it("does not treat primary-button pointerdown as a context-menu gesture", () => {
87-
expect(
88-
isContextMenuPointerDown({
89-
button: 0,
90-
ctrlKey: false,
91-
}),
92-
).toBe(false);
93-
});
94-
});
95-
9666
describe("resolveThreadStatusPill", () => {
9767
const baseThread = {
9868
interactionMode: "plan" as const,

apps/web/src/components/Sidebar.logic.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ export function shouldClearThreadSelectionOnMouseDown(target: HTMLElement | null
3838
return !target.closest(THREAD_SELECTION_SAFE_SELECTOR);
3939
}
4040

41-
export function isContextMenuPointerDown(input: { button: number; ctrlKey: boolean }): boolean {
41+
export function isMacOS(): boolean {
42+
const nav = window.navigator as Navigator & {
43+
userAgentData?: { platform: string };
44+
};
45+
return nav.userAgentData ? nav.userAgentData.platform === "macOS" : /Mac/i.test(nav.userAgent);
46+
}
47+
48+
export function isContextMenuPointerDown(input: {
49+
button: number;
50+
ctrlKey: boolean;
51+
isMac: boolean;
52+
}): boolean {
4253
if (input.button === 2) return true;
43-
return input.button === 0 && input.ctrlKey;
54+
return input.isMac && input.button === 0 && input.ctrlKey;
4455
}
4556

4657
export function resolveThreadRowClassName(input: {

apps/web/src/components/Sidebar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "
9393
import { isNonEmpty as isNonEmptyString } from "effect/String";
9494
import {
9595
isContextMenuPointerDown,
96+
isMacOS,
9697
resolveThreadRowClassName,
9798
resolveThreadStatusPill,
9899
shouldClearThreadSelectionOnMouseDown,
@@ -927,6 +928,7 @@ export default function Sidebar() {
927928
isContextMenuPointerDown({
928929
button: event.button,
929930
ctrlKey: event.ctrlKey,
931+
isMac: isMacOS(),
930932
})
931933
) {
932934
// Keep context-menu gestures from arming the sortable drag sensor.

0 commit comments

Comments
 (0)