Skip to content

Default targeted replies for targeted inbound messages#592

Open
heyitsaamir wants to merge 9 commits into
mainfrom
targeted-replies-default
Open

Default targeted replies for targeted inbound messages#592
heyitsaamir wants to merge 9 commits into
mainfrom
targeted-replies-default

Conversation

@heyitsaamir
Copy link
Copy Markdown
Collaborator

@heyitsaamir heyitsaamir commented May 22, 2026

Summary

  • make send / reply default to targeted when replying to a targeted inbound message
  • keep explicit public sends, different recipients, and different conversation refs public
  • split the targeting logic into helpers so the rules are less spicy
  • keep targetedMessageInfo limited to targeted inbound replies, so normal explicit targeted sends still work
  • add targeted-messages example commands for send private and send public

Note: this also cleans up a pre-existing dead branch from when isTargeted moved onto recipientparams.recipient?.isTargeted already means params.recipient exists.

image

Test plan

  • cd packages/apps && npx jest src/contexts/activity.test.ts --runInBand
  • cd packages/apps && npm run build
  • cd examples/targeted-messages && npm run build

Copilot AI review requested due to automatic review settings May 22, 2026 18:44
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

This PR updates ActivityContext.send()/reply() behavior so that when the inbound activity is a targeted message, outbound message sends default to targeted as well, while still allowing callers to explicitly send a non-targeted (public) message. It also adds Jest coverage for the new defaulting behavior and the explicit override path.

Changes:

  • Default outbound send() messages to targeted when the inbound activity is targeted (unless an explicit recipient is provided).
  • Update the targeted-reply test to assert the new default recipient targeting behavior.
  • Add tests covering the new default-targeted behavior and the explicit “public send” override.

Reviewed changes

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

File Description
packages/apps/src/contexts/activity.ts Adjusts send() to default outbound messages to targeted when the inbound activity is targeted.
packages/apps/src/contexts/activity.test.ts Adds/updates tests to cover the new defaulting behavior and override case.

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

Comment thread packages/apps/src/contexts/activity.ts Outdated
Comment thread packages/apps/src/contexts/activity.test.ts Outdated
Comment thread packages/apps/src/contexts/activity.ts Outdated
Comment thread packages/apps/src/contexts/activity.ts
Comment on lines +65 to +68
await send(
new MessageActivity('🌍 This is a **public message** — everyone can see this!')
.withRecipient(activity.from)
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we get further documentation underlining that for auto-targeting, caller must pass any recipient to work? (Maybe you had planned this already)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(Inline comment indicating recipient = user here would also be good, I think)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

actually the intent here is that the default behavior is to auto-target. But you bring up a really good point that if recipient that is not the user is set, then we shouldn't auto-target

Comment thread packages/apps/src/contexts/activity.ts Outdated
Comment thread examples/targeted-messages/src/index.ts Outdated
Comment thread examples/targeted-messages/README.md Outdated
Comment thread packages/apps/src/contexts/activity.ts
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