feat: enhance session handling and discovery#64
Conversation
Arbuzov
commented
Mar 3, 2026
- Implemented asynchronous reading of session files to improve performance and prevent blocking the event loop.
- Introduced caching mechanism to skip unchanged session files based on modification time.
- Added functionality to skip oversized session files during reading.
- Enhanced session discovery to support global scanning of all workspaces and project-specific filtering.
- Updated session panel to allow filtering by current project or all projects.
- Improved session rendering in the webview to display project names and current workspace status.
- Refactored session parsing to handle large JSONL files more efficiently.
- Added tests to ensure correct parsing and handling of session data.
- Implemented asynchronous reading of session files to improve performance and prevent blocking the event loop. - Introduced caching mechanism to skip unchanged session files based on modification time. - Added functionality to skip oversized session files during reading. - Enhanced session discovery to support global scanning of all workspaces and project-specific filtering. - Updated session panel to allow filtering by current project or all projects. - Improved session rendering in the webview to display project names and current workspace status. - Refactored session parsing to handle large JSONL files more efficiently. - Added tests to ensure correct parsing and handling of session data. Signed-off-by: Serge Arbuzov <Serge.Arbuzov@spacebridge.com>
23min
left a comment
There was a problem hiding this comment.
I really like the global session discovery and the performance improvements! The caching, event-loop yielding, and project grouping UX are well done. A few issues to address before merging:
| const nonEmpty = byProvider.filter((s) => s.requests.length > 0); | ||
| const emptyCount = byProvider.length - nonEmpty.length; | ||
| if (this.currentScope === "current-project") { | ||
| filtered = filtered.filter((s) => s.isCurrentWorkspace !== false); |
There was a problem hiding this comment.
Bug: double scope filtering with inconsistent logic. The extension host filters here using !== false (passes true and undefined), but the webview also filters in renderSessionList() using s.isCurrentWorkspace (only passes true). Sessions with undefined will behave differently depending on which filter runs. I'd suggest removing one — either filter server-side here and trust the webview to render what it receives, or keep it client-side only for faster toggling without a round-trip.
| // Check cache by mtime to skip unchanged files | ||
| const stats = await fs.stat(entry.fullPath); | ||
| const cached = this.sessionCache.get(entry.fullPath); | ||
| if (cached && cached.mtimeMs === stats.mtimeMs) { |
There was a problem hiding this comment.
Bug: subagent updates missed by cache. The cache keys on the main session file's mtime only. If a subagent .jsonl file is updated but the main file isn't touched, the stale cached session is returned and subagent changes are never reflected.
|
|
||
| if (discoverAll) { | ||
| // Global mode: watch all projects under ~/.claude/projects/ | ||
| const claudeProjectsRoot = path.join(os.homedir(), ".claude", "projects"); |
There was a problem hiding this comment.
Missing watch target: In global mode, only ~/.claude/projects/**/*.jsonl is watched. If the user has a custom claudeDir configured, changes there won't trigger a refresh.
| "agentLens.discoverAllProjects": { | ||
| "type": "boolean", | ||
| "default": true, | ||
| "markdownDescription": "Discover sessions from **all** projects across Claude, Copilot, and Codex — not just the current workspace. Disable to show only sessions for the open workspace." |
There was a problem hiding this comment.
Misleading docs: The description says "Claude, Copilot, and Codex" but the Codex provider doesn't read this setting — it always scans all sessions. Either update Codex to respect the setting, or narrow the description.
|
Hi @Arbuzov — thanks for this contribution! The global session discovery and performance improvements are great work. Since it's been a week without response on the review feedback, I'm going to pick this up, address the remaining issues, and merge it. Appreciate your effort on this! |