Skip to content

feat(trigger): owner 续轮支持 actorUnionId,单人白名单默认识别主人 - #3954

Merged
deepcoldy merged 2 commits into
deepcoldy:masterfrom
tongyihao1233:feat/trigger-owner-union-id
Nov 28, 2026
Merged

deepcoldy merged 2 commits into
deepcoldy:masterfrom
tongyihao1233:feat/trigger-owner-union-id

Conversation

@tongyihao1233

@tongyihao1233 tongyihao1233 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

背景

#3599 让本机 Dashboard 管理员可以在 /api/trigger 用 actor: "owner" 以 bot 主人身份续轮,但主人只认 bots.json 里显式配置的 ownerOpenId。多数个人部署的 bot 的 allowedUsers 只有一个人(写的是 on_ 或邮箱),没配 ownerOpenId 就全部 403 owner_unresolved。另外,同一个人在不同飞书应用下的 open_id 各不相同,客户端没法用跨应用稳定的 union_id 说明「我要以这个人的身份发」,也没法在 owner 是别人时被拒。

改了什么

主人认定(getStrictOwnerOpenId,同步纯函数)

  • 显式配置优先:ownerOpenId(ou_)或新增的 ownerUnionId(on_)。ownerUnionId 必须同时是 allowedUsers 条目,并经现有解析映射 rawAllowedUserResolution 落到本 app 的 ou_。显式主人必须仍在解析后的管理员名单内,两者都配时必须是同一人,否则视为无法认定,不会退回默认。
  • 未显式配置时:名单里所有原始条目都解析成功,且都指向同一个人(resolvedAllowedUsers 去重后恰好 1 人),这个人就是主人。名单为空、多人,或有条目没解析出来(可能是另一个人)时,不认定主人,返回 403 owner_unresolved。
  • 宽松版 getOwnerOpenId 保持「显式优先,否则取第一个 ou_」的旧语义,只是显式来源多了 ownerUnionId。这样 lark-cli --as user 的 owner fallback 和 owner actor 认的是同一个人。

请求字段 actorUnionId

  • 只能和 actor: "owner" 一起出现,格式为 on_…,否则 400 bad_request。非管理员通道(公开只读 token、H5、平台身份、webhook)带了这个字段,就和 actor/runAs 一样返回 403 actor_not_allowed。
  • 校验发生在幂等处理和派发之前:名单里有这个 on_ 条目时直接比对映射;声明了 ownerUnionId 而请求值不同时直接拒绝;其余情况用本 app 凭证查主人的 union_id(复用现有 resolveUnionIdFromOpenIdStrict)来比对。不是主人一律 403 owner_mismatch;查不到或暂时失败返回 403 owner_unresolved。
  • 幂等 hash 带上 actorUnionId,同一个 key 换了身份声明会判为冲突。
  • 派发前 deliverToExisting 会再复核一次主人,daemon 重启 / reattach 时的身份恢复(validateBeforeWrite)调用的也是同一个函数,所以中途改名单或改主人都会在发出前被拒。

路由与能力宣告

  • Dashboard 把带 actorUnionId 的请求转发到新的 IPC 路由 /api/trigger/owner-union(必须是宿主签名请求,并且必须带 actorUnionId)。旧 daemon 没有这条路由会返回 404,Dashboard 转成 503 daemon_upgrade_required。旧 daemon 的 validator 会原样放行未知字段,如果复用老路由,actorUnionId 这道限制会被静默忽略、照样以主人身份发出。这里沿用了 feat(trigger): API 任务触发支持指定工作目录与按指定用户身份执行 #3746 /api/trigger/host 的做法。
  • /api/trigger/owner 和 /api/trigger/host 这两个受信端点也会校验 actorUnionId。
  • GET /api/sessions/:id/turns 的 capabilities 改为 ["ownerActor", "ownerUnionId"]。
  • ownerUnionId 加进 CLONE_IDENTITY_KEYS,克隆 bot 时不会带上源 bot 的主人声明。
  • 文档:docs/session-turns.md、docs/lark-tool-identity.md、docs-site 中英文 bots.json 字段表、CHANGELOG。

影响面评估

  • 共用路径:bot-registry.ts(getOwnerOpenId / getStrictOwnerOpenId)、core/trigger-session.ts、core/dashboard-ipc-server.ts、dashboard/trigger-api.ts、services/trigger-types.ts。
  • 行为变化只影响 owner actor 回合(trg_owner_*):单人名单的 bot 从拒绝变为放行。普通 trigger、runAs、webhook 都不受影响,这些路径的测试全部通过。
  • getOwnerOpenId 只有在 bot 新配置了 ownerUnionId 时结果才会变;没配新字段的 bot 结果不变(已有单测覆盖)。
  • 与 CLI 种类、PTY/Tmux 后端无关:改动只涉及 daemon 入口的身份判定,worker 侧没有改。

测试验证

本机(Linux)实测:

命令 结果
bun run build(含 tsc、typecheck、audit:domains、dist / 嵌入资源审计) exit 0;[domain-audit] no private deployment hostnames found
git diff --check upstream/master..HEAD 无输出
npx vitest run --project unit test/owner-actor-strict-owner.test.ts(新增) 22 passed
npx vitest run --project unit test/trigger-session-root-message.test.ts 153 passed(含 #3599 原有 owner 用例)
#3599 涉及的全部测试文件 + 引用 owner 判定的测试(28 个文件) 1778 passed / 3 skipped
扩大回归集(test/trigger*、webhook-routes、plugin-webhook-routes、test-hygiene、session-turns、bot-config-editor、dashboard-clone-prefill、event-dispatcher、dashboard-ipc 等 52 个文件) 3012 passed,1 failed:event-dispatcher.test.ts「为慢插件先 ACK 再更新原卡片」

这条失败用例与本改动无关:它起一个慢插件子进程,靠 1000ms 挂钟截止来断言,对整机负载敏感。在不含本改动的 upstream/master 临时 worktree 上,同一条用例同样是 3 次里 1 败 2 过,本分支也是 3 次里 1 败 2 过。

本地 bun 为 1.3.11,比项目钉的 1.4.4 旧,构建时只告警、不拦截。上面的测试都通过 vitest 运行。

用例覆盖

  • 单人名单(on_ / 邮箱 / 字面 ou_)默认识别主人;不带 actorUnionId 放行,带本人 union 也放行;他人 union 返回 owner_mismatch,不派发。
  • 多人名单未显式指定:返回 owner_unresolved,即使带的是名单里某个人自己的 union 也拒绝。显式 ownerOpenId 或 ownerUnionId 匹配时放行,他人返回 owner_mismatch。
  • 显式主人已离开名单时不退回单人默认;ownerOpenId 与 ownerUnionId 冲突时拒绝;ownerUnionId 不在名单条目里时拒绝;格式非法的 ownerUnionId 被忽略。
  • 有条目没解析出来时不默认;解析后名单里出现没有任何条目对应的人时也不默认。
  • 主人以邮箱列名、需要查询 union_id 的路径:查到且相同则放行,不同返回 owner_mismatch;查不到或暂时失败返回 owner_unresolved;查询期间名单变化时拒绝派发。
  • Dashboard 边界:管理员 token 转发到 /api/trigger/owner-union;公开只读 token / H5 / 平台身份带 actorUnionId(不论有没有 actor)一律 403;缺 actor 或格式非法返回 400;旧 daemon 404 时返回 503 daemon_upgrade_required。
  • daemon IPC:/api/trigger/owner-union 未签名请求 401;签名但不带 actorUnionId 返回 403 actor_not_allowed;普通 /api/trigger 带 owner actor 返回 403。
  • capabilities 为 ["ownerActor", "ownerUnionId"]。

变异复验:逐个摘掉新增守卫后跑对应测试,10 处全部变红。这 10 处是:单人判定的「全部条目解析到同一人」检查、「去重后恰好一人」检查、trigger 入口的 union 校验、声明了 ownerUnionId 时直接判不匹配、显式主人冲突检查、IPC owner-union 必带字段检查、Dashboard 路由选择、validator 400 检查、非管理员通道的身份声明拦截、union 查询结果比对。

对抗复核(持久身份语义)

尝试交给独立上下文复核,但没有成功执行,所以下面的探针由实现者自己完成。每项都用真实组件跑出了复现序列:

  • 幂等重放:用同一个 turnIdempotencyKey,第一次用主人 union,结果 ok;换成他人 union 重放,得到 idempotency_conflict;同一 union 重放,得到 idempotent: true。worker 总共只收到 1 次派发。
  • 被拒的首次请求:他人 union 首次请求直接 owner_mismatch,0 次派发,key 没有被占用。
  • 人工中途干预:在解析发送者期间,管理员把名单改成两人并用 ownerUnionId 指定另一个人,结果 owner_unresolved,0 次派发;只往单人名单里加一个人,同样 owner_unresolved,0 次派发。
  • 重启 / reattach 恢复:恢复时复核调用的是同一个 getStrictOwnerOpenId,规则与触发时一致;名单在重启后变成多人时,恢复同样会被拒。
  • 没有发现需要修的问题。

🤖 Generated with Claude Code

配套客户端

Persona 侧:nwverse/persona#17691(设置「BotMux Owner Union ID」,探测到 ownerUnionId 时随 actor: "owner" 携带 actorUnionId,并把 403 owner_unresolved / owner_mismatch 原样转成清晰的拒收原因)。

- 管理员名单只有一个人(所有条目都解析到同一人)且未显式指定主人时,默认此人为主人;多人名单仍需显式指定,否则 403 owner_unresolved
- 新增 bots.json `ownerUnionId`(on_,须同时是 allowedUsers 条目),与 ownerOpenId 同时配置时必须是同一人
- `/api/trigger` 在 actor=owner 时接受可选 `actorUnionId`,不是该 bot 主人时 403 owner_mismatch;格式非法或缺 actor 时 400
- Dashboard 把带 actorUnionId 的请求转发到新的 `/api/trigger/owner-union`,旧 daemon 404 时返回 daemon_upgrade_required,不会静默忽略该字段
- 会话 turns 的 capabilities 新增 ownerUnionId

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论(head 680802f0)

发现 1 个需要修复的正确性问题,建议修复后再合入。除下述 core-only 边界外,未发现有待阻断的改动。

[P2] apiOnly bot 带 actorUnionId 时抛出 500,而不是受控拒绝

位置:src/core/trigger-session.ts:992(src/im/lark/client.ts:699 是异常冒泡点)。

当 core-only(apiOnly: true)bot 以单个字面 ou_ 条目配置 allowedUsers 时,getStrictOwnerOpenId 可以认定主人,ownerUnionIdVerdict 随后返回 lookup。refuseOtherUnionId 调用 resolveUnionIdFromOpenIdStrict,但后者在进入自己的 try 之前执行 getBotClient;core-only bot 因此抛出 LarkTransportDisabledError。该异常穿过 triggerSessionTurn,最终由 IPC 外层转成 500 trigger_failed,而不是契约内的 403 owner_unresolved。

已在围栏内用真实 triggerSessionTurn 复现:

{"outcome":"threw","name":"LarkTransportDisabledError","message":"Feishu transport is disabled for core-only bot local_pr3954_probe (attempted: getBotClient)"}

同一请求去掉 actorUnionId 的对照组正常返回结构化错误,没有抛异常:

{"outcome":"control-returned","result":{"ok":false,"errorCode":"bad_request","error":"apiOnly bot requires an HTTP response mode (waitForFinalOutput or asyncReturnSessionId)"}}

建议将 strict lookup 的 client 构造纳入异常分类,或在该调用边界显式接住 transport-disabled 并返回 owner_unresolved;同时补一条从 trigger 入口进入的 apiOnly + actorUnionId 回归用例,断言不抛出、不派发且返回受控 403。

本地验证

运行时为项目钉版 Bun 1.4.4:

  • bun run build:通过,含 typecheck、domain / dist / embedded-assets 审计。
  • PR 直接改动的 5 个测试文件:688 passed / 3 skipped。
  • owner 身份恢复、turn CLI 身份、Webhook、bot 配置编辑/克隆等关联回归:255 passed。
  • git diff --check:通过;复审后工作区干净。

CI 状态核对

当前唯一代码测试红项仍是 bun-test (4/4) 的 test/loopback-fetch.test.ts 未处理 ECONNRESET,与开放的 #3287 现象一致;本 PR 未触碰该文件。其余 vitest 分片、build、三平台 bun-binary、network-boundary 均绿。该检查目前尚未重跑成功,合并闸仍需按项目流程处理。

在 union_id 查询边界仅将 LarkTransportDisabledError 转为 owner_unresolved,其它异常继续抛出。补充 typed、跨模块副本与未知异常的入口回归。

Co-Authored-By: Claude Code <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner

P2 修复已追加提交并推送:380762fea266e2633dde54274b8b0ac5ce2cf089(普通 non-force push,父提交为 680802f0d7)。

修复内容

  • src/core/trigger-session.ts:仅在 refuseOtherUnionId 的查询边界捕获 LarkTransportDisabledError,兼容真实类型与跨模块副本的 error.name,返回 owner_unresolved;其它异常继续原样抛出,共享 strict lookup 原语未改。
  • test/trigger-session-root-message.test.ts:新增 3 条 trigger 入口回归,分别覆盖 typed error、跨模块 name 形态和未知异常响度;前两条断言受控拒绝且 0 派发,后一条断言原异常继续抛出且 0 派发。

验证结果

  • 修前定向复验:新增用例 2 failed / 1 passed,失败均为原 LarkTransportDisabledError。
  • 修后定向复验:3 passed。
  • 真实 strict lookup 的 fenced-run 探针:原 apiOnly + actorUnionId 场景现返回 {"ok":false,"errorCode":"owner_unresolved"},不再抛异常。
  • 相关 5 个测试文件:691 passed / 3 skipped。
  • bun run build:通过,含 typecheck、domain / dist / embedded-assets 审计。
  • git diff --check:通过。

tongyihao1233 added a commit to tongyihao1233/persona that referenced this pull request Nov 28, 2026
Refs nwverse#17649

botmux answers 403 with {ok:false, errorCode:"owner_mismatch", error:"<words>"} (deepcoldy/botmux#3954): the node
read the code from error, so a real refusal still looked like a stale token. It now reads errorCode, falling back to a
bare code in error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner

#109 合并树背书:可合(绑定 master 2b0a14fd)

原指定组合 3ca92fd1 × 380762fe 已复算,预测 tree 确为 c0bd77c1018e0084bc763e8bf36129f0d80be3aa。观测期间 master 又加入 #3962,因此同时补算并验证了当前实际合并目标:

merge-base: ac56aaf7f4b0540014389606272ca5518f248a37
master:     2b0a14fdb24e6c9faf5a1733bba13d55ac5e7b2a
PR head:    380762fea266e2633dde54274b8b0ac5ce2cf089
merge-tree: bf514666e5d7a9c3334d640fa56e23066d58a6bc

结构与内容复核

  • git merge-tree --write-tree 2b0a14fd 380762fe 成功,无冲突清单。
  • PR 与 master 相对共同基线的文件交集仍只有 src/core/dashboard-ipc-server.ts。
  • c0bd77c..bf514666 之间仅有 fix(worker): deferred 定时输入只在所有权校验后做写入准备,退休条目不留幽灵 active turn #3962 的 src/worker.ts 与 test/worker-scheduled-deferred-retain.test.ts 增量,不触碰本 PR 文件。
  • 最新 tree 中两侧关键内容共存:lastStatus 的 'deferred' 联合在 dashboard-ipc-server.ts:9426,/api/trigger/owner-union 在同文件 :10483,core-only transport catch 在 trigger-session.ts:1000。
  • package.json、bun.lock、.github 无合并增量,验证复用未变依赖,不执行 install。

最新 tree 实测

结论:满足 #109 窄例外,可不同步 master 直接 squash。 背书绑定上述 master/tree;若实际 squash 前 master 再前进,应按新 tip 重新计算,不能沿用本 tree OID。不发版、不部署。

@deepcoldy
deepcoldy merged commit d024ea3 into deepcoldy:master Nov 28, 2026
27 of 29 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner

已合并,感谢贡献!

评审与验证小结

  • 主人认定重写(显式 ownerOpenId/ownerUnionId 优先,否则单人白名单且全部条目解析到同一人才认定主人)、actorUnionId 校验、新 IPC 路由 /api/trigger/owner-union 的混合版本 fail-closed、turn 幂等 hash 纳入身份声明,整体设计与现有 trigger 鉴权边界一致。
  • 复审中发现并修复了一个 core-only(apiOnly)边界:带 actorUnionId 且需要查询 union_id 时,getBotClient 在异常分类之前抛出 LarkTransportDisabledError,会冒泡成 500;现已在查询边界受控转换为 403 owner_unresolved,其它异常仍照常抛出,并补了 typed error、跨模块副本、未知异常响度三条入口回归。
  • 验证:typecheck/build 通过;相关 691 单测 + 合并树定向 819 单测全绿;身份判定、边缘鉴权、IPC 守卫、幂等等关键守卫的变异复验均能咬红。

非阻断 follow-up(不影响本次合入)

  • bot-config-editor 的克隆身份键测试目前没有 ownerUnionId 的逐键断言(与既有 ownerOpenId 一样依赖声明式数组的通用覆盖);克隆时该字段的剥离/保留行为已手动验证正确,后续可补一条专门断言更稳。

本次为自动评审,最终以维护者审阅为准。欢迎继续贡献。

chyroc pushed a commit to nwverse/persona that referenced this pull request Nov 28, 2026
…on suggestions and worded owner refusals (#17691)

Fixes #17649

Companion BotMux change: deepcoldy/botmux#3954 (`actorUnionId`, the `ownerUnionId` capability, 403 `owner_unresolved` / `owner_mismatch`). This PR works with any BotMux: without that change the node sends `actor: "owner"` alone, and before 3.59.23 it sends the plain external trigger.

## What changed and why

#10770 sent every botmux turn as `actor: "owner"` whenever BotMux advertised `ownerActor`. Persona never said whose turn that was, and a BotMux owner refusal looked like an expired token. This PR makes the owner an explicit, hub-wide choice.

- **Setting (manager, `server/internal/assistant/agents_display.go`, `agents_botmux_owner.go`).** Agents display settings gain `botmux_owner_union_id`, stored as `agents.botmux_owner_union_id` beside `show_botmux`. On save the value is trimmed and checked with `proto.ParseBotmuxOwnerUnionID` (`^on_[A-Za-z0-9_-]+$`, at most 128 bytes); `""` clears it, anything else is a 400, and only full access may save. A save hands the value to every computer online with `node.configure {"botmux_owner_union_id"}`; each push sends what is stored when it goes out, so the last of two quick saves wins. Every new connection also gets it through `nodeConnectCalls`. Another manager reads it through `agents.display.get`, and when that read fails the node is handed nothing, so a failed read can never clear the node's value.
- **Suggestions, never silent (`node/hostbotmux_owner.go`, `GET /api/v1/agents/botmux-owner-candidates`).** The new read-only node method `botmux.owner_candidates` is registered through `nodeRPC`. It reads the bots.json BotMux loads (`BOTS_CONFIG`, else `~/.botmux/bots.json`, at most 8 MiB) and decodes only `ownerUnionId` and `allowedUsers`. It returns deduplicated `on_…` ids, the ids that are a bot's only person first. It never returns secrets, tokens, open_ids, e-mail addresses or the path, and it writes nothing. The manager asks every computer online, waits at most 3 s, merges the answers, and lets only full access read them. Nothing is saved by the suggestion.
- **Sending (`node/hostbotmux.go`, `hostbotmux_turns.go`).** The node keeps the id in memory and hands it to the botmux host, including a host made later (`syncBotmuxOwner`).

  | Owner Union ID | capabilities | `/api/trigger` | composer |
  | --- | --- | --- | --- |
  | empty | any | external trigger, no `actor` | `botmux_external_trigger_reason: "owner_unset"` |
  | `on_…` | `ownerActor` + `ownerUnionId` | `actor: "owner"` + `actorUnionId` | — |
  | `on_…` | `ownerActor` only | `actor: "owner"` (no unknown field for that BotMux) | — |
  | any | neither | external trigger | `"upgrade"` (the existing 3.59.23+ notice) |

- **Clear refusals (`node/sendsafe.go`, `apierr`, `devices/held.go`).** A 403 whose `errorCode` (or bare `error`) is `owner_…` is no longer treated as a stale token, so the node does not refresh the token or retry. It becomes `not_delivered` with `delivered: "none"` and a reason: `botmux_owner_unresolved`, `botmux_owner_mismatch`, or `botmux_owner_refused` for any other `owner_…` code. The hub words the reason in the viewer's language, in en / zh-Hans / ja, held messages included. A 403 without an owner code is still refreshed and retried once, as before.
- **Session wire (`proto`).** `botmux_external_trigger_reason` is stored sparsely on `SessionHierarchy`, so `TestSessionFitsItsSizeClass` still holds. The hand-written encoder writes it (new `hierarchyWireLayout`), and the list key includes the reason, so a change is pushed.
- **Web (`views/settings/BotmuxOwnerField.tsx`, lazy).** Under **Show botmux sessions in Agents** (only while it is on, and only from a hub that sends the field) there is a text field with Save and Clear, a format check before sending, and **Use suggestion**, which only fills the field. The words explain what the setting does and where to find the id. `AgentStatusLine` picks the composer line by reason. The decoded and raw botmux display and the botmux chip are unchanged and do not read the setting.
- **Docs.** `docs/protocol/protocol.md` ("Agents display settings", "BotMux messages"), `docs/integrations/engines.md` ("botmux"), `docs/web/web.md` ("Shared botmux visibility"). The mock hub serves the setting and a made-up candidate for screenshots.

## Verification

Run on Linux at `cb1803f804` (merged with `upstream/main` `8dfd576f87`), unless noted.

- Go
  - `go build ./...` and `go vet` on `proto`, `transcript`, `node`, `assistant`, `assistantwire`, `apierr`, `devices`, `hub` and `i18n`: clean.
  - `go test -race -run 'TestBotmux|TestToolView' ./internal/node/`: ok. New tests:
    - `TestBotmuxOwnerUnsetSendsExternalTrigger`
    - `TestBotmuxOwnerUnionIDNeedsItsCapability`
    - `TestBotmuxOwnerRefusalIsClearAndNotRetried`: one POST, no token refresh; a plain 403 is still retried once.
    - `TestBotmuxTriggerAnswerCode`
    - `TestBotmuxOwnerConfigure`
    - `TestBotmuxOwnerCandidatesScan`: no secret, open_id, e-mail address or path in the answer, and the file is unchanged.
    - `TestBotmuxOwnerCandidatesMethod`
    - `TestBotmuxBotsPath`

    The #10770 owner tests were updated to set an owner id.
  - `go test -race -run 'TestBotmuxOwner|TestAgentsDisplay|TestAgyIdleCompact' ./internal/assistant/`: ok. New tests:
    - `TestBotmuxOwnerUnionIDSetting`: validation, roles, push to online computers only, clearing.
    - `TestBotmuxOwnerUnionIDOnConnect`: own value, shared value, and a failed read hands nothing.
    - `TestBotmuxOwnerCandidates`: merge, invalid ids dropped, older or offline nodes, full access only, nothing saved.
  - `go test -race ./internal/proto/ ./internal/transcript/`: ok, including `TestSessionWireMatchesReflect`, `TestSessionFitsItsSizeClass`, `TestSessionBotmuxExternalTriggerWire` and `TestParseBotmuxOwnerUnionID`. `go test -race -run 'Held|Localize|Bridge' ./internal/devices/ ./internal/apierr/`: ok.
  - `route_scopes`: `PERSONA_UPDATE_ROUTE_SCOPES=1` adds one row, `- GET /api/v1/agents/botmux-owner-candidates` (full credentials only). `TestRouteScopes` and the hub architecture guard pass.
  - Domain model: `go test ./internal/archguard/` gives the same rule lines on this branch and on clean `upstream/main` (`diff` empty, 28 lines). Its failures (`TestCentralListsTakeNoNewName`, `TestDomainHookScope`, `TestDomainLayers`) are pre-existing. The first version of this branch added a `handleMethod` case; that was moved to a `nodeRPC` registration.
  - Full packages `./internal/node/`, `./internal/assistant/` and `./internal/devices/` on this machine: 8, 20 and 4 failures. Rerun with the same `-run` on clean `upstream/main`, they are the identical sets (tmux/worktree/git-environment tests, prompt goldens). `./internal/i18n` `TestHardcodedChineseBaseline` fails on files this PR does not touch (`assistant/attachments.go`, `memory_entity.go`, `title_guard.go`, `extension/source.go`), which came from `upstream/main`.
- Web
  - `npx tsc -b` and `npm run lint`: pass.
  - `npx vitest run src/views/settings/BotmuxOwnerField.test.tsx src/lib/agents-display.test.tsx src/views/chat/botmux-messages.test.tsx src/i18n`: 17 files, 98 tests passed.
  - Before the merge, `src/views/settings/` plus the botmux, agents-display, status-line and i18n suites: 172 of 173 files passed. The failure is `Labs.test.tsx`, which fails identically on clean `upstream/main`.
  - `npm run build` after the merge: `first screen en 485,034 B, ja 487,522 B, zh-Hans 486,044 B; 164 B left under FIRST_SCREEN_BUDGET (ja)`. The field and its words are in the lazy Settings chunk. Before the merge, the same build left 691–733 B against 152 B on `main`, so the first screen did not grow.
- Repository checks
  - `git diff --check upstream/main..HEAD`: clean.
  - `python3 scripts/privacy_check.py` and `--range upstream/main..HEAD`: clean.
  - `python3 scripts/ci/wire_types_ratchet.py --base upstream/main`: none above the baseline (new ids are the named `proto.BotmuxOwnerUnionID`).
  - `test_doc_paths`, `test_doc_go_paths` and `test_doc_wire`: OK.
  - `test_doc_sections` fails only on `ExecutionChannelsCard.tsx` / `RuntimesCard.tsx` "Engines and channels", which is the same on clean `upstream/main`.
  - `web_font_ratchet.py` fails only on `web/src/views/session/files/empty.tsx`, the same on `upstream/main`; this PR adds no px font sizes.
  - `scripts/mock/test_mock_hub.py` fails only on the pre-existing `MOCK_BOT_GROUP`; this PR adds no `MOCK_*` switch.
- Not run: the full web suite (`npm test`), Apple / Android / HarmonyOS / Desktop builds, hosted CI, and a live BotMux end to end (the BotMux side is the open #3954, so the 403 shape was checked against its diff).

Screenshots are synthetic mock hub data, `vite preview` of this branch, 1280×900. Not taken at the largest text size.

| | light | dark |
| --- | --- | --- |
| Suggestion found, nothing set | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/en-light-1-suggestion.png) | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/en-dark-1-suggestion.png) |
| Suggestion filled (not saved) | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/en-light-2-filled.png) | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/en-dark-2-filled.png) |
| Saved (Clear appears) | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/en-light-3-saved.png) | |
| zh-Hans, and a value that is not a union_id | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/zh-light-1-suggestion.png) | ![](https://raw.githubusercontent.com/tongyihao1233/persona/5211589f984b7431f8e024dda255b965095ac1f0/zh-light-4-invalid.png) (light) |

## Apple performance

Not applicable (no `apple/` changes).

## Design principles self-check

- [x] 1 Defaults first: with nothing set, BotMux messages go the usual way, and the composer says so in one line. Fresh installs behave as before for older BotMux. Evidence: `TestBotmuxOwnerUnsetSendsExternalTrigger` and the web notice test.
- [x] 2 Progressive disclosure: the field appears only under **Show botmux sessions in Agents** while it is on, is lazy-loaded, and the first screen did not grow. Evidence: `BotmuxOwnerField.test.tsx` and the build output above.
- [x] 3 User control: the value is visible, saved explicitly, and cleared with one button; a suggestion only fills the field. Evidence: `BotmuxOwnerField.test.tsx` and `TestBotmuxOwnerCandidates`.
- [x] 4 Consistency first: reuses `Row`, `SettingsHint`, `settingsInputClass`, `Button`, the display-settings store and the existing composer notice line. No new component or token, so `DESIGN_SYSTEM.md` is unchanged.
- [x] 5 Model and product separate: touches features only (who BotMux sends speak for). Speed, model and presentation are unaffected; decoding and the botmux chip do not read the setting.
- [x] 6 Checkable: each acceptance item in #17649 is backed by the tests named above.
- [x] 7 Fast, local-first and stateful: saving shows **Saving…** at once, and the answer is the hub's stored value. A failed save keeps the draft and shows the existing retry row. Owner refusals arrive with `delivered: "none"`, so they are safe to resend after fixing.
- [x] Other platforms: not applicable here. iOS and Android do not read `botmux_external_trigger` today, and older clients keep the boolean.
- [x] Parity list row updated: not applicable (no parity row for BotMux).

UI change self-check (rules):
- Only tokens and design-system components; the token and font ratchets did not go up for these files.
- Existing styles are unchanged.
- Every control has a spoken label (`aria-label` on the field; buttons have text), and the format error is an `alert`.
- Clearing is reversible, since the value can be entered again, so there is no confirmation.
- New copy is in en, zh-Hans and ja.
- Screenshots are shown here in light and dark, not committed. Deviation: no largest-text-size capture.
- No new problem of a kind listed in `HIG_AUDIT.md`.
- Primary screens show no raw ids except the setting's own value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@github-actions

Copy link
Copy Markdown

🚀 Released in v3.59.37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants