Skip to content

fix(search): include undated Cursor sessions in time filters - #31991

Merged
nwparker merged 2 commits into
mainfrom
nwparker/cursor-search-timestamps
Oct 23, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/cursor-search-timestamps

Conversation

@nwparker

@nwparker nwparker commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​205 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​205
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​84 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​52

ELI5

What was broken: Cursor's transcript files contain no timestamps, so Orca's session search index saved every Cursor session with "last updated = unknown". As a result orca search --since ... dropped every Cursor session, and --sort newest couldn't place them. (Timestamp part of #28255.)

What changes for the user:

  • An undated Cursor session now uses its transcript file's last-modified time, so it shows up in --since filters and sorts correctly by newest. Sessions that already carry a real date (from the transcript or Cursor's meta.json) keep that date.
  • Existing indexes repair themselves on next launch. Null Cursor dates are filled in from the file time the index already recorded, with no transcript re-read and no index rebuild.
  • When the search index commits a Cursor session, it now includes the sidecar metadata (meta.json date/cwd/title) that Session History already shows. Before, it stored only the raw transcript data.

How

  • session-search-file-records.ts: updated_at falls back to modifiedAt (final and provisional chunk writes), only for agent = 'cursor'.
  • session-search-schema.ts: idempotent UPDATE on every open for Cursor rows where updated_at IS NULL, using files.mtime_ms truncated to whole ms so the result matches Date#toISOString exactly. It uses the sessions_agent index and does nothing once repaired.
  • session-transcript-reader.ts / session-scanner-parse-cache.ts: sidecar enrichment now runs before finishRead, so consumers commit the enriched session. The parse cache still stores the raw fold, so a later sidecar-only change still re-merges. A cancel during enrichment throws and the read does not commit.

Verification

  • Real data, end to end (throwaway harness, not checked in): I copied the 82 real Cursor CLI transcripts on this Mac to a scratch home and ran the real scanAiVaultSessions -> search index consumer -> SessionSearchEngine path:
    • main: 82 Cursor rows, 82 with updated_at NULL, --since 2020-01-01 returns 0 hits.
    • this PR: 82 rows, 0 NULL, --since returns hits sorted newest first (e.g. 2026-06-02T07:38:43.857Z).
    • Upgrade path: I built the index with main, then reopened it with this PR without rescanning. All 82 rows were repaired and the dates matched a fresh scan to the millisecond. A review fix was needed here: before it, SQLite rounding put repaired dates 1 ms off.
  • pnpm test src/main/ai-vault-search src/main/ai-vault: 1944 passed, 1 skipped (the skip already exists).
  • New regression file session-search-cursor-timestamps.test.ts: 5 of its 7 cases fail against main's source. The repair case also fails without the truncation fix (.876Z vs .875Z).

Risks / tradeoffs

  • File mtime is a best-effort date. If something rewrites Cursor transcript mtimes in bulk (restore from backup, sync tools), those sessions look recently updated. Real timestamps always take precedence.
  • Devin uses the same enrichment step, so a session the user hid in Devin's UI is now also left out of search, matching Session History. Before, it still appeared in search. If such a session is later un-hidden, it comes back to search only when its transcript changes.
  • Out of scope, unchanged: project-based Cursor cwd inference, wrapper-tag titles, and metadata-only sidecar changes (search freshness keys on the transcript's stat).
  • Mixed versions: the index is local to each host, so an older remote host keeps returning null dates for its own Cursor sessions until it updates. Nothing changes in the wire format.

Related

Visual proof: n/a (main-process search index change, no UI change).

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Transcript readers can enrich sessions before publishing them to the message channel, with cancellation checked before read completion. Session search uses Cursor file modification times when session timestamps are absent. Database setup repairs null Cursor timestamps from matching file metadata. Tests cover timestamp filtering, sorting, append behavior, metadata precedence, cancellation, and database reopen repair.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to f3ce0

Cancelled Devin scans can still mutate the parse cache and return session data; the localized guard should be added.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: including undated Cursor sessions in time filters.
Description check Passed The description is detailed and covers the problem, user impact, implementation, testing, risks, and visual proof. It includes an issue reference and explains why the change does not close it. Some te…
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.
Full details: Description check

Explanation

The description is detailed and covers the problem, user impact, implementation, testing, risks, and visual proof. It includes an issue reference and explains why the change does not close it. Some template sections are omitted or not explicitly completed, including Why, Review, Agent skill upstream boundary, Notes, and Checklist.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

SQLite rounds sub-millisecond file times while Date#toISOString truncates,
so repaired rows could land 1ms after the date a re-read writes.

Co-Authored-By: Claude <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Check cancellation before storing the sidecar-enriched… · session-scanner-parse-cache.ts:205-225

src/main/ai-vault/session-scanner-parse-cache.ts:205-225
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Check cancellation before storing the sidecar-enriched cache entry.

When a cached Devin transcript has a changed sidecar, parseCachedInLane awaits enrichment, then stores and returns the session. The Devin enrichment branch does not inspect signal. If cancellation occurs before enrichment resolves, the aborted operation can still mutate the parse cache and return a session.

Add the cancellation check immediately after enrichment and before cache storage:

Suggested fix
+import { throwIfAiVaultScanCancelled } from './ai-vault-scan-cancellation'
...
       const enriched = await enrichSessionFromSidecar(
         candidate,
         entry.foldSession,
         platform,
         signal
       )
+      throwIfAiVaultScanCancelled(signal)
       const session = reuseUnchangedSidecarSession(entry.session, enriched.session)

ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cae43d09-879f-4ee5-8946-fc27b354cdee
📥 Commits

Reviewing files that changed from the base of the PR and between de037b2 and f3ce0a1.

📒 Files selected for processing: 2
  • src/main/ai-vault-search/session-search-cursor-timestamps.test.ts
  • src/main/ai-vault-search/session-search-schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

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