From 7b63288f687c278c2bbfde25ff0825222b60319c Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 10 Apr 2026 13:52:46 -0700 Subject: [PATCH] feat: GitHub issue command automation for worktree creation (#441) * feat: add shared issue command config and worktree automation - Add shared top-level issue command support in orca.yaml with per-user .orca override read/write paths - Surface the issue command in repository settings and the create-worktree dialog - Queue issue-command terminal splits independently from setup-runner splits - Preserve user checkbox state and repo-switch draft saves for issue command configuration - Add parser, activation, and terminal-state test coverage for the new flow * fix: clarify custom issue command settings label * docs: clarify issue command effect behavior * docs: unify issue command examples * fix: keep issue command examples on one line * style: use direct useEffect import in add worktree dialog --- src/main/hooks.test.ts | 144 +++++++++-- src/main/hooks.ts | 203 ++++++++++++--- src/main/ipc/worktrees.ts | 28 +- src/preload/api-types.d.ts | 8 + src/preload/index.ts | 15 +- .../settings/RepositoryHooksSection.tsx | 239 +++++++++++++----- .../components/settings/RepositoryPane.tsx | 21 +- .../src/components/settings/general-search.ts | 4 +- .../components/sidebar/AddWorktreeDialog.tsx | 161 ++++++++++-- .../components/terminal-pane/TerminalPane.tsx | 12 + .../use-terminal-pane-lifecycle.ts | 41 ++- .../src/lib/worktree-activation.test.ts | 49 ++++ src/renderer/src/lib/worktree-activation.ts | 16 +- src/renderer/src/store/slices/terminals.ts | 52 +++- src/shared/types.ts | 1 + 15 files changed, 850 insertions(+), 144 deletions(-) diff --git a/src/main/hooks.test.ts b/src/main/hooks.test.ts index 0524dbeec..ec9e76e8c 100644 --- a/src/main/hooks.test.ts +++ b/src/main/hooks.test.ts @@ -7,7 +7,11 @@ import { parseOrcaYaml } from './hooks' // Mock fs and path used by loadHooks vi.mock('fs', () => ({ readFileSync: vi.fn(), - existsSync: vi.fn() + existsSync: vi.fn(), + mkdirSync: vi.fn(), + writeFileSync: vi.fn(), + rmSync: vi.fn(), + chmodSync: vi.fn() })) const { execMock, execFileMock } = vi.hoisted(() => ({ @@ -107,6 +111,123 @@ describe('parseOrcaYaml', () => { it('returns null for empty string', () => { expect(parseOrcaYaml('')).toBeNull() }) + + it('parses a top-level issueCommand block scalar', () => { + const yaml = [ + 'issueCommand: |', + ' claude -p "Read issue #{{issue}}"', + ' codex exec "Review docs/design-{{issue}}.md"' + ].join('\n') + const result = parseOrcaYaml(yaml) + expect(result).toEqual({ + scripts: {}, + issueCommand: + 'claude -p "Read issue #{{issue}}"\ncodex exec "Review docs/design-{{issue}}.md"' + }) + }) + + it('parses issueCommand alongside scripts', () => { + const yaml = [ + 'scripts:', + ' setup: |', + ' pnpm install', + 'issueCommand: |', + ' claude -p "Read issue #{{issue}}"' + ].join('\n') + const result = parseOrcaYaml(yaml) + expect(result).toEqual({ + scripts: { + setup: 'pnpm install' + }, + issueCommand: 'claude -p "Read issue #{{issue}}"' + }) + }) +}) + +describe('readIssueCommand', () => { + it('prefers the local override over the shared orca.yaml command', async () => { + const fs = await import('fs') + vi.mocked(fs.existsSync).mockImplementation( + (path) => path === '/test/repo/.orca/issue-command' || path === '/test/repo/orca.yaml' + ) + vi.mocked(fs.readFileSync).mockImplementation((path) => { + if (path === '/test/repo/.orca/issue-command') { + return 'local command\n' + } + if (path === '/test/repo/orca.yaml') { + return 'issueCommand: |\n shared command\n' + } + return '' + }) + + const { readIssueCommand } = await import('./hooks') + expect(readIssueCommand('/test/repo')).toEqual({ + localContent: 'local command', + sharedContent: 'shared command', + effectiveContent: 'local command', + localFilePath: '/test/repo/.orca/issue-command', + source: 'local' + }) + }) + + it('falls back to the shared orca.yaml command when no local override exists', async () => { + const fs = await import('fs') + vi.mocked(fs.existsSync).mockImplementation((path) => path === '/test/repo/orca.yaml') + vi.mocked(fs.readFileSync).mockImplementation((path) => { + if (path === '/test/repo/orca.yaml') { + return 'issueCommand: |\n shared command\n' + } + return '' + }) + + const { readIssueCommand } = await import('./hooks') + expect(readIssueCommand('/test/repo')).toEqual({ + localContent: null, + sharedContent: 'shared command', + effectiveContent: 'shared command', + localFilePath: '/test/repo/.orca/issue-command', + source: 'shared' + }) + }) +}) + +describe('writeIssueCommand', () => { + it('writes only the local override file and keeps .orca ignored locally', async () => { + const fs = await import('fs') + vi.mocked(fs.existsSync).mockImplementation( + (path) => path === '/test/repo/.gitignore' || path === '/test/repo/.orca' + ) + vi.mocked(fs.readFileSync).mockImplementation((path) => { + if (path === '/test/repo/.gitignore') { + return 'node_modules/\n' + } + return '' + }) + + const { writeIssueCommand } = await import('./hooks') + writeIssueCommand('/test/repo', 'local command') + + expect(vi.mocked(fs.writeFileSync)).toHaveBeenCalledWith( + '/test/repo/.gitignore', + 'node_modules/\n.orca\n', + 'utf-8' + ) + expect(vi.mocked(fs.writeFileSync)).toHaveBeenCalledWith( + '/test/repo/.orca/issue-command', + 'local command\n', + 'utf-8' + ) + }) + + it('deletes the local override when the override is cleared', async () => { + const fs = await import('fs') + const { writeIssueCommand } = await import('./hooks') + writeIssueCommand('/test/repo', ' ') + + expect(vi.mocked(fs.rmSync)).toHaveBeenCalledWith('/test/repo/.orca/issue-command', { + force: true + }) + }) }) describe('getEffectiveHooks', () => { @@ -347,26 +468,15 @@ describe('runHook', () => { try { const { runHook } = await import('./hooks') - const result = await runHook( - 'setup', - '\\\\wsl.localhost\\Ubuntu\\home\\jin\\feature', - { - ...makeRepo(), - path: 'C:\\Users\\jinwo\\git\\orca' - } - ) + const result = await runHook('setup', '\\\\wsl.localhost\\Ubuntu\\home\\jin\\feature', { + ...makeRepo(), + path: 'C:\\Users\\jinwo\\git\\orca' + }) expect(result).toEqual({ success: true, output: '' }) expect(execFileMock).toHaveBeenCalledWith( 'wsl.exe', - [ - '-d', - 'Ubuntu', - '--', - 'bash', - '-c', - "cd '/home/jin/feature' && echo hello" - ], + ['-d', 'Ubuntu', '--', 'bash', '-c', "cd '/home/jin/feature' && echo hello"], expect.any(Object), expect.any(Function) ) diff --git a/src/main/hooks.ts b/src/main/hooks.ts index ede5e87d6..6dab3228c 100644 --- a/src/main/hooks.ts +++ b/src/main/hooks.ts @@ -1,4 +1,5 @@ -import { readFileSync, existsSync, mkdirSync, writeFileSync, chmodSync } from 'fs' +/* eslint-disable max-lines -- Why: hook parsing, layered issue-command resolution, and cross-platform runner setup share one execution surface, so keeping them together avoids subtle drift across create/read/write paths. */ +import { readFileSync, existsSync, mkdirSync, writeFileSync, chmodSync, rmSync } from 'fs' import { dirname, join } from 'path' import { exec, execFile } from 'child_process' import { getDefaultRepoHookSettings } from '../shared/constants' @@ -23,56 +24,84 @@ function getHookShell(): string | undefined { } /** - * Parse a simple orca.yaml file. Handles only the `scripts:` block with - * multiline string values (YAML block scalar `|`). + * Parse a simple orca.yaml file. Handles only the supported `scripts:` and + * `issueCommand:` keys with multiline string values (YAML block scalar `|`). */ export function parseOrcaYaml(content: string): OrcaHooks | null { const hooks: OrcaHooks = { scripts: {} } + const lines = content.split(/\r?\n/) - // Match top-level "scripts:" block - const scriptsMatch = content.match(/^scripts:\s*$/m) - if (!scriptsMatch) { - return null - } - - const afterScripts = content.slice(scriptsMatch.index! + scriptsMatch[0].length) - // [Fix]: Split using /\r?\n/ instead of '\n'. Otherwise, on Windows, trailing \r characters - // stay attached to script commands, which causes fatal '\r command not found' errors in WSL/bash. - const lines = afterScripts.split(/\r?\n/) - + let currentSection: 'scripts' | 'issueCommand' | null = null let currentKey: 'setup' | 'archive' | null = null - let currentValue = '' + let issueCommandValue = '' for (const line of lines) { - // Another top-level key (not indented) — stop parsing scripts block - if (/^\S/.test(line) && line.trim().length > 0) { - break - } - - // Indented key like " setup: |" or " archive: |" or " setup: echo hello" - const keyMatch = line.match(/^ (setup|archive):\s*(\|)?\s*(.*)$/) - if (keyMatch) { - // Save previous key - if (currentKey) { - hooks.scripts[currentKey] = currentValue.trimEnd() + const topLevelKeyMatch = line.match(/^([A-Za-z][A-Za-z0-9_-]*):\s*(\|)?\s*(.*)$/) + if (topLevelKeyMatch) { + if (currentSection === 'scripts' && currentKey) { + hooks.scripts[currentKey] = issueCommandValue.trimEnd() + } else if (currentSection === 'issueCommand') { + hooks.issueCommand = issueCommandValue.trimEnd() || undefined } - currentKey = keyMatch[1] as 'setup' | 'archive' - currentValue = keyMatch[3] ? `${keyMatch[3]}\n` : '' + + const [, key, blockScalar, rest] = topLevelKeyMatch + currentKey = null + issueCommandValue = '' + + if (key === 'scripts') { + currentSection = 'scripts' + continue + } + + if (key === 'issueCommand') { + currentSection = 'issueCommand' + if (blockScalar) { + continue + } + hooks.issueCommand = rest.trim() || undefined + currentSection = null + continue + } + + currentSection = null continue } - // Content line (indented by 4+ spaces under a key) - if (currentKey && line.startsWith(' ')) { - currentValue += `${line.slice(4)}\n` + if (currentSection === 'scripts') { + // Indented key like " setup: |" or " archive: |" or " setup: echo hello" + const keyMatch = line.match(/^ (setup|archive):\s*(\|)?\s*(.*)$/) + if (keyMatch) { + // Save previous key + if (currentKey) { + hooks.scripts[currentKey] = issueCommandValue.trimEnd() + } + currentKey = keyMatch[1] as 'setup' | 'archive' + issueCommandValue = keyMatch[3] ? `${keyMatch[3]}\n` : '' + continue + } + + // Content line (indented by 4+ spaces under a key) + if (currentKey && line.startsWith(' ')) { + issueCommandValue += `${line.slice(4)}\n` + } + continue + } + + if (currentSection === 'issueCommand' && line.startsWith(' ')) { + // Why: `issueCommand` is a top-level scalar in `orca.yaml`, so its block + // content must stay separate from the `scripts:` parser rather than being + // shoehorned into that section's indentation rules. + issueCommandValue += `${line.slice(2)}\n` } } - // Save last key - if (currentKey) { - hooks.scripts[currentKey] = currentValue.trimEnd() + if (currentSection === 'scripts' && currentKey) { + hooks.scripts[currentKey] = issueCommandValue.trimEnd() + } else if (currentSection === 'issueCommand') { + hooks.issueCommand = issueCommandValue.trimEnd() || undefined } - if (!hooks.scripts.setup && !hooks.scripts.archive) { + if (!hooks.scripts.setup && !hooks.scripts.archive && !hooks.issueCommand) { return null } return hooks @@ -102,6 +131,110 @@ export function hasHooksFile(repoPath: string): boolean { return existsSync(join(repoPath, 'orca.yaml')) } +// ─── Issue command files ──────────────────────────────────────────────── +// Why: `orca.yaml` is the tracked, project-wide defaults surface, while +// `.orca/issue-command` remains the per-user override. Keeping the local file in +// `.orca/` lets users customize agent automation without editing committed config. + +const ORCA_DIR = '.orca' +const ISSUE_COMMAND_FILENAME = 'issue-command' + +export function getIssueCommandFilePath(repoPath: string): string { + return join(repoPath, ORCA_DIR, ISSUE_COMMAND_FILENAME) +} + +export function getSharedIssueCommand(repoPath: string): string | null { + return loadHooks(repoPath)?.issueCommand?.trim() || null +} + +export type ResolvedIssueCommand = { + localContent: string | null + sharedContent: string | null + effectiveContent: string | null + localFilePath: string + source: 'local' | 'shared' | 'none' +} + +/** + * Resolve the GitHub issue command using local override first, then tracked repo config. + */ +export function readIssueCommand(repoPath: string): ResolvedIssueCommand { + const filePath = getIssueCommandFilePath(repoPath) + let localContent: string | null = null + + if (existsSync(filePath)) { + try { + const content = readFileSync(filePath, 'utf-8').trim() + localContent = content || null + } catch { + localContent = null + } + } + + const sharedContent = getSharedIssueCommand(repoPath) + const effectiveContent = localContent ?? sharedContent + + return { + localContent, + sharedContent, + effectiveContent, + localFilePath: filePath, + source: localContent ? 'local' : sharedContent ? 'shared' : 'none' + } +} + +/** + * Write the per-user issue command override to `{repoRoot}/.orca/issue-command`. + * Creates `.orca/` and ensures it is in `.gitignore` on first write. + * If content is empty, deletes only the override so the shared `orca.yaml` + * command becomes effective again. + */ +export function writeIssueCommand(repoPath: string, content: string): void { + const filePath = getIssueCommandFilePath(repoPath) + const trimmed = content.trim() + + try { + if (!trimmed) { + rmSync(filePath, { force: true }) + return + } + + const orcaDir = join(repoPath, ORCA_DIR) + if (!existsSync(orcaDir)) { + mkdirSync(orcaDir, { recursive: true }) + } + ensureOrcaDirIgnored(repoPath) + writeFileSync(filePath, `${trimmed}\n`, 'utf-8') + } catch (err) { + console.error('[hooks] Failed to write issue command:', err) + // Why: re-throw so the error propagates through the IPC handler to the + // renderer, which already has .catch() ready to surface write failures. + throw err + } +} + +/** + * Ensure `.orca` is listed in the repo's `.gitignore` so the per-user + * directory is never accidentally committed. + */ +function ensureOrcaDirIgnored(repoPath: string): void { + const gitignorePath = join(repoPath, '.gitignore') + try { + if (existsSync(gitignorePath)) { + const content = readFileSync(gitignorePath, 'utf-8') + if (/^\.orca\/?$/m.test(content)) { + return + } + const separator = content.endsWith('\n') ? '' : '\n' + writeFileSync(gitignorePath, `${content}${separator}.orca\n`, 'utf-8') + } else { + writeFileSync(gitignorePath, '.orca\n', 'utf-8') + } + } catch { + console.warn('[hooks] Could not update .gitignore to exclude .orca') + } +} + export function getEffectiveHooks(repo: Repo): OrcaHooks | null { const yamlHooks = loadHooks(repo.path) const legacySetup = repo.hookSettings?.scripts.setup?.trim() diff --git a/src/main/ipc/worktrees.ts b/src/main/ipc/worktrees.ts index 6fe616aa6..f1d4358ec 100644 --- a/src/main/ipc/worktrees.ts +++ b/src/main/ipc/worktrees.ts @@ -20,9 +20,11 @@ import { createSetupRunnerScript, getEffectiveHooks, loadHooks, + readIssueCommand, runHook, hasHooksFile, - shouldRunSetupForCreate + shouldRunSetupForCreate, + writeIssueCommand } from '../hooks' import { sanitizeWorktreeName, @@ -48,6 +50,8 @@ export function registerWorktreeHandlers(mainWindow: BrowserWindow, store: Store ipcMain.removeHandler('worktrees:updateMeta') ipcMain.removeHandler('worktrees:persistSortOrder') ipcMain.removeHandler('hooks:check') + ipcMain.removeHandler('hooks:readIssueCommand') + ipcMain.removeHandler('hooks:writeIssueCommand') ipcMain.handle('worktrees:listAll', async () => { // Why: use ensureAuthorizedRootsCache (not rebuild) to avoid redundantly @@ -307,6 +311,28 @@ export function registerWorktreeHandlers(mainWindow: BrowserWindow, store: Store hooks } }) + + ipcMain.handle('hooks:readIssueCommand', (_event, args: { repoId: string }) => { + const repo = store.getRepo(args.repoId) + if (!repo || isFolderRepo(repo)) { + return { + localContent: null, + sharedContent: null, + effectiveContent: null, + localFilePath: '', + source: 'none' as const + } + } + return readIssueCommand(repo.path) + }) + + ipcMain.handle('hooks:writeIssueCommand', (_event, args: { repoId: string; content: string }) => { + const repo = store.getRepo(args.repoId) + if (!repo || isFolderRepo(repo)) { + return + } + writeIssueCommand(repo.path, args.content) + }) } function notifyWorktreesChanged(mainWindow: BrowserWindow, repoId: string): void { diff --git a/src/preload/api-types.d.ts b/src/preload/api-types.d.ts index 8db49e63b..cbe183adb 100644 --- a/src/preload/api-types.d.ts +++ b/src/preload/api-types.d.ts @@ -224,6 +224,14 @@ export type PreloadApi = { browser: BrowserApi hooks: { check: (args: { repoId: string }) => Promise<{ hasHooks: boolean; hooks: OrcaHooks | null }> + readIssueCommand: (args: { repoId: string }) => Promise<{ + localContent: string | null + sharedContent: string | null + effectiveContent: string | null + localFilePath: string + source: 'local' | 'shared' | 'none' + }> + writeIssueCommand: (args: { repoId: string; content: string }) => Promise } cache: { getGitHub: () => Promise<{ diff --git a/src/preload/index.ts b/src/preload/index.ts index 6f6e5d10a..b4a7a3a0f 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -335,7 +335,20 @@ const api = { hooks: { check: (args: { repoId: string }): Promise<{ hasHooks: boolean; hooks: unknown }> => - ipcRenderer.invoke('hooks:check', args) + ipcRenderer.invoke('hooks:check', args), + + readIssueCommand: (args: { + repoId: string + }): Promise<{ + localContent: string | null + sharedContent: string | null + effectiveContent: string | null + localFilePath: string + source: 'local' | 'shared' | 'none' + }> => ipcRenderer.invoke('hooks:readIssueCommand', args), + + writeIssueCommand: (args: { repoId: string; content: string }): Promise => + ipcRenderer.invoke('hooks:writeIssueCommand', args) }, cache: { diff --git a/src/renderer/src/components/settings/RepositoryHooksSection.tsx b/src/renderer/src/components/settings/RepositoryHooksSection.tsx index 6d3a7cf10..7bec883ea 100644 --- a/src/renderer/src/components/settings/RepositoryHooksSection.tsx +++ b/src/renderer/src/components/settings/RepositoryHooksSection.tsx @@ -1,7 +1,8 @@ +import { useCallback, useEffect, useRef, useState } from 'react' import type { OrcaHooks, Repo, SetupRunPolicy } from '../../../../shared/types' import { AlertTriangle } from 'lucide-react' +import { toast } from 'sonner' import { Button } from '../ui/button' -import { DEFAULT_REPO_HOOK_SETTINGS } from './SettingsConstants' import { SearchableSetting } from './SearchableSetting' type RepositoryHooksSectionProps = { @@ -14,21 +15,11 @@ type RepositoryHooksSectionProps = { onUpdateSetupRunPolicy: (policy: SetupRunPolicy) => void } -const SETUP_RUN_POLICY_OPTIONS: { - policy: SetupRunPolicy - label: string - description: string -}[] = [ - { - policy: 'ask', - label: 'Ask every time', - description: 'Prompt before running setup.' - }, - { - policy: 'run-by-default', - label: 'Run by default', - description: 'Run setup automatically.' - }, +type PolicyOption

= { policy: P; label: string; description: string } + +const SETUP_RUN_POLICY_OPTIONS: PolicyOption[] = [ + { policy: 'ask', label: 'Ask every time', description: 'Prompt before running setup.' }, + { policy: 'run-by-default', label: 'Run by default', description: 'Run setup automatically.' }, { policy: 'skip-by-default', label: 'Skip by default', @@ -40,7 +31,50 @@ const EXAMPLE_TEMPLATE = `scripts: setup: | pnpm worktree:setup archive: | - echo "Cleaning up before archive"` + echo "Cleaning up before archive" +issueCommand: | + claude -p "Read issue #{{issue}} and write a design doc to docs/design-{{issue}}.md covering the approach, edge cases, and test plan." && codex exec "Review docs/design-{{issue}}.md for gaps, missing edge cases, or unclear requirements. Add feedback at the bottom."` + +/** Shared button grid for setup run-policy selectors. */ +function PolicyOptionGrid

({ + options, + selected, + onSelect, + columns +}: { + options: PolicyOption

[] + selected: P + onSelect: (p: P) => void + columns: string +}): React.JSX.Element { + return ( +

+ {options.map(({ policy, label, description }) => { + const active = selected === policy + return ( + + ) + })} +
+ ) +} function ExampleTemplateCard({ copiedTemplate, @@ -84,11 +118,78 @@ export function RepositoryHooksSection({ onUpdateSetupRunPolicy }: RepositoryHooksSectionProps): React.JSX.Element { const yamlState = yamlHooks ? 'loaded' : hasHooksFile ? 'invalid' : 'missing' + const hs = repo.hookSettings const legacyHookEntries = (['setup', 'archive'] as const) - .map((hookName) => [hookName, repo.hookSettings?.scripts[hookName]?.trim() ?? ''] as const) + .map((hookName) => [hookName, hs?.scripts[hookName]?.trim() ?? ''] as const) .filter(([, script]) => Boolean(script)) - const selectedSetupRunPolicy = - repo.hookSettings?.setupRunPolicy ?? DEFAULT_REPO_HOOK_SETTINGS.setupRunPolicy + // Why: the type allows `undefined` in persisted settings for backward compatibility, + // but the UI always needs a concrete value so the policy grid has an active selection. + const selectedSetupRunPolicy: SetupRunPolicy = hs?.setupRunPolicy ?? 'run-by-default' + const [issueCommandDraft, setIssueCommandDraft] = useState('') + const [hasSharedIssueCommand, setHasSharedIssueCommand] = useState(false) + const [issueCommandSaveError, setIssueCommandSaveError] = useState(null) + // Why: track the latest draft across blur/unmount so repo switches still + // persist the user's local override without racing the next repo's state load. + const issueCommandDraftRef = useRef(issueCommandDraft) + issueCommandDraftRef.current = issueCommandDraft + const lastCommittedIssueCommandRef = useRef('') + + // Keep the local override editor in sync with the selected repo and flush unsaved edits on exit. + useEffect(() => { + let cancelled = false + const repoId = repo.id + + setIssueCommandDraft('') + setHasSharedIssueCommand(false) + setIssueCommandSaveError(null) + + // Why: settings only edit the local override, but we still need to know + // whether `orca.yaml` defines a shared default so the helper copy can + // explain what happens when the override is blank. + void window.api.hooks + .readIssueCommand({ repoId }) + .then((result) => { + if (cancelled) { + return + } + const localContent = result.localContent ?? '' + setIssueCommandDraft(localContent) + setHasSharedIssueCommand(Boolean(result.sharedContent)) + lastCommittedIssueCommandRef.current = localContent + }) + .catch(() => { + if (!cancelled) { + setIssueCommandDraft('') + setHasSharedIssueCommand(false) + lastCommittedIssueCommandRef.current = '' + } + }) + + return () => { + cancelled = true + const draft = issueCommandDraftRef.current.trim() + if (draft !== lastCommittedIssueCommandRef.current) { + void window.api.hooks.writeIssueCommand({ repoId, content: draft }).catch((err) => { + console.error('[RepositoryHooksSection] Failed to save issue command on unmount:', err) + }) + } + } + }, [repo.id]) + + const commitIssueCommand = useCallback(async (): Promise => { + const trimmed = issueCommandDraft.trim() + setIssueCommandDraft(trimmed) + try { + await window.api.hooks.writeIssueCommand({ repoId: repo.id, content: trimmed }) + lastCommittedIssueCommandRef.current = trimmed + setIssueCommandSaveError(null) + } catch (err) { + console.error('[RepositoryHooksSection] Failed to write issue command:', err) + const message = err instanceof Error ? err.message : 'Failed to save GitHub issue command.' + setIssueCommandSaveError(message) + toast.error(message) + } + }, [issueCommandDraft, repo.id]) return (
@@ -102,7 +203,7 @@ export function RepositoryHooksSection({

{yamlState === 'loaded' - ? 'Hook commands are defined in the repo and shared with everyone who uses it.' + ? 'Shared hook and issue-automation defaults are defined in the repo and available to everyone who uses it.' : yamlState === 'invalid' ? 'The core configuration file exists in the repo root, but Orca could not parse the supported hook definitions yet.' - : 'Add an `orca.yaml` file to enable setup or archive hooks for this repo. Example template:'} + : 'Add an `orca.yaml` file to enable shared setup, archive, or issue-automation defaults for this repo. Example template:'}

@@ -147,7 +248,7 @@ export function RepositoryHooksSection({

- Edit `orca.yaml` in the repository if you need to change these commands. + Edit `orca.yaml` in the repository if you need to change these shared commands.

) : yamlState === 'invalid' ? ( @@ -165,7 +266,7 @@ export function RepositoryHooksSection({ {/* Why: once a repo has an `orca.yaml`, the failure mode is usually bad shape rather than a missing concept. Showing a repair-oriented explanation and template here lets maintainers fix the committed file without needing the doc. */} - The file is present, but Orca could not find valid `setup` or `archive` hook + The file is present, but Orca could not find valid `scripts` or `issueCommand` definitions in the expected format.

@@ -252,33 +353,45 @@ export function RepositoryHooksSection({

-
- {SETUP_RUN_POLICY_OPTIONS.map(({ policy, label, description }) => { - const selected = selectedSetupRunPolicy === policy + +
+
- return ( - - ) - })} + +
+
+
Custom GitHub Issue Command
+
+
+