Skip to content

fix: prefer Claude-generated titles in AI Vault - #7369

Merged
AmethystLiang merged 2 commits into
stablyai:mainfrom
hmrserver:fix/ai-vault-claude-generated-title
Jul 6, 2026
Merged

AmethystLiang merged 2 commits into
stablyai:mainfrom
hmrserver:fix/ai-vault-claude-generated-title

Conversation

@hmrserver

@hmrserver hmrserver commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

I fixed Agent Session History so Claude Code sessions use the Claude-generated ai-title when one exists, matching /status and the terminal tab title.

The title priority is now: user-set custom-title > Claude-generated ai-title > first user prompt > injected/meta text > agent/id default. New sessions still fall back to the first prompt until Claude writes the generated title.

I also stopped indexing Claude Task subagent transcripts as separate history rows by pruning <session>/subagents/ during discovery.

Screenshots

Same session, before and after (a Claude session with 350 messages).

Before — the AI Vault side panel labeled the session with a truncated copy of the first user prompt (in orc can see that they are not actually using the session generate…), even though Claude had already generated a name for it.
image

After — the session shows its generated name, Investigate Orca session title generation bug, matching what /status and the tab title show. Other sessions likewise show their generated names (e.g. Understanding karma and moral accountability).
image

Testing

  • Targeted AI Vault scanner tests: pnpm test, 53 tests across 13 files passing on Node 24, including the two new Claude title/subagent tests.
  • Typecheck is clean for all changed files via tsgo -p config/tsconfig.node.json; there is one pre-existing unrelated error in src/main/browser/cdp-ws-proxy.test.ts.
  • oxlint is clean on the changed files.
  • Ran the dev app with pnpm dev and confirmed Agent Session History now shows Claude-generated titles and no longer shows subagent noise rows.
  • Full repo-wide pnpm test not yet run end to end in this environment.
  • Full pnpm build not yet run end to end in this environment.

AI Review Report

Before finalizing, I ran a layered AI review. Three Opus high-reasoning agents first codified Orca's actual codebase conventions for production TypeScript, vitest scanner tests, and scanner performance contracts. I then handed that context to a separate Codex/GPT-class reviewer focused on correctness and optimization.

The main review catch was that my first cut filtered subagents per file, which still walked and allocated over the full subagents/ subtree. I changed that to a directory-level directoryPredicate prune, so the subtree is never readdir'd. I also added the requested mapped-array assertions and the explicit test proving custom-title beats ai-title.

The review explicitly checked cross-platform behavior for macOS, Linux, and Windows: path handling uses Node path APIs and directory entry name comparison, not separator-dependent string matching. There are no keyboard shortcuts, shortcut labels, shell invocations, or Electron platform differences introduced by this change. It also covered SSH/remote behavior since the scanner can index remote and WSL homes, and the performance angle because this path can scan thousands of JSONL transcript files.

Security Audit

No new input parsing was added beyond records the scanner already reads. ai-title and custom-title values continue through the existing normalizeTitleText path.

Path handling is limited to comparing a directory entry name against subagents; it does not construct or trust paths from transcript input, so this does not introduce traversal risk.

There is no command execution, no new IPC surface, no secrets handling, no auth change, no network calls, and no new dependencies. This remains read-only session-history indexing.

Notes

All changed code is in the main process scanner path. There are no renderer or UI code changes, though the result is visible in the AI Vault side panel.

The subagent filtering is Claude-specific and scoped to Claude discovery. It does not change generic scanner behavior or other agent providers. The filter is intentionally applied during directory traversal for performance and for Windows-safe path handling.

CI should still confirm the full repo-wide test and build jobs.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 961f8c14-9fb1-4cc9-b27a-6d181bf90c65

📥 Commits

Reviewing files that changed from the base of the PR and between 72afc1467bfebb4ac6bc04fdd8254e1805201520 and b92685e.

📒 Files selected for processing (6)
  • src/main/ai-vault/session-scanner-claude-title.test.ts
  • src/main/ai-vault/session-scanner-discovery.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner-source-discovery.ts
  • src/main/ai-vault/session-scanner-test-fixtures.ts
  • src/main/ai-vault/session-scanner.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/ai-vault/session-scanner-test-fixtures.ts
  • src/main/ai-vault/session-scanner-source-discovery.ts
  • src/main/ai-vault/session-scanner-claude-title.test.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/main/ai-vault/session-scanner-discovery.ts

📝 Walkthrough

Walkthrough

This PR adds directory filtering support to AI vault session file discovery, uses it to exclude Claude subagent transcript files, and updates Claude title fallback handling to prefer generated titles, then the first user prompt, then meta-injected titles. It also extracts shared test fixture helpers into a new module and adds tests for title precedence and subagent exclusion.

Related issues: None provided
Related PRs: None provided
Suggested labels: ai-vault, tests, bug-fix
Suggested reviewers: None provided

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: preferring Claude-generated titles in AI Vault.
Description check ✅ Passed The description covers all required template sections and includes the requested testing, review, security, and notes details.
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.

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.

hmrserver and others added 2 commits July 5, 2026 17:03
Agent Session History labeled Claude Code sessions with a truncated
first prompt even when the session already had a Claude-generated name
(the ai-title shown in /status and the tab title). Reserve the top
title slot for a user-set custom-title and rank the generated ai-title
above the first prompt: custom-title > ai-title > first prompt > meta.
New sessions still fall back to the first prompt until the ai-title is
written.

Also prune <session>/subagents/ during discovery via an injected
directoryPredicate so Task subagent transcripts, which share the parent
sessionId and are not independently resumable, stop appearing as
separate untitled history rows. Pruning at the directory level avoids
readdir'ing the excluded subtree and is cross-platform safe.
Ensure the scanner updates the generated session title when Claude
revises it, rather than only keeping the first parsed 'ai-title'
record.
@hmrserver
hmrserver force-pushed the fix/ai-vault-claude-generated-title branch from 97a08f8 to 72afc14 Compare July 5, 2026 11:35
@AmethystLiang
AmethystLiang removed their request for review July 5, 2026 18:29
@hmrserver
hmrserver force-pushed the fix/ai-vault-claude-generated-title branch from 72afc14 to b92685e Compare July 5, 2026 18:58
@AmethystLiang
AmethystLiang requested review from AmethystLiang and removed request for brennanb2025 July 5, 2026 22:46
@AmethystLiang
AmethystLiang merged commit e172adf into stablyai:main Jul 6, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix: prefer Claude-generated titles in AI Vault

Agent Session History labeled Claude Code sessions with a truncated
first prompt even when the session already had a Claude-generated name
(the ai-title shown in /status and the tab title). Reserve the top
title slot for a user-set custom-title and rank the generated ai-title
above the first prompt: custom-title > ai-title > first prompt > meta.
New sessions still fall back to the first prompt until the ai-title is
written.

Also prune <session>/subagents/ during discovery via an injected
directoryPredicate so Task subagent transcripts, which share the parent
sessionId and are not independently resumable, stop appearing as
separate untitled history rows. Pruning at the directory level avoids
readdir'ing the excluded subtree and is cross-platform safe.

* Use latest generated Claude title in session scanner

Ensure the scanner updates the generated session title when Claude
revises it, rather than only keeping the first parsed 'ai-title'
record.

---------

Co-authored-by: Jinjing <[email protected]>
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.

3 participants