Add timer to demonstrate new AbortSignal introduce in Chrome 153 - #403
Draft
marcianoskate wants to merge 7 commits into
Draft
Add timer to demonstrate new AbortSignal introduce in Chrome 153#403marcianoskate wants to merge 7 commits into
marcianoskate wants to merge 7 commits into
Conversation
| 1. **Tool Registration Lifecycle:** | ||
| ```javascript | ||
| const regController = new AbortController(); | ||
| document.modelContext.registerTool(toolDefinition, { signal: regController.signal }); |
Collaborator
There was a problem hiding this comment.
ModelContextRegisterToolOptions signal has been available since Chrome 148.0.7757.0. This is not new.
| const regController = new AbortController(); | ||
| document.modelContext.registerTool(toolDefinition, { signal: regController.signal }); | ||
| ``` | ||
| Calling `regController.abort()` unregisters the tool from the page's tool catalog, **without terminating or breaking in-flight tool executions**. |
Collaborator
There was a problem hiding this comment.
This specific line is the new part in Chrome 153 though
| const execController = new AbortController(); | ||
| const promise = document.modelContext.executeTool(tool, args, { signal: execController.signal }); | ||
| ``` | ||
| Passing `{ signal }` in `executeTool` provides that signal directly to the tool's `execute(params, clientContext)` callback. Calling `execController.abort()` immediately signals the running loop, freeing the event loop and settling the promise cleanly. |
Collaborator
There was a problem hiding this comment.
clientContext isn't the right name. it's just options.
|
|
||
| ```javascript | ||
| // 1. Resolve modelContext with hybrid fallback | ||
| const modelContext = document.modelContext || navigator.modelContext || document.modelContextTesting; |
Collaborator
There was a problem hiding this comment.
We only use document.modelContext now
added 6 commits
September 3, 2026 15:23
…and abort bugs - Simplify DOM structure and eliminate Tailwind class injection in JS by using declarative data-state styling - Extract pure zero-DOM startTimerExecution engine with AbortSignal listeners - Add hard cancellation handle (bindCancel) and run sequence tracking (runId) to fix reset timer continuation bug - Fall back to host AbortController signal when clientContext.signal is omitted by native Chrome WebMCP - Add direct abort handle (bindAbort) and recover from Blink AbortError promise rejections - Prevent duplicate execution loops by guarding on running/runaway states TAG=agy CONV=685fb023-d315-42af-be2f-2c2bc1ec0588
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.
In the upcoming Chrome 153, a change to the API introduces the ability to pass an
AbortSignalto the tool registration and tool execution. This enables long-running tasks to be properly notified when the user or the agent interrupts the task.