diff --git a/src/main/computer/macos-app-catalog.ts b/src/main/computer/macos-app-catalog.ts deleted file mode 100644 index 1b7fcb233..000000000 --- a/src/main/computer/macos-app-catalog.ts +++ /dev/null @@ -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 { - 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 - 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() - 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 }) - }) - }) -} diff --git a/src/main/gitlab/glab-known-hosts.ts b/src/main/gitlab/glab-known-hosts.ts deleted file mode 100644 index 157e579ed..000000000 --- a/src/main/gitlab/glab-known-hosts.ts +++ /dev/null @@ -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, - connectionId?: string | null -): Promise { - 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 { - 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() - 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) -} diff --git a/src/renderer/src/components/feature-wall/ComputerUseAnimatedVisual.tsx b/src/renderer/src/components/feature-wall/ComputerUseAnimatedVisual.tsx deleted file mode 100644 index b1a3c4742..000000000 --- a/src/renderer/src/components/feature-wall/ComputerUseAnimatedVisual.tsx +++ /dev/null @@ -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(null) - const buttonRef = useRef(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 ( -
- - -
-
- - - - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.9cddfe96b2', - 'Local app' - )} - -
- -
-
-
-
-
-
-
- - {verified - ? translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.c11dda000b', - 'Approved' - ) - : translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.bdd5312213', - 'Pending' - )} - -
-
- -
-
- -
-
-
-
-
-
- {clicked - ? translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.3cc2df3671', - 'Done' - ) - : translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.9634d870d1', - 'Approve' - )} -
-
-
- - -
-
-
-
- ) -} - -function AgentWorktreeTerminal(props: { - phase: ComputerUsePhase - targetVisible: boolean - clicked: boolean - verified: boolean -}): JSX.Element { - return ( -
-
- - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.94787f01f8', - 'Claude Code' - )} - - - - {WORKTREE_LABEL} - -
-
- - ● - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.2adb561b44', - 'Claude Code session started' - )} - - - - {translate('auto.components.feature.wall.ComputerUseAnimatedVisual.99a8624bcb', '>')} - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.79445f7512', - 'approve the note in my app' - )} - - - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.1719b28a81', - 'found "Approve"' - )} - [#7] - - - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.6804cb356f', - 'click sent' - )} - - - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.f27676a92c', - 'status:' - )} - - {translate( - 'auto.components.feature.wall.ComputerUseAnimatedVisual.d8401975b1', - 'approved' - )} - - -
-
- ) -} - -function ComputerActionLine(props: { - action: string - target: string - active: boolean - done: boolean -}): JSX.Element { - return ( - - {props.done ? ✓ : } - {props.action} - {props.target} - - ) -} - -function TerminalLine(props: { - children: ReactNode - muted?: boolean - wrap?: boolean - indent?: boolean - visible?: boolean -}): JSX.Element { - const visible = props.visible ?? true - return ( -
- {props.children} -
- ) -} - -function RunSpinner(): JSX.Element { - return ( - - ) -} - -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 => - new Promise((resolve) => { - const id = window.setTimeout(() => resolve(), ms) - timeouts.push(id) - }) - - setIdx(0) - async function loop(): Promise { - 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 ( -
-
-
-
- ) -} - -function ComputerUseCursor(props: { - visible: boolean - x: number - y: number - isClick: boolean -}): JSX.Element { - return ( -
- - {props.isClick ? : null} -
- ) -} diff --git a/src/renderer/src/components/github/CloseReasonDropdown.tsx b/src/renderer/src/components/github/CloseReasonDropdown.tsx deleted file mode 100644 index 6002529cb..000000000 --- a/src/renderer/src/components/github/CloseReasonDropdown.tsx +++ /dev/null @@ -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 ( - - - - - - {CLOSE_ISSUE_REASONS.map((option) => ( - onCloseReasonChange(option.reason)}> -
- {closeReason === option.reason ? ( - - ) : ( - - )} -
-
- {option.icon} - {option.label} -
-

{option.description}

-
-
-
- ))} -
-
- ) -} diff --git a/src/renderer/src/components/github/GitHubIssueCommentComposer.tsx b/src/renderer/src/components/github/GitHubIssueCommentComposer.tsx deleted file mode 100644 index 7b77f4b1e..000000000 --- a/src/renderer/src/components/github/GitHubIssueCommentComposer.tsx +++ /dev/null @@ -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 | 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('completed') - const [viewer, setViewer] = useState(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 ? ( - {viewer.login} - ) : ( -
- ) - const canSubmitComment = hasBoundedCommentBodyText(body) - - return ( -
-
- {avatar} -
-

- {translate( - 'auto.components.github.GitHubIssueCommentComposer.a1b2c3d4e5', - 'Add a comment' - )} -

- void handleSubmit()} - /> -
- {canMutateIssueState ? ( - - - { - setCloseReason(reason) - void handleCloseIssue(reason) - }} - /> - - ) : null} - {canReopenIssue ? ( - - ) : null} - -
-
-
-
- ) -} diff --git a/src/renderer/src/components/github/GitHubWorkItemAssigneePopoverContent.tsx b/src/renderer/src/components/github/GitHubWorkItemAssigneePopoverContent.tsx deleted file mode 100644 index bfdc5fb75..000000000 --- a/src/renderer/src/components/github/GitHubWorkItemAssigneePopoverContent.tsx +++ /dev/null @@ -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 = ( - - - -) - -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
{error}
- } - - const emptyText = loading - ? translate( - 'auto.components.github.GitHubWorkItemAssigneePopoverContent.cddd9b04a7', - 'Loading assignees' - ) - : translate( - 'auto.components.github.GitHubWorkItemAssigneePopoverContent.a00830d3f7', - 'No users' - ) - - return ( - - - - - {emptyText} - - {filteredAssignees.map((user) => { - const isSelected = selectedSet.has(user.login) - return ( - onToggleAssignee(user.login)} - className="flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px]" - > - - {isSelected ? assigneeCheckIcon : null} - - - {user.login} - {user.name ? ( - - {user.name} - - ) : null} - - - ) - })} - - - ) -} diff --git a/src/renderer/src/components/github/GitHubWorkItemLabelPopoverContent.tsx b/src/renderer/src/components/github/GitHubWorkItemLabelPopoverContent.tsx deleted file mode 100644 index ff0612e86..000000000 --- a/src/renderer/src/components/github/GitHubWorkItemLabelPopoverContent.tsx +++ /dev/null @@ -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 = ( - - - -) - -function GitHubLabelsSettingsLink({ - url, - separated, - onOpen -}: { - url: string | null - separated?: boolean - onOpen?: () => void -}): React.JSX.Element | null { - if (!url) { - return null - } - - return ( -
- -
- ) -} - -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
{error}
- } - - const emptyText = loading - ? translate( - 'auto.components.github.GitHubWorkItemLabelPopoverContent.cddd9b04a7', - 'Loading labels' - ) - : translate('auto.components.github.GitHubWorkItemLabelPopoverContent.de26e2eb06', 'No labels') - - return ( - <> - - - - - {emptyText} - - {filteredLabels.map((label) => { - const isSelected = selectedSet.has(label) - return ( - onToggleLabel(label)} - className="flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px]" - > - - {isSelected ? labelCheckIcon : null} - - {label} - - ) - })} - - - 0} - onOpen={onOpenSettingsLink} - /> - - ) -} diff --git a/src/renderer/src/components/github/github-issue-close-reasons.tsx b/src/renderer/src/components/github/github-issue-close-reasons.tsx deleted file mode 100644 index 921e62d7f..000000000 --- a/src/renderer/src/components/github/github-issue-close-reasons.tsx +++ /dev/null @@ -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: - }, - { - 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: - }, - { - 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: - } -] diff --git a/src/renderer/src/components/onboarding/OnboardingTourStep.tsx b/src/renderer/src/components/onboarding/OnboardingTourStep.tsx deleted file mode 100644 index a9f2b4306..000000000 --- a/src/renderer/src/components/onboarding/OnboardingTourStep.tsx +++ /dev/null @@ -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 - onExitTour: () => void - onTourDepthSummaryChange: (summary: FeatureWallTourDepthSummary) => void -} - -type ViewTransition = { - finished: Promise -} - -type DocumentWithOptionalViewTransition = Document & { - startViewTransition?: (updateCallback: () => void | Promise) => 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 ( - - {translate('auto.components.onboarding.OnboardingTourStep.60c5576353', 'Exit tour')} - - } - /> - ) - } - - return ( -
- - -
- ) -} diff --git a/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx b/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx deleted file mode 100644 index 8db272584..000000000 --- a/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx +++ /dev/null @@ -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 - onBranchChangedByGeneration: () => Promise - onCreated: (result: { - provider: HostedReviewProvider - number: number - url: string - }) => Promise -} - -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(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 => { - 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 ( - - - -
- - {translate( - 'auto.components.right.sidebar.CreatePullRequestDialog.db9cee18f7', - 'Create {{value0}}', - { value0: copy.titleLabel } - )} - - {aiGenerationEnabled ? ( - void handleGenerate()} - onCancelGenerate={handleCancelGenerate} - /> - ) : null} -
- - {translate( - 'auto.components.right.sidebar.CreatePullRequestDialog.f658ff2455', - 'Confirm the target branch and {{value0}} details before creating the hosted review.', - { value0: copy.shortLabel } - )} - -
- - - - - - - -
-
- ) -} diff --git a/src/renderer/src/components/right-sidebar/CreatePullRequestDialogForm.tsx b/src/renderer/src/components/right-sidebar/CreatePullRequestDialogForm.tsx deleted file mode 100644 index 75f128d1f..000000000 --- a/src/renderer/src/components/right-sidebar/CreatePullRequestDialogForm.tsx +++ /dev/null @@ -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 ( -
-
- -
- {branch} -
-
- -
-
- -

- {translate( - 'auto.components.right.sidebar.CreatePullRequestDialog.0fad57a14c', - 'Search remote branches or enter a branch name.' - )} -

-
-
- { - setBaseQuery(event.target.value) - setBase(event.target.value) - }} - placeholder={translate( - 'auto.components.right.sidebar.CreatePullRequestDialog.694550a610', - 'main' - )} - aria-invalid={!base.trim()} - className="pr-8" - /> - -
- {baseSearchError ?

{baseSearchError}

: null} - {baseResults.length > 0 ? ( -
- {baseResults.map((ref) => ( - - ))} -
- ) : null} -
- -
- - setTitle(event.target.value)} - placeholder={translate( - 'auto.components.right.sidebar.CreatePullRequestDialog.68314b4369', - 'Title' - )} - aria-invalid={!title.trim()} - /> -
- -
- -