Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .agents/skills/webui-development/references/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ file holds only the traps in running those checks and the boundaries of what the
`pnpm exec vitest run --config vitest.oss.config.mjs <file>`.

Aggregate gates (`pnpm verify`, `pnpm test:webui`, the full browser suite) are not the default for a local
change. `pnpm lint` is not a WebUI ESLint gate. Build artifact checks need a current build: Vite
development behavior is not the shipped esbuild artifact.
change. `pnpm lint` is not a WebUI ESLint gate. Build artifact checks need a current esbuild build.
`pnpm dev:webui` builds and serves the client and runtime on one port; rebuild and restart after
client edits. A running server alone does not prove its assets match the current sources.

## What each kind of evidence establishes

Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ updates:
directory: /
schedule:
interval: weekly
# Tailwind v4 requires a coordinated CLI, CSS and dynamic-class migration.
ignore:
- dependency-name: tailwindcss
update-types: [version-update:semver-major]
groups:
tooling-minor-patch:
dependency-type: development
Expand Down
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ Do not reference internal hosts, generated IDL, or private services; `check:sour

## WebUI

### 本项目的后续维护入口

开始维护或收到“继续维护”时,先读取 [项目维护指南](docs/项目维护指南.md) 和
[项目维护基线](docs/项目维护基线.md)。默认按“官方桌面版功能对齐 → Bug 排查、测试与修复 → PR / Issue 维护”推进,以 WebUI 为主体;先刷新基线,再选择具体任务。
这两份中文文档是维护者指定的项目记录,其中指南承载长期规则,基线承载带日期和提交号的现状;源码与实际验证优先于旧快照。遵守指南中的当次授权和默认不推送规则。

`packages/webui` is a browser client with its own operating guide. Before changing anything under it,
read `packages/webui/AGENTS.md` — the layering rules, the gates each kind of change needs, the test
conventions and the fork's branch and issue workflow — and `packages/webui/docs/README.md` for the
Expand Down
345 changes: 345 additions & 0 deletions docs/项目维护基线.md

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions docs/项目维护指南.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# 项目维护指南

本项目后续维护的固定顺序是:**官方 MiniMax Code 桌面版功能对齐 → Bug 排查、测试与修复 → PR 和 Issue 维护**。维护主体是 WebUI;本指南是这套长期规则的唯一正文。[项目维护基线](项目维护基线.md) 保存可更新的事实、证据和待办,不重复定义规则。

本指南由维护者于 2026-12-04 确认。新任务通过根 [AGENTS.md](../AGENTS.md) 进入本指南;修改 WebUI 前还需阅读其 [开发规范](../packages/webui/AGENTS.md)。新增的两份中文维护文档遵从维护者的明确要求,不据此改写其他文档的语言。

## 1. 项目定位与架构

`mcode-webui/minimax-code` 是 MiniMax Code 的 WebUI 仓库,保留 CLI/TUI、ACP 和共享运行时。官方桌面产品提供功能对标依据;这个仓库不是桌面应用源码的完整替代品,也不能直接用桌面版本号与本仓库 package 版本号比较功能完整性。

### 执行与数据流

```text
React 页面 / 组件
→ application owner(业务状态和命令)
→ browser transport(带 requestId 的请求)
→ 经认证的 WebSocket
→ WebuiService 校验、operation registry 分派
→ WebuiHarnessPort / harness adapter
→ local-runtime-v2 进程内 host
→ session / turn / agent、模型与工具、持久化

响应 / AsyncIterable 事件
→ 服务端响应帧 / 事件帧
→ transport / event-channel
→ application owner 更新状态
→ projection / bindings / React 显示
```

证据入口:[客户端组合入口](../packages/webui/src/client/main.tsx)、[服务入口](../packages/webui/src/server/service.ts)、[流处理](../packages/webui/src/server/operation/handlers/stream.ts)、[运行时装配](../packages/webui/src/runtime/assembly.ts)、[harness 适配器](../packages/webui/src/runtime/harness/adapter.ts)。WebUI 直接调用进程内运行时,不通过启动 TUI 驱动对话。

| 范围 | 职责与维护边界 |
| --- | --- |
| `packages/webui/src/client` | React 界面、业务 owner、浏览器 IO;业务按 `features` 划分,组件通过命令改状态,不能跨到 Node 侧。 |
| `packages/webui/src/server` | HTTP、WebSocket、认证与校验、协议分派、Mini App 代理及浏览器扩展桥接。 |
| `packages/webui/src/runtime` | 本地能力适配、host 装配、终端/浏览器等资源及退出顺序。 |
| `packages/webui/src/shared` | 浏览器和服务端共享的操作名、请求结果和事件契约。 |
| `packages/local-runtime-v2` | 会话、队列、交互、Agent 等服务和应用入口;修改时评估其他客户端影响。 |
| `packages/local-runtime`、`packages/agent-*` | 复用的持久化、文件工具、配置设施和 Agent 能力模块。 |
| `packages/browser-core`、`packages/browser-extension` | 共享浏览器动作语义与外部浏览器接入;不把授权判断下沉到传输实现。 |
| `packages/tui`、`packages/code-acp` | 终端、无界面和 ACP 相关代码;以实际包和发布清单为准,不因目录存在就认定独立发布。 |
| `third_party` | 有独立许可的 vendored 代码,不默认纳入本项目全量测试。 |
| `release`、`scripts`、`test` | 公开文件清单、构建发布与验证、显式测试目录;新增文件需要更新发布清单。 |

主要业务包括项目/会话、输入与消息、模型与账号、插件/Skills/MCP、文件/Diff/终端、浏览器、Mini App、Goal、定时任务、SSH 与远程/IM。详见 [模块地图](../packages/webui/docs/architecture/module-map.md) 和 [架构分层](../packages/webui/docs/architecture/layered-model.md)。现有文档可能滞后,重要结论须回到源码和测试。

### 环境与运行入口

- 环境:以根 `package.json` 为准;当前要求 Node.js `>=22.19 <23 || >=24.2 <27`,`pnpm@10.34.9`。
- 默认数据目录 `~/.minimax`,通过 `MINIMAX_DATA_DIR` 隔离;桌面版、CLI 和 WebUI 可能共用账号、模型和会话数据。测试使用仓库外临时目录及合成数据。
- `WEBUI_HOST` 默认 `127.0.0.1`;`WEBUI_SERVER_PORT` 默认 `2233`;`WEBUI_MINIAPP_PORT` 默认 `49152`;`WEBUI_OPEN_BROWSER=0` 可禁止自动打开浏览器。
- 远程访问必须遵守现有认证和启动凭证设计,项目文件与终端属于服务运行的机器。不要把浏览器本地路径误当作服务器路径。

```bash
pnpm install --frozen-lockfile
# 启动前将 MINIMAX_DATA_DIR 设置为专用测试目录
pnpm dev:webui
# 或者先构建,再单独启动同一个服务
# pnpm build:webui
# pnpm --filter @mavis/webui dev:server
```

当前 `pnpm dev:webui` 先构建,再通过服务打印的 `127.0.0.1:2233` 地址提供客户端与运行时;通过 `WEBUI_SERVER_PORT` 调整端口。客户端修改后重新运行命令,不提供热更新。[WebUI 使用文档](../packages/webui/README.md) 负责完整配置说明;实际验证范围记录在维护基线中。

## 2. 每次维护的入口与排序

1. 读取指南和基线,检查工作区、当前分支、远端与基线提交,保留用户现有改动。
2. 读取 [官方桌面版更新日志](https://code.minimax.cn/docs/changelog),核对桌面标签、版本和发布日期;发现提取器内容滞后时直接核验页面。记录北京时间检查日期,不把缓存页面称为最新版本。
3. 刷新 `origin`,读取明确指定仓库的 PR / Issue,检查是否已有相同工作或阻塞。排除 `origin/HEAD` 等符号引用后统计分支。
4. 按上述三个优先级选择具体工作;同级先处理新版本差距、已有依赖可满足的工作。高优先级被外部条件阻塞时,记录阻塞并推进下一项可执行工作,不反复空转。
5. 从明确的 `origin/main` 提交建立 `feat/`、`fix/`、`docs/`、`test/` 或 `chore/` 分支。每项工作写清目标、证据、验收与结束条件,再进入实现。
6. 完成后更新基线中的状态、提交、验证平台及剩余边界。合并后重新核对主线与待办;旧快照不是当前结论。

“继续维护”授权按此流程检查和选择工作,不等同于授权推送、发评论、关闭工单、合并 PR 或发布版本。本指南不创建定时任务;需要持续定时检查时按用户当次要求另行配置。

## 3. 第一优先级:官方功能对齐

### 对标与实施

- 官方日志确定产品行为;公开源码和本仓库实际实现确定复用路径。首先适配浏览器可承载的能力,必要时修改共享运行时;不默认引入桌面壳、桌面专属桥接或私有服务。
- 首次从最新桌面版本向前覆盖官方页面可见历史,按能力合并重复演进项,但保留版本到能力的对应关系;CLI / Web 标签单独看待,不混入桌面对标范围。
- 每项记录:版本/来源、行为、实现位置、现有测试、状态、差距、依赖条件、下一步和用户可见验收标准。旧版本的行为可能被后续版本替代,验收以最新适用行为为准。
- 源码存在只证明实现线索;测试文件存在只证明有测试资产。必须核对真实入口和执行结果,才能宣布对齐。
- 公开源码同步和桌面功能适配是两件事。遵守 [源码同步流程](source-sync.md),逐文件审阅,不盲目覆盖,不引入内部 Git 历史,不因选择性功能移植就推进完整源码基线。

### 状态定义

| 状态 | 使用条件 |
| --- | --- |
| 已验证对齐 | 指定提交、构建、平台和真实用户入口已满足该条验收;附证据及范围。 |
| 已实现待验证 | 已找到该行为的实现链路,但还未完成真实场景验证。 |
| 部分实现 | 已有明确子能力;列出未接通、未覆盖或待核验的子项,不能泛称完整支持。 |
| 尚未实现 | 在记录的检索范围内没有对应入口/契约/实现;说明范围,不能推断共享层永远不支持。 |
| 不适用 | 桌面安装器等不属于当前 WebUI 维护边界的行为;说明理由。 |
| 受外部依赖阻塞 | 明确缺少的账号、服务、权限、平台或公开接口导致无法继续;记录解除条件。 |

## 4. 第二优先级:Bug 排查、测试与修复

从真实用户入口复现,记录候选提交、安装方式、系统/架构、Node 版本、隔离配置、操作步骤、预期与实际。先定位失败链路,再改最小必要范围并增加能防止复发的测试。

重点检查项目选择、会话恢复与排队、消息流、工具执行、Mini App 跨客户端生命周期、终端资源和服务退出。官方日志中的修复可作为回归场景;日志只写“修复已知问题”时,不自行编造问题内容。

| 改动 | 最小相关验证 |
| --- | --- |
| 客户端 TypeScript | `pnpm --filter @mavis/webui typecheck:client` 与相关 Vitest 文件。 |
| 服务端/运行时 TypeScript | `pnpm --filter @mavis/webui typecheck:server` 与对应适配/集成测试。 |
| TypeScript 测试 | `pnpm --filter @mavis/webui typecheck:test`。 |
| 用户交互 | `pnpm build:webui` 后运行相关 Playwright spec,并走真实产品入口。 |
| 导入、层次、目录角色 | `pnpm check:webui-dependency`。 |
| UI 词汇、动效、浮层、反馈 | 按改动选择 `check:webui-presentation`、`check:webui-motion`、`check:webui-overlays`、`check:webui-feedback`。 |
| 构建/发布入口 | `pnpm build:webui`、`pnpm check:webui-boundary`;涉及安装包才运行 `pnpm test:webui-package`。 |
| 文档、新增/移动文件 | 审核公开内容后运行 `node scripts/source-inventory.mjs --write`、`pnpm check:source`、`git diff --check`。 |

聚焦测试命令:`pnpm exec vitest run --config vitest.oss.config.mjs <test-file>`;浏览器测试:`pnpm exec playwright test <spec-file>`。新增 Vitest 文件必须登记到 `test/vitest-suites.json`。

默认不跑全量 `pnpm verify`。相同提交、构建、平台的有效通过证据可以复用;有相关变化、失败或缺平台覆盖时再运行相应检查。macOS 通过不能代表 Windows/Linux 通过;模拟响应和夹具测试不能代替真实产品工作流的验收。明确区分通过、失败、未运行、受阻。

## 5. 第三优先级:PR 与 Issue 维护

所有 `gh` 的仓库操作显式指定 `--repo mcode-webui/minimax-code`;`gh api` 的路径显式使用 `repos/mcode-webui/minimax-code/...`。避免把 WebUI 的工单或变更发到官方上游。

- Issue:读正文与讨论,确认复现、适用版本、重复项、已合入修复和剩余验收;已有修复分支不代表问题已解决。
- PR:阅读 diff、讨论、依赖和兼容性影响,检查基线、CI 与真实验收;PR 已关闭不代表代码没有以其他方式进入主线。
- 沿用仓库的 `needs-triage`、`needs-info`、`ready-for-agent`、`ready-for-human`、`wontfix` 等标签约定;不为文档盘点擅自改标签。
- PR / Issue 是工作来源,不是另一套优先级:功能对齐进入第一类,Bug 进入第二类,纯整理和依赖维护进入第三类。
- 默认允许本地逻辑分明的提交,不推送。只有当前对话明确要求推送,才按用户规则先创建 `~/.codex/allow-push.json`,设置当前 UTC 时间加 15 分钟的 `expires_at`,完成后立即删除;不绕过拦截。
- 不直接推送 `main`;发布评论、关闭工单、合并和发布按当次授权范围执行。

## 6. 文档与认知维护

指南承载长期规则,基线承载当前事实;详细架构继续由现有技术文档负责,避免建立第二套相互冲突的架构规范。基线中的每个分支都有用途、提交差异、关联 PR 和建议;每条功能都有实现证据或明确的待验证/缺失说明。

原始网页、完整 GitHub 响应、运行日志、私人审阅材料留在仓库外;这两份文档是维护者明确要求交付的长期项目记录,只保留可公开的总结,不保存凭证或用户会话数据。

根 `AGENTS.md` 的 AOCI 托管块保持原样。工具可用时遵守其检查和维护流程;不可用时说明未完成索引维护,不手工修改 AOCI 资产,也不把源码阅读描述为完成了索引同步。
2 changes: 1 addition & 1 deletion packages/shared/src/logging/structured-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function getCallerLocation(): string | undefined {
const match = line.match(/at\s+(?:.+\s+\()?(.+):(\d+):(\d+)\)?$/);
if (!match) continue;

const rawPath = match[1]?.replace(/^file:\/\//, '');
const rawPath = match[1]?.replace(/^file:\/\//, '').replace(/\\/g, '/');
const lineNumber = match[2];
if (!rawPath || !lineNumber) continue;
if (rawPath.includes('/node_modules/') || rawPath.includes('/pino/')) continue;
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ highest number is the newest. ADR 0014 fixes the four internal boundaries; ADR 0
modules, application-owned lifetimes) and ADR 0017 (temporal ownership) describe the client as it
stands; ADR 0018 records the last ownership programme and the observation decision (whose evidence is
[`adr/observation-architecture.md`](adr/observation-architecture.md)). ADR 0010 sets the build
(esbuild artifact, Vite as dev server only); ADR 0011 lets the WebUI re-implement TUI projection
(esbuild artifact; its current-status note describes the single-port development entry); ADR 0011 lets the WebUI re-implement TUI projection
logic against a shared harness-event corpus. ADR 0019 records the accepted Browser Use surfaces and
the decisions and remaining design questions for Browser Use. ADR 0022 records the workspace panel as
a browser tab strip and the two selections it separates, and amends ADR 0019 with **A8**; between
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# The WebUI ships an esbuild artifact and takes Vite only as a development server

## Current status (2026-12-04)

The esbuild artifact remains the build contract. The current `pnpm dev:webui`
entry runs `predev` to build it, then serves the client and runtime on the same
listener (port `2233` by default). Client edits require a rebuild and restart.
The original Vite/HMR rationale below is historical; it does not describe the
current development entry. See [Run from source](../../README.md#run-from-source).

## Original decision

The WebUI's published artifact is produced by `scripts/build-webui.mjs` with esbuild, in the
shape ADR 0005 requires: `dist-webui/` with its own metafile, which
`scripts/check-webui-boundary.mjs` reads. Vite's role is limited to a development server for the
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/docs/architecture/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ nothing from `packages/tui` (ADR 0003) and does not drive the CLI binary (ADR 00
| ADR 0005 — artifacts build separately | `dist-webui/` has its own two entries and its own metafile; the CLI bundle never contains the server |
| ADR 0006 — one data directory | `~/.minimax` is shared with the CLI; the harness host is a scripted stand-in where a live `CliSession` would not be deterministic |
| ADR 0007 — additive changes | `release/public-source.json` lists every file; a new file is a publication decision, and moving a file costs a conflict at the next upstream sync |
| ADR 0010 — esbuild artifact, Vite as dev server | The shipped artefact is an esbuild build with its own metafile (the input the boundary check reads); Vite serves the dev client only, never the published one |
| ADR 0010 — esbuild artifact | The shipped artifact is an esbuild build with its own metafile (the input the boundary check reads); the current `pnpm dev:webui` entry rebuilds and serves that client with the runtime on one port |
| ADR 0011 — shared harness-event corpus | The WebUI may re-implement TUI projection logic locally; each re-implementation pairs with a corpus-backed regression test that the harness protocol change can update in the same cycle |
| ADR 0013 — editable harness code | `runtimeOwnerKind: "webui"` is a declared identity with its own policy row |
| ADR 0014 — four internal boundaries | Capability and orchestration are split inside both the client and the runtime; see §3 |
Expand Down
4 changes: 2 additions & 2 deletions packages/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"@types/ws": "8.18.1",
"autoprefixer": "10.6.2",
"postcss": "8.5.32",
"autoprefixer": "10.7.0",
"postcss": "8.5.33",
"postcss-import": "15.1.0",
"tailwindcss": "3.4.17",
"tsx": "4.23.15",
Expand Down
20 changes: 17 additions & 3 deletions packages/webui/test/browser/feedback.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,25 @@ test("the usage model-source menu uses the shared dropdown entrance and exit", a
.toBe("webui-dropdown-in");
await expect(menu.getByRole("menuitem")).toHaveCount(2);

// Record the 120ms exit in the page before dismissing. A busy test runner
// can resume after the popup has unmounted, when computed style is empty.
await menu.evaluate((element) => {
window.__webuiUsageSourceExit = null;
const observer = new MutationObserver(() => {
if (!element.classList.contains("is-leaving")) return;
window.__webuiUsageSourceExit = {
connected: element.isConnected,
animationName: getComputedStyle(element).animationName,
};
observer.disconnect();
});
observer.observe(element, { attributes: true, attributeFilter: ["class"] });
});
await page.keyboard.press("Escape");
await expect(menu).toHaveClass(/is-leaving/u);
await expect.poll(() => menu.evaluate((element) => getComputedStyle(element).animationName))
.toBe("webui-dropdown-out");
await expect(menu).toHaveCount(0);
// Read after removal deliberately: the evidence must outlive the surface.
await expect.poll(() => page.evaluate(() => window.__webuiUsageSourceExit))
.toEqual({ connected: true, animationName: "webui-dropdown-out" });

await page.getByRole("button", { name: "选择模型来源" }).click();
const reopenedMenu = page.getByRole("menu", { name: "选择模型来源" });
Expand Down
Loading
Loading