Skip to content

Conversation

@singhk97
Copy link
Contributor

Ensure that HTTP responses are returned directly from handlers, rather than through event-based callbacks.

Activity processing and response flow:

  • The onActivity handler in app.events.ts now returns a Promise<InvokeResponse> and directly returns the result of processing the activity, rather than just awaiting it.
  • The $process function in app.process.ts is refactored to always return an InvokeResponse, handling both normal and error cases, and ensuring response construction is consistent.

HttpPlugin interface and implementation updates:

  • The $onActivity event handler in HttpPlugin is now asynchronous and returns a Promise<InvokeResponse>, aligning with the new app contract.
  • The HTTP request handler in HttpPlugin now awaits the activity response and sends it directly to the client, removing the previous pattern of storing pending responses and using callback events.
  • Old error and activity response event handlers (onError, onActivityResponse) and related state management are removed from HttpPlugin, as response handling is now synchronous with the HTTP request.

Type and import consistency:

  • The InvokeResponse type is imported and used consistently across files to improve type safety and clarity.

Copy link
Collaborator

@heyitsaamir heyitsaamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Add tests?

@singhk97 singhk97 marked this pull request as ready for review November 18, 2025 22:00
): Promise<InvokeResponse> {
this.events.emit('activity', event);
await this.process(sender, { ...event, sender });
return await this.process(sender, { ...event, sender });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

One thing I think we should do is have an onActivity in apps (core, not app.events). That should call emit's onActivity, and then call process from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue with that is that other event handler methods will be here... do we want to have that discrepancy? Let's plan that refactor for later?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but now process is no longer tied to an event right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected onActivity = onActivity; // eslint-disable-line @typescript-eslint/member-ordering

the process is not really tied to an event (it's tied to the event manager) and the App's OnActivity implementation is just ^^.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right that's what i mean. Why does onActivity needs to be in events anymore? It can be in the main app file. The flow of data is weird right now, app.events is powering onActivity for no clear reason

Copy link
Contributor Author

@singhk97 singhk97 Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the responsibility of the app.events is to handle events, and OnActivity is one of them. Moving it to app will split the responsibility of managing events between app and app.events.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's responsible for emitting events, not really handling them.
"process" is part of handling an event that's happening. I think what makes sense is:

Http plugin gets the http event -> forwards the event to app -> app sends the event to be processed -> emits it out/

wdyt?

heyitsaamir added a commit to microsoft/teams.py that referenced this pull request Dec 4, 2025
Linked PR: microsoft/teams.ts#398

This is how the architecture looked like before 

<img width="1131" height="573" alt="image"
src="https://github.com/user-attachments/assets/f24e60a3-8326-497d-b63b-e0a3e2579c3f"
/>

This is what it looks like now:

<img width="1168" height="556" alt="image"
src="https://github.com/user-attachments/assets/450c7092-3595-4bfe-89ae-f3f1ff875aba"
/>

---------

Co-authored-by: heyitsaamir <[email protected]>
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.

3 participants