Skip to content

The agent that grows with you

test(hermes-ink): trim combining-grapheme pre-clear tests to two invariants

kshitijk4poorc1648af8f77b
diff --git a/ui-tui/packages/hermes-ink/src/ink/log-update.test.ts b/ui-tui/packages/hermes-ink/src/ink/log-update.test.ts
index 2b5179fad18..bb94df6000f 100644
--- a/ui-tui/packages/hermes-ink/src/ink/log-update.test.ts
+++ b/ui-tui/packages/hermes-ink/src/ink/log-update.test.ts
@@ -92,70 +92,6 @@ describe('LogUpdate.render diff contract', () => {
expect(diff.some(part => part.type === 'stdout' && part.content === ' ')).toBe(false)
})
- it('does not clear before painting a grapheme into an empty cell', () => {
- const prev = mkScreen(4, 1)
- const next = mkScreen(4, 1)
-
- setCellAt(next, 1, 0, {
- char: 'ร้',
- styleId: stylePool.none,
- width: CellWidth.Narrow,
- hyperlink: undefined
- })
- next.damage = { x: 1, y: 0, width: 1, height: 1 }
-
- const log = new LogUpdate({ isTTY: true, stylePool })
- const diff = log.render(mkFrame(prev, 4, 1), mkFrame(next, 4, 1), true, false)
-
- expect(stdoutOnly(diff)).toBe('ร้')
- expect(diff.some(part => part.type === 'cursorTo')).toBe(false)
- })
-
- it('does not clear when only a grapheme cell style changes', () => {
- const prev = mkScreen(4, 1)
- const next = mkScreen(4, 1)
- const style = stylePool.intern([{ code: '\u001b[32m', endCode: '\u001b[39m' }])
-
- setCellAt(prev, 1, 0, { char: 'ร้', styleId: stylePool.none, width: CellWidth.Narrow, hyperlink: undefined })
- setCellAt(next, 1, 0, { char: 'ร้', styleId: style, width: CellWidth.Narrow, hyperlink: undefined })
- next.damage = { x: 1, y: 0, width: 1, height: 1 }
-
- const log = new LogUpdate({ isTTY: true, stylePool })
- const diff = log.render(mkFrame(prev, 4, 1), mkFrame(next, 4, 1), true, false)
-
- expect(stdoutOnly(diff)).toBe('ร้')
- expect(diff.some(part => part.type === 'cursorTo')).toBe(false)
- })
-
- it('resets active hyperlink and style before pre-clearing a grapheme cell', () => {
- const prev = mkScreen(4, 1)
- const next = mkScreen(4, 1)
- const oldStyle = stylePool.intern([{ code: '\u001b[31m', endCode: '\u001b[39m' }])
- const newStyle = stylePool.intern([{ code: '\u001b[32m', endCode: '\u001b[39m' }])
-
- setCellAt(prev, 0, 0, { char: 'x', styleId: stylePool.none, width: CellWidth.Narrow, hyperlink: undefined })
- setCellAt(next, 0, 0, { char: 'y', styleId: oldStyle, width: CellWidth.Narrow, hyperlink: 'https://old.example' })
- setCellAt(prev, 1, 0, { char: 'ร้', styleId: oldStyle, width: CellWidth.Narrow, hyperlink: 'https://old.example' })
- setCellAt(next, 1, 0, { char: 'ร', styleId: newStyle, width: CellWidth.Narrow, hyperlink: undefined })
- next.damage = { x: 0, y: 0, width: 2, height: 1 }
-
- const log = new LogUpdate({ isTTY: true, stylePool })
- const diff = log.render(mkFrame(prev, 4, 1), mkFrame(next, 4, 1), true, false)
- const writeIndex = diff.findIndex(part => part.type === 'stdout' && part.content === 'ร')
- const clearIndex = diff.findIndex(part => part.type === 'stdout' && part.content === ' ')
- const resetStyle = stylePool.transition(oldStyle, stylePool.none)
- const styleResetIndex = diff.findIndex(part => part.type === 'styleStr' && part.str === resetStyle)
- const closeIndex = diff.findIndex(part => part.type === 'hyperlink' && part.uri === '')
-
- expect(writeIndex).toBeGreaterThan(clearIndex)
- expect(clearIndex).toBeGreaterThan(-1)
- expect(styleResetIndex).toBeGreaterThan(-1)
- expect(styleResetIndex).toBeLessThan(clearIndex)
- expect(closeIndex).toBeGreaterThan(-1)
- expect(closeIndex).toBeLessThan(clearIndex)
- expect(diff.slice(clearIndex, writeIndex)).toContainEqual({ type: 'cursorTo', col: 2 })
- })
-
it('emits only changed cells when most rows match', () => {
const w = 20
const h = 4