-
Notifications
You must be signed in to change notification settings - Fork 2
[web] Add channel agent mention replies and clear sender names #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web] Add channel agent mention replies and clear sender names #531
Conversation
📝 WalkthroughWalkthroughAdds an agent-mention responder that detects Changes
Sequence DiagramsequenceDiagram
actor User
participant API as Message API
participant Responder as Agent Mention Responder
participant DB as Database
participant AskAgent as Ask Agent Service
participant Channel as Channel Service
participant Broadcast as Inbox Broadcast
User->>API: Send message with `@agent` mention
API->>DB: Insert message (uses messageContent)
API->>Responder: triggerMentionedAgentResponses(params)
Responder->>DB: Resolve mentioned agents & fetch context
DB-->>Responder: Agent metadata, channel history, members
Responder->>Responder: Build transcript, check permissions/tools
alt Agent Eligible
Responder->>AskAgent: ask_agent with context & prompt
AskAgent-->>Responder: AI response
Responder->>Channel: send_channel_message (AI reply with aiMeta)
Channel->>DB: Store AI message
Channel->>Broadcast: broadcastInboxEvent (aiMeta, preview)
Broadcast-->>User: Notify recipients
else Not Eligible
Responder->>Responder: Skip posting
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ca9d7bf10
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| toolCallId: `channel-mention-send-${params.sourceMessageId}-${agent.id}`, | ||
| messages: [], | ||
| experimental_context: { | ||
| userId: params.userId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a non-user sender context for mention auto-replies
Passing params.userId as the experimental_context.userId for send_channel_message causes mention-triggered AI replies to be treated as if the requesting user sent them. In send_channel_message, that sender identity is used to update that user’s read watermark and to skip inbox broadcast to that same user (filter(m => m.userId !== userId)), so when the AI reply arrives later (common with model latency), the requester can miss unread/inbox notifications for the response they asked for.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! This concern is already addressed in the implementation.
Looking at the send_channel_message call in agent-mention-responder.ts (lines 274-296), the context includes:
chatSource: {
type: 'page',
agentPageId: agent.id,
agentTitle: agent.title,
}This triggers the treatAsSelfAuthored = false path in channel-tools.ts:97:
const treatAsSelfAuthored = senderIdentity.senderType === 'global_assistant';When treatAsSelfAuthored is false (agent messages):
- Read watermark is NOT updated for the requesting user (line 114-123)
- Requester IS included in inbox broadcasts (line 211 filter condition)
So agent-triggered replies correctly:
- Keep the message unread for the requester
- Include the requester in inbox notifications
The fix in commit da55b4ba specifically implemented this semantic distinction.
The mocked tool functions return `unknown`, causing Extract<unknown, T> to resolve to `never`. Define explicit interfaces for test result types. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use `as unknown as Mock` pattern instead of `vi.mocked()` to avoid strict type checking that expects full union including AsyncIterable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
@[label](id:page)) and triggers in-channel agent repliesAI_CHATagents the user can view and that havesend_channel_messageenabledPOST /api/channels/[pageId]/messageswithout blocking normal post flowAgent Name (User Full Name)insend_channel_message/api/inboxchannel last-message sender queries viaCOALESCE(cm."aiMeta"->>'senderName', u.name)Testing
vitestis unavailable becauseapps/web/node_modulesis not installed in this workspace (sh: vitest: command not found)Summary by CodeRabbit
New Features
Bug Fixes
Tests