Files
orca/src/shared/worktree-card-properties.test.ts
T
NeilandOrca 8f5a45401f fix(terminal): stop switch bold flash and Windows lag (#10692)
* fix(terminal): stop bold flash on worktree switch

Worktree hide disposes WebGL and falls back to xterm's DOM renderer.
On reveal, resume ran after paint and flushed backlog against DOM first,
so the first frame used heavier CSS-AA glyphs before WebGL settled.

Resume in useLayoutEffect and reattach WebGL before backlog flush so the
first painted frame stays on the GPU path. No cold-park policy change.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): fit WebGL grid before backlog flush on resume

Adversarial review: resume-before-flush alone wrote TUI backlog onto the
transient DOM↔WebGL one-column-off metrics window. Order is now
resume → fitAllRevealedPanes → flush on heavy reveal and window wake.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): latch viewport intent before WebGL wake resume

Adversarial review: wake path synced intents after resume/fit, which can
re-latch a pinned viewport as followOutput. Capture before reattach and
drop the post-resume re-sync on heavy reveal (outer path already latched).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): complete visibility bookkeeping before PaneManager exists

useLayoutEffect runs before the passive lifecycle creates PaneManager, so
the mount-visible path never set hasCompletedVisibleResume. The first
intra-worktree hide then wrongly suspended WebGL. Bookkeep completion
even when managerRef is still null (extracted helper for max-lines).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): re-sync pin geometry after resume backlog flush

Keep the pre-resume intent latch (reattach must not re-latch pins as
followOutput), then re-sync after flush with preservePinnedAtBottom so
scrollback trim updates absolute pin lines before enforce.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): drop same-tick post-flush intent re-sync

flushTerminalOutput only queues terminal.write and returns before parse, so
a same-tick re-sync read pre-parse resume/fit geometry and could overwrite
pre-resume pins. Keep pre-resume latch + enforce only.

Co-authored-by: Orca <help@stably.ai>

* fix(test): expect default worktree card properties to include cli

#10712 added 'cli' to DEFAULT_WORKTREE_CARD_PROPERTIES, but the fresh
default-profile assertion still omitted it and fails verify.

Co-authored-by: Orca <help@stably.ai>

* perf(terminal): retain Windows WebGL across worktree hides

* perf(terminal): bound retained WebGL contexts

* fix(terminal): harden retained WebGL lifecycle

* fix(terminal): preserve healthy WebGL on wake

* fix(terminal): preserve reveal recovery ordering

---------

Co-authored-by: Orca <help@stably.ai>
2026-07-26 05:29:38 -07:00

75 lines
2.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
COMPACT_WORKTREE_CARD_PROPERTIES,
DEFAULT_WORKTREE_CARD_PROPERTIES,
TASK_WORKTREE_CARD_PROPERTIES,
getWorktreeCardModeProperties,
getWorktreeCardModeUpdates,
isDefaultedCompactWorktreeCardProperties,
normalizeWorktreeCardProperties
} from './worktree-card-properties'
describe('worktree card properties', () => {
it('defines Default with inline agents and without branch', () => {
const props = getWorktreeCardModeProperties('Default')
expect(props).toContain('inline-agents')
expect(props).not.toContain('branch')
expect(props).toContain('pr')
expect(props).toContain('automation')
expect(props).toContain('cli')
expect(props).toEqual(DEFAULT_WORKTREE_CARD_PROPERTIES)
})
it('defines Compact as the status-only quiet preset', () => {
const props = getWorktreeCardModeProperties('Compact')
expect(props).toEqual(['status'])
expect(props).toEqual(COMPACT_WORKTREE_CARD_PROPERTIES)
expect(props).not.toContain('inline-agents')
expect(props).not.toContain('issue')
expect(props).not.toContain('linear-issue')
expect(props).not.toContain('comment')
expect(props).not.toContain('ports')
expect(props).not.toContain('branch')
expect(props).not.toContain('pr')
expect(props).not.toContain('automation')
})
it('keeps status enabled in both presets', () => {
expect(getWorktreeCardModeProperties('Default')).toEqual(expect.arrayContaining(['status']))
expect(getWorktreeCardModeProperties('Compact')).toEqual(expect.arrayContaining(['status']))
})
it('keeps provider-specific task metadata together in Default mode', () => {
expect(getWorktreeCardModeProperties('Default')).toEqual(
expect.arrayContaining(TASK_WORKTREE_CARD_PROPERTIES)
)
})
it('normalizes fixed and legacy properties while preserving selected properties', () => {
expect(normalizeWorktreeCardProperties(['ci', 'branch', 'pr', 'automation', 'unread'])).toEqual(
['status', 'unread', 'ci', 'branch', 'pr', 'automation']
)
})
it('returns combined mode update payloads', () => {
expect(getWorktreeCardModeUpdates('Compact')).toEqual({
settings: { compactWorktreeCards: true },
ui: {
worktreeCardProperties: getWorktreeCardModeProperties('Compact'),
_worktreeCardModeDefaulted: true
}
})
})
it('recognizes only exact defaulted Compact presets', () => {
expect(isDefaultedCompactWorktreeCardProperties(['status'])).toBe(true)
expect(isDefaultedCompactWorktreeCardProperties(['status', 'unread'])).toBe(true)
expect(isDefaultedCompactWorktreeCardProperties(['status', 'automation'])).toBe(true)
expect(isDefaultedCompactWorktreeCardProperties(['status', 'unread', 'automation'])).toBe(true)
expect(isDefaultedCompactWorktreeCardProperties(['automation', 'status'])).toBe(false)
expect(isDefaultedCompactWorktreeCardProperties(['status', 'automation', 'pr'])).toBe(false)
})
})