perf: optimize Claude Code discover() — use history.jsonl, batch lsof#96
Merged
Conversation
The discover() method was scanning 156 project dirs and 1,697 session files, timing out at 5s. Claude Code maintains ~/.claude/history.jsonl with every session's ID, project path, timestamp, and prompt text. - Read history.jsonl as primary discovery source (~2ms vs 5s+ timeout) - Fall back to project dir scanning only if history.jsonl doesn't exist - Batch lsof: single call for all PIDs instead of one per PID - Batch ps: single call for all start times instead of one per PID - Defer expensive fields (model, tokens) to status() calls Fixes #90 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
768f2d8 to
2b2026d
Compare
c-h-
added a commit
that referenced
this pull request
Mar 6, 2026
New features: - feat: add --file flag to launch command (#95) Bug fixes: - fix: insert -- separator before positional prompt args (#106) - fix: peek/status timeout on opencode sessions (#100) - fix: use temp file for large prompts instead of CLI args (#101) Performance: - perf: use history.jsonl for Claude Code discover(), batch lsof calls (#96) Co-Authored-By: Charlie Hulcher <charlie@kindo.ai>
Merged
c-h-
added a commit
that referenced
this pull request
Mar 6, 2026
New features: - feat: add --file flag to launch command (#95) Bug fixes: - fix: insert -- separator before positional prompt args (#106) - fix: peek/status timeout on opencode sessions (#100) - fix: use temp file for large prompts instead of CLI args (#101) Performance: - perf: use history.jsonl for Claude Code discover(), batch lsof calls (#96) Co-authored-by: Doink (OpenClaw) <charlie+doink@kindo.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
history.jsonlinstead of scanning all project dirs to find active Claude Code sessionslsofcalls for PID checks instead of one-per-sessiondiscover()from timeout (>5s) to <500msFixes #90
Test plan
--fileflag from feat: add --file flag to launch command #95)🤖 Generated with Claude Code