mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
Re-announce identical retry results
This commit is contained in:
+20
@@ -398,4 +398,24 @@ describe('AutoRenameFailedDialog sessions and focus', () => {
|
||||
await act(async () => frames.splice(0).forEach((frame) => frame(0)))
|
||||
expect(document.activeElement?.getAttribute('aria-label')).toBe('Dismiss')
|
||||
})
|
||||
|
||||
it('re-announces an identical result by clearing the live region while naming runs', async () => {
|
||||
await renderFailure()
|
||||
const liveRegion = () => document.querySelector('[aria-live="polite"]')?.textContent ?? ''
|
||||
retryBranchAutoRename.mockResolvedValueOnce({
|
||||
attemptId: 1,
|
||||
outcome: { kind: 'nothing-yet' },
|
||||
finishedAt: 1
|
||||
})
|
||||
await act(async () => button('Try again')?.click())
|
||||
expect(liveRegion()).toBe('No changes to name this branch from yet.')
|
||||
const second = Promise.withResolvers<BranchAutoRenameRetryResult>()
|
||||
retryBranchAutoRename.mockReturnValueOnce(second.promise)
|
||||
await act(async () => button('Try again')?.click())
|
||||
expect(liveRegion()).toBe('')
|
||||
await act(async () =>
|
||||
second.resolve({ attemptId: 2, outcome: { kind: 'nothing-yet' }, finishedAt: 1 })
|
||||
)
|
||||
expect(liveRegion()).toBe('No changes to name this branch from yet.')
|
||||
})
|
||||
})
|
||||
|
||||
+8
-2
@@ -170,6 +170,7 @@ export function AutoRenameFailedDialog({
|
||||
showFooterClose={false}
|
||||
reason={branchAutoRenameReasonText(retry.lastOutcome, t)}
|
||||
detailsFinishedAt={retry.lastFinishedAt}
|
||||
announcementPaused={retry.running}
|
||||
action={
|
||||
<>
|
||||
<Button
|
||||
@@ -230,6 +231,8 @@ type NameGenerationFailedDialogProps = {
|
||||
tone?: 'error' | 'neutral'
|
||||
/** When the latest retry finished; stamps the label so identical errors still read as new. */
|
||||
detailsFinishedAt?: number | null
|
||||
/** Empties the live region while an attempt runs, so an identical result is announced again. */
|
||||
announcementPaused?: boolean
|
||||
}
|
||||
|
||||
/** Full output is memory-only; fall back to the published excerpt after restart and scroll long replies. */
|
||||
@@ -244,7 +247,8 @@ export function NameGenerationFailedDialog({
|
||||
showFooterClose = true,
|
||||
reason = null,
|
||||
tone = 'error',
|
||||
detailsFinishedAt = null
|
||||
detailsFinishedAt = null,
|
||||
announcementPaused = false
|
||||
}: NameGenerationFailedDialogProps): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const intlLocale = useIntlLocale()
|
||||
@@ -297,7 +301,9 @@ export function NameGenerationFailedDialog({
|
||||
)
|
||||
// Announce the reason, or the label and first error line; never the full output.
|
||||
const announcement =
|
||||
detailsFinishedAt === null ? '' : (reason ?? `${detailsLabel}. ${error.split('\n')[0] ?? ''}`)
|
||||
detailsFinishedAt === null || announcementPaused
|
||||
? ''
|
||||
: (reason ?? `${detailsLabel}. ${error.split('\n')[0] ?? ''}`)
|
||||
|
||||
const handleCopy = useCallback(async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user