Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
const threadKey = scopedThreadKey(threadRef);
const lastVisitedAt = useUiStateStore((state) => state.threadLastVisitedAtById[threadKey]);
const isSelected = useThreadSelectionStore((state) => state.selectedThreadKeys.has(threadKey));
const hasSelection = useThreadSelectionStore((state) => state.selectedThreadKeys.size > 0);
const runningTerminalIds = useTerminalStateStore(
(state) =>
selectThreadTerminalState(state.terminalStateByThreadKey, threadRef).runningTerminalIds,
Expand Down Expand Up @@ -411,6 +410,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
const handleRowContextMenu = useCallback(
(event: React.MouseEvent) => {
event.preventDefault();
const hasSelection = useThreadSelectionStore.getState().hasSelection();
if (hasSelection && isSelected) {
void handleMultiSelectContextMenu({
x: event.clientX,
Expand All @@ -427,14 +427,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
y: event.clientY,
});
},
[
clearSelection,
handleMultiSelectContextMenu,
handleThreadContextMenu,
hasSelection,
isSelected,
threadRef,
],
[clearSelection, handleMultiSelectContextMenu, handleThreadContextMenu, isSelected, threadRef],
);
const handlePrClick = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
Expand Down Expand Up @@ -945,7 +938,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
const clearSelection = useThreadSelectionStore((state) => state.clearSelection);
const removeFromSelection = useThreadSelectionStore((state) => state.removeFromSelection);
const setSelectionAnchor = useThreadSelectionStore((state) => state.setAnchor);
const selectedThreadCount = useThreadSelectionStore((state) => state.selectedThreadKeys.size);
const { copyToClipboard: copyThreadIdToClipboard } = useCopyToClipboard<{
threadId: ThreadId;
}>({
Expand Down Expand Up @@ -1215,7 +1207,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
event.stopPropagation();
return;
}
if (selectedThreadCount > 0) {
if (useThreadSelectionStore.getState().hasSelection()) {
clearSelection();
}
toggleProject(project.projectKey);
Expand All @@ -1224,7 +1216,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
clearSelection,
dragInProgressRef,
project.projectKey,
selectedThreadCount,
suppressProjectClickAfterDragRef,
suppressProjectClickForContextMenuRef,
toggleProject,
Expand Down Expand Up @@ -2748,7 +2739,6 @@ export default function Sidebar() {
const suppressProjectClickAfterDragRef = useRef(false);
const suppressProjectClickForContextMenuRef = useRef(false);
const [desktopUpdateState, setDesktopUpdateState] = useState<DesktopUpdateState | null>(null);
const selectedThreadCount = useThreadSelectionStore((s) => s.selectedThreadKeys.size);
const clearSelection = useThreadSelectionStore((s) => s.clearSelection);
const setSelectionAnchor = useThreadSelectionStore((s) => s.setAnchor);
const platform = navigator.platform;
Expand Down Expand Up @@ -3193,7 +3183,7 @@ export default function Sidebar() {

useEffect(() => {
const onMouseDown = (event: globalThis.MouseEvent) => {
if (selectedThreadCount === 0) return;
if (!useThreadSelectionStore.getState().hasSelection()) return;
const target = event.target instanceof HTMLElement ? event.target : null;
if (!shouldClearThreadSelectionOnMouseDown(target)) return;
clearSelection();
Expand All @@ -3203,7 +3193,7 @@ export default function Sidebar() {
return () => {
window.removeEventListener("mousedown", onMouseDown);
};
}, [clearSelection, selectedThreadCount]);
}, [clearSelection]);

useEffect(() => {
if (!isElectron) return;
Expand Down
Loading