Accessible Conversational Interfaces with Recovery and Human Handoff

Pressing Stop should leave a reply stopped. That sounds a modest requirement, but aborting a request and refusing its later callbacks are separate jobs. A completion arriving at the wrong moment must not turn an interrupted answer into a finished one.
The same care is needed when somebody asks to speak to a person. An unanswered transfer request may already have reached its destination. The interface needs to preserve that uncertainty, explain what will be retried, and let the reader inspect what they are sending.
I built a small library‑room enquiry screen around those decisions. It uses React 19.3.1 and TypeScript 6.0.3, with a scripted reply streamed over a real local HTTP connection. There's no language model, availability service, or booking operation behind the replies. The handoff saves to a local demonstration queue and doesn't contact library staff. That lets us try the recovery behaviour without sending anyone a real enquiry.
Give Each Reply a Lifetime
The controller distinguishes waiting, streaming, complete, failed, and cancelled replies. Partial text stays in the transcript, labelled as incomplete after failure or cancellation. The editable question stays in the composer.
Send uses the current composer text. Retry reply repeats the last sent question, even if the reader has since edited the composer. Both actions create a fresh attempt identifier. The interface explains this distinction beside the input; a retry should not quietly choose which version of the question somebody meant.
Every chunk, completion, and failure callback checks that it still owns the active attempt. Retiring an attempt clears that ownership before aborting its request:
private retire = (): void => {
const active = this.active;
this.active = null;
if (active) {
clearTimeout(active.timer);
active.abort.abort();
}
};
private current = (id: string): boolean =>
!this.disposed && this.active?.id === id;The callback starts with if (!this.current(id)) return. Stop, replacement, timeout, and completion all retire the attempt. Disposing the controller does the same. The test deliberately calls back after AbortController.abort(), so we can check that the controller actually ignores the late result.
The HTTP implementation requires an explicit completion frame. A stream that ends after some text, without that frame, is incomplete. It also bounds accumulated reply text and gives the whole attempt a three‑second deadline. That short deadline belongs to this controlled demonstration; choose a production deadline from the service's behaviour and the reader's task.
These retries repeat a read‑only enquiry. They are not permission to repeat a booking, payment, or other side effect. As with agent‑facing service boundaries, the backend still has to enforce the consequence of an action. Cancelling a browser request does not prove that a server action was cancelled.
Announce Progress Without Reading Every Chunk
The transcript and the status message have different responsibilities. The transcript contains the question, partial answer, and completion label. The status gives a short indication of what is happening.
There is one persistent live region, present before the request starts:
<p
id="status"
role="status"
aria-live="polite"
aria-atomic="true"
>
{state.status}
</p>It changes when the reply starts, when the first text arrives, and when the attempt finishes or fails. Further chunks update the non‑live transcript without changing the status. Completion says "Reply ready. Use Read latest reply." It does not also copy the answer into another live region.
That follows the distinction in WCAG's status‑message guidance: a short message about progress or results is different from the substantial content that has arrived. The existing live‑region article covers the underlying announcement and focus choices.
A named log region is another reasonable design for sequential messages. It has implicit polite live behaviour, though, so adding one alongside a status announcement needs an explicit policy about what gets announced where. Putting a token stream inside a live log would not give this example the reading control it needs.
Here, Read latest reply moves focus to the newest reply heading, so the reader can continue through the answer normally. Moving focus doesn't guarantee that a screen reader will speak the whole response. Jump to latest scrolls the transcript when requested; streaming never scrolls it automatically. Someone reviewing an older answer keeps control of their place.
I've chosen to let people decide when to read the completed reply, rather than having it spoken in full as soon as it arrives. I'd still want to try that with the intended readers to find out whether it suits them.
Keep the Controls Usable After They Act
Send, Stop, and Retry remain mounted whilst their availability changes. They use native buttons, aria-disabled, and controller guards. The guard matters: aria-disabled describes availability but does not prevent an event handler from running.
This lets Stop retain focus after it stops a reply. Removing the button, or making it natively disabled at that moment, would require a separate focus decision. The same applies to an approval button whilst its request is pending. These unavailable controls remain in the tab order, so keep the set small.
Talk to a person opens an inline review section and moves focus to its heading after React commits it. Cancelling that review returns focus to the trigger. There is no custom dialogue keyboard scheme to learn, and the review does not hide the original conversation.
Opening the review also retires an active reply. The attempt reference and reply state shown for approval therefore cannot be changed by a late completion. The reader can edit the question they intend to transfer without the background response rewriting the context around it.
Approve a Specific Handoff
The handoff contains a small, explicit set of fields:
type Handoff = Readonly<{
conversationId: string;
attemptId: string | null;
taskState: 'idle' | 'complete' | 'failed' | 'cancelled';
question: string;
room: Room;
details: string;
}>;The review lets the reader edit the question, room choice, and optional details, and see the request reference and current state. It does not silently attach the transcript. Approval freezes these scalar values and creates one idempotency key. A retry reuses that exact body and key; it cannot collect newer composer text or generate a fresh request by accident.
The local server validates the named fields, compares a repeated key against the original payload, and returns the existing receipt when both match. The lookup and insertion contain no asynchronous gap in this single Node process. A changed payload under the same key is a conflict.
The important failure case happens after insertion: the server drops the connection instead of returning its receipt. The client cannot call that a rejection. It says the queue may already have the request and offers to retry the same approved request. When the receipt is recovered, the queue still contains one item for that key.
An HTTP success alone is insufficient. The client validates the receipt shape, its acceptance flag and its matching request identifier. A malformed or mismatched acknowledgement leaves the outcome uncertain. Even a valid receipt confirms only this local queue's acceptance, not that a person has read anything.
The queue is an in‑memory teaching implementation. Restarting the server loses it; closing the page loses the local conversation and retry reference. A real handoff needs durable storage, identity and authorisation, retention decisions, and a support‑system contract that distinguishes queued, assigned, and received states. You'll need to work through those decisions with the receiving support system.
Collect Events Without Collecting the Conversation
Useful recovery telemetry does not require copying the question into every error report. The controller only includes the following fields in its events:
type Telemetry = {
event: 'reply' | 'handoff';
from: Phase;
to: Phase;
durationBucket: 'under-1s' | '1-5s' | 'over-5s';
outcome: Outcome;
};The implementation projects those five fields at runtime and validates each against its allowed primitive values. It reads each candidate once, then returns the validated values in a new object. A TypeScript cast alone would not stop an unexpected caller supplying a raw error, extra payload fields, or a value that merely converts to an allowed string.
Tests supply deliberately sensitive fictional questions, details, and error messages, then inspect the collected events. They also bypass the TypeScript types to check extra‑field removal and invalid values. No conversation identifiers, question text, reply text or handoff payload enters this telemetry.
Keeping those details out of telemetry is useful, but the application still handles private information elsewhere. The handoff itself intentionally contains approved text, and any real receiving system still needs its own handling policy. Privacy by design starts with deciding which data a feature needs, rather than collecting everything and hoping to remove it later.
Verify the Recovery, Then Verify the Reading
The local example and test commands separate controller races from actual HTTP behaviour. The controller cases force late chunks, completion and errors after Stop, replacement, retry, and disposal. Server cases exercise concurrent duplicate handoffs, changed‑payload conflicts, rejected requests, and missing or malformed acknowledgements. A split UTF‑8 body case checks that the approved text survives network chunk boundaries. You can download the conversation and handoff example.
The native‑browser checks cover keyboard focus, partial replies, timeout, consent, acknowledgement recovery, and a narrow viewport. For the browser's lost‑acknowledgement case, Playwright lets the real server accept the request, then aborts delivery of the response. The raw socket‑loss case is a separate HTTP test. Status‑node identity and text mutations are inspected separately from transcript changes. The scrolling checks establish what the page does whilst someone is reading older content.
I haven't yet tested the spoken output with VoiceOver in Safari or NVDA in Firefox. Before using this interaction in a product, I'd record the versions and work through what each announces, in what order, whether messages interrupt one another, and how the reader reaches the completed answer. Lighthouse and DOM checks can't tell us how that experience sounds.
A conversational interface can be quite ordinary about its failures. It can keep the question, label an unfinished answer honestly, leave the controls where the reader expects them, and show exactly what a handoff will send. Those behaviours are worth establishing before giving it a more fluent voice.