Repository navigation
Replies: 5 comments 2 replies
|
@M4n5ter @UncertaintyDeterminesYou4ndMe I’d love to try the Rust Host and GPUI together for daily work. How close do you think the two branches are to a first usable build—something that can run real tasks and continue existing work after a restart? Do you have a rough timeframe in mind? What are the main things still to connect or work through? I’d be happy to help where I can. 中文版(点击展开)@M4n5ter @UncertaintyDeterminesYou4ndMe,想早点试试 Rust Host + GPUI 一起跑日常工作。 你们觉得两个分支离第一个可日用的联合版本还有多远,大概什么时候能试上?能跑真实任务、重启后继续已有工作就很好。 现在主要还有哪些地方需要接起来,或者有什么卡点?也想看看有没有我能帮上忙的地方。 |
EnglishThanks for bringing this up! An update from the Rust side: the foundational work is already in place on One important clarification to the original post: @UncertaintyDeterminesYou4ndMe, I’d prefer for you to lead the GPUI desktop design and implementation. An agent-assisted walkthrough of At this early stage, I think it’s better to keep the desktop design and implementation under one clear lead, rather than split the work across more contributors before the direction has taken shape. That should help keep the design coherent and avoid unnecessary coordination overhead and conflicting changes. 中文版感谢发起讨论!更新一下 Rust 侧的进展: 需要澄清原帖中的一个重要前提: @UncertaintyDeterminesYou4ndMe,我更倾向于由你主导 GPUI desktop 的设计和实现。借助 agent 梳理一下 在这个早期阶段,我觉得更适合先由你集中主导设计和实现,而不是在方向尚未成形之前就拆给更多人并行参与。这样更容易保持设计的一致性,也能减少不必要的沟通成本和修改冲突。 |
EnglishThanks, @M4n5ter. I'm happy to lead the desktop. I went through What fits. The Host services cover most of what a desktop needs: the Agent service (history with cursors, watch, send and stop, the queue, pending interactions, attachments), Settings, skills and the plugin manager. The views of the GPUI client I've been building against What gets in the way. Today the desktop draws the same TypeScript scenes as the TUI. Every callback sends the component's whole JSON state through the UI worker and back; the scene vocabulary has no virtualized list, menus, tabs, splitters, tooltips or theming; and native components only render what they are given, so they cannot fetch their own data. That works for sharing one view between the TUI and the desktop, but long streaming conversations, a colored terminal and a diff view need native components that own their data. What I'd like to discuss first:
Smaller items I'll bring with the design: structured error codes instead of strings; serving the terminal's raw byte stream, which exists but is not exposed, so the desktop can render it with alacritty; and services the desktop needs that don't exist yet (git status and diff for a changes view, file listing and watching, a context breakdown, forking a session for side chats, whole-word and case-insensitive search). Next I'll build and run 中文版谢谢 @M4n5ter,我来主导 desktop。我借助 agent 梳理了 能直接用的。 Host 服务基本覆盖了 desktop 的需要:Agent 服务(带游标分页的历史、watch、发送和停止、队列、待处理的交互、附件)、Settings、skills 和插件管理器。我在 妨碍 desktop 的。 现在 desktop 画的是和 TUI 共用的 TypeScript scene。每次回调都要把组件的整份 JSON state 经 UI worker 来回传一遍;scene 词汇里没有虚拟列表、菜单、tab、分栏、tooltip 和主题;原生组件只渲染传进来的数据,不能自己取数据。这适合让 TUI 和 desktop 共用一份视图,但长对话的流式输出、彩色终端和 diff 视图都需要自己持有数据的原生组件。 想先讨论的两件事:
几个小一些的问题会随设计一起提:错误改用结构化的错误码;把终端已有但没有对外提供的原始字节流暴露出来,让 desktop 用 alacritty 渲染;补上 desktop 需要但还没有的服务(Changes 视图用的 git status 和 diff、文件列表和监听、上下文构成、为 side chat 分叉会话、全字匹配和不区分大小写的搜索)。 接下来我会在临时 Root 上构建并运行 |
|
@UncertaintyDeterminesYou4ndMe EnglishThanks—these are valuable observations, and exactly the boundaries we should discuss now. To clarify the intent behind the current architecture: we are exploring how to combine Rust and native performance with a highly flexible, programmable UI, so users can create entirely new products by writing and composing plugins. The current JS components, native capabilities and composition model are attempts toward that goal. Their state, scene and execution boundaries remain open to redesign; they are not fixed constraints that Desktop must accommodate. On the first point, I agree that whole-state round trips, gaps in the presentation API and high-frequency data paths deserve attention. I also support components calling and subscribing to Host services within their composition grants. However, I would like us to evaluate the implementation boundaries before deciding that the transcript, composer, workbar and other core product views should all be implemented in Rust. Users should be able to change those interactions through plugins, or replace the entire product—not merely arrange a fixed set of compiled components. gpui-shell is worth including in this discussion. It lets scripts retain View state and define presentation and application behavior, while Rust supplies native state, layout and rendering. We can evaluate using it directly or adopting the parts of its design that fit Maka. Its threading model, update granularity and plugin execution costs still need validation against our workloads. Implementation complexity should not deter us from a better architecture. If achieving both performance and flexibility requires changing existing interfaces, state ownership or the runtime, we should be willing to do that. TUI and Desktop can share contracts, composition mechanisms and suitable application logic while each uses its own presentation capabilities fully. They do not need identical UI representations. On the second point, I agree that this is a capability gap we should close. The Host should have a lifecycle independent of any window, and both TUI and Desktop should be able to connect to the same Host and access the same business state. Closing a window or disconnecting a client should not implicitly stop background work already accepted by the Host. Closing the UI, stopping a task and stopping the Host need distinct semantics. Exclusive ownership of the business Root should remain with that Host; allowing multiple processes to write the same Root is not the solution. We already have foundations for an independently running Host, but the frontend connection, caller-state and shutdown paths are not fully integrated with it. I will work on closing that gap on the Host side. The Desktop design can target an independent Host with multiple clients. Please continue leading the Desktop proposal. We should validate performance with real long conversations, streaming output, terminals and diffs, while also demonstrating that a third party can build a complete product with a different workflow without modifying Maka’s native code. Both are necessary to meet the goal of this architecture. 中文版谢谢,这些反馈很有价值,也正是现在需要一起讨论的边界。 先说明一下当前架构的出发点:我们正在探索如何在使用 Rust、获得原生性能的同时,保留极高的 UI 灵活度,让用户通过编写和组合插件创造全新的产品。 当前的 JS 组件、原生能力和组合机制都是围绕这个目标的尝试,具体的 state、scene 和执行边界仍然可以重新设计,不是 Desktop 必须迁就的固定约束。 关于第一点,我认同你指出的整份 state 往返、展示能力不足和高频数据路径的问题,也支持组件在组合授予的权限内直接调用和订阅 Host 服务。但我希望我们一起评估具体的实现边界,不提前把 transcript、composer、workbar 等核心业务界面全部确定为 Rust 实现。用户应当能够用插件改变这些交互,甚至替换整个产品,而不只是排列几个官方编译好的组件。 gpui-shell 值得纳入这个设计讨论。它让脚本保留 View 状态、定义界面和业务行为,同时由 Rust 提供原生状态、布局和渲染能力。我们可以评估直接采用它,也可以借鉴其中适合 Maka 的设计;它的线程模型、更新粒度和插件执行成本仍需要结合实际负载验证。 我们不需要因为实现复杂度而回避更好的架构。 如果要同时实现性能和自由度,需要调整现有接口、状态所有权或运行时,就可以大胆改。TUI 和 Desktop 可以共享契约、组合机制及适合共享的业务逻辑,各自充分发挥展示能力,不要求使用完全相同的 UI 表达。 关于第二点,我同意这是需要补齐的能力。Host 应当具有独立于窗口的生命周期,TUI 和 Desktop 都能够连接同一个 Host,访问同一份业务状态。 关闭窗口或断开客户端,不应默认停止 Host 已接受的后台工作;显式停止任务、停止 Host 和关闭界面需要区分。业务 Root 的唯一所有权应保留在负责它的 Host,不能通过放松租约、让多个进程直接写同一个 Root 来解决。 目前已有独立 Host 的基础,但前端的连接、调用方状态和退出清理还没有完整接到这条路径上。这部分我会在 Host 侧推进补齐,Desktop 的设计可以把独立 Host 和多客户端接入作为目标。 你可以继续主导 Desktop 提案。希望我们用真实的长对话、持续输出、终端和 diff 场景验证性能,同时验证第三方能否在不修改 Maka 原生代码的情况下,构建一个不同工作流的完整产品。两方面都成立,才算达到了这次架构探索的目标。 |
EnglishThanks, that clarifies the goal. I've moved away from "core views in Rust": the measurements below suggest the transcript itself can be a script, as long as the heavy pieces it uses (virtualized list, markdown, diff, terminal) are native components that own their data. I ran a first gpui-shell spike (gpui-kit Transcript as a script. The script uses
Making each message its own view halves the per-token script cost. The trade-off is fast scrolling: about 4.6 ms per frame, with P95 up to 9.3 ms (over budget), because each row that comes into view renders for the first time. Memory for 10k messages is about 140 MB after loading and levels off around 300 MB after scrolling the whole history. Diff and terminal as native components.
Neither involves script on the hot path. Plugin execution cost is the open question. gpui-shell runs QuickJS on the UI thread, with no worker. I ran the same pure-JS module under both engines over 10,000 messages (5.9 MB). QuickJS (release, with its JIT tier on) is 2–27× slower than V8:
On the UI thread, a 27–55 ms task drops 3–7 frames. Describing UI is cheap, so this does not matter for views. It does matter for plugins that compute. My proposal is a rule for desktop UI scripts: they describe views, handle events and call services. Search, indexing, transforms and anything else over the whole history go to Host services or Host-side plugins, and the Desktop calls them asynchronously. A third party's product would then put its logic in Host plugins and its interface in desktop scripts. Does that boundary fit what you have in mind for "a complete product without modifying Maka's native code"? What gpui-shell is missing for an embedding host. I'd raise these with its maintainers and can send PRs:
I worked around all of these with small local hooks; none blocked the spike. Next.
Side note on the current 中文版谢谢,目标清楚了。我不再坚持"核心界面用 Rust 写":下面的数据说明,对话界面本身可以是脚本,只要它用到的重型部件(虚拟列表、markdown、diff、终端)是自己持有数据的原生组件。 我先做了一轮 gpui-shell 验证(gpui-kit 对话界面用脚本写。 脚本用
每条消息做成独立 view,每 token 的脚本开销能减半。代价在快速滚动:每帧约 4.6 ms,P95 最高 9.3 ms(超出预算),因为每条进入视口的行都要做第一次渲染。1 万条消息加载后内存约 140 MB,滚完全部历史后稳定在 300 MB 左右。 diff 和终端用原生组件。
两者的热路径上都没有脚本参与。 没解决的是插件执行成本。 gpui-shell 的 QuickJS 跑在 UI 线程上,没有 worker。我用同一段纯 JS 模块在两个引擎上跑 1 万条消息(5.9 MB)。QuickJS(release,JIT 层已开启)比 V8 慢 2–27 倍:
在 UI 线程上,27–55 ms 的任务会掉 3–7 帧。描述界面很便宜,所以这对视图没有影响,但对要做计算的插件有影响。我的提议是给 desktop 的 UI 脚本定一条规则:它们只负责描述视图、处理事件、调用服务。搜索、索引、转换以及其他针对全部历史的计算,都放到 Host 服务或 Host 侧插件里,Desktop 异步调用。这样第三方的产品就是:逻辑写在 Host 插件里,界面写在 desktop 脚本里。这条边界符合你说的"不修改 Maka 原生代码就能构建完整产品"吗? 嵌入宿主还缺什么。 这些我会和 gpui-shell 的维护者提,可以提 PR:
这些我都用本地的小改动绕过了,没有一个卡住验证。 接下来:
另外,当前 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'd like to discuss Rust execution work by @M4n5ter and GPUI desktop work by @UncertaintyDeterminesYou4ndMe , aiming for lower memory and battery use and faster, cheaper task completion.
Boundary and performance
Keep Runtime Host as the execution authority and its existing protocol as the shared contract. GPUI can connect to the current Host; the Rust implementation can serve the current client. The rewrites can progress independently.
Compare the same workloads, with the same model and settings for execution:
Questions for discussion
Always-on Bot harness (#6076) covers the continuing-work and interaction model. This discussion covers implementation and performance. Host lifecycle changes remain a separate decision.
中文版(点击展开)
我想讨论 M4n5ter 的 Rust 执行端重写和 U4DYM 的 GPUI 桌面端重写,目标是更少的内存、更低的耗电,以及更快、更低成本地完成任务。
边界与性能
Runtime Host 仍是执行权威,以现有 Host 协议为共同契约。GPUI 可以连接当前 Host,Rust 实现也可以服务当前客户端,两边分别推进。
使用同样的工作负载比较,执行端保持相同模型和配置:
想讨论的问题
Always-on Bot harness(#6076)讨论持续工作和交互方式。本篇讨论实现和性能,Host 生命周期改变仍需单独定案。
All reactions