@@ -27,6 +27,7 @@ public sealed partial class ChatPage : Page
2727 private HubWindow ? _hub ;
2828 private MountedFunctionalChat ? _functionalHost ;
2929 private IChatDataProvider ? _mountedProvider ;
30+ private IChatDataProvider ? _accessibilityTestProvider ;
3031 private string ? _mountedThreadId ;
3132 private string ? _chatUrl ;
3233 private bool _webViewInitialized ;
@@ -230,7 +231,7 @@ private void ShowFunctionalSurface()
230231 DevToolsButton . Visibility = Visibility . Collapsed ;
231232
232233 var app = App . Current as App ;
233- var provider = app ? . ChatProvider ;
234+ var provider = ResolveChatProvider ( app ) ;
234235 Func < string , Task > ? readAloud = app is null ? null : app . SpeakChatTextAsync ;
235236
236237 // Consume a pending session-key hand-off from SessionsPage or a
@@ -311,6 +312,116 @@ private void ShowFunctionalSurface()
311312 }
312313 }
313314
315+ private IChatDataProvider ? ResolveChatProvider ( App ? app )
316+ {
317+ if ( app ? . ChatProvider is { } liveProvider )
318+ return liveProvider ;
319+
320+ // The accessibility suite launches an isolated app process without a
321+ // gateway. Mount a deterministic provider only under its explicit
322+ // test flag so Axe scans the real FunctionalUI timeline and composer,
323+ // not merely the disconnected page shell.
324+ if ( Environment . GetEnvironmentVariable ( "OPENCLAW_ACCESSIBILITY_TEST_CHAT" ) == "1"
325+ && Environment . GetEnvironmentVariable ( "OPENCLAW_TRAY_DATA_DIR" ) is { Length : > 0 } )
326+ {
327+ return _accessibilityTestProvider ??= new AccessibilityChatDataProvider ( ) ;
328+ }
329+
330+ return null ;
331+ }
332+
333+ private sealed class AccessibilityChatDataProvider : IChatDataProvider
334+ {
335+ private const string ThreadId = "accessibility-main" ;
336+ private static readonly ChatDataSnapshot Snapshot = CreateSnapshot ( ) ;
337+
338+ public string DisplayName => "Accessibility test chat" ;
339+
340+ public event EventHandler < ChatDataChangedEventArgs > ? Changed
341+ {
342+ add { }
343+ remove { }
344+ }
345+
346+ public event EventHandler < ChatProviderNotificationEventArgs > ? NotificationRequested
347+ {
348+ add { }
349+ remove { }
350+ }
351+
352+ public Task < ChatDataSnapshot > LoadAsync ( CancellationToken cancellationToken = default )
353+ => Task . FromResult ( Snapshot ) ;
354+
355+ public Task SendMessageAsync (
356+ string threadId ,
357+ string message ,
358+ CancellationToken cancellationToken = default )
359+ => Task . CompletedTask ;
360+
361+ public Task StopResponseAsync ( string threadId , CancellationToken cancellationToken = default )
362+ => Task . CompletedTask ;
363+
364+ public Task SetThreadSuspendedAsync ( string threadId , bool suspended , CancellationToken cancellationToken = default )
365+ => Task . CompletedTask ;
366+
367+ public Task DeleteThreadAsync ( string threadId , CancellationToken cancellationToken = default )
368+ => Task . CompletedTask ;
369+
370+ public Task SetModelAsync ( string threadId , string model , CancellationToken cancellationToken = default )
371+ => Task . CompletedTask ;
372+
373+ public Task SetThinkingLevelAsync ( string threadId , string thinkingLevel , CancellationToken cancellationToken = default )
374+ => Task . CompletedTask ;
375+
376+ public Task SetPermissionModeAsync ( string threadId , bool allowAll , CancellationToken cancellationToken = default )
377+ => Task . CompletedTask ;
378+
379+ public Task RespondToPermissionAsync (
380+ string threadId ,
381+ string requestId ,
382+ string action ,
383+ CancellationToken cancellationToken = default )
384+ => Task . CompletedTask ;
385+
386+ public ValueTask DisposeAsync ( ) => ValueTask . CompletedTask ;
387+
388+ private static ChatDataSnapshot CreateSnapshot ( )
389+ {
390+ var timeline = ChatTimelineState . Initial ( ) with
391+ {
392+ Entries = ChatTimelineState . Initial ( ) . Entries
393+ . Add ( new ChatTimelineItem (
394+ "accessibility-user" ,
395+ ChatTimelineItemKind . User ,
396+ "Verify the native chat surface." ) )
397+ . Add ( new ChatTimelineItem (
398+ "accessibility-assistant" ,
399+ ChatTimelineItemKind . Assistant ,
400+ "The timeline and composer are ready." ) ) ,
401+ NextId = 3 ,
402+ HistoryLoaded = true ,
403+ } ;
404+
405+ return new ChatDataSnapshot (
406+ [ new ChatThread
407+ {
408+ Id = ThreadId ,
409+ Title = "Accessibility session" ,
410+ Status = ChatThreadStatus . Running ,
411+ Activity = ChatActivity . Idle ,
412+ Model = "test-model" ,
413+ } ] ,
414+ new Dictionary < string , ChatTimelineState >
415+ {
416+ [ ThreadId ] = timeline ,
417+ } ,
418+ ThreadId ,
419+ "Connected (accessibility test)" ,
420+ [ "test-model" ] ,
421+ new ChatComposeTarget ( ThreadId , IsReady : true ) ) ;
422+ }
423+ }
424+
314425 private void ShowWebViewSurface ( bool forceNavigate = false )
315426 {
316427 // Consume pending session key for WebView mode.
0 commit comments