Skip to content

fix: align ModelContext event types with Chrome 156 - #71

Merged
kashishhora merged 1 commit into
mainfrom
kashish/react-library-updates-8b244f
Sep 30, 2026
Merged

kashishhora merged 1 commit into
mainfrom
kashish/react-library-updates-8b244f

Conversation

@kashishhora

Copy link
Copy Markdown
Member

Summary

Chrome 156.0.8076.0 moves the toolactivated and toolcancel events from window to document.modelContext (webmachinelearning/webmcp#245). ModelContext only knew about toolchange, so a listener for either new event failed to compile against the document.modelContext augmentation.

Added

  • ToolActivatedEvent, ToolCancelEvent (an Event with a toolName string) and ModelContextEventMap, all exported.
  • ontoolactivated / ontoolcancel on ModelContext, plus typed addEventListener / removeEventListener overloads. Event names outside the map fall back to the plain EventTarget signature instead of erroring.
  • Type-level tests (*.test-d.ts) now run through vitest's typecheck mode against a new tsconfig.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)
  • Extension build and typecheck
  • In a consumer on this branch, add a toolactivated listener on document.modelContext and confirm ev.toolName is a string without a cast

@kashishhora
kashishhora merged commit 656e336 into main Sep 30, 2026
4 checks passed
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