Skip to content

feat: add action-based sub-route routing for dialogs and card actions#529

Open
heyitsaamir wants to merge 5 commits intomainfrom
feat/action-based-subroute-routing
Open

feat: add action-based sub-route routing for dialogs and card actions#529
heyitsaamir wants to merge 5 commits intomainfrom
feat/action-based-subroute-routing

Conversation

@heyitsaamir
Copy link
Copy Markdown
Collaborator

@heyitsaamir heyitsaamir commented Apr 16, 2026

Summary

  • Add dot-separated sub-route routing for dialog.open.{dialogId}, dialog.submit.{action}, and card.action.{action}, matching the pattern used by file.consent.accept and message.submit.feedback
  • Route selectors match against value.data.dialog_id (dialog open), value.data.action (dialog submit), and value.action.data.action (card action)
  • Pairs with the existing OpenDialogData and SubmitData card utilities that set these reserved fields

Usage

// Before: single catch-all handler with manual dispatch
app.on('dialog.open', (ctx) => {
  const dialogId = ctx.activity.value.data?.dialog_id;
  if (dialogId === 'simple_form') { ... }
});

// After: targeted handler per identifier
app.on('dialog.open.simple_form', (ctx) => { ... });
app.on('dialog.submit.submit_form', (ctx) => { ... });
app.on('card.action.save_profile', (ctx) => { ... });

Test plan

  • New router tests verify sub-route selection for all three invoke types
  • Existing catch-all routes (dialog.open, dialog.submit, card.action) continue to work
  • Tested cards and dialogs examples and things work as usual.

🤖 Generated with Claude Code

Enable targeted routing for dialog open/submit and card action events
using dot-separated identifiers (e.g., `dialog.open.simple_form`),
matching the established sub-route pattern used by file.consent and
message.submit routes.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 16, 2026 20:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds action-based sub-route routing for specific invoke activities so handlers can be registered as dialog.open.{dialogId}, dialog.submit.{action}, and card.action.{action}, consistent with existing sub-route patterns like file.consent.accept and message.submit.feedback.

Changes:

  • Extends invoke route typings to include dialog.open.*, dialog.submit.*, and card.action.* route keys.
  • Updates Router invoke matching to select sub-routes based on reserved payload fields (value.data.dialog_id, value.data.action, value.action.data.action).
  • Adds router tests validating sub-route selection and continued catch-all behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/apps/src/routes/invoke/index.ts Wires new sub-route type maps into the invoke route surface and exports them.
packages/apps/src/routes/invoke/dialog-open.ts Introduces dialog.open.${string} route typing for task/fetch invokes.
packages/apps/src/routes/invoke/dialog-submit.ts Introduces dialog.submit.${string} route typing for task/submit invokes.
packages/apps/src/routes/invoke/card-action.ts Introduces card.action.${string} route typing for adaptiveCard/action invokes.
packages/apps/src/router/router.ts Adds runtime selection logic for the new sub-routes.
packages/apps/src/router/router.spec.ts Adds unit tests for the new invoke sub-route selection behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/apps/src/router/router.spec.ts Outdated
Comment thread packages/apps/src/router/router.spec.ts Outdated
Comment thread packages/apps/src/router/router.spec.ts Outdated
Comment thread packages/apps/src/router/router.ts Outdated
heyitsaamir and others added 2 commits April 16, 2026 14:31
Replace manual dispatch (switch/if on dialog_id/action) with targeted
sub-route handlers and remove `as any` casts from router tests.

Co-Authored-By: Claude <noreply@anthropic.com>
Use === comparison against template literals instead of startsWith/slice,
eliminating the need for string casts and staying consistent with the
file.consent and message.submit selector patterns.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread examples/dialogs/src/index.ts
Comment thread packages/apps/src/routes/invoke/index.ts
Comment thread examples/dialogs/src/index.ts
heyitsaamir and others added 2 commits April 18, 2026 22:23
The router matches dialog.submit sub-routes on value.data.action,
but the HTML form was sending submissiondialogtype instead of action.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

4 participants