Conversation
Co-authored-by: eliesteinbock <eliesteinbock@gmail.com>
|
Cursor Agent can help with this pull request. Just |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces webhook-specific UI enhancements: tooltip for CALL_WEBHOOK action, input placeholder and a “View payload structure” link in RuleForm, a new WebhookDocumentation component with dialog and copyable payload examples, minor spacing and settings text tweaks, action field type updated to support placeholders, and version bump to v2.6.13. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant RulesTab as Rules Tab
participant RuleForm as RuleForm
participant DocLink as WebhookDocumentationLink
participant Dialog as WebhookDocumentationDialog
User->>RulesTab: Open Rules
RulesTab->>RuleForm: Render action fields
Note over RuleForm: CALL_WEBHOOK URL shows placeholder and tooltip enabled
User->>DocLink: Click "View payload structure"
DocLink->>Dialog: Open dialog
Dialog-->>User: Display example payload + copy action
User->>Dialog: Copy payload JSON
Dialog-->>User: Copied state (check icon)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
|
|
@cursor @cursoragent we already had existing webhook functionality in the project. the main thing was to just tell the dev how to use the feature. |
|
I streamlined the webhook documentation experience by removing a dedicated page and simplifying the in-app dialog to focus solely on the webhook payload structure. This makes the information more accessible and concise directly within the settings.
3 tasks completed
Learn more about Cursor Agents |
Co-authored-by: eliesteinbock <eliesteinbock@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (6)
apps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsx (1)
17-17: Copy nit: use a readable breadcrumb arrow.
Replace ASCII "=>":- description="API webhook secret for request verification. Include this in the X-Webhook-Secret header when setting up webhook endpoints. Set webhook URLs for individual rules in the Assistant=>Rules tab." + description="API webhook secret for request verification. Include this in the X-Webhook-Secret header when setting up webhook endpoints. Set webhook URLs for individual rules in the Assistant → Rules tab."apps/web/utils/action-item.ts (1)
141-144: Clarify label as “Webhook URL”.
Minor UX clarity improvement in forms.- label: "URL", + label: "Webhook URL",apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsx (1)
217-217: Prevent long webhook URLs from overflowing.
Add Tailwind word-break to the summary wrapper.- <div className="whitespace-pre-wrap">{summaryContent}</div> + <div className="whitespace-pre-wrap break-all">{summaryContent}</div>apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx (1)
1269-1276: Use type="url" for webhook URL input; keep inline docs linkImprove UX/validation for the webhook URL by using the URL input type. The docs link integration looks good.
Apply this diff:
- <Input - type="text" + <Input + type={field.name === "url" ? "url" : "text"} name={`actions.${index}.${field.name}.value`} registerProps={register( `actions.${index}.${field.name}.value`, )} placeholder={field.placeholder} />Also applies to: 1277-1282
apps/web/components/WebhookDocumentation.tsx (2)
75-87: Add accessible label/title to icon-only copy buttonIcon-only controls need an accessible name.
Apply this diff:
- <Button - variant="ghost" - size="sm" - onClick={() => copyToClipboard(payloadJson)} - > + <Button + variant="ghost" + size="sm" + aria-label={copied ? "Copied payload JSON" : "Copy payload JSON"} + title={copied ? "Copied payload JSON" : "Copy payload JSON"} + onClick={() => copyToClipboard(payloadJson)} + >
66-72: Clarify HTTP details (method and content type)Explicitly state Content-Type to remove ambiguity.
Apply this diff:
<div className="text-sm text-muted-foreground"> When a rule with a webhook action is triggered, we'll send a POST request to your URL with the following payload: </div> + <div className="text-xs text-muted-foreground"> + HTTP details: Method <code>POST</code>, <code>Content-Type: application/json</code>. + </div>
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx(2 hunks)apps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsx(2 hunks)apps/web/components/WebhookDocumentation.tsx(1 hunks)apps/web/utils/action-item.ts(2 hunks)version.txt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (18)
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use@/for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/utils/action-item.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/**
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
NextJS app router structure with (app) directory
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/**/*.tsx
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
!{.cursor/rules/*.mdc}
📄 CodeRabbit inference engine (.cursor/rules/cursor-rules.mdc)
Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/utils/action-item.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxversion.txt
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport Prisma in the project using
import prisma from "@/utils/prisma";
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/utils/action-item.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/(app)/*/**
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/(app)/*/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
If you need to use onClick in a component, that component is a client component and file must start with 'use client'
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/(app)/*/**/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
If we're in a deeply nested component we will use swr to fetch via API
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Components with
onClickmust be client components withuse clientdirective
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/utils/action-item.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
!pages/_document.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/utils/action-item.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxversion.txt
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
**/*.{html,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...Files:
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsxapps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/WebhookDocumentation.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using ZodFiles:
apps/web/utils/action-item.tsapps/web/utils/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logicFiles:
apps/web/utils/action-item.tsapps/web/utils/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle sizeFiles:
apps/web/utils/action-item.tsapps/web/components/**/*.tsx
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Use React Hook Form with Zod validation for form handling
Use the
LoadingContentcomponent to handle loading and error states consistently in data-fetching components.Use PascalCase for components (e.g.
components/Button.tsx)Files:
apps/web/components/WebhookDocumentation.tsx🧬 Code graph analysis (2)
apps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsx (1)
apps/web/app/(app)/[emailAccountId]/settings/WebhookGenerate.tsx (1)
RegenerateSecretButton(8-43)apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx (1)
apps/web/components/WebhookDocumentation.tsx (1)
WebhookDocumentationLink(152-164)🔇 Additional comments (10)
version.txt (2)
1-1: Version bump looks good.
No functional impact.
1-1: Guardrail passed: no<img>/<picture>tags in the docs UI code. Searches inapps/web(tsx, jsx, mdx, html) returned no instances; the only<img>is inREADME.md(outside code).apps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsx (1)
8-8: Layout spacing tweak LGTM.
The added mt-8 improves visual rhythm without side effects.apps/web/app/(app)/[emailAccountId]/settings/WebhookSection.tsx (2)
29-34: Button layout wrapper LGTM.
The flex container aligns the Copy and Regenerate buttons cleanly.
17-17: Verify backend verification logic uses ‘X-Webhook-Secret’. The header name is consistent across frontend code and docs; confirm the backend webhook handler expects the same casing and name to avoid doc drift.apps/web/utils/action-item.ts (1)
25-26: Additive placeholder field is safe and useful.
Type addition is backward-compatible; placeholder on CALL_WEBHOOK improves DX.Also applies to: 141-144
apps/web/app/(app)/[emailAccountId]/assistant/ActionSummaryCard.tsx (1)
176-178: Good tooltip copy—concise and actionable.
No logic changes; improves discoverability.apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx (2)
99-99: Webhook docs link import — LGTMImport path and usage align with project aliases. No issues.
1275-1276: Contextual placeholders for action fields — LGTMPassing field-specific placeholders from actionInputs improves clarity without coupling.
apps/web/components/WebhookDocumentation.tsx (1)
46-63: No changes needed: documentation matches implementation
The example payload fields (strings for cc/bcc, no “to” property) and theheaderMessageIdnaming align exactly with theWebhookPayloadtype in apps/web/utils/webhook.ts, and the header is correctly cased asX-Webhook-Secret.
| const copyToClipboard = async (text: string) => { | ||
| try { | ||
| await navigator.clipboard.writeText(text); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 2000); | ||
| } catch (err) { | ||
| console.error("Failed to copy text: ", err); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Remove console usage; add clipboard fallback + user feedback
Project guideline forbids console usage. Add a graceful fallback when navigator.clipboard is unavailable/blocked and surface an error toast.
Apply this diff:
import { useState } from "react";
import { Copy, Check } from "lucide-react";
import { Button } from "@/components/ui/button";
+import { toastError } from "@/components/Toast";
@@
const copyToClipboard = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
- } catch (err) {
- console.error("Failed to copy text: ", err);
+ } catch {
+ // Fallback for insecure contexts or denied permissions
+ try {
+ const el = document.createElement("textarea");
+ el.value = text;
+ el.setAttribute("readonly", "");
+ el.style.position = "absolute";
+ el.style.left = "-9999px";
+ document.body.appendChild(el);
+ el.select();
+ document.execCommand("copy");
+ document.body.removeChild(el);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ } catch {
+ toastError({ description: "Failed to copy to clipboard." });
+ }
}
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const copyToClipboard = async (text: string) => { | |
| try { | |
| await navigator.clipboard.writeText(text); | |
| setCopied(true); | |
| setTimeout(() => setCopied(false), 2000); | |
| } catch (err) { | |
| console.error("Failed to copy text: ", err); | |
| } | |
| }; | |
| import { useState } from "react"; | |
| import { Copy, Check } from "lucide-react"; | |
| import { Button } from "@/components/ui/button"; | |
| import { toastError } from "@/components/Toast"; | |
| const copyToClipboard = async (text: string) => { | |
| try { | |
| await navigator.clipboard.writeText(text); | |
| setCopied(true); | |
| setTimeout(() => setCopied(false), 2000); | |
| } catch { | |
| // Fallback for insecure contexts or denied permissions | |
| try { | |
| const el = document.createElement("textarea"); | |
| el.value = text; | |
| el.setAttribute("readonly", ""); | |
| el.style.position = "absolute"; | |
| el.style.left = "-9999px"; | |
| document.body.appendChild(el); | |
| el.select(); | |
| document.execCommand("copy"); | |
| document.body.removeChild(el); | |
| setCopied(true); | |
| setTimeout(() => setCopied(false), 2000); | |
| } catch { | |
| toastError({ description: "Failed to copy to clipboard." }); | |
| } | |
| } | |
| }; |
🤖 Prompt for AI Agents
In apps/web/components/WebhookDocumentation.tsx around lines 35 to 43, remove
the console.error usage and implement a graceful clipboard fallback and
user-facing error toast: first try navigator.clipboard.writeText if available,
otherwise copy by creating a hidden textarea, selecting its content and using
document.execCommand('copy'); on success setCopied(true) and clear it after 2s
as before; on any failure call the project's toast/error notification API (do
not use console) with a clear message like "Failed to copy to clipboard" and
include optional error detail, and ensure any created DOM nodes are cleaned up
and proper permission errors are handled.
| placeholder?: string; | ||
| }[]; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify placeholder is actually rendered and URL is validated.
Ensure RuleForm passes field.placeholder to the Input and Zod validates https URLs for CALL_WEBHOOK.
🏁 Script executed:
#!/bin/bash
# 1) Confirm placeholder is wired into RuleForm inputs
rg -nP -C3 'placeholder\s*=' apps/web/app/\(app\)/\[emailAccountId]/assistant/RuleForm.tsx
# 2) Locate rule.validation and check CALL_WEBHOOK url uses z.string().url()
fd -t f 'rule.validation.*\.ts' apps/web | xargs -I {} rg -nP -C3 'CALL_WEBHOOK|url\s*:\s*z\.string\(\)\.url\(\)' {}Length of output: 2072
Enforce URL format in Zod schema for CALL_WEBHOOK
Placeholder wiring in RuleForm is correct. In apps/web/utils/rule.validation.ts, the url field for ActionType.CALL_WEBHOOK only checks !data.url?.value?.trim(); replace this manual check with a Zod constraint such as z.string().url() (or restrict to HTTPS) to validate URL format.
🤖 Prompt for AI Agents
In apps/web/utils/action-item.ts around lines 25 to 26, the current handling
leaves URL format validation to a manual check elsewhere; replace that with a
Zod constraint on the CALL_WEBHOOK url field by using z.string().url() (or
z.string().regex(/^https:\/\//) if you want to enforce HTTPS only), ensuring the
schema requires a non-empty string and validates format, update any optional
chaining to match the schema (make the field required if needed) and provide a
clear Zod error message for invalid URLs so the manual !data.url?.value?.trim()
check can be removed.
Add comprehensive webhook documentation and integrate it into the UI to improve the developer experience.
This PR addresses the need for better webhook documentation and user experience, providing developers with easy access to payload schemas, examples, and best practices directly within the application, thereby eliminating guesswork during configuration.
Summary by CodeRabbit
New Features
UI/Style
Documentation
Chores