Skip to content

fix(mobile): preserve custom title when renaming agent terminal tabs - #28713

Closed
zhangxaochen wants to merge 10 commits into
stablyai:mainfrom
zhangxaochen:mobile-tab-rename
Closed

zhangxaochen wants to merge 10 commits into
stablyai:mainfrom
zhangxaochen:mobile-tab-rename

Conversation

@zhangxaochen

@zhangxaochen zhangxaochen commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When you rename an Agent terminal tab in the Orca mobile app, the new custom title is now immediately visible in the mobile tab bar and preserved across runtime updates, without breaking the Agent status indicator (working/permission/idle) or Agent provider icon.

What Changed

  • Mobile Client: In handleRenameTerminal, optimistically updates sessionTabsRef and sessionTabs state (which powers the mobile header tab bar) upon RPC acceptance, and schedules refreshes for both session.tabs.list and terminal.list.
  • Runtime PTY & Snapshot State: Separates user-specified custom titles from controller/timestamped title evidence by storing manual renames in customTitle. Both live PTY and bound PTY leaf fallback branches in renameTerminal set customTitle, update title, and notify/touch mobile session snapshots.
  • Session Projection: In projectRuntimeMobileSessionTabs and buildTerminalSummary, prioritizes customTitle ahead of Agent title normalization while preserving liveTitleEvidence (leafTitle ?? ptyTitle) for Agent activity status detection and icon resolution. Clearing custom titles restores the live Agent OSC title.

Why

Previously, mobile tab renames only updated terminal.list instead of session.tabs.list, and the runtime projection prioritized live OSC titles over custom titles for active agent panes. Additionally, controller-provided PTY titles could shadow OSC updates if manual titles were not isolated in a dedicated customTitle field. Storing customTitle separately guarantees that manual renames take precedence without corrupting OSC-driven state transitions or controller inventory fallbacks.

Linked Issue

Fixes #28665

Visual Proof

N/A - Mobile UI title text update and host projection state alignment verified via automated unit and integration tests.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  1. mobile/src/session/use-mobile-session-close-actions.test.ts: Verifies optimistic sessionTabs state updates and fetch schedules on terminal rename.
  2. src/main/runtime/orca-runtime-tests/mobile-session-tabs.spec.ts: Verifies leaf-backed agent terminal renaming, custom title persistence through OSC updates, clearing to restore live OSC titles, and ensuring controller-seeded titles do not lock custom titles.

AI Disclosure

Assisted by Google DeepMind Antigravity agentic coding assistant for implementation, static analysis review resolution, and unit test coverage.

Review

Follows Orca runtime session projection contract and mobile action conventions.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Platform & remote compatibility considered: PTY rename operates across both desktop and headless/remote runtime configurations.
  • Preserves OSC-based status inference while honoring explicit user custom titles.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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 (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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
📝 Walkthrough

Runtime and client changes add custom-title storage and propagate titles through terminal tabs, agent sessions, and launch flows. Runtime rename paths update title state and restore live titles when a custom title is cleared. Mobile terminal tabs support double-tap rename, with optimistic session-tab updates and delayed refreshes. Tests cover these paths and title persistence.

Fixed issue severity: Medium

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟠 High · up to af963

The change to custom terminal and session titles has several unresolved problems. A test file still contains a merge-conflict marker, which breaks the test suite. Cleared titles can reappear. Resumed agents can lose live title updates. Renames of remote sessions are written to the wrong host. Mirrored tabs can keep stale labels. Resolve these before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning The pull request includes changes not required by [#28665]. It adds a general workspace session custom-title system, an aiVault.renameSession RPC, closed Agent History and resume-title behavior, wor… Remove the unrelated AI Vault session, Agent History/resume, workspace ownership, and browser-tab changes from this pull request, or move them to separate pull requests. Keep only the mobile terminal rename flow, required runtime custom-tit…
Docstring Coverage Warning Docstring coverage is 13.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 59 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: preserving custom titles when renaming Agent terminal tabs in mobile.
Description check Passed The description includes all required sections, explains the user impact and implementation, links issue #28665, documents testing, provides a valid N/A visual-proof explanation, and addresses compati…
Linked Issues check Passed The changes meet the coding requirements in [#28665]. handleRenameTerminal updates sessionTabsRef and sessionTabs, then refreshes session.tabs.list and terminal.list. Runtime rename paths st…
Full details: Description check

Explanation

The description includes all required sections, explains the user impact and implementation, links issue #28665, documents testing, provides a valid N/A visual-proof explanation, and addresses compatibility and checklist items.

Full details: Linked Issues check

Explanation

The changes meet the coding requirements in [#28665]. handleRenameTerminal updates sessionTabsRef and sessionTabs, then refreshes session.tabs.list and terminal.list. Runtime rename paths store normalized values in customTitle for live and leaf-backed terminals. Session and terminal projections prefer customTitle while retaining live OSC title evidence for Agent status and icon resolution. Clearing the title restores the live title. The added tests cover optimistic state, refresh scheduling, leaf-backed renaming, OSC updates, controller-seeded titles, status preservation, and clearing.

Full details: Out of Scope Changes check

Explanation

The pull request includes changes not required by [#28665]. It adds a general workspace session custom-title system, an aiVault.renameSession RPC, closed Agent History and resume-title behavior, workspace ownership and migration rules, and new headless browser-tab projections. These changes extend beyond renaming a mobile Agent terminal tab and its required projections and tests.

Resolution

Remove the unrelated AI Vault session, Agent History/resume, workspace ownership, and browser-tab changes from this pull request, or move them to separate pull requests. Keep only the mobile terminal rename flow, required runtime custom-title persistence and projection changes, and their focused tests.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch mobile-tab-rename
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 Biome (2.5.14)
src/main/runtime/orca-runtime-terminal-rename-retention.test.ts

File contains syntax errors that prevent linting: Line 161: Expected an expression but instead found '<<'.; Line 161: Expected an expression but instead found '<<'.; Line 162: expected > but instead found describe

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: 069a0d04-6e4b-4f4a-88de-c12ff9533e63
📥 Commits

Reviewing files that changed from the base of the PR and between eb1ee8f and 63bdaab.

📒 Files selected for processing: 11
  • mobile/src/session/use-mobile-session-close-actions.test.ts
  • mobile/src/session/use-mobile-session-close-actions.ts
  • src/main/runtime/orca-runtime-persist-headless-terminal-title.ts
  • src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs.spec.ts
  • src/main/runtime/orca-runtime-write-orchestration-pointer-pty.ts
  • src/main/runtime/runtime-mobile-session-projection.ts
  • src/renderer/src/runtime/sync-runtime-graph/graph-publication.ts
  • src/renderer/src/runtime/sync-runtime-graph/mobile-session-terminal-tabs.ts
  • src/shared/runtime-mobile-session-tab-contracts.ts
  • src/shared/runtime-session-contracts.ts

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

Comment on lines +63 to +69
const nextSessionTabs = sessionTabsRef.current.map((tab) =>
tab.type === 'terminal' && tab.terminal === target.handle
? { ...tab, title: title || 'Terminal' }
: tab
)
sessionTabsRef.current = nextSessionTabs
setSessionTabs(nextSessionTabs)

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 | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '30,85p' mobile/src/session/use-mobile-session-close-actions.ts
rg -n 'sessionTabs|handleRenameTerminal|fetchSessionTabs' mobile/src/session | head -100

Repository: stablyai/orca

Length of output: 12383


🏁 Script executed:

set -u
printf '%s\n' '--- mobile title/header bindings ---'
rg -n -F --glob '*.{ts,tsx}' -e 'sessionTabs' -e 'MobileSessionTab' -e 'title' mobile/src/session mobile/src | head -240
printf '%s\n' '--- fetchSessionTabs definitions/callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'function fetchSessionTabs' -e 'const fetchSessionTabs' -e 'fetchSessionTabs =' -e 'sessionTabsListRead' mobile/src/session | head -160
printf '%s\n' '--- rename operation bindings ---'
rg -n -F --glob '*.{ts,tsx}' -e 'sessionTerminalRename' -e 'terminalRename' src mobile | head -200

Repository: stablyai/orca

Length of output: 29090


🏁 Script executed:

set -u
printf '%s\n' '--- tab rendering and state composition ---'
rg -n -F --glob '*.{ts,tsx}' -e 'sessionTabs.map' -e 'sessionTabsRef.current' -e 'setSessionTabs' -e 'SessionHeader' -e 'session header' mobile src | head -260
printf '%s\n' '--- read/write operation definitions ---'
sed -n '80,125p' mobile/src/session/mobile-session-read-operations.ts
sed -n '75,110p' mobile/src/session/mobile-session-write-operations.ts
printf '%s\n' '--- RPC rename symbols and likely host handlers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'session.terminal.rename' -e 'terminal.rename' -e 'sessionTerminalRename' -e 'terminalRename' src mobile | head -260
printf '%s\n' '--- controller and screen state ---'
sed -n '1,180p' mobile/src/session/use-mobile-session-controller.ts
sed -n '1,180p' mobile/src/session/use-mobile-session-screen-state.ts

Repository: stablyai/orca

Length of output: 31360


🏁 Script executed:

set -u
printf '%s\n' '--- MobileSessionHeader ---'
sed -n '1,190p' mobile/src/session/MobileSessionHeader.tsx
printf '%s\n' '--- session tab application and read flow ---'
sed -n '1,135p' mobile/src/session/use-mobile-session-tab-application.ts
sed -n '1,210p' mobile/src/session/use-mobile-session-terminal-list.ts
rg -n -F --glob '*.ts' -e 'fetchSessionTabs' -e 'sessionTabsListRead.request' mobile/src/session src/main/runtime | head -120
printf '%s\n' '--- terminal rename handler ---'
sed -n '90,160p' src/main/runtime/rpc/methods/terminal/terminal-query-methods.ts
printf '%s\n' '--- terminal title construction ---'
rg -n -F --glob '*.ts' -e 'customTitle' -e 'generatedTitle' -e 'title:' src/main/runtime src/shared | head -240

Repository: stablyai/orca

Length of output: 41827


🏁 Script executed:

set -u
printf '%s\n' '--- header tab label ---'
sed -n '125,215p' mobile/src/session/MobileSessionHeader.tsx
printf '%s\n' '--- fetchSessionTabs binding ---'
rg -n -F --glob '*.ts' -e 'fetchSessionTabs' mobile/src/session | head -100
sed -n '1,240p' mobile/src/session/use-mobile-session-tab-reconciliation.ts
printf '%s\n' '--- terminal rename implementation ---'
sed -n '105,145p' src/main/runtime/rpc/methods/terminal/terminal-query-methods.ts
rg -n -F --glob '*.ts' -e 'renameTerminal(' -e 'resolveTerminalTabTitle' -e 'session-tabs-snapshot' src/main/runtime | head -120
printf '%s\n' '--- title projection definitions ---'
sed -n '105,215p' src/main/runtime/runtime-leaf-record-projection.ts
sed -n '100,135p' src/main/runtime/orca-runtime-write-orchestration-pointer-pty.ts

Repository: stablyai/orca

Length of output: 29113


🏁 Script executed:

set -u
printf '%s\n' '--- mobile title helper and visible tabs ---'
rg -n -F --glob '*.ts' -e 'getMobileSessionTabTitle' -e 'visibleTabs' mobile/src/session | head -100
sed -n '1,220p' mobile/src/session/mobile-terminal-tab-agent.ts
sed -n '1,180p' mobile/src/session/use-mobile-session-presentation.ts
printf '%s\n' '--- session tabs fetch implementation ---'
sed -n '1,330p' mobile/src/session/use-mobile-session-tabs-reconciliation.ts
printf '%s\n' '--- runtime rename clear path ---'
sed -n '200,275p' src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
printf '%s\n' '--- shared title resolution ---'
rg -n -F --glob '*.ts' -e 'function resolveTerminalTabTitle' -e 'export function resolveTerminalTabTitle' src/shared
sed -n '1,220p' src/shared/tab-title-resolution.ts

Repository: stablyai/orca

Length of output: 22052


🏁 Script executed:

set -u
printf '%s\n' '--- mobile snapshot touch methods ---'
rg -n -F --glob '*.ts' -e 'touchMobileSessionSnapshotsForPty' -e 'touchMobileSessionTabsForWorktree' -e 'immediate:' src/main/runtime | head -140
printf '%s\n' '--- snapshot publication implementation ---'
rg -n -F --glob '*.ts' -e 'mobileSession' -e 'sessionTabs' src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts src/main/runtime | grep -E 'touchMobile|Snapshot|snapshot|session.tabs' | head -180
printf '%s\n' '--- rename tests ---'
sed -n '675,755p' src/main/runtime/orca-runtime-tests/mobile-session-tabs.spec.ts
sed -n '375,420p' src/main/runtime/orca-runtime-tests/terminal-side-effect-facts.spec.ts
printf '%s\n' '--- title retention tests ---'
sed -n '1,125p' src/main/runtime/orca-runtime-terminal-rename-retention.test.ts

Repository: stablyai/orca

Length of output: 38849


🏁 Script executed:

set -u
printf '%s\n' '--- touch implementation ---'
sed -n '1,125p' src/main/runtime/orca-runtime-touch-mobile-session-tabs-for-worktree.ts
sed -n '1,190p' src/main/runtime/orca-runtime-publish-pty-backed-mobile-session-terminal.ts
printf '%s\n' '--- notification scheduling ---'
sed -n '1,190p' src/main/runtime/orca-runtime-schedule-mobile-session-tabs-changed.ts
printf '%s\n' '--- snapshot refresh coalescing ---'
sed -n '1,125p' src/main/runtime/mobile-session-tabs-churn-coalescing.test.ts

Repository: stablyai/orca

Length of output: 23556


🏁 Script executed:

set -u
printf '%s\n' '--- coalescer definition and delay ---'
rg -n -F --glob '*.ts' -e 'mobileSessionTabsNotifyCoalescer' -e 'class .*Coales' -e 'schedule(worktreeId' src/main/runtime | head -160
printf '%s\n' '--- rename response contract ---'
rg -n -F --glob '*.ts' -e 'RuntimeTerminalRename' -e 'terminal-renamed' -e 'rename: RuntimeTerminalRename' src/shared src/main/runtime mobile/src | head -100
sed -n '1,80p' src/shared/runtime-types.ts

Repository: stablyai/orca

Length of output: 4493


🏁 Script executed:

set -u
printf '%s\n' '--- exact decisive excerpts ---'
nl -ba mobile/src/session/use-mobile-session-close-actions.ts | sed -n '41,76p'
nl -ba mobile/src/session/MobileSessionHeader.tsx | sed -n '165,205p'
nl -ba mobile/src/session/mobile-terminal-tab-agent.ts | sed -n '42,70p'
nl -ba src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts | sed -n '210,268p'
nl -ba src/main/runtime/orca-runtime-touch-mobile-session-tabs-for-worktree.ts | sed -n '14,48p'
printf '%s\n' '--- coalescer binding ---'
nl -ba src/main/runtime/orca-runtime-runtime-id.ts | sed -n '235,260p'
rg -n -F --glob '*.ts' -e 'export class MobileSessionTabsNotifyCoalescer' -e 'class MobileSessionTabsNotifyCoalescer' src/main/runtime src/shared

Repository: stablyai/orca

Length of output: 11139


Do not show Terminal while clearing a custom title.

The host returns no live OSC title in the rename response. Keep the previous session-tab title until the authoritative session snapshot arrives. The host can publish that snapshot before the 300 ms refresh, so the exact delay is not fixed.

Suggested fix
-            ? { ...tab, title: title || 'Terminal' }
+            ? { ...tab, title: title || tab.title }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const nextSessionTabs = sessionTabsRef.current.map((tab) =>
tab.type === 'terminal' && tab.terminal === target.handle
? { ...tab, title: title || 'Terminal' }
: tab
)
sessionTabsRef.current = nextSessionTabs
setSessionTabs(nextSessionTabs)
const nextSessionTabs = sessionTabsRef.current.map((tab) =>
tab.type === 'terminal' && tab.terminal === target.handle
? { ...tab, title: title || tab.title }
: tab
)
sessionTabsRef.current = nextSessionTabs
setSessionTabs(nextSessionTabs)

… field

- Store manual renames in customTitle on RuntimePtyWorktreeRecord and update both renameTerminal branches

- Read customTitle instead of pty.title for manualTitle in mobile session and terminal summary projections

- Ensure controller-seeded titles do not shadow live Agent OSC updates

- Eliminate type assertions in mobile and runtime tests to comply with strict code quality linting
@zhangxaochen

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@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: b425fbd2-2a66-4990-98dc-a3b9dfb51218
📥 Commits

Reviewing files that changed from the base of the PR and between e2007e4 and 6f9296a.

📒 Files selected for processing: 6
  • src/main/runtime/orchestration/terminal-authority/write-orchestration-pointer-pty.ts
  • src/main/runtime/terminal/identity/pty-worktree-record.ts
  • src/main/runtime/workspaces/workspace-file-session-targets.ts
  • src/main/runtime/workspaces/workspace-removal-target.ts
  • src/renderer/src/runtime/sync-runtime-graph/graph-publication.ts
  • src/shared/runtime-session-contracts.ts

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

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

Caution

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

⚠️ Outside diff range comments (1)

🟡 Minor · Allow clearing the terminal title · MobileSessionHeader.tsx:175-186

mobile/src/session/MobileSessionHeader.tsx:175-186
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Allow clearing the terminal title

The double-tap path and the action-sheet Rename path both open this modal. The modal omits allowEmpty, so TextInputModal rejects an empty submission. A user cannot clear an existing custom title. Add allowEmpty only to the terminal rename modal so empty input reaches the rename handler and restores the live OSC title.

Suggested fix
       <TextInputModal
         visible={renameTarget != null}
         title="Rename Terminal"
         defaultValue={renameTarget?.title || 'Terminal'}
         placeholder="Terminal name"
+        allowEmpty
         onSubmit={(value) => void handleRenameTerminal(value)}
         onCancel={() => setRenameTarget(null)}
       />

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bdbac445-4ac0-41be-a3f2-5897f962c011
📥 Commits

Reviewing files that changed from the base of the PR and between 6f9296a and 71f6c19.

📒 Files selected for processing: 3
  • src/main/runtime/orca-runtime-terminal-rename-retention.test.ts
  • src/main/runtime/orchestration/terminal-authority/write-orchestration-pointer-pty.ts
  • src/main/runtime/workspaces/workspace-file-session-targets.ts

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

Comment on lines +109 to +111
...(normalizedTitle === null && fallbackTitle !== null
? { title: fallbackTitle }
: {})

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Persist the fallback title when clearing a headless custom title.

If no matching leaf supplies fallbackTitle, clearing the custom title sets the in-memory and mobile titles to Terminal. This branch leaves the persisted tab’s previous title unchanged. A later session rebuild can therefore restore the old manual title. Persist the same fallback title used by the in-memory paths.

@zhangxaochen

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 8

🧹 Nitpick comments: 1
src/main/runtime/workspaces/workspace-removal-target.ts: 1

252-253: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the duplicate session-title write.

persistHeadlessTerminalTitle already calls resolveSessionIdForTab(tabId) and setSessionCustomTitle. The next rememberTerminalSessionTitle call does the same work again, with the handle added. Each rename therefore writes the workspace session twice. If the two calls resolve different session IDs, one rename stores two aliases. Pass handle to the session-ID resolution inside persistHeadlessTerminalTitle, or remove that resolution from it, so each rename has one write path.

Also applies to: 259-262, 276-276


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74a214e4-5b27-493d-a9dc-9d95a799c58d
📥 Commits

Reviewing files that changed from the base of the PR and between 71f6c19 and af96321.

📒 Files selected for processing: 46
  • mobile/src/agent-history/agent-history-session-card.ts
  • mobile/src/session/ai-vault-resume-launch.test.ts
  • mobile/src/session/ai-vault-resume-launch.ts
  • mobile/src/worktree/agent-row-display.ts
  • src/main/orca-profiles/profile-project-session-field-disposition.ts
  • src/main/persistence/restoring-sessions/session-worktree-ownership.ts
  • src/main/persistence/runtime-authored-workspace-session-fields.ts
  • src/main/runtime/orca-runtime-terminal-rename-retention.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
  • src/main/runtime/rpc/rpc-params-type-parity.ts
  • src/main/runtime/runtime-terminal-spawn-placement.ts
  • src/main/runtime/runtime-terminal-state-records.ts
  • src/main/runtime/runtime-worktree-agent-rows.ts
  • src/main/runtime/runtime-worktree-agent-source.ts
  • src/main/runtime/runtime-worktree-pty-agent-sources.ts
  • src/main/runtime/session-graph/session-graph-promotion.ts
  • src/main/runtime/session-graph/session-window-graph-titles.ts
  • src/main/runtime/session-graph/session-window-graph.ts
  • src/main/runtime/session-lifecycle/projection/build-headless-mobile-session-browser-tabs.ts
  • src/main/runtime/session-lifecycle/projection/headless-browser-tab-projection.ts
  • src/main/runtime/session-tabs/structured-session-tab-restoration.ts
  • src/main/runtime/terminal/launch/terminal-create.ts
  • src/main/runtime/workspaces/workspace-file-session-targets.ts
  • src/main/runtime/workspaces/workspace-process-listing.ts
  • src/main/runtime/workspaces/workspace-removal-target.ts
  • src/main/runtime/workspaces/workspace-session-custom-titles.ts
  • src/main/startup/main-window-agent-status.ts
  • src/main/startup/main-window-structured-status-filter.test.ts
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.structured-title.test.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts
  • src/renderer/src/components/right-sidebar/use-ai-vault-session-display-title.ts
  • src/renderer/src/lib/launch-ai-vault-session.ts
  • src/renderer/src/runtime/sync-runtime-graph/graph-publication.ts
  • src/renderer/src/runtime/web-session-tabs-sync/terminal-surfaces.ts
  • src/renderer/src/store/terminals/terminal-actions.ts
  • src/renderer/src/store/terminals/terminal-tab-appearance.ts
  • src/renderer/src/store/terminals/terminal-tab-creation.ts
  • src/shared/ai-vault-types.ts
  • src/shared/runtime-mobile-session-tab-contracts.ts
  • src/shared/runtime-session-contracts.ts
  • src/shared/workspace-layout/workspace-layout-beside.ts
  • src/shared/workspace-session-host-field-ownership.ts
  • src/shared/workspace-session-schema-field-coverage.test.ts
  • src/shared/workspace-session-schema.ts
  • src/shared/workspace-session-state-types.ts
  • src/shared/wsl-move/wsl-move-dispositions.ts

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

})
})

<<<<<<< HEAD

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

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -n '^(<<<<<<<|=======|>>>>>>>)' src/main/runtime/orca-runtime-terminal-rename-retention.test.ts

Repository: stablyai/orca

Length of output: 168


Resolve the leftover merge-conflict marker.

src/main/runtime/orca-runtime-terminal-rename-retention.test.ts contains <<<<<<< HEAD at line 161. Resolve the conflict and remove all conflict markers so the test file can be parsed.

🧰 Tools
🪛 Biome (2.5.14)

[error] 161-161: Expected an expression but instead found '<<'.

(parse)


[error] 161-161: Expected an expression but instead found '<<'.

(parse)

Source: Linters/SAST tools

Comment on lines +138 to +139
if (session.structuredSession) {
runtime.setSessionCustomTitle(session.structuredSession.sessionId, customTitle)

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect title-key normalization and the structured-tab rename path.
rg -n -C 6 'getSessionCustomTitle\s*\(|setSessionCustomTitle\s*\(' src/main/runtime
sed -n '20,36p' src/renderer/src/store/terminals/terminal-tab-appearance.ts

Repository: stablyai/orca

Length of output: 13223


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- workspace-session-custom-titles.ts ---'
nl -ba src/main/runtime/workspaces/workspace-session-custom-titles.ts | sed -n '1,90p'
printf '%s\n' '--- ai-vault.ts ---'
nl -ba src/main/runtime/rpc/methods/ai-vault.ts | sed -n '90,170p'
printf '%s\n' '--- stable pane parser ---'
rg -n -C 8 -F -- 'parsePaneKey' src/shared src/main/runtime | head -160

Repository: stablyai/orca

Length of output: 23833


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- session title tab resolution ---'
nl -ba src/main/runtime/workspaces/workspace-session-custom-titles.ts | sed -n '104,156p'
printf '%s\n' '--- rename callers and agent-session identity ---'
rg -n -C 10 -F -- 'aiVault.renameSession' mobile src/main src/renderer | head -240
rg -n -C 8 -F -- "contentType: 'agent-session'" src/main mobile src/renderer | head -200

Repository: stablyai/orca

Length of output: 26836


Keep provider and structured-session title keys consistent.

getSessionCustomTitle checks the exact key first, while setSessionCustomTitle writes or clears only the exact key. If provider and structured-session IDs differ, listing can copy a provider-keyed title to the structured-session key. Clearing the structured-session key then leaves the provider title, which a later list can restore.

Store one canonical title key, or clear every alias.

Comment on lines +8 to +16
for (const tab of tabs) {
const customTitle = tab.customTitle?.trim() || null
const previousCustomTitle = previousTabs.get(tab.tabId)?.customTitle?.trim() || null
if (customTitle) {
rememberTitle(tab.tabId, customTitle)
} else if (previousCustomTitle) {
rememberTitle(tab.tabId, null)
}
}

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.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Write session titles only when the custom title changes.

syncWindowGraph calls this function on every graph publish. Each tab with a custom title calls rememberTitle. That call runs resolveSessionIdForTab and setWorkspaceSession, even when the title is unchanged. Graph publishes are frequent, so this causes repeated full session writes and linear scans. Compare customTitle with previousCustomTitle and skip equal values.

⚡ Proposed fix
-    if (customTitle) {
+    if (customTitle === previousCustomTitle) {
+      continue
+    }
+    if (customTitle) {
       rememberTitle(tab.tabId, customTitle)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (const tab of tabs) {
const customTitle = tab.customTitle?.trim() || null
const previousCustomTitle = previousTabs.get(tab.tabId)?.customTitle?.trim() || null
if (customTitle) {
rememberTitle(tab.tabId, customTitle)
} else if (previousCustomTitle) {
rememberTitle(tab.tabId, null)
}
}
for (const tab of tabs) {
const customTitle = tab.customTitle?.trim() || null
const previousCustomTitle = previousTabs.get(tab.tabId)?.customTitle?.trim() || null
if (customTitle === previousCustomTitle) {
continue
}
if (customTitle) {
rememberTitle(tab.tabId, customTitle)
} else if (previousCustomTitle) {
rememberTitle(tab.tabId, null)
}
}

Comment on lines +35 to +40
const normalized = title?.trim() || null
if (normalized) {
this.inMemorySessionCustomTitles.set(sessionId, normalized)
} else {
this.inMemorySessionCustomTitles.delete(sessionId)
}

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Do not write titles longer than 256 characters into sessionCustomTitles.

setSessionCustomTitle stores any trimmed title. The schema in src/shared/workspace-session-schema.ts accepts only values with .max(256). salvagingRecord therefore drops longer entries on the next load, so a long rename is lost after restart. Truncate or reject the title here so the stored value matches the schema.

🐛 Proposed fix
--- "a/src/main/runtime/workspaces/workspace-session-custom-titles.ts"
+++ "b/src/main/runtime/workspaces/workspace-session-custom-titles.ts"
@@ -32,7 +32,7 @@
     if (!sessionId) {
       return
     }
-    const normalized = title?.trim() || null
+    const normalized = title?.trim().slice(0, 256) || null
     if (normalized) {
       this.inMemorySessionCustomTitles.set(sessionId, normalized)
     } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const normalized = title?.trim() || null
if (normalized) {
this.inMemorySessionCustomTitles.set(sessionId, normalized)
} else {
this.inMemorySessionCustomTitles.delete(sessionId)
}
const normalized = title?.trim().slice(0, 256) || null
if (normalized) {
this.inMemorySessionCustomTitles.set(sessionId, normalized)
} else {
this.inMemorySessionCustomTitles.delete(sessionId)
}

{
agent: session.agent,
worktreeId: targetId.worktreeId,
customTitle: session.customTitle ?? session.title ?? null,

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

Pass only the manual title as customTitle.

When session.customTitle is null, this expression passes session.title as a custom title. The local launch path then stores it in TerminalTab.customTitle. A resumed Agent consequently treats a scanned title as a manual rename and keeps it over later OSC titles. Pass session.customTitle without the scanned-title fallback.

// Why: a manual rename lives only on the client; re-nulling it here made
// every host snapshot silently discard the user's title.
customLabel: existing?.customLabel ?? null,
customLabel: existing?.customLabel ?? tab.customTitle ?? null,

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Allow host title updates after the first mirrored snapshot.

When the first snapshot supplies tab.customTitle = 'A', this line stores 'A' in customLabel. On the next snapshot, existing.customLabel wins even if the host changes the title to 'B' or clears it. The mirrored tab remains at 'A'. Track whether a label was edited locally, or otherwise reconcile host-supplied labels with the current host snapshot.

.flat()
.find((t) => t.id === tabId)?.aiVaultTitle?.sessionId
if (sessionId) {
callRuntimeRpc({ kind: 'local' }, 'aiVault.renameSession', { sessionId, title }).catch(

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Send the rename to the session’s execution host.

When item.executionHostId identifies a remote host, { kind: 'local' } writes the title to the desktop runtime instead. The owning host keeps its old title and restores it on refresh. Route aiVault.renameSession to the unified tab’s execution host, as the other remote tab operations do.

Comment on lines +31 to +33
callRuntimeRpc({ kind: 'local' }, 'aiVault.renameSession', { sessionId, title }).catch(
() => {}
)

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Preserve the order of successive rename writes.

If a user renames a tab twice before the first RPC finishes, both writes run independently. The first write can finish last and restore the older title on the next refresh. Serialize writes for the session, or attach a revision that makes an older write ineffective.

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for the report and the root-cause notes. This is superseded by #30163, a leaner fix for the same bug, so I'm closing this one.

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.

[Bug]: Renaming an Agent terminal tab on Mobile does not take effect

2 participants