fix(web): 合成会话键原样存取,使标记在会话落盘后依然生效 - #354
Closed
onychen wants to merge 1 commit into
Closed
Conversation
…stence removeWorkspace and archiveSession resolved the synthetic current:<sessionId> key against the process cwd before persisting it. The polluted key matched the projection only while both sides resolved identically in the same process; once the session gained a real file the mark was lost forever, making the active session disappear from the sidebar after deleting its workspace and unrecoverable via /api/sessions/select. Keep synthetic keys verbatim on write, load, and lookup via a shared sessionKey() helper, and match persisted marks by either the resolved file path or the synthetic current:<id> key so marks recorded before persistence keep applying after it. Legacy polluted entries stay inert. Update the two assertions that locked the resolved form and add regression tests covering both the ungrouped and archive flows across the unpersisted-to-persisted transition. Fixes openpi-dev#351
5 tasks
Contributor
Author
|
关闭本 PR,原因:经进一步真实验证,修复所针对的问题分支在生产路径上不可达,按维护者与提交者商定的处理方式,连同 #351 一并关闭。 验证过程 搭建了真实 根因核实
结论
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #351.
当前工作区在活动会话尚未落盘(还没有会话文件)时被移除,
removeWorkspace会把合成标记current:<sessionId>先经resolve()再写入ungroupedSessions,实际持久化的是<cwd>/current:<uuid>这样的污染键。该键只有在同一进程内写入与查询两侧 resolve 结果恰好一致时才能匹配投影;一旦会话获得真实文件(发出第一条消息),标记永久丢失:会话从所有侧栏分组中消失,/api/sessions/select被requireSession以 "Workspace is not available" 拒绝,切走后无法切回。archiveSession存在同样模式,归档标记同样会丢失。Value
workspace-state.json/archived-sessions.json累积假的<cwd>\current:<uuid>条目。Approach
遵循 #351 中建议的最小修复:
current:<sessionId>现在原样往返:共享的sessionKey()辅助(配合isSyntheticSessionKey)统一用于写入(removeWorkspace、archiveSession)与加载(ensureWorkspaceStateLoaded、ensureArchivesLoaded);真实路径仍照常resolve()。hasSessionMark()辅助,按「resolve 后的真实文件路径」(落盘后记录的标记)或「合成current:<id>键」(落盘前记录的标记)双查,标记在会话获得真实文件后依然生效,无需任何迁移。<cwd>\current:<uuid>)resolve 幂等、不再匹配任何键——按 bug(web): removing the current workspace hides its unpersisted active session instead of moving it to Ungrouped #351 的决策保留为惰性孤儿,不做迁移。Validation
npm run format:check、npm run lint、npm run typecheck— 通过。node --test --experimental-strip-types tests/web/pi-adapter.test.ts— 15/15 通过,含 2 条新回归测试,完整复现 ungrouped 与 archive 两条流程的「未落盘 → 落盘」转换。tests/web纯逻辑套件(protocol、http-dispatcher、observer-registry、terminal-status、web-host-lease):38 通过 / 0 失败 / 2 平台跳过;app-render.test.ts:21/21。node scripts/run-tests.mjs会命中 test: eliminate Windows background-terminal process-test flakes in the full suite #304 已跟踪的背景终端 kill 测试 flake/挂起(进程管理域,与本改动无关),本机无法完整跑完,如实说明。Impact
current:<id>原样存储;旧污染条目保持可读且惰性(按 bug(web): removing the current workspace hides its unpersisted active session instead of moving it to Ungrouped #351 不迁移),无 schema 变化。