mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 09:07:40 +00:00
* 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
97 lines
3.5 KiB
TypeScript
97 lines
3.5 KiB
TypeScript
import type {
|
|
ExternalWorktreeVisibility,
|
|
Repo,
|
|
WorktreeVisibilitySourcePreferences
|
|
} from '../repo-types'
|
|
import type { WorktreeVisibilityDefaults } from '../global-settings-types'
|
|
import {
|
|
normalizeWorktreeVisibilitySourcePreferences,
|
|
type WorktreeVisibilitySourceMatch
|
|
} from './visibility-sources'
|
|
|
|
function legacyBuiltInPreferences(
|
|
repo: Pick<Repo, 'agentWorktreeVisibility'>
|
|
): WorktreeVisibilitySourcePreferences['builtIn'] {
|
|
return repo.agentWorktreeVisibility
|
|
? { claude: repo.agentWorktreeVisibility, gsd: repo.agentWorktreeVisibility }
|
|
: {}
|
|
}
|
|
|
|
function preferenceResult(
|
|
builtIn: NonNullable<WorktreeVisibilitySourcePreferences['builtIn']>,
|
|
custom: NonNullable<WorktreeVisibilitySourcePreferences['custom']>
|
|
): WorktreeVisibilitySourcePreferences {
|
|
return {
|
|
...(Object.keys(builtIn).length > 0 ? { builtIn } : {}),
|
|
...(Object.keys(custom).length > 0 ? { custom } : {})
|
|
}
|
|
}
|
|
|
|
export function buildWorktreeSourcePreferenceUpdate(
|
|
repo: Pick<Repo, 'agentWorktreeVisibility' | 'worktreeVisibilitySourcePreferences'>,
|
|
source: WorktreeVisibilitySourceMatch,
|
|
visibility: ExternalWorktreeVisibility
|
|
): WorktreeVisibilitySourcePreferences {
|
|
const current = normalizeWorktreeVisibilitySourcePreferences(
|
|
repo.worktreeVisibilitySourcePreferences
|
|
)
|
|
const builtIn = { ...legacyBuiltInPreferences(repo), ...current?.builtIn }
|
|
const custom = { ...current?.custom }
|
|
if (source.kind === 'built-in') {
|
|
builtIn[source.id] = visibility
|
|
} else {
|
|
custom[source.id] = visibility
|
|
}
|
|
return preferenceResult(builtIn, custom)
|
|
}
|
|
|
|
export function removeCustomWorktreeSourcePreference(
|
|
repo: Pick<Repo, 'agentWorktreeVisibility' | 'worktreeVisibilitySourcePreferences'>,
|
|
sourceId: string
|
|
): WorktreeVisibilitySourcePreferences {
|
|
const current = normalizeWorktreeVisibilitySourcePreferences(
|
|
repo.worktreeVisibilitySourcePreferences
|
|
)
|
|
const custom = { ...current?.custom }
|
|
delete custom[sourceId]
|
|
return preferenceResult({ ...legacyBuiltInPreferences(repo), ...current?.builtIn }, custom)
|
|
}
|
|
|
|
export function removeBuiltInWorktreeSourcePreference(
|
|
repo: Pick<Repo, 'agentWorktreeVisibility' | 'worktreeVisibilitySourcePreferences'>,
|
|
sourceId: keyof NonNullable<WorktreeVisibilitySourcePreferences['builtIn']>
|
|
): WorktreeVisibilitySourcePreferences {
|
|
const current = normalizeWorktreeVisibilitySourcePreferences(
|
|
repo.worktreeVisibilitySourcePreferences
|
|
)
|
|
const builtIn = { ...legacyBuiltInPreferences(repo), ...current?.builtIn }
|
|
delete builtIn[sourceId]
|
|
return preferenceResult(builtIn, { ...current?.custom })
|
|
}
|
|
|
|
export function buildDefaultWorktreeSourcePreferenceUpdate(
|
|
defaults: WorktreeVisibilityDefaults,
|
|
source: WorktreeVisibilitySourceMatch,
|
|
visibility: ExternalWorktreeVisibility
|
|
): WorktreeVisibilitySourcePreferences {
|
|
const current = normalizeWorktreeVisibilitySourcePreferences(defaults.sourcePreferences)
|
|
const builtIn = { ...current?.builtIn }
|
|
const custom = { ...current?.custom }
|
|
if (source.kind === 'built-in') {
|
|
builtIn[source.id] = visibility
|
|
} else {
|
|
custom[source.id] = visibility
|
|
}
|
|
return preferenceResult(builtIn, custom)
|
|
}
|
|
|
|
export function removeDefaultCustomWorktreeSourcePreference(
|
|
defaults: WorktreeVisibilityDefaults,
|
|
sourceId: string
|
|
): WorktreeVisibilitySourcePreferences {
|
|
const current = normalizeWorktreeVisibilitySourcePreferences(defaults.sourcePreferences)
|
|
const custom = { ...current?.custom }
|
|
delete custom[sourceId]
|
|
return preferenceResult({ ...current?.builtIn }, custom)
|
|
}
|