Skip to content

refactor: remove HTML validation functions and simplify HtmlPreview component logic#6730

Merged
bijin-bruno merged 2 commits intousebruno:mainfrom
abhishek-bruno:fix/html-preview-issues
Jan 7, 2026
Merged

refactor: remove HTML validation functions and simplify HtmlPreview component logic#6730
bijin-bruno merged 2 commits intousebruno:mainfrom
abhishek-bruno:fix/html-preview-issues

Conversation

@abhishek-bruno
Copy link
Member

@abhishek-bruno abhishek-bruno commented Jan 7, 2026

Description

Remove HTML validation functions and simplify HtmlPreview component logic.
Closes #6709

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
    • Streamlined response preview: all string responses are now treated as HTML and rendered in a webview with dynamic base URL support, while non-string data shows as preformatted text.
  • Chores
    • Removed internal HTML validity helpers no longer used by the preview logic.
  • Tests
    • Simplified a test by removing an assertion that checked specific response body content.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

The PR removes HTML-validity checks and routes all string response data into the HTML rendering path (webview with a dynamic base tag). Two helper validators (isValidHtml, isValidHtmlSnippet) were deleted and a test assertion checking response body content was removed.

Changes

Cohort / File(s) Summary
HTML rendering logic
packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/HtmlPreview.js
Consolidated string handling: removed runtime isValidHtml/isValidHtmlSnippet checks and now treats any string as HTML to render in the webview after inserting a <base> tag; non-strings render as preformatted text.
Utility function removals
packages/bruno-app/src/utils/common/index.js, packages/bruno-app/src/utils/response/index.js
Deleted exported helpers isValidHtml and isValidHtmlSnippet; module APIs shrank by those predicates.
Tests
tests/asserts/add-assertions.spec.ts
Removed assertion that validated response body contained "pong" (status assertion retained).

Sequence Diagram(s)

(Skipped — changes are localized to component rendering logic and helper removal; no multi-component sequential flow requiring visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno

Poem

✨ Strings once tested, now set to display,
A base tag whispers the paths on their way;
Helpers retired, the renderer sings,
Webview opens wide — let the HTML bring! 🖼️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: removing HTML validation functions and simplifying HtmlPreview component logic, which aligns with the changeset.
Linked Issues check ✅ Passed The PR removes HTML validation that was blocking valid HTML content from rendering. By treating all strings as potential HTML and rendering them with base tags, it allows HTML dump output like Laravel dd() to display correctly styled.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing HTML rendering: removal of overly restrictive validation functions and simplification of HtmlPreview logic. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 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 859f8b0 and e240359.

📒 Files selected for processing (1)
  • tests/asserts/add-assertions.spec.ts

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
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: 0

🧹 Nitpick comments (1)
packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/HtmlPreview.js (1)

56-72: Consider adding indentation to JSON.stringify for better readability.

Objects are currently stringified without indentation (JSON.stringify(data, null)), which renders them as a single line. For improved readability, consider adding an indent level:

♻️ Proposed refactor
  } else if (typeof data === 'object') {
-    displayContent = JSON.stringify(data, null);
+    displayContent = JSON.stringify(data, null, 2);
  } else {
📜 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 9005e17 and 859f8b0.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/HtmlPreview.js
  • packages/bruno-app/src/utils/common/index.js
  • packages/bruno-app/src/utils/response/index.js
💤 Files with no reviewable changes (2)
  • packages/bruno-app/src/utils/response/index.js
  • packages/bruno-app/src/utils/common/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/QueryResult/QueryResultPreview/HtmlPreview.js
🧠 Learnings (1)
📚 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/QueryResult/QueryResultPreview/HtmlPreview.js
⏰ 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: Unit Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
🔇 Additional comments (2)
packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/HtmlPreview.js (2)

2-2: LGTM: Import simplification aligns with validation removal.

The import statement correctly retains only escapeHtml, which is still needed for safe base URL insertion.


33-54: No action required - the routing logic prevents the issue identified in the review.

HtmlPreview is only rendered when selectedFormat === 'html' or selectedFormat === 'javascript' (QueryResult/index.js). Plain text responses are explicitly routed to TextPreview via selectedFormat === 'raw' (preview-text mode). The typeof data === 'string' check is appropriate for HTML content since it's explicitly selected by the user. The component also includes proper fallback handling for non-string data types (lines 56-72).

Likely an incorrect or invalid review comment.

bijin-bruno
bijin-bruno previously approved these changes Jan 7, 2026
@bijin-bruno bijin-bruno merged commit 0b436e2 into usebruno:main Jan 7, 2026
7 of 8 checks passed
lohit-bruno pushed a commit that referenced this pull request Jan 7, 2026
…omponent logic (#6730)

* refactor: remove HTML validation functions and simplify HtmlPreview component logic

* chore: fix playwright - removed body value check since response is rendered in webview

---------

Co-authored-by: Bijin A B <bijin@usebruno.com>
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.

dump result is not rendered properly in the response

2 participants