refactor: main process workspace switch state machine with phase logging (phase 4)#24
Merged
Merged
Conversation
- extract detachForWorkspaceSwitch with named phase logging (start → backend-ready/backend-failed → previous-views-detached → view-attached → reinit-sent/init-sent → ready/failed) - replace positionTabOffScreen(-15000) with removeChildView during workspace switch (keep views alive in wcvCache) - clear activeTabView after detach to prevent stale state - fix processActionQueue error returns causing coalesce deadlock (return → continue for all non-terminal errors) - add isWorkspaceSwitch param to setTabViewIntoWindow for precise log placement at addChildView / send wave-init points - action queue coalescing semantics preserved unchanged
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.
Summary
Phase 4 of workspace-switch refactor: main 进程 workspace switch 状态机。
Changes
核心改动:
processActionQueue重构before: workspace switch 的
switchworkspacecase 是 20 行内联代码,混杂在 action queue 的 80 行函数中:positionTabOffScreen(-15000)隐藏旧 workspace viewsthis.activeTabView在 detach 后未清理after: 提取命名方法 + 阶段日志 + 精确时点拆分
detachForWorkspaceSwitch()setTabViewIntoWindow(..., isWorkspaceSwitch)阶段日志
view-attached和reinit-sent/init-sent分别在addChildView和webContents.send("wave-init", ...)的确切时点打印,而非批处理后。Bug 修复
readysuccess标志 →ready/failed互斥ready漏打entry?.op在 coalesce 后指向新 action,自然跳过activeTabView仍指向旧 viewthis.activeTabView = nullreturn卡死 coalesced actionreturn→continue(finally执行shift()后 while 继续处理)workspaceId来自入参而非后端this.workspaceId = newWs.oid未变更
_queueActionInternalcoalescing 逻辑([0]执行中、[1]覆盖)完全保留finalizePositioning中positionTabOffScreen保留(同 workspace 内 tab 切换仍需隐藏非 active tab)removeChildView后旧 workspace 的WaveTabView实例保留在全局wcvCache,由 cache eviction 按需销毁设计文档
补充
docs/design/workspace-switch-refactor-plan.md,覆盖四阶段完整方案描述。Review 闭环
所有 8 项 Review 意见已修复:
https://github.com/anomalyco/opencode/issues
TypeCheck
零新增错误。仅
frontend/preview/下 3 个文件的 17 个已有错误(与本 PR 无关)。