Skip to content

Commit 5505a85

Browse files
RBridCopilot
andauthored
Native chat: cross-turn overwrite + reasoning bubbles + exec.approval delivery + multi-segment dedup (#676)
Co-authored-by: Copilot <[email protected]>
1 parent 0e61fa2 commit 5505a85

14 files changed

Lines changed: 2365 additions & 78 deletions

File tree

‎src/OpenClaw.Chat/ChatModels.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,14 @@ public record ChatUserMessageEvent(string Text, string? Nonce = null) : ChatEven
134134
public record ChatThinkingEvent(string Text) : ChatEvent;
135135
public record ChatReasoningEvent(string Text) : ChatEvent;
136136
public record ChatReasoningDeltaEvent(string Text) : ChatEvent;
137-
public record ChatMessageEvent(string Text, string? ReasoningText = null, bool ReconcilePrevious = false) : ChatEvent;
137+
/// <summary>
138+
/// Closes the current reasoning section so the next reasoning chunk starts a
139+
/// fresh bubble instead of appending/replacing the previous one. Emitted from
140+
/// the gateway's <c>stream:"item", kind:"reasoning", phase:"end"</c> bracket
141+
/// marker that delimits each distinct thinking pass within a single turn.
142+
/// </summary>
143+
public record ChatReasoningEndEvent() : ChatEvent;
144+
public record ChatMessageEvent(string Text, string? ReasoningText = null, bool ReconcilePrevious = false, bool IsStreaming = false) : ChatEvent;
138145
public record ChatMessageDeltaEvent(string Text) : ChatEvent;
139146
public record ChatTurnEndEvent() : ChatEvent;
140147
public record ChatIntentEvent(string Intent) : ChatEvent;

‎src/OpenClaw.Chat/ChatTimelineReducer.cs‎

Lines changed: 354 additions & 8 deletions
Large diffs are not rendered by default.

‎src/OpenClaw.Connection/GatewayConnectionManager.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,8 @@ public void Info(string message)
13101310

13111311
public void Debug(string message) => _inner.Debug(message);
13121312

1313+
public void Trace(string message) => _inner.Trace(message);
1314+
13131315
public void Warn(string message)
13141316
{
13151317
_inner.Warn(message);

‎src/OpenClaw.SetupEngine/SetupSteps.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ internal sealed class SetupOpenClawLogger(SetupLogger logger) : IOpenClawLogger
200200
{
201201
public void Info(string message) => logger.Info($"[WS] {message}");
202202
public void Debug(string message) => logger.Debug($"[WS] {message}");
203+
// Trace intentionally drops to the default no-op: setup-engine sessions
204+
// are short-lived and don't normally drive agent-event traffic, and there
205+
// is no OPENCLAW_TRAY_TRACE-style opt-in gate available here. Letting the
206+
// interface default (no-op) apply keeps verbose lines out of setup logs.
207+
public void Trace(string message) { }
203208
public void Warn(string message) => logger.Warn($"[WS] {message}");
204209
public void Error(string message, Exception? ex = null) => logger.Error($"[WS] {message}{(ex != null ? $": {ex}" : "")}");
205210
}

‎src/OpenClaw.Shared/IOpenClawLogger.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ public interface IOpenClawLogger
1010
void Debug(string message);
1111
void Warn(string message);
1212
void Error(string message, Exception? ex = null);
13+
14+
// Verbose diagnostic channel. Default implementation drops the call so
15+
// existing implementers (tests, console logger, etc.) don't need to be
16+
// updated. Implementations that have a backing log file can opt in and
17+
// gate output behind a flag.
18+
void Trace(string message) { }
1319
}
1420

1521
/// <summary>

‎src/OpenClaw.Shared/OpenClawGatewayClient.cs‎

Lines changed: 345 additions & 0 deletions
Large diffs are not rendered by default.

‎src/OpenClaw.Tray.WinUI/AppLogger.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ internal sealed class AppLogger : IOpenClawLogger
1010
public void Warn(string message) => Logger.Warn(message);
1111
public void Error(string message, Exception? ex = null) =>
1212
Logger.Error(ex != null ? $"{message}: {ex.Message}" : message);
13+
public void Trace(string message) => Logger.Trace(message);
1314
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public interface IChatGatewayBridge : IDisposable
3939
Task PatchSessionThinkingLevelAsync(string sessionKey, string thinkingLevel);
4040
Task<ChatHistoryInfo> RequestChatHistoryAsync(string? sessionKey);
4141
Task SendChatAbortAsync(string runId, string? sessionKey = null);
42+
Task ResolveExecApprovalAsync(string approvalId, string decision);
4243

4344
event EventHandler<ConnectionStatus>? StatusChanged;
4445
event EventHandler<SessionInfo[]>? SessionsUpdated;
@@ -161,6 +162,9 @@ public Task<ChatHistoryInfo> RequestChatHistoryAsync(string? sessionKey) =>
161162

162163
public Task SendChatAbortAsync(string runId, string? sessionKey = null) => _client.SendChatAbortAsync(runId, sessionKey);
163164

165+
public Task ResolveExecApprovalAsync(string approvalId, string decision) =>
166+
_client.ResolveExecApprovalAsync(approvalId, decision);
167+
164168
public event EventHandler<ConnectionStatus>? StatusChanged;
165169
public event EventHandler<SessionInfo[]>? SessionsUpdated;
166170
public event EventHandler<ChatMessageInfo>? ChatMessageReceived;

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

Lines changed: 168 additions & 69 deletions
Large diffs are not rendered by default.

‎src/OpenClaw.Tray.WinUI/Services/Logger.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,19 @@ static Logger()
8383

8484
public static string LogFilePath => _logFilePath;
8585

86+
// OPENCLAW_TRAY_TRACE=1 surfaces verbose protocol traces that are normally
87+
// suppressed (e.g. per-event kind/phase dumps from the gateway client).
88+
// Off by default so day-to-day logs aren't drowned in low-signal lines;
89+
// diagnosis sessions can opt in without rebuilding.
90+
private static readonly bool s_traceEnabled =
91+
string.Equals(Environment.GetEnvironmentVariable("OPENCLAW_TRAY_TRACE"), "1", StringComparison.Ordinal) ||
92+
string.Equals(Environment.GetEnvironmentVariable("OPENCLAW_TRAY_TRACE"), "true", StringComparison.OrdinalIgnoreCase);
93+
8694
public static void Info(string message) => Log("INFO", message);
8795
public static void Warn(string message) => Log("WARN", message);
8896
public static void Error(string message) => Log("ERROR", message);
8997
public static void Debug(string message) => Log("DEBUG", message);
98+
public static void Trace(string message) { if (s_traceEnabled) Log("TRACE", message); }
9099

91100
private static void Log(string level, string message)
92101
{

0 commit comments

Comments
 (0)