Files
XCEngine/docs/plan/xcui_editor_windowing_architecture_plan.md

6.1 KiB
Raw Blame History

XCUI Editor Windowing Plan

更新日期: 2026-04-26

状态: In Progress, authority/planner、显式 mutation request、destroy reconciliation 已收口,下一阶段聚焦 live projection 去副本化

1. 长期目标

这个计划只关注 editor/app/Windowingeditor/app/Platform/Win32/Windowing 的多窗口工作区主线。目标不是继续把行为堆进 EditorWindowWorkspaceCoordinator,而是把 editor 窗口系统收口为下面的单向数据流:

EditorWindowSystem authoritative window set
  -> semantic mutation / lifecycle policy
  -> synchronization plan
  -> Win32 host execution
  -> native observation / frame requests
  -> app-layer reconciliation

长期完成态应满足:

  • EditorWindowSystem 是窗口工作区 authority、validation、planner、destroy reconciliation 的唯一 app 层入口。
  • EditorWorkspaceWindowContentController 只负责 projection、交互和 mutation request 生产,不再充当 host 可写的 authority 副本。
  • EditorWindow 不再把 TryGetWorkspaceController() / ReplaceWorkspaceController() 作为跨层同步主接口host 侧消费的是受控 projection 或 presentation data。
  • EditorWindowWorkspaceCoordinator 收缩为 host executor + native event bridge不再同时承担领域编排、live projection 回滚和跨窗口语义决策。
  • detach、dock、close、destroy、primary switch 都先形成 app 层 mutation / transition再生成 sync plan再由 host 执行。

验证基线统一收口到 tests/UI/Editor:

  • editor_windowing_phase1_tests 负责 planner / reconcile / transition 规则。
  • 若当前 checkout 提供对应 target则由 editor_app_feature_tests 负责 host 集成行为。
  • xcui_editor_app_smoke 负责启动烟测。
  • tests/UI/Editor/manual_validation 保留复杂交互人工验证。

2. 当前进展

已完成并已经并回总 plan 的收口项:

  • EditorWindowSystem 已拥有 BuildPlanForWorkspaceMutationRequest(...)BuildPlanForDestroyedWindow(...)CommitSynchronizationPlan(...)
  • EditorWindowWorkspaceCoordinator 已不再直接写 authority store。
  • live frame 内工作区变化已经通过显式 workspaceMutation request 回到 app 层。
  • editor_windowing_phase1_tests 已覆盖显式 mutation request commit、unknown windowId rejection、detached window create/close、destroyed primary closeout 等基础规则。

这意味着前一轮 subplan 里围绕“authority 回写收口”“显式 request 成为主输入”“destroy reconciliation 回到 app 层”的工作已经完成,后续不再继续保留为独立 subplan。

当前离长期目标仍有两个核心缺口:

  • live content 仍持有可变 UIEditorWorkspaceControllerprojection 和 authority 的边界还不够硬。
  • EditorWindowWorkspaceCoordinator 仍然过厚,把 host 执行、projection 替换、标题刷新、drag/detach 流程和失败回滚串在同一层。

3. 下一个阶段执行计划

3.1 阶段目标

下一阶段只做一个切口: 把“live workspace controller 是 host 可写副本”收口为“content 只持有受控 projection并通过显式 request 回传语义变化”。

做完这一阶段后,EditorWindowWorkspaceCoordinator 可以暂时保留现有 drag/detach 能力,但它不应再依赖 EditorWindow::GetWorkspaceController() / ReplaceWorkspaceController() 作为常规同步手段。

3.2 范围

主要涉及:

  • editor/app/Windowing/Content/**
  • editor/app/Windowing/System/**
  • editor/app/Platform/Win32/Windowing/**
  • tests/UI/Editor/unit
  • 必要时补 tests/UI/Editor/smoke

本阶段不扩到 shell、viewport、panel feature 业务重构。

3.3 执行步骤

  1. 定义 projection 边界
  • 为 workspace window 引入明确的 projection / presentation payload至少覆盖 content compose、title、minimum size、detached title bar 所需数据。
  • EditorWorkspaceWindowContentController 改为消费 projection 并产出 request不再把内部 UIEditorWorkspaceController 暴露为 host 通用读写接口。
  1. 改造窗口更新路径
  • 拆分 EditorWindowWorkspaceCoordinator::ApplySynchronizationPlan(...)把“host 执行”和“projection 刷新/commit”从同一段流程里拆开。
  • UpdateWorkspaceWindow 动作不再通过 ReplaceWorkspaceController(...) 整体替换 live controller而是通过受控 projection refresh API 更新窗口内容。
  1. 收口 presentation 读取路径
  • RefreshWindowTitle(...)ResolveMinimumOuterSize()ResolveDetachedWindowTitleText(...) 等 presentation 决策统一基于 authoritative state 或 projection payload。
  • 清理 EditorWindow::TryGetWorkspaceController() 在 Win32 协调器里的常规读路径,只保留确实无法在本阶段消除的过渡性接口。
  1. 建立回归验证
  • 保持现有 workspaceMutation request / destroyed window reconciliation 测试基线不回退。
  • 为 projection refresh、title refresh 增补 focused unit coverage。
  • 为 detach、dock、primary switch 至少补一组 focused integration 或 app feature tests确保改造后 host 行为不回退。
  • 继续保留 xcui_editor_app_smoke 作为 editor 启动基线。

3.4 本阶段验收标准

  • EditorWorkspaceWindowContentController 不再被当成 authority 副本使用。
  • EditorWindowWorkspaceCoordinator 的常规同步路径不再依赖 ReplaceWorkspaceController(...)
  • 标题、最小尺寸、detached tab strip 文案等 presentation 行为能从 projection / authoritative state 稳定导出。
  • workspaceMutation 仍是 frame 内工作区变化的显式入口,没有恢复任何平台隐式写回。
  • editor_windowing_phase1_tests 与可用的 host 集成测试入口能覆盖本阶段新增规则。
  • xcui_editor_app_smoke 继续通过。

3.5 本阶段非目标

  • 不重写 XCUIEditorApp 启动流程。
  • 不在本阶段改造 EditorShellRuntime、viewport render loop 或各 feature panel 业务。
  • 不追求一次性删除所有 UIEditorWorkspaceController 使用点,先消除 host 常规同步路径上的 authority 副本语义。
  • 不把 Win32 host adapter 直接扩写成跨平台窗口系统。