refactor: clarify state ownership - promote windowId to explicit lifecycle atom (phase 2)#21
Merged
Merged
Conversation
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
明确 state owner,将 window 相关状态从
GlobalModel的普通属性 + 内联 derived atom 迁移为显式 lifecycle atoms,消除第二条隐式 workspace 派生链。Phase 2 of workspace-switch refactor.Changes
New explicit lifecycle atoms
atoms.windowIdPrimitiveAtom<string>applyWorkspaceContext()+ init value frominitOpts.windowIdatoms.windowDataAtom<WaveWindow>atoms.windowIdvia WOSatoms.windowId+atoms.windowDataGlobalAtomsTypeuiContextAtomnow reactivewindowid字段由闭包捕获initOpts.windowId改为从atoms.windowId派生。当 workspace reinit 更新windowIdAtom时,uiContextAtom自动反映最新值。GlobalModel精简移除
windowId字段、windowDataAtom、workspaceAtom(死代码,从未被任何组件消费)。GlobalModel降级为仅提供setIsActive()工具方法。AppInnergate 迁移AppInner的初始化守卫从GlobalModel.getInstance().windowDataAtom迁移到atoms.windowData,与主生命周期链对齐。架构变化
Bug Fixes
Builder 模式回归 (CR#1)
initBuilder()路径不经过applyWorkspaceContext()。windowIdAtom初始值设为initOpts.windowId(而非null),所有路径(tab/builder/preview)立即获得正确值。Init 时序空窗 (CR#2)
atom(initOpts.windowId)确保从initGlobalAtoms()完成到applyWorkspaceContext()被调用之间,callBackendService等同步 RPC 调用不会发送windowid: null。Mock preview uiContext 一致性 (CR#3)
mock 的
uiContext从静态硬编码值改为派生 atom,订阅windowIdAtomMock,与 production 行为一致。测试 Note