Files
orca/src/shared/worktree-visibility-resolution.ts
T
Brennan Benson 83e2123582 Add global worktree visibility source defaults (#14276)
* Add global external worktree visibility defaults

* Expand global worktree visibility source defaults

* Fix host-scoped visibility settings races

* Fix global worktree visibility integration

* Enable source visibility defaults on mobile

* Polish external worktree settings navigation

* Clarify inherited worktree visibility settings

* feat(sidebar): replace the inherited-visibility switch with a Show/Hide picker

Each source row now shows a two-segment Show / Hide control preselected to the
global setting, and explains itself only where the project actually disagrees:
an "Overriding global setting: <value>" card names the value being ignored.
Picking the segment global already holds drops the override instead of pinning
a duplicate, so the same control both overrides and reverts, retiring the
separate "Use global" link. The dialog footer now lists every inheritable
source with its global value.

* fix(sidebar): preserve reset for matching visibility overrides
2026-08-14 12:15:58 -07:00

57 lines
1.7 KiB
TypeScript

import { isExplicitlyImportedExternalWorktreePath } from './external-worktree-inbox'
import {
effectiveAgentWorktreeVisibility,
effectiveExternalWorktreeVisibility
} from './external-worktree-visibility'
import {
effectiveWorktreeSourceVisibility,
type WorktreeVisibilitySourceMatcher
} from './worktree/visibility-sources'
import type { GlobalSettings } from './global-settings-types'
import type { Repo } from './repo-types'
import type { Worktree, WorktreeOwnership } from './worktree/types'
export function shouldShowWorktree(args: {
worktree: Pick<Worktree, 'path'>
ownership: WorktreeOwnership
repo: Repo
isLegacyRepoForVisibility: boolean
isSelectedCheckout: boolean
visibilityDefaults?: GlobalSettings['worktreeVisibilityDefaults']
importedExternalWorktreePaths?: readonly string[] | undefined
visibilitySource?: ReturnType<WorktreeVisibilitySourceMatcher>
}): boolean {
if (args.isSelectedCheckout || args.ownership === 'orca-managed') {
return true
}
if (
isExplicitlyImportedExternalWorktreePath(args.worktree.path, {
importedExternalWorktreePaths: args.importedExternalWorktreePaths
})
) {
return true
}
if (args.visibilitySource) {
return (
effectiveWorktreeSourceVisibility(
args.repo,
args.visibilitySource,
args.visibilityDefaults
) === 'show'
)
}
if (args.ownership === 'agent-scratch') {
return effectiveAgentWorktreeVisibility(args.repo) === 'show'
}
if (args.ownership === 'unknown-legacy' && args.isLegacyRepoForVisibility) {
return true
}
return (
effectiveExternalWorktreeVisibility(
args.repo,
args.isLegacyRepoForVisibility,
args.visibilityDefaults
) === 'show'
)
}