From 5d41ad710cc7b6276b33dcb18b74a1c9dfd9586a Mon Sep 17 00:00:00 2001 From: ethernet Date: Fri, 3 Jul 2026 20:10:24 -0400 Subject: [PATCH] fix(js): fix long-time broken tests ( --- ui-tui/package.json | 5 +++-- ui-tui/src/__tests__/cursorDriftRegression.test.ts | 2 +- ui-tui/src/__tests__/statusRule.test.ts | 11 ++++------- ui-tui/src/__tests__/virtualHeights.test.ts | 9 ++++++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ui-tui/package.json b/ui-tui/package.json index e370624c3c8b..7c83ad71e6b3 100644 --- a/ui-tui/package.json +++ b/ui-tui/package.json @@ -4,15 +4,16 @@ "private": true, "type": "module", "scripts": { - "dev": "npm run build --prefix packages/hermes-ink && tsx --watch src/entry.tsx", + "dev": "npm run build:ink && tsx --watch src/entry.tsx", "start": "tsx src/entry.tsx", "build": "node scripts/build.mjs", + "build:ink": "npm run build --prefix packages/hermes-ink", "typecheck": "tsc --noEmit -p tsconfig.json", "lint": "eslint src/ packages/", "lint:fix": "eslint src/ packages/ --fix", "fmt": "prettier --write 'src/**/*.{ts,tsx}' 'packages/**/*.{ts,tsx}'", "fix": "npm run lint:fix && npm run fmt", - "check": "npm run typecheck && npm run test", + "check": "npm run build:ink && npm run typecheck && npm run test", "test": "vitest run", "test:watch": "vitest" }, diff --git a/ui-tui/src/__tests__/cursorDriftRegression.test.ts b/ui-tui/src/__tests__/cursorDriftRegression.test.ts index 3f9082dcefcd..87cee33fe8c9 100644 --- a/ui-tui/src/__tests__/cursorDriftRegression.test.ts +++ b/ui-tui/src/__tests__/cursorDriftRegression.test.ts @@ -68,7 +68,7 @@ describe('cursor-drift regression — composer cursorLayout matches Ink renderin ).toEqual(expected) } } - }) + }, 10_000) it('keeps cursor on the same row when text exactly fills the terminal width', () => { // wrap-ansi does NOT push exact-fill text onto a phantom next line. diff --git a/ui-tui/src/__tests__/statusRule.test.ts b/ui-tui/src/__tests__/statusRule.test.ts index 6af617a973dc..9b8224b40789 100644 --- a/ui-tui/src/__tests__/statusRule.test.ts +++ b/ui-tui/src/__tests__/statusRule.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { busyIndicatorWidth, statusBarSegments, statusRuleWidths } from '../components/appChrome.js' +import { busyIndicatorWidth, StatusBarSegments, statusBarSegments, statusRuleWidths } from '../components/appChrome.js' describe('statusRuleWidths', () => { it('keeps the status rule within the terminal width', () => { @@ -69,8 +69,7 @@ describe('statusBarSegments', () => { voice: true, bg: true, subagents: true, - cost: true - }) + } satisfies StatusBarSegments) }) it('collapses the context bar to a token count on narrow terminals', () => { @@ -79,19 +78,17 @@ describe('statusBarSegments', () => { expect(s.compactCtx).toBe(true) expect(s.bar).toBe(false) expect(s.duration).toBe(false) - expect(s.cost).toBe(false) }) it('sheds tail segments in priority order as the terminal narrows', () => { - // cost is the first to go, the context bar the last of the tail. + // the context bar is the last of the tail to go. const order: (keyof ReturnType)[] = [ 'bar', 'duration', 'compressions', 'voice', 'bg', - 'subagents', - 'cost' + 'subagents' ] let prevCount = Infinity diff --git a/ui-tui/src/__tests__/virtualHeights.test.ts b/ui-tui/src/__tests__/virtualHeights.test.ts index 9819a7214da9..17cd32fec8d3 100644 --- a/ui-tui/src/__tests__/virtualHeights.test.ts +++ b/ui-tui/src/__tests__/virtualHeights.test.ts @@ -18,10 +18,13 @@ describe('virtual height estimates', () => { }) it('uses compound user prompt width when estimating user message wrapping', () => { - const msg: Msg = { role: 'user', text: 'x'.repeat(21) } + // cols must clear the 20-col body-width floor for both prompts (gutter + + // horizontalReserve=4) so the wider 'Ψ >' prompt actually narrows the + // body enough to wrap an extra line vs the single-cell '❯' prompt. + const msg: Msg = { role: 'user', text: 'x'.repeat(23) } - expect(estimatedMsgHeight(msg, 26, { compact: false, details: false, userPrompt: '❯' })).toBe(3) - expect(estimatedMsgHeight(msg, 26, { compact: false, details: false, userPrompt: 'Ψ >' })).toBe(4) + expect(estimatedMsgHeight(msg, 30, { compact: false, details: false, userPrompt: '❯' })).toBe(3) + expect(estimatedMsgHeight(msg, 30, { compact: false, details: false, userPrompt: 'Ψ >' })).toBe(4) }) it('adds one row for a group-boundary lead gap', () => {