mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
- profile-state restart: runNow now returns the saved pending row (#38217) - codex account switch: click the backdrop clear of the sidebar seam strip (#38288) - claude sidebar agent view: drop the removed subagent indicator check (#34558) - IME preedit continuity: refit after changing the font, like font zoom - agent send picker: bind local fixture panes to a live PTY so reattach keeps them Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
import { expect, test } from './helpers/orca-app'
|
||
import { closeTerminalImePaneArena, openTerminalImePaneArena } from './terminal-ime-pane-arena'
|
||
import { setImeComposition } from './terminal-ime-cdp-composition'
|
||
import { writeToActiveTerminal } from './terminal-ime-midline-occlusion-probe'
|
||
|
||
test('keeps the CJK prefix in place across mixed text and the layout budget', async ({
|
||
orcaPage
|
||
}, testInfo) => {
|
||
const arena = await openTerminalImePaneArena(orcaPage)
|
||
let completed = false
|
||
try {
|
||
await orcaPage.evaluate(() => {
|
||
const state = window.__store!.getState()
|
||
const pane = window.__paneManagers!.get(state.activeTabId!)!.getActivePane()!
|
||
pane.terminal.options.fontSize = 13
|
||
pane.terminal.options.fontFamily = 'monospace'
|
||
// Why: like font zoom, refit now; a later refit changes the cell width and shifts the baseline.
|
||
pane.fitAddon.fit()
|
||
})
|
||
await writeToActiveTerminal(orcaPage, '\x1b[2J\x1b[H')
|
||
const prefix = 'あ'.repeat(32)
|
||
let initial: number[] | undefined
|
||
for (const suffix of [
|
||
'',
|
||
'a',
|
||
'',
|
||
'😀',
|
||
'سلام',
|
||
'क्षि',
|
||
' あ',
|
||
...[125, 126, 127, 128, 129, 130, 256].map((count) => 'aあ'.repeat(count)),
|
||
`${'aあ'.repeat(256)}\u3099`,
|
||
'',
|
||
'a'
|
||
]) {
|
||
await setImeComposition(arena.session, prefix + suffix)
|
||
const preedit = orcaPage.locator('.composition-view.active .xterm-composition-preedit')
|
||
await expect(preedit).toHaveText(`${prefix + suffix}`)
|
||
const sample = await preedit.evaluate((element) => {
|
||
const bounds = element.getBoundingClientRect()
|
||
const starts: number[] = []
|
||
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT)
|
||
let node: Node | null
|
||
while ((node = walker.nextNode()) && starts.length < 32) {
|
||
const text = node.textContent ?? ''
|
||
for (let offset = 0; offset < text.length && starts.length < 32; offset++) {
|
||
if (text[offset] !== 'あ') {
|
||
continue
|
||
}
|
||
const range = document.createRange()
|
||
range.setStart(node, offset)
|
||
range.setEnd(node, offset + 1)
|
||
starts.push(range.getBoundingClientRect().left - bounds.left)
|
||
}
|
||
}
|
||
const caret = element.parentElement!.querySelector('.xterm-composition-caret')!
|
||
return {
|
||
starts,
|
||
width: bounds.width,
|
||
caretRight: caret.getBoundingClientRect().right - bounds.left
|
||
}
|
||
})
|
||
initial ??= sample.starts
|
||
expect(sample.starts).toHaveLength(32)
|
||
for (const [index, start] of sample.starts.entries()) {
|
||
expect(start).toBeCloseTo(initial[index], 1)
|
||
}
|
||
expect(sample.caretRight).toBeCloseTo(sample.width, 1)
|
||
}
|
||
await setImeComposition(arena.session, '')
|
||
completed = true
|
||
} finally {
|
||
await closeTerminalImePaneArena(arena, testInfo, 'preedit-continuity', !completed)
|
||
}
|
||
})
|