Add pluggable activity context#288
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a pluggable activity context system that allows plugins to add typed values to the activity context. The implementation adds a new buildActivityContext method to the plugin interface and updates all activity context types to support generics for plugin-provided context values.
Key changes:
- Adds
buildActivityContextmethod to the plugin interface for injecting typed context values - Updates all activity context interfaces and route types to accept generic context parameters
- Implements context merging logic in the app processing pipeline
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/apps/src/types/plugin/plugin.ts | Adds generic type parameters and buildActivityContext method to plugin interface |
| packages/apps/src/contexts/activity.ts | Updates activity context interfaces to support generic plugin context types |
| packages/apps/src/app.process.ts | Implements plugin context building and merging in activity processing |
| packages/apps/src/routes/*.ts | Updates all route type definitions to support generic context parameters |
| packages/apps/src/router.ts | Updates router class to support typed plugin contexts |
| packages/apps/src/app.ts | Updates app class to use typed plugin contexts in router |
| packages/apps/src/types/app-routing.ts | Adds utility type for extracting plugin context types |
aacebo
left a comment
There was a problem hiding this comment.
left questions, this is a good first draft let me know when its ready for another review!
Updated it with your suggestions @aacebo . Take a look! |
|
Does this behavior still work? I'm unable to pass the additional context from teams.ts/packages/apps/src/app.process.ts Line 97 in a8986a4 |
I think you're right. This needs a test. Will prioritize this fix. BTW, what's the use case you're looking for with this? |
Thanks! Appreciate the quick response.
We're wrapping the Teams SDK in our own abstraction, being built as part of a larger system. This plugin approach would enable us to enrich inbound requests with additional, domain-specific context that can propagate through the remainder of the route chain. Think, for example, |
This PR #288 introduces the ability for plugins to provide extra context. Unfortunately, the PR was incomplete, and needed tests. This PR adds tests, and fixes the issues with actually plumbing that value through to the context.
This PR introduces the ability for plugins to add typed values to the activity context. It does this by adding a dedicated
buildActivityContextfunction that gets called inapp.process. Then via a bunch of generics plumbing we merge the plugin's context values with the default ones.We can use this to separate graph out into other packages, but keep the contextual objects for the activity-handlers unchanged (aka.
appGraph, anduserGraphwill still be available). However,graphobject onappwould most likely be part of the theGraphPlugin- (maybe we make that accessible via a newapp.getPlugin('graph')method?)Here's a mini demo:
Screen.Recording.2025-08-04.at.8.35.09.AM.mov
PR Dependency Tree
This tree was auto-generated by Charcoal