mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 08:03:20 +00:00
refactor: pass app state to palette filter builder
Let the builder function extract the sidebar scope it needs instead of requiring callers to destructure and pass individual properties. This reduces coupling and simplifies the data flow through the palette initialization lifecycle.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ExecutionHostId } from '../../../../shared/execution-host'
|
||||
import { getVisibleWorkspaceHostIdSet } from '../sidebar/visible-worktree-host-scope'
|
||||
import type { Worktree } from '../../../../shared/worktree/types'
|
||||
import { getVisibleWorkspaceHostIdSet } from '../sidebar/visible-worktree-host-scope'
|
||||
import {
|
||||
resolveRepoFilterHostId,
|
||||
resolveWorktreeFilterHostId,
|
||||
@@ -120,16 +120,11 @@ export function reconcilePaletteFilter(
|
||||
return { hostIds, projectKeys }
|
||||
}
|
||||
|
||||
export type SidebarScopeForPaletteFilter = Parameters<typeof getVisibleWorkspaceHostIdSet>[0] & {
|
||||
type SidebarScopeForPaletteFilter = Parameters<typeof getVisibleWorkspaceHostIdSet>[0] & {
|
||||
filterRepoIds: readonly string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeds the palette's host/project selection from the sidebar's "Show" scope so
|
||||
* Cmd+J opens on the same slice the user is looking at. One-way: the user can
|
||||
* clear or change it per open, and the sidebar never reads it back. A field
|
||||
* that would select every option is left empty — that is not a filter, just chips.
|
||||
*/
|
||||
/** Omits fields that select every available option because they do not narrow results. */
|
||||
export function buildPaletteFilterFromSidebarScope(
|
||||
scope: SidebarScopeForPaletteFilter,
|
||||
model: PaletteFilterModel
|
||||
|
||||
@@ -24,7 +24,7 @@ import type { WorktreeJumpPaletteWorktrees } from './use-worktree-jump-palette-w
|
||||
|
||||
type WorktreeJumpPaletteSelectionLifecycleInput = WorktreeJumpPaletteStoreState &
|
||||
WorktreeJumpPaletteLocalState &
|
||||
WorktreeJumpPaletteFilter &
|
||||
Pick<WorktreeJumpPaletteFilter, 'filterModel'> &
|
||||
WorktreeJumpPaletteOpenTabs &
|
||||
WorktreeJumpPaletteProjectTargets &
|
||||
WorktreeJumpPaletteQuickActions &
|
||||
@@ -60,9 +60,6 @@ export function useWorktreeJumpPaletteSelectionLifecycle({
|
||||
setSelectedItemId,
|
||||
setRawFilter,
|
||||
filterModel,
|
||||
workspaceHostScope,
|
||||
visibleWorkspaceHostIds,
|
||||
filterRepoIds,
|
||||
selectionMovedByUserRef,
|
||||
taskSourceUrl,
|
||||
listRef,
|
||||
@@ -87,10 +84,8 @@ export function useWorktreeJumpPaletteSelectionLifecycle({
|
||||
if (visible && !wasVisibleRef.current) {
|
||||
recordFeatureInteraction('cmd-j')
|
||||
createLookupGuard.invalidate()
|
||||
activeGroupSnapshotRef.current = captureCmdJActiveGroupSnapshot(
|
||||
useAppStore.getState(),
|
||||
activeWorktreeId
|
||||
)
|
||||
const appState = useAppStore.getState()
|
||||
activeGroupSnapshotRef.current = captureCmdJActiveGroupSnapshot(appState, activeWorktreeId)
|
||||
previousWorktreeIdRef.current = activeWorktreeId
|
||||
previousActiveTabTypeRef.current = activeTabType
|
||||
previousBrowserPageIdRef.current =
|
||||
@@ -114,13 +109,7 @@ export function useWorktreeJumpPaletteSelectionLifecycle({
|
||||
setQuery('')
|
||||
setSelectedItemId('')
|
||||
selectionMovedByUserRef.current = false
|
||||
// Each open starts from the sidebar's current Show scope, not the last palette selection.
|
||||
setRawFilter(
|
||||
buildPaletteFilterFromSidebarScope(
|
||||
{ workspaceHostScope, visibleWorkspaceHostIds, filterRepoIds },
|
||||
filterModel
|
||||
)
|
||||
)
|
||||
setRawFilter(buildPaletteFilterFromSidebarScope(appState, filterModel))
|
||||
listRef.current?.scrollTo(0, 0)
|
||||
}
|
||||
if (!visible && wasVisibleRef.current) {
|
||||
|
||||
@@ -97,9 +97,6 @@ export function useWorktreeJumpPaletteStoreState({
|
||||
(state) => state.hideWorkspacesFromOtherDevices
|
||||
)
|
||||
const showSleepingWorkspaces = useAppStore((state) => state.showSleepingWorkspaces)
|
||||
const workspaceHostScope = useAppStore((state) => state.workspaceHostScope)
|
||||
const visibleWorkspaceHostIds = useAppStore((state) => state.visibleWorkspaceHostIds)
|
||||
const filterRepoIds = useAppStore((state) => state.filterRepoIds)
|
||||
const alwaysShowDefaultBranchWorkspace = useAppStore(
|
||||
(state) => state.alwaysShowDefaultBranchWorkspace
|
||||
)
|
||||
@@ -177,9 +174,6 @@ export function useWorktreeJumpPaletteStoreState({
|
||||
hideDetachedHeadWorkspaces,
|
||||
hideWorkspacesFromOtherDevices,
|
||||
showSleepingWorkspaces,
|
||||
workspaceHostScope,
|
||||
visibleWorkspaceHostIds,
|
||||
filterRepoIds,
|
||||
alwaysShowDefaultBranchWorkspace,
|
||||
lastVisitedAtByWorktreeId,
|
||||
workspacePortScan,
|
||||
|
||||
Reference in New Issue
Block a user