test(tui): direct unit tests for mergeStartupHistory

DE
8d ago
+49-0

Issue for this PR

Closes #1826

Part of #1304 (item 8).

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds direct unit tests for mergeStartupHistory() in packages/tui/src/prompt/history.tsx, which was only covered indirectly by the full-mount test in history-startup-race.test.tsx. Test-only change; no production code is touched.

The tests in packages/tui/test/prompt/history.test.ts pin the invariants a normal append() keeps:

  • disk entries come before entries appended in memory during the read
  • a duplicate straddling the disk/in-memory boundary is collapsed
  • consecutive duplicates within either half are collapsed
  • the result is capped at MAX_HISTORY_ENTRIES, keeping the newest entries
  • the inputs are not mutated and a new array is returned

How did you verify your code works?

  • bun test test/prompt/history.test.ts in packages/tui: 11 pass, 0 fail.
  • packages/tui typecheck (tsgo --noEmit): 0 errors.

Cost side effects

None. Test-only change.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Devin Review


Summary by cubic

Adds direct unit tests for mergeStartupHistory() in packages/tui so the merge logic no longer relies solely on full-mount integration coverage. Closes #1826. Test-only change; no production code is touched.

The tests pin the invariants a normal append() keeps:

  • disk entries come before entries appended in memory during the read
  • duplicates on the disk/memory boundary and consecutive duplicates within each half are collapsed
  • results are capped at MAX_HISTORY_ENTRIES, keeping the newest entries
  • inputs are not mutated and a new array is returned