Repository navigation
Description
Summary
Archive Management's archived list becomes slow when an archived session id no longer has a
session storage directory ("dangling" id). Every such id costs a filesystem round trip on every
/state request, and the id cannot be removed through the plugin, so it stays forever.
Environment
dsh-archived-chats2.0.8- DSH host 0.2.2-rc.5 (Windows 11)
- Registry:
~/.dsh/storages/workspace.json→global.archivedSessionIds
Observed
GET /plugins/dsh-archived-chats/state, same host, no other change:
| archived ids | session dirs present | GET /state |
|---|---|---|
| 783 | 103 | 8.6 / 8.8 / 9.0 / 9.4 / 10.3 s |
| 105 | 105 | 75 ms (228 ms cold) |
While the dangling ids were present, the settings page stayed on state.loading ("加载中…") and
looked hung; every reopen restarted another ~9 s scan (the client also refetches on window focus).
Rows for dangling ids come back as title: null, createdAt: null.
/state is otherwise healthy: /stats 66 ms, /unarchived 102 ms on the same host.
Why they cannot be cleaned from the plugin
POST /plugins/dsh-archived-chats/unarchive-all answers for such an id:
503 { "error": "session-reachability-unavailable", "reason": "session-header-unavailable" }So there is no supported way to drop them; the only fix we found was editing
global.archivedSessionIds by hand while the host was stopped (the host rewrites that file from
memory on exit, so it has to be done before start).
Cheap fix suggestions
listArchived()already buildsheaderByIdfrompersistence.list()before the loop. For an id
with no header and no live session,continueinstead of callingreadTitle(id)— that alone
removes the whole dangling cost.- The title read is serial (
awaitinside afor); a small concurrency cap (e.g. 8) would also
cover the non-dangling case, since ~1000 archived chats already costs seconds with 0 dangling ids. - A negative cache (id → missing) keeps the steady state cheap.
- A supported cleanup path for entries whose session file is gone would stop the archive set from
drifting into an unmaintainable state.
How dangling ids can appear (not only by hand)
Session directories can disappear via manual cleanup, session-store/profile migration, backup
restore, AV quarantine or a torn log — none of which removes the id from the persisted archive set.
Happy to test a patch or share more timing data.
Activity
Ultroncn commentedon Nov 30, 2026
Thanks for the timings and the offer to test. I reproduced the repeated reads on DSH 0.2.2-rc.5 and released a fix in 2.0.9. With 103 stored chats and 680 missing IDs, refreshing Archived now made zero attempts to open the missing logs on my Mac.
After updating, open Archived → More archive actions → Remove missing chat entries. It rechecks each entry and clears only the archive markers for sessions the Host confirms are missing. In my test, all 103 stored chats remained. You can leave the missing entries in place and still get the loading fix.
If you still have the original dataset, I’d be interested in the new loading time on Windows 11.
xinming-chenniang commentedon Dec 1, 2026
补一份 Windows 上的数据,分两部分:悬空 id 那条确实修好了,但冷启动还有一个独立的 O(总日志字节) 成本。
环境:Windows 11,
dsh-archived-chats2.0.9,DSH 0.2.2-rc.5。一、悬空 id:已不再产生开销
/state返回 171 行、无一行headerMissing;680 条悬空 id 的备份清单与当前归档集合的交集是 0。代码侧也对得上:listArchived()先建headerById,missing的行直接跳过readTitle,不会再对缺失日志做任何 open。二、冷启动 9 s 不是悬空 id,是"为取标题读完整份日志"
GET /state第 1 次(本进程内首次)session.v4.jsonl.zstd2.0.9 这条路径没变:
readTitle(id)→inspect(id, true)→handle.read(0, undefined)取全部事件,再线性扫最后一个session/title。所以冷启动的成本跟行数几乎无关、跟归档日志总字节成正比;第二遍起走titleCache,才降到 0.1 s。三、标题其实不用读这么多
抽 12 份日志看
session/title的位置:首次出现在第 5–18 个事件(全长的 0.6%–4.7%),最后一次(改名)落在 4%–98%。也就是说首屏标题读前 32 个事件就够,改名再补一次有界尾读(比如最后 64 个事件);或者干脆把title落进 header,listArchived就完全不必碰日志。四、讨论
这条跟 #132 修的悬空 id 不重叠,是 2.0.9 之后仍在的独立成本。可选的收法:
readTitle改有界读(前 32 个事件,改名再补一次尾 64),读不到或inheritedEventCount > 0再回退整份;不动inspect/readSession的既有契约。当前:每次重启 DSH 后第一次打开归档页等 9 s,其余时间 0.1 s。Ultroncn commentedon Dec 2, 2026
谢谢你补的 Windows 11 数据,尤其是把悬空 ID 和冷启动读标题的开销区分开了。
2.0.10 已发布到 npm。这版归档列表直接用 Harness 提供的标题缓存,不再为了取标题打开会话日志。如果缓存里没有标题,列表会先显示「未命名会话」,仍然可以按原来的标题搜索。
方便的话,能否只升级插件到 2.0.10,保留 DSH 0.2.2-rc.5 和原来的 171 条归档?完全退出再启动 Harness 后,记录一下第一次和第二次
GET /plugins/dsh-archived-chats/state的耗时,就能和你之前的 9.28 秒 / 0.11 秒直接对比。不需要发会话内容或日志,谢谢!xinming-chenniang commentedon Dec 2, 2026
装好了,2.0.10 只升插件,DSH 仍然是 0.2.2-rc.5,归档一条没动。整机完全退出再启动两轮,取到这些数:
GET /state第 1 次(新进程内首次)headerMissing先解释行数:不是这次升级弄丢的。12-01 之后这台机器做过两次会话清理,被摘掉的 111 个 id 日志已经不在盘上(抽样 20 个,0 个还能找到文件);现在的 106 行与 Harness 的
archivedSessionIds完全一致。日志体量和上一批基本持平(130.5 MB vs 138.3 MB),所以这组对比是同量级的。同量级日志上,旧路径还值多少(复刻 2.0.9 的
readTitle:整份解压 + 扫最后一个session/title,纯本地、不含 Host 开销):也就是说 2.0.9 那条路径放到今天的归档体量上仍是 8–9 s 级;2.0.10 把它整个拿掉了 —— 第一次请求已经不比稳态慢。
两次重启的两个「第一次」:0.33 s 与 1.04 s 的差别来自 Host 自身还在启动(第二次取数时新进程刚起来 4 s,第一次那轮是 14 s 且窗口还没出),不是标题读取的差异;同一轮里随后 4 次是 0.17–0.44 s,与第一次同量级。
一个与你这边发布有关的边角:
registry.npmmirror.com上latest还是 2.0.9(今天 08:10 查),registry.npmjs.org上 2.0.10 是 2026-12-01T17:06Z 发的。国内走镜像的用户这几天自动更新会停在 2.0.9,不是我这边漏升。方法:新进程端口一开就立刻打该路由(此时归档面板还没被打开,是进程内第一次调用);稳态用 Node keep-alive 与 PowerShell 各打一遍交叉验证,PowerShell 的绝对值偏高(+80~400 ms 客户端开销),所以上表主数用 Node。