Repository navigation
fix(terminal): mirror pane renames to the owning runtime - #30333
wangshifeng wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to
|
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:
75758434-f407-4c7d-9fd5-98dec596b363
📥 Commits
Reviewing files that changed from the base of the PR and between aa07d58 and 8346c0c39ef8a033d3a1695a8e74ce4235e15fbc.
📒 Files selected for processing: 4
src/renderer/src/components/terminal-pane/terminal-layout-gesture-persist.test.tsxsrc/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.tssrc/renderer/src/runtime/pane-terminal-title-sync.test.tssrc/renderer/src/runtime/pane-terminal-title-sync.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.
| @@ -203,6 +204,11 @@ export function useTerminalPaneLayoutPersistence(controller: TerminalPaneStartup | |||
| const showTitle = (): void => | |||
| title === null ? removePaneTitleLocally(paneId) : setPaneTitleLocally(paneId, title) | |||
| const leafId = managerRef.current?.getPanes().find((pane) => pane.id === paneId)?.leafId | |||
| if (leafId) { | |||
| void syncPaneTerminalTitle({ worktreeId, tabId, leafId, title }).catch((error: unknown) => { | |||
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- target hook ---'
nl -ba src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts | sed -n '150,240p'
printf '%s\n' '--- symbols ---'
rg -n -F --glob '*.{ts,tsx}' -e 'sendLayoutCommandToOwner' -e 'syncPaneTerminalTitle' -e 'ORCA_LAYOUT_OWNER_IS_MAIN' src || test "$?" -eq 1
printf '%s\n' '--- relevant test names/content ---'
rg -n -i --glob '*.{test,spec}.{ts,tsx}' -e 'sendLayoutCommandToOwner' -e 'syncPaneTerminalTitle' -e 'accepted' -e 'apply' src/renderer/src/components src/renderer/src/runtime || test "$?" -eq 1
printf '%s\n' '--- changed-file diff ---'
git diff --no-ext-diff aa07d5891a402a2f98cc1e56d22a2b30d4f15542 8346c0c39ef8a033d3a1695a8e74ce4235e15fbc -- src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts
printf '%s\n' '--- sync helper definitions ---'
rg -n -F --glob '*.{ts,tsx}' -e 'export async function syncPaneTerminalTitle' -e 'function syncPaneTerminalTitle' -e 'const syncPaneTerminalTitle' src || test "$?" -eq 1Repository: stablyai/orca
Length of output: 45667
🏁 Script executed:
set -eu
printf '%s\n' '--- exact owner-command references ---'
rg -n -F -- 'sendLayoutCommandToOwner' src/renderer src/shared src/main || test "$?" -eq 1
printf '%s\n' '--- owner-command imports/definitions ---'
rg -n -F -- 'function sendLayoutCommandToOwner' src || test "$?" -eq 1
rg -n -F -- 'const sendLayoutCommandToOwner' src || test "$?" -eq 1
rg -n -F -- 'export { sendLayoutCommandToOwner' src || test "$?" -eq 1
printf '%s\n' '--- sync helper and focused tests ---'
nl -ba src/renderer/src/runtime/pane-terminal-title-sync.ts
rg -n -F -- 'pane-terminal-title-sync' src/renderer src/shared src/main || test "$?" -eq 1
rg -n -F -- 'renamePane' src/renderer/src/components/terminal-pane src/renderer/src/store src/shared/workspace-layout src/main/runtime | head -120 || true
printf '%s\n' '--- owner-related layout test files ---'
rg --files src | rg 'layout-owner|workspace-layout-command|terminal-pane-layout-persistence|pane-terminal-title'Repository: stablyai/orca
Length of output: 24237
🏁 Script executed:
set -eu
printf '%s\n' '--- owner command implementation ---'
nl -ba src/renderer/src/runtime/layout-owner-command.ts
printf '%s\n' '--- owner command tests ---'
nl -ba src/renderer/src/runtime/layout-owner-command.test.ts | sed -n '1,240p'
printf '%s\n' '--- gesture persistence test ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-layout-gesture-persist.test.tsx | sed -n '1,230p'
printf '%s\n' '--- hook imports and surrounding declarations ---'
nl -ba src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts | sed -n '1,45p'
nl -ba src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts | sed -n '185,230p'Repository: stablyai/orca
Length of output: 22248
🏁 Script executed:
set -eu
printf '%s\n' '--- layout apply send implementation ---'
nl -ba src/renderer/src/runtime/layout-apply-send.ts
printf '%s\n' '--- layout apply type/callback declarations ---'
rg -n -F -- 'export type LayoutApplyHandlers' src/renderer/src/runtime src || test "$?" -eq 1
rg -n -F -- 'type LayoutApplyHandlers' src/renderer/src/runtime src || test "$?" -eq 1
printf '%s\n' '--- callback usage around sendLayoutApply ---'
rg -n -F -- 'sendLayoutApply' src/renderer/src/runtime src/renderer/src/components | head -80 || trueRepository: stablyai/orca
Length of output: 14601
Sync the runtime title only after applying the local title.
sendLayoutCommandToOwner returns before its RPC completes. A failed RPC calls refused('call_failed') without invoking apply or asToday, but the current code has already started syncPaneTerminalTitle. Move the sync into the title-application callback and preserve the immediate window-owned path.
🐛 Suggested fix
--- "a/src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts"
+++ "b/src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts"
@@ -201,27 +201,30 @@
/** A user's title for a pane, trimmed and non-empty; null clears it. */
const changePaneTitle = useCallback(
(paneId: number, title: string | null) => {
const showTitle = (): void =>
title === null ? removePaneTitleLocally(paneId) : setPaneTitleLocally(paneId, title)
const leafId = managerRef.current?.getPanes().find((pane) => pane.id === paneId)?.leafId
- if (leafId) {
- void syncPaneTerminalTitle({ worktreeId, tabId, leafId, title }).catch((error: unknown) => {
- console.warn('[terminal-pane] failed to sync pane title to runtime:', error)
- })
- }
+ const showTitleAndSync = (): void => {
+ showTitle()
+ if (leafId) {
+ void syncPaneTerminalTitle({ worktreeId, tabId, leafId, title }).catch((error: unknown) => {
+ console.warn('[terminal-pane] failed to sync pane title to runtime:', error)
+ })
+ }
+ }
// Switch point: main renames the pane first; the window then shows the title.
if (
ORCA_LAYOUT_OWNER_IS_MAIN &&
leafId &&
sendLayoutCommandToOwner(
worktreeId,
{ type: 'renamePane', tabId, leafId, title },
- { apply: showTitle, asToday: showTitle }
+ { apply: showTitleAndSync, asToday: showTitleAndSync }
)
) {
return
}
- showTitle()
+ showTitleAndSync()
},
// oxlint-disable-next-line react-hooks/exhaustive-deps -- Refs are stable.
[removePaneTitleLocally, setPaneTitleLocally, tabId, worktreeId]| if (!resolved.terminal) { | ||
| return | ||
| } | ||
| await callRuntimeRpc(target, 'terminal.rename', { |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,110p' src/renderer/src/runtime/pane-terminal-title-sync.ts
sed -n '194,230p' src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts
rg -n "'terminal.rename'|'terminal.resolvePane'|terminal\.rename" src/main src/renderer/src/runtime src/shared | head -90Repository: stablyai/orca
Length of output: 7044
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- runtime RPC client and related queueing ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'export async function callRuntimeRpc' -e 'function callRuntimeRpc' -e 'class .*Queue' -e 'serialize' -e 'enqueue' src/renderer/src/runtime src/shared src/main/runtime | head -160
printf '%s\n' '--- runtime RPC client source ---'
client=$(rg -l -F --glob '*.ts' -- 'export async function callRuntimeRpc' src/renderer/src/runtime | head -1)
if [ -n "$client" ]; then
sed -n '1,240p' "$client"
fi
printf '%s\n' '--- terminal query/rename methods ---'
sed -n '1,190p' src/main/runtime/rpc/methods/terminal/terminal-query-methods.ts
printf '%s\n' '--- direct rename receiver and callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'renameTerminal' -e 'terminal.rename' -e 'rename(' src/main/runtime src/shared | head -220
printf '%s\n' '--- sync helper callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'syncPaneTerminalTitle' src/renderer/srcRepository: stablyai/orca
Length of output: 42160
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- callRuntimeRpc implementation ---'
sed -n '1,220p' src/renderer/src/runtime/runtime-rpc-client.ts
printf '%s\n' '--- environment transport and queue references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'callRuntimeEnvironmentWithRevision' -e 'RuntimeRpcCallQueue' -e 'runtimeRpcCallQueue' -e 'new RuntimeRpcCallQueue' -e 'queue.enqueue' src/renderer/src/runtime src/main/runtime src/shared | head -180
printf '%s\n' '--- queue implementation and tests ---'
rg -l -F --glob '*.ts' -- 'class RuntimeRpcCallQueue' src/shared src/main src/renderer | while read -r f; do echo "FILE $f"; sed -n '1,240p' "$f"; done
printf '%s\n' '--- renameTerminal declarations and implementations ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'async renameTerminal' -e 'renameTerminal(handle' -e 'renameTerminal(' src/main/runtime | head -160Repository: stablyai/orca
Length of output: 32064
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- environment RPC call ---'
sed -n '1,260p' src/renderer/src/runtime/runtime-rpc-environment-call.ts
printf '%s\n' '--- queue construction and enqueue bindings ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'RuntimeRpcCallQueuePool' -e 'new RuntimeRpcCallQueuePool' -e '.enqueue(selector' -e '.enqueue(environment' src/main src/renderer src/shared | head -220
printf '%s\n' '--- local runtime.call registration/handler ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e \"runtime.call\" -e \"'runtime:call'\" -e 'runtimeCall' src/main src/renderer src/shared | head -180
printf '%s\n' '--- runtime rename receiver ---'
sed -n '180,285p' src/main/runtime/workspaces/workspace-removal-target.ts
printf '%s\n' '--- runtime rename declaration context ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'class OrcaRuntime' -e 'renameTerminal(handle' -e 'renameTerminal(' src/main/runtime/orca-runtime.ts src/main/runtime | head -120Repository: stablyai/orca
Length of output: 41816
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- main environment call queue wrapper ---'
cat src/main/ipc/runtime-environment-call-queue.ts
printf '%s\n' '--- callers of enqueueRuntimeEnvironmentCall ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'enqueueRuntimeEnvironmentCall' -e 'runtimeEnvironmentCallQueue' -e 'runtimeEnvironments.call' src/main src/renderer | head -180
printf '%s\n' '--- IPC registration around runtime environment calls ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'runtimeEnvironments' -e 'runtime-environments' src/main/ipc src/main | head -220
printf '%s\n' '--- complete rename mutation ---'
sed -n '205,275p' src/main/runtime/workspaces/workspace-removal-target.ts
printf '%s\n' '--- terminal RPC method context ---'
sed -n '105,140p' src/main/runtime/rpc/methods/terminal/terminal-query-methods.tsRepository: stablyai/orca
Length of output: 42686
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- active queue binding ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'enqueueRuntimeCall' src/main src/renderer src/shared
printf '%s\n' '--- runtime environment call handler ---'
rg -l -F --glob '*.ts' -- 'runtimeEnvironments:call' src/main/ipc | while read -r f; do
echo "FILE $f"
rg -n -F -C 12 -- 'runtimeEnvironments:call' "$f"
done
printf '%s\n' '--- local runtime call handlers and dispatch ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'runtime:call' -e 'runtime.call' -e 'ipcMain.handle' src/main/ipc src/main/window | head -180Repository: stablyai/orca
Length of output: 37392
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- paired transport queue call ---'
sed -n '1,105p' src/main/ipc/runtime-environment-transport-routing.ts
printf '%s\n' '--- local runtime IPC handler ---'
sed -n '1,120p' src/main/ipc/runtime.ts
printf '%s\n' '--- runtime RPC server dispatch ---'
sed -n '1,180p' src/main/runtime/runtime-rpc.tsRepository: stablyai/orca
Length of output: 11411
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- remote RPC request dispatch ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'sendRemoteRuntimeRequest' -e 'RpcDispatcher' -e 'dispatch(' src/main src/shared | head -220
printf '%s\n' '--- remote runtime server request handlers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'runtimeRpc' -e 'remote runtime' -e 'incoming' src/main/runtime/runtime-rpc src/main | head -220Repository: stablyai/orca
Length of output: 41252
Serialize title synchronization per pane.
Rapid title changes can overlap. changePaneTitle starts each synchronization independently, and the RPC paths do not serialize requests per pane. The second terminal.resolvePane can complete first, so the older terminal.rename can overwrite the newer host title.
Serialize the complete resolve-and-rename operation by pane key. This is a narrow race in the title integration path, so the issue is minor rather than major.
Pane titles live in the renderer layout. On a Web client (and on paired clients with local PTYs) the layout push is gated on a remote ptyId, so a pane rename never reached the host and `terminal.list` kept reporting the old title. Mirror the rename through the same `terminal.resolvePane` + `terminal.rename` path the CLI uses, for both local and environment runtimes. Clearing a title forwards null. Fixes stablyai#30329
8346c0c to
1aff58f
Compare
|
Updated to address the review:
|
|
The two review points are addressed in
@coderabbitai review |
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:
a69412c9-6e06-4153-a44f-946aad55aac7
📥 Commits
Reviewing files that changed from the base of the PR and between 8346c0c39ef8a033d3a1695a8e74ce4235e15fbc and 1aff58f.
📒 Files selected for processing: 3
src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.tssrc/renderer/src/runtime/pane-terminal-title-sync.test.tssrc/renderer/src/runtime/pane-terminal-title-sync.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.
|
getRuntimeEnvironmentIdForWorktree is read-only and collapses an ambiguous owner to null, which made the mirror fall back to the local runtime. Use runtimeEnvironmentIdForWorkspaceOwner and skip synchronization when the owner is ambiguous; local and direct-SSH owners keep the existing path.
|
Thank you @wangshifeng, both for this PR and for the careful root-cause write-up in #30329. I'm closing this in favour of #30433, which builds on your investigation and credits you as co-author. Why not merge this one:
So naming one pane of a split would rename the whole tab everywhere. That includes the user's own desktop, because a local worktree routes to the What #30433 does instead:
Hosts that have their own desktop window still need a follow-up to pass client pane names on to that window. That work is tracked under #30386. |
…ring the last one sticks (#30433) A client's pane rename already lands in the host's saved layout (titlesByLeafId), but terminal.list/show never read it, and clearing a remote tab's last pane title sent no titles at all, which every host reads as 'unchanged'. - terminal summaries carry an optional paneTitle from the host's saved layout; the CLI list prints it ahead of the terminal title. Older hosts omit it. - clearing the last pane title of a remote tab pushes titlesByLeafId: {}, which old and new hosts both persist as cleared. Supersedes #30333, which renamed the whole tab via terminal.rename. Co-authored-by: wangshifeng <[email protected]>
ELI5
When you rename a terminal pane in Orca Web, the new name only lived in that browser tab. This PR also tells the Orca host, so
orca terminal list, other clients, agents, and dashboards see the same name.What Changed
syncPaneTerminalTitle(src/renderer/src/runtime/pane-terminal-title-sync.ts).changePaneTitlenow mirrors the title to the owning runtime after the local title is applied:terminal.resolvePane(paneKey = tabId:leafId),terminal.renamewith the resolved handle (same path as the CLI).runtimeEnvironmentIdForWorkspaceOwner; when the owner is ambiguous, synchronization is skipped instead of falling back to the local runtime.title: null.Why
Pane titles are renderer layout state. The existing remote-layout push is gated on
hasRemotePane(isRemoteRuntimePtyId), so a host-local PTY never sendstitlesByLeafId; even when it does,updateMobileSessionPaneLayoutearly-returns when an authoritative desktop window exists. The host therefore keeps reporting the old title, and any host-side consumer (CLI, exporters, dashboards, agents addressing sessions by name) disagrees with the UI.Routing the rename through
terminal.renameupdates the terminal summary directly, which is exactly whatorca terminal renamealready does. This avoids changing layout ownership rules and works for single- and multi-pane tabs.Related but distinct: #19582 / #19583 and #17644 cover tab-level
customTitle; this is pane-leveltitlesByLeafId.On layout persistence (
titlesByLeafId)terminal.listis built from the PTY/tab title (terminal.renamesetspty.pty.title;mobile-session-terminal-projection.tsuses tab-level title fields), nottitlesByLeafId. Replacingterminal.renamewithsession.tabs.updatePaneLayoutwould persist the layout but leave the reportedterminal.list/ exporter / dashboard symptom stale.updatePaneLayoutalso intentionally skips when an authoritative window owns the layout.Follow-up issue: #30386 (linked to the in-flight tab-title work in #19583 / #17644).
Linked Issue
Fixes #30329
Visual Proof
N/A — no visual change; the Orca UI already showed the new title. Before/after behavior on the host:
Testing
vitest:src/renderer/src/runtime/pane-terminal-title-sync.test.tsandsrc/renderer/src/components/terminal-pane/terminal-layout-gesture-persist.test.tsx— 12 tests pass.oxlint(both repo configs) andoxfmtpass on the changed files via lint-staged.tsc -p config/tsconfig.web.json --noEmit).pnpm lint/typecheck/test/buildnot completed locally (this checkout lacks some optional native bindings); CI will cover.AI Disclosure
Claude Code (Anthropic) was used to investigate the rename path, draft the patch, and write the tests.
Review
resolvePaneplus onerenameper user rename; fire-and-forget, serialized per pane, no hot path.TerminalRenamecontract.Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test,pnpm buildpass (targeted checks pass; full run left to CI)