github / github/app

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

未关闭
#1,487 1 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
Bugs
主要语言
没有语言数据
星标
2.1k
派生
153
PR 合并指标
30 天内没有已合并 PR

描述

## 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.

贡献指南

打开贡献指南

调研方向

首先定位 session loader 以及对 events.jsonl 的事件日志处理,然后追踪压缩边界、sessionEnd hooks 和 stale inuse .lock 的处理。如果可能,重现大日志失败,并将所述验收条件——经过数周的重复使用和数百次压缩后,必须能够在不手动裁剪的情况下可靠地重新打开——作为完成检查。

由索引模型根据 Issue 内容生成。

评估

领域
cli, desktop
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。