From 552dedd26b2c7c977b0baa92044dedff0bc015c9 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Fri, 14 Aug 2026 13:06:57 -0700 Subject: [PATCH] Keep remote workspace filter visible (#14579) --- .../SidebarWorkspaceFilterSection.test.tsx | 31 ++------------- .../sidebar/SidebarWorkspaceFilterSection.tsx | 39 +------------------ 2 files changed, 6 insertions(+), 64 deletions(-) diff --git a/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.test.tsx b/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.test.tsx index 3afe412fb8f..3701737c85e 100644 --- a/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.test.tsx +++ b/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.test.tsx @@ -35,10 +35,7 @@ function setState(overrides: Record = {}): void { setHideDetachedHeadWorkspaces: vi.fn(), hideWorkspacesFromOtherDevices: false, setHideWorkspacesFromOtherDevices: vi.fn(), - worktreesByRepo: {}, - folderWorkspaces: [], runtimeEnvironments: [], - runtimeStatusByEnvironmentId: new Map(), alwaysShowDefaultBranchWorkspace: true, setAlwaysShowDefaultBranchWorkspace: vi.fn(), ...overrides @@ -90,37 +87,17 @@ describe('SidebarWorkspaceFilterSection', () => { expect(rowLabels()).not.toContain(EXEMPTION_LABEL) }) - it('shows the other-client filter only when it can hide a known workspace', () => { + it('shows the other-client filter when a remote server is configured', () => { setState({ - worktreesByRepo: { - repo: [ - { - id: 'other', - runtimeOwnerEnvironmentId: 'server', - creatorProvenance: { kind: 'paired-device', deviceId: 'other-client' } - } - ] - }, - runtimeEnvironments: [{ id: 'server', pairedDeviceId: 'this-client' }] + runtimeEnvironments: [{ id: 'server' }] }) render() expect(rowLabels()).toContain('Hide other-client workspaces') }) - it('hides the other-client filter when every known workspace belongs to this client', () => { - setState({ - worktreesByRepo: { - repo: [ - { - id: 'own', - runtimeOwnerEnvironmentId: 'server', - creatorProvenance: { kind: 'paired-device', deviceId: 'this-client' } - } - ] - }, - runtimeEnvironments: [{ id: 'server', pairedDeviceId: 'this-client' }] - }) + it('hides the other-client filter for local-only clients', () => { + setState() render() expect(rowLabels()).not.toContain('Hide other-client workspaces') diff --git a/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.tsx b/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.tsx index 4186da051bb..ba06a2d1dae 100644 --- a/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.tsx +++ b/src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react' +import React from 'react' import { CalendarClock, GitBranch, @@ -9,13 +9,7 @@ import { } from 'lucide-react' import { useAppStore } from '@/store' import { translate } from '@/i18n/i18n' -import { getIndexedAllWorktrees } from '@/store/worktree-repo-index' import { FilterToggleRow } from './FilterToggleRow' -import { - getPairedDeviceIdsByEnvironment, - isFolderWorkspaceFromOtherDevice, - isWorkspaceFromOtherDevice -} from './workspace-creator-visibility' const SidebarWorkspaceFilterSection = React.memo(function SidebarWorkspaceFilterSection() { const showSleepingWorkspaces = useAppStore((s) => s.showSleepingWorkspaces) @@ -32,41 +26,12 @@ const SidebarWorkspaceFilterSection = React.memo(function SidebarWorkspaceFilter const setHideDetachedHeadWorkspaces = useAppStore((s) => s.setHideDetachedHeadWorkspaces) const hideWorkspacesFromOtherDevices = useAppStore((s) => s.hideWorkspacesFromOtherDevices) const setHideWorkspacesFromOtherDevices = useAppStore((s) => s.setHideWorkspacesFromOtherDevices) - const worktreesByRepo = useAppStore((s) => s.worktreesByRepo) - const folderWorkspaces = useAppStore((s) => s.folderWorkspaces) const runtimeEnvironments = useAppStore((s) => s.runtimeEnvironments) - const runtimeStatusByEnvironmentId = useAppStore((s) => s.runtimeStatusByEnvironmentId) const alwaysShowDefaultBranchWorkspace = useAppStore((s) => s.alwaysShowDefaultBranchWorkspace) const setAlwaysShowDefaultBranchWorkspace = useAppStore( (s) => s.setAlwaysShowDefaultBranchWorkspace ) - const showOtherClientFilter = useMemo(() => { - if (hideWorkspacesFromOtherDevices) { - return true - } - const pairedDeviceIds = getPairedDeviceIdsByEnvironment( - runtimeEnvironments, - runtimeStatusByEnvironmentId - ) - const worktrees = getIndexedAllWorktrees(worktreesByRepo) - return ( - worktrees.some( - (worktree) => !worktree.isArchived && isWorkspaceFromOtherDevice(worktree, pairedDeviceIds) - ) || - folderWorkspaces.some((workspace) => { - if (workspace.isArchived) { - return false - } - return isFolderWorkspaceFromOtherDevice(workspace, pairedDeviceIds) - }) - ) - }, [ - folderWorkspaces, - hideWorkspacesFromOtherDevices, - runtimeEnvironments, - runtimeStatusByEnvironmentId, - worktreesByRepo - ]) + const showOtherClientFilter = runtimeEnvironments.length > 0 || hideWorkspacesFromOtherDevices return ( <>