Description
loadEntries(limit) returns only the most recent entries, but it still reads and parses the full JSONL history file before slicing down to the requested amount.
Location
src/history/store.ts:19
src/history/store.ts:33
Problematic code
const raw = await readFile(historyPath, 'utf-8');
const lines = raw
.split('\n')
.map((line, index) => ({ line, lineNumber: index + 1 }))
.filter(({ line }) => line.trim().length > 0)
.reverse();
Suggested fix
Keep the current behavior but avoid full-file parsing when a small limit is requested. Even a simpler incremental approach that scans from the end of the file would help.
Impact
As history grows, commands like history and style-profile generation can do more work than necessary.
Description
loadEntries(limit)returns only the most recent entries, but it still reads and parses the full JSONL history file before slicing down to the requested amount.Location
src/history/store.ts:19src/history/store.ts:33Problematic code
Suggested fix
Keep the current behavior but avoid full-file parsing when a small
limitis requested. Even a simpler incremental approach that scans from the end of the file would help.Impact
As history grows, commands like
historyand style-profile generation can do more work than necessary.