From 1c2939dbbe1fcadfb0adc00248134a480aecc66b Mon Sep 17 00:00:00 2001 From: Alan Wizemann Date: Fri, 24 Apr 2026 14:33:18 +0200 Subject: [PATCH] M7 #15 (pass-2): load transcript from state.db on session resume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass-2 observation: "When selecting a previous session from the dashboard, the chat opens, loads, but starts fresh — we should load the session with previous work like we do on the mac..." The Mac's resume path does two things: (a) call session/resume on ACPClient to re-bind Hermes to the session id, and (b) call `richChatViewModel.loadSessionHistory(sessionId:acpSessionId:)` to pull the persisted transcript out of state.db and populate the message list. ScarfGo only did (a) — the ACP channel was wired up correctly, but there was no SQLite read, so the UI showed an empty bubble list until the user sent their first new prompt. Added the loadSessionHistory call right after setSessionId in ChatController.startResuming. It internally calls `dataService.refresh()` first so the snapshot reflects whatever Hermes wrote between the Dashboard's last SQLite pull and the resume tap. The acpSessionId param is nil when resume preserved the id (no origin-vs-ACP split needed) and set to the resolved id otherwise so the CLI + ACP message streams can be merged chronologically — same behaviour the Mac gets. Co-Authored-By: Claude Opus 4.7 (1M context) --- scarf/Scarf iOS/Chat/ChatView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scarf/Scarf iOS/Chat/ChatView.swift b/scarf/Scarf iOS/Chat/ChatView.swift index 15d3dbd..0ca1825 100644 --- a/scarf/Scarf iOS/Chat/ChatView.swift +++ b/scarf/Scarf iOS/Chat/ChatView.swift @@ -644,6 +644,16 @@ final class ChatController { resolvedID = try await client.loadSession(cwd: home, sessionId: sessionID) } vm.setSessionId(resolvedID) + // Pull the transcript out of state.db so the user sees + // everything said up to now. Mirrors the Mac resume flow + // (scarf/scarf/Features/Chat/ViewModels/ChatViewModel.swift:376). + // `loadSessionHistory` refreshes the SQLite snapshot first + // so we pick up messages Hermes wrote between the + // Dashboard's last load and now. + await vm.loadSessionHistory( + sessionId: sessionID, + acpSessionId: resolvedID == sessionID ? nil : resolvedID + ) state = .ready } catch { state = .failed(error.localizedDescription)