github / github/app

Long-lived sessions become unloadable: events.jsonl never capped/rotated, replayed in full on open

Offen
#1,487 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Bugs
Vorherrschende Sprache
Keine Sprachdaten
Sterne
2.1k
Forks
153
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Summary
A long-lived CLI chat session becomes unloadable once its `events.jsonl` grows large. The loader appears to read/replay the **entire** event log on open, so a heavily-reused session eventually fails to load. Reuse + pinning is the intended workflow, so this hits the sessions people care about most.

## Impact
- A reused session ran for weeks and became impossible to open.
- `events.jsonl` reached ~**460 MB / ~147k lines** across **544 compactions**.
- On open the app loops: load → fail → append `sessionEnd` hooks → repeat, so the file keeps growing during failed loads.
- User-visible: "can't get it to load," accumulated context appears lost.

## Root cause
- `events.jsonl` is append-only and is **never rotated or capped**.
- Compaction shrinks the model context but does not shrink the on-disk log.
- It is not a few giant lines: lines >200 KB total only ~23 MB (largest ~775 KB). The remaining ~435 MB is the sheer count of ordinary events, so the loader must not depend on full-log size.

## Repro
1. Reuse one session for many days (hundreds of compactions).
2. Let `events.jsonl` exceed a few hundred MB.
3. Reopen — load hangs/fails; file grows on each retry.

## Workaround (reversible)
Trim `events.jsonl` to the last few compaction cycles (keep `session.start` + tail): ~35 MB / ~11.6k lines loaded fine, full log preserved as backup.

## Proposed fixes
1. **Tail-load on open** from the latest compaction boundary; don't replay the whole file.
2. **Cap + rotate** `events.jsonl` (roll past a threshold; keep N recent cycles; archive the rest).
3. **Stop the failure loop** — don't append `sessionEnd` on failed load; expire/release the stale `inuse..lock`.
4. Optional: keep heavy assets out of the event stream (store as files referenced by path).

## Acceptance
A session reused for weeks (hundreds of compactions) opens reliably without manual trimming.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by locating the session loader and the event-log handling for events.jsonl, then trace compaction boundaries, sessionEnd hooks, and stale inuse..lock handling. Reproduce the large-log failure if possible and use the stated acceptance condition—weeks of reuse and hundreds of compactions must reopen reliably without manual trimming—as the completion check.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Bereich
cli, desktop
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.