Files
orca/src/shared/command-code-output-retention.test.ts
T
d04b05b5c8 Detach retained CI and terminal tails from oversized strings (#20960)
* fix(memory): detach retained CI and terminal tails from oversized strings

* fix(terminal): detach retained error and reattach string slices

* fix(terminal): release oversized recent-output backing strings

* fix(terminal): release backing strings held by PTY detectors

* fix(memory): own bounded Claude background task labels

* fix: detach retained terminal mode scan tails

* fix: own retained plugin worker output strings

* fix: own incomplete OSC 133 carry strings

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
2026-09-17 20:34:19 -07:00

27 lines
1001 B
TypeScript

import { describe, expect, it } from 'vitest'
import { createCommandCodeOutputStatusDetector } from './command-code-output-status'
function heapAfterGc(): number {
if (!('gc' in globalThis) || typeof globalThis.gc !== 'function') {
throw new Error('The test runner must enable --expose-gc')
}
globalThis.gc()
globalThis.gc()
return process.memoryUsage().heapUsed
}
describe('Command Code output retention', () => {
it('keeps small boundary carries without pinning oversized output on ordinary panes', () => {
const before = heapAfterGc()
const detectors = Array.from({ length: 8 }, (_value, index) => {
const detector = createCommandCodeOutputStatusDetector({ onWorking: () => {} })
detector.observe(`${index}:${'x'.repeat(4 * 1024 * 1024)}`)
return detector
})
expect(heapAfterGc() - before).toBeLessThan(2 * 1024 * 1024)
for (const detector of detectors) {
expect(detector.observe('\nordinary shell output\n')).toBe(false)
}
})
})