Skip to content

Add copy response headers action#41884

Open
xiyaoeva wants to merge 1 commit into
appsmithorg:releasefrom
xiyaoeva:feature/copy-api-response-headers
Open

Add copy response headers action#41884
xiyaoeva wants to merge 1 commit into
appsmithorg:releasefrom
xiyaoeva:feature/copy-api-response-headers

Conversation

@xiyaoeva

@xiyaoeva xiyaoeva commented Jun 9, 2026

Copy link
Copy Markdown

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced the API response section with a new "Copy headers" button for improved usability and efficiency. Users can now easily copy all response headers to their clipboard with a single click. A success notification confirms when the copy operation completes successfully, providing clear visual feedback.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

ApiResponseHeaders adds a "Copy headers" toolbar button above the read-only editor. The button serializes and copies the current response headers to the clipboard, showing a success toast. The component wraps the editor with styled containers for the toolbar and editor layout, and disables the button when headers are empty.

Changes

Copy Headers Toolbar

Layer / File(s) Summary
UI structure and styling
app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx
Imports useCallback, clipboard, button, and toast utilities; defines HeadersToolbar and HeadersEditorWrapper styled-components for layout.
Copy headers implementation
app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx
copyResponseHeaders callback serializes and copies headers to clipboard with success toast; render wraps the editor in the new wrapper and adds a "Copy headers" button above it, disabled when empty.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A toolbar blooms above the headers true,
With one quick click—the data's copied through,
A toast ascends to celebrate the win,
Now clipboard holds the secrets tucked within. 📋✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete—it contains only the template structure with no actual details about motivation, context, related issues, or dependencies filled in. Replace template placeholders with concrete information: reference the issue number, explain the motivation/context, list any dependencies, and provide relevant links.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a copy action for response headers in the UI component.
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 unit tests (beta)
  • Create PR with 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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (2)
app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx (2)

82-82: ⚡ Quick win

Use i18n pattern for toast message.

The toast message is hardcoded, but the file already imports createMessage() from ee/constants/messages (line 7). For consistency with the codebase's internationalization pattern, consider adding message constants.

♻️ Use createMessage pattern

Add to ee/constants/messages:

COPY_HEADERS_SUCCESS: () => "Response headers copied to clipboard",
COPY_HEADERS_ERROR: () => "Failed to copy headers to clipboard",

Then update the callback:

-toast.show("Response headers copied to clipboard", {
+toast.show(createMessage(COPY_HEADERS_SUCCESS), {
   kind: "success",
 });
🤖 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
`@app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx`
at line 82, Replace the hardcoded toast text in the ApiResponseHeaders component
with i18n message constants: add COPY_HEADERS_SUCCESS and COPY_HEADERS_ERROR
factory entries to ee/constants/messages, import them into
PluginActionResponse/components/ApiResponseHeaders.tsx (you already import
createMessage), and call toast.show(createMessage(COPY_HEADERS_SUCCESS())) on
successful clipboard copy and toast.show(createMessage(COPY_HEADERS_ERROR())) in
the catch/failure branch so both success and error toasts use the project i18n
pattern.

124-124: ⚡ Quick win

Apply i18n pattern to button text.

The button text "Copy headers" is hardcoded. For consistency with the i18n pattern used elsewhere in the codebase, consider using createMessage().

🤖 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
`@app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx`
at line 124, In ApiResponseHeaders component replace the hardcoded button label
"Copy headers" with the i18n helper (e.g.,
createMessage(Messages.COPY_HEADERS)); import createMessage and the appropriate
Messages key if missing, and use createMessage(Messages.COPY_HEADERS) wherever
the literal "Copy headers" is used (button text, aria-labels or tooltips) so the
component follows the project's i18n pattern.
🤖 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
`@app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx`:
- Around line 80-85: The copyResponseHeaders handler always shows a success
toast even if copy(headersInput.value) fails; change it to capture the boolean
return (e.g., const success = copy(headersInput.value)) and only call toast.show
with the success message when success is true, otherwise call toast.show with an
error/failure message; update the copyResponseHeaders useCallback to use
headersInput.value and the copy result to decide which toast to display.

---

Nitpick comments:
In
`@app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx`:
- Line 82: Replace the hardcoded toast text in the ApiResponseHeaders component
with i18n message constants: add COPY_HEADERS_SUCCESS and COPY_HEADERS_ERROR
factory entries to ee/constants/messages, import them into
PluginActionResponse/components/ApiResponseHeaders.tsx (you already import
createMessage), and call toast.show(createMessage(COPY_HEADERS_SUCCESS())) on
successful clipboard copy and toast.show(createMessage(COPY_HEADERS_ERROR())) in
the catch/failure branch so both success and error toasts use the project i18n
pattern.
- Line 124: In ApiResponseHeaders component replace the hardcoded button label
"Copy headers" with the i18n helper (e.g.,
createMessage(Messages.COPY_HEADERS)); import createMessage and the appropriate
Messages key if missing, and use createMessage(Messages.COPY_HEADERS) wherever
the literal "Copy headers" is used (button text, aria-labels or tooltips) so the
component follows the project's i18n pattern.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e3a1a86b-9ebf-4666-a407-3e395c72bcd5

📥 Commits

Reviewing files that changed from the base of the PR and between 3afa599 and ba070a5.

📒 Files selected for processing (1)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx

Comment on lines +80 to +85
const copyResponseHeaders = useCallback(() => {
copy(headersInput.value);
toast.show("Response headers copied to clipboard", {
kind: "success",
});
}, [headersInput.value]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Handle copy operation failure.

The copy() function returns a boolean indicating success, but the code shows a success toast regardless of the result. If the copy fails (e.g., browser restrictions), users will see a misleading success message.

✅ Check copy success before showing toast
 const copyResponseHeaders = useCallback(() => {
-  copy(headersInput.value);
-  toast.show("Response headers copied to clipboard", {
-    kind: "success",
-  });
+  const success = copy(headersInput.value);
+  if (success) {
+    toast.show("Response headers copied to clipboard", {
+      kind: "success",
+    });
+  } else {
+    toast.show("Failed to copy headers to clipboard", {
+      kind: "error",
+    });
+  }
 }, [headersInput.value]);
📝 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.

Suggested change
const copyResponseHeaders = useCallback(() => {
copy(headersInput.value);
toast.show("Response headers copied to clipboard", {
kind: "success",
});
}, [headersInput.value]);
const copyResponseHeaders = useCallback(() => {
const success = copy(headersInput.value);
if (success) {
toast.show("Response headers copied to clipboard", {
kind: "success",
});
} else {
toast.show("Failed to copy headers to clipboard", {
kind: "error",
});
}
}, [headersInput.value]);
🤖 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
`@app/client/src/PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders.tsx`
around lines 80 - 85, The copyResponseHeaders handler always shows a success
toast even if copy(headersInput.value) fails; change it to capture the boolean
return (e.g., const success = copy(headersInput.value)) and only call toast.show
with the success message when success is true, otherwise call toast.show with an
error/failure message; update the copyResponseHeaders useCallback to use
headersInput.value and the copy result to decide which toast to display.

@github-actions

Copy link
Copy Markdown

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions Bot added the Stale label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant