feat: add View Task button to content agent Slack response#430
feat: add View Task button to content agent Slack response#430sweetmantech merged 3 commits intotestfrom
Conversation
Move buildTaskCard to shared lib/agents/ location (DRY) and add a
"View Task" button to the content agent's Slack acknowledgment,
matching the existing coding agent behavior. The button links to
chat.recoupable.com/tasks/{runId} using the first triggered run ID.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 47 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request centralizes the Changes
Sequence Diagram(s)sequenceDiagram
participant Handler as registerOnNewMention Handler
participant CardBuilder as buildTaskCard
participant Thread as Thread Service
participant State as State Manager
participant Poller as Polling Service
Handler->>Handler: Collect runIds from content creation
Handler->>Handler: Verify runIds.length > 0
Handler->>CardBuilder: buildTaskCard("Content Generation Started", message, runIds[0])
CardBuilder-->>Handler: Returns Card object
Handler->>Thread: post({ card })
Thread-->>Handler: Card posted to thread
Handler->>State: setState({ status: "running", ...runIds })
State-->>Handler: State updated
Handler->>Poller: triggerPollContentRun(...)
Poller-->>Handler: Polling initiated
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
2 issues found across 6 files
Confidence score: 4/5
- This PR is likely safe to merge, with the main risk being a user-facing UX hiccup rather than a functional break.
- In
lib/agents/content/handlers/registerOnNewMention.ts, the mention flow appears to post overlapping acknowledgment text ("Generating content…" plus a near-duplicate follow-up), which could make bot responses feel noisy or repetitive. - In
lib/agents/__tests__/buildTaskCard.test.ts, adding explicit types to theCardmock parameters would reduce implicitanyusage and improve maintainability, but this is low runtime risk. - Pay close attention to
lib/agents/content/handlers/registerOnNewMention.tsandlib/agents/__tests__/buildTaskCard.test.ts- prevent duplicate acknowledgment messaging and tighten mock typing before/after merge.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/agents/__tests__/buildTaskCard.test.ts">
<violation number="1" location="lib/agents/__tests__/buildTaskCard.test.ts:7">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**
Add explicit types to the `Card` mock parameters to avoid implicit `any`.</violation>
</file>
<file name="lib/agents/content/handlers/registerOnNewMention.ts">
<violation number="1" location="lib/agents/content/handlers/registerOnNewMention.ts:112">
P2: Custom agent: **Flag AI Slop and Fabricated Changes**
The card text duplicates the acknowledgment already posted a few lines above — the user sees "Generating content…" and "I'll reply here when ready (~5-10 min)." twice in the same thread. Either fold the View Task button into the existing acknowledgment or give the card distinct, non-overlapping text (e.g., just the title + button).</violation>
</file>
Architecture diagram
sequenceDiagram
participant User as Slack User
participant Slack as Slack/Bot Thread
participant Content as Content Agent
participant Coding as Coding Agent
participant Shared as Shared Libs (buildTaskCard)
participant Trigger as Trigger.dev (Worker)
participant Web as Web Dashboard
Note over Content,Trigger: Content Generation Flow (NEW interaction)
User->>Slack: Mentions content bot "@bot make 3 videos"
Slack->>Content: registerOnNewMention()
Content->>Content: parseContentPrompt()
loop For each item in batch
Content->>Trigger: triggerCreateContent()
Trigger-->>Content: runId
end
Content->>Shared: NEW: buildTaskCard(title, msg, firstRunId)
Note right of Shared: Formats link to chat.recoupable.com/tasks/{runId}
Shared-->>Content: Card Object (with View Task button)
Content->>Slack: NEW: thread.post({ card })
Slack-->>User: Display interactive "View Task" button
Note over Coding,Trigger: Coding Agent Flow (CHANGED logic)
User->>Slack: Mentions coding bot or provides feedback
Slack->>Coding: onNewMention() / handleFeedback()
Coding->>Trigger: triggerCodingAgent() / triggerUpdatePR()
Trigger-->>Coding: runId
Coding->>Shared: CHANGED: buildTaskCard() (refactored shared import)
Shared-->>Coding: Card Object
Coding->>Slack: thread.post({ card })
Note over User,Web: User Interaction
User->>Web: Clicks "View Task" button
Web-->>User: Show task execution status/logs (runId context)
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| import { LinkButton } from "chat"; | ||
|
|
||
| vi.mock("chat", () => ({ | ||
| Card: vi.fn(({ title, children }) => ({ type: "card", title, children })), |
There was a problem hiding this comment.
P2: Custom agent: Enforce Clear Code Style and Maintainability Practices
Add explicit types to the Card mock parameters to avoid implicit any.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/agents/__tests__/buildTaskCard.test.ts, line 7:
<comment>Add explicit types to the `Card` mock parameters to avoid implicit `any`.</comment>
<file context>
@@ -0,0 +1,49 @@
+import { LinkButton } from "chat";
+
+vi.mock("chat", () => ({
+ Card: vi.fn(({ title, children }) => ({ type: "card", title, children })),
+ CardText: vi.fn((text: string) => ({ type: "cardText", text })),
+ Actions: vi.fn((buttons: unknown[]) => ({ type: "actions", buttons })),
</file context>
…t-agent-view-task-button
Previously posted both a plain-text "Generating content..." message and a near-duplicate View Task card. Fold the details into the card body so users see one consolidated message with the action button. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/agents/content/handlers/registerOnNewMention.ts (1)
111-118: Extract the repeated ETA text into a constant.The same ETA phrase is now duplicated across the acknowledgment and card message, which can drift over time.
♻️ Suggested refactor
+ const replyEtaText = "I'll reply here when ready (~5-10 min)."; await thread.post( - `Generating content...\n${details.join("\n")}\n\nI'll reply here when ready (~5-10 min).`, + `Generating content...\n${details.join("\n")}\n\n${replyEtaText}`, ); @@ const card = buildTaskCard( "Content Generation Started", - `Generating content for *${artistSlug}*...\n\nI'll reply here when ready (~5-10 min).`, + `Generating content for *${artistSlug}*...\n\n${replyEtaText}`, runIds[0], );As per coding guidelines, "Use constants for repeated values".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/agents/content/handlers/registerOnNewMention.ts` around lines 111 - 118, The ETA phrase "(~5-10 min)" is duplicated; extract the full repeated phrase (e.g., "I'll reply here when ready (~5-10 min).") into a single constant (name it ETA_MESSAGE or ETA_PHRASE) at the top of registerOnNewMention.ts and replace the literal strings used in both the acknowledgment and the buildTaskCard call so both use that constant; update any string interpolation (e.g., the template passed to buildTaskCard and the earlier acknowledgement message) to reference ETA_MESSAGE to avoid drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/agents/content/handlers/registerOnNewMention.ts`:
- Around line 111-118: The ETA phrase "(~5-10 min)" is duplicated; extract the
full repeated phrase (e.g., "I'll reply here when ready (~5-10 min).") into a
single constant (name it ETA_MESSAGE or ETA_PHRASE) at the top of
registerOnNewMention.ts and replace the literal strings used in both the
acknowledgment and the buildTaskCard call so both use that constant; update any
string interpolation (e.g., the template passed to buildTaskCard and the earlier
acknowledgement message) to reference ETA_MESSAGE to avoid drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ecb99994-e724-4712-af4d-3c3320092ea9
⛔ Files ignored due to path filters (2)
lib/agents/__tests__/buildTaskCard.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**lib/agents/content/__tests__/registerOnNewMention.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**
📒 Files selected for processing (4)
lib/agents/buildTaskCard.tslib/agents/content/handlers/registerOnNewMention.tslib/coding-agent/handlers/handleFeedback.tslib/coding-agent/handlers/onNewMention.ts
Summary
buildTaskCardfromlib/coding-agent/to sharedlib/agents/location (DRY)chat.recoupable.com/tasks/{runId}using the first triggered run ID, matching the coding agent's existing behaviorbuildTaskCardTest plan
buildTaskCard(2 tests)registerOnNewMention(16 tests, including 2 new tests for View Task card)🤖 Generated with Claude Code
Summary by cubic
Adds a single "View Task" card to the content agent’s Slack response so users can open the task run page and see key details. Shares
buildTaskCardacross agents, fulfilling Linear REC-60.New Features
Refactors
buildTaskCardto sharedlib/agents/and updated coding agent imports.Written for commit 71d20da. Summary will update on new commits.
Summary by CodeRabbit