Skip to content

fix(sdk): retain DM classification on generic message readback - #1991

Open
AyobamiH wants to merge 1 commit into
AgentWorkforce:mainfrom
AyobamiH:fix/dm-generic-message-kind
Open

AyobamiH wants to merge 1 commit into
AgentWorkforce:mainfrom
AyobamiH:fix/dm-generic-message-kind

Conversation

@AyobamiH

@AyobamiH AyobamiH commented Oct 25, 2026 •

Copy link
Copy Markdown

Fixes #1987.

What changed

The generic messages.get(id) path receives no direct-message context. For some real one-to-one DMs, Relaycast returns a valid message with channel_id: dmch_... (its internal DM backing channel) but omits conversation_id. Previously, the SDK inferred kind: channel from any channel_id, even for these internal DM channels.

  • Recognize a dmch_ backing channel when inferring an otherwise context-free RelayMessage.kind, preserving the dm discriminator on recipient readback.
  • Keep explicit MessageContext.kind authoritative; continue to prefer thread replies and explicit conversation IDs over channel fallback.
  • Preserve the existing IDs, sender/text fields and channel reference. Do not synthesize an unobserved conversationId.
  • Add regression tests for generic DM readback, a genuine channel ID, explicit kind, thread-reply precedence, and unknown records.

Verification

  • npm --prefix packages/sdk test — 197 passed, 15 test files.
  • npm --prefix packages/sdk run check — TypeScript passed.
  • Prettier check on changed TypeScript — passed.
  • git diff --check — passed.
  • The original issue provides a controlled live engine reproduction against released packages; this PR's own validation is SDK-unit-level with fixtures matching the observed raw response. No permission changes are introduced.

Note for maintainers

This is a compatibility inference for Relaycast's observed dmch_ internal ID. If the engine can expose conversation_id (or an explicit wire kind) consistently on generic GET /v1/messages/:id, that would be a stronger long-term discriminator; the SDK still prioritizes that metadata when present.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d9abe37b-80e1-437c-aab9-5243c8204938
Commits

Reviewing files that changed from the base of the PR and between c3a92d9 and 17bbf12.

Files selected for processing: 3
  • CHANGELOG.md
  • packages/sdk/src/__tests__/messaging.test.ts
  • packages/sdk/src/messaging/normalize.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The message normalizer now infers DM classification from dmch_ channel IDs when no explicit kind is supplied. Tests cover this fallback and the precedence of explicit context, thread-parent IDs, and conversation IDs. The changelog records the fix.

Changes: DM Readback Classification

Layer / File(s) Summary
Message kind classification
packages/sdk/src/messaging/normalize.ts, packages/sdk/src/__tests__/messaging.test.ts, CHANGELOG.md
The normalizer treats a dmch_ channel ID as DM evidence. Explicit kind and thread-parent precedence remain covered by tests, along with regular channel and unknown classifications. The changelog records the fix.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 17bbf

The generic DM readback behavior is covered, and no issue remains that should delay merging.

Pre-merge checks: Passed 2 · Failed 3

Failed Failed checks: 3 warnings

Check name Status Explanation Resolution
Description check Warning The description states the problem, the fix, and the verification results. It explains that Relaycast returns a dmch_ channel_id without conversation_id, that the SDK now recognizes dmch_ backing chan… Add the RelayFlow Proof section with a Change type (bugfix fits, since this is user-visible behavior) and a RelayFlow case under tests/relayflows/cases//, replacing the placeholder values and keeping the relay-pr-proof HTML comme…
Out of Scope Changes check Warning The fixed changelog entry supports issue [#1987]. However, the same change renames the global CHANGELOG.md heading from Unreleased to Unreleased - Major. That release-category change has no stat… Revert the unrelated Unreleased to Unreleased - Major heading change. Keep the changelog entry that documents the DM classification fix.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 2 passed
Check name Status Explanation
Title check Passed The title "fix(sdk): retain DM classification on generic message readback" matches the main change. The diff makes normalizeMessage classify messages from dmch_ backing channels as dm when no explicit…
Linked Issues check Passed Issue [#1987] requires generic DM reads to keep kind: 'dm' when the raw record has a dmch_ channel ID and no conversation_id. The normalizer now maps that ID to dm when no explicit kind exists…
Full details: Title check

Explanation

The title "fix(sdk): retain DM classification on generic message readback" matches the main change. The diff makes normalizeMessage classify messages from dmch_ backing channels as dm when no explicit kind is supplied, and adds regression tests. The title is specific, uses a conventional fix(sdk) prefix, and is under 72 characters.

Full details: Linked Issues check

Explanation

Issue [#1987] requires generic DM reads to keep kind: 'dm' when the raw record has a dmch_ channel ID and no conversation_id. The normalizer now maps that ID to dm when no explicit kind exists. context.kind remains authoritative, thread replies remain higher priority, and explicit conversation IDs remain supported. The existing channel fallback still maps genuine channel records to channel, and the normalizer still returns the existing message fields and channel reference. The supplied test summary reports coverage for DM readback, channel records, explicit kind, thread precedence, and unknown records.

Full details: Description check

Explanation

The description states the problem, the fix, and the verification results. It explains that Relaycast returns a dmch_ channel_id without conversation_id, that the SDK now recognizes dmch_ backing channels, and that explicit kind, thread-reply precedence, and explicit conversation IDs keep their priority. It lists test and check results and links the issue (#1987). It does not fill in the template's Test Plan checkboxes, the Change type and RelayFlow case placeholders in the RelayFlow Proof section (both still read replace-me in the template and are absent from the description), or the Screenshots section. The Summary heading is replaced by 'What changed', and the Test Plan checkboxes are not ticked.

Resolution

Add the RelayFlow Proof section with a Change type (bugfix fits, since this is user-visible behavior) and a RelayFlow case under tests/relayflows/cases/<case-id>/, replacing the placeholder values and keeping the relay-pr-proof HTML comment markers. Tick the Test Plan checkboxes that apply (Tests added/updated is clearly done; Manual testing completed should be ticked only if it was actually run, otherwise state that it was not). Add a Screenshots note (for example 'N/A') or remove the placeholder. Rename or map the 'What changed' section so it sits under the template's Summary heading, or add a Summary section.

Full details: Out of Scope Changes check

Explanation

The fixed changelog entry supports issue [#1987]. However, the same change renames the global CHANGELOG.md heading from Unreleased to Unreleased - Major. That release-category change has no stated connection to the DM classification fix or to the linked issue.

Resolution

Revert the unrelated Unreleased to Unreleased - Major heading change. Keep the changelog entry that documents the DM classification fix.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads a message bright,
A dmch_ keeps its DM right.
The channel stays a channel too,
Context guides what kind to view.
The tests hop through each case,
And the changelog marks the place.

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Generic messages.get readback now recognizes dmch_ backing channels as direct messages without inventing a conversationId.

  • Generic message readbacks recognize internal DM channel IDs.

Reviews (1) · Last reviewed commit: "fix(sdk): preserve DM kind on generic me..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

fix(sdk): generic DM readback changes message kind to channel

1 participant