Skip to content

ADE-104 External session import: Codex project-scope discovery can truncate at the 2000-file scan ceiling -> Primary#892

Merged
arul28 merged 2 commits into
mainfrom
ade-104-external-session-import-codex-project-scope-discovery-can-truncate-at-the-2000-file-scan-ceiling
Jul 24, 2026
Merged

ADE-104 External session import: Codex project-scope discovery can truncate at the 2000-file scan ceiling -> Primary#892
arul28 merged 2 commits into
mainfrom
ade-104-external-session-import-codex-project-scope-discovery-can-truncate-at-the-2000-file-scan-ceiling

Conversation

@arul28

@arul28 arul28 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Fixes ADE-104

Linked Linear issues

ADE   Open in ADE  ·  ade-104-external-session-import-codex-project-scope-discovery-can-truncate-at-the-2000-file-scan-ceiling branch  ·  PR #892

Summary by CodeRabbit

  • Bug Fixes

    • Improved project-scoped Codex session discovery, including projects with many newer sessions outside the selected project.
    • Excluded Codex subagent rollouts from discovered sessions.
    • Improved session metadata handling for titles, working directories, creation times, and import eligibility.
  • Performance

    • Added caching to make repeated project-scoped Codex session discovery faster and more reliable.

Greptile Summary

This PR improves Codex external session discovery for project-scoped imports. The main changes are:

  • Adds a rebuildable cwd/importability index for Codex rollout metadata.
  • Removes the fixed project-scope scan limit that could hide older in-scope sessions.
  • Excludes structured-source Codex subagent rollouts from importable sessions.
  • Adds tests for large rollout inventories, index rewrite batching, and subagent filtering.
  • Updates external session import docs for the new Codex discovery behavior.

Confidence Score: 5/5

Safe to merge with low risk.

The changes are localized to Codex external-session discovery, add targeted tests for the previous truncation failure and cache behavior, and preserve existing non-scoped discovery paths.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The pre-proof environment state was captured from Ade104-01-before.log, showing 2,001 outside sessions and 1 project session.
  • The real targeted Vitest run was validated against Ade104-02-after.log, which shows the run completed successfully with 1 test file passed, 2 tests passed, 14 skipped, and exit code 0.
  • The test source used for validation was copied to Ade104-used-discoverProviders.test.ts and the copy was logged in Ade104-used-test-copy.log.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
apps/desktop/src/main/services/externalSessions/discoverCodex.ts Replaces the fixed project-scope scan limit with a rebuildable Codex cwd/importability index and excludes object-shaped subagent source metadata.
apps/desktop/src/main/services/externalSessions/discoverProviders.test.ts Adds coverage for project-scoped discovery beyond 2,000 newer rollouts, index rewrite batching, and subagent rollout exclusion.
docs/features/terminals-and-sessions/external-session-import.md Updates external session import documentation to describe the Codex scope index and stricter source/importability behavior.

Sequence Diagram

sequenceDiagram
  participant Caller as External session list
  participant Discover as discoverCodexSessions
  participant FS as Codex sessions dir
  participant Index as ADE cwd/importability index

  Caller->>Discover: request Codex sessions with scopeRoots
  Discover->>Index: load cached scope index
  Discover->>FS: stat rollout inventory
  loop each rollout file
    alt missing or changed index entry
      Discover->>FS: read session_meta prefix
      Discover->>Index: refresh mtime/size/meta entry
    else unchanged
      Index-->>Discover: reuse cached meta
    end
  end
  Discover->>Discover: filter importable sessions in scope
  Discover->>Index: write immediately or schedule batched rewrite
  Discover-->>Caller: sorted Codex session summaries
Loading

Reviews (2): Last reviewed commit: "Refs ADE-104: ship: iteration 1 — batch ..." | Re-trigger Greptile

@linear-code

linear-code Bot commented Jul 24, 2026

Copy link
Copy Markdown

ADE-104

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview Jul 24, 2026 7:15am

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Codex discovery now parses session metadata directly, derives importability from payload fields, and uses cached per-directory indexes for project-scoped rollouts. Discovery processing and tests cover indexed scope filtering and exclusion of object-shaped subagent sources.

Changes

Codex discovery

Layer / File(s) Summary
Metadata parsing and importability
apps/desktop/src/main/services/externalSessions/discoverCodex.ts
Adds bounded binary session_meta parsing, explicit importability evaluation, and candidate collection separated from mtime sorting.
Project-scoped indexing
apps/desktop/src/main/services/externalSessions/discoverCodex.ts
Adds validated on-disk scope indexes with in-memory caching, changed-file refreshes, deduplication, and atomic-style writes.
Discovery integration and tests
apps/desktop/src/main/services/externalSessions/discoverCodex.ts, apps/desktop/src/main/services/externalSessions/discoverProviders.test.ts
Uses metadata for JSONL filtering and fields, preserves JSONLZST handling, and tests scoped indexing plus subagent exclusion.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • arul28/ADE#797: Also changes Codex session discovery logic in discoverCodex.ts.

Suggested labels: desktop, docs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the Codex project-scope discovery fix and matches the PR’s main change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade-104-external-session-import-codex-project-scope-discovery-can-truncate-at-the-2000-file-scan-ceiling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/desktop/src/main/services/externalSessions/discoverCodex.ts (1)

605-611: 🚀 Performance & Scalability | 🔵 Trivial

Full-index rewrite on any single-file change may amplify writes on large Codex dirs.

indexChanged flips whenever one rollout's mtimeMs/size differs — which happens on every discovery while the current-day session is still being appended to. Each such run re-serializes and rewrites the entire index (all entries), so on a directory with thousands of rollouts this becomes a large JSON write on nearly every scoped discovery. Consider debouncing writes, batching, or only rewriting past a change threshold if this path runs frequently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/main/services/externalSessions/discoverCodex.ts` around
lines 605 - 611, Reduce full-index rewrites in the discovery flow around
indexChanged and writeCodexScopeIndex: avoid serializing and writing the entire
index for every single rollout mtimeMs/size update during active sessions.
Implement a scoped batching, debounce, or change-threshold policy while
preserving index updates and ensuring accumulated changes are eventually
persisted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/desktop/src/main/services/externalSessions/discoverCodex.ts`:
- Around line 605-611: Reduce full-index rewrites in the discovery flow around
indexChanged and writeCodexScopeIndex: avoid serializing and writing the entire
index for every single rollout mtimeMs/size update during active sessions.
Implement a scoped batching, debounce, or change-threshold policy while
preserving index updates and ensuring accumulated changes are eventually
persisted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c51085d-2750-434b-b0d6-3129a0e8c1ce

📥 Commits

Reviewing files that changed from the base of the PR and between bcd019d and d3c3023.

⛔ Files ignored due to path filters (1)
  • docs/features/terminals-and-sessions/external-session-import.md is excluded by !docs/**
📒 Files selected for processing (2)
  • apps/desktop/src/main/services/externalSessions/discoverCodex.ts
  • apps/desktop/src/main/services/externalSessions/discoverProviders.test.ts

@arul28

arul28 commented Jul 24, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 16f8a535c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@arul28
arul28 merged commit be1d431 into main Jul 24, 2026
34 checks passed
@arul28
arul28 deleted the ade-104-external-session-import-codex-project-scope-discovery-can-truncate-at-the-2000-file-scan-ceiling branch July 24, 2026 07:31
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