Skip to content

feat(msteams): add topLevel parameter for per-send reply style override (ENG-14117) - #38

Merged
convyusboy merged 3 commits into
boonfrom
ridho/ENG-14117/msteams-top-level-override
Jul 14, 2026
Merged

convyusboy merged 3 commits into
boonfrom
ridho/ENG-14117/msteams-top-level-override

Conversation

@convyusboy

@convyusboy convyusboy commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes ENG-14117: MS Teams agents can only reply in thread, cannot post top-level channel messages.

Root cause: The global channels.msteams.replyStyle: "thread" configuration makes ALL messages threaded, including scheduled cron announcements that should be top-level.

Solution: Add a topLevel parameter to the MS Teams message tool that allows per-send override of the reply style, without changing global configuration.

Why This Change Was Made

This change enables scheduled cron jobs to post top-level channel messages while keeping interactive conversations threaded. For example:

  • Daily summary cron posts → top-level (new thread each day)
  • Interactive agent replies → threaded (keeps conversations organized)

The implementation mirrors Slack's existing topLevel parameter for cross-platform API consistency.

User Impact

Before

All messages are threaded, including cron announcements.

After

Agents can explicitly control reply style per-message using topLevel parameter.

Implementation Details

Core Mechanism (from PR #20)

  • Added replyStyleOverride parameter through the send context chain
  • Added tests for bidirectional override behavior

Last-Mile Wiring (this PR)

  • Added topLevel boolean parameter to message tool schema for send and upload-file actions
  • Implemented parameter handling in action handlers
  • Supports bidirectional override (force top-level OR force threading)
  • Accepts threadId: null as equivalent to topLevel: true

Design Decisions

  • Message tool parameter approach (not cron-only) for maximum flexibility
  • Mirrors Slack API for cross-platform consistency
  • Bidirectional support unique to MS Teams
  • Plugin boundary respect - no shared interface changes

Evidence

Files Changed

  • extensions/msteams/src/send-context.ts - Core override mechanism
  • extensions/msteams/src/send-context.test.ts - Test coverage
  • extensions/msteams/src/send.ts - Accept replyStyleOverride
  • extensions/msteams/src/channel.ts - Schema and action handlers

Code Statistics

4 files changed, 162 insertions(+), 16 deletions(-)

Verification

  • TypeScript compilation passes
  • Formatting passes (oxfmt)
  • Unit tests added for override mechanism

Related

Related to PR #20 which implemented the core replyStyleOverride mechanism. This PR completes the implementation by adding the last-mile wiring.

Co-Authored-By: Claude Sonnet 4.5 [email protected]


Summary by cubic

Adds a per-send reply style override for MS Teams via a topLevel parameter so cron announcements can post as top‑level messages while conversations stay threaded. Addresses Linear ENG-14117 without changing global channels.msteams.replyStyle.

  • New Features

    • Added topLevel boolean to MS Teams message tool for send and upload-file.
    • Plumbed replyStyleOverride through sendMessageMSTeams and resolveMSTeamsSendContext; honored early in resolveMSTeamsProactiveReplyStyle.
    • Bidirectional control: topLevel: true or threadId: null → top‑level; topLevel: false → thread.
    • Applies to non‑presentation sends; presentation unchanged.
    • Tests ensure override wins over global defaults and is a no‑op when undefined.
  • Bug Fixes

    • Fixed TypeScript schema typing for topLevel and schema contributions (return type, action arrays, imports).
    • Formatted extensions/msteams/src/channel.ts with oxfmt.

Written for commit 0c6cf3d. Summary will update on new commits.

Review in cubic

convyusboy and others added 2 commits July 6, 2026 21:25
…ply style override (ENG-14117)

Implements the last-mile wiring for MS Teams replyStyleOverride mechanism,
exposing it to agents via a topLevel parameter on the message tool.

Changes:
- Add replyStyleOverride parameter through send context chain:
  - sendMessageMSTeams accepts replyStyleOverride
  - resolveMSTeamsSendContext passes it through
  - resolveMSTeamsProactiveReplyStyle honors override with early return

- Add topLevel boolean parameter to message tool schema for send and upload-file actions
  - Mirrors Slack's topLevel API for cross-platform consistency
  - Supports bidirectional override (force top-level OR force threading)
  - Accepts threadId: null as equivalent to topLevel: true

- Handle topLevel in action handlers:
  - upload-file: read topLevel param, convert to replyStyleOverride, pass to sendMessageMSTeams
  - send (non-presentation): explicit handler to support topLevel before outbound fallthrough
  - send (presentation): no change, presentation cards don't support override

- Add tests for replyStyleOverride mechanism:
  - Test top-level override on thread-default channel
  - Test thread override on top-level config
  - Test undefined override (no behavior change)

This allows scheduled cron jobs to post top-level channel messages while
interactive conversations stay threaded, without changing global config.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 4 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread extensions/msteams/src/channel.ts Resolved
…resentation limitation

- Fix return type of createMSTeamsTopLevelActionSchema to Record<string, TSchema>
- Add explicit type for schema array: ChannelMessageToolSchemaContribution[]
- Add satisfies ChannelMessageActionName[] to actions arrays for type safety
- Import TSchema and ChannelMessageToolSchemaContribution from channel-contract
- Document that topLevel parameter only works for non-presentation sends

Fixes TypeScript compilation errors in check-prod-types and check-test-types.
Addresses review comment about presentation card limitation by documenting it.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@convyusboy

Copy link
Copy Markdown
Collaborator Author

/cr

@claude

claude Bot commented Jul 14, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed — LGTM, approving.

What I verified:

  • Logic is sound. The presentation send branch runs and returns first, so the new if (ctx.action === "send" && !presentation) block is correctly gated to text sends only — no risk of topLevel silently no-op'ing on a card send within the same code path.
  • Slack parity confirmed. The readBooleanParam(params, "topLevel") === true || threadId === null → top-level mapping matches extensions/slack/src/message-action-dispatch.ts. The MS Teams version adds the bidirectional topLevel: false → thread case, which is a clean superset and consistent with the documented behavior.
  • Override plumbing is correct. replyStyleOverride threads through sendMessageMSTeams → resolveMSTeamsSendContext → resolveMSTeamsProactiveReplyStyle, and the early-return in resolveMSTeamsProactiveReplyStyle guarantees the per-send override wins over the global replyStyle without mutating global config. The undefined case is a proven no-op.
  • Tests exist and cover the right cases — top-level override on a thread-default channel, thread override on a top-level config, and undefined (no behavior change).
  • CI is green on head SHA 0c6cf3d — check-prod-types, check-test-types, check-lint, and the full checks-node-* matrix all SUCCESS.
  • cubic's one P2 (presentation cards ignore topLevel) is resolved: scoped to non-presentation sends + documented in the param description, and cubic acknowledged the resolution. Adaptive-card replyStyleOverride is a reasonable follow-up, not a blocker.

Nit (non-blocking): the topLevel → replyStyleOverride mapping block is duplicated verbatim in the send and upload-file handlers. Fine as-is; a tiny local helper would DRY it up if you touch this again.

Ship it. 🧙

@convyusboy
convyusboy merged commit e6b97a0 into boon Jul 14, 2026
141 of 142 checks passed
@convyusboy
convyusboy deleted the ridho/ENG-14117/msteams-top-level-override branch July 14, 2026 08:28
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.

1 participant