Skip to content

fix(permission): 在 Claude 桌面版里答过的权限请求,卡片不再挂到这一轮结束 - #389

Merged
wxtsky merged 2 commits into
wxtsky:mainfrom
Junyu06:fix/claude-desktop-answered-permission
Oct 28, 2026
Merged

wxtsky merged 2 commits into
wxtsky:mainfrom
Junyu06:fix/claude-desktop-answered-permission

Conversation

@Junyu06

@Junyu06 Junyu06 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

在 Claude 桌面版里答过 propose_branch(问改动放哪个分支)之后,刘海上的「待处理」卡要等这一轮结束才消失。答完以后,这次调用结束时的 tool_input 跟请求里的不一样了,同一个调用的 PostToolUse 就对不上请求(#216 要求输入相同)。

相关:#388

改了什么

拿这次调用在 PreToolUse 时的输入(按 tool_use_id 记在 pendingToolUses 里)跟请求比,对上了就算同一个调用。agent 和工具名照旧要相同。

验证

  • 新增 2 个测试,复现的那个改之前失败、改之后通过;全量 swift test 只有 main 上本来就失败的 CodexTmuxRoutingTests.testProbeAgainstIsolatedTmuxServer。
  • 在桌面版里答一次 propose_branch:1.0.40 上卡片留到下一条消息才消失,这个分支上答完就消失。

Junyu06 and others added 2 commits October 27, 2026 23:05
…all finishes

Claude Code's PermissionRequest carries no tool_use_id, so its card is
taken down by a later step of the agent that asked (wxtsky#216), and a step
naming a tool call must have the request's tool name and input (wxtsky#147).
Answered in the Claude app, a propose_branch request outlived its own
call's PostToolUse and was dropped two minutes later by the next
UserPromptSubmit. With the same agent and tool, only the input can have
differed: the call finishes with other input than it was asked with
(the tool's schema keeps `_setupAnswer` for the app).

The call's PreToolUse carries its tool_use_id and the input it was asked
with, and the PostToolUse names the same id. A step now counts as the
request's call when either its own input or that PreToolUse's input is
the request's. The agent and tool name must still match, and the request
is still answered with no decision. resolveOrphanPermissionsOnActivity
runs before resolveToolUseIfCompleted, which forgets the PreToolUse once
the call is done; the two take disjoint requests (without and with a
tool_use_id).
…lUse past the cache TTL

A request with no tool_use_id is now matched to its call through the
input that call's PreToolUse recorded, but the cleanup tick forgets
PreToolUse records 15 minutes after they arrive, whether or not a
request still waits on that call. Answered in the Claude app after more
than 15 minutes, propose_branch's card again outlived its call's
PostToolUse and stayed until the next prompt or the end of the turn.

A card's records now stay while a request without a tool_use_id waits
in it; once nothing waits there, the next tick prunes them as before.
Records of other cards are pruned on the same 15-minute TTL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wxtsky
wxtsky merged commit e130971 into wxtsky:main Oct 28, 2026
wxtsky added a commit that referenced this pull request Oct 28, 2026
… idle removal and more

Unreleased notes for this round: the island's 20 fps clock (#381, #391),
"Always allow" holding in its session and Codex rules Codex can use
(#380), shortcuts and pinned displays with a second monitor (#384), pi
and Oh My Pi ringing once a task (#386), the Claude Desktop answer and
background compaction fixes (#389, #388), removing idle cards (#385),
the Codex Desktop thread jump (#387), the DeepSeek whale (#390) and the
Grok / DeepSeek Harness sections in Group by CLI.

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

wxtsky commented Oct 28, 2026

Copy link
Copy Markdown
Owner

感谢 @Junyu06!定位很准:Claude Code 的 PermissionRequest 不带 tool_use_id。在桌面版里答完 propose_branch 后,PostToolUse 的 tool_input 多了应用填进去的 _setupAnswer,原来的严格比对就对不上了。现在用 PreToolUse 按 tool_use_id 记下的输入来认"同一个调用",agent 和工具名仍要相同,撤卡仍只回 {}、不替用户做决定,信任边界没有放宽。

我在你的提交上面加了一个维护者提交(6c61531):

  • PreToolUse 记录原本到 15 分钟就会被定时清理,不管还有没有请求在等它。在桌面版里隔了 15 分钟以上才回答,卡片又会挂到下一条消息或这一轮结束。现在只要这张卡上还有不带 tool_use_id 的请求在等,它的记录就保留;没有请求在等的照旧清掉。附了测试。

单独跑全量测试、和这次其他改动合在一起跑全量测试,都通过了。已 squash 合并,会随下个版本发布。

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