Skip to content

Load session list dynamically from ACP backend - #23

Open
gitricko wants to merge 3 commits into
mainfrom
fix/dynamic-session-list
Open

Load session list dynamically from ACP backend#23
gitricko wants to merge 3 commits into
mainfrom
fix/dynamic-session-list

Conversation

@gitricko

Copy link
Copy Markdown
Owner

Summary

The extension loses the session list on browser reload because SessionStore stores everything in VS Code workspaceState — which is in-memory only in code-server. The Hermes ACP backend already has a list_sessions RPC returning all sessions from its own state.db, but the extension never called it.

Fix: On ACP connection, call list_sessions and populate the session list dynamically. Backend is the source of truth — no file fallback, no dual persistence needed.

Changes (4 files, +52 lines)

File Change
sessionManager.ts Added listSessions() — calls ACP list_sessions RPC
sessionStore.ts Added addBackendSession() — inserts a backend session without activating it
chatPanel.ts Added syncSessionsFromBackend() — merges backend sessions into the store, deduped by acpSessionId
extension.ts Calls panel.syncSessionsFromBackend() after client.start() succeeds

How it works

Extension activate → client.start() → ACP connected
  → syncSessionsFromBackend()
    → acpClient.call(list_sessions, {})
    → Backend returns [{sessionId, title, updatedAt}, ...]
    → Store adds sessions not already present
    → Session list broadcast to webview

User clicks an old session → switchSessionsession/load restores Hermes context → works immediately.

How to test

  1. Open the Hermes chat panel and start a few sessions (each creates a row in Hermes state.db)
  2. Reload the browser tab
  3. Before fix: session list is empty, only "new session" shows
  4. After fix: old sessions appear in the list with their titles, clickable and resumable

Tradeoffs

  • Old sessions restored from the backend show with their titles but empty message history in the chat panel (messages are in Hermes state.db but not returned by session/load). The session context IS restored on Hermes side — you can continue chatting from where you left off.
  • Adding a session/get_history backend endpoint later would let us load the previous turns into the UI too.

Gram Ricko added 3 commits June 21, 2026 08:17
The extension stored session metadata only in VS Code workspaceState,
which is in-memory only in code-server — lost on browser reload.

Now on ACP connect, the extension calls the backend's built-in
list_sessions RPC and populates the session list dynamically.
Clicking an old session calls session/load to restore Hermes context.

No file fallback or dual persistence needed — backend is the source of truth.
The ACP protocol method is session/list (kebab slash), not list_sessions.
Confirmed in acp/meta.py: AGENT_METHODS['session_list'] = 'session/list'.
Previous build was silently failing — the call returned an error and
listSessions() returned empty, so no backend sessions appeared in the UI.

Local testing showed only the 2 'hi' sessions (created in the local store
on this session) were visible — the 5 backend sessions in state.db were
never synced because the RPC call was returning an error response that
got swallowed by the empty-array fallback.

Field names (sessionId, title, updatedAt) are correct — Pydantic
serializes with by_alias=True so camelCase comes over the wire.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant