Repository navigation
feat(native-chat): record the provider's name for an agent session - #19908
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: Advanced Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change adds normalized conversation names to agent session records and validates them during record checks. The runtime store can set or clear names without a writer lease. Tests cover normalization, persistence, clearing, validation, and unknown sessions. Reservation admission is consolidated in Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to Dashboard rows can retain stale agent-session names or tab state after updates. Resolve cache invalidation before merge so users see current session metadata. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, security, compatibility, and checklist items. However, it does not provide the required linked issue and does not state whether
✨ 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 70ff196c-7606-4ebf-acc6-8be972424cc4
📒 Files selected for processing (36)
src/main/ai-vault/session-scanner-text-normalization.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-tabs.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-types.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-reveal.tssrc/main/native-chat/structured-agent-session-conversation-name.tssrc/main/runtime/agent-session-conversation-name-store.test.tssrc/main/runtime/agent-session-record-conversation-name.test.tssrc/main/runtime/agent-session-record-conversation-name.tssrc/main/runtime/agent-session-record-store.tssrc/main/runtime/agent-session-reservation-admission.tssrc/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.tssrc/main/runtime/rpc/methods/structured-agent-session-reveal.tssrc/main/runtime/structured-agent-session-tab-name-publication.test.tssrc/main/runtime/structured-conversation-tab-replacement.tssrc/renderer/src/components/dashboard/dashboard-card-labels.tssrc/renderer/src/components/dashboard/use-agent-row-conversation-name.tssrc/renderer/src/components/dashboard/useDashboardData.tssrc/renderer/src/components/dashboard/worktree-agent-rows-cache.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.tssrc/renderer/src/components/sidebar/worktree-agent-row-fallback-tab.tssrc/renderer/src/components/sidebar/worktree-agent-row-session-name.test.tssrc/renderer/src/components/sidebar/worktree-agent-rows.tssrc/renderer/src/components/sidebar/worktree-agent-session-tab-index.tssrc/renderer/src/components/tab-bar/tab-bar-item-model.tssrc/renderer/src/components/tab-bar/tab-bar-item-surface.tsxsrc/renderer/src/runtime/web-session-tabs-sync/terminal-surfaces.tssrc/shared/agent-row-conversation-name.tssrc/shared/agent-session-conversation-name.test.tssrc/shared/agent-session-conversation-name.tssrc/shared/agent-session-record.tssrc/shared/runtime-mobile-session-tab-contracts.tssrc/shared/surrogate-safe-text-slice.tssrc/shared/tab-title-resolution.test.tssrc/shared/tab-title-resolution.tssrc/shared/tab-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| ptyIdsByTabId, | ||
| terminalLayoutsByTabId, | ||
| runtimeAgentOrchestrationByPaneKey: orchestration, | ||
| agentSessionTabsByTabId: selectAgentSessionTabsByTabIdForWorktree(state, worktreeId), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Add the agent-session tab map to the cache key.
Line 162 makes each row depend on unifiedTabsByWorktree. The cache-hit condition does not track this dependency.
If only agentSessionName changes, this function returns cached.rows before it reads the updated tab. The dashboard then shows the old session name until another row dependency changes.
Select the map before the cache check. Store its identity in WorktreeAgentRowsCacheEntry. Compare that identity during cache lookup.
There was a problem hiding this comment.
Important
The dashboard's cached agent rows don't include the new session-name input in their cache key, so a conversation name set while a session is already open can stay invisible on the dashboard board (and bucket counts) until an unrelated store update evicts the cache. The sidebar and tab strip refresh immediately, so the two surfaces end up showing different labels for the same session. Inline note on worktree-agent-rows-cache.ts.
Reviewed changes
- Durable
conversationName— a new optional field onAgentSessionRecordwith a normalizer/validator pair;setStructuredAgentSessionConversationNameis the single write path (normalize → store → republish the tab). - Publication & mirroring — optional
sessionNameon the agent-session wire tab andagentSessionNameonTab, threaded host → snapshot →buildMirroredAgentTabs→ tab strip and sidebar. - Label precedence — a session-name tier lands directly under the user rename in both
resolveUnifiedTabLabelandgetAgentRowConversationName. - Supporting refactors — surrogate-safe slice extracted to
src/shared, and thereserveOwnertransaction body relocated intocommitAgentSessionReservation.
The normalization regex and the surrogate-slice behavior were verified independently (paired surrogates survive [\uD800-\uDFFF] under the u flag; joiners U+200C/U+200D are kept; \p{Cf} is stripped). Wire reasoning against remote-wire-compatibility.md checks out: sessionName is Rule 1, and the title name-or-placeholder change is a Rule 3 reasoning call the PR documents.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ementation `sliceAtCodeUnitLimit` lived in src/main/ai-vault, and src/shared never imports src/main, so a shared consumer could not reach it. Rather than add a second copy, it moves to src/shared and ai-vault imports and re-exports it, leaving every existing importer of that module untouched. Separated from the feature that needs it: this is the only change here to a subsystem the rest of the branch does not touch.
Adds the normalized conversation name and the record field that stores it, so Orca has a durable note that it already named a session and does not name it again on a later acquisition. No name is generated yet, and nothing displays this field: the AI Vault path stays the home for the name a user sees. - `agent-session-conversation-name` bounds and flattens the text once, at 200 characters, cutting on a character boundary. - `AgentSessionRecord.conversationName` carries it, validated on load. - `setAgentSessionRecordConversationName` sets or clears it, unfenced: the name is a durable note, not ownership, so writing it never contends with the writer lease.
…sion logic Pure move, no behavior change. `reserveOwner`'s transaction body sequenced decisions that all live in agent-session-reservation-admission and then applied the winning one; it now sits there as `commitAgentSessionReservation`, and the store keeps the transaction boundary and a one-line delegation. Takes agent-session-record-store.ts from 300/300 to 279/300, which is what the conversation-name field needs to land. Every existing test passes unedited. The module header said nothing in it mutates; that is now qualified rather than left false, since the committer writes the state it is handed.
`setConversationName` is the one writer for the record field, so a producer never reaches the record shape itself. It normalizes at the boundary, so no caller can persist a name the loader would then reject as unreadable. Unfenced by design: the name is durable memory that Orca already named this session, not ownership, so naming never contends with the writer lease. No name generation and no provider code yet.
…nt tab The replacement tab open-coded `'Claude Chat' : 'Codex Chat'` while every other publisher already calls `defaultAgentChatLabel`. One writer for the placeholder.
3504ade to
92c79ec
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one housekeeping note on the PR description.
Reviewed changes
- Dropped the entire read path and publication — since the prior review the author removed
resolveUnifiedTabLabel'sagentSessionNametier,getAgentRowConversationName'ssessionNameparameter, the sidebarselectAgentSessionTabsByTabIdForWorktreeindex, the wiresessionNamefield, and every renderer touch. No renderer or wire file remains in the diff. - Dropped the sole writer —
setStructuredAgentSessionConversationNameandrenameStructuredAgentSessionTabare gone, so nothing populatesconversationNameyet; the carrier is now field-only. - Kept the durable field, normalizer, and an unfenced setter —
AgentSessionRecord.conversationName(loose reload validator),normalizeAgentSessionConversationName,AgentSessionRecordStore.setConversationName, and thesetAgentSessionRecordConversationNamepure helper all remain and read correctly. - Two verbatim relocations + one label simplification —
reserveOwner's body now lives incommitAgentSessionReservation;sliceAtCodeUnitLimitstays insrc/shared;structured-conversation-tab-replacementreusesdefaultAgentChatLabel(equivalent forclaude/codex, and no longer mislabels an unknown agent as "Codex Chat").
I verified the relocation is a byte-for-byte move, the normalizer's surrogate/joiner/\p{Cf} behavior is unchanged and correct, and the defaultAgentChatLabel swap is behavior-preserving.
ℹ️ PR description no longer matches the diff
The "What Changed" (Half 2) and "Where the lines go" sections describe a renderer read path that was removed in this rewrite: resolveUnifiedTabLabel gaining an agentSessionName tier, getAgentRowConversationName gaining a sessionName parameter, and a 44-line cached-index file. None of those files are in the 11-file diff. The description also cites two relocation commits by SHA (915383ea33, d277de686c), a publish + rename write path, and a "~373 total production" line count that no longer exist — the actual diff is 8 prod files at roughly +170/−41, plus 3 test files. Reviewers reading the body will look for changes that are not in the PR.
Technical details
# Reconcile the PR body with the 11-file diff
## Affected sites
- PR body "What Changed" (Half 2) — describes `resolveUnifiedTabLabel` / `getAgentRowConversationName` changes absent from the diff.
- PR body "Where the lines go" table — lists a "Renderer read path ~113 (44-line index)" and "~373 total production"; there is no renderer path.
- PR body "The two relocations" — cites `915383ea33` and `d277de686c`; the current commits are `63c2da2d`..`92c79ec`.
- PR body "The invariant" — "only the user's own rename outranks the session's name" no longer holds anywhere, since no read path remains.
## Required outcome
- The body's "What Changed", "Where the lines go", and "The two relocations" sections describe only what the diff actually ships.
## Suggested approach
- Rewrite those sections to the carrier-only scope (record field + validator, normalizer, unfenced store setter, two relocations, one label simplification) and update the commit SHAs to match HEAD.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (92c79ec), one commit landed:
- Tightened the reload validator to canonical form —
isAgentSessionConversationNamenow requiresnormalizeAgentSessionConversationName(value) === value, soisAgentSessionRecordrejects any persisted name that bypassed normalization (embedded newline, bidi override, surrounding whitespace) instead of only bounding length. This is consistent with the sole writer (setAgentSessionRecordConversationNamenormalizes on the way in), so the write path and read path agree on exactly one canonical form. - Added predicate- and record-level tests — new cases assert the predicate rejects noncanonical inputs (
' Fix the probe ','Fix\nthe probe','Fix\u202Egnp.exe probe') and that a record carrying such a name failsisAgentSessionRecord.
I verified the normalizer is idempotent on its own output (the gu-flagged LONE_SURROGATE/UNRENDERABLE_RUN passes and trim are no-ops on canonical text, and the truncation path strips any dangling joiner via TRAILING_DANGLE), so the === value equality check never rejects a name the writer itself produced.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status: clean — readiness PASSReviewed the rewritten branch through Architecture judgments:
Validation at the pushed head:
Conclusion: ready to merge as the focused storage foundation. The provider-side naming producer remains intentionally separate follow-up work. |


ELI5
This adds a place to record the name a chat was given, and nothing else.
Nothing writes to it in this PR — there is no production caller of the setter here, by design. It displays nothing, publishes nothing, and changes nothing you can see. The name a tab or a sidebar row shows is unchanged and still comes from where it always came from.
Which providers? The field itself is provider-agnostic — nothing in it branches on Claude versus Codex. But the first and currently only writer is the stacked PR #19941, which covers Claude structured chat only. Codex never names a thread itself, so it needs a model turn and its own design; that work does not exist yet. So when this and #19941 have both landed, Claude chats get real names and Codex chats still read "Codex Chat".
What Changed
One optional field on the durable session record, plus the pieces needed to write to it safely:
AgentSessionRecord.conversationName— the provider's name for a conversation, on the record that already holds that session's identity, lease and options.store.setConversationName— one mutation, unfenced, since a name is metadata rather than ownership.Plus two relocations that stand on their own and are isolated in their own commits:
63c2da2d38— the surrogate-safe slice existed only undersrc/main/ai-vault, andsrc/sharedcannot importsrc/main. Moved to shared, with ai-vault re-exporting it, instead of adding a second copy.0f3081f6fe—agent-session-record-store.tssat at 300 of a 300-line cap and could not accept a new method at all.reserveOwner's transaction body moved next to the admission logic it already delegated to. The store is now well clear of the cap. No lint suppression, no per-file bump.Why this is a record and not a display value
The displayed name stays where it already lives: the provider stores it — Claude's CLI writes an
ai-titlerecord into its transcript, Codex writes a thread name into its session index — the AI Vault scanner reads it, and the existingaiVaultTitletier surfaces it. Orca does not carry a second copy for display.What Orca cannot get from the vault is whether it has already named a session.
AiVaultSession.titlefalls back to the truncated first user message when no real title exists, so "named" and "unnamed" look identical through that lens. Without a durable record, every acquisition of a conversation would ask the provider to generate a title again and re-charge the user for it. That is the entire job of this field.History rewritten
An earlier revision of this PR also added a display carrier: a
sessionNamewire field, anagentSessionNametier inresolveUnifiedTabLabel, a matching parameter ingetAgentRowConversationName, a publication path through the mobile-tabs snapshot, and a cached tab index to support it — about 220 further production lines across 19 more files.That approach was rejected in review: it would have meant two places deriving one string, with the new tier outranking the vault's and able to mask a rename made in the provider's own CLI. The branch has been rebuilt without it. Every file involved is now byte-identical to the merge base, and
agentSessionNamehas zero occurrences tree-wide.Linked Issue
N/A — foundation for the structured-chat naming work. The producer PR carries the issue link.
Visual Proof
N/A— nothing reads this field, so every tab and every sidebar row renders exactly as it does onmain.Testing
Typecheck:
tc:node,tc:cli,tc:webclean, run sequentially, at the rebuilt head.Tests:
src/main/runtime+src/main/native-chat— 8,585 passed.src/shared— 7,693 passed. Renderer sidebar, dashboard and tab-bar — 3,565 passed.Ablations: the validator clause, the identical-value early return, the surrogate-safe cut and the normalizer's stripping each reverted, run, restored and re-run, with the guard symbol grepped back after every restore.
The
reserveOwnermove is a pure move: it cherry-picked clean and the suite passes with zero test edits, which is the gate it had to meet.One pre-existing failure:
automation-change-publication.test.tsfails on a 30-second timeout. It fails identically without these changes — environmental, not caused here.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Retry semantics live with the producer, not here
This PR only stores. Whether a declined or unsupported generation may be retried is the producer's decision, and is documented there.
agent-session-record.tsis at 299/300The new field is the only line added to it. Anything further needs a split, not a shave. CI lints the merge ref, so this is worth re-checking after any merge of
main.Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally