Repository navigation
feat(approval): 审批卡片 1/2/3 快捷键、记住作用域、拒绝说明与改动预览 - #1098
Merged
AlphaCatMeow merged 1 commit intoNov 1, 2026
Merged
Conversation
- 1/回车允许本次;2 允许并记住,卡片写明规则,可选本会话/本项目/所有项目, 默认取后端建议;3 展开拒绝说明,回车连同说明拒绝。Esc 在说明框里只收起。 可编辑控件里的数字键与输入法上屏回车不触发快捷键。 - 命令完整显示、多行可滚动。 - Edit/Write 显示 diff:未超 4000 字显示全文;超了先按行、再按字符聚焦到改动处, 仍超就分开显示原内容和新内容。桌面算好后经 __toolApprovalPreview 同步给 WebUI。 - K-brain 回 400 后重新弹出的审批写明原因(__toolApprovalNotice)。 - 同步给 Gateway 的工具参数先删掉模型自带的审批合成键,防止伪造 WebUI 审批卡片。 Closes Stack-Cairn#1097 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 1, 2026
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.
LA-2a(#1094)已经把 K-brain 的记住规则、默认作用域和拒绝说明接到了客户端,但审批卡片还没有用上这些数据。本 PR 是 LA-2b,在审批卡片上把它们用起来:按键 1/2/3、选择记住的作用域、填写拒绝说明,并预览完整命令和文件改动。
Closes #1097
Depends-On: none
Stack-Root: #1098
改动
suggestion.default_scope。后端没有建议规则时,2 走原来的"本会话始终允许"(不带 scope)。deny+reason)。在输入框里按 Esc 只收起输入框,在卡片上按 Esc 直接拒绝。keyCode 229,WebKit 的事件顺序)不会提交,复用了isImeKeyboardEvent,并把它的参数类型放宽到KeyboardEvent<Element>。EditDiffView显示 diff(approvalPreviewFromToolCall)。__toolApprovalPreview同步给 WebUI,只有 Edit/Write 才接受,并会校验数据格式、重新限制长度。没有这份预览时,WebUI 退回到 Gateway 截断过的参数副本;Edit 只要有一边被截断,就分开显示两块。turn.ts把错误信息作为onPermissionRequest的第三个参数传进来,卡片显示"上次没能记住:<原因>",同时通过__toolApprovalNotice同步给 WebUI。__toolApprovalPending等),借此在 WebUI 上伪造审批卡片、diff 和提示。新增TOOL_APPROVAL_SYNTHETIC_ARG_KEYS和withoutApprovalSyntheticArgs:同步给 Gateway 之前,先删掉模型参数里的这些键。builder 和 K-brain 回合的第一条 tool_call 事件都会经过这一步。LA-2a 加的那几个标记也一并受到保护。DISPLAY_SYNTHETIC_ARG_KEYS,不会出现在参数展示里。契约面
preview/notice;onPermissionRequest(request, signal, refusal?)__toolApprovalPreview、__toolApprovalNotice;同步前删掉模型参数里的同名合成键;chatRuntimeSnapshot走同一个 builderpendingToolApprovalFromToolCall取得 preview/notice,用同一个卡片组件截图(调试版真实客户端)
桌面 1280,Edit diff,拒绝说明已展开:

桌面 480,Edit diff 与作用域选择:

WebUI 1280,Write 预览与拒绝说明:

WebUI 480:

验证
typecheck:ui/typecheck:gui/typecheck:webui通过;改动文件转 LF 后biome check --line-ending=lf通过;node scripts/check-mirror.mjs通过;git diff --check通过。chat/tool-approval-card:真实ToolApprovalBar,覆盖按键、作用域、拒绝说明、命令、diff、split、提示和 emoji 截断。改动前 10 条里有 9 条失败。chat/tool-approval-card-wiring:真实 K-brain 回合加 HTTP/SSE fixture,覆盖 400 后提示在桌面和 WebUI 都显示、Edit 预览、WebUI 截断预览。改动前 2 条都失败。review-la2b-approval-card*.test.mjs(r1–r4)都保留在 PR 里。审批相关测试共 84 条,全部通过。la-full-tests.mjs,8 个批次全部跑完):共 4349 条,通过 4345,失败 3,跳过 1。3 条失败都在已知环境问题清单里:Rust 测试第一次编译超过 180 秒上限;另外两条按当前目录的相对路径读源码,在crates/agent-gui下重跑通过。之后只改了capPreviewText的 emoji 边界,改完重跑了相关测试和三项 typecheck,都通过。node -e "console.log(21*2)":按 2 选"本项目"后,规则写入项目规则文件;新开会话再运行同一条命令,不再询问,显示"按规则允许"。测试用的规则已经清理掉。package.json:1280 和 480 宽度下 diff 都显示 +1 −1。在拒绝说明框里按 Esc 只收起输入框,再按一次 Esc 才拒绝;文件没有改动。RUST_MIN_STACK=16777216后不再出现。这个问题另行跟进。🤖 Generated with Claude Code