From 870c9f0b999564dd3ed05fee0c280d93d27e318b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 23:20:55 +0100 Subject: [PATCH] refactor: stop pinning hardcoded main session in chat UI --- CHANGELOG.md | 1 + .../Sources/ClawdbotChatUI/ChatViewModel.swift | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 078d5c6a0..28590fe3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ - Cron: parse Telegram topic targets for isolated delivery. (#478) — thanks @nachoiacovino - Cron: enqueue main-session system events under the resolved main session key. (#510) - Mobile: centralize main session key normalization for iOS/Android runtime helpers. — thanks @steipete +- Chat UI: stop pinning hardcoded `main` session in the recent list; prefer active session if missing. — thanks @steipete - Outbound: default Telegram account selection for config-only tokens; remove heartbeat-specific accountId handling. (follow-up #516) — thanks @YuriNachos - Cron: allow Telegram delivery targets with topic/thread IDs (e.g. `-100…:topic:123`). (#474) — thanks @mitschabaude-bot - Heartbeat: resolve Telegram account IDs from config-only tokens; cron tool accepts canonical `jobId` and legacy `id` for job actions. (#516) — thanks @YuriNachos diff --git a/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatViewModel.swift b/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatViewModel.swift index 7a68a8c18..aa72c8acc 100644 --- a/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatViewModel.swift +++ b/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatViewModel.swift @@ -112,24 +112,19 @@ public final class ClawdbotChatViewModel { recent.append(entry) } - let mainKey = "main" var result: [ClawdbotChatSessionEntry] = [] var included = Set() - if let main = sorted.first(where: { $0.key == mainKey }) { - result.append(main) - included.insert(mainKey) - } else if self.sessionKey == mainKey { - result.append(self.placeholderSession(key: mainKey)) - included.insert(mainKey) - } - for entry in recent where !included.contains(entry.key) { result.append(entry) included.insert(entry.key) } if !included.contains(self.sessionKey) { - result.append(self.placeholderSession(key: self.sessionKey)) + if let current = sorted.first(where: { $0.key == self.sessionKey }) { + result.append(current) + } else { + result.append(self.placeholderSession(key: self.sessionKey)) + } } return result