Skip to content

feat: add AgentRunActivityAction type and action field to activity in…#41

Open
gakshita wants to merge 3 commits intomainfrom
feat/activity-action-type
Open

feat: add AgentRunActivityAction type and action field to activity in…#41
gakshita wants to merge 3 commits intomainfrom
feat/activity-action-type

Conversation

@gakshita
Copy link
Copy Markdown
Collaborator

@gakshita gakshita commented May 4, 2026

Summary

  • Adds AgentRunActivityAction interface with name and redirect_url fields
  • Adds optional action?: AgentRunActivityAction | null to AgentRunActivity (response shape from API)
  • Adds optional action?: AgentRunActivityAction | null to CreateAgentRunActivityRequest (request shape to API)

Context

Agents need to attach a CTA button to response activities — for example, nudging a user to connect their account when a personal API key is missing. This button is a top-level action on the activity, separate from content, so the frontend can render it independently of the response body.

Without this type, passing action to planeClient.agentRuns.activities.create(...) is rejected as an unknown property.

Changes

// New type
export interface AgentRunActivityAction {
  name: string;
  redirect_url: string | null;
}

// Added to AgentRunActivity
action?: AgentRunActivityAction | null;

// Added to CreateAgentRunActivityRequest
action?: AgentRunActivityAction | null;


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Activities on agent runs can include one or more actions with display names and optional redirect URLs, enabling users to trigger navigation or external flows directly from activity events.
  * Agent runs can be updated to include an optional external link, allowing runs to reference or redirect to related external resources.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3e4c344e-2e1e-4612-988c-39c2707ed9dc

📥 Commits

Reviewing files that changed from the base of the PR and between 3d7d1ef and 9e86ff6.

📒 Files selected for processing (1)
  • src/models/AgentRun.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/models/AgentRun.ts

📝 Walkthrough

Walkthrough

Adds a nullable external_link update request type and an AgentRunActivityAction type; extends text activity content to include optional actions. Exposes AgentRuns.update(workspaceSlug, runId, data) which PATCHes a run and returns the updated AgentRun.

Changes

Agent Run models + API update

Layer / File(s) Summary
Data Shape
src/models/AgentRun.ts
Adds UpdateAgentRunRequest with `external_link?: string
Model Extension
src/models/AgentRun.ts
Extends AgentRunActivityTextContent to include optional actions?: AgentRunActivityAction[].
API Wiring
src/api/AgentRuns/index.ts
Imports UpdateAgentRunRequest and adds AgentRuns.update(workspaceSlug, runId, data) which PATCHes /workspaces/${workspaceSlug}/runs/${runId}/ and returns AgentRun.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through types with nimble paws,
I planted links and tiny action laws,
Text bubbles learned to carry more,
A PATCH that opens one new door,
🥕 Hooray — a rabbit's joyful cause

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main changes: adding AgentRunActivityAction type and action field to activity content, which aligns with the changeset modifications to AgentRunActivityTextContent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/activity-action-type

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@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)
src/models/AgentRun.ts (1)

110-123: ⚡ Quick win

Add unit coverage for action round-trip behavior.

Nice type alignment on both request/response. Please add a focused unit test that creates an activity with top-level action and asserts it is sent/parsed as expected (current activity-create test covers content action type, but not this new top-level field).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models/AgentRun.ts` around lines 110 - 123, Add a unit test that
exercises the top-level action round-trip: construct a
CreateAgentRunActivityRequest with its action field set to a non-null
AgentRunActivityAction, call the same activity creation helper used by the
existing activity-create test, assert the outgoing request payload contains the
top-level action, and assert the parsed response includes the same action value
(verify both serialization and deserialization). Target the code that
builds/parses agent activities (use CreateAgentRunActivityRequest,
AgentRunActivityAction, and the activity create/parse helpers used in the
current tests) and keep the test focused only on the top-level action behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/models/AgentRun.ts`:
- Around line 110-123: Add a unit test that exercises the top-level action
round-trip: construct a CreateAgentRunActivityRequest with its action field set
to a non-null AgentRunActivityAction, call the same activity creation helper
used by the existing activity-create test, assert the outgoing request payload
contains the top-level action, and assert the parsed response includes the same
action value (verify both serialization and deserialization). Target the code
that builds/parses agent activities (use CreateAgentRunActivityRequest,
AgentRunActivityAction, and the activity create/parse helpers used in the
current tests) and keep the test focused only on the top-level action behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8849bce1-f1cb-43a1-89e7-4dc4dffb8ea8

📥 Commits

Reviewing files that changed from the base of the PR and between b5534e8 and 0cb4f1a.

📒 Files selected for processing (1)
  • src/models/AgentRun.ts

…terfaces

Adds AgentRunActivityAction interface (name + redirect_url) and an optional
action field to AgentRunActivity and CreateAgentRunActivityRequest, so agents
can attach CTA buttons to response activities.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gakshita gakshita force-pushed the feat/activity-action-type branch from 0cb4f1a to 0d29ff7 Compare May 4, 2026 14:15
Co-Authored-By: Claude Sonnet 4.6 <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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/models/AgentRun.ts (1)

68-70: ⚡ Quick win

Derive UpdateAgentRunRequest from the model to reduce DTO drift.

This DTO is small now, but deriving it via Pick/Partial keeps it aligned with AgentRun over time and follows the models convention.

Proposed refactor
-export interface UpdateAgentRunRequest {
-  external_link?: string | null;
-}
+export interface UpdateAgentRunRequest extends Partial<Pick<AgentRun, "external_link">> {
+  external_link?: string | null;
+}

As per coding guidelines, src/models/**/*.ts: Use TypeScript interfaces for entity models with separate Create/Update DTOs using Pick, Omit, and Partial.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/AgentRun.ts` around lines 68 - 70, UpdateAgentRunRequest is
defined manually and may drift from the AgentRun model; change its definition to
derive from the AgentRun interface using TypeScript utility types (e.g., Pick
and Partial) so it stays aligned. Locate the AgentRun interface and replace the
explicit UpdateAgentRunRequest fields with a derived type such as
Partial<Pick<AgentRun, 'external_link'>> (or the appropriate property set) so
the DTO follows the models convention and will update automatically if AgentRun
changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/models/AgentRun.ts`:
- Line 117: Change the top-level property from an array to a nullable singular
field: replace occurrences of actions?: AgentRunActivityAction[] with action?:
AgentRunActivityAction | null in the AgentRun model so the type matches the API
contract; update the declarations referenced (the property at/around the
AgentRun interface/class and the other occurrence currently named actions) to
use the singular name "action" and allow nullability instead of an array so
callers passing a single action will type-check correctly.

---

Nitpick comments:
In `@src/models/AgentRun.ts`:
- Around line 68-70: UpdateAgentRunRequest is defined manually and may drift
from the AgentRun model; change its definition to derive from the AgentRun
interface using TypeScript utility types (e.g., Pick and Partial) so it stays
aligned. Locate the AgentRun interface and replace the explicit
UpdateAgentRunRequest fields with a derived type such as Partial<Pick<AgentRun,
'external_link'>> (or the appropriate property set) so the DTO follows the
models convention and will update automatically if AgentRun changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06a07e8b-07d7-4f54-a67e-28fd06eabf03

📥 Commits

Reviewing files that changed from the base of the PR and between 0cb4f1a and 3d7d1ef.

📒 Files selected for processing (2)
  • src/api/AgentRuns/index.ts
  • src/models/AgentRun.ts

Comment thread src/models/AgentRun.ts Outdated
type: AgentRunActivityType;
project?: string;
workspace: string;
actions?: AgentRunActivityAction[];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Use singular nullable action here to match the intended API contract.

Line 117 and Line 130 currently expose actions?: AgentRunActivityAction[], but the feature goal is a single top-level CTA (action?: AgentRunActivityAction | null). With the current shape, callers passing action still won’t type-check as intended.

Proposed fix
 export interface AgentRunActivity extends BaseModel {
@@
-  actions?: AgentRunActivityAction[];
+  action?: AgentRunActivityAction | null;
 }
@@
 export interface CreateAgentRunActivityRequest {
@@
-  actions?: AgentRunActivityAction[];
+  action?: AgentRunActivityAction | null;
 }

Also applies to: 130-130

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/AgentRun.ts` at line 117, Change the top-level property from an
array to a nullable singular field: replace occurrences of actions?:
AgentRunActivityAction[] with action?: AgentRunActivityAction | null in the
AgentRun model so the type matches the API contract; update the declarations
referenced (the property at/around the AgentRun interface/class and the other
occurrence currently named actions) to use the singular name "action" and allow
nullability instead of an array so callers passing a single action will
type-check correctly.

…t top-level fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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