feat(web): expose Pi-native turn cancellation - #358
Closed
seekskyworld wants to merge 2 commits into
Closed
Conversation
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
tt-a1i
requested changes
Sep 4, 2026
tt-a1i
left a comment
Collaborator
There was a problem hiding this comment.
需要改:用 abort() 返回值当取消完成
interruptTurn 在 await abort() 之后立刻发 prompt_cancelled 并返回 cancelled,没有等 Pi 的 stopReason: "aborted"。这是从调用结果推断完成,违反「不要从标签/调用返回值推断完成」。
另外没有 commandId / epoch:同一 session 上,过期客户端可以取消更新的 turn。preparing/queued 走 already_settled no-op。
同 issue 的 #385 才是 turn 范围的回执(sessionId+commandId+epoch,等 turn_settled)。请关掉本 PR,或 rebase 成那份合同。不要再叠 #357 的 capability-intent 改动。
This was referenced Sep 4, 2026
tt-a1i
added a commit
that referenced
this pull request
Sep 7, 2026
…utions (#439) Restore the clipboard fallback from #352 in React with honest failure feedback, focus and selection restoration, and cleanup. Keep current exact-turn cancellation and request deadlines, and add timeout regression coverage inspired by #377. Credit the original #352, #377, and #358 contributions in README. Closes #438 Co-authored-by: QuinnWan <144975606+somewan820@users.noreply.github.com> Co-authored-by: seekskyworld <djh1813553759@gmail.com>
Collaborator
|
Pi-native cancellation is implemented on main with exact session, command, and epoch targeting. #439 records this proposal and credits seekskyworld in README and as a recognized co-author of main commit 41c59d4. The unrelated capability-intent change remains tracked separately in #357. Closing the overlapping session-only cancellation implementation. |
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.
Problem
Implements the first runtime slice of #342. The Web host had no per-turn cancellation endpoint and could only abort sessions during host disposal.
Value
A browser client can request cancellation without tearing down unrelated Web runtime state, while stale Session requests are rejected.
Approach
Add an optional
interruptTurncontroller seam backed by PiAgentSession.abort(). Bind the request to the active Session id, returncancelledoralready_settled, emit a cancellation event, and exposePOST /api/prompt/cancel. Existing test doubles remain compatible through the optional interface member.Validation
npx tsc --noEmitnode --test --experimental-strip-types tests/web/pi-runtime.test.ts tests/web/web-host.test.ts(39 passed)git diff --checkImpact