Repository navigation
fix(tui): queue concurrent permission requests - #885
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
No blocking code findings on the current head.
GitHub currently reports merge conflicts around the newer generic interaction queue and permission handling. Please preserve those main-branch behaviors during the rebase; the resolved diff may need another look.
f5be57e to
92a9377
Compare
English@Astro-Han The conflict resolution for this PR has been pushed. The resolved diff stays on top of the newer generic interaction queue rather than restoring a permission-only slot or parallel queue. It adds permission-specific identity and lifecycle handling within that shared structure: request-ID deduplication, authoritative dequeue by acknowledgement or terminal event, and in-flight response fencing until Runtime advances the request. The existing The rebased head is mergeable, and typecheck, test, and e2e CI are green. I also updated the PR description to reflect the post-conflict design. 简体中文@Astro-Han 该 PR 的冲突解决已经推送。 解决后的 diff 继续建立在较新的通用 interaction queue 上,没有恢复 permission-only 槽或引入平行队列。它只在共享结构内补充 permission 所需的身份与生命周期处理:按 request ID 去重、由 acknowledgement 或 terminal event 权威出队,以及在 Runtime 推进请求前保持 response in-flight fence。既有 Rebase 后的 head 可合并,typecheck、test 与 e2e CI 均已通过。我也更新了 PR 描述,使其反映冲突解决后的设计。 |
English
Follow-up to #856.
Summary
AskUserQuestion.permission_decision_ack, a matching terminaltool_result, or turn termination advance permission state; completingrespondToPermission()alone does not.Why
Runtime may park more than one tool call at the permission boundary. The shared interaction queue provides the right common structure for permission requests and user questions, but permission lifecycle edges still need precise identity and terminal cleanup so overlapping or replayed events cannot lose or duplicate an actionable request.
The response API has a second timing boundary: its Promise confirms that a response was submitted, not that Runtime has committed the decision. Advancing locally at that point can expose a stale sibling request that Runtime already resolved through turn memory. The event stream is the authoritative lifecycle source for both cases.
Key decisions
requestId.AskUserQuestiondoes not need a parallel queue.requestId, including out of order.toolUseId.Scope
Included:
AskUserQuestioninteractionNot included:
WriteStdin-specific behavior, inspection UI, or runtime contractsVerification
npm run typecheck,npm test, andnpm run buildpassed.git diff --check upstream/main...HEADpassed.No visual artifact is included because the existing prompt layout is unchanged; the user-visible difference occurs only when permission events overlap, and that lifecycle is covered through the real TUI runner surface.
Impact
Concurrent TUI permission requests can no longer disappear, duplicate, or be answered before Runtime advances them. Ordinary single-request prompts retain the same keys and presentation, and user-question interactions continue through the same generic queue.
There is no schema migration, dependency change, compatibility layer, documentation requirement, or release-note impact.
Reviewer notes
The highest-value review boundaries are:
pi-transcript.ts: shared interaction identity, permission-specific terminal cleanup, and duplicate suppression.pi-tui-runner.ts: response in-flight state versus authoritative event-driven dequeue.Ready for review
简体中文
#856 的后续改进。
摘要
AskUserQuestion既有的共享队列与 overlay 行为。permission_decision_ack、匹配的 terminaltool_result或 turn 终止才能推进 permission 状态;respondToPermission()自身完成不能推进。原因
Runtime 可能在权限边界同时 park 多个工具调用。共享 interaction queue 是 permission request 与 user question 的正确通用结构,但 permission 生命周期边界仍需精确的身份与 terminal cleanup,避免重叠或重放事件丢失请求或制造重复的可操作项。
Response API 还有第二个时序边界:它的 Promise 只确认响应已经提交,并不代表 Runtime 已经提交决策。如果此时由本地提前推进,TUI 可能展示一条已被 Runtime 通过 turn memory 自动处理的 stale sibling request。两种情况下都应以 event stream 作为权威生命周期来源。
关键决策
requestId去重。AskUserQuestion也不需要另一套队列。requestId删除 ack,包括乱序 ack。toolUseId删除 terminal tool result。范围
包含:
AskUserQuestioninteraction 的交错不包含:
WriteStdin专用行为、检查 UI 或 runtime contract验证
npm run typecheck、npm test与npm run build通过。git diff --check upstream/main...HEAD通过。现有 permission prompt 布局没有变化,因此不附视觉 artifact;用户可见差异只发生在 permission event 重叠时,该生命周期已通过真实 TUI runner surface 覆盖。
影响
并发 TUI permission request 不再丢失、重复,也不能在 Runtime 推进前被提前回答。普通单请求 prompt 的按键和展示保持不变,user-question interaction 继续使用同一通用队列。
本次没有 schema migration、依赖变更、兼容层、文档要求或 release-note 影响。
审查重点
最值得审查的边界是:
pi-transcript.ts:共享 interaction 身份、permission 专用 terminal cleanup 与重复抑制。pi-tui-runner.ts:response in-flight 状态与由权威事件驱动的出队。可供审查