Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 19, 2025

Parallel Event Handler Support

Adding support for instant and parallel event function handlers to CommandKit.

Event handlers can now export parallel = true to execute concurrently using Promise.all(), while handlers without this flag continue to execute sequentially as before.

Changes Made

  • EventListener Type: Added parallel boolean field to track parallel execution mode
  • Event Loading: Modified loadEvents() to read the parallel export from event handler modules
  • Listener Grouping: Separated listeners into parallel and sequential groups for both regular and once-only listeners
  • Execution Logic:
    • Parallel listeners execute concurrently using Promise.all()
    • Sequential listeners execute in order (existing behavior)
    • Parallel listeners run before sequential listeners
  • Error Handling: Errors in parallel handlers don't stop other parallel handlers from executing
  • Logging: Updated event registration logging to show counts of sequential/parallel listeners
  • Formatting: Applied prettier formatting to code

Usage

Event handlers can now opt-in to parallel execution:

// File: src/app/events/interactionCreate/handler.js

// Export parallel flag to execute this handler concurrently
export const parallel = true;

export default async function (interaction) {
  // handle event
}

Testing

  • ✅ TypeScript compilation passes
  • ✅ Build process completes successfully
  • ✅ Code formatted with prettier

Fixes #568

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for instant + parallel event function handlers</issue_title>
<issue_description>The current event handler implementation calls event functions in an order, while waiting for the previous one to finish. Some situations require multiple, instant, and parallel handling which the current handler lacks.

Proposed structure

// File: src/app/events/interactionCreate/handler.js

// an export to treat this handler differently from the ones running in sequence
// ckit might use something like Promise.all() to call them all at once
export const parallel = true; // variable name might need work

export default async function (interaction) {
  // handle event
}
```</issue_description>

<agent_instructions>your work goes inside `packages/commandkit/src/app/handlers/AppEventsHandler.ts` file for this issue. Just grab `parallel` export from the loaded event file and group parallel vs sequential and register them with different execution logic.</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

Fixes #568


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link

netlify bot commented Oct 19, 2025

Deploy Preview for commandkit canceled.

Name Link
🔨 Latest commit 9d177f4
🔍 Latest deploy log https://app.netlify.com/projects/commandkit/deploys/68f5365cf1e32f0008f274b2

Copilot finished work on behalf of twlite October 19, 2025 18:50
Copilot AI requested a review from twlite October 19, 2025 18:50
@twlite
Copy link
Member

twlite commented Oct 19, 2025

@copilot do not worry about tests, only make the necessary changes and make sure the build passes

Co-authored-by: twlite <46562212+twlite@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 19, 2025

@copilot do not worry about tests, only make the necessary changes and make sure the build passes

Done! I've removed the test file and focused only on the implementation. The build passes successfully. Changes include:

  • Added parallel flag to EventListener type
  • Read parallel export from event handler modules
  • Parallel handlers execute concurrently via Promise.all()
  • Sequential handlers execute in order (existing behavior)

Commit: The changes are in the commit above.

Copilot AI changed the title [WIP] Add support for instant and parallel event function handlers Add support for instant and parallel event function handlers Oct 19, 2025
Copilot finished work on behalf of twlite October 19, 2025 18:59
@twlite twlite changed the title Add support for instant and parallel event function handlers feat: add support for instant and parallel event function handlers Oct 19, 2025
@twlite
Copy link
Member

twlite commented Oct 19, 2025

@copilot please run pnpm prettier:format from the root and push the changes

Co-authored-by: twlite <46562212+twlite@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 19, 2025

@copilot please run pnpm prettier:format from the root and push the changes

Done! Ran pnpm prettier:format and pushed the formatting changes. Commit: 79953af (formatting applied)

Copilot AI requested a review from twlite October 19, 2025 19:05
Copilot finished work on behalf of twlite October 19, 2025 19:05
@twlite twlite marked this pull request as ready for review October 19, 2025 19:06
@twlite twlite merged commit 0162552 into main Oct 19, 2025
6 checks passed
@twlite twlite deleted the copilot/add-instant-parallel-event-handlers branch October 19, 2025 19:06
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.

Add support for instant + parallel event function handlers

2 participants