Skip to content

feat(native-chat): record the provider's name for an agent session - #19908

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/structured-session-name-carrier
Sep 11, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/structured-session-name-carrier

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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.
  • A normalizer — bounds the string to 200 characters, flattens newlines, and strips control, bidi, zero-width and unpaired-surrogate characters, so a name from another client cannot break a tab strip or a sidebar row.
  • 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 under src/main/ai-vault, and src/shared cannot import src/main. Moved to shared, with ai-vault re-exporting it, instead of adding a second copy.
  • 0f3081f6fe — agent-session-record-store.ts sat 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-title record into its transcript, Codex writes a thread name into its session index — the AI Vault scanner reads it, and the existing aiVaultTitle tier 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.title falls 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 sessionName wire field, an agentSessionName tier in resolveUnifiedTabLabel, a matching parameter in getAgentRowConversationName, 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 agentSessionName has 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 on main.

Testing

  • Typecheck: tc:node, tc:cli, tc:web clean, 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 reserveOwner move 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.ts fails 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.ts is at 299/300

The 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

  • Not applicable.

Notes

  • Security: the only new input is a string bounded to 200 characters and stripped of control, bidi and zero-width characters before storage.
  • Cross-platform: no paths, shells or processes.
  • Remote SSH / mobile: no wire change at all in this revision.
  • Performance: one optional field on an existing record; an unchanged value returns the same object and opens no transaction.
  • Backwards compatibility: an optional field on a record that already tolerates absent optional fields.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm lint, pnpm typecheck, pnpm test pass locally

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b2fbc479-cd9e-4711-ae55-fbde9bd762b4

📥 Commits

Reviewing files that changed from the base of the PR and between 92c79ec and b4ccebf.

📒 Files selected for processing (3)
  • src/main/runtime/agent-session-record-conversation-name.test.ts
  • src/shared/agent-session-conversation-name.test.ts
  • src/shared/agent-session-conversation-name.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/shared/agent-session-conversation-name.test.ts
  • src/main/runtime/agent-session-record-conversation-name.test.ts
  • src/shared/agent-session-conversation-name.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The 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 commitAgentSessionReservation. UTF-16-safe slicing moves to a shared helper. Replacement tabs use the shared default chat label.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to b4cce

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 `… Replace N/A under Linked Issue with the relevant issue reference. Also document the pnpm build result or state that CI will cover the build.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 36 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: recording the provider's name for an agent session.
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 change, rationale, testing, security, compatibility, and checklist items. However, it does not provide the required linked issue and does not state whether pnpm build passes or CI will cover it.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 70ff196c-7606-4ebf-acc6-8be972424cc4

📥 Commits

Reviewing files that changed from the base of the PR and between f2d5711 and fbe683f.

📒 Files selected for processing (36)
  • src/main/ai-vault/session-scanner-text-normalization.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host-tabs.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host-types.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-reveal.ts
  • src/main/native-chat/structured-agent-session-conversation-name.ts
  • src/main/runtime/agent-session-conversation-name-store.test.ts
  • src/main/runtime/agent-session-record-conversation-name.test.ts
  • src/main/runtime/agent-session-record-conversation-name.ts
  • src/main/runtime/agent-session-record-store.ts
  • src/main/runtime/agent-session-reservation-admission.ts
  • src/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.ts
  • src/main/runtime/rpc/methods/structured-agent-session-reveal.ts
  • src/main/runtime/structured-agent-session-tab-name-publication.test.ts
  • src/main/runtime/structured-conversation-tab-replacement.ts
  • src/renderer/src/components/dashboard/dashboard-card-labels.ts
  • src/renderer/src/components/dashboard/use-agent-row-conversation-name.ts
  • src/renderer/src/components/dashboard/useDashboardData.ts
  • src/renderer/src/components/dashboard/worktree-agent-rows-cache.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
  • src/renderer/src/components/sidebar/worktree-agent-row-fallback-tab.ts
  • src/renderer/src/components/sidebar/worktree-agent-row-session-name.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-agent-session-tab-index.ts
  • src/renderer/src/components/tab-bar/tab-bar-item-model.ts
  • src/renderer/src/components/tab-bar/tab-bar-item-surface.tsx
  • src/renderer/src/runtime/web-session-tabs-sync/terminal-surfaces.ts
  • src/shared/agent-row-conversation-name.ts
  • src/shared/agent-session-conversation-name.test.ts
  • src/shared/agent-session-conversation-name.ts
  • src/shared/agent-session-record.ts
  • src/shared/runtime-mobile-session-tab-contracts.ts
  • src/shared/surrogate-safe-text-slice.ts
  • src/shared/tab-title-resolution.test.ts
  • src/shared/tab-title-resolution.ts
  • src/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),

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.

🎯 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.

@pullfrog pullfrog 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.

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 on AgentSessionRecord with a normalizer/validator pair; setStructuredAgentSessionConversationName is the single write path (normalize → store → republish the tab).
  • Publication & mirroring — optional sessionName on the agent-session wire tab and agentSessionName on Tab, threaded host → snapshot → buildMirroredAgentTabs → tab strip and sidebar.
  • Label precedence — a session-name tier lands directly under the user rename in both resolveUnifiedTabLabel and getAgentRowConversationName.
  • Supporting refactors — surrogate-safe slice extracted to src/shared, and the reserveOwner transaction body relocated into commitAgentSessionReservation.

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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025 brennanb2025 changed the title feat(native-chat): give an agent session one place to hold its name refactor(native-chat): one home for an agent session's name, nothing names a chat yet Sep 10, 2026
Merge Sim added 5 commits September 10, 2026 16:09
…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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/structured-session-name-carrier branch from 3504ade to 92c79ec Compare September 10, 2026 23:22
@brennanb2025 brennanb2025 changed the title refactor(native-chat): one home for an agent session's name, nothing names a chat yet feat(native-chat): record the provider's name for an agent session Sep 10, 2026

@pullfrog pullfrog 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.

ℹ️ 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's agentSessionName tier, getAgentRowConversationName's sessionName parameter, the sidebar selectAgentSessionTabsByTabIdForWorktree index, the wire sessionName field, and every renderer touch. No renderer or wire file remains in the diff.
  • Dropped the sole writer — setStructuredAgentSessionConversationName and renameStructuredAgentSessionTab are gone, so nothing populates conversationName yet; the carrier is now field-only.
  • Kept the durable field, normalizer, and an unfenced setter — AgentSessionRecord.conversationName (loose reload validator), normalizeAgentSessionConversationName, AgentSessionRecordStore.setConversationName, and the setAgentSessionRecordConversationName pure helper all remain and read correctly.
  • Two verbatim relocations + one label simplification — reserveOwner's body now lives in commitAgentSessionReservation; sliceAtCodeUnitLimit stays in src/shared; structured-conversation-tab-replacement reuses defaultAgentChatLabel (equivalent for claude/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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Since the prior pullfrog review (92c79ec), one commit landed:

  • Tightened the reload validator to canonical form — isAgentSessionConversationName now requires normalizeAgentSessionConversationName(value) === value, so isAgentSessionRecord rejects any persisted name that bypassed normalization (embedded newline, bidi override, surrounding whitespace) instead of only bounding length. This is consistent with the sole writer (setAgentSessionRecordConversationName normalizes 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 fails isAgentSessionRecord.

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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: clean — readiness PASS

Reviewed the rewritten branch through b4ccebfbc0. One meaningful fix was pushed: persisted conversationName values must now already equal their canonical normalization. Previously, reload validation accepted bounded strings containing newlines, bidi controls, or other content that the sole store writer would have stripped.

Architecture judgments:

  • The reserveOwner change is a pure relocation. The store still invokes it inside one transact callback; refusal/replay happens before mutation, reservation application still precedes the operation-row and record writes, adoption uniqueness remains inside the transaction, and queue serialization/refresh/rollback/save behavior is unchanged.
  • AI Vault should not replace the durable record. Its public title can be an explicit provider title, a first-user-message fallback, or a synthetic fallback, so title presence cannot prove Orca successfully named the provider conversation. Cold ID-only title lookup and tab/service lifecycle also make it unsuitable as the durable retry oracle.
  • A successful conversationName is an acceptable success-only marker for this storage foundation. Declined or unsupported attempts remain absent and may be retried by the producer on a later acquisition; the producer must write the marker only after provider success. No display wire field, renderer cache, or second display derivation was reintroduced.

Validation at the pushed head:

  • GitHub: typecheck, static analysis, cross-version wire compatibility, package, Windows package, all eight test shards, verify, and PR guards passed.
  • Local: 139 focused persistence/reservation/AI Vault tests passed; 55 mobile/projection tests passed; typecheck passed; changed-code quality reported 0 findings; all 118 reliability gates passed; diff check passed.
  • Hidden Electron/CDP launch against the exact worktree succeeded with ORCA_BACKGROUND_LAUNCH=1; the unchanged storage-only UI rendered normally. No provider naming call or interactive mobile flow was exercised, by scope.

PR 19908 hidden-renderer launch proof

Conclusion: ready to merge as the focused storage foundation. The provider-side naming producer remains intentionally separate follow-up work.

@brennanb2025
brennanb2025 merged commit 25b5fac into main Sep 11, 2026
28 checks passed
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