fix: align ModelContext event types with Chrome 156 - #71
Merged
Merged
Conversation
naji247
approved these changes
Sep 30, 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.
Summary
Chrome 156.0.8076.0 moves the
toolactivatedandtoolcancelevents fromwindowtodocument.modelContext(webmachinelearning/webmcp#245).ModelContextonly knew abouttoolchange, so a listener for either new event failed to compile against thedocument.modelContextaugmentation.Added
ToolActivatedEvent,ToolCancelEvent(anEventwith atoolNamestring) andModelContextEventMap, all exported.ontoolactivated/ontoolcancelonModelContext, plus typedaddEventListener/removeEventListeneroverloads. Event names outside the map fall back to the plainEventTargetsignature instead of erroring.*.test-d.ts) now run through vitest's typecheck mode against a newtsconfig.test.json; the root tsconfig excludes__tests__, so they were not being checked at all.Other
docs/api.md: Chrome 156 row and an Events section covering all three events. Changelog entry under Unreleased. AGENTS.md note on where type tests live.No runtime change. The polyfill still only fires
toolchange; dispatching the two new events is left for a follow-up.Test Plan
pnpm build && pnpm typecheck && pnpm lint && pnpm test(306 tests, 7 of them type tests)toolactivatedlistener ondocument.modelContextand confirmev.toolNameis astringwithout a cast