From 5340e70dd3920069b3e601b72d3064a3353b1972 Mon Sep 17 00:00:00 2001 From: Alan Wizemann Date: Fri, 24 Apr 2026 00:58:07 +0200 Subject: [PATCH] fix(projects): watch session-project-map so Sessions tab refreshes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ProjectSessionsView's `.onChange(of: fileWatcher.lastChangeDate)` was silently never firing when a new chat attributed a session to a project — the sidecar was written correctly, the session was in state.db correctly, attribution IDs matched exactly, but the per- project Sessions list didn't auto-refresh. Root cause: HermesFileWatcher.watchedCorePaths was missing `paths.sessionProjectMap` (`~/.hermes/scarf/session_project_map.json`, introduced in the v2.3 feature commit). Since the watcher didn't observe that file, writes from SessionAttributionService.persist produced no `lastChangeDate` change, the VM's onChange never ran, and the Sessions tab stayed empty until the user navigated away and back (triggering .task(id: project.id) to re-fire). One-line fix: add the sidecar to the watched-paths array. Now the flow works end-to-end: 1. User clicks "New Chat" on a project 2. ChatViewModel starts ACP session with cwd=project.path 3. SessionAttributionService.attribute writes the sidecar 4. HermesFileWatcher detects the change, bumps lastChangeDate 5. ProjectSessionsView's onChange fires, VM reloads, new session appears in the list immediately 80/80 tests still pass. No test change needed — the sidecar's direct tests are in SessionAttributionServiceTests; this is a file-watching integration fix. Co-Authored-By: Claude Opus 4.7 (1M context) --- scarf/scarf/Core/Services/HermesFileWatcher.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scarf/scarf/Core/Services/HermesFileWatcher.swift b/scarf/scarf/Core/Services/HermesFileWatcher.swift index 7a8c78e..1b20aae 100644 --- a/scarf/scarf/Core/Services/HermesFileWatcher.swift +++ b/scarf/scarf/Core/Services/HermesFileWatcher.swift @@ -35,6 +35,16 @@ final class HermesFileWatcher { paths.errorsLog, paths.gatewayLog, paths.projectsRegistry, + // v2.3: sidecar attributing Hermes session IDs to Scarf project + // paths. Written by SessionAttributionService when a chat + // starts with a project context; read by + // ProjectSessionsViewModel to filter the session list. Without + // watching this file, the per-project Sessions tab would only + // pick up new sessions when the user re-entered the tab + // (triggering .task(id:) re-fire) — switching directly back + // to the project's Sessions tab after a chat left the tab + // stale. + paths.sessionProjectMap, paths.mcpTokensDir ] }