Skip to content

fix: run formatResponse execution on copy button click#6485

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
pooja-bruno:fix/run-format-response-on-copy
Dec 23, 2025
Merged

fix: run formatResponse execution on copy button click#6485
bijin-bruno merged 1 commit intousebruno:mainfrom
pooja-bruno:fix/run-format-response-on-copy

Conversation

@pooja-bruno
Copy link
Collaborator

@pooja-bruno pooja-bruno commented Dec 23, 2025

Description

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.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Refactor
    • Improved internal code organization in the response copying functionality for better maintainability and readability, with no impact on user experience or functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

Refactored the ResponseCopy component to extract text-to-copy computation logic into a dedicated getTextToCopy helper function, replacing inline useMemo logic with useCallback. The public API and functional behavior remain unchanged.

Changes

Cohort / File(s) Summary
ResponseCopy Refactoring
packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
Extracted textToCopy computation into getTextToCopy helper function; replaced useMemo with useCallback for copyResponse callback; improved code organization and readability without functional changes

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • usebruno/bruno#6436: Modifies the same ResponseCopy logic for determining the text to copy based on selectedFormat, selectedTab, and data.

Suggested reviewers

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

Poem

Copy logic flows to helper's home,
No longer inline does it roam,
useCallback now stands tall and clear,
Refactored thoughts, more structured cheer! 📋✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes running formatResponse on copy button click, but the actual changes refactor the copy logic by extracting text selection into a helper function without explicitly handling formatResponse execution. Clarify the title to reflect the actual refactoring (e.g., 'refactor: extract text selection logic in ResponseCopy') or verify that formatResponse is being called during copy and update the implementation accordingly.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70178f6 and dd92813.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
🧠 Learnings (3)
📓 Common learnings
Learnt from: sid-bruno
Repo: usebruno/bruno PR: 6266
File: packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js:38-38
Timestamp: 2025-12-02T09:45:31.709Z
Learning: In the ResponseCopy component (packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js), the copy button is intentionally disabled using `!response.data` to prevent copying stream resets which result in empty strings.
📚 Learning: 2025-12-02T09:45:31.709Z
Learnt from: sid-bruno
Repo: usebruno/bruno PR: 6266
File: packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js:38-38
Timestamp: 2025-12-02T09:45:31.709Z
Learning: In the ResponseCopy component (packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js), the copy button is intentionally disabled using `!response.data` to prevent copying stream resets which result in empty strings.

Applied to files:

  • packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js (4)
packages/bruno-app/src/components/ResponsePane/QueryResponse/index.js (2)
  • selectedTab (21-21)
  • selectedFormat (20-20)
packages/bruno-app/src/components/RunnerResults/ResponsePane/index.js (1)
  • selectedTab (18-18)
packages/bruno-app/src/components/ResponsePane/index.js (1)
  • selectedFormat (52-52)
packages/bruno-app/src/utils/common/index.js (4)
  • dataBuffer (284-284)
  • dataBuffer (388-388)
  • formatResponse (277-433)
  • formatResponse (277-433)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Windows
🔇 Additional comments (3)
packages/bruno-app/src/components/ResponsePane/ResponseCopy/index.js (3)

1-1: LGTM! Appropriate import change for the refactoring.

The switch from useMemo to useCallback aligns with refactoring copyResponse to use useCallback for function identity stability.


35-44: LGTM! Proper use of useCallback with correct dependencies.

The refactoring correctly stabilizes the copyResponse function identity, and the dependency array includes all values used within the callback (selectedTab, selectedFormat, data, dataBuffer). The function properly delegates text computation to getTextToCopy before copying to the clipboard.


9-20: The condition on line 16 is appropriate. dataBuffer is always provided alongside data in response construction, and since formatResponse returns an empty string when dataBuffer is missing, requiring it prevents unnecessary calls. No valid scenarios exist where data exists but dataBuffer should still be formatted.


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.

@bijin-bruno bijin-bruno merged commit 01d4d3d into usebruno:main Dec 23, 2025
8 checks passed
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.

2 participants