Skip to content

feat: enhance session handling and discovery#64

Open
Arbuzov wants to merge 1 commit into23min:mainfrom
Arbuzov:feature/global-session-discovery
Open

feat: enhance session handling and discovery#64
Arbuzov wants to merge 1 commit into23min:mainfrom
Arbuzov:feature/global-session-discovery

Conversation

@Arbuzov
Copy link

@Arbuzov 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>
Copy link
Owner

@23min 23min left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@23min 23min self-assigned this Mar 13, 2026
@23min
Copy link
Owner

23min commented Mar 13, 2026

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!

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.

2 participants