mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 08:03:58 +00:00
Query the `worktree.show` RPC endpoint on screen focus and poll every 3 seconds to retrieve up-to-date worktree metadata. This ensures that task-generated names and subsequent displayName updates are reflected, rather than relying solely on the initial route parameter entry hint.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { getLiveWorktreeDisplayName } from './worktree-display-name'
|
|
|
|
describe('getLiveWorktreeDisplayName', () => {
|
|
it('uses the host-list display name for the current worktree', () => {
|
|
expect(
|
|
getLiveWorktreeDisplayName(
|
|
[
|
|
{ worktreeId: 'wt-1', displayName: 'Old' },
|
|
{ worktreeId: 'wt-2', displayName: 'Auto Generated Name' }
|
|
],
|
|
'wt-2'
|
|
)
|
|
).toBe('Auto Generated Name')
|
|
})
|
|
|
|
it('matches worktree.show payloads keyed by id', () => {
|
|
expect(getLiveWorktreeDisplayName([{ id: 'wt-1', displayName: 'Settled Name' }], 'wt-1')).toBe(
|
|
'Settled Name'
|
|
)
|
|
})
|
|
|
|
it('falls back to repo only when the display name is blank', () => {
|
|
expect(
|
|
getLiveWorktreeDisplayName([{ worktreeId: 'wt-1', displayName: ' ', repo: 'orca' }], 'wt-1')
|
|
).toBe('orca')
|
|
})
|
|
|
|
it('ignores snapshots that do not contain the current worktree', () => {
|
|
expect(getLiveWorktreeDisplayName([{ worktreeId: 'wt-1', displayName: 'Other' }], 'wt-2')).toBe(
|
|
null
|
|
)
|
|
})
|
|
})
|