Skip to content

Commit 959b352

Browse files
RomneyDashanselmanCopilot
authored
fix: show readable session names across Windows UX (#983)
* fix: render sessions with friendly presentation metadata * fix: harden legacy session presentation fallbacks * fix: use valid session wrapper tuple names * fix: preserve sparse session presentation updates * fix: preserve legacy main identity on sparse updates * fix: decouple session localization from test runtime * fix: align session presentation drift guard * fix: complete session title localization * fix(chat): retain session title tooltips * fix: deep-copy nested session state and harden ended-session surfaces - SessionInfo.Clone() now deep-copies Presentation and Worktree objects so defensive snapshots cannot alias live tracked session state (#1012). - TrayDashboardSummary.SelectActiveSession prefers non-ended sessions as the fallback display item, preserving AbortedLastRun visibility. - Add snapshot isolation tests proving clone independence. - Add runtime behavior tests for ended/background/routing pipeline. - Add dashboard ended-session deprioritization tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c311ae3b-8656-403f-91a6-5bfe2f91f5cd --------- Co-authored-by: Scott Hanselman <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent 6c54e5e commit 959b352

27 files changed

Lines changed: 1728 additions & 173 deletions

‎src/OpenClaw.Chat/ChatModels.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ public record ChatThread
9696
{
9797
public required string Id { get; init; }
9898
public required string Title { get; init; }
99+
public string? AgentId { get; init; }
100+
public bool IsBackground { get; init; }
101+
public bool IsVisibleInSessionPicker(string? activeThreadId) =>
102+
!IsBackground || string.Equals(Id, activeThreadId, StringComparison.Ordinal);
99103
public ChatThreadStatus Status { get; init; }
100104
public ChatActivity Activity { get; init; }
101105
public string? Cwd { get; init; }
@@ -231,9 +235,9 @@ public record ChatDataSnapshot(
231235
/// and accepts <see cref="IChatDataProvider.SendMessageAsync"/> calls keyed by
232236
/// <see cref="SessionKey"/>.
233237
/// </param>
234-
public sealed record ChatComposeTarget(string? SessionKey, bool IsReady)
238+
public sealed record ChatComposeTarget(string? SessionKey, bool IsReady, string? AgentId = null)
235239
{
236-
public static ChatComposeTarget NotReady { get; } = new(null, false);
240+
public static ChatComposeTarget NotReady { get; } = new(null, false, null);
237241
}
238242

239243
public sealed class ChatDataChangedEventArgs(ChatDataSnapshot snapshot) : EventArgs

‎src/OpenClaw.Shared/Models.cs‎

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,70 @@ private static bool TryGetBool(JsonElement parent, string property) =>
251251
}
252252
}
253253

254+
public sealed class SessionPresentationInfo
255+
{
256+
public string Title { get; set; } = "";
257+
public string TitleSource { get; set; } = "generated";
258+
public string? Subtitle { get; set; }
259+
public string Family { get; set; } = "custom";
260+
public string? AgentId { get; set; }
261+
public string? Channel { get; set; }
262+
public string? AccountId { get; set; }
263+
public string? PeerKind { get; set; }
264+
public bool IsMain { get; set; }
265+
public bool IsBackground { get; set; }
266+
}
267+
268+
public sealed class SessionWorktreeInfo
269+
{
270+
public string? Id { get; set; }
271+
public string? Branch { get; set; }
272+
public string? RepoRoot { get; set; }
273+
}
274+
254275
public class SessionInfo
255276
{
256277
/// <summary>Defensive copy so a snapshot handed to a SessionsUpdated subscriber does not
257278
/// alias the live tracked instance (whose fields are mutated in place under _sessionsLock).</summary>
258-
public SessionInfo Clone() => (SessionInfo)MemberwiseClone();
279+
public SessionInfo Clone()
280+
{
281+
var copy = (SessionInfo)MemberwiseClone();
282+
if (copy.Presentation is { } p)
283+
copy.Presentation = new SessionPresentationInfo
284+
{
285+
Title = p.Title, TitleSource = p.TitleSource, Subtitle = p.Subtitle,
286+
Family = p.Family, AgentId = p.AgentId, Channel = p.Channel,
287+
AccountId = p.AccountId, PeerKind = p.PeerKind,
288+
IsMain = p.IsMain, IsBackground = p.IsBackground,
289+
};
290+
if (copy.Worktree is { } w)
291+
copy.Worktree = new SessionWorktreeInfo
292+
{
293+
Id = w.Id, Branch = w.Branch, RepoRoot = w.RepoRoot,
294+
};
295+
return copy;
296+
}
259297

260298
public string Key { get; set; } = "";
261299
public bool IsMain { get; set; }
300+
internal bool IsMainResolved { get; set; }
301+
public string? Label { get; set; }
262302
public string Status { get; set; } = "unknown";
263303
public string? Model { get; set; }
264304
public string? Channel { get; set; }
265305
public string? DisplayName { get; set; }
306+
public string? DerivedTitle { get; set; }
266307
public string? Provider { get; set; }
267308
public string? Subject { get; set; }
268309
public string? Room { get; set; }
269310
public string? Space { get; set; }
311+
public string? ChatType { get; set; }
312+
public string? OriginLabel { get; set; }
313+
public SessionWorktreeInfo? Worktree { get; set; }
314+
public string? ExecNode { get; set; }
315+
public string? ParentSessionKey { get; set; }
316+
public int? SpawnDepth { get; set; }
317+
public SessionPresentationInfo? Presentation { get; set; }
270318
public string? SessionId { get; set; }
271319
public string? ThinkingLevel { get; set; }
272320
public string? VerboseLevel { get; set; }
@@ -304,9 +352,7 @@ public string RichDisplayText
304352
{
305353
get
306354
{
307-
var title = !string.IsNullOrWhiteSpace(DisplayName)
308-
? DisplayName!
309-
: (IsMain ? "Main session" : "Session");
355+
var title = SessionPresentationResolver.Resolve(this).Title;
310356

311357
// Fixed-size array avoids List<string> allocation; at most 9 detail slots.
312358
var details = new string?[9];
@@ -349,26 +395,7 @@ public string ContextSummaryShort
349395
/// <summary>Gets a shortened, user-friendly version of the session key.</summary>
350396
public string ShortKey
351397
{
352-
get
353-
{
354-
if (string.IsNullOrEmpty(Key)) return "unknown";
355-
356-
// Extract meaningful part from session keys like "agent:main:subagent:uuid"
357-
var parts = Key.Split(':');
358-
if (parts.Length >= 3)
359-
{
360-
// Return something like "subagent" or "cron"
361-
return parts[^2]; // Second to last part
362-
}
363-
364-
// For file paths, just return filename
365-
if (Key.Contains('/') || Key.Contains('\\'))
366-
{
367-
return Path.GetFileName(Key);
368-
}
369-
370-
return Key.Length > 20 ? Key[..17] + "..." : Key;
371-
}
398+
get => SessionPresentationResolver.Resolve(this).Title;
372399
}
373400

374401
}

0 commit comments

Comments
 (0)