mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
refactor(renderer): reuse existing control paths (#13425)
This commit is contained in:
@@ -183,34 +183,6 @@ export function useGrabMode(browserPageId: string): GrabModeHook {
|
||||
}
|
||||
}, [mountedRef])
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
if ((state === 'idle' || state === 'error') && grabTabIdRef.current === null) {
|
||||
setError(null)
|
||||
setPayload(null)
|
||||
setContextMenu(false)
|
||||
void armAndAwait()
|
||||
} else {
|
||||
// Disable grab mode
|
||||
const targetTabId = grabTabIdRef.current ?? browserTabIdRef.current
|
||||
armGenerationRef.current += 1
|
||||
void window.api.browser.setGrabMode({
|
||||
browserPageId: targetTabId,
|
||||
enabled: false
|
||||
})
|
||||
if (activeOpIdRef.current) {
|
||||
void window.api.browser.cancelGrab({
|
||||
browserPageId: targetTabId
|
||||
})
|
||||
activeOpIdRef.current = null
|
||||
}
|
||||
grabTabIdRef.current = null
|
||||
setState('idle')
|
||||
setPayload(null)
|
||||
setError(null)
|
||||
setContextMenu(false)
|
||||
}
|
||||
}, [state, armAndAwait])
|
||||
|
||||
const cancel = useCallback(() => {
|
||||
const targetTabId = grabTabIdRef.current ?? browserTabIdRef.current
|
||||
armGenerationRef.current += 1
|
||||
@@ -231,6 +203,17 @@ export function useGrabMode(browserPageId: string): GrabModeHook {
|
||||
setContextMenu(false)
|
||||
}, [])
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
if ((state === 'idle' || state === 'error') && grabTabIdRef.current === null) {
|
||||
setError(null)
|
||||
setPayload(null)
|
||||
setContextMenu(false)
|
||||
void armAndAwait()
|
||||
} else {
|
||||
cancel()
|
||||
}
|
||||
}, [state, armAndAwait, cancel])
|
||||
|
||||
// Why: Copy re-arms so the user can quickly pick another element without
|
||||
// re-clicking the toolbar button. Attach to AI exits because the user's
|
||||
// intent is to continue in the chat, not keep selecting.
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { SetupScriptImportCandidate } from '../../../shared/setup-script-im
|
||||
import type { Repo, RepoHookSettings } from '../../../shared/types'
|
||||
import type { HookCheckResult } from '@/runtime/runtime-hooks-client'
|
||||
import { isRuntimeScopeForbiddenError } from '@/runtime/runtime-rpc-client'
|
||||
import { hasEffectiveSetupCommand } from './setup-script-status'
|
||||
|
||||
const SETUP_SCRIPT_PROMPT_DISMISSAL_PREFIX = 'generation-v1:'
|
||||
|
||||
@@ -69,25 +70,6 @@ export async function inspectSetupScriptPromptState({
|
||||
}
|
||||
}
|
||||
|
||||
export function hasEffectiveSetupCommand(repo: Repo, hooksResult: HookCheckResult): boolean {
|
||||
const localSetup = repo.hookSettings?.scripts?.setup?.trim()
|
||||
const sharedSetup = hooksResult.hooks?.scripts?.setup?.trim()
|
||||
const rawPolicy = repo.hookSettings?.commandSourcePolicy
|
||||
const sourcePolicy = resolveHookCommandSourcePolicy(rawPolicy, {
|
||||
hasLocalScript: Boolean(localSetup)
|
||||
})
|
||||
|
||||
if (sourcePolicy === 'local-only') {
|
||||
return Boolean(localSetup)
|
||||
}
|
||||
|
||||
if (sourcePolicy === 'run-both') {
|
||||
return Boolean(sharedSetup || localSetup)
|
||||
}
|
||||
|
||||
return Boolean(sharedSetup)
|
||||
}
|
||||
|
||||
export function ignoresSharedSetupScripts(repo: Pick<Repo, 'hookSettings'>): boolean {
|
||||
const localSetup = repo.hookSettings?.scripts?.setup?.trim()
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user