Skip to content

Commit aac07ab

Browse files
calebedenCopilot
andauthored
improve(chat): make tool activity compact and fully inspectable (#1092)
* feat(chat): compact consecutive tool activity Co-authored-by: Copilot App <[email protected]> * fix(chat): compact expanded tool rows Co-authored-by: Copilot App <[email protected]> * fix(chat): preserve tool input details Co-authored-by: Copilot App <[email protected]> * fix(chat): space expanded tool details Co-authored-by: Copilot App <[email protected]> * fix(chat): preserve selected tool detail text Co-authored-by: Copilot App <[email protected]> * fix(chat): preserve ordered tool history Co-authored-by: Copilot App <[email protected]> * test(chat): inspect Reactor tool output text Co-authored-by: Copilot App <[email protected]> * test(chat): reconcile tool activity off-tree Co-authored-by: Copilot App <[email protected]> * test(chat): expand compact native tool proof Co-authored-by: Copilot App <[email protected]> * fix(chat): correlate string tool results Co-authored-by: Copilot App <[email protected]> * fix(chat): preserve history tool correlation Prefer semantic tool-result call references and consume aborted assistant state on the first replayed part, including tool-first messages. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
1 parent cdcb74f commit aac07ab

25 files changed

Lines changed: 3235 additions & 263 deletions

‎docs/ARCHITECTURE.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ leading and trailing pipe. Columns, in order:
136136
| composition-root | authoritative | src/OpenClaw.Tray.WinUI/App.xaml.cs | presentation-layer service construction and wiring | AppServiceRegistration | App remains the composition root and owns non-DI service lifetimes | one validated root ServiceProvider; App-owned singletons registered as instances are never disposed by the container | AppServiceRegistrationTests.Dispose_DoesNotDisposeAppOwnedInstanceSingletons | behavioral | - |
137137
| node-summary-text | authoritative | src/OpenClaw.Tray.WinUI/App.xaml.cs | node-summary clipboard text formatting | NodeSummaryText | App keeps the clipboard side effect (building the DataPackage and setting clipboard content) | copied node-summary text is projected only by NodeSummaryText.Build (online/offline state, display-name fallback, short id, detail text, newline join) | NodeSummaryTextTests.Build_MultipleNodes_OneLinePerNodeJoinedByNewline | behavioral | - |
138138
| reactor-chat-timeline | authoritative | src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs | production chat message virtualization, row realization, and imperative scroll follow | ReactorChatTimeline through OpenClawReactorChatRoot and ReactorHostControl | OpenClawChatTimeline remains a legacy focused-test surface while its runtime route is migrated | the default chat route mounts one direct ReactorHostControl per XAML chat target; Reactor owns stable-key ItemsView and ItemContainer realization without a custom native list, collection reconciler, or scroll-layout mutation | review-only: user explicitly deferred new tests for this migration; required build and existing shared/tray suites still run | review-only | when Reactor timeline proof coverage replaces the legacy focused UI host coverage |
139+
| chat-tool-activity-renderer | authoritative | src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs | production standalone tool-call and grouped activity presentation, summaries, disclosures, and detail rendering | ChatToolActivityPresentation + ToolCallCardRenderer | ReactorChatTimeline projects rows and delegates realization only | consecutive invocation grouping preserves source chronology; stable group identity comes from session, generation, and first tool entry; selectable output remains capped at 240px | ChatToolActivityPresentationTests.Project_GroupsOnlyConsecutiveSpansOfAtLeastTwoTools | behavioral | - |
140+
| chat-history-replay-projection | authoritative | src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs | array-valued history content ordering projection | ChatHistoryReplayProjection | provider applies projected text and tool parts to the reducer | interleaved text, calls, and results replay in source order without clearing active tool correlation | OpenClawChatDataProviderTests.LoadHistoryAsync_InterleavedContentParts_PreserveChronologyAndCorrelation | behavioral | - |
141+
| reactor-tool-rendering-closed | closed | src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs | per-tool and grouped activity summary/detail rendering implementation | ToolCallCardRenderer | row projection, virtualization, hover state, assistant runs, and renderer delegation only | ReactorChatTimeline contains no tool detail renderer and delegates both standalone and grouped tool rows | ChatTimelinePresentationTests.ReactorTimeline_DelegatesToolAndActivityRenderingToFocusedOwner | source-shape | when ReactorChatTimeline is replaced as the production virtualization owner |
139142
| functional-chat-default-mount | closed | src/OpenClaw.Tray.WinUI/Chat/FunctionalChatHostExtensions.cs | mounting the FunctionalUI chat tree as the default ChatPage or ChatWindow surface | ReactorChatHostExtensions and OpenClawReactorChatRoot | legacy FunctionalUI chat files may remain for focused compatibility coverage only | ChatPage and ChatWindow mount the Reactor root directly into their existing ChatHost Borders; no FunctionalUI component mounts or nests Reactor on the default path | review-only: user explicitly deferred new tests for this migration; required build and existing shared/tray suites still run | review-only | when legacy FunctionalUI chat surfaces are removed |
140143
| settings-store | authoritative | src/OpenClaw.Tray.WinUI/Pages/SettingsPage.xaml.cs | hand-rolled save/echo suppression flags for two-way settings binding | ISettingsStore | PermissionsPage and other surfaces may read SettingsManager directly until migrated | a save originating from Update does not echo Changed to the caller and external saves are republished on the UI thread | SettingsStoreTests.Update_DoesNotEchoChangedToSelf | behavioral | when all settings surfaces read and write through ISettingsStore |
141144
| settings-page-vm | authoritative | src/OpenClaw.Tray.WinUI/Pages/SettingsPage.xaml.cs | settings load, persist, echo-guard, and auto-save wiring | SettingsPageViewModel | code-behind keeps gateway-uninstall, gateway-info and uptime timer, saved-indicator visual, and app-info population | each settings control persists its field through the store preserving mutate-save-notify order and does not re-persist on external change | SettingsPageViewModelTests.ExternalChange_ReloadsWithoutRePersisting | behavioral | when the Settings page holds no settings persistence logic in code-behind |

‎src/OpenClaw.Chat/ChatTimelineReducer.cs‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,40 @@ public static class ChatTimelineReducer
1010
private const int MaxTerminalToolCorrelations = 768;
1111
private const int MaxRetainedToolTurns = 2;
1212

13+
public static ChatTimelineState RebuildActiveToolTracking(ChatTimelineState state)
14+
{
15+
var activeToolCallId = default(string);
16+
var activeToolCalls =
17+
System.Collections.Immutable.ImmutableDictionary<ChatToolCorrelationKey, string>.Empty;
18+
19+
foreach (var entry in state.Entries)
20+
{
21+
if (entry.Kind != ChatTimelineItemKind.ToolCall
22+
|| entry.ToolResult is not (null or ChatToolCallStatus.InProgress))
23+
{
24+
continue;
25+
}
26+
27+
activeToolCallId = entry.Id;
28+
var correlationIds = entry.ToolCorrelationIds
29+
?? System.Collections.Immutable.ImmutableHashSet<string>.Empty;
30+
if (!string.IsNullOrWhiteSpace(entry.ToolCallId))
31+
correlationIds = correlationIds.Add(entry.ToolCallId);
32+
foreach (var correlationId in correlationIds)
33+
{
34+
activeToolCalls = activeToolCalls.SetItem(
35+
CorrelationKey(entry.ToolRunId, entry.ToolLegacyTurn, correlationId),
36+
entry.Id);
37+
}
38+
}
39+
40+
return state with
41+
{
42+
ActiveToolCallId = activeToolCallId,
43+
ActiveToolCalls = activeToolCalls,
44+
};
45+
}
46+
1347
public static ChatTimelineState Apply(ChatTimelineState state, ChatEvent evt)
1448
{
1549
return evt switch

‎src/OpenClaw.Shared/Models.cs‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,21 @@ public static bool IsSilentAssistantDirective(string? role, string? text) =>
18011801
/// <summary>Full text content of the message.</summary>
18021802
public string Text { get; set; } = "";
18031803

1804+
/// <summary>
1805+
/// Structured tool call/result blocks retained from array-valued message
1806+
/// content so native clients can correlate inputs with outputs.
1807+
/// </summary>
1808+
public IReadOnlyList<ChatToolContentInfo> ToolContent { get; set; } =
1809+
Array.Empty<ChatToolContentInfo>();
1810+
1811+
/// <summary>
1812+
/// Ordered text and tool blocks retained from array-valued message content.
1813+
/// Flat <see cref="Text"/> and <see cref="ToolContent"/> remain populated for
1814+
/// compatibility with consumers that do not need block-level chronology.
1815+
/// </summary>
1816+
public IReadOnlyList<ChatMessageContentPartInfo> ContentParts { get; set; } =
1817+
Array.Empty<ChatMessageContentPartInfo>();
1818+
18041819
/// <summary>
18051820
/// Optional gateway-assigned message state. "final" indicates a complete
18061821
/// terminal message; absent or other values indicate intermediate state.
@@ -1858,6 +1873,35 @@ public static bool IsSilentAssistantDirective(string? role, string? text) =>
18581873
public string? StopReason { get; set; }
18591874
}
18601875

1876+
public enum ChatToolContentKind
1877+
{
1878+
Call,
1879+
Result,
1880+
}
1881+
1882+
public class ChatToolContentInfo
1883+
{
1884+
public ChatToolContentKind Kind { get; set; }
1885+
public string? CallId { get; set; }
1886+
public string ToolName { get; set; } = "tool";
1887+
public JsonElement? Args { get; set; }
1888+
public string? Text { get; set; }
1889+
public bool IsError { get; set; }
1890+
}
1891+
1892+
public enum ChatMessageContentPartKind
1893+
{
1894+
Text,
1895+
Tool,
1896+
}
1897+
1898+
public class ChatMessageContentPartInfo
1899+
{
1900+
public ChatMessageContentPartKind Kind { get; set; }
1901+
public string? Text { get; set; }
1902+
public ChatToolContentInfo? Tool { get; set; }
1903+
}
1904+
18611905
/// <summary>
18621906
/// Result of a <c>chat.history</c> RPC: the full transcript for a session.
18631907
/// The gateway already applies display normalization (strips delivery

0 commit comments

Comments
 (0)