refactor(harmonyos): split the app shell into MVVM layers - #2160
Open
wgqqqqq wants to merge 2 commits into
Open
Conversation
AppRoot had grown into a single runtime object that owned routing, remote transport, conversation state and presentation at once, so every feature change reached across all of them. Split it along explicit boundaries: - pages/runtime for the composition root and lifecycle - pages/viewmodel for controllers and view models - pages/policy for pure decision helpers - pages/actions for the typed intent/action surface handed to components - pages/navigation and pages/layout for route and geometry contracts Components now receive typed action objects instead of reaching into view models, which lets Local and Remote share one conversation shell (ConversationRouteSurface on compact, WideConversationHost on wide). Behaviour changes that came out of the split: - Creating a chat from the "chat" option binds the desktop's assistant workspace first. The desktop ignores workspace_path for Claw sessions and always uses its assistant workspace, so the app used to keep showing the code workspace it was on while the session was actually created elsewhere - the new chat never appeared in the list. - Picking a workspace in the create sheet now pairs it with the code agent, so the picker is honoured instead of being silently dropped. - Compact remote conversations open the sidebar over the chat from a menu button, matching local chats, instead of popping back out of the conversation. The system back gesture still leaves the chat and reveals the drawer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The MVVM split only holds if the import direction is enforced. Add `pnpm run harmony:architecture`, which fails when services import pages, when components import view models, when the page graph gains a cycle, or when action and hook interfaces are passed as anything but typed object literals. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
背景
AppRoot已经膨胀成一个同时负责路由、远程传输、会话状态与展示的运行时对象,任何一个改动都要横跨全部职责。这个 PR 把它按边界拆开,并顺带修掉了拆分过程中暴露出来的几个行为问题。结构调整
pages/runtime—— 组合根与生命周期pages/viewmodel—— 控制器与 ViewModelpages/policy—— 纯决策函数pages/actions—— 交给组件的 intent / action 类型化接口pages/navigation、pages/layout—— 路由与几何契约组件不再直接访问 ViewModel,而是接收类型化的 action 对象,因此 Local 与 Remote 可以共用同一套会话外壳(紧凑布局用
ConversationRouteSurface,宽屏用WideConversationHost)。行为修复
workspace_path并强制使用 assistant 工作区,所以之前 App 仍停留在原来的代码工作区,而会话其实建在了别处——新会话在列表里根本看不到。codeagent 配对,选择会被真正生效,而不是被静默丢弃。配套检查
新增
pnpm run harmony:architecture,在 services 反向导入 pages、components 导入 viewmodel、页面依赖成环、action/hook 接口不是类型化对象字面量时报错。验证
pnpm run harmony:architectureentry/src/test)🤖 Generated with Claude Code