Skip to content

fix: sync copy with filtered view#7839

Open
eeshm wants to merge 1 commit intousebruno:mainfrom
eeshm:fix/response-copy-jsonpath-filter-copy
Open

fix: sync copy with filtered view#7839
eeshm wants to merge 1 commit intousebruno:mainfrom
eeshm:fix/response-copy-jsonpath-filter-copy

Conversation

@eeshm
Copy link
Copy Markdown

@eeshm eeshm commented Apr 23, 2026

fixes : #7832

Description

  • Fixes an inconsistency where the response pane showed filtered JSONPath output, but Copy response copied the unfiltered body.
  • Ensures the active responseFilter is applied consistently across the response view and copy functionality.
  • Updates the copy flow so it uses the same filtered/processed data shown in the UI.

before : Copy returns the full response even if filter is applied
after : Copy returns filtered result as shown

sc :
image

Testing

  • Added test: tests/response/response-actions.spec.ts
    should copy filtered JSONPath result when response filter is applied

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Summary by CodeRabbit

New Features

  • Response filtering is now integrated with the copy function—when you apply a response filter (such as JSONPath) and copy the response, the clipboard contains only the filtered data rather than the complete response.

Pass the active response filter through the response copy action so clipboard output matches the filtered JSON view. Add an e2e regression test to verify copy uses filtered JSONPath results.
Copilot AI review requested due to automatic review settings April 23, 2026 10:05
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Walkthrough

A filter parameter is propagated through the response panel component hierarchy—from ResponsePane to ResponsePaneActions to ResponseCopy—enabling the useResponseCopy hook to pass the filter into formatResponse when generating clipboard text. A test case validates copying filtered response content.

Changes

Cohort / File(s) Summary
Response Filter Propagation
packages/bruno-app/src/components/ResponsePane/index.js, packages/bruno-app/src/components/ResponsePane/ResponsePaneActions/index.js, packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
Added filter parameter throughout the component chain. ResponsePane extracts responseFilter from focused tab and passes to ResponsePaneActions, which forwards it to ResponseCopy. The hook useResponseCopy accepts and applies filter when calling formatResponse, with updated dependencies in the clipboard generation logic.
Test Coverage
tests/response/response-actions.spec.ts
New test case validates copying filtered response content by applying a JSONPath filter and verifying clipboard output matches expected filtered JSON.

Sequence Diagram

sequenceDiagram
    participant ResponsePane
    participant ResponsePaneActions
    participant ResponseCopy
    participant formatResponse

    ResponsePane->>ResponsePaneActions: Pass filter from focusedTab.responseFilter
    ResponsePaneActions->>ResponseCopy: Forward filter prop to component
    ResponseCopy->>ResponseCopy: Initialize useResponseCopy hook with filter
    ResponseCopy->>formatResponse: Call with filter parameter on clipboard copy
    formatResponse-->>ResponseCopy: Return filtered response text
    ResponseCopy->>ResponseCopy: Update clipboard with filtered content
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno
  • sid-bruno

Poem

🎬 A filter flows through panes so deep,
From tab to action, copy to keep,
Clipboard now respects the sieve,
Formatted responses with less to retrieve! ✨

🚥 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 title clearly summarizes the main change: ensuring the copy functionality respects the active response filter to match the filtered view shown in the UI.
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 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.

Copy link
Copy Markdown
Contributor

@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)
tests/response/response-actions.spec.ts (1)

65-104: Consider a negative-path assertion too.

The happy path is covered well. A quick follow-up case asserting that clearing the filter restores the full-body copy (or that copy-without-filter still works after this plumbing) would guard against regressions where filter='' is mistakenly treated as truthy downstream. Optional.

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

In `@tests/response/response-actions.spec.ts` around lines 65 - 104, Add a
negative-path assertion that verifies clearing the response filter restores
full-body copy: after the existing filtered-copy checks, clear the filter input
(selector '#response-filter' or use the same UI flow that sets it to ''),
trigger the copy action again via clickResponseAction(page,
'response-copy-btn'), wait for the "Response copied to clipboard" toast, then
read navigator.clipboard.readText() and assert it equals the original full JSON
body (e.g., '{"store":{"book":[{"author":"A"},{"author":"B"}]}}' normalized for
line endings); this guards against treating filter='' as truthy and ensures
response-copy-btn and the response filter plumbing handle an empty filter
correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/response/response-actions.spec.ts`:
- Around line 81-85: The test currently types JSON into the CodeMirror editor
using page.keyboard.type which triggers Bruno's autoCloseBrackets and can
corrupt braces; replace the keystroke approach by targeting the CodeMirror
textarea and calling .fill(...) instead: locate the editor via bodyEditor =
page.getByTestId('request-body-editor').locator('.CodeMirror').first(), then use
bodyEditor.locator('textarea').fill('{"store":{"book":[{"author":"A"},{"author":"B"}]}}')
and remove the keyboard.press/keyboard.type steps so the JSON is set directly
without invoking editor keystroke handlers.

---

Nitpick comments:
In `@tests/response/response-actions.spec.ts`:
- Around line 65-104: Add a negative-path assertion that verifies clearing the
response filter restores full-body copy: after the existing filtered-copy
checks, clear the filter input (selector '#response-filter' or use the same UI
flow that sets it to ''), trigger the copy action again via
clickResponseAction(page, 'response-copy-btn'), wait for the "Response copied to
clipboard" toast, then read navigator.clipboard.readText() and assert it equals
the original full JSON body (e.g.,
'{"store":{"book":[{"author":"A"},{"author":"B"}]}}' normalized for line
endings); this guards against treating filter='' as truthy and ensures
response-copy-btn and the response filter plumbing handle an empty filter
correctly.
🪄 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: aa84d3dd-635f-468c-8834-d3a10cabb51a

📥 Commits

Reviewing files that changed from the base of the PR and between e12b736 and 93ac602.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
  • packages/bruno-app/src/components/ResponsePane/ResponsePaneActions/index.js
  • packages/bruno-app/src/components/ResponsePane/index.js
  • tests/response/response-actions.spec.ts

Comment on lines +81 to +85
const bodyEditor = page.getByTestId('request-body-editor').locator('.CodeMirror').first();
await bodyEditor.click();
await page.keyboard.press(process.platform === 'darwin' ? 'Meta+a' : 'Control+a');
await page.keyboard.type('{"store":{"book":[{"author":"A"},{"author":"B"}]}}');
});
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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm existing tests use a different pattern when seeding CodeMirror bodies
rg -nP -C2 "request-body-editor" tests

Repository: usebruno/bruno

Length of output: 968


🏁 Script executed:

#!/bin/bash
# Search for other keyboard.type usage in tests with CodeMirror
rg -nP "keyboard\.type" tests --type ts --type tsx -C2

Repository: usebruno/bruno

Length of output: 85


🏁 Script executed:

#!/bin/bash
# Search for alternative patterns (fill, paste) in CodeMirror contexts
rg -nP "(\.fill\(|clipboard|paste)" tests --type ts --type tsx -C2 | head -100

Repository: usebruno/bruno

Length of output: 85


🏁 Script executed:

#!/bin/bash
# Look for CodeMirror configuration in Bruno's codebase
fd -e js -e ts -e tsx | xargs grep -l "CodeMirror" | head -20

Repository: usebruno/bruno

Length of output: 1190


🏁 Script executed:

#!/bin/bash
# Check if there's CodeMirror configuration or setup that enables/disables auto-brackets
rg -nP "autoCloseBrackets|matchBrackets|closeBrackets" . --type ts --type tsx --type js -C2 | head -50

Repository: usebruno/bruno

Length of output: 85


🏁 Script executed:

#!/bin/bash
# Search for keyboard.type in test files
rg -nP "keyboard\.type" tests -C2 | head -80

Repository: usebruno/bruno

Length of output: 5941


🏁 Script executed:

#!/bin/bash
# Search for CodeMirror setup/initialization in Bruno codebase
rg -nP "new CodeMirror|CodeMirror\(" . -C3 | head -100

Repository: usebruno/bruno

Length of output: 5149


🏁 Script executed:

#!/bin/bash
# Check for autoCloseBrackets configuration
rg "autoCloseBrackets|bracketMatching" . -C2

Repository: usebruno/bruno

Length of output: 1582


🏁 Script executed:

#!/bin/bash
# Look for textarea fill patterns in tests
rg "textarea.*fill|fill.*textarea" tests -C2

Repository: usebruno/bruno

Length of output: 15125


🏁 Script executed:

#!/bin/bash
# Read the full test file around the flagged lines
cat tests/response/response-actions.spec.ts | head -100

Repository: usebruno/bruno

Length of output: 4218


🏁 Script executed:

#!/bin/bash
# Check for keyboard.type usage specifically with JSON/braces in tests
rg "keyboard\.type.*[{\[\"]" tests -C1 | head -60

Repository: usebruno/bruno

Length of output: 2684


Use .fill() on CodeMirror textarea instead of keyboard.type() for JSON body content.

Bruno's CodeMirror has autoCloseBrackets: true enabled, so typing { or [ will auto-insert matching closers. The established pattern in the test suite is to use bodyEditor.locator('textarea').fill(...) to bypass keystroke handlers. This approach is used consistently across 20+ other tests (headers, variables, multipart fields, etc.) and avoids flakiness from bracket corruption.

Proposed fix
-      const bodyEditor = page.getByTestId('request-body-editor').locator('.CodeMirror').first();
-      await bodyEditor.click();
-      await page.keyboard.press(process.platform === 'darwin' ? 'Meta+a' : 'Control+a');
-      await page.keyboard.type('{"store":{"book":[{"author":"A"},{"author":"B"}]}}');
+      const bodyEditor = page.getByTestId('request-body-editor').locator('.CodeMirror').first();
+      await bodyEditor.click();
+      await bodyEditor.locator('textarea').fill('{"store":{"book":[{"author":"A"},{"author":"B"}]}}');
📝 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 bodyEditor = page.getByTestId('request-body-editor').locator('.CodeMirror').first();
await bodyEditor.click();
await page.keyboard.press(process.platform === 'darwin' ? 'Meta+a' : 'Control+a');
await page.keyboard.type('{"store":{"book":[{"author":"A"},{"author":"B"}]}}');
});
const bodyEditor = page.getByTestId('request-body-editor').locator('.CodeMirror').first();
await bodyEditor.click();
await bodyEditor.locator('textarea').fill('{"store":{"book":[{"author":"A"},{"author":"B"}]}}');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/response/response-actions.spec.ts` around lines 81 - 85, The test
currently types JSON into the CodeMirror editor using page.keyboard.type which
triggers Bruno's autoCloseBrackets and can corrupt braces; replace the keystroke
approach by targeting the CodeMirror textarea and calling .fill(...) instead:
locate the editor via bodyEditor =
page.getByTestId('request-body-editor').locator('.CodeMirror').first(), then use
bodyEditor.locator('textarea').fill('{"store":{"book":[{"author":"A"},{"author":"B"}]}}')
and remove the keyboard.press/keyboard.type steps so the JSON is set directly
without invoking editor keystroke handlers.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an inconsistency where “Copy response” ignored an active JSONPath response filter by passing the current responseFilter through the ResponsePane actions pipeline and into the copy formatter.

Changes:

  • Pass the active responseFilter from ResponsePaneResponsePaneActionsResponseCopy.
  • Apply the filter during copy by forwarding it to formatResponse(...).
  • Add a Playwright regression test ensuring filtered JSONPath output is copied.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/response/response-actions.spec.ts Adds an E2E regression test validating clipboard contents match filtered JSONPath output.
packages/bruno-app/src/components/ResponsePane/index.js Passes the active focusedTab.responseFilter into the response action components.
packages/bruno-app/src/components/ResponsePane/ResponsePaneActions/index.js Threads the new filter prop through to ResponseCopy.
packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js Uses formatResponse(..., filter) so copy matches the filtered/processed editor output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

"Copy" icon on response pane does not copy the actual content

2 participants