mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix(settings): turn session search on without a confirmation dialog
Each switch and Turn on all now act on the click. The dialogs restated the row they sat under and stood between the user and a preference they can reverse with the same control. Clearing search data keeps its dialog: that one destroys something.
This commit is contained in:
@@ -210,7 +210,7 @@ it('keeps an offline server dimmed, disabled and honest about its index', async
|
||||
expect(serverSwitch()).toHaveAttribute('aria-checked', 'false')
|
||||
})
|
||||
|
||||
it('asks for consent naming the server before enabling it', async () => {
|
||||
it('turns a server on straight from its switch, with nothing to confirm', async () => {
|
||||
const confirm = vi.fn().mockResolvedValue(true)
|
||||
mocks.status.mockResolvedValue(unavailableSessionSearchStatus())
|
||||
serverRow(connectedDetails(), confirm)
|
||||
@@ -218,28 +218,12 @@ it('asks for consent naming the server before enabling it', async () => {
|
||||
await act(async () => {
|
||||
fireEvent.click(serverSwitch())
|
||||
})
|
||||
expect(confirm).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
title: 'Turn on session search on build-box?',
|
||||
description: expect.stringContaining('results are sent to this computer'),
|
||||
confirmLabel: 'Turn on'
|
||||
})
|
||||
)
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(mocks.setEnabled).toHaveBeenCalledWith('runtime:env-1', true)
|
||||
expect(screen.getByRole('status')).toHaveTextContent('4,880 sessions · 1.4M messages searchable')
|
||||
})
|
||||
|
||||
it('leaves a server untouched when the consent is declined', async () => {
|
||||
mocks.status.mockResolvedValue(unavailableSessionSearchStatus())
|
||||
serverRow(connectedDetails(), vi.fn().mockResolvedValue(false))
|
||||
await act(async () => {})
|
||||
await act(async () => {
|
||||
fireEvent.click(serverSwitch())
|
||||
})
|
||||
expect(mocks.setEnabled).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('turns a server off without asking again', async () => {
|
||||
it('turns a server off straight from its switch', async () => {
|
||||
const confirm = vi.fn().mockResolvedValue(true)
|
||||
serverRow(connectedDetails(), confirm)
|
||||
await act(async () => {})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import type { PublicKnownRuntimeEnvironment } from '../../../../shared/runtime-environments'
|
||||
import { toRuntimeExecutionHostId } from '../../../../shared/execution-host'
|
||||
import { useConfirmationDialog } from '@/components/confirmation-dialog-context'
|
||||
import { useMountedRef } from '@/hooks/useMountedRef'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { useAppStore } from '@/store'
|
||||
@@ -39,7 +38,6 @@ export function SessionHistoryServerRow({
|
||||
onUserToggle?: (environmentId: string, enabled: boolean) => void
|
||||
}): React.JSX.Element {
|
||||
const hostId = toRuntimeExecutionHostId(environment.id)
|
||||
const confirm = useConfirmationDialog()
|
||||
const mounted = useMountedRef()
|
||||
const openSettingsPage = useAppStore((state) => state.openSettingsPage)
|
||||
const openSettingsTarget = useAppStore((state) => state.openSettingsTarget)
|
||||
@@ -94,37 +92,9 @@ export function SessionHistoryServerRow({
|
||||
}
|
||||
}
|
||||
|
||||
async function toggle(): Promise<void> {
|
||||
function toggle(): Promise<void> {
|
||||
onUserToggle?.(environment.id, !enabled)
|
||||
if (enabled) {
|
||||
await setEnabled(false)
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
let accepted = false
|
||||
try {
|
||||
accepted = await confirm({
|
||||
title: translate(
|
||||
'sessionHistory.settings.serverEnableTitle',
|
||||
'Turn on session search on {{host}}?',
|
||||
{ host: environment.name }
|
||||
),
|
||||
description: translate(
|
||||
'sessionHistory.settings.serverEnableConsent',
|
||||
'Orca will make the agent conversations and tool output on {{host}} searchable from Agent Session History. The searchable copy stays on {{host}}; results are sent to this computer when you search. The first pass runs in the background and can take a few minutes.',
|
||||
{ host: environment.name }
|
||||
),
|
||||
confirmLabel: translate('sessionHistory.settings.enableConfirm', 'Turn on')
|
||||
})
|
||||
} finally {
|
||||
if (mounted.current) {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
if (!accepted || !mounted.current) {
|
||||
return
|
||||
}
|
||||
await setEnabled(true)
|
||||
return setEnabled(!enabled)
|
||||
}
|
||||
|
||||
function openServerSettings(): void {
|
||||
|
||||
@@ -156,7 +156,7 @@ afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
it('requires opt-in and saves the existing policy without touching transcripts or polling while off', async () => {
|
||||
it('turns search on from the switch alone, touching no transcript while it is off', async () => {
|
||||
const save = vi.fn().mockResolvedValue(undefined)
|
||||
const confirm = vi.fn().mockResolvedValue(true)
|
||||
pane(false, confirm, save)
|
||||
@@ -169,13 +169,7 @@ it('requires opt-in and saves the existing policy without touching transcripts o
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('switch'))
|
||||
})
|
||||
expect(confirm).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
title: 'Turn on session search?',
|
||||
description: expect.stringContaining('It stays on this computer'),
|
||||
confirmLabel: 'Turn on'
|
||||
})
|
||||
)
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(save).toHaveBeenCalledWith({ aiVaultSearch: { enabled: true, historyDays: null } })
|
||||
})
|
||||
|
||||
@@ -189,17 +183,7 @@ it('sends the user to the sidebar panel with one click', async () => {
|
||||
expect(mocks.closeSettingsPage).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('leaves search off when the indexing consent is declined', async () => {
|
||||
const save = vi.fn().mockResolvedValue(undefined)
|
||||
pane(false, vi.fn().mockResolvedValue(false), save)
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('switch'))
|
||||
})
|
||||
expect(save).not.toHaveBeenCalled()
|
||||
expect(screen.getByRole('switch')).toHaveAttribute('aria-checked', 'false')
|
||||
})
|
||||
|
||||
it('turns search off without asking again', async () => {
|
||||
it('turns search off from the switch alone', async () => {
|
||||
const confirm = vi.fn().mockResolvedValue(true)
|
||||
const save = vi.fn().mockResolvedValue(undefined)
|
||||
pane(true, confirm, save)
|
||||
@@ -437,9 +421,7 @@ it('turns on every reachable computer and skips the ones it cannot', async () =>
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Turn on all' }))
|
||||
})
|
||||
expect(confirm).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ title: 'Turn on session search on every computer?' })
|
||||
)
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(mocks.setEnabled.mock.calls.map((call) => call[0])).toEqual(['runtime:off'])
|
||||
expect(save).toHaveBeenCalledWith({ aiVaultSearchAutoEnableNewComputers: true })
|
||||
})
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from '../../../../shared/execution-host'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { useConfirmationDialog } from '@/components/confirmation-dialog-context'
|
||||
import { isWebClientLocation } from '@/lib/web-client-location'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { useAppStore } from '@/store'
|
||||
@@ -48,7 +47,6 @@ export function SessionHistorySettingsPane({
|
||||
const policy = resolveAiVaultSearchSettings(settings)
|
||||
const autoEnableNewComputers = settings.aiVaultSearchAutoEnableNewComputers === true
|
||||
const isWebClient = isWebClientLocation()
|
||||
const confirm = useConfirmationDialog()
|
||||
const closeSettingsPage = useAppStore((state) => state.closeSettingsPage)
|
||||
const showAiVaultSearch = useAppStore((state) => state.showAiVaultSearch)
|
||||
const [busy, setBusy] = useState(false)
|
||||
@@ -128,31 +126,8 @@ export function SessionHistorySettingsPane({
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleEnabled(): Promise<void> {
|
||||
if (policy.enabled) {
|
||||
await save({ enabled: false })
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
let accepted = false
|
||||
try {
|
||||
accepted = await confirm({
|
||||
title: translate('sessionHistory.settings.enableTitle', 'Turn on session search?'),
|
||||
description: translate(
|
||||
'sessionHistory.settings.enableConsent',
|
||||
'Orca will make your past agent conversations and tool output on this computer searchable from Agent Session History. It stays on this computer. The first pass runs in the background and can take a few minutes.'
|
||||
),
|
||||
confirmLabel: translate('sessionHistory.settings.enableConfirm', 'Turn on')
|
||||
})
|
||||
} finally {
|
||||
if (mounted.current) {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
if (!accepted || !mounted.current) {
|
||||
return
|
||||
}
|
||||
await save({ enabled: true })
|
||||
function toggleEnabled(): Promise<void> {
|
||||
return save({ enabled: !policy.enabled })
|
||||
}
|
||||
|
||||
/** A hand-off the user made themselves overrides the standing "turn on new computers" consent. */
|
||||
@@ -171,28 +146,6 @@ export function SessionHistorySettingsPane({
|
||||
}
|
||||
|
||||
async function turnOnEveryComputer(): Promise<void> {
|
||||
setBusy(true)
|
||||
let accepted = false
|
||||
try {
|
||||
accepted = await confirm({
|
||||
title: translate(
|
||||
'sessionHistory.settings.enableAllTitle',
|
||||
'Turn on session search on every computer?'
|
||||
),
|
||||
description: translate(
|
||||
'sessionHistory.settings.enableAllConsent',
|
||||
'Orca will make the agent conversations and tool output on this computer and on every reachable paired server searchable from Agent Session History. Each searchable copy stays on the computer that made it; results are sent here when you search. Offline servers and servers that need an update are skipped. The first pass runs in the background and can take a few minutes.'
|
||||
),
|
||||
confirmLabel: translate('sessionHistory.settings.enableConfirm', 'Turn on')
|
||||
})
|
||||
} finally {
|
||||
if (mounted.current) {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
if (!accepted || !mounted.current) {
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
let failed = false
|
||||
|
||||
@@ -17956,9 +17956,6 @@
|
||||
},
|
||||
"settings": {
|
||||
"saveError": "Could not save. Try again.",
|
||||
"enableTitle": "Turn on session search?",
|
||||
"enableConsent": "Orca will make your past agent conversations and tool output on this computer searchable from Agent Session History. It stays on this computer. The first pass runs in the background and can take a few minutes.",
|
||||
"enableConfirm": "Turn on",
|
||||
"advanced": "Advanced",
|
||||
"deleteIndexCopy": "Clear search data",
|
||||
"deleteTitle": "Clear search data on this computer?",
|
||||
@@ -17978,8 +17975,6 @@
|
||||
"serverOffline": "Offline",
|
||||
"serverTooOld": "Needs a newer version of Orca.",
|
||||
"updateServer": "Update server",
|
||||
"serverEnableTitle": "Turn on session search on {{host}}?",
|
||||
"serverEnableConsent": "Orca will make the agent conversations and tool output on {{host}} searchable from Agent Session History. The searchable copy stays on {{host}}; results are sent to this computer when you search. The first pass runs in the background and can take a few minutes.",
|
||||
"serverToggleError": "Could not change session search on {{host}}. Try again.",
|
||||
"clearedAndTurnedOff": "Search turned off and search data cleared.",
|
||||
"thisComputer": "This computer",
|
||||
@@ -17989,8 +17984,6 @@
|
||||
"summaryNeedUpdate": "{{needUpdate}} need an update",
|
||||
"summaryAutoEnable": "New computers turn on when they can.",
|
||||
"turnOnAll": "Turn on all",
|
||||
"enableAllTitle": "Turn on session search on every computer?",
|
||||
"enableAllConsent": "Orca will make the agent conversations and tool output on this computer and on every reachable paired server searchable from Agent Session History. Each searchable copy stays on the computer that made it; results are sent here when you search. Offline servers and servers that need an update are skipped. The first pass runs in the background and can take a few minutes.",
|
||||
"showMore": "Show {{count}} more",
|
||||
"showFewer": "Show fewer",
|
||||
"openInSidebar": "Open in the sidebar",
|
||||
|
||||
Reference in New Issue
Block a user