Repository navigation
fix(terminal): show AI Vault conversation names in tabs - #12778
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (22)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (20)
📝 WalkthroughWalkthroughThe change adds AI Vault session-title types, validation, persistence, and Codex cached-title refresh. The renderer collects and synchronizes titles from retained, sleeping, and active sessions. Terminal and unified-tab state preserves titles across hydration, mirroring, runtime projections, and reconciliation. Title resolution applies AI Vault titles with defined precedence. Tests cover synchronization, persistence, cache reuse, and title precedence. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
src/renderer/src/lib/provider-native-tab-title-sync.ts (1)
93-111: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winHoist the request re-collection out of the per-request loop.
collectProviderNativeTitleRequestswalksretainedAgentsByPaneKey,sleepingAgentSessionsByPaneKey,agentStatusByPaneKey, and every terminal tab. The loop calls it once per request in the group.setProviderNativeTabTitleonly changestabsByWorktreeentries'providerNativeTitle, which does not change any candidate identity, so the recomputation returns the same identities. Collect once before the loop and index bytabId.⚡ Proposed refactor
+ const currentByTabId = new Map( + collectProviderNativeTitleRequests(dependencies.getState()).map( + (candidate) => [candidate.tabId, candidate] as const + ) + ) for (const request of requests) { const identity = requestIdentity(request) const title = titleByIdentity.get(identity) if (!title) { markMissing(identity) continue } attempts.delete(identity) - const current = collectProviderNativeTitleRequests(dependencies.getState()).find( - (candidate) => candidate.tabId === request.tabId - ) + const current = currentByTabId.get(request.tabId) if (current && requestIdentity(current) === identity) {src/renderer/src/store/slices/terminals.ts (1)
2087-2100: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winSkip the unified-tab write when no unified tab matches.
unifiedTabs.map(...)always allocates a new array and always writesunifiedTabsByWorktree[ownerWorktreeId]. A terminal tab can exist intabsByWorktreewithout a matching unified terminal tab, for example before reconciliation restores it. In that case this write changes the map reference without changing any member. Unified-tab subscribers, including the session writer, then run for nothing.
updateTabTitlein this same file avoids that:updateUnifiedTerminalLabelreturnsnullwhen nothing changed and the caller omits the key. Mirror that pattern.♻️ Proposed refactor
const unifiedTabs = s.unifiedTabsByWorktree[ownerWorktreeId] ?? [] - const nextUnifiedTabs = unifiedTabs.map((tab) => - tab.contentType === 'terminal' && tab.entityId === tabId - ? { ...tab, providerNativeTitle } - : tab - ) + let unifiedChanged = false + const nextUnifiedTabs = unifiedTabs.map((tab) => { + if (tab.contentType !== 'terminal' || tab.entityId !== tabId) { + return tab + } + unifiedChanged = true + return { ...tab, providerNativeTitle } + }) scheduleRuntimeGraphSync() return { tabsByWorktree: { ...s.tabsByWorktree, [ownerWorktreeId]: ownerTabs }, - unifiedTabsByWorktree: { - ...s.unifiedTabsByWorktree, - [ownerWorktreeId]: nextUnifiedTabs - } + ...(unifiedChanged + ? { + unifiedTabsByWorktree: { + ...s.unifiedTabsByWorktree, + [ownerWorktreeId]: nextUnifiedTabs + } + } + : {}) }src/shared/workspace-session-schema.test.ts (1)
278-284: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert the complete provider-native title object.
The test checks only
title.agentandsessionIdidentify the provider session and drive synchronization. Assert the complete object for both terminal and unified tabs. Otherwise, the test can pass after title text survives but session identity is lost.Proposed test assertion
- expect(result.value.tabsByWorktree.wt[0].providerNativeTitle?.title).toBe( - 'Provider thread name' - ) + expect(result.value.tabsByWorktree.wt[0].providerNativeTitle).toEqual({ + agent: 'codex', + sessionId: 'session-1', + title: 'Provider thread name' + }) - expect(result.value.unifiedTabs?.wt[0].providerNativeTitle?.title).toBe( - 'Provider thread name' - ) + expect(result.value.unifiedTabs?.wt[0].providerNativeTitle).toEqual({ + agent: 'codex', + sessionId: 'session-1', + title: 'Provider thread name' + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 75ca0b3d-dd05-4e18-8002-8be82cfa4e9f
📒 Files selected for processing (28)
src/main/ai-vault/session-list-result-validation.test.tssrc/main/ai-vault/session-list-result-validation.tssrc/main/ai-vault/session-scanner-accumulator.tssrc/main/ai-vault/session-scanner-claude-title.test.tssrc/main/ai-vault/session-scanner-codex-cached-title.tssrc/main/ai-vault/session-scanner-codex-parser.tssrc/main/ai-vault/session-scanner-parse-cache-agents.test.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-primary-parsers.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner.test.tssrc/renderer/src/App.tsxsrc/renderer/src/components/ProviderNativeTabTitleSyncGate.tsxsrc/renderer/src/lib/provider-native-tab-title-requests.tssrc/renderer/src/lib/provider-native-tab-title-sync.test.tssrc/renderer/src/lib/provider-native-tab-title-sync.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/tabs-hydration.tssrc/renderer/src/store/slices/tabs.tssrc/renderer/src/store/slices/terminals.tssrc/shared/ai-vault-types.tssrc/shared/provider-native-session-title.tssrc/shared/tab-title-resolution.test.tssrc/shared/tab-title-resolution.tssrc/shared/types.tssrc/shared/workspace-session-schema.test.tssrc/shared/workspace-session-schema.ts
💤 Files with no reviewable changes (1)
- src/main/ai-vault/session-scanner.test.ts
| function activePaneKey(state: AppState, tabId: string): string | null { | ||
| const activeLeafId = state.terminalLayoutsByTabId[tabId]?.activeLeafId | ||
| return activeLeafId ? `${tabId}:${activeLeafId}` : null | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm makePaneKey is exported from the shared pane-id module and matches the literal format.
fd -t f 'stable-pane-id.ts' src/shared --exec sh -c 'echo "== $1"; rg -n -C4 "export function (makePaneKey|parsePaneKey)" "$1"' sh {}Repository: stablyai/orca
Length of output: 892
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== candidate file imports and activePaneKey"
file="src/renderer/src/lib/provider-native-tab-title-requests.ts"
rg -n -C3 "import .*stable-pane-id|activePaneKey|makePaneKey|parsePaneKey" "$file"
echo
echo "== stable-pane-id export"
fd -t f 'stable-pane-id.ts' src/shared --exec sh -c 'sed -n "22,30p" "$1"' sh {}
echo
echo "== terminals.ts usages of makePaneKey"
if [ -f src/renderer/src/store/slices/terminals.ts ]; then
rg -n -C2 "makePaneKey\(" src/renderer/src/store/slices/terminals.ts
fiRepository: stablyai/orca
Length of output: 2369
Use makePaneKey for the active-pane lookup.
activePaneKey duplicates the pane-key separator convention. Import makePaneKey from src/shared/stable-pane-id.ts and reuse it here so this active-pane comparison stays aligned with the shared pane-key builder used elsewhere.
| const markMissing = (identity: string): void => { | ||
| const count = (attempts.get(identity)?.count ?? 0) + 1 | ||
| const delay = RETRY_DELAYS_MS[count - 1] | ||
| attempts.set(identity, { | ||
| count, | ||
| retryAt: delay === undefined ? Number.POSITIVE_INFINITY : now() + delay | ||
| }) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
A missing title parks the session for the whole process lifetime.
markMissing sets retryAt to Number.POSITIVE_INFINITY after the third attempt. reconcile then never adds that identity to ready, because retryAt <= now() is never true. The total retry window is 1 s + 5 s + 20 s. Claude and Codex often write the conversation name later than that, for example after the first assistant turn completes. In that case the tab never receives its provider-native title until the app restarts.
The attempts map also keeps entries for tabs that were closed, because only reconcile and scanGroup delete them and both require the identity to still be collected.
Consider one of these:
- Repeat the last delay instead of parking, so a late title still lands.
- Reset the attempt count when the pane's agent status or provider session changes.
- Prune
attemptsentries whose identity is absent from the collected requests.
🔁 Proposed change: repeat the final delay and prune stale identities
const markMissing = (identity: string): void => {
const count = (attempts.get(identity)?.count ?? 0) + 1
- const delay = RETRY_DELAYS_MS[count - 1]
- attempts.set(identity, {
- count,
- retryAt: delay === undefined ? Number.POSITIVE_INFINITY : now() + delay
- })
+ // Why: providers can name a conversation minutes after launch, so keep polling on the longest delay.
+ const delay = RETRY_DELAYS_MS[count - 1] ?? RETRY_DELAYS_MS[RETRY_DELAYS_MS.length - 1]
+ attempts.set(identity, { count, retryAt: now() + delay })
} const ready: ProviderNativeTitleRequest[] = []
+ const liveIdentities = new Set(requests.map(requestIdentity))
+ for (const identity of attempts.keys()) {
+ if (!liveIdentities.has(identity) && !inFlight.has(identity)) {
+ attempts.delete(identity)
+ }
+ }
for (const request of requests) {If you keep a terminal cap, add a longer final delay tier instead of Infinity so the ladder still ends but stays useful.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/shared/workspace-session-schema.ts (1)
75-82: 🩺 Stability & Availability | 🟠 MajorAdd a field-level fallback for malformed
aiVaultTitle.
aiVaultTitleis optional session metadata, but the nested object can reject an unknownagent, a non-object value, or malformed field types. The error can propagate throughterminalTabSchemaortabSchemaand makeworkspaceSessionStateSchemareject the complete workspace session.Add
.catch(undefined)after.optional()at Line 75 and Line 123. This is the same failure previously reported forproviderNativeTitle; the rename did not change the failure mode.Proposed fix
.nullable() - .optional(), + .optional() + .catch(undefined),Apply this change to both
aiVaultTitleschemas.Also applies to: 123-130
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d174353-43c2-441c-8ff8-6919bb48f18a
📒 Files selected for processing (19)
src/main/ai-vault/session-scanner-codex-cached-title.tssrc/main/ai-vault/session-scanner-parse-cache-agents.test.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/renderer/src/App.tsxsrc/renderer/src/components/AiVaultTabTitleSyncGate.tsxsrc/renderer/src/lib/ai-vault-tab-title-requests.tssrc/renderer/src/lib/ai-vault-tab-title-sync.test.tssrc/renderer/src/lib/ai-vault-tab-title-sync.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/tabs-hydration.tssrc/renderer/src/store/slices/tabs.tssrc/renderer/src/store/slices/terminals.tssrc/shared/ai-vault-session-title.tssrc/shared/tab-title-resolution.test.tssrc/shared/tab-title-resolution.tssrc/shared/types.tssrc/shared/workspace-session-schema.test.tssrc/shared/workspace-session-schema.ts
💤 Files with no reviewable changes (1)
- src/main/ai-vault/session-scanner-parse-cache-agents.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/renderer/src/store/slices/tabs.ts
- src/main/ai-vault/session-scanner-parse-cache.ts
- src/renderer/src/store/slices/tabs-hydration.ts
- src/shared/workspace-session-schema.test.ts
- src/shared/tab-title-resolution.test.ts
| // Why: the host transport carries no generated title, so rebuilding the tab | ||
| // without this dropped the client's agent-prompt label on every snapshot. | ||
| ...(existing?.generatedTitle ? { generatedTitle: existing.generatedTitle } : {}), | ||
| ...(existing?.aiVaultTitle ? { aiVaultTitle: existing.aiVaultTitle } : {}), |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)src/renderer/src/runtime/(web-session-tabs-sync|sync-runtime-graph)\.ts$|(^|/)TerminalSurface|web-session-tabs-sync\.ts|sync-runtime-graph\.ts' || true
echo "== relevant line counts =="
for f in src/renderer/src/runtime/web-session-tabs-sync.ts src/renderer/src/runtime/sync-runtime-graph.ts; do
if [ -f "$f" ]; then
echo "--- $f wc ---"
wc -l "$f"
fi
done
echo "== snippets around mentioned lines =="
for f in src/renderer/src/runtime/web-session-tabs-sync.ts src/renderer/src/runtime/sync-runtime-graph.ts; do
if [ -f "$f" ]; then
echo "--- $f lines 480-680 ---"
sed -n '480,680p' "$f" | nl -ba -v480
fi
done
echo "== search aiVaultTitle references =="
rg -n "aiVaultTitle|TerminalSurface|activeSurface" src/renderer/src/runtime src/renderer/src -g '*.{ts,tsx,js,jsx,json,jsonc}' | head -n 200Repository: stablyai/orca
Length of output: 664
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for f in ['src/renderer/src/runtime/web-session-tabs-sync.ts', 'src/renderer/src/runtime/sync-runtime-graph.ts']:
p = Path(f)
lines = p.read_text(encoding='utf-8').splitlines()
print(f'--- {f} lines 480-690 ---')
for i in range(480, min(len(lines), 690)):
print(f'{i+1}: {lines[i]}')
PY
echo "== search aiVaultTitle references =="
rg -n "aiVaultTitle|TerminalSurface|activeSurface" src/renderer/src/runtime src/renderer/src -g '*.{ts,tsx,js,jsx,json,jsonc}' | head -n 300Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('src/shared')
for f in sorted(p.rglob('*')):
if f.is_file() and f.name.endswith(('.ts', '.tsx', '.d.ts')):
s = f.read_text(encoding='utf-8', errors='ignore')
if 'RuntimeMobileSessionTerminalClientTab' in s or 'TerminalSurface' in s or 'aiVaultTitle' in s:
print(f'--- {f} ---')
lines = s.splitlines()
for i,l in enumerate(lines, 1):
if any(x in l for x in ['RuntimeMobileSessionTerminalClientTab', 'TerminalSurface', 'aiVaultTitle', 'generatedTitle', 'quickCommandLabel']):
print(f'{i}: {l}')
PY
echo "== focused RuntimeMobileSessionTerminalClientTab definitions =="
rg -n "type RuntimeMobileSessionTerminalClientTab|interface RuntimeMobileSessionTerminalClientTab|RuntimeMobileSessionTerminalClientTab|GeneratedTitle|aiVaultTitle" shared src -g '*.{ts,tsx,d.ts}' | head -n 200Repository: stablyai/orca
Length of output: 15935
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for name in ['src/shared/runtime-types.ts', 'src/shared/workspace-session-schema.ts']:
p = Path(name)
print(f'--- {name} ---')
lines = p.read_text(encoding='utf-8').splitlines()
start = None
end = None
if name == 'src/shared/runtime-types.ts':
for i,l in enumerate(lines, 1):
if 'export type RuntimeMobileSessionTerminalClientTab' in l or 'export interface RuntimeMobileSessionTerminalClientTab' in l:
start = i
if start and (i > start + 100 or ('| RuntimeMobileSessionTerminalClientTab' in l and i > start + 30)):
if not end:
end = i
break
if end is None:
end = min(len(lines), start + 80)
else:
for i,l in enumerate(lines, 1):
if 'aiVaultTitle' in l or 'generatedTitle' in l:
line_i = i
start = max(1, line_i - 6)
end = min(len(lines), line_i + 12) if line_i > i else min(len(lines), line_i + 12)
print(f'{max(1,line_i-8)}-{min(len(lines),line_i+14)}:')
for j in range(max(1,line_i-8), min(len(lines),line_i+14)+1):
print(f'{j}: {lines[j-1]}')
if start is not None and start <= end:
for i in range(start, end + 1):
print(f'{i}: {lines[i-1]}')
PY
echo "== inspect sync graph projection/construction around terminal surface tabs =="
python3 - <<'PY'
from pathlib import Path
p = Path('src/renderer/src/runtime/sync-runtime-graph.ts')
lines = p.read_text(encoding='utf-8').splitlines()
for a,b in [(1814,1925), (1508,1560)]:
print(f'--- {p} lines {a}-{b} ---')
for i in range(a, min(b, len(lines))+1):
print(f'{i}: {lines[i-1]}')
PYRepository: stablyai/orca
Length of output: 14707
Read the host aiVaultTitle when rebuilding a mirrored tab.
buildRuntimeMobileTabsProjection carries tab.aiVaultTitle, but buildMirroredTerminalTabs keeps only an existing value for the mirrored tab. On a fresh mirror this drops the host title; on an updated mirror it keeps a stale title when the host changes or clears aiVaultTitle.
Read activeSurface.aiVaultTitle when the host surface has it, use the existing only when omitted, and preserve an explicit null so host clears remove the local title. If the mobile terminal surface contract does not include aiVault, add it before using this value at this call site.
|
Review follow-up pushed in 6f81eec:
Validation:
|
|
CI follow-up: every test shard on Node 24 and 26, typecheck, packaging (including Windows), Git compatibility, shell contracts, and cross-version wire compatibility passed. The only failing root check is static analysis (and its aggregate verify job): full-repo lint flags mobile/src/session/use-mobile-native-chat-controller.ts from the base branch for exceeding max lines. This PR does not touch mobile, so I left that unrelated base-branch issue out of scope. |
…-native-tab-titles
…-native-tab-titles # Conflicts: # src/renderer/src/App.tsx
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
* fix(terminal): use provider-native session titles * refactor(terminal): source session names from AI Vault * fix(tabs): harden AI Vault title sync

Summary
AiVaultSession.titleinto terminal and unified tabs using execution-host + provider-session identitysession_index.jsonltitles even when the transcript parse cache is unchanged; periodically refresh only live tab identities so later Claude/Codex renames propagateValidation
pnpm typecheckpnpm lintgit diff --checkand focusedoxfmt --checkpnpm run build:electron-viteElectron visual gap: the isolated QA profile intentionally contained no real provider session, so the exact title projection is validated by focused integration tests rather than a fabricated screenshot state.