Skip to content

Avoid full Codex session reads when listing and looking up sessions#2

Open
Vottivott wants to merge 1 commit intovignesh07:mainfrom
Vottivott:fix/codex-session-scan
Open

Avoid full Codex session reads when listing and looking up sessions#2
Vottivott wants to merge 1 commit intovignesh07:mainfrom
Vottivott:fix/codex-session-scan

Conversation

@Vottivott
Copy link

Summary

This fixes two Codex-specific performance problems in ccshare:

  • avoid reading entire Codex .jsonl files just to extract the first-line session_meta.cwd
  • avoid doing a full listSessions() scan when the user already provided an explicit Codex session id

Changes

  • add a bounded readFirstLine() helper for Codex metadata discovery
  • make Codex session listing read only the first line of each file
  • add a direct Codex session lookup path by exact id / unique prefix
  • keep the existing fallback behavior for Claude, Gemini, and numeric index lookups

Why

Large Codex session files can be multiple GB. The previous implementation used readFile(..., 'utf-8') for every Codex session during list, and also for explicit session-id operations because getSession() always went through listSessions() first.

That makes ccshare list and ccshare share/export/preview <codex-session-id> unsafe on large histories.

Verification

Manual verification in an isolated temp HOME:

  • bun run src/cli.ts list --limit 5 succeeded with a 1 GB sparse Codex session file
  • bun run src/cli.ts export 019c70c7-9e1f-70c1-84a8-1405892852f1 -o out.html succeeded with an explicit Codex session id

Notes

I did not rely on tsc --noEmit for validation here because the repo currently has unrelated missing dependency / type environment issues in this environment.

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