Skip to content

fix(mobile): preserve Claude chat after renaming its pane - #31358

Merged
nwparker merged 2 commits into
mainfrom
nwparker/mobile-chat-rename
Oct 21, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/mobile-chat-rename

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Renaming a Claude terminal pane to a normal label makes mobile chat lose its transcript address, even though the same agent and conversation are still running.

ELI5

Changing a pane's name should work like changing a folder label: its conversation stays inside. Orca now checks the title the running program last reported before deciding the shell has taken the pane back.

Changes

  • Keep the provider session when a manual title overrides an agent OSC title.
  • Apply that distinction to live-hook selection and restored-turn retirement.
  • Continue retiring activity on a later shell OSC title and clearing status on a certified PTY exit.

Validation

  • Reproduced: the new runtime rename regression fails against the baseline because agentStatus disappears.
  • 40 focused runtime integration/builder tests pass, including working-agent rename, shell reclaim, no-session panes, and renamed PTY exit.
  • Source main build, focused lint, and changed-code quality gate pass.
  • Native iPhone simulator: the baseline rename exits chat and removes its session; the fixed runtime retains the same transcript under Release review. Captures visually reviewed.
  • Native scope: current source-built Release shell, production hosted page, real source runtimes and E2EE v2. A controlled Claude-compatible transcript/provider process emits the installed managed hooks; no renderer status is fabricated.
  • Independent root review found no correctness blockers.

Community credit

Adapted from #22865 by @innocarpe (Wooseong Kim), credited with Co-authored-by: Wooseong Kim <[email protected]> in the implementation commit. This revision also applies the same distinction to live and restored hook rows.

Fixes #20626

Native proof

Before: renaming the live pane drops conversation identity and returns to terminal view.

(screenshot removed: contained real product data)

After: the same manual title retains the conversation and readable transcript.

(screenshot removed: contained real product data)

nwparker and others added 2 commits October 20, 2026 20:23
Distinguish a manual title override from a later shell OSC title, keeping transcript identity and live hook selection while preserving exit retirement.

Co-authored-by: Wooseong Kim <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The runtime status builder now treats a non-agent title as a manual override when the OSC title identifies an agent and differs from the current title. Such overrides do not trigger shell-title suppression or restored-status retirement. Regression tests cover restored status, hook status and transcript-session projection across manual renames, shell-title return, and PTY exit.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 9d15d

In a narrow adoption case, a pane that has returned to a shell may still show stale agent status on mobile. The main rename fix works as intended, so this can be followed up with owner awareness.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: preserving Claude mobile chat after a terminal pane rename.
Description check Passed The description explains the problem, user impact, implementation, linked issue, validation, and visual proof. It does not reproduce every template heading or checklist item, but it provides the requi…
Linked Issues check Passed Issue #20626 is active and directly linked. The builder now distinguishes a manual title from a later shell OSC title by comparing ptyTitle with lastOscTitle. A manual title keeps `providerSession…
Out of Scope Changes check Passed The changed production code is limited to mobile agent-status projection for manual rename, shell reclaim, restored-turn retirement, and PTY-exit behavior. The added tests cover these behaviors and th…
Full details: Description check

Explanation

The description explains the problem, user impact, implementation, linked issue, validation, and visual proof. It does not reproduce every template heading or checklist item, but it provides the required information in equivalent sections.

Full details: Linked Issues check

Explanation

Issue #20626 is active and directly linked. The builder now distinguishes a manual title from a later shell OSC title by comparing ptyTitle with lastOscTitle. A manual title keeps providerSession, live hook status, and restored status. The regression tests verify transcript address retention after rename, agentType: 'claude', working status, restored status, and retirement after a later bash OSC title. The projection test also verifies PTY exit still removes the status.

Full details: Out of Scope Changes check

Explanation

The changed production code is limited to mobile agent-status projection for manual rename, shell reclaim, restored-turn retirement, and PTY-exit behavior. The added tests cover these behaviors and the no-session cases. These changes support issue #20626 and show no unrelated change.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4fdd6cf-6c58-4cad-8b85-2dc9f0114b31
📥 Commits

Reviewing files that changed from the base of the PR and between 411b5c0 and 9d15d8e.

📒 Files selected for processing: 3
  • src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts
  • src/main/runtime/runtime-mobile-agent-status-builder.test.ts
  • src/main/runtime/runtime-mobile-agent-status-builder.ts

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

Comment on lines +70 to +75
const titleOmitsAgent = ptyTitle !== null && ptyTitleClassification !== 'agent'
const oscTitle = pty?.lastOscTitle ?? leaf?.lastOscTitle ?? null
// Why: a manual rename is not the shell reclaiming the pane, so the hook session stays addressable (#20626).
const manualTitleOverridesAgentOsc =
titleOmitsAgent && ptyTitle !== oscTitle && classifyAgentTitle(oscTitle) === 'agent'
const nonAgentTitle = titleOmitsAgent && !manualTitleOverridesAgentOsc

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:

#!/bin/bash
# Find writers of pty.title / leaf.paneTitle to confirm only rename or OSC paths set them.
rg -nP --type=ts -C3 '\b(title|paneTitle)\s*=' src/main/runtime --glob '!**/*.test.ts' | head -150
rg -nP --type=ts -C3 'getLatestAgentCandidateTitle' src/main/runtime --glob '!**/*.test.ts'

Repository: stablyai/orca

Length of output: 26087


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- builder ---'
nl -ba src/main/runtime/runtime-mobile-agent-status-builder.ts | sed -n '1,125p'
printf '%s\n' '--- title projection ---'
nl -ba src/main/runtime/runtime-worktree-status-projection.ts | sed -n '1,250p'
printf '%s\n' '--- pty title writers and helper references ---'
rg -n -F --glob '*.ts' -e 'pty.title =' -e 'leaf.paneTitle =' -e 'setPtyManagementTitleFromObservedTitle' -e 'lastOscTitle =' -e 'paneTitle =' src/main/runtime
printf '%s\n' '--- rename references ---'
rg -n -F --glob '*.ts' -e 'terminal rename' -e 'renameTerminal' -e 'renamePty' -e 'rename' src/main/runtime/terminal src/main/runtime | head -240

Repository: stablyai/orca

Length of output: 41988


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- manual rename implementation ---'
nl -ba src/main/runtime/workspaces/workspace-removal-target.ts | sed -n '215,285p'
printf '%s\n' '--- identity restore/title state ---'
nl -ba src/main/runtime/terminal/identity/pty-worktree-record.ts | sed -n '80,215p'
printf '%s\n' '--- OSC observation ---'
nl -ba src/main/runtime/terminal/output/terminal-title-observation.ts | sed -n '90,225p'
printf '%s\n' '--- hydration ---'
nl -ba src/main/runtime/terminal/output/headless-terminal-hydration.ts | sed -n '120,175p'
printf '%s\n' '--- launch title path ---'
nl -ba src/main/runtime/terminal/launch/terminal-create.ts | sed -n '215,265p'
printf '%s\n' '--- observation sequence and title fields ---'
rg -n -F --glob '*.ts' -e 'nextTitleObservationSequence' -e 'titleUpdatedAt' -e 'lastOscTitleAt' src/main/runtime/terminal src/main/runtime/workspaces | head -240

Repository: stablyai/orca

Length of output: 27163


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- recordPtyWorktree declaration ---'
rg -n -F --glob '*.ts' 'recordPtyWorktree' src/main/runtime
printf '%s\n' '--- callers and state.title construction ---'
rg -n -F --glob '*.ts' -e 'title: ' -e 'title =' -e 'recordPtyWorktree(' src/main/runtime | grep -E 'recordPtyWorktree|title' | head -300
printf '%s\n' '--- owning declaration context ---'
nl -ba src/main/runtime/terminal/identity/pty-worktree-record.ts | sed -n '1,135p'

Repository: stablyai/orca

Length of output: 41923


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- controller inventory caller ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-controller-inventory-refresh.ts | sed -n '185,225p'
printf '%s\n' '--- output ingestion caller ---'
nl -ba src/main/runtime/terminal/output/pty-output-ingestion.ts | sed -n '160,195p'
printf '%s\n' '--- lifecycle registration caller ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-registration.ts | sed -n '80,115p'
printf '%s\n' '--- terminal create dedup caller ---'
nl -ba src/main/runtime/terminal/launch/terminal-create-deduplication.ts | sed -n '90,120p'
printf '%s\n' '--- inventory title semantics ---'
rg -n -F --glob '*.ts' -e 'listProcesses' -e 'title: session.title' -e 'session.title' src/main/runtime/terminal src/main/runtime | head -180

Repository: stablyai/orca

Length of output: 29620


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- PTY process contract ---'
rg -n -F --glob '*.ts' -e 'export type PtyProcessInfo' -e 'interface PtyProcessInfo' -e 'type PtyProcessInfo' src shared
printf '%s\n' '--- process contract context ---'
rg -n -F --glob '*.ts' 'PtyProcessInfo' src/main/runtime | head -80
printf '%s\n' '--- deduplication function ---'
nl -ba src/main/runtime/terminal/launch/terminal-create-deduplication.ts | sed -n '1,145p'
printf '%s\n' '--- controllerTitle consumers ---'
rg -n -F --glob '*.ts' 'controllerTitle' src/main/runtime

Repository: stablyai/orca

Length of output: 303


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- PTY process contract ---'
nl -ba src/main/providers/pty-process-info.ts | sed -n '1,100p'
printf '%s\n' '--- deduplication function ---'
nl -ba src/main/runtime/terminal/launch/terminal-create-deduplication.ts | sed -n '1,145p'
printf '%s\n' '--- controllerTitle consumers ---'
rg -n -F --glob '*.ts' 'controllerTitle' src/main/runtime || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 10059


Track manual-rename provenance separately.

reconcileRemoteTerminalCreate passes the provider's session.title to recordPtyWorktree. For an existing PTY, that overwrites pty.title without changing lastOscTitle. If session.title is a shell title after an agent OSC title, manualTitleOverridesAgentOsc becomes true even though no manual rename occurred. The builder can then retain stale agent status instead of applying non-agent-title suppression.

Use an explicit manual-rename marker, or keep adoption titles out of this comparison, and add a regression test for this sequence.

@nwparker
nwparker merged commit 8bec732 into main Oct 21, 2026
68 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.

Mobile: renaming a Claude pane with orca terminal rename empties its chat view until the original title is restored

1 participant