Repository navigation
Description
Description
Summary
The Copilot CLI chat-sessions provider (CopilotCLIChatSessionContentProvider) re-enumerates the entire Copilot CLI session store on every refresh — no incremental update, cache, or cap. provideChatSessionItems (logged as listSessions took <n>ms) calls getAllSessions() and maps every session. It's triggered constantly: a 5s poll runs while any CLI session is active (setInterval(updateActiveSessionsOnly, 5000)), and any session-state change fires _onDidChangeChatSessionItems, each re-triggering the full walk. With a large store this takes seconds to minutes and stalls the extension host Copilot Chat runs on — multiplied across open windows.
Impact
- Chat turns become very slow.
- The affected window's UI thread stalls, causing keyboard input lag (keystrokes queue, then burst in).
- "Extension host unresponsive" events.
Evidence (my machine)
- Store: ~6,000 CLI sessions / 3.4 GB under
~/.copilot/session-state, plus a 256 MBsession-store.db. I drive the CLI from scripts (~300 sessions/day), so it accumulates fast and nothing prunes it. GitHub Copilot Chat.log:listSessions tookwas typically 2,500–5,500 ms, spiking to 39,000 ms, 71,000 ms, and 312,000 ms (5+ minutes).- One window logged 67
listSessionscalls totaling ~36 min of extension-host time; another logged 220 calls. - After pruning the store to ~670 sessions,
listSessionsdropped to a steady ~400 ms.
Root cause (bundled dist/extension.js, Copilot Chat 0.58.0)
provideChatSessionItems→getAllSessions()enumerates all sessions unconditionally, thenPromise.all(map(toChatSessionItem))over all of them.startActiveSessionPolling()=setInterval(updateActiveSessionsOnly, 5000)while any session is active; changes fire_onDidChangeChatSessionItems→ full re-walk.github.copilot.chat.cli.showExternalSessions=falseonly filters display (per-itemshouldShowSession); it does not short-circuit thegetAllSessions()walk, so it doesn't address the cost.
Expected
The provider shouldn't do an O(N) full-store enumeration on every refresh/poll. Options: incremental updates for active-session changes; cache with invalidation; pagination/cap; back off the 5s poll; and/or a first-party retention/prune for the CLI session store (it currently grows unbounded — no cleanup command or setting exists).
Workarounds
- Prune
~/.copilot/session-state+session-store.db(restored ~400 ms). showExternalSessions=falsehelps partially (skips per-item display work), not the walk.
Environment
- VS Code 1.130.0 (e5381e4)
- GitHub Copilot Chat 0.58.0
- Windows 11, Node ≥ 22
Issue Details
| Item | Value |
|---|---|
| Issue Category | Performance Issue |
| Target | Agents Window |
| VS Code Version | Code 1.130.0 (e5381e4, 2026-07-21T13:18:50+05:00) |
| OS Version | Windows_NT x64 10.0.26310 |
Activity
KHARSHAVARDHAN-eng commentedon Jul 22, 2026
Thanks for the detailed investigation and performance analysis!
I've been looking into this issue and would be interested in working on a fix if there isn't already an implementation in progress.
From my initial investigation, it appears the repeated full session enumeration on refresh is indeed the primary performance bottleneck, especially for large CLI session stores.
Before I start implementing anything, could a maintainer let me know whether this issue is open for external contributions, or if someone on the team is already working on it?
Thanks!
3v1n0 commentedon Sep 16, 2026
This is definitely an issue, and even more because this happens in a SYNC way in the UI process, blocking it.
The interface hangs forever of time in some old workspaces I have, making vscode completely unusable without
chat.disableAIFeatures:chat.disableAIFeaturesbeing set #336421 as a duplicate of this issuealexdima commentedon Nov 10, 2026
Thanks for the detailed analysis. This should be fixed on current Insiders. #345095 changed the Copilot CLI provider so a refresh lists only session ids and times, and drops sessions created outside VS Code (and ones the agent host already owns) before reading anything else. Details are cached per session by modified time, and the 5 s full re-walk is gone.
What I checked on Insiders 1.146.0 (macOS arm64), with
COPILOT_HOMEpointing at a store of 6,000 CLI sessions created bygithub/cliover 20 days:listSessions tookwas 1.7 s once at startup, then 120 ms on the next refresh. There were no repeated walks while a session was active.I tested on macOS rather than Windows, but the change isn't platform-specific. If you still see long
listSessions tooktimes on a current Insiders, please reopen with the log lines. A retention or prune option for the CLI session store would be a separate feature request.i327021-6000-sessions.mp4
🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).