import { mkdtempSync, readFileSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import { writeActiveSessionFile } from '../app/useSessionLifecycle.js' describe('writeActiveSessionFile', () => { let dir = '' afterEach(() => { if (dir) { rmSync(dir, { force: true, recursive: true }) dir = '' } }) it('writes the actual resumed session id for the shell exit summary', () => { dir = mkdtempSync(join(tmpdir(), 'hermes-tui-active-')) const path = join(dir, 'active.json') writeActiveSessionFile('actual_session', path) expect(JSON.parse(readFileSync(path, 'utf8'))).toEqual({ session_id: 'actual_session' }) }) })