Skip to content

Commit aaa1b0e

Browse files
ranjeshjCopilot
andcommitted
Fix tool output accessibility labels
Add accessible names to the TaskList tool burst header and expanded body so screen readers can announce both the summary and step output without changing the header-only click target. Co-authored-by: Copilot <[email protected]>
1 parent bfeb3b5 commit aaa1b0e

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

‎src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,7 @@ string Truncate(string s, int max)
19931993
// ▼ when collapsed (action: click to expand down).
19941994
var chevron = effectiveExpanded ? "▲" : "▼";
19951995
var stepCountLabel = $"{stepCount} step{(stepCount == 1 ? "" : "s")}";
1996+
var taskListHeaderAutomationName = $"{summaryLine}, {stepCountLabel}, {taskStatusText}, {(effectiveExpanded ? "expanded" : "collapsed")}";
19961997

19971998
Action toggleTaskList = () =>
19981999
{
@@ -2004,6 +2005,7 @@ string Truncate(string s, int max)
20042005

20052006
// Per-step rows (used only when expanded).
20062007
var stepRows = new System.Collections.Generic.List<Element>();
2008+
var stepAutomationSummaries = new System.Collections.Generic.List<string>();
20072009
for (int i = 0; i < entries.Count; i++)
20082010
{
20092011
var e = entries[i];
@@ -2012,6 +2014,7 @@ string Truncate(string s, int max)
20122014
var prefix = StepPrefix(i);
20132015
var labelText = string.IsNullOrEmpty(prefix) ? label : $"{prefix} {label}";
20142016
var summary = ShortSummary(e);
2017+
stepAutomationSummaries.Add(string.IsNullOrEmpty(summary) ? labelText : $"{labelText}: {summary}");
20152018

20162019
stepRows.Add(
20172020
(FlexRow(
@@ -2054,19 +2057,21 @@ string Truncate(string s, int max)
20542057
.Set(t => { t.FontSize = 11; }).VAlign(VerticalAlignment.Center)
20552058
) with { ColumnGap = 8 }).Margin(0, 0, 0, 0);
20562059

2057-
var headerButton = Button(headerContent, toggleTaskList).Set(b =>
2058-
{
2059-
b.HorizontalAlignment = HorizontalAlignment.Stretch;
2060-
b.HorizontalContentAlignment = HorizontalAlignment.Stretch;
2061-
b.Padding = bubblePadding;
2062-
b.CornerRadius = new CornerRadius(bubbleRadius.TopLeft, bubbleRadius.TopRight, effectiveExpanded ? 0 : bubbleRadius.BottomRight, effectiveExpanded ? 0 : bubbleRadius.BottomLeft);
2063-
}).Resources(r => r
2064-
.Set("ButtonBackground", new SolidColorBrush(Colors.Transparent))
2065-
.Set("ButtonBackgroundPointerOver", themeBrush("SubtleFillColorTertiaryBrush"))
2066-
.Set("ButtonBackgroundPressed", themeBrush("SubtleFillColorSecondaryBrush"))
2067-
.Set("ButtonBorderBrush", new SolidColorBrush(Colors.Transparent))
2068-
.Set("ButtonBorderBrushPointerOver", new SolidColorBrush(Colors.Transparent))
2069-
.Set("ButtonBorderBrushPressed", new SolidColorBrush(Colors.Transparent)));
2060+
var headerButton = Button(headerContent, toggleTaskList)
2061+
.AutomationName(taskListHeaderAutomationName)
2062+
.Set(b =>
2063+
{
2064+
b.HorizontalAlignment = HorizontalAlignment.Stretch;
2065+
b.HorizontalContentAlignment = HorizontalAlignment.Stretch;
2066+
b.Padding = bubblePadding;
2067+
b.CornerRadius = new CornerRadius(bubbleRadius.TopLeft, bubbleRadius.TopRight, effectiveExpanded ? 0 : bubbleRadius.BottomRight, effectiveExpanded ? 0 : bubbleRadius.BottomLeft);
2068+
}).Resources(r => r
2069+
.Set("ButtonBackground", new SolidColorBrush(Colors.Transparent))
2070+
.Set("ButtonBackgroundPointerOver", themeBrush("SubtleFillColorTertiaryBrush"))
2071+
.Set("ButtonBackgroundPressed", themeBrush("SubtleFillColorSecondaryBrush"))
2072+
.Set("ButtonBorderBrush", new SolidColorBrush(Colors.Transparent))
2073+
.Set("ButtonBorderBrushPointerOver", new SolidColorBrush(Colors.Transparent))
2074+
.Set("ButtonBorderBrushPressed", new SolidColorBrush(Colors.Transparent)));
20702075

20712076
var cardChildren = new System.Collections.Generic.List<Element> { headerButton };
20722077
if (effectiveExpanded)
@@ -2075,6 +2080,7 @@ string Truncate(string s, int max)
20752080
// header + body read as one unit but the divide is clear.
20762081
cardChildren.Add(
20772082
Border(VStack(8, stepRows.ToArray()))
2083+
.AutomationName($"Tool steps for: {summaryLine}. {string.Join("; ", stepAutomationSummaries)}")
20782084
.Set(b =>
20792085
{
20802086
b.Padding = bubblePadding;

‎tests/OpenClaw.Tray.Tests/ChatToolCallsToggleContractTests.cs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@ public void ProductionTimeline_HonorsComposerToolCallVisibilityToggle()
2525
source);
2626
}
2727

28+
[Fact]
29+
public void TaskListToolBurst_LabelsHeaderAndExpandedBodyForScreenReaders()
30+
{
31+
var source = File.ReadAllText(Path.Combine(
32+
GetRepositoryRoot(),
33+
"src",
34+
"OpenClaw.Tray.WinUI",
35+
"Chat",
36+
"OpenClawChatTimeline.cs"));
37+
38+
Assert.Matches(
39+
new Regex(@"var\s+taskListHeaderAutomationName\s*=\s*\$""\{summaryLine\},\s*\{stepCountLabel\},\s*\{taskStatusText\},\s*\{"),
40+
source);
41+
Assert.Matches(
42+
new Regex(@"var\s+headerButton\s*=\s*Button\(headerContent,\s*toggleTaskList\)\s*\.AutomationName\(taskListHeaderAutomationName\)", RegexOptions.Singleline),
43+
source);
44+
Assert.Matches(
45+
new Regex(@"\.AutomationName\(\$""Tool steps for:\s*\{summaryLine\}\.\s*\{string\.Join\("";\s*"",\s*stepAutomationSummaries\)\}""\)", RegexOptions.Singleline),
46+
source);
47+
}
48+
2849
private static string GetRepositoryRoot()
2950
{
3051
var env = Environment.GetEnvironmentVariable("OPENCLAW_REPO_ROOT");

0 commit comments

Comments
 (0)