fix(frontend): announce RAG wait status from a persistent live region
role="status" lived on the wait row itself, so the live region was inserted together with its own text and screen readers had nothing to announce. Move the announcement to an sr-only region that stays mounted for the whole turn, which also covers the pre-pipeline wait row that had no announcement at all. Co-authored-by: lyingbug <lyingbug@users.noreply.github.com>main
parent
2454eaf253
commit
fcc4cd6a9f
|
|
@ -69,6 +69,14 @@ test('rag pipeline shows a pending model-answer step after retrieval completes',
|
|||
assert.match(source, /waitController\.dispose\(\)/)
|
||||
})
|
||||
|
||||
test('rag pipeline announces wait status from a region that outlives each row', () => {
|
||||
const template = source.split('<script')[0]
|
||||
assert.match(template, /class="sr-only" role="status" aria-live="polite"/)
|
||||
assert.equal((template.match(/aria-live/g) || []).length, 1)
|
||||
assert.match(source, /liveStatusText/)
|
||||
assert.match(source, /\.sr-only \{[\s\S]*clip: rect\(0, 0, 0, 0\)/)
|
||||
})
|
||||
|
||||
test('done row appears only after the full turn completes', () => {
|
||||
assert.match(source, /const showDoneRow = computed\(\(\) => \{[\s\S]*hasAnswer\.value/)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
<template>
|
||||
<div v-if="visible" ref="rootElement" class="rag-pipeline-progress">
|
||||
<!-- Announcements need a region that outlives each wait row, otherwise screen
|
||||
readers miss a live region that appears together with its own text. -->
|
||||
<div class="sr-only" role="status" aria-live="polite">{{ liveStatusText }}</div>
|
||||
|
||||
<div v-if="showPrePipelineWait" class="tree-children">
|
||||
<div class="tree-child tree-child-last streaming-loading-node">
|
||||
<div class="tree-branch" />
|
||||
|
|
@ -411,6 +415,12 @@ const visible = computed(
|
|||
() => steps.value.length > 0 || showPrePipelineWait.value || showThinkingStep.value,
|
||||
)
|
||||
|
||||
const liveStatusText = computed(() => {
|
||||
if (showPrePipelineWait.value) return t('chat.preparingAnswer')
|
||||
if (showWaitStep.value) return waitStepText.value
|
||||
return ''
|
||||
})
|
||||
|
||||
const collapsedStatusText = computed(() => {
|
||||
if (steps.value.length === 0) {
|
||||
return hasThinking.value ? t('agentStream.toolStatus.thinkingDone') : ''
|
||||
|
|
@ -511,6 +521,18 @@ onBeforeUnmount(() => {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.tree-container {
|
||||
margin: 0 0 8px;
|
||||
position: relative;
|
||||
|
|
|
|||
Loading…
Reference in New Issue