chore: remove 31 unused files (~3.6k lines of dead code) (#7494)

Removes 31 fully-orphaned source files with zero references anywhere in
the codebase, surfaced by knip static analysis and independently verified
(import-specifier grep across .ts/.tsx/.mjs/.cjs/.html/build configs,
transitive-cluster + basename-collision analysis).

Notable clusters:
- GitHub issue-comment composer + its close-reason dropdown/labels/popovers
  (GitHubIssueCommentComposer and everything only it imported)
- Create-PR dialog components superseded by inline SourceControl logic
- right-sidebar Search/SearchHeader (unused search UI)
- two stale source-control-primary-* renderer duplicates (live logic moved
  to src/shared/)
- CliAgentSkillSetup superseded by CliSection; its entry removed from the
  AgentSkillSetupPanel governance test

Verified: typecheck (node/cli/web), oxlint, localization catalog+coverage,
full unit suite (24,581 tests), and electron-vite + web bundler builds all
pass with these files removed.
This commit is contained in:
Neil
2026-07-05 21:55:03 -07:00
committed by GitHub
parent c49a14f557
commit 8478babe62
32 changed files with 0 additions and 3628 deletions
-121
View File
@@ -1,121 +0,0 @@
import { execFile } from 'node:child_process'
import type { ComputerAppInfo } from '../../shared/runtime-types'
type MacOSRunningApp = ComputerAppInfo & {
activationPolicy: number
isFrontmost: boolean
}
const JXA_LIST_RUNNING_APPS = `
ObjC.import('AppKit');
const apps = $.NSWorkspace.sharedWorkspace.runningApplications;
const out = [];
for (let i = 0; i < apps.count; i += 1) {
const app = apps.objectAtIndex(i);
if (app.isTerminated) continue;
const name = ObjC.unwrap(app.localizedName) || '';
const bundleId = ObjC.unwrap(app.bundleIdentifier) || null;
const pid = Number(app.processIdentifier);
const activationPolicy = Number(app.activationPolicy);
if (!name || !Number.isInteger(pid) || pid <= 0) continue;
out.push({
name,
bundleId,
pid,
activationPolicy,
isFrontmost: Boolean(app.active)
});
}
JSON.stringify(out);
`
export async function listMacOSApps(): Promise<ComputerAppInfo[]> {
const { stdout } = await execFilePromise(
'osascript',
['-l', 'JavaScript', '-e', JXA_LIST_RUNNING_APPS],
{
encoding: 'utf8',
timeout: 5000,
maxBuffer: 1024 * 1024
}
)
const apps = parseMacOSApps(stdout).filter(hasLivePid)
return dedupeApps(apps.filter(isUserFacingApp)).map(({ name, bundleId, pid }) => ({
name,
bundleId,
pid
}))
}
function parseMacOSApps(stdout: string): MacOSRunningApp[] {
const parsed: unknown = JSON.parse(stdout)
if (!Array.isArray(parsed)) {
return []
}
return parsed.flatMap((value): MacOSRunningApp[] => {
if (!value || typeof value !== 'object') {
return []
}
const record = value as Record<string, unknown>
const name = typeof record.name === 'string' ? record.name : ''
const bundleId = typeof record.bundleId === 'string' ? record.bundleId : null
const pid = typeof record.pid === 'number' && Number.isInteger(record.pid) ? record.pid : 0
const activationPolicy =
typeof record.activationPolicy === 'number' && Number.isInteger(record.activationPolicy)
? record.activationPolicy
: -1
const isFrontmost = record.isFrontmost === true
return name && pid > 0 ? [{ name, bundleId, pid, activationPolicy, isFrontmost }] : []
})
}
function isUserFacingApp(app: MacOSRunningApp): boolean {
return app.activationPolicy === 0
}
function hasLivePid(app: MacOSRunningApp): boolean {
try {
process.kill(app.pid, 0)
return true
} catch {
// NSWorkspace can briefly retain terminated apps; filter them before provider calls.
return false
}
}
function dedupeApps(apps: MacOSRunningApp[]): MacOSRunningApp[] {
const seen = new Set<string>()
const sorted = [...apps].sort((a, b) => {
if (a.isFrontmost !== b.isFrontmost) {
return a.isFrontmost ? -1 : 1
}
return a.name.localeCompare(b.name)
})
const result: MacOSRunningApp[] = []
for (const app of sorted) {
const key = app.bundleId ? `bundle:${app.bundleId.toLowerCase()}` : `pid:${app.pid}`
if (seen.has(key)) {
continue
}
seen.add(key)
result.push(app)
}
return result
}
function execFilePromise(
file: string,
args: string[],
options: { encoding: 'utf8'; timeout: number; maxBuffer: number }
): Promise<{ stdout: string }> {
return new Promise((resolve, reject) => {
execFile(file, args, options, (error, stdout, stderr) => {
if (error) {
const detail = typeof stderr === 'string' && stderr.trim() ? `: ${stderr.trim()}` : ''
reject(new Error(`${error.message}${detail}`))
return
}
resolve({ stdout })
})
})
}
-79
View File
@@ -1,79 +0,0 @@
import { glabExecFileAsync } from '../git/runner'
import { DEFAULT_GITLAB_HOSTS, normalizeGitLabHost, type ProjectRef } from './project-ref-parser'
let knownHostsCache: readonly string[] | null = null
export function rememberGlabKnownHost(host: string): void {
const normalizedHost = normalizeGitLabHost(host)
if (!knownHostsCache || knownHostsCache.map(normalizeGitLabHost).includes(normalizedHost)) {
return
}
knownHostsCache = [...knownHostsCache, normalizedHost]
}
export async function isGlabConfiguredForRemoteHost(
repoPath: string,
projectRef: Pick<ProjectRef, 'host'>,
connectionId?: string | null
): Promise<boolean> {
try {
const result = await glabExecFileAsync(
['auth', 'status', '--hostname', projectRef.host],
connectionId ? {} : { cwd: repoPath }
)
return result !== undefined
} catch (error) {
const execLike = error as { stdout?: unknown; stderr?: unknown; message?: unknown }
const output =
[execLike.stdout, execLike.stderr, execLike.message]
.filter((value): value is string => typeof value === 'string' && value.trim().length > 0)
.join('\n') || String(error)
const hosts = parseGlabAuthStatusHosts(output).map(normalizeGitLabHost)
return hosts.includes(normalizeGitLabHost(projectRef.host))
}
}
/** @internal - exposed for tests only */
export function _resetKnownHostsCache(): void {
knownHostsCache = null
}
export async function getGlabKnownHosts(): Promise<readonly string[]> {
if (knownHostsCache) {
return knownHostsCache
}
try {
const { stdout, stderr } = await glabExecFileAsync(['auth', 'status'])
// Why: glab writes auth status to stderr in some versions, stdout in
// others. Concatenate so the parser sees both.
const hosts = parseGlabAuthStatusHosts(`${stdout}\n${stderr}`)
// Always include gitlab.com so a fresh-install user with no auth
// still recognizes the canonical host.
const merged = Array.from(new Set([...DEFAULT_GITLAB_HOSTS, ...hosts]))
knownHostsCache = merged
return merged
} catch {
// Auth check failed (glab not installed, no auth, etc.) - fall back
// to the canonical default. The caller will hit the auth error on
// the first real request anyway.
knownHostsCache = [...DEFAULT_GITLAB_HOSTS]
return knownHostsCache
}
}
// Why: glab auth status output is human-formatted and varies across versions.
// Match observed logged-in lines and host headers, dedupe, lowercase.
export function parseGlabAuthStatusHosts(output: string): string[] {
const hosts = new Set<string>()
for (const m of output.matchAll(/logged in to ([a-zA-Z0-9.-]+)/gi)) {
hosts.add(m[1].toLowerCase())
}
for (const line of output.split('\n')) {
const bareLine = line.trim()
const hostLine = bareLine.endsWith(':') ? bareLine.slice(0, -1) : bareLine
if (line === bareLine && /^[a-zA-Z0-9](?:[a-zA-Z0-9.-]*[a-zA-Z0-9])?$/.test(hostLine)) {
hosts.add(hostLine.toLowerCase())
}
}
return Array.from(hosts)
}
@@ -1,377 +0,0 @@
import { useEffect, useLayoutEffect, useRef, useState, type JSX, type ReactNode } from 'react'
import { GitBranch } from 'lucide-react'
import { cn } from '@/lib/utils'
import { ClaudeIcon } from '../status-bar/icons'
import { FeatureWallClickRing } from './FeatureWallClickRing'
import { CursorIcon } from './feature-tour-preview-glyphs'
import { translate } from '@/i18n/i18n'
type ComputerUsePhase = 'inspect' | 'target' | 'click' | 'verified'
const PHASES: readonly ComputerUsePhase[] = ['inspect', 'target', 'click', 'verified', 'verified']
const PHASE_MS = 1350
// Why: the visual must read as "an agent in an Orca worktree drives the
// local app via the `orca computer` CLI" — each command on the left causes
// the visible effect on the right, in lockstep.
const WORKTREE_LABEL = 'checkout fix'
export function ComputerUseAnimatedVisual(props: {
reducedMotion: boolean
onCycleComplete?: () => void
}): JSX.Element {
const phase = useComputerUsePhase(props.reducedMotion, props.onCycleComplete)
const containerRef = useRef<HTMLDivElement>(null)
const buttonRef = useRef<HTMLDivElement>(null)
const [cursorCoords, setCursorCoords] = useState({ x: 0, y: 0, visible: false })
const targetVisible = phase === 'target' || phase === 'click' || phase === 'verified'
const clicked = phase === 'click' || phase === 'verified'
const verified = phase === 'verified'
// Why: cursor coordinates are computed against the app body so they survive
// any reflow when the carousel sizes the slide.
useLayoutEffect(() => {
if (props.reducedMotion) {
setCursorCoords({ x: 0, y: 0, visible: false })
return
}
function updateCoords(): void {
const container = containerRef.current
const button = buttonRef.current
if (!container || !button) {
return
}
const containerRect = container.getBoundingClientRect()
const buttonRect = button.getBoundingClientRect()
const buttonX = buttonRect.left - containerRect.left + buttonRect.width * 0.78
const buttonY = buttonRect.top - containerRect.top + buttonRect.height / 2
const startX = containerRect.width * 0.35
const startY = containerRect.height * 0.35
if (phase === 'inspect' || phase === 'verified') {
setCursorCoords({ x: startX, y: startY, visible: false })
} else {
setCursorCoords({ x: buttonX, y: buttonY, visible: true })
}
}
updateCoords()
window.addEventListener('resize', updateCoords)
return () => window.removeEventListener('resize', updateCoords)
}, [phase, props.reducedMotion])
return (
<div className="relative grid min-h-[282px] gap-3 rounded-xl border border-border bg-card p-3 text-foreground shadow-xs md:h-[282px] md:grid-cols-[230px_minmax(0,1fr)]">
<AgentWorktreeTerminal
phase={phase}
targetVisible={targetVisible}
clicked={clicked}
verified={verified}
/>
<div className="relative min-w-0 overflow-hidden rounded-lg border border-border bg-background">
<div className="flex h-7 items-center gap-1.5 border-b border-border bg-muted/40 px-2.5">
<span className="size-2 rounded-full bg-rose-400/70" />
<span className="size-2 rounded-full bg-amber-400/70" />
<span className="size-2 rounded-full bg-emerald-400/70" />
<span className="ml-1 truncate text-[11px] font-medium text-muted-foreground">
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.9cddfe96b2',
'Local app'
)}
</span>
</div>
<div className="grid h-[253px] grid-rows-[58px_minmax(0,1fr)] bg-muted/10">
<div className="border-b border-border bg-card px-4 py-2.5">
<div className="flex items-center justify-between gap-3">
<div className="min-w-0 flex-1 overflow-hidden">
<div className="h-2.5 w-24 max-w-full rounded-full bg-foreground/20" />
<div className="mt-2 h-2 w-36 max-w-full rounded-full bg-muted-foreground/25" />
</div>
<span
className={cn(
'shrink-0 rounded-full border px-2 py-1 text-[11px] font-medium transition-colors',
verified
? 'border-primary/30 bg-primary/10 text-primary'
: 'border-border bg-muted/40 text-muted-foreground'
)}
>
{verified
? translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.c11dda000b',
'Approved'
)
: translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.bdd5312213',
'Pending'
)}
</span>
</div>
</div>
<div ref={containerRef} className="relative p-3">
<div className="space-y-2">
<AppRow width="78%" />
<div
className={cn(
'flex items-center gap-2 rounded-lg border bg-card px-3 py-2.5 transition-[background-color,border-color,box-shadow]',
targetVisible
? 'border-ring bg-accent/50 ring-2 ring-ring/30 shadow-xs'
: 'border-border'
)}
>
<div className="min-w-0 flex-1 overflow-hidden pr-1">
<div className="h-2.5 w-1/2 max-w-16 rounded-full bg-foreground/20" />
<div className="mt-2 h-2 w-3/5 max-w-20 rounded-full bg-muted-foreground/25" />
</div>
<div
ref={buttonRef}
aria-hidden
className={cn(
'flex h-8 w-[72px] shrink-0 items-center justify-center rounded-md border px-2 text-xs font-medium transition-[background-color,color,transform]',
clicked
? 'border-primary/30 bg-primary/10 text-primary'
: 'border-border bg-secondary text-secondary-foreground',
phase === 'click' ? 'scale-[0.97]' : null
)}
>
{clicked
? translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.3cc2df3671',
'Done'
)
: translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.9634d870d1',
'Approve'
)}
</div>
</div>
</div>
<ComputerUseCursor
visible={cursorCoords.visible}
x={cursorCoords.x}
y={cursorCoords.y}
isClick={phase === 'click'}
/>
</div>
</div>
</div>
</div>
)
}
function AgentWorktreeTerminal(props: {
phase: ComputerUsePhase
targetVisible: boolean
clicked: boolean
verified: boolean
}): JSX.Element {
return (
<div className="min-w-0 overflow-hidden rounded-lg border border-border bg-background">
<div className="flex h-7 items-center gap-1.5 border-b border-border bg-muted/40 px-2.5">
<ClaudeIcon size={13} />
<span className="truncate text-[11px] font-medium text-muted-foreground">
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.94787f01f8',
'Claude Code'
)}
</span>
<span className="ml-auto inline-flex min-w-0 items-center gap-1 text-[10px] text-muted-foreground">
<GitBranch className="size-3" />
<span className="truncate">{WORKTREE_LABEL}</span>
</span>
</div>
<div className="space-y-1.5 p-3 font-mono text-[10.5px] leading-snug">
<TerminalLine muted>
<span className="mr-1.5 text-foreground">●</span>
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.2adb561b44',
'Claude Code session started'
)}
</TerminalLine>
<TerminalLine wrap>
<span className="mr-1.5 text-amber-600">
{translate('auto.components.feature.wall.ComputerUseAnimatedVisual.99a8624bcb', '>')}
</span>
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.79445f7512',
'approve the note in my app'
)}
</TerminalLine>
<ComputerActionLine
action="Computer"
target="inspect Notes"
active={props.phase === 'inspect'}
done={props.targetVisible}
/>
<TerminalLine visible={props.targetVisible} indent muted>
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.1719b28a81',
'found "Approve"'
)}
<span>[#7]</span>
</TerminalLine>
<ComputerActionLine
action="Computer"
target="click Approve"
active={props.phase === 'target' || props.phase === 'click'}
done={props.clicked}
/>
<TerminalLine visible={props.clicked} indent muted>
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.6804cb356f',
'click sent'
)}
</TerminalLine>
<ComputerActionLine
action="Computer"
target="verify Notes"
active={props.phase === 'click'}
done={props.verified}
/>
<TerminalLine visible={props.verified} indent muted>
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.f27676a92c',
'status:'
)}
<span className="text-foreground">
{translate(
'auto.components.feature.wall.ComputerUseAnimatedVisual.d8401975b1',
'approved'
)}
</span>
</TerminalLine>
</div>
</div>
)
}
function ComputerActionLine(props: {
action: string
target: string
active: boolean
done: boolean
}): JSX.Element {
return (
<TerminalLine visible={props.active || props.done}>
{props.done ? <span className="mr-1.5 font-bold text-emerald-600">✓</span> : <RunSpinner />}
<span className="text-foreground">{props.action}</span>
<span className="ml-1.5 truncate text-muted-foreground">{props.target}</span>
</TerminalLine>
)
}
function TerminalLine(props: {
children: ReactNode
muted?: boolean
wrap?: boolean
indent?: boolean
visible?: boolean
}): JSX.Element {
const visible = props.visible ?? true
return (
<div
className={cn(
'min-h-[15px] transition-opacity duration-200',
props.muted ? 'text-muted-foreground' : null,
props.indent ? 'pl-4' : null,
props.wrap ? 'whitespace-pre-wrap break-words' : 'truncate whitespace-pre',
visible ? 'opacity-100' : 'opacity-0'
)}
>
{props.children}
</div>
)
}
function RunSpinner(): JSX.Element {
return (
<span
className="mr-1.5 inline-block size-2 animate-spin rounded-full border-[1.5px] border-foreground/20 border-t-foreground align-[-1px]"
aria-hidden
/>
)
}
function useComputerUsePhase(
reducedMotion: boolean,
onCycleComplete?: () => void
): ComputerUsePhase {
const [idx, setIdx] = useState(() => (reducedMotion ? PHASES.indexOf('verified') : 0))
useEffect(() => {
if (reducedMotion) {
setIdx(PHASES.indexOf('verified'))
return
}
let cancelled = false
const timeouts: number[] = []
const wait = (ms: number): Promise<void> =>
new Promise((resolve) => {
const id = window.setTimeout(() => resolve(), ms)
timeouts.push(id)
})
setIdx(0)
async function loop(): Promise<void> {
while (!cancelled) {
for (let nextIdx = 0; nextIdx < PHASES.length; nextIdx += 1) {
setIdx(nextIdx)
await wait(PHASE_MS)
if (cancelled) {
return
}
}
onCycleComplete?.()
}
}
loop()
return () => {
cancelled = true
timeouts.forEach((id) => window.clearTimeout(id))
}
}, [onCycleComplete, reducedMotion])
return PHASES[idx] ?? 'verified'
}
function AppRow(props: { width: string }): JSX.Element {
return (
<div className="rounded-lg border border-border bg-card px-3 py-2">
<div className="h-2.5 rounded-full bg-foreground/15" style={{ width: props.width }} />
<div className="mt-2 h-2 w-1/2 rounded-full bg-muted-foreground/20" />
</div>
)
}
function ComputerUseCursor(props: {
visible: boolean
x: number
y: number
isClick: boolean
}): JSX.Element {
return (
<div
aria-hidden
className={cn(
'pointer-events-none absolute left-0 top-0 z-20 size-4 transition-[opacity,transform] duration-700 ease-[cubic-bezier(.45,.05,.2,1)]',
props.visible ? 'opacity-100' : 'opacity-0'
)}
style={{
transform: `translate(${props.x - 4}px, ${props.y - 4}px)`
}}
>
<CursorIcon />
{props.isClick ? <FeatureWallClickRing /> : null}
</div>
)
}
@@ -1,61 +0,0 @@
import { Check, ChevronDown } from 'lucide-react'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { Button } from '@/components/ui/button'
import { CLOSE_ISSUE_REASONS } from './github-issue-close-reasons'
import type { GitHubIssueCloseReason } from '../../../../shared/types'
import { translate } from '@/i18n/i18n'
export function CloseReasonDropdown({
closeReason,
disabled,
onCloseReasonChange
}: {
closeReason: GitHubIssueCloseReason
disabled: boolean
onCloseReasonChange: (reason: GitHubIssueCloseReason) => void
}): React.JSX.Element {
return (
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild>
<Button
type="button"
size="sm"
variant="secondary"
className="px-2"
disabled={disabled}
aria-label={translate(
'auto.components.github.CloseReasonDropdown.e1f2a3b4c5',
'Choose close reason'
)}
>
<ChevronDown className="size-3.5 opacity-70" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-72">
{CLOSE_ISSUE_REASONS.map((option) => (
<DropdownMenuItem key={option.reason} onSelect={() => onCloseReasonChange(option.reason)}>
<div className="flex min-w-0 items-start gap-2">
{closeReason === option.reason ? (
<Check className="mt-0.5 size-4 shrink-0" />
) : (
<span className="size-4 shrink-0" />
)}
<div className="min-w-0">
<div className="flex items-center gap-2 text-[13px] font-medium">
{option.icon}
<span>{option.label}</span>
</div>
<p className="mt-0.5 text-[11px] text-muted-foreground">{option.description}</p>
</div>
</div>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
)
}
@@ -1,398 +0,0 @@
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { LoaderCircle } from 'lucide-react'
import { toast } from 'sonner'
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
import { GitHubMarkdownComposer } from '@/components/github/GitHubMarkdownComposer'
import { CLOSE_ISSUE_REASONS } from '@/components/github/github-issue-close-reasons'
import { CloseReasonDropdown } from '@/components/github/CloseReasonDropdown'
import {
addIssueCommentForRepo,
githubAvatarUrl,
runIssueStateUpdate,
type GitHubIssueCommentProjectOrigin
} from '@/components/github/github-issue-comment-helpers'
import {
getCommentBodySubmitState,
hasBoundedCommentBodyText
} from '@/lib/comment-body-submit-state'
import { useMountedRef } from '@/hooks/useMountedRef'
import { cn } from '@/lib/utils'
import { useAppStore } from '@/store'
import type {
GitHubIssueCloseReason,
GitHubOwnerRepo,
GitHubViewer,
GitHubWorkItem,
GlobalSettings,
PRComment
} from '../../../../shared/types'
import type { TaskSourceContext } from '../../../../shared/task-source-context'
import { translate } from '@/i18n/i18n'
export function GitHubIssueCommentComposer({
className,
repoPath,
repoId,
issueNumber,
itemType,
itemState,
itemId,
sourceContext,
sourceSettings,
projectOrigin,
previewGithubRepo,
onCommentAdded,
onStateChange,
onMutated
}: {
className?: string
repoPath: string
repoId?: string | null
issueNumber: number
itemType: 'issue' | 'pr'
itemState?: GitHubWorkItem['state']
itemId?: string
sourceContext?: TaskSourceContext | null
sourceSettings?: Pick<GlobalSettings, 'activeRuntimeEnvironmentId'> | null | undefined
projectOrigin?: GitHubIssueCommentProjectOrigin
previewGithubRepo?: GitHubOwnerRepo | null
onCommentAdded: (comment: PRComment) => void
onStateChange?: (state: GitHubWorkItem['state']) => void
onMutated?: () => void
}): React.JSX.Element {
const [body, setBody] = useState('')
const [submitting, setSubmitting] = useState(false)
const [statePending, setStatePending] = useState(false)
const [closeReason, setCloseReason] = useState<GitHubIssueCloseReason>('completed')
const [viewer, setViewer] = useState<GitHubViewer | null>(null)
const mountedRef = useMountedRef()
const viewerRequestIdRef = useRef(0)
const patchWorkItem = useAppStore((s) => s.patchWorkItem)
const patchProjectRowContent = useAppStore((s) => s.patchProjectRowContent)
useEffect(() => {
const requestId = ++viewerRequestIdRef.current
void window.api.gh
.viewer()
.then((nextViewer) => {
if (mountedRef.current && requestId === viewerRequestIdRef.current) {
setViewer(nextViewer)
}
})
.catch(() => {
if (mountedRef.current && requestId === viewerRequestIdRef.current) {
setViewer(null)
}
})
return () => {
viewerRequestIdRef.current += 1
}
}, [mountedRef])
const selectedCloseReason =
CLOSE_ISSUE_REASONS.find((option) => option.reason === closeReason) ?? CLOSE_ISSUE_REASONS[0]
const canMutateIssueState =
itemType === 'issue' &&
itemState !== undefined &&
itemState !== 'closed' &&
Boolean(onStateChange) &&
Boolean(repoPath || projectOrigin)
const canReopenIssue =
itemType === 'issue' &&
itemState === 'closed' &&
Boolean(onStateChange) &&
Boolean(repoPath || projectOrigin)
const patchProjectRowIfNeeded = useCallback(
(state: GitHubWorkItem['state']) => {
if (!projectOrigin) {
return
}
patchProjectRowContent(projectOrigin.cacheKey, projectOrigin.projectItemId, { state })
},
[patchProjectRowContent, projectOrigin]
)
const applyStatePatch = useCallback(
(state: GitHubWorkItem['state']) => {
onStateChange?.(state)
if (itemId) {
patchWorkItem(itemId, { state }, repoId ?? undefined)
}
patchProjectRowIfNeeded(state)
},
[itemId, onStateChange, patchProjectRowIfNeeded, patchWorkItem, repoId]
)
const handleSubmit = useCallback(async () => {
const bodyState = getCommentBodySubmitState(body)
if (bodyState.status === 'empty') {
return
}
if (bodyState.status === 'too-large-leading-whitespace') {
toast.error(
translate(
'auto.components.github.GitHubIssueCommentComposer.commentTooLarge',
'Comment is too large to submit safely.'
)
)
return
}
setSubmitting(true)
try {
const result = await addIssueCommentForRepo({
repoPath,
repoId: repoId ?? undefined,
sourceContext,
number: issueNumber,
body: bodyState.body,
type: itemType
})
if (!mountedRef.current) {
return
}
if (result.ok) {
setBody('')
onCommentAdded(result.comment)
} else {
toast.error(
result.error ??
translate(
'auto.components.github.GitHubIssueCommentComposer.082515176a',
'Failed to add comment'
)
)
}
} catch (err) {
if (mountedRef.current) {
toast.error(
err instanceof Error
? err.message
: translate(
'auto.components.github.GitHubIssueCommentComposer.082515176a',
'Failed to add comment'
)
)
}
} finally {
if (mountedRef.current) {
setSubmitting(false)
}
}
}, [body, issueNumber, itemType, mountedRef, onCommentAdded, repoId, repoPath, sourceContext])
const handleCloseIssue = useCallback(
async (reason: GitHubIssueCloseReason = closeReason) => {
if (!canMutateIssueState || statePending) {
return
}
const previousState = itemState ?? 'open'
setStatePending(true)
applyStatePatch('closed')
try {
await runIssueStateUpdate({
repoPath,
repoId,
sourceContext,
sourceSettings,
projectOrigin,
number: issueNumber,
updates: { state: 'closed', stateReason: reason }
})
useAppStore.getState().recordFeatureInteraction('github-tasks')
toast.success(
translate('auto.components.github.GitHubIssueCommentComposer.9f88657c4e', 'Issue closed')
)
onMutated?.()
} catch (err) {
applyStatePatch(previousState)
toast.error(
err instanceof Error
? err.message
: translate(
'auto.components.github.GitHubIssueCommentComposer.e9b7cb7d17',
'Failed to close issue'
)
)
} finally {
if (mountedRef.current) {
setStatePending(false)
}
}
},
[
applyStatePatch,
canMutateIssueState,
closeReason,
issueNumber,
itemState,
mountedRef,
onMutated,
projectOrigin,
repoId,
repoPath,
sourceContext,
sourceSettings,
statePending
]
)
const handleReopenIssue = useCallback(async () => {
if (!canReopenIssue || statePending) {
return
}
const previousState = itemState ?? 'closed'
setStatePending(true)
applyStatePatch('open')
try {
await runIssueStateUpdate({
repoPath,
repoId,
sourceContext,
sourceSettings,
projectOrigin,
number: issueNumber,
updates: { state: 'open' }
})
useAppStore.getState().recordFeatureInteraction('github-tasks')
toast.success(
translate('auto.components.github.GitHubIssueCommentComposer.bd3b4492a0', 'Issue reopened')
)
onMutated?.()
} catch (err) {
applyStatePatch(previousState)
toast.error(
err instanceof Error
? err.message
: translate(
'auto.components.github.GitHubIssueCommentComposer.f2a8c1d903',
'Failed to reopen issue'
)
)
} finally {
if (mountedRef.current) {
setStatePending(false)
}
}
}, [
applyStatePatch,
canReopenIssue,
issueNumber,
itemState,
mountedRef,
onMutated,
projectOrigin,
repoId,
repoPath,
sourceContext,
sourceSettings,
statePending
])
const avatar = viewer?.login ? (
<img
src={githubAvatarUrl(viewer.login)}
alt={viewer.login}
className="size-8 shrink-0 rounded-full border border-border/50 bg-muted"
/>
) : (
<div className="size-8 shrink-0 rounded-full border border-border/50 bg-muted" />
)
const canSubmitComment = hasBoundedCommentBodyText(body)
return (
<div className={cn('github-issue-comment-composer', className)}>
<div className="flex items-start gap-3">
{avatar}
<div className="min-w-0 flex-1">
<h3 className="mb-2 text-[13px] font-semibold text-foreground">
{translate(
'auto.components.github.GitHubIssueCommentComposer.a1b2c3d4e5',
'Add a comment'
)}
</h3>
<GitHubMarkdownComposer
value={body}
onChange={setBody}
placeholder={translate(
'auto.components.github.GitHubIssueCommentComposer.c5c117270e',
'Add your comment here, be kind'
)}
disabled={submitting || statePending}
minHeightClassName="min-h-28"
className="w-full"
layout="tabbed"
previewGithubRepo={previewGithubRepo}
onSubmitShortcut={() => void handleSubmit()}
/>
<div className="mt-2 flex flex-wrap items-center justify-end gap-2">
{canMutateIssueState ? (
<ButtonGroup>
<Button
type="button"
size="sm"
variant="secondary"
className="gap-2"
disabled={statePending}
onClick={() => void handleCloseIssue(closeReason)}
>
{statePending ? (
<LoaderCircle className="size-3.5 animate-spin" />
) : (
selectedCloseReason.icon
)}
{translate(
'auto.components.github.GitHubIssueCommentComposer.f6a7b8c9d0',
'Close issue'
)}
</Button>
<CloseReasonDropdown
closeReason={closeReason}
disabled={statePending}
onCloseReasonChange={(reason) => {
setCloseReason(reason)
void handleCloseIssue(reason)
}}
/>
</ButtonGroup>
) : null}
{canReopenIssue ? (
<Button
type="button"
size="sm"
variant="secondary"
disabled={statePending}
onClick={() => void handleReopenIssue()}
>
{statePending ? (
<LoaderCircle className="size-3.5 animate-spin" />
) : (
translate(
'auto.components.github.GitHubIssueCommentComposer.b1c2d3e4f5',
'Reopen issue'
)
)}
</Button>
) : null}
<Button
onClick={() => void handleSubmit()}
disabled={!canSubmitComment || submitting || statePending}
size="sm"
className="gap-2 bg-emerald-600 text-white hover:bg-emerald-700 disabled:bg-emerald-600/50"
aria-label={translate(
'auto.components.github.GitHubIssueCommentComposer.0a73f59e85',
'Send comment'
)}
>
{submitting ? <LoaderCircle className="size-3.5 animate-spin" /> : null}
{translate('auto.components.github.GitHubIssueCommentComposer.bf43425540', 'Comment')}
</Button>
</div>
</div>
</div>
</div>
)
}
@@ -1,116 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react'
import {
Command,
CommandEmpty,
CommandInput,
CommandItem,
CommandList
} from '@/components/ui/command'
import { cn } from '@/lib/utils'
import { translate } from '@/i18n/i18n'
import type { GitHubAssignableUser } from '../../../../shared/types'
import { filterGitHubWorkItemAssignees } from './github-work-item-assignee-filter'
const assigneeCheckIcon = (
<svg className="size-2.5" viewBox="0 0 12 12" fill="none">
<path
d="M2 6l3 3 5-5"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
export function GitHubWorkItemAssigneePopoverContent({
open,
assignees,
selectedLogins,
error,
loading,
onToggleAssignee
}: {
open: boolean
assignees: readonly GitHubAssignableUser[]
selectedLogins: readonly string[]
error: string | null | undefined
loading?: boolean
onToggleAssignee: (login: string) => void
}): React.JSX.Element {
const [query, setQuery] = useState('')
const filteredAssignees = useMemo(
() => filterGitHubWorkItemAssignees(assignees, query),
[assignees, query]
)
const selectedSet = useMemo(() => new Set(selectedLogins), [selectedLogins])
useEffect(() => {
if (!open) {
setQuery('')
}
}, [open])
if (error) {
return <div className="px-2 py-3 text-center text-[12px] text-destructive">{error}</div>
}
const emptyText = loading
? translate(
'auto.components.github.GitHubWorkItemAssigneePopoverContent.cddd9b04a7',
'Loading assignees'
)
: translate(
'auto.components.github.GitHubWorkItemAssigneePopoverContent.a00830d3f7',
'No users'
)
return (
<Command shouldFilter={false} className="bg-transparent">
<CommandInput
placeholder={translate(
'auto.components.github.GitHubWorkItemAssigneePopoverContent.4f8b6f2c1d',
'Filter assignees...'
)}
value={query}
onValueChange={setQuery}
className="h-8 text-[12px]"
wrapperClassName="border-b border-border/60 px-2"
iconClassName="size-3.5"
/>
<CommandList className="max-h-60">
<CommandEmpty className="px-2 py-3 text-center text-[12px] text-muted-foreground">
{emptyText}
</CommandEmpty>
{filteredAssignees.map((user) => {
const isSelected = selectedSet.has(user.login)
return (
<CommandItem
key={user.login}
value={user.login}
onSelect={() => onToggleAssignee(user.login)}
className="flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px]"
>
<span
className={cn(
'flex size-3.5 items-center justify-center rounded-sm border',
isSelected ? 'border-primary bg-primary text-primary-foreground' : 'border-input'
)}
>
{isSelected ? assigneeCheckIcon : null}
</span>
<span className="min-w-0 flex-1">
<span className="block truncate">{user.login}</span>
{user.name ? (
<span className="block truncate text-[11px] text-muted-foreground">
{user.name}
</span>
) : null}
</span>
</CommandItem>
)
})}
</CommandList>
</Command>
)
}
@@ -1,152 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react'
import { ExternalLink, Settings } from 'lucide-react'
import {
Command,
CommandEmpty,
CommandInput,
CommandItem,
CommandList
} from '@/components/ui/command'
import { cn } from '@/lib/utils'
import { translate } from '@/i18n/i18n'
import { filterGitHubWorkItemLabels } from './github-work-item-label-filter'
const labelCheckIcon = (
<svg className="size-2.5" viewBox="0 0 12 12" fill="none">
<path
d="M2 6l3 3 5-5"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
function GitHubLabelsSettingsLink({
url,
separated,
onOpen
}: {
url: string | null
separated?: boolean
onOpen?: () => void
}): React.JSX.Element | null {
if (!url) {
return null
}
return (
<div className={cn(separated && 'mt-1 border-t border-border/60 pt-1')}>
<button
type="button"
onClick={() => {
onOpen?.()
void window.api.shell.openUrl(url)
}}
className="flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] text-muted-foreground hover:bg-accent hover:text-accent-foreground"
>
<Settings className="size-3.5 shrink-0" />
<span className="min-w-0 flex-1 text-left">
{translate(
'auto.components.github.GitHubWorkItemLabelPopoverContent.2aa9acdf34',
'Edit labels on GitHub'
)}
</span>
<ExternalLink className="size-3 shrink-0 opacity-70" />
</button>
</div>
)
}
export function GitHubWorkItemLabelPopoverContent({
open,
labels,
selectedLabels,
error,
loading,
repositoryLabelsUrl,
onToggleLabel,
onOpenSettingsLink
}: {
open: boolean
labels: readonly string[]
selectedLabels: readonly string[]
error: string | null | undefined
loading?: boolean
repositoryLabelsUrl?: string | null
onToggleLabel: (label: string) => void
onOpenSettingsLink?: () => void
}): React.JSX.Element {
const [query, setQuery] = useState('')
const filteredLabels = useMemo(() => filterGitHubWorkItemLabels(labels, query), [labels, query])
const selectedSet = useMemo(() => new Set(selectedLabels), [selectedLabels])
useEffect(() => {
if (!open) {
setQuery('')
}
}, [open])
if (error) {
return <div className="px-2 py-3 text-center text-[12px] text-destructive">{error}</div>
}
const emptyText = loading
? translate(
'auto.components.github.GitHubWorkItemLabelPopoverContent.cddd9b04a7',
'Loading labels'
)
: translate('auto.components.github.GitHubWorkItemLabelPopoverContent.de26e2eb06', 'No labels')
return (
<>
<Command shouldFilter={false} className="bg-transparent">
<CommandInput
placeholder={translate(
'auto.components.github.GitHubWorkItemLabelPopoverContent.8b0d52ee3a',
'Filter labels...'
)}
value={query}
onValueChange={setQuery}
className="h-8 text-[12px]"
wrapperClassName="border-b border-border/60 px-2"
iconClassName="size-3.5"
/>
<CommandList className="max-h-60">
<CommandEmpty className="px-2 py-3 text-center text-[12px] text-muted-foreground">
{emptyText}
</CommandEmpty>
{filteredLabels.map((label) => {
const isSelected = selectedSet.has(label)
return (
<CommandItem
key={label}
value={label}
onSelect={() => onToggleLabel(label)}
className="flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px]"
>
<span
className={cn(
'flex size-3.5 items-center justify-center rounded-sm border',
isSelected
? 'border-primary bg-primary text-primary-foreground'
: 'border-input'
)}
>
{isSelected ? labelCheckIcon : null}
</span>
<span className="min-w-0 truncate">{label}</span>
</CommandItem>
)
})}
</CommandList>
</Command>
<GitHubLabelsSettingsLink
url={repositoryLabelsUrl ?? null}
separated={labels.length > 0}
onOpen={onOpenSettingsLink}
/>
</>
)
}
@@ -1,61 +0,0 @@
import { Ban, CheckCircle2, Copy } from 'lucide-react'
import { translate } from '@/i18n/i18n'
import type { GitHubIssueCloseReason } from '../../../../shared/types'
export type CloseIssueReasonOption = {
reason: GitHubIssueCloseReason
label: string
description: string
icon: React.JSX.Element
}
export const CLOSE_ISSUE_REASONS: CloseIssueReasonOption[] = [
{
reason: 'completed',
get label() {
return translate(
'auto.components.github.githubIssueCloseReasons.completed.label',
'Close as completed'
)
},
get description() {
return translate(
'auto.components.github.githubIssueCloseReasons.completed.description',
'Done, closed, fixed, resolved'
)
},
icon: <CheckCircle2 className="size-4 text-violet-500" />
},
{
reason: 'not_planned',
get label() {
return translate(
'auto.components.github.githubIssueCloseReasons.notPlanned.label',
'Close as not planned'
)
},
get description() {
return translate(
'auto.components.github.githubIssueCloseReasons.notPlanned.description',
"Won't fix, can't repro, stale"
)
},
icon: <Ban className="size-4 text-muted-foreground" />
},
{
reason: 'duplicate',
get label() {
return translate(
'auto.components.github.githubIssueCloseReasons.duplicate.label',
'Close as duplicate'
)
},
get description() {
return translate(
'auto.components.github.githubIssueCloseReasons.duplicate.description',
'Duplicate of another issue'
)
},
icon: <Copy className="size-4 text-muted-foreground" />
}
]
@@ -1,104 +0,0 @@
import type { JSX } from 'react'
import { flushSync } from 'react-dom'
import { ArrowRight } from 'lucide-react'
import { Button } from '@/components/ui/button'
import type { FeatureWallTourDepthSummary } from '../../../../shared/feature-wall-tour-depth'
import { FeatureTourPreview } from '../feature-wall/FeatureTourPreview'
import { FeatureWallTourSurface } from '../feature-wall/FeatureWallTourSurface'
import { usePrefersReducedMotion } from '../feature-wall/feature-wall-modal-helpers'
import { translate } from '@/i18n/i18n'
type OnboardingTourStepProps = {
tourStarted: boolean
busyLabel: string | null
onStartTour: () => void
onCompleteTour: (markSuccessfulExit?: () => void) => boolean | void | Promise<boolean | void>
onExitTour: () => void
onTourDepthSummaryChange: (summary: FeatureWallTourDepthSummary) => void
}
type ViewTransition = {
finished: Promise<void>
}
type DocumentWithOptionalViewTransition = Document & {
startViewTransition?: (updateCallback: () => void | Promise<void>) => ViewTransition
}
export function OnboardingTourStep({
tourStarted,
busyLabel,
onStartTour,
onCompleteTour,
onExitTour,
onTourDepthSummaryChange
}: OnboardingTourStepProps): JSX.Element {
const prefersReducedMotion = usePrefersReducedMotion()
const handleStartTour = (): void => {
if (busyLabel) {
return
}
const doc = document as DocumentWithOptionalViewTransition
if (prefersReducedMotion || typeof doc.startViewTransition !== 'function') {
onStartTour()
return
}
const root = document.documentElement
let didStart = false
root.classList.add('onboarding-tour-start-transition')
try {
// Why: starting the inline feature wall rewrites the page shell; a view
// transition cross-fades the compact intro into the wide tour surface.
const transition = doc.startViewTransition(() => {
didStart = true
flushSync(onStartTour)
})
void transition.finished.finally(() => {
root.classList.remove('onboarding-tour-start-transition')
})
} catch {
root.classList.remove('onboarding-tour-start-transition')
if (!didStart) {
onStartTour()
}
}
}
if (tourStarted) {
return (
<FeatureWallTourSurface
isOpen
source="onboarding"
onDone={onCompleteTour}
doneLabel="Continue to project setup"
footerText={null}
compactRail
onTourDepthSummaryChange={onTourDepthSummaryChange}
className="h-full min-h-0"
panelClassName="rounded-xl border border-border bg-card"
leadingFooterContent={
<button
type="button"
className="rounded-md px-3 py-2 text-sm text-muted-foreground hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:text-muted-foreground"
disabled={Boolean(busyLabel)}
onClick={onExitTour}
>
{translate('auto.components.onboarding.OnboardingTourStep.60c5576353', 'Exit tour')}
</button>
}
/>
)
}
return (
<div className="flex flex-col gap-5">
<FeatureTourPreview />
<Button onClick={handleStartTour} disabled={Boolean(busyLabel)} className="gap-2 self-start">
{translate('auto.components.onboarding.OnboardingTourStep.3f9586c043', 'Take the tour')}
<ArrowRight className="size-4" />
</Button>
</div>
)
}
@@ -1,339 +0,0 @@
import React, { useCallback, useRef, useState } from 'react'
import { Loader2 } from 'lucide-react'
import { toast } from 'sonner'
import { Button } from '@/components/ui/button'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog'
import { useAppStore } from '@/store'
import type {
HostedReviewCreationEligibility,
HostedReviewProvider
} from '../../../../shared/hosted-review'
import { resolveHostedReviewCreationProvider } from '../../../../shared/hosted-review-creation-providers'
import { normalizeHostedReviewHeadRef } from '../../../../shared/hosted-review-refs'
import { stripBaseRef, useCreatePullRequestDialogFields } from './useCreatePullRequestDialogFields'
import {
DEFAULT_SOURCE_CONTROL_AI_PR_CREATION_DEFAULTS,
resolveSourceControlAiEnabled,
resolveSourceControlAiForOperation,
resolveSourceControlAiPrCreationDefaults
} from '../../../../shared/source-control-ai'
import { getCommitMessageModelDiscoveryHostKeyForScope } from '../../../../shared/commit-message-host-key'
import { getRuntimeGitScope } from '@/runtime/runtime-git-client'
import { CreatePullRequestGenerateButton } from './CreatePullRequestGenerateButton'
import { CreatePullRequestDialogForm } from './CreatePullRequestDialogForm'
import { formatCreateError, reviewCopy } from './create-pull-request-review-copy'
import { translate } from '@/i18n/i18n'
type CreatePullRequestDialogProps = {
open: boolean
repoId: string
repoPath: string
worktreeId: string | null
worktreePath: string
branch: string
eligibility: HostedReviewCreationEligibility | null
pushBeforeCreate: boolean
onOpenChange: (open: boolean) => void
onPushBeforeCreate: () => Promise<boolean>
onBranchChangedByGeneration: () => Promise<void>
onCreated: (result: {
provider: HostedReviewProvider
number: number
url: string
}) => Promise<void>
}
export function CreatePullRequestDialog({
open,
repoId,
repoPath,
worktreeId,
worktreePath,
branch,
eligibility,
pushBeforeCreate,
onOpenChange,
onPushBeforeCreate,
onBranchChangedByGeneration,
onCreated
}: CreatePullRequestDialogProps): React.JSX.Element {
const settings = useAppStore((s) => s.settings)
const repo = useAppStore((s) => s.repos.find((candidate) => candidate.id === repoId) ?? null)
const createHostedReview = useAppStore((s) => s.createHostedReview)
const submitInFlightRef = useRef(false)
const [submitting, setSubmitting] = useState(false)
const [error, setError] = useState<string | null>(null)
const provider = resolveHostedReviewCreationProvider(eligibility?.provider)
const copy = reviewCopy(provider)
const sourceControlAiActionsVisible = React.useMemo(
() => (settings ? resolveSourceControlAiEnabled({ settings, repo }) : false),
[repo, settings]
)
const prCreationDefaults = React.useMemo(() => {
if (!settings) {
return DEFAULT_SOURCE_CONTROL_AI_PR_CREATION_DEFAULTS
}
const hostKey = getCommitMessageModelDiscoveryHostKeyForScope(
getRuntimeGitScope(settings, repo?.connectionId)
)
const resolved = resolveSourceControlAiForOperation({
settings,
repo,
operation: 'pullRequest',
discoveryHostKey: hostKey,
prCreationProductDefaults: DEFAULT_SOURCE_CONTROL_AI_PR_CREATION_DEFAULTS
})
return resolved.ok
? resolved.value.prCreationDefaults
: resolveSourceControlAiPrCreationDefaults({
settings,
repo,
prCreationProductDefaults: DEFAULT_SOURCE_CONTROL_AI_PR_CREATION_DEFAULTS
})
}, [repo, settings])
const {
aiGenerationEnabled,
base,
setBase,
title,
setTitle,
body,
setBody,
draft,
setDraft,
baseQuery,
setBaseQuery,
baseResults,
setBaseResults,
baseSearchError,
generating,
generateError,
generateDisabled,
generateDisabledReason,
handleGenerate,
handleCancelGenerate
} = useCreatePullRequestDialogFields({
open,
repoId,
worktreeId,
worktreePath,
branch,
eligibility,
repo,
settings,
submitting,
prCreationDefaults,
sourceControlAiActionsVisible,
onBranchChangedByGeneration
})
const resetSubmissionState = useCallback((): void => {
submitInFlightRef.current = false
setSubmitting(false)
setError(null)
}, [])
const submitDisabled =
submitting ||
generating ||
title.trim().length === 0 ||
base.trim().length === 0 ||
stripBaseRef(base).toLowerCase() === stripBaseRef(branch).toLowerCase()
const handleSubmit = useCallback(async (): Promise<void> => {
if (submitDisabled || submitInFlightRef.current) {
return
}
submitInFlightRef.current = true
setSubmitting(true)
setError(null)
let pushed = false
try {
if (pushBeforeCreate) {
const ok = await onPushBeforeCreate()
if (!ok) {
setError('Push failed. Resolve the push error, then try again.')
return
}
pushed = true
}
const result = await createHostedReview(repoPath, {
provider,
base: stripBaseRef(base.trim()),
head: normalizeHostedReviewHeadRef(branch),
title: title.trim(),
body,
draft,
worktreePath,
useTemplate: prCreationDefaults.useTemplate
})
if (result.ok) {
await onCreated({ provider, number: result.number, url: result.url })
if (prCreationDefaults.openAfterCreate) {
window.api.shell.openUrl(result.url)
}
resetSubmissionState()
onOpenChange(false)
return
}
if (result.existingReview?.url) {
const number = result.existingReview.number
toast.success(
number
? translate(
'auto.components.right.sidebar.CreatePullRequestDialog.edc35a7027',
'{{value0}} #{{value1}} is already open',
{ value0: copy.titleLabel, value1: number }
)
: translate(
'auto.components.right.sidebar.CreatePullRequestDialog.21c7a1daa0',
'{{value0}} is already open',
{ value0: copy.titleLabel }
),
{
action: {
label: translate(
'auto.components.right.sidebar.CreatePullRequestDialog.7a21f0dae8',
'Open on {{value0}}',
{ value0: copy.providerName }
),
onClick: () => window.api.shell.openUrl(result.existingReview!.url)
}
}
)
if (number) {
await onCreated({ provider, number, url: result.existingReview.url })
resetSubmissionState()
onOpenChange(false)
return
}
}
setError(formatCreateError(result, pushed, copy.shortLabel))
} finally {
submitInFlightRef.current = false
setSubmitting(false)
}
}, [
base,
body,
branch,
createHostedReview,
draft,
onCreated,
onOpenChange,
onPushBeforeCreate,
provider,
pushBeforeCreate,
copy.providerName,
copy.shortLabel,
copy.titleLabel,
prCreationDefaults.openAfterCreate,
prCreationDefaults.useTemplate,
repoPath,
resetSubmissionState,
submitDisabled,
title,
worktreePath
])
const handleOpenChange = useCallback(
(nextOpen: boolean): void => {
// Why: closing during submit would reset the in-flight guard while the
// main-process create call can still complete, allowing duplicate clicks.
if (submitting && !nextOpen) {
return
}
if (!nextOpen) {
resetSubmissionState()
}
onOpenChange(nextOpen)
},
[onOpenChange, resetSubmissionState, submitting]
)
return (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogContent className="max-w-lg">
<DialogHeader>
<div className="flex min-w-0 items-center justify-between gap-2 pr-8">
<DialogTitle className="min-w-0 truncate">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.db9cee18f7',
'Create {{value0}}',
{ value0: copy.titleLabel }
)}
</DialogTitle>
{aiGenerationEnabled ? (
<CreatePullRequestGenerateButton
generating={generating}
generateDisabled={generateDisabled}
generateDisabledReason={generateDisabledReason}
shortLabel={copy.shortLabel}
reviewLabel={copy.reviewLabel}
onGenerate={() => void handleGenerate()}
onCancelGenerate={handleCancelGenerate}
/>
) : null}
</div>
<DialogDescription>
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.f658ff2455',
'Confirm the target branch and {{value0}} details before creating the hosted review.',
{ value0: copy.shortLabel }
)}
</DialogDescription>
</DialogHeader>
<CreatePullRequestDialogForm
branch={branch}
base={base}
setBase={setBase}
baseQuery={baseQuery}
setBaseQuery={setBaseQuery}
baseResults={baseResults}
setBaseResults={setBaseResults}
baseSearchError={baseSearchError}
title={title}
setTitle={setTitle}
body={body}
setBody={setBody}
draft={draft}
setDraft={setDraft}
copy={copy}
generateError={generateError}
error={error}
/>
<DialogFooter>
<Button variant="outline" onClick={() => handleOpenChange(false)} disabled={submitting}>
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.2bc1b4345e',
'Cancel'
)}
</Button>
<Button onClick={() => void handleSubmit()} disabled={submitDisabled}>
{submitting ? <Loader2 className="size-4 animate-spin" /> : null}
{pushBeforeCreate
? translate(
'auto.components.right.sidebar.CreatePullRequestDialog.a154fe55e6',
'Push & Create {{value0}}',
{ value0: copy.shortLabel }
)
: translate(
'auto.components.right.sidebar.CreatePullRequestDialog.b7f43474d7',
'Create {{value0}}',
{ value0: copy.shortLabel }
)}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
@@ -1,189 +0,0 @@
import { Check, ChevronsUpDown } from 'lucide-react'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { cn } from '@/lib/utils'
import { stripBaseRef } from './useCreatePullRequestDialogFields'
import type { CreatePullRequestReviewCopy } from './create-pull-request-review-copy'
import { translate } from '@/i18n/i18n'
type CreatePullRequestDialogFormProps = {
branch: string
base: string
setBase: (value: string) => void
baseQuery: string
setBaseQuery: (value: string) => void
baseResults: string[]
setBaseResults: (value: string[]) => void
baseSearchError: string | null
title: string
setTitle: (value: string) => void
body: string
setBody: (value: string) => void
draft: boolean
setDraft: (value: boolean) => void
copy: CreatePullRequestReviewCopy
generateError: string | null
error: string | null
}
export function CreatePullRequestDialogForm({
branch,
base,
setBase,
baseQuery,
setBaseQuery,
baseResults,
setBaseResults,
baseSearchError,
title,
setTitle,
body,
setBody,
draft,
setDraft,
copy,
generateError,
error
}: CreatePullRequestDialogFormProps): React.JSX.Element {
return (
<div className="space-y-4">
<div className="space-y-1">
<Label>
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.6f5f1962b6',
'Head branch'
)}
</Label>
<div className="inline-flex max-w-full items-center rounded-full border border-border bg-muted px-2 py-1 text-xs font-medium text-foreground">
<span className="truncate">{branch}</span>
</div>
</div>
<div className="space-y-2">
<div className="space-y-1">
<Label htmlFor="create-pr-base">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.8584ccb43c',
'Base branch'
)}
</Label>
<p className="text-xs text-muted-foreground">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.0fad57a14c',
'Search remote branches or enter a branch name.'
)}
</p>
</div>
<div className="relative">
<Input
id="create-pr-base"
value={baseQuery || base}
onChange={(event) => {
setBaseQuery(event.target.value)
setBase(event.target.value)
}}
placeholder={translate(
'auto.components.right.sidebar.CreatePullRequestDialog.694550a610',
'main'
)}
aria-invalid={!base.trim()}
className="pr-8"
/>
<ChevronsUpDown className="pointer-events-none absolute right-2 top-2.5 size-3.5 text-muted-foreground" />
</div>
{baseSearchError ? <p className="text-xs text-destructive">{baseSearchError}</p> : null}
{baseResults.length > 0 ? (
<div className="max-h-36 overflow-auto rounded-md border border-border p-1 scrollbar-sleek">
{baseResults.map((ref) => (
<button
key={ref}
type="button"
className={cn(
'flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent',
stripBaseRef(base) === ref && 'bg-accent text-accent-foreground'
)}
onClick={() => {
setBase(ref)
setBaseQuery('')
setBaseResults([])
}}
>
<span className="truncate">{ref}</span>
{stripBaseRef(base) === ref ? <Check className="size-3" /> : null}
</button>
))}
</div>
) : null}
</div>
<div className="space-y-2">
<Label htmlFor="create-pr-title">
{translate('auto.components.right.sidebar.CreatePullRequestDialog.68314b4369', 'Title')}
</Label>
<Input
id="create-pr-title"
value={title}
onChange={(event) => setTitle(event.target.value)}
placeholder={translate(
'auto.components.right.sidebar.CreatePullRequestDialog.68314b4369',
'Title'
)}
aria-invalid={!title.trim()}
/>
</div>
<div className="space-y-2">
<Label htmlFor="create-pr-body">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.1cd53359db',
'Description'
)}
</Label>
<textarea
id="create-pr-body"
value={body}
onChange={(event) => setBody(event.target.value)}
rows={6}
placeholder={translate(
'auto.components.right.sidebar.CreatePullRequestDialog.02b2ce911f',
'Description (optional)'
)}
className="w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground/70 focus-visible:ring-1 focus-visible:ring-ring"
/>
<p className="text-xs text-muted-foreground">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.0c9f9a568c',
'Supports Markdown formatting. Use Generate with AI to auto-fill from your changes.'
)}
</p>
</div>
<label className="flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground">
<input
type="checkbox"
checked={draft}
onChange={(event) => setDraft(event.target.checked)}
className="size-4 shrink-0 rounded border-border accent-primary"
/>
<span className="min-w-0 flex-1 truncate">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.7ef56f3efe',
'Create as draft'
)}
</span>
</label>
{stripBaseRef(base).toLowerCase() === stripBaseRef(branch).toLowerCase() ? (
<p className="text-xs text-destructive">
{translate(
'auto.components.right.sidebar.CreatePullRequestDialog.27ef4b195c',
'Choose a different base branch before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)}
</p>
) : null}
{generateError ? <p className="text-xs text-destructive">{generateError}</p> : null}
{error ? <p className="text-xs text-destructive">{error}</p> : null}
</div>
)
}
@@ -1,93 +0,0 @@
import { RefreshCw, Sparkles, Square } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { translate } from '@/i18n/i18n'
export function CreatePullRequestGenerateButton({
generating,
generateDisabled,
generateDisabledReason,
shortLabel,
reviewLabel,
onGenerate,
onCancelGenerate
}: {
generating: boolean
generateDisabled: boolean
generateDisabledReason: string | null | undefined
shortLabel: string
reviewLabel: string
onGenerate: () => void
onCancelGenerate: () => void
}): React.JSX.Element {
if (generating) {
return (
<div className="shrink-0">
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="outline"
size="sm"
onClick={onCancelGenerate}
title={translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.e041998cad',
'Stop generating'
)}
aria-label={translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.e61d7e7ad4',
'Stop generating {{value0}} details',
{ value0: reviewLabel }
)}
>
<RefreshCw className="size-4 animate-spin" />
{translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.a6ea6dc3aa',
'Generating…'
)}
<Square className="size-3 fill-current" />
</Button>
</TooltipTrigger>
<TooltipContent side="left" sideOffset={6}>
{translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.d47fd63012',
'Generating {{value0}} details. Click to stop.',
{ value0: shortLabel }
)}
</TooltipContent>
</Tooltip>
</div>
)
}
return (
<div className="shrink-0">
<Button
type="button"
variant="outline"
size="sm"
disabled={generateDisabled}
onClick={onGenerate}
title={
generateDisabledReason ??
translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.a0501572c1',
'Generate {{value0}} details with AI',
{ value0: reviewLabel }
)
}
aria-label={translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.a0501572c1',
'Generate {{value0}} details with AI',
{ value0: reviewLabel }
)}
>
<Sparkles className="size-4" />
{translate(
'auto.components.right.sidebar.CreatePullRequestGenerateButton.4012459f8a',
'Generate with AI'
)}
</Button>
</div>
)
}
@@ -1,43 +0,0 @@
import React from 'react'
import { translate } from '@/i18n/i18n'
import type { RightSidebarExplorerView } from '../../../../shared/types'
import { FileExplorerQueryStrip } from './FileExplorerQueryStrip'
import { SearchFilters } from './SearchFilters'
import { SearchQueryRow } from './SearchQueryRow'
import { SearchResultsPane } from './SearchResultsPane'
import { useFileSearchPanel } from './useFileSearchPanel'
type SearchProps = {
explorerView: RightSidebarExplorerView
onSelectExplorerView: (view: RightSidebarExplorerView) => void
}
export default function Search({
explorerView,
onSelectExplorerView
}: SearchProps): React.JSX.Element {
const searchPanel = useFileSearchPanel(explorerView)
if (!searchPanel.activeWorktreeId) {
return (
<div className="flex h-full items-center justify-center text-xs text-muted-foreground">
{translate(
'auto.components.right.sidebar.Search.98c8435e36',
'Select a workspace to search'
)}
</div>
)
}
return (
<div className="flex h-full flex-col">
<FileExplorerQueryStrip view={explorerView} onSelectView={onSelectExplorerView}>
<SearchQueryRow {...searchPanel.queryRowProps} />
</FileExplorerQueryStrip>
<div className="border-b border-border px-2 pb-1.5">
<SearchFilters {...searchPanel.filtersProps} />
</div>
<SearchResultsPane {...searchPanel.resultsProps} />
</div>
)
}
@@ -1,41 +0,0 @@
import React from 'react'
import { SearchFilters, type SearchFiltersProps } from './SearchFilters'
import { SearchQueryRow, type SearchQueryRowProps } from './SearchQueryRow'
type SearchHeaderProps = SearchQueryRowProps & {
embedded?: boolean
} & SearchFiltersProps
export function SearchHeader({
includeInputRef,
excludeInputRef,
includePattern,
excludePattern,
onIncludeChange,
onExcludeChange,
embedded = false,
...queryRowProps
}: SearchHeaderProps): React.JSX.Element {
return (
<div
className={
embedded ? 'flex flex-col gap-1.5' : 'flex flex-col gap-1.5 border-b border-border p-2'
}
>
<SearchQueryRow {...queryRowProps} />
{/* Why: the Search tab is a secondary destination — users switch to it
when they want powerful, scoped search, so include/exclude fields
stay visible instead of hidden behind a toggle. */}
<SearchFilters
includePattern={includePattern}
excludePattern={excludePattern}
includeInputRef={includeInputRef}
excludeInputRef={excludeInputRef}
onIncludeChange={onIncludeChange}
onExcludeChange={onExcludeChange}
/>
</div>
)
}
export type { SearchQueryRowProps }
@@ -1 +0,0 @@
export { CONFLICT_KIND_LABELS } from '../../../../shared/source-control-conflict-prompts'
@@ -1,39 +0,0 @@
import { translate } from '@/i18n/i18n'
import type { PrimaryAction } from './source-control-primary-action-types'
export function resolveLinkedReviewPrimaryAction(args: {
hasOpenHostedReview: boolean
canPushLinkedReviewWithoutUpstream: boolean
}): PrimaryAction | null {
if (!args.hasOpenHostedReview) {
return null
}
if (args.canPushLinkedReviewWithoutUpstream) {
return {
kind: 'push',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.95550cff15',
'Push'
),
// Why: older fork-review worktrees can lose persisted pushTarget and
// appear untracked even though their branch config still names a PR head.
title: translate(
'auto.components.right.sidebar.source.control.primary.action.1d47e850cf',
'Push updates to the linked review branch'
),
disabled: false
}
}
return {
kind: 'commit',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.ed93b4f14f',
'Commit'
),
title: translate(
'auto.components.right.sidebar.source.control.primary.action.c39d0c75c3',
'Linked review branch target is unavailable.'
),
disabled: true
}
}
@@ -1,65 +0,0 @@
import { translate } from '@/i18n/i18n'
import {
PRIMARY_LABEL_BY_KIND,
type PrimaryAction,
type PrimaryActionInputs
} from './source-control-primary-action-types'
export function resolvePrimaryActionDuringRemoteOp(
inputs: PrimaryActionInputs,
resolveWithoutRemoteOp: (inputs: PrimaryActionInputs) => PrimaryAction
): PrimaryAction {
const { inFlightRemoteOpKind, hasUnresolvedConflicts } = inputs
const candidate = resolveWithoutRemoteOp({ ...inputs, isRemoteOperationActive: false })
const inFlightIsPrimaryKind =
inFlightRemoteOpKind === 'push' ||
inFlightRemoteOpKind === 'pull' ||
inFlightRemoteOpKind === 'sync' ||
inFlightRemoteOpKind === 'publish'
if (inFlightRemoteOpKind === 'force_push') {
return {
kind: 'push',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.390abeab93',
'Force Push'
),
title: translate(
'auto.components.right.sidebar.source.control.primary.action.74fc171e99',
'Force Push in progress…'
),
disabled: true
}
}
if (inFlightIsPrimaryKind && candidate.kind !== inFlightRemoteOpKind) {
const label = PRIMARY_LABEL_BY_KIND[inFlightRemoteOpKind]
return {
kind: inFlightRemoteOpKind,
label,
title: translate(
'auto.components.right.sidebar.source.control.primary.action.484f45c439',
'{{value0}} in progress…',
{ value0: label }
),
disabled: true
}
}
// Why: when the candidate label is "Commit", the generic "remote
// operation in progress…" tooltip mismatches the visible label. Point
// the user at the fact that the commit will wait, keeping the label and
// the explanation consistent. Conflicts take precedence over the remote
// tooltip because resolving them is the only action the user can start
// while the remote op runs.
const title = hasUnresolvedConflicts
? 'Resolve conflicts before committing'
: candidate.kind === 'commit'
? 'Remote operation in progress — try again once it finishes'
: 'Remote operation in progress…'
return {
...candidate,
title,
disabled: true
}
}
@@ -1,71 +0,0 @@
import { translate } from '@/i18n/i18n'
import type { PrimaryAction } from './source-control-primary-action-types'
import type { PRState } from '../../../../shared/types'
export function resolveUnpublishedPrimaryAction({
hasCurrentBranch,
isPRStateLoading,
prState
}: {
hasCurrentBranch: boolean
isPRStateLoading?: boolean
prState?: PRState | null
}): PrimaryAction {
if (!hasCurrentBranch) {
return {
kind: 'commit',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.ed93b4f14f',
'Commit'
),
title: translate(
'auto.components.right.sidebar.source.control.primary.action.e61b0d7a3c',
'Check out a branch before publishing commits.'
),
disabled: true
}
}
if (isPRStateLoading) {
return {
kind: 'commit',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.ed93b4f14f',
'Commit'
),
title: translate(
'auto.components.right.sidebar.source.control.primary.action.41d4bcf157',
'Checking PR status…'
),
disabled: true
}
}
if (prState === 'merged') {
return {
kind: 'commit',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.ed93b4f14f',
'Commit'
),
title: translate(
'auto.components.right.sidebar.source.control.primary.action.3d5dccef0b',
'Nothing to commit. PR is already merged.'
),
disabled: true
}
}
return {
kind: 'publish',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.7b4d02e6b8',
'Publish Branch'
),
title: translate(
'auto.components.right.sidebar.source.control.primary.action.1884cf34af',
'Publish this branch to origin'
),
disabled: false
}
}
@@ -1,135 +0,0 @@
import { buildBranchNamePrompt } from '../../../../shared/branch-name-from-work'
import { Button } from '../ui/button'
import { Label } from '../ui/label'
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
import { translate } from '@/i18n/i18n'
const BUILT_IN_BRANCH_NAME_PROMPT = buildBranchNamePrompt({
firstPrompt: '{first agent prompt}',
assistantMessage: '{agent initial response, when available}'
})
type AutoRenameBranchPromptEditorProps = {
draft: string
dirty: boolean
saving: boolean
onDraftChange: (value: string) => void
onDiscard: () => void
onSave: () => void | Promise<void>
}
export function AutoRenameBranchPromptEditor({
draft,
dirty,
saving,
onDraftChange,
onDiscard,
onSave
}: AutoRenameBranchPromptEditorProps): React.JSX.Element {
return (
// Why: py-2 matches the sibling rows so the editor doesn't hug the group's
// divide-y divider the way the model/prompt rows are spaced.
<div className="space-y-2 py-2">
<div className="space-y-0.5">
<Label htmlFor="git-auto-rename-branch-name-prompt">
{translate('auto.components.settings.AutoRenameBranchPromptEditor.7d6176f506', 'Prompt')}
</Label>
<p className="text-xs text-muted-foreground">
{translate(
'auto.components.settings.AutoRenameBranchPromptEditor.2f5dc661fe',
"Appended to Orca's"
)}{' '}
<Popover>
<PopoverTrigger asChild>
<button
type="button"
className="inline rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
{translate(
'auto.components.settings.AutoRenameBranchPromptEditor.182d419b97',
'built-in branch-name prompt'
)}
</button>
</PopoverTrigger>
<PopoverContent
align="start"
side="bottom"
className="w-[520px] max-w-[calc(100vw-2rem)] p-3"
>
<div>
<pre className="scrollbar-sleek max-h-72 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-background px-3 py-2 font-mono text-[11px] leading-relaxed text-muted-foreground">
{BUILT_IN_BRANCH_NAME_PROMPT}
</pre>
</div>
</PopoverContent>
</Popover>
{translate(
'auto.components.settings.AutoRenameBranchPromptEditor.af2d9a2cc6',
'. Orca generates only the final segment, like'
)}{' '}
<code className="font-mono">
{translate(
'auto.components.settings.AutoRenameBranchPromptEditor.ebb942a2ec',
'fix-login-flow'
)}
</code>
{translate(
'auto.components.settings.AutoRenameBranchPromptEditor.39278f4411',
'; your branch prefix setting still applies.'
)}
</p>
</div>
<textarea
id="git-auto-rename-branch-name-prompt"
rows={4}
value={draft}
onChange={(event) => onDraftChange(event.target.value)}
placeholder={translate(
'auto.components.settings.AutoRenameBranchPromptEditor.4416b25d29',
'Prefer domain nouns from the task, avoid ticket IDs, and keep names reviewer-friendly.'
)}
className="w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 text-xs text-foreground outline-none placeholder:text-muted-foreground/70 focus-visible:ring-1 focus-visible:ring-ring"
/>
<div className="flex items-center justify-between gap-3">
<p className="text-[11px] text-muted-foreground">
{dirty
? translate(
'auto.components.settings.AutoRenameBranchPromptEditor.0691753cf2',
'Unsaved changes'
)
: translate(
'auto.components.settings.AutoRenameBranchPromptEditor.af0831a590',
'Saved'
)}
</p>
<div className="flex items-center gap-2">
{dirty ? (
<Button type="button" variant="ghost" size="xs" onClick={onDiscard} disabled={saving}>
{translate(
'auto.components.settings.AutoRenameBranchPromptEditor.63121132c0',
'Discard'
)}
</Button>
) : null}
<Button
type="button"
variant="secondary"
size="xs"
onClick={() => void onSave()}
disabled={!dirty || saving}
>
{saving
? translate(
'auto.components.settings.AutoRenameBranchPromptEditor.54ac229ad4',
'Saving...'
)
: translate(
'auto.components.settings.AutoRenameBranchPromptEditor.5968112152',
'Save'
)}
</Button>
</div>
</div>
</div>
)
}
@@ -1,135 +0,0 @@
import { useCallback, useMemo } from 'react'
import type { CliInstallStatus } from '../../../../shared/cli-install-types'
import type { GlobalSettings } from '../../../../shared/types'
import {
ORCA_CLI_SKILL_INSTALL_COMMAND,
ORCA_CLI_SKILL_NAME,
ORCA_CLI_SKILL_UPDATE_COMMAND
} from '@/lib/agent-feature-install-commands'
import {
AGENT_SKILL_CLI_PREREQUISITE_NOTICE,
ensureOrcaCliAvailableForAgentSkillTerminal,
isOrcaCliAvailableOnPath
} from '@/lib/agent-skill-cli-prerequisite'
import {
GLOBAL_AGENT_SKILL_SOURCE_KINDS,
useInstalledAgentSkill
} from '@/hooks/useInstalledAgentSkills'
import { AgentSkillSetupPanel } from './AgentSkillSetupPanel'
import {
buildSkillCommandForRuntime,
ensureWslCliAvailableForAgentSkillTerminal,
getAgentSkillTerminalShellOverride,
getSelectedAgentRuntime,
getSkillDiscoveryTargetForRuntime,
getWslCliDistroRequest
} from './CliSkillRuntimeSetup'
import { Label } from '../ui/label'
import { translate } from '@/i18n/i18n'
type CliAgentSkillSetupProps = {
currentPlatform: string
settings: GlobalSettings
wslSupportedPlatform: boolean
wslAvailable: boolean
wslCapabilitiesLoading: boolean
onHostStatusChange: (nextStatus: CliInstallStatus) => void
}
export function CliAgentSkillSetup({
currentPlatform,
settings,
wslSupportedPlatform,
wslAvailable,
wslCapabilitiesLoading,
onHostStatusChange
}: CliAgentSkillSetupProps): React.JSX.Element {
const agentRuntime = useMemo(
() =>
getSelectedAgentRuntime(settings, wslSupportedPlatform, wslAvailable, wslCapabilitiesLoading),
[settings, wslAvailable, wslCapabilitiesLoading, wslSupportedPlatform]
)
const cliSkillDiscoveryTarget = useMemo(
() => getSkillDiscoveryTargetForRuntime(agentRuntime),
[agentRuntime]
)
const {
installed: cliSkillDetected,
loading: cliSkillLoading,
error: cliSkillError,
refresh: refreshCliSkill
} = useInstalledAgentSkill(ORCA_CLI_SKILL_NAME, {
discoveryTarget: cliSkillDiscoveryTarget,
sourceKinds: GLOBAL_AGENT_SKILL_SOURCE_KINDS
})
const cliSkillInstallCommand = buildSkillCommandForRuntime(
ORCA_CLI_SKILL_INSTALL_COMMAND,
agentRuntime
)
const cliSkillUpdateCommand = buildSkillCommandForRuntime(
ORCA_CLI_SKILL_UPDATE_COMMAND,
agentRuntime
)
const cliSkillTerminalShellOverride = getAgentSkillTerminalShellOverride(
currentPlatform,
settings,
agentRuntime
)
const getCliSkillPrerequisiteStatus = useCallback(
() =>
agentRuntime.runtime === 'wsl'
? window.api.cli.getWslInstallStatus(getWslCliDistroRequest(agentRuntime))
: window.api.cli.getInstallStatus(),
[agentRuntime]
)
return (
<div className="border-t border-border/60 pt-3">
<div className="space-y-0.5">
<Label>{translate('auto.components.settings.CliSection.04873eea3e', 'Agent skills')}</Label>
<p className="text-xs text-muted-foreground">
{translate(
'auto.components.settings.CliSection.36a6f919ba',
'Give agents Orca-aware workspace, terminal, and progress workflows.'
)}
</p>
</div>
<AgentSkillSetupPanel
className="mt-3"
variant="inline"
title={translate('auto.components.settings.CliSection.6053cf736c', 'CLI skill')}
description={translate(
'auto.components.settings.CliSection.e8012c03a1',
'Enables agents to use Orca workspace, terminal, and progress commands.'
)}
command={cliSkillInstallCommand}
installedCommand={cliSkillUpdateCommand}
terminalTitle={translate(
'auto.components.settings.CliSection.cliSkillTerminalTitle',
'CLI skill setup'
)}
terminalAriaLabel={translate(
'auto.components.settings.CliSection.cliSkillTerminalAria',
'CLI skill install terminal'
)}
terminalWorktreeId={`settings-cli-skill-terminal-${agentRuntime.runtime}`}
terminalShellOverride={cliSkillTerminalShellOverride}
installed={cliSkillDetected}
loading={cliSkillLoading}
error={cliSkillError}
preInstallNotice={AGENT_SKILL_CLI_PREREQUISITE_NOTICE}
getPrerequisiteStatus={getCliSkillPrerequisiteStatus}
isPrerequisiteAvailable={isOrcaCliAvailableOnPath}
onBeforeOpenTerminal={async () => {
await (agentRuntime.runtime === 'wsl'
? ensureWslCliAvailableForAgentSkillTerminal(agentRuntime)
: ensureOrcaCliAvailableForAgentSkillTerminal({
onStatusChange: onHostStatusChange
}))
}}
onRecheck={refreshCliSkill}
/>
</div>
)
}
@@ -1,298 +0,0 @@
import type { Dispatch, SetStateAction } from 'react'
import type { GlobalSettings } from '../../../../shared/types'
import {
DEFAULT_TERMINAL_FONT_WEIGHT,
TERMINAL_FONT_WEIGHT_MAX,
TERMINAL_FONT_WEIGHT_MIN,
TERMINAL_FONT_WEIGHT_STEP,
normalizeTerminalFontWeight
} from '../../../../shared/terminal-fonts'
import {
fontFamilyHasKnownLigatures,
resolveTerminalLigaturesEnabled
} from '../../../../shared/terminal-ligatures'
import { Button } from '../ui/button'
import {
FontAutocomplete,
NumberField,
SettingsRow,
SettingsSegmentedControl,
SettingsSubsectionHeader
} from './SettingsFormControls'
import { SearchableSetting } from './SearchableSetting'
import { clampNumber } from '@/lib/terminal-theme'
import { TerminalSettingsPreview } from './TerminalSettingsPreview'
import { TerminalFontSizeSetting } from './TerminalFontSizeSetting'
import type { UseGhosttyImportReturn } from './useGhosttyImport'
import ghosttyIcon from '../../../../../resources/ghostty.svg'
import { translate } from '@/i18n/i18n'
type TerminalTypographyAppearanceSectionProps = {
settings: GlobalSettings
updateSettings: (updates: Partial<GlobalSettings>) => void
systemPrefersDark: boolean
terminalFontSuggestions: string[]
ghostty: UseGhosttyImportReturn
previewFontFamily: string | null
setPreviewFontFamily: Dispatch<SetStateAction<string | null>>
}
export function TerminalTypographyAppearanceSection({
settings,
updateSettings,
systemPrefersDark,
terminalFontSuggestions,
ghostty,
previewFontFamily,
setPreviewFontFamily
}: TerminalTypographyAppearanceSectionProps): React.JSX.Element {
return (
<section className="grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]">
<div className="min-w-0 space-y-3">
<div className="flex flex-wrap items-start justify-between gap-3">
<SettingsSubsectionHeader
title={translate(
'auto.components.settings.TerminalAppearanceSection.048aac8a64',
'Terminal Typography'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.711e589f18',
'Default terminal typography for new panes and live updates.'
)}
/>
<Button
variant="outline"
size="sm"
className="gap-1.5"
onClick={() => void ghostty.handleClick()}
>
<img src={ghosttyIcon} alt="" aria-hidden="true" className="size-4" />
{translate(
'auto.components.settings.TerminalAppearanceSection.855a76343a',
'Import from Ghostty'
)}
</Button>
</div>
<div className="divide-y divide-border/40">
<TerminalFontSizeSetting settings={settings} updateSettings={updateSettings} />
<SearchableSetting
title={translate(
'auto.components.settings.TerminalAppearanceSection.a408266e67',
'Font Family'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.f04b17a50e',
'Default terminal font family for new panes and live updates.'
)}
keywords={['terminal', 'typography', 'font']}
>
<SettingsRow
alignTop
label={translate(
'auto.components.settings.TerminalAppearanceSection.a408266e67',
'Font Family'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.f04b17a50e',
'Default terminal font family for new panes and live updates.'
)}
control={
<FontAutocomplete
value={settings.terminalFontFamily}
suggestions={terminalFontSuggestions}
onChange={(value) => updateSettings({ terminalFontFamily: value })}
onPreviewFontFamily={setPreviewFontFamily}
/>
}
/>
</SearchableSetting>
<SearchableSetting
title={translate(
'auto.components.settings.TerminalAppearanceSection.4aae5db258',
'Font Weight'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.36af8ad94c',
'Controls the terminal text font weight.'
)}
keywords={['terminal', 'typography', 'weight']}
>
<NumberField
label={translate(
'auto.components.settings.TerminalAppearanceSection.4aae5db258',
'Font Weight'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.36af8ad94c',
'Controls the terminal text font weight.'
)}
value={normalizeTerminalFontWeight(settings.terminalFontWeight)}
defaultValue={DEFAULT_TERMINAL_FONT_WEIGHT}
min={TERMINAL_FONT_WEIGHT_MIN}
max={TERMINAL_FONT_WEIGHT_MAX}
step={TERMINAL_FONT_WEIGHT_STEP}
suffix="100-900"
onChange={(value) =>
updateSettings({
terminalFontWeight: normalizeTerminalFontWeight(value)
})
}
/>
</SearchableSetting>
<SearchableSetting
title={translate(
'auto.components.settings.TerminalAppearanceSection.c084eb7d4c',
'Line Height'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.bafc80efbc',
'Controls the terminal line height multiplier.'
)}
keywords={['terminal', 'typography', 'line height', 'spacing']}
>
<NumberField
label={translate(
'auto.components.settings.TerminalAppearanceSection.c084eb7d4c',
'Line Height'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.bafc80efbc',
'Controls the terminal line height multiplier.'
)}
value={settings.terminalLineHeight}
defaultValue={1}
min={1}
max={3}
step={0.1}
suffix="1-3"
onChange={(value) =>
updateSettings({
terminalLineHeight: clampNumber(value, 1, 3)
})
}
/>
</SearchableSetting>
<SearchableSetting
title={translate(
'auto.components.settings.TerminalAppearanceSection.be8da35e7f',
'Font Ligatures'
)}
description={translate(
'auto.components.settings.TerminalAppearanceSection.7233d594bf',
'Render programming ligatures (e.g. =>, !=, ===) for fonts that ship them. "Auto" enables ligatures only for known ligature fonts (Fira Code, JetBrains Mono, Cascadia Code, Iosevka, etc.).'
)}
keywords={[
'terminal',
'typography',
'ligatures',
'ligature',
'fira code',
'jetbrains mono',
'cascadia code',
'iosevka',
'calt',
'font features'
]}
>
<SettingsRow
label={translate(
'auto.components.settings.TerminalAppearanceSection.be8da35e7f',
'Font Ligatures'
)}
description={
settings.terminalLigatures === 'on'
? translate(
'auto.components.settings.TerminalAppearanceSection.7234abcd08',
'Always on. Fonts without ligatures simply render as-is.'
)
: settings.terminalLigatures === 'off'
? translate(
'auto.components.settings.TerminalAppearanceSection.04569feb07',
'Always off, even for fonts that ship them.'
)
: fontFamilyHasKnownLigatures(settings.terminalFontFamily)
? translate(
'auto.components.settings.TerminalAppearanceSection.400e950ca5',
'Auto - enabled for "{{value0}}".',
{ value0: settings.terminalFontFamily }
)
: translate(
'auto.components.settings.TerminalAppearanceSection.4b1f29598e',
'Auto - disabled for "{{value0}}".',
{ value0: settings.terminalFontFamily || 'the current font' }
)
}
control={
<SettingsSegmentedControl
ariaLabel={translate(
'auto.components.settings.TerminalAppearanceSection.be8da35e7f',
'Font Ligatures'
)}
value={settings.terminalLigatures ?? 'auto'}
onChange={(option) => updateSettings({ terminalLigatures: option })}
options={[
{
value: 'auto',
label: translate(
'auto.components.settings.TerminalAppearanceSection.bc9ff84d61',
'Auto'
)
},
{
value: 'on',
label: translate(
'auto.components.settings.TerminalAppearanceSection.84bd22f2cd',
'On'
)
},
{
value: 'off',
label: translate(
'auto.components.settings.TerminalAppearanceSection.870377082f',
'Off'
)
}
]}
/>
}
/>
<p className="sr-only" aria-live="polite">
{translate(
'auto.components.settings.TerminalAppearanceSection.31f6e61085',
'Ligatures are currently'
)}{' '}
{resolveTerminalLigaturesEnabled(
settings.terminalLigatures,
settings.terminalFontFamily
)
? translate(
'auto.components.settings.TerminalAppearanceSection.4e7d41a9f0',
'enabled'
)
: translate(
'auto.components.settings.TerminalAppearanceSection.4415beb958',
'disabled'
)}
.
</p>
</SearchableSetting>
</div>
</div>
<TerminalSettingsPreview
title={translate(
'auto.components.settings.TerminalAppearanceSection.70beb1bbc7',
'Preview'
)}
settings={settings}
systemPrefersDark={systemPrefersDark}
previewFontFamily={previewFontFamily}
showThemeToggle
/>
</section>
)
}
@@ -27,10 +27,6 @@ const updateCapableCallers = new Map<string, readonly string[]>([
'src/renderer/src/components/settings/EphemeralVmsPane.tsx',
['EPHEMERAL_VMS_SKILL_UPDATE_COMMAND', 'installedCommand={updateCommand}']
],
[
'src/renderer/src/components/settings/CliAgentSkillSetup.tsx',
['ORCA_CLI_SKILL_UPDATE_COMMAND', 'installedCommand={cliSkillUpdateCommand}']
],
[
'src/renderer/src/components/settings/CliSection.tsx',
['ORCA_CLI_SKILL_UPDATE_COMMAND', 'installedCommand={cliSkillUpdateCommand}']
@@ -1,66 +0,0 @@
import type { ReactNode } from 'react'
import { Accessibility, Camera } from 'lucide-react'
import type {
ComputerUsePermissionId,
ComputerUsePermissionStatus
} from '../../../../shared/computer-use-permissions-types'
import { translate } from '@/i18n/i18n'
type PermissionDefinition = {
id: ComputerUsePermissionId
label: string
description: string
icon: ReactNode
}
export const COMPUTER_USE_PERMISSIONS: PermissionDefinition[] = [
{
id: 'accessibility',
get label() {
return translate('auto.components.settings.ComputerUsePane.6b5a2cd3a5', 'Accessibility')
},
get description() {
return translate(
'auto.components.settings.ComputerUsePane.4d03dec2d0',
'Read app interface trees and perform requested actions.'
)
},
icon: <Accessibility className="size-4" />
},
{
id: 'screenshots',
get label() {
return translate('auto.components.settings.ComputerUsePane.07bbe4c4cb', 'Screenshots')
},
get description() {
return translate(
'auto.components.settings.ComputerUsePane.0c9a33f468',
'Capture app windows so agents can inspect visual state.'
)
},
icon: <Camera className="size-4" />
}
]
export function getComputerUsePermissionStatusLabel(
status: ComputerUsePermissionStatus | undefined
): string {
switch (status) {
case 'granted':
return 'Granted'
case 'unsupported':
return 'macOS only'
case 'not-granted':
case undefined:
return 'Not enabled'
}
}
export function getComputerUsePermissionStatusClass(
status: ComputerUsePermissionStatus | undefined
): string {
if (status === 'granted') {
return 'border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300'
}
return 'border-border bg-muted text-muted-foreground'
}
@@ -1,25 +0,0 @@
import type { GlobalSettings } from '../../../../shared/types'
import { translate } from '@/i18n/i18n'
import { getSelectedAgentRuntime, type LocalAgentRuntime } from './CliSkillRuntimeSetup'
export type ComputerUseSkillRuntimeInput = {
settings?: GlobalSettings | null
wslSupportedPlatform?: boolean
wslAvailable?: boolean
wslCapabilitiesLoading?: boolean
}
export function getComputerUseSkillRuntime(input: ComputerUseSkillRuntimeInput): LocalAgentRuntime {
if (!input.settings) {
return {
runtime: 'host',
label: translate('auto.components.settings.computerUseSkillRuntime.thisDevice', 'This device')
}
}
return getSelectedAgentRuntime(
input.settings,
input.wslSupportedPlatform ?? false,
input.wslAvailable ?? false,
input.wslCapabilitiesLoading ?? false
)
}
@@ -1,69 +0,0 @@
import { translate } from '@/i18n/i18n'
type ComputerUseSummaryInput = {
checking: boolean
setupUnavailable: boolean
allGranted: boolean
helperUnavailableReason: string | null
requiredPermissionCount: number
}
export function getComputerUseSummary({
checking,
setupUnavailable,
allGranted,
helperUnavailableReason,
requiredPermissionCount
}: ComputerUseSummaryInput): { title: string; description: string } {
if (checking) {
return {
title: translate(
'auto.components.settings.computerUseSummary.checkingTitle',
'Checking Computer Use access.'
),
description: translate(
'auto.components.settings.computerUseSummary.checkingDescription',
'Orca is checking macOS privacy permissions for the Computer Use helper.'
)
}
}
if (setupUnavailable) {
return {
title: translate(
'auto.components.settings.computerUseSummary.unavailableTitle',
'Computer Use is unavailable.'
),
description: translate(
'auto.components.settings.computerUseSummary.unavailableDescription',
'Computer Use permissions are unavailable because {{value0}}.',
{ value0: helperUnavailableReason }
)
}
}
if (allGranted) {
return {
title: translate(
'auto.components.settings.computerUseSummary.readyTitle',
'Computer Use is ready.'
),
description: translate(
'auto.components.settings.computerUseSummary.readyDescription',
'Agents can inspect and operate app windows when you ask.'
)
}
}
return {
title: translate(
'auto.components.settings.computerUseSummary.permissionsTitle',
'Finish setup to use local apps.'
),
description: translate(
'auto.components.settings.computerUseSummary.permissionsRequired',
'{{value0}} permission{{value1}} required before agents can operate app windows.',
{
value0: requiredPermissionCount,
value1: requiredPermissionCount === 1 ? '' : 's'
}
)
}
}
@@ -1,72 +0,0 @@
import type React from 'react'
export type AddRepoCreateKind = 'git' | 'folder'
type AddRepoCreateKindCardProps = {
kind: AddRepoCreateKind
selected: boolean
disabled: boolean
onSelect: () => void
onArrowNav: () => void
icon: React.ReactNode
title: string
caption: string
}
export function AddRepoCreateKindCard({
kind,
selected,
disabled,
onSelect,
onArrowNav,
icon,
title,
caption
}: AddRepoCreateKindCardProps): React.JSX.Element {
return (
<button
type="button"
role="radio"
aria-checked={selected}
tabIndex={selected ? 0 : -1}
onClick={onSelect}
onKeyDown={(e) => {
// Why: WAI-ARIA radiogroup spec expects all four arrow keys to move
// selection, even if this specific layout is horizontal today.
if (
e.key === 'ArrowLeft' ||
e.key === 'ArrowRight' ||
e.key === 'ArrowUp' ||
e.key === 'ArrowDown'
) {
e.preventDefault()
onArrowNav()
} else if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault()
onSelect()
}
}}
disabled={disabled}
data-kind={kind}
className={`group relative flex cursor-pointer items-center gap-3 rounded-md border px-3.5 py-3.5 text-left text-xs transition-colors outline-none ${
selected ? 'border-foreground/30 bg-accent' : 'border-border hover:bg-accent/50'
} focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-60`}
>
<span
className={`inline-flex size-8 shrink-0 items-center justify-center rounded-md border transition-colors ${
selected
? 'border-foreground/20 bg-background/60 text-foreground'
: 'border-border/70 bg-background/30 text-muted-foreground group-hover:text-foreground'
}`}
>
{icon}
</span>
<span className="min-w-0">
<span className="block text-[13px] font-medium leading-tight">{title}</span>
<span className="mt-0.5 block text-[11px] leading-snug text-muted-foreground">
{caption}
</span>
</span>
</button>
)
}
@@ -1,89 +0,0 @@
import React, { useCallback } from 'react'
import { X } from 'lucide-react'
import { useAppStore } from '@/store'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { shouldShowProjectOrderManualDefaultNotice } from './project-order-manual-default-notice-visibility'
import { translate } from '@/i18n/i18n'
function ProjectOrderManualDefaultNotice(): React.JSX.Element | null {
const persistedUIReady = useAppStore((s) => s.persistedUIReady)
const projectOrderManualDefaultNoticeDismissed = useAppStore(
(s) => s.projectOrderManualDefaultNoticeDismissed
)
const dismissProjectOrderManualDefaultNotice = useAppStore(
(s) => s.dismissProjectOrderManualDefaultNotice
)
const groupBy = useAppStore((s) => s.groupBy)
const projectOrderBy = useAppStore((s) => s.projectOrderBy)
const repoCount = useAppStore((s) => s.repos.length)
const shouldShow = shouldShowProjectOrderManualDefaultNotice({
persistedUIReady,
projectOrderManualDefaultNoticeDismissed,
groupBy,
projectOrderBy,
repoCount
})
const handleDismiss = useCallback(() => {
dismissProjectOrderManualDefaultNotice()
}, [dismissProjectOrderManualDefaultNotice])
if (!shouldShow) {
return null
}
return (
<div className="shrink-0 px-3 pb-2 pt-2">
<div className="worktree-sidebar-notice-card worktree-sidebar-notice-card--to-section-title rounded-lg p-3 text-worktree-sidebar-foreground">
<div className="flex items-start justify-between gap-2">
<p className="min-w-0 text-sm font-semibold leading-snug text-worktree-sidebar-foreground">
{translate(
'auto.components.sidebar.ProjectOrderManualDefaultNotice.a1f4c2d8e0',
'Manual project order is now the default'
)}
</p>
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="ghost"
size="icon-xs"
aria-label={translate(
'auto.components.sidebar.ProjectOrderManualDefaultNotice.822ff300ad',
'Dismiss'
)}
className="-mr-1 -mt-0.5 shrink-0 text-worktree-sidebar-foreground/60"
onClick={handleDismiss}
>
<X className="size-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent side="top" sideOffset={4}>
{translate(
'auto.components.sidebar.ProjectOrderManualDefaultNotice.822ff300ad',
'Dismiss'
)}
</TooltipContent>
</Tooltip>
</div>
<p className="mt-1 text-xs leading-snug text-worktree-sidebar-foreground/60">
{translate(
'auto.components.sidebar.ProjectOrderManualDefaultNotice.b7e3a91c4f',
'Drag project headers to reorder, or switch to'
)}{' '}
<span className="font-medium text-worktree-sidebar-foreground">
{translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.b451c8b162', 'Recent')}
</span>{' '}
{translate(
'auto.components.sidebar.ProjectOrderManualDefaultNotice.e8c1f4a2b9',
'in workspace options.'
)}
</p>
</div>
</div>
)
}
export default React.memo(ProjectOrderManualDefaultNotice)
@@ -1,75 +0,0 @@
import React from 'react'
import { AlertTriangle, Loader2, X } from 'lucide-react'
import { useAppStore } from '@/store'
import { Button } from '@/components/ui/button'
import {
getSidebarHostVisibilityLabel,
shouldShowHostScopeControls,
type SidebarHostScopeOption
} from './sidebar-host-options'
import { useSidebarHostScopeOptions } from './use-sidebar-host-scope-options'
import { translate } from '@/i18n/i18n'
function HostScopeWarningIcon({ health }: { health: SidebarHostScopeOption['health'] }) {
// Why: the banner stays quiet unless the scoped host needs attention.
if (health === 'connecting') {
return <Loader2 className="size-3 shrink-0 animate-spin text-muted-foreground" />
}
if (health === 'blocked' || health === 'error') {
return <AlertTriangle className="size-3 shrink-0 text-destructive" />
}
return null
}
/** Shown only when the sidebar is scoped to a single host: names the scope and
* offers the way back. In All-hosts view the host section headers tell the
* story, so no persistent strip renders; scope switching lives in the
* workspace options menu. */
const SidebarHostScopeStrip = React.memo(function SidebarHostScopeStrip() {
const visibleWorkspaceHostIds = useAppStore((s) => s.visibleWorkspaceHostIds)
const setVisibleWorkspaceHostIds = useAppStore((s) => s.setVisibleWorkspaceHostIds)
const { hostOptions, hostScopeOptions } = useSidebarHostScopeOptions()
if (!visibleWorkspaceHostIds) {
return null
}
if (!shouldShowHostScopeControls(hostOptions)) {
return null
}
const label = getSidebarHostVisibilityLabel(visibleWorkspaceHostIds, hostOptions)
const selectedScope =
visibleWorkspaceHostIds.length === 1
? hostScopeOptions.find((option) => option.id === visibleWorkspaceHostIds[0])
: undefined
return (
<div className="px-2 pb-1">
<div className="flex h-7 w-full items-center justify-between gap-2 rounded-md border border-sidebar-border/70 bg-sidebar-accent/35 pl-2 pr-1">
<span className="flex min-w-0 items-center gap-1.5">
<HostScopeWarningIcon health={selectedScope?.health ?? 'available'} />
<span className="truncate text-xs font-medium text-sidebar-foreground">
{translate(
'auto.components.sidebar.SidebarHostScopeStrip.scopedTo',
'{{value0}} visible',
{
value0: label
}
)}
</span>
</span>
<Button
variant="ghost"
size="sm"
className="h-5 shrink-0 gap-1 rounded px-1.5 text-[11px] font-normal text-muted-foreground hover:text-foreground"
onClick={() => setVisibleWorkspaceHostIds(null)}
>
<X className="size-3" />
{translate('auto.components.sidebar.SidebarHostScopeStrip.backToAll', 'All hosts')}
</Button>
</div>
</div>
)
})
export default SidebarHostScopeStrip
@@ -1,60 +0,0 @@
import { useEffect } from 'react'
import type { RefObject } from 'react'
import { shouldAllowComposerEnterSubmitTarget } from '@/lib/new-workspace-enter-guard'
import { isScreenSubmitShortcut } from '@/lib/screen-submit-shortcut'
type UseFolderWorkspaceComposerKeyboardInput = {
open: boolean
submitting: boolean
composerRef: RefObject<HTMLDivElement | null>
onOpenChange: (open: boolean) => void
onCreate: () => void
}
export function useFolderWorkspaceComposerKeyboard({
open,
submitting,
composerRef,
onOpenChange,
onCreate
}: UseFolderWorkspaceComposerKeyboardInput): void {
useEffect(() => {
if (!open) {
return
}
const onKeyDown = (event: KeyboardEvent): void => {
if (event.key !== 'Enter' && event.key !== 'Escape') {
return
}
const target = event.target
if (!(target instanceof HTMLElement)) {
return
}
if (event.key === 'Escape') {
if (
target instanceof HTMLInputElement ||
target instanceof HTMLTextAreaElement ||
target instanceof HTMLSelectElement ||
target.isContentEditable
) {
event.preventDefault()
target.blur()
return
}
event.preventDefault()
onOpenChange(false)
return
}
if (!isScreenSubmitShortcut(event)) {
return
}
if (!shouldAllowComposerEnterSubmitTarget(target, composerRef.current) || submitting) {
return
}
event.preventDefault()
onCreate()
}
window.addEventListener('keydown', onKeyDown, { capture: true })
return () => window.removeEventListener('keydown', onKeyDown, { capture: true })
}, [composerRef, onCreate, onOpenChange, open, submitting])
}
@@ -1,125 +0,0 @@
import type { AgentActivityDisplayMode } from '../../../../shared/types'
import { translate } from '@/i18n/i18n'
export const GROUP_BY_OPTIONS = [
{
id: 'none',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.c2c7a45cda', 'None')
}
},
{
id: 'workspace-status',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.e029a2d775', 'Status')
}
},
{
id: 'pr-status',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.0f9b959b31', 'PR')
}
},
{
id: 'repo',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.2170d553cf', 'Project')
}
}
] as const
export const AGENT_ACTIVITY_DISPLAY_OPTIONS: { id: AgentActivityDisplayMode; label: string }[] = [
{
id: 'compact',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.25105b28cb', 'Compact')
}
},
{
id: 'full',
get label() {
return translate(
'auto.components.sidebar.SidebarWorkspaceOptionsMenu.2a81e07366',
'Full list'
)
}
}
]
export const SORT_OPTIONS = [
{
id: 'name',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.3728165cdd', 'Name')
},
description: null
},
{
id: 'smart',
get label() {
return translate(
'auto.components.sidebar.SidebarWorkspaceOptionsMenu.503462f2b4',
'Agent Activity'
)
},
get description() {
return translate(
'auto.components.sidebar.SidebarWorkspaceOptionsMenu.b759bb87ee',
'Agents that need attention, then most recent activity.'
)
}
},
{
id: 'recent',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.b451c8b162', 'Recent')
},
description: null
},
{
id: 'repo',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.2170d553cf', 'Project')
},
description: null
},
{
id: 'manual',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.7b316bdd51', 'Manual')
},
get description() {
return translate(
'auto.components.sidebar.SidebarWorkspaceOptionsMenu.7153d07485',
'Drag workspaces to arrange them within each group.'
)
}
}
] as const
export const PROJECT_ORDER_OPTIONS = [
{
id: 'manual',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.7b316bdd51', 'Manual')
},
get description() {
return translate(
'auto.components.sidebar.SidebarWorkspaceOptionsMenu.6664282a7b',
'Drag projects to arrange them'
)
}
},
{
id: 'recent',
get label() {
return translate('auto.components.sidebar.SidebarWorkspaceOptionsMenu.b451c8b162', 'Recent')
},
get description() {
return translate(
'auto.components.sidebar.SidebarWorkspaceOptionsMenu.af9249c505',
'Most recent workspace activity'
)
}
}
] as const
@@ -1,105 +0,0 @@
import { translate } from '@/i18n/i18n'
import { formatTokens } from './usage-formatters'
export type UsageSessionRow = {
sessionId: string
lastActiveAt: string
projectLabel: string
model: string | null
events?: number
turns?: number
inputTokens: number
outputTokens: number
cacheTokens?: number
totalTokens?: number
hasInferredPricing?: boolean
}
function formatSessionTime(timestamp: string): string {
const parsed = new Date(timestamp)
if (Number.isNaN(parsed.getTime())) {
return timestamp
}
return parsed.toLocaleString(undefined, {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit'
})
}
type UsageSessionsTableProps = {
sessions: UsageSessionRow[]
eventsColumn?: 'events' | 'turns'
tokensColumn?: 'cache' | 'total'
}
export function UsageSessionsTable({
sessions,
eventsColumn = 'events',
tokensColumn = 'total'
}: UsageSessionsTableProps): React.JSX.Element {
const eventsLabel =
eventsColumn === 'turns'
? translate('auto.components.stats.UsageSessionsTable.1afc25eb06', 'Turns')
: translate('auto.components.stats.UsageSessionsTable.0f03975d59', 'Events')
const tokensLabel =
tokensColumn === 'cache'
? translate('auto.components.stats.UsageSessionsTable.21ea00bfa8', 'Cache')
: translate('auto.components.stats.UsageSessionsTable.e0b988599d', 'Total')
return (
<div className="overflow-x-auto">
<table className="min-w-full text-sm">
<thead>
<tr className="border-b border-border/60 text-left text-xs text-muted-foreground">
<th className="px-2 py-2 font-medium">
{translate('auto.components.stats.UsageSessionsTable.01476891c7', 'Last active')}
</th>
<th className="px-2 py-2 font-medium">
{translate('auto.components.stats.UsageSessionsTable.c17bed0416', 'Project')}
</th>
<th className="px-2 py-2 font-medium">
{translate('auto.components.stats.UsageSessionsTable.f6a2c8d019', 'Model')}
</th>
<th className="px-2 py-2 font-medium">{eventsLabel}</th>
<th className="px-2 py-2 font-medium">
{translate('auto.components.stats.UsageSessionsTable.faf3444859', 'Input')}
</th>
<th className="px-2 py-2 font-medium">
{translate('auto.components.stats.UsageSessionsTable.a8b7487ff7', 'Output')}
</th>
<th className="px-2 py-2 font-medium">{tokensLabel}</th>
</tr>
</thead>
<tbody>
{sessions.map((row) => (
<tr key={row.sessionId} className="border-b border-border/40 last:border-b-0">
<td className="px-2 py-2 text-muted-foreground">
{formatSessionTime(row.lastActiveAt)}
</td>
<td className="px-2 py-2 text-foreground">{row.projectLabel}</td>
<td className="px-2 py-2 text-muted-foreground">
{row.model ??
translate('auto.components.stats.UsageSessionsTable.cfe2282ffa', 'Unknown')}
{row.hasInferredPricing ? ' *' : ''}
</td>
<td className="px-2 py-2 text-muted-foreground">
{eventsColumn === 'turns' ? row.turns : row.events}
</td>
<td className="px-2 py-2 text-muted-foreground">{formatTokens(row.inputTokens)}</td>
<td className="px-2 py-2 text-muted-foreground">{formatTokens(row.outputTokens)}</td>
<td className="px-2 py-2 text-muted-foreground">
{formatTokens(
tokensColumn === 'cache'
? (row.cacheTokens ?? 0)
: (row.totalTokens ?? row.inputTokens + row.outputTokens)
)}
</td>
</tr>
))}
</tbody>
</table>
</div>
)
}
@@ -1,20 +0,0 @@
import { isOrcaCliAvailableOnPath } from '@/lib/agent-skill-cli-prerequisite'
/**
* Whether the `orca` CLI will resolve on PATH in the terminal an agent launch
* is about to create. Used to gate launch-prompt hints that recommend `orca`
* commands, so prompts never point agents at a command that cannot run.
*/
export async function isOrcaCliAvailableForLaunch(args: { remote: boolean }): Promise<boolean> {
// Why: SSH worktrees always have the CLI — the relay deploys an `orca` shim
// and the remote PTY provider prepends it to PATH. Only local launches
// depend on the user's install state.
if (args.remote) {
return true
}
try {
return isOrcaCliAvailableOnPath(await window.api.cli.getInstallStatus())
} catch {
return false
}
}