Skip to content

feat: add View Task button to content agent Slack response#430

Merged
sweetmantech merged 3 commits intotestfrom
feature/rec-60-content-agent-view-task-button
Apr 13, 2026
Merged

feat: add View Task button to content agent Slack response#430
sweetmantech merged 3 commits intotestfrom
feature/rec-60-content-agent-view-task-button

Conversation

@recoup-coding-agent
Copy link
Copy Markdown
Collaborator

@recoup-coding-agent recoup-coding-agent commented Apr 13, 2026

Summary

  • Moved buildTaskCard from lib/coding-agent/ to shared lib/agents/ location (DRY)
  • Added "View Task" button to content agent's Slack acknowledgment when content creation is triggered
  • Button links to chat.recoupable.com/tasks/{runId} using the first triggered run ID, matching the coding agent's existing behavior
  • Updated coding agent imports to use the shared buildTaskCard

Test plan

  • Unit tests for buildTaskCard (2 tests)
  • Unit tests for content agent registerOnNewMention (16 tests, including 2 new tests for View Task card)
  • Verify in Slack that content agent response includes "View Task" button
  • Verify button opens correct task URL

🤖 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 buildTaskCard across agents, fulfilling Linear REC-60.

  • New Features

    • Posts a single task card with "View Task" linking to https://chat.recoupable.com/tasks/{runId}; uses the first run ID when multiple runs are triggered.
    • Card body includes generation details to replace the previous plain-text acknowledgment.
  • Refactors

    • Moved buildTaskCard to shared lib/agents/ and updated coding agent imports.

Written for commit 71d20da. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Task cards now automatically post when content generation starts, providing instant status updates and quick access to view task details.

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>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 13, 2026

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

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Apr 13, 2026 10:55pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

Warning

Rate limit exceeded

@sweetmantech has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 47 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9d3e2ca7-fb7f-4dae-94d0-0e7804fd1b51

📥 Commits

Reviewing files that changed from the base of the PR and between 6a825cb and 71d20da.

⛔ Files ignored due to path filters (1)
  • lib/agents/content/__tests__/registerOnNewMention.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (1)
  • lib/agents/content/handlers/registerOnNewMention.ts
📝 Walkthrough

Walkthrough

The pull request centralizes the buildTaskCard utility by consolidating import paths to use an alias-based module reference across handlers, and introduces a new feature that posts a structured task card notification immediately after content creation is triggered, before state management and polling commence.

Changes

Cohort / File(s) Summary
Import Path Consolidation
lib/coding-agent/handlers/handleFeedback.ts, lib/coding-agent/handlers/onNewMention.ts
Updated buildTaskCard import paths from relative to alias-based (@/lib/agents/buildTaskCard) for consistency and improved maintainability.
Task Card Documentation
lib/agents/buildTaskCard.ts
Added explicit @returns JSDoc annotation clarifying that the function returns a Card containing the message and "View Task" link button.
Task Card Notification Feature
lib/agents/content/handlers/registerOnNewMention.ts
Added new workflow step that constructs and posts a task card with "Content Generation Started" status immediately after content creation is confirmed, sending the card to the thread before state management and polling initialization.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🎴 A card is born when content stirs,

Posted swift before the threads confer,

Import paths aligned with grace,

Consistency finds its rightful place. ✨

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Solid & Clean Code ✅ Passed PR successfully applies DRY principle by extracting buildTaskCard to shared lib/agents location, eliminating duplication across handleFeedback.ts and onNewMention.ts with consolidated import paths and minimal focused changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/rec-60-content-agent-view-task-button

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

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

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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 the Card mock parameters would reduce implicit any usage and improve maintainability, but this is low runtime risk.
  • Pay close attention to lib/agents/content/handlers/registerOnNewMention.ts and lib/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)
Loading

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 })),
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 13, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Comment thread lib/agents/content/handlers/registerOnNewMention.ts
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>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6e472c5 and 6a825cb.

⛔ Files ignored due to path filters (2)
  • lib/agents/__tests__/buildTaskCard.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/agents/content/__tests__/registerOnNewMention.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (4)
  • lib/agents/buildTaskCard.ts
  • lib/agents/content/handlers/registerOnNewMention.ts
  • lib/coding-agent/handlers/handleFeedback.ts
  • lib/coding-agent/handlers/onNewMention.ts

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@sweetmantech sweetmantech merged commit 8562fa9 into test Apr 13, 2026
5 of 6 checks passed
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.

2 participants