Skip to content

[Performance] loadEntries(limit) still parses the entire history file #206

Description

@404-Page-Found

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions