Commit Graph

8 Commits

Author SHA1 Message Date
roboomp 9ae089d71b fix(session): repaired torn JSONL appends
Rolled partial file appends back to their pre-write size and marked malformed resumed sessions for an atomic rewrite.

Retried transient persistence failures from in-memory state and surfaced the first failure in the interactive TUI.

Fixes #8596
2026-08-15 00:34:41 +00:00
Kyle McCleary 8e5f619502 fix(coding-agent): harden Agent Hub lifecycle and persistence 2026-08-04 16:29:15 -07:00
Paolo Mazzitti 3c7233af44 fix(coding-agent): scope advisor cost to active session 2026-07-29 07:18:48 +00:00
can1357 0823892295 fix(coding-agent): repaired type errors from merge sweep
- Restored CustomInputRow.priority field dropped in 3b80dc01d ask row budgeting.
- Narrowed dereferenced schema properties via isRecord in yield-assembly and output-schema-validator instead of untyped object access.
- Renamed stale advisorReadOnlyTools to advisorTools in advisor parity test.
- Narrowed AgentMessage content access in session-loader-stream test.
- Reformatted browser-schema test to satisfy biome.
2026-07-01 23:49:32 +02:00
can1357 5f1ed0fcde chore: reformat 2026-07-01 23:14:36 +02:00
can1357 38a6821729 test(coding-agent): avoid unchecked session loader casts 2026-07-01 21:47:54 +02:00
oldschoola 4c4cc8857a fix(coding-agent): preserve multibyte UTF-8 across stream chunks in session loader
Address review: the per-chunk Buffer.from(chunk).toString("utf8") string concat corrupted multibyte sequences (e.g. ✓, emoji) that straddled a chunk boundary — silent data loss in exactly the ≥8MiB long sessions that take this path. Keep the buffer as a Uint8Array and pass it directly to Bun.JSONL.parseChunk (it accepts typed arrays and parses UTF-8 natively), so no decoding happens until a complete record is parsed. Only the title-slot first line is decoded, and only after the full line (up to its '\n') is buffered, so it is a complete UTF-8 sequence.

Also: drop the defensive 'read || 0' (read is number per typings); add a multibyte multi-chunk parity test (>128KiB fixture) that would have caught the bug.
2026-06-29 18:28:39 -07:00
oldschoola 66d3676d25 perf(coding-agent): speed up large-session resume with Bun.JSONL
The ≥8MiB session-load path (loadEntriesFromFileStream) used node:readline + per-line JSON.parse, while the common (<8MiB) path already used Bun's native Bun.JSONL. The large-session path is now the lone outlier getting the slower parser.

Rewrite loadEntriesFromFileStream to a lenient streaming Bun.JSONL.parseChunk loop: stream the file via Bun.file().stream() into a bounded buffer (memory guard preserved — the file is never fully loaded, which is why the 8MiB threshold exists), skip malformed records to the next newline instead of throwing, peel/fold the non-JSON first-line title slot, terminate a trailing newline-less record, and keep isEnoent→empty. Removed the now-unused node:fs + node:readline imports.

Measured ~9.5ms → ~6.0ms (-37%) loading a 10MiB valid session; the remaining cost is I/O + native parse (floor).

Correctness: new session-loader-stream.test.ts asserts the stream path produces byte-identical entries + titleSlot to parseSessionContent (the common-path parser) across title-slot / blank / malformed / no-trailing-newline / missing-file cases.
2026-06-29 18:28:39 -07:00