Skip to content

Commit 079a7c3

Browse files
committed
fix(webview): keep MiMo refresh status in one persistent live region
What: the loading/success/error status divs in the MiMo provider settings panel now render inside a single wrapper with role="status" and aria-live="polite", and Mimo.spec.tsx pins that the wrapper stays mounted while its content changes. The spec's hand-wrapped QueryClientProvider also moves to renderWithExtensionState, which the webview lint rule requires. Why: each status div used to mount and unmount as the region itself. A live region only announces content that changes inside an element already present in the accessibility tree, so screen-reader users got no announcement for the refresh outcome. Impact: refresh progress and results are announced to assistive tech. DOM structure gains one wrapper div; the existing text queries are unchanged.
1 parent 653bf2e commit 079a7c3

2 files changed

Lines changed: 68 additions & 23 deletions

File tree

‎webview-ui/src/components/settings/providers/Mimo.tsx‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,27 @@ export const Mimo = ({ apiConfiguration, setApiConfigurationField }: MimoProps)
157157
{t("settings:providers.refreshModels.label")}
158158
</div>
159159
</Button>
160-
{refreshStatus === RefreshStatus.Loading && (
161-
<div className="text-sm text-vscode-descriptionForeground">
162-
{t("settings:providers.refreshModels.loading")}
163-
</div>
164-
)}
165-
{refreshStatus === RefreshStatus.Success && (
166-
<div className="text-sm text-vscode-foreground">{t("settings:providers.refreshModels.success")}</div>
167-
)}
168-
{refreshStatus === RefreshStatus.Error && (
169-
<div className="text-sm text-vscode-errorForeground">
170-
{refreshError || t("settings:providers.refreshModels.error")}
171-
</div>
172-
)}
160+
{/* One persistent live region: screen readers only announce content that
161+
changes inside an element that is already in the accessibility tree,
162+
so the conditional status divs mount into this wrapper instead of
163+
appearing and disappearing as the region itself. */}
164+
<div role="status" aria-live="polite">
165+
{refreshStatus === RefreshStatus.Loading && (
166+
<div className="text-sm text-vscode-descriptionForeground">
167+
{t("settings:providers.refreshModels.loading")}
168+
</div>
169+
)}
170+
{refreshStatus === RefreshStatus.Success && (
171+
<div className="text-sm text-vscode-foreground">
172+
{t("settings:providers.refreshModels.success")}
173+
</div>
174+
)}
175+
{refreshStatus === RefreshStatus.Error && (
176+
<div className="text-sm text-vscode-errorForeground">
177+
{refreshError || t("settings:providers.refreshModels.error")}
178+
</div>
179+
)}
180+
</div>
173181
</>
174182
)
175183
}

‎webview-ui/src/components/settings/providers/__tests__/Mimo.spec.tsx‎

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
// npx vitest src/components/settings/providers/__tests__/Mimo.spec.tsx
22

3-
import { render, screen, fireEvent, waitFor, act } from "@/utils/test-utils"
4-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
3+
import {
4+
render,
5+
screen,
6+
fireEvent,
7+
waitFor,
8+
act,
9+
renderWithExtensionState,
10+
createTestQueryClient,
11+
} from "@/utils/test-utils"
512
import { allRouterModelsProvider, providerIdentifiers, type ProviderSettings } from "@roo-code/types"
613

714
import { Mimo } from "../Mimo"
@@ -168,16 +175,15 @@ describe("Mimo Component", () => {
168175
})
169176

170177
it("invalidates only the MiMo and shared router-model caches after a successful refresh", async () => {
171-
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
178+
const queryClient = createTestQueryClient()
172179
const invalidateQueries = vi.spyOn(queryClient, "invalidateQueries")
173180

174-
render(
175-
<QueryClientProvider client={queryClient}>
176-
<Mimo
177-
apiConfiguration={createDefaultApiConfiguration({ mimoApiKey: "test-key" })}
178-
setApiConfigurationField={mockSetApiConfigurationField}
179-
/>
180-
</QueryClientProvider>,
181+
renderWithExtensionState(
182+
<Mimo
183+
apiConfiguration={createDefaultApiConfiguration({ mimoApiKey: "test-key" })}
184+
setApiConfigurationField={mockSetApiConfigurationField}
185+
/>,
186+
{ queryClient },
181187
)
182188

183189
fireEvent.click(findRefreshButton()!)
@@ -313,6 +319,37 @@ describe("Mimo Component", () => {
313319
)
314320
})
315321

322+
it("keeps one persistent polite live region mounted across status changes", async () => {
323+
// Screen readers only announce content that changes inside an element already
324+
// present in the accessibility tree. When each status div mounts and unmounts
325+
// as the region itself, the announcement is lost, so the wrapper has to stay
326+
// mounted and only its children change.
327+
render(
328+
<Mimo
329+
apiConfiguration={createDefaultApiConfiguration({ mimoApiKey: "test-key" })}
330+
setApiConfigurationField={mockSetApiConfigurationField}
331+
/>,
332+
)
333+
334+
const liveRegion = screen.getByRole("status")
335+
expect(liveRegion).toHaveAttribute("aria-live", "polite")
336+
expect(liveRegion).toBeEmptyDOMElement()
337+
338+
fireEvent.click(findRefreshButton()!)
339+
340+
expect(screen.getByRole("status")).toBe(liveRegion)
341+
expect(liveRegion).toHaveTextContent("settings:providers.refreshModels.loading")
342+
343+
act(() => {
344+
window.dispatchEvent(new MessageEvent("message", { data: { type: "routerModels" } }))
345+
})
346+
347+
await waitFor(() => {
348+
expect(liveRegion).toHaveTextContent("settings:providers.refreshModels.success")
349+
})
350+
expect(screen.getByRole("status")).toBe(liveRegion)
351+
})
352+
316353
it("shows 'Get MiMo API Key' link when no API key is set", () => {
317354
render(
318355
<Mimo

0 commit comments

Comments
 (0)