Skip to content

test(tui): cover memoryMonitor level transitions - #22297

Closed
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:tests/tui-memory-monitor
Closed

wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:tests/tui-memory-monitor

Conversation

@wesleysimplicio

@wesleysimplicio wesleysimplicio commented May 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

test(tui): cover memoryMonitor level transitions

Root cause

The detailed rationale from the original PR body is preserved below. This template update keeps the review structure consistent with #29640.

Fix

Why this shape

This shape mirrors #29640 so reviewers can quickly compare scope, root cause, fix, tests, and related context without having to decode a custom PR description.

Tests

  • Veja a descrição original preservada abaixo para detalhes de validação, testes e notas de verificação.
Original body

Related PRs / issues

  • Original body preserved below for full context.
Original body

Summary

test(tui): cover memoryMonitor level transitions

What Changed

  • Standardized this PR body to the current Hermes Turbo template.
  • Preserved the original detailed description below for reference.

Fluxo

A mudança continua seguindo o fluxo original descrito na seção preservada abaixo, sem ampliar o escopo funcional deste PR.

Visão

A padronização melhora a revisão, reduz ruído e evita deriva de formatação entre PRs abertos.

Test Plan

  • Veja a descrição original preservada abaixo para detalhes de validação, testes e notas de verificação.
Original body

Summary

Add 8 vitest cases for the previously untested startMemoryMonitor in ui-tui/src/lib/memoryMonitor.ts.

Coverage

  • no callbacks fire while heap stays in normal range
  • onHigh fires exactly once when heap crosses high threshold (dedup)
  • onCritical fires with auto-critical heap dump trigger
  • evictInkCaches receives 'all' on critical level
  • snapshot passed to callbacks carries { level, heapUsed, rss }
  • dedup state clears when level returns to normal, refires on next high
  • custom highBytes/criticalBytes thresholds respected
  • returned stop function cancels the interval

Test plan

  • npx vitest run src/__tests__/memoryMonitor.test.ts (8/8 passed)
  • npx vitest run (662/662 across 63 files)

Generated by Hermes Turbo


Generated by Hermes Turbo

Add 8 vitest cases for startMemoryMonitor:
- no callbacks while heap stays in normal range
- onHigh fires once on high threshold cross
- onCritical fires with auto-critical trigger
- evictInkCaches passes 'all' on critical
- snapshot carries level/heapUsed/rss
- dedup clears on normal, refires on next high
- custom thresholds respected
- stop() cancels interval
Copilot AI review requested due to automatic review settings May 9, 2026 05:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds dedicated Vitest coverage for startMemoryMonitor in the TUI layer, validating that memory-level transitions (normal/high/critical) drive the expected callbacks and side effects (heap dumps + Ink cache eviction) and that monitoring can be cleanly stopped.

Changes:

  • Adds 8 new unit tests covering level transitions, dedup behavior, snapshot contents, custom thresholds, and stop/interval cancellation.
  • Mocks heap-dump and Ink cache eviction dependencies to assert triggers/arguments deterministically.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alt-glitch alt-glitch added type/test Test coverage or test infrastructure P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels May 9, 2026
@wesleysimplicio

Copy link
Copy Markdown
Contributor Author

Closing non-fix PR as requested — mantendo apenas PRs de fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants