Skip to content

fix(slack-work-apps): add attachment content to slack messages#2317

Merged
miles-kt-inkeep merged 3 commits intomainfrom
fix/pull-forwarded-messages-into-context
Feb 24, 2026
Merged

fix(slack-work-apps): add attachment content to slack messages#2317
miles-kt-inkeep merged 3 commits intomainfrom
fix/pull-forwarded-messages-into-context

Conversation

@miles-kt-inkeep
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 24, 2026

🦋 Changeset detected

Latest commit: ecc8704

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@inkeep/agents-work-apps Patch
@inkeep/agents-api Patch
@inkeep/agents-manage-ui Patch
@inkeep/agents-cli Patch
@inkeep/agents-core Patch
@inkeep/agents-mcp Patch
@inkeep/agents-sdk Patch
@inkeep/ai-sdk-provider Patch
@inkeep/create-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Feb 24, 2026 7:53pm
agents-manage-ui Ready Ready Preview, Comment Feb 24, 2026 7:53pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
agents-docs Skipped Skipped Feb 24, 2026 7:53pm

Request Review

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

PR Review Summary

(2) Total Issues | Risk: Low

🟠⚠️ Major (1) 🟠⚠️

Inline Comments:

  • 🟠 Major: dispatcher.ts:52-65 Type definition duplicated inline instead of importing exported SlackAttachment interface

🟡 Minor (1) 🟡

Inline Comments:

  • 🟡 Minor: app-mention.ts:312 Debug log at INFO level should be DEBUG

💭 Consider (2) 💭

💭 1) utils.ts:513-526 Interface placement in utils.ts vs types.ts

Issue: The SlackAttachment interface is defined in utils.ts, but other Slack-related interfaces (SlackCommandPayload, SlackCommandResponse) are in services/types.ts.

Why: Co-locating the type with formatAttachments() that uses it is also a valid pattern. This is a developer preference call.

Fix: Either move to types.ts for consistency with other Slack types, or keep near usage. Both are reasonable.

Refs: types.ts — other Slack interfaces

💭 2) events.test.ts Missing edge case test for incomplete attachment fields

Issue: No test verifies that attachment fields with missing title or value are correctly skipped by formatAttachments().

Why: The implementation guards with if (field.title && field.value) but there's no test protecting this behavior from accidental changes.

Fix: Consider adding:

it('should skip fields with missing title or value', () => {
  const result = formatAttachments([{ 
    text: 'Message', 
    fields: [{ title: 'OnlyTitle' }, { value: 'OnlyValue' }] 
  }]);
  expect(result).not.toContain('OnlyTitle');
  expect(result).not.toContain('OnlyValue');
});

Refs: utils.ts:552-558 — field guard logic


💡 APPROVE WITH SUGGESTIONS

Summary: This is a well-implemented fix that properly adds attachment content (forwarded/shared messages) to the agent's query context. The code is clean, well-tested, and follows existing patterns. The main suggestion is to consolidate the duplicate type definition by importing the existing SlackAttachment interface instead of redefining it inline. The logging level change is a minor polish item.

Discarded (4)
Location Issue Reason Discarded
app-mention.ts:332 Context tag naming follows convention Positive observation, not actionable
events.test.ts Missing test for thread path + attachments Indirectly covered by getThreadContext with attachments unit test
events.test.ts Missing test for text vs fallback preference Too minor, behavior is correct and standard Slack pattern
utils.ts:513-526 Missing JSDoc for subset selection Nice-to-have but not required, type purpose is clear from usage
Reviewers (4)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
pr-review-standards 0 0 0 0 0 0 0
pr-review-consistency 4 0 1 0 2 0 1
pr-review-tests 4 0 1 0 0 0 3
pr-review-types 2 0 0 0 0 0 2
Total 10 0 2 0 2 0 6

Note: Type duplication finding was raised by both consistency and types reviewers — merged and routed to inline comment.

Comment thread packages/agents-work-apps/src/slack/dispatcher.ts Outdated
// Has query → Execute agent with streaming
let queryText = text;
const attachmentContext = formatAttachments(attachments);
logger.info({ attachmentContext }, 'Attachment context');
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.

🟡 Minor: Debug log at INFO level

Issue: This log statement outputs the full attachment context at INFO level, which may produce verbose output in production.

Why: Similar context-related logging elsewhere in the codebase uses logger.debug (e.g., checkIfBotThread in utils.ts). INFO level logs are typically reserved for significant operational events, not intermediate processing state.

Fix:

Suggested change
logger.info({ attachmentContext }, 'Attachment context');
logger.debug({ attachmentContext }, 'Attachment context');

Refs:

@github-actions github-actions Bot deleted a comment from claude Bot Feb 24, 2026
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
@vercel vercel Bot temporarily deployed to Preview – agents-docs February 24, 2026 19:46 Inactive
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

PR Review Summary

(2) Total Issues | Risk: Medium

🔴❗ Critical (1) ❗🔴

Inline Comments:

  • 🔴 Critical: dispatcher.ts:52 Missing import for SlackAttachment type — will cause TypeScript compilation error

🕐 Pending Recommendations (1)


🚫 REQUEST CHANGES

Summary: The delta addressed the prior Major finding (replaced inline type with SlackAttachment), but the fix is incomplete — the import statement for SlackAttachment was not added. This will cause a TypeScript compilation error. Add import type { SlackAttachment } from './services/events/utils'; to the imports at the top of dispatcher.ts.

Reviewers (1)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
orchestrator 1 0 0 0 1 1 0
Total 1 0 0 0 1 1 0

Note: Delta review — only dispatcher.ts changed since last review. Sub-agents not dispatched for minimal delta.

bot_id?: string;
subtype?: string;
edited?: unknown;
attachments?: SlackAttachment[];
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.

🔴 CRITICAL: Missing import for SlackAttachment

Issue: The type SlackAttachment is used here but is not imported. This will cause a TypeScript compilation error: "Cannot find name 'SlackAttachment'".

Why: The prior review suggested replacing the inline type definition with the exported SlackAttachment interface, which was done. However, the corresponding import statement was not added.

Fix: Add the import at the top of the file (after line 14):

import type { SlackAttachment } from './services/events/utils';

Refs:

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

PR Review Summary

(0) Total Issues | Risk: Low

All prior feedback has been addressed in this commit:

Prior Issue Status
🔴 Critical: Missing SlackAttachment import in dispatcher.ts Resolved — import added on line 14
🟡 Minor: Debug log at INFO level in app-mention.ts Resolved — log statement removed

✅ APPROVE

Summary: The latest commit (ecc87043c feedback) correctly addresses both prior review findings. The SlackAttachment type is now properly imported from ./services/events/utils in dispatcher.ts, and the verbose INFO-level log statement has been removed from app-mention.ts. The PR is ready to merge. 🎉

Reviewers (1)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
orchestrator 0 0 0 0 0 0 0
Total 0 0 0 0 0 0 0

Note: Delta review — both changed files (dispatcher.ts, app-mention.ts) contained only fixes for prior review feedback. No new issues introduced.

@github-actions github-actions Bot deleted a comment from claude Bot Feb 24, 2026
@miles-kt-inkeep miles-kt-inkeep merged commit 8063da9 into main Feb 24, 2026
11 checks passed
@miles-kt-inkeep miles-kt-inkeep deleted the fix/pull-forwarded-messages-into-context branch February 24, 2026 20:02
inkeep Bot added a commit that referenced this pull request Feb 24, 2026
Reflects PR #2317 which adds support for Slack attachment content
(shared/forwarded messages) in the context sent to agents.
@itoqa
Copy link
Copy Markdown

itoqa Bot commented Feb 24, 2026

Ito Test Report ✅

17 test cases ran. 17 passed.

All test cases for PR #2317 (add attachment content to Slack messages) passed verification. The tests validate the new formatAttachments() utility function and its integration into the Slack event dispatch pipeline. Unit tests confirmed correct handling of shared/forwarded messages, fallback text, channel metadata, empty inputs, multiple attachments, and edge cases like special characters and large attachment counts. The full test suite (454 tests) passed with no regressions from the mock strategy change.

✅ Passed (17)
Test Case Summary Timestamp Screenshot
ROUTE-1 Verified via unit test: dispatcher.ts extracts attachments from event and passes to handleAppMention 0:57 ROUTE-1_0-57.png
ROUTE-2 Verified via unit test: channel mention with query and forwarded message includes attachment context via streamAgentResponse 0:58 ROUTE-2_0-58.png
ROUTE-3 Verified via unit tests and source: in-thread mention with attachments includes both thread context and attachment content 0:59 ROUTE-3_0-59.png
ROUTE-4 Verified via source and unit tests: getThreadContext iterates thread messages and calls formatAttachments for each 1:00 ROUTE-4_1-00.png
ROUTE-5 All app-mention tests pass; full suite of 454 tests confirms no regressions for no-attachments path 2:08 ROUTE-5_2-08.png
EDGE-1 Verified via unit test: attachment with no text and no fallback is skipped 4:21 EDGE-1_4-21.png
EDGE-2 Verified via unit test: attachment uses fallback text when primary text is missing 4:22 EDGE-2_4-22.png
EDGE-3 Verified via unit test: channel_id fallback when channel_name is missing 4:23 EDGE-3_4-23.png
EDGE-4 Verified via unit tests: empty string returned for undefined and empty array inputs 4:24 EDGE-4_4-24.png
EDGE-5 Verified via unit tests: multiple attachments formatted; content-less ones skipped 4:25 EDGE-5_4-25.png
EDGE-6 Verified via unit test: from_url included as source reference line 4:26 EDGE-6_4-26.png
EDGE-7 Verified via unit test: attachment fields with title/value pairs included; missing title/value skipped 4:27 EDGE-7_4-27.png
ADV-1 Verified via unit test: content wrapped in triple backtick delimiters; backtick sequences handled 5:58 ADV-1_5-58.png
ADV-2 Stress tests confirm linear O(n) scaling: 1000 attachments processed in 0.22ms 8:45 ADV-2_8-45.png
ADV-3 Verified via unit tests: author_name with special characters passes through without throwing 6:03 ADV-3_6-03.png
ADV-4 Verified via unit tests: null/non-string text fields safely handled via OR operator and continue 6:08 ADV-4_6-08.png
LOGIC-1 Partial mock (importOriginal) preserves test accuracy; all 8 app-mention tests pass, 454/454 full suite passes 3:11 LOGIC-1_3-11.png
📋 View Recording

Screen Recording

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