Skip to content

fix(sessions): 有界详情读取保留新的空闲编辑缓存 - #2233

Merged
vastsa merged 1 commit into
vastsa:mainfrom
yg2224:fix/session-window-cache-race
Nov 11, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
yg2224:fix/session-window-cache-race

Conversation

@yg2224

@yg2224 yg2224 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

侧边栏预读取的有界 session.get 晚返回时,原逻辑把旧正文及旧历史窗口写回缓存,覆盖请求期间的空闲编辑。现在仅在缓存仍未变化,或需要合并运行中的实时尾部时回填;调用方仍获得读取响应。此修复是 loadSessionDetail 路径,区别于已合入 #2224 的 loadFullSessionMessages。

主要实现:apps/desktop/src/stores/runtime/session-runtime.ts;新增生产入口回归和独立 Electron 检查,同步中英文规格及 E2E 场景。

旧代码回归把 edited 内容变回 original;候选有界/全量缓存、streaming、空读取保护及相关回归 25/25 通过。真实 Electron 用生产 runtime/API 及 MessageRow 呈现恢复缓存,正文为新编辑内容且窗口与之配对。Desktop TypeScript、样式、文档检查通过。仅调整已有源码断言以容纳缓存所有权条件,保留可疑空读取保护及新增 live-tail 行为断言。

候选 81e5f13,基线 4ad0094。运行命令为 Node D:/pi/toolchain/node.exe、node --test、Desktop tsc --noEmit、node scripts/e2e-session-window-cache-race.mjs、样式及文档检查。Electron 检查使用本候选的生产代码与实际 BrowserWindow,仅控制外部 API 结果,复用宿主依赖和样式;没有访问真实用户配置、真实远端或付费 provider。此专项 Electron 测试不等同于完整应用 bootstrap E2E,后者未运行。

Refs #2086。修复与该综合反馈有关的确定缺陷,未声称覆盖原 issue 全部根因。等待最新 head 的远端 CI 和人工评审。

2026-11-10 12:00 复查:本 PR 上述最新 head 的六项 CI 均 SUCCESS,无 pending、无失败;主线仍为 4ad0094,无冲突,GitHub merge-ref 的源码树再次核对与本地已验证候选一致。尚无人工批准。

旧详情读取不能覆盖空闲会话的编辑缓存和历史窗口。未更新缓存仍正常填充,运行中的实时尾部继续按已有规则合并。

Refs vastsa#2086
@vastsa
vastsa merged commit 1ea89e1 into vastsa:main Nov 11, 2026
6 checks passed
SeanLiu326 added a commit to SeanLiu326/PI-Desktop that referenced this pull request Nov 12, 2026
…e compare

The guard required a captured cache entry before comparing, so a read
that started with no transcript cache entry could never see the movement
an in-flight idle edit makes (undefined -> entry). The runtime guard
this mirrors (vastsa#2233) needs no such precondition; dropping it keeps the
caller-level compare aligned with that semantics. Warm re-selects are
unaffected: the comparison is the same reference check it always was,
and a quiet read whose runtime write replaces the entry still resolves
to the same window content.
jiangchuanso pushed a commit to jiangchuanso/PI-Desktop that referenced this pull request Nov 15, 2026
…s detail read

selectSession awaited the bounded detail read and then re-cached and committed its window unconditionally. An idle-session edit (message delete, revision switch) that landed while the read was in flight replaces the transcript cache entry, so committing the stale window reverted the edit on screen and in the cache. vastsa#2233 taught loadSessionDetail itself to refuse caching such a read; the caller-level commit now applies the same guard: when the cache entry moved during the read for an idle session, the commit keeps the edit writer's cache content and cached window instead.

Pinned by session-select-stale-read.test.mjs driving the real slice (superseded read keeps the edit; uneventful re-select still hydrates; running sessions still merge the live tail).
jiangchuanso pushed a commit to jiangchuanso/PI-Desktop that referenced this pull request Nov 15, 2026
…e compare

The guard required a captured cache entry before comparing, so a read
that started with no transcript cache entry could never see the movement
an in-flight idle edit makes (undefined -> entry). The runtime guard
this mirrors (vastsa#2233) needs no such precondition; dropping it keeps the
caller-level compare aligned with that semantics. Warm re-selects are
unaffected: the comparison is the same reference check it always was,
and a quiet read whose runtime write replaces the entry still resolves
to the same window content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants