Repository navigation
fix(remote): make the host's tab name the one source for CLI and desktop renames #30037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/main/runtime/orca-runtime-tests/headless-terminal-rename-publication.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import { describe, expect, it, vi } from 'vitest' | ||
| import { OrcaRuntimeService } from '../orca-runtime-test-mocks.spec' | ||
| import { | ||
| HEADLESS_LEAF_ID, | ||
| TEST_WORKTREE_ID, | ||
| makeRuntimeStoreWithWorkspaceSession, | ||
| makeWorkspaceSessionWithHeadlessTerminal | ||
| } from '../orca-runtime-test-fixtures.spec' | ||
|
|
||
| // #29975: a paired desktop ranks its own saved-session title over the host's live title, so a | ||
| // CLI rename on a headless host only reaches it when the host says the name is manual. | ||
| function headlessRuntime() { | ||
| const { runtimeStore, getSession } = makeRuntimeStoreWithWorkspaceSession( | ||
| makeWorkspaceSessionWithHeadlessTerminal() | ||
| ) | ||
| // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the fixture store implements every method these headless paths call; it is the shared runtime spec fixture. | ||
| return { runtime: new OrcaRuntimeService(runtimeStore as never), getSession } | ||
| } | ||
|
|
||
| describe('headless terminal rename publication', () => { | ||
| async function renamedRuntime() { | ||
| const { runtime } = headlessRuntime() | ||
| runtime.setPtyController({ | ||
| spawn: vi.fn(async () => ({ id: 'rename-pty' })), | ||
| write: () => true, | ||
| kill: () => true, | ||
| getForegroundProcess: async () => null | ||
| }) | ||
| const created = await runtime.createTerminal(`id:${TEST_WORKTREE_ID}`, { | ||
| tabId: 'host-tab', | ||
| leafId: HEADLESS_LEAF_ID, | ||
| activate: true | ||
| }) | ||
| return { runtime, handle: created.handle } | ||
| } | ||
|
|
||
| async function publishedSurface(runtime: OrcaRuntimeService) { | ||
| const listed = await runtime.listMobileSessionTabs(`id:${TEST_WORKTREE_ID}`) | ||
| const surface = listed.tabs.find( | ||
| (tab) => tab.type === 'terminal' && tab.parentTabId === 'host-tab' | ||
| ) | ||
| return surface?.type === 'terminal' ? surface : undefined | ||
| } | ||
|
|
||
| it('publishes the manual name on the live surface without a cold rehydrate', async () => { | ||
| const { runtime, handle } = await renamedRuntime() | ||
|
|
||
| await runtime.renameTerminal(handle, 'Codex · 绑定实现') | ||
|
|
||
| expect(await publishedSurface(runtime)).toMatchObject({ | ||
| title: 'Codex · 绑定实现', | ||
| customTitle: 'Codex · 绑定实现' | ||
| }) | ||
| }) | ||
|
|
||
| it('names a tab with no live pane by its tab id, and persists it', async () => { | ||
| const { runtime, getSession } = headlessRuntime() | ||
| runtime['hydrateHeadlessMobileSessionTabsFromWorkspaceSession'](TEST_WORKTREE_ID) | ||
|
|
||
| await runtime.setMobileSessionTabProps(`id:${TEST_WORKTREE_ID}`, { | ||
| tabId: 'host-tab', | ||
| customTitle: ' Sleeping ' | ||
| }) | ||
|
|
||
| // `title` too: phones and older desktops read only that. | ||
| expect(await publishedSurface(runtime)).toMatchObject({ | ||
| title: 'Sleeping', | ||
| customTitle: 'Sleeping' | ||
| }) | ||
| expect( | ||
| getSession().tabsByWorktree[TEST_WORKTREE_ID]!.find((tab) => tab.id === 'host-tab') | ||
| ?.customTitle | ||
| ).toBe('Sleeping') | ||
| }) | ||
|
|
||
| it('restores the saved title when a tab-id rename is cleared', async () => { | ||
| const { runtime } = headlessRuntime() | ||
| runtime['hydrateHeadlessMobileSessionTabsFromWorkspaceSession'](TEST_WORKTREE_ID) | ||
| const before = (await publishedSurface(runtime))?.title | ||
| const worktree = `id:${TEST_WORKTREE_ID}` | ||
| await runtime.setMobileSessionTabProps(worktree, { tabId: 'host-tab', customTitle: 'X' }) | ||
|
|
||
| await runtime.setMobileSessionTabProps(worktree, { tabId: 'host-tab', customTitle: null }) | ||
|
|
||
| expect(await publishedSurface(runtime)).toMatchObject({ title: before, customTitle: null }) | ||
| }) | ||
|
|
||
| it('names and clears a live pane through its tab id as terminal.rename does', async () => { | ||
| const { runtime, handle } = await renamedRuntime() | ||
| const worktree = `id:${TEST_WORKTREE_ID}` | ||
| await runtime.renameTerminal(handle, 'By handle') | ||
|
|
||
| await runtime.setMobileSessionTabProps(worktree, { tabId: 'host-tab', customTitle: 'By tab' }) | ||
| expect(await publishedSurface(runtime)).toMatchObject({ | ||
| title: 'By tab', | ||
| customTitle: 'By tab' | ||
| }) | ||
|
|
||
| await runtime.setMobileSessionTabProps(worktree, { tabId: 'host-tab', customTitle: null }) | ||
| const cleared = await publishedSurface(runtime) | ||
| expect(cleared?.customTitle).toBeNull() | ||
| expect(cleared?.title).not.toBe('By tab') | ||
| }) | ||
|
|
||
| it('drops a name set while the pane slept when its handle is reset', async () => { | ||
| const { runtime } = headlessRuntime() | ||
| runtime['hydrateHeadlessMobileSessionTabsFromWorkspaceSession'](TEST_WORKTREE_ID) | ||
| await runtime.setMobileSessionTabProps(`id:${TEST_WORKTREE_ID}`, { | ||
| tabId: 'host-tab', | ||
| customTitle: 'Asleep name' | ||
| }) | ||
| runtime.setPtyController({ | ||
| spawn: vi.fn(async () => ({ id: 'wake-pty' })), | ||
| write: () => true, | ||
| kill: () => true, | ||
| getForegroundProcess: async () => null | ||
| }) | ||
| const woken = await runtime.createTerminal(`id:${TEST_WORKTREE_ID}`, { | ||
| tabId: 'host-tab', | ||
| leafId: HEADLESS_LEAF_ID, | ||
| activate: true | ||
| }) | ||
|
|
||
| await runtime.renameTerminal(woken.handle, null) | ||
|
|
||
| const surface = await publishedSurface(runtime) | ||
| expect(surface?.customTitle).toBeNull() | ||
| expect(surface?.title).not.toBe('Asleep name') | ||
| }) | ||
|
|
||
| it('publishes a cleared name as null so clients drop theirs', async () => { | ||
| const { runtime, handle } = await renamedRuntime() | ||
| await runtime.renameTerminal(handle, 'Pinned') | ||
|
|
||
| await runtime.renameTerminal(handle, null) | ||
|
|
||
| expect(await publishedSurface(runtime)).toMatchObject({ customTitle: null }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
Publish the normalized
customTitleon the live-pane path, not the rawargs.customTitle.Line 293 normalizes the value: it trims it, and a blank value becomes
null. The live-pane path does not use the normalized value.liveHandles.length > 0, the conditional override on lines 318-323 does not apply....argsthen writes the untrimmedargs.customTitleinto the snapshot. This overwrites the trimmed value thatrenameTerminalpublished." foo ", the host publishescustomTitle: " foo "." ", the host publishes" "instead ofnull. Clients then never see the name as cleared.When a notifier with
renameTerminalexists,renameTerminalskips its own snapshot write. This spread is then the only thing that publishescustomTitle, so the raw value always reaches clients.Always spread the normalized value. Keep the
titleoverride for paneless tabs only.🐛 Proposed fix
📝 Committable suggestion