Skip to content

fix(ws): remove default '{}' message body and make all message headers sticky#8565

Merged
sid-bruno merged 3 commits into
usebruno:mainfrom
pooja-bruno:fix/ws-message-body-default-and-sticky-headers
Jul 13, 2026
Merged

fix(ws): remove default '{}' message body and make all message headers sticky#8565
sid-bruno merged 3 commits into
usebruno:mainfrom
pooja-bruno:fix/ws-message-body-default-and-sticky-headers

Conversation

@pooja-bruno

@pooja-bruno pooja-bruno commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Description

JIRA

  1. Empty message body no longer defaults to {}.

  2. Sticky headers for all messages. Only the selected message's header stuck to the top when scrolling; now every message header is sticky.

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

Summary by CodeRabbit

  • Bug Fixes

    • WebSocket body:ws content now defaults to an empty payload (no {}) when content is missing/falsy.
    • Accordion headers now remain sticky during scrolling (with the correct background styling), including for disabled rows.
  • Tests

    • Updated WebSocket UI tests to use shared locators/utilities and improved tab/cleanup handling.
    • Added coverage to confirm default message bodies stay empty and expanded websocket locators/action helpers for add/send/delete.

@pooja-bruno pooja-bruno changed the title fix(ws): remove default '{}' message body and make all message header… fix(ws): remove default '{}' message body and make all message headers sticky Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

WebSocket message serialization now emits empty content instead of {} for falsy values. Accordion headers remain sticky for disabled rows. Shared locators, modal cleanup, and browser tests cover empty bodies for new and initial WebSocket messages.

Changes

WebSocket message defaults

Layer / File(s) Summary
Empty message serialization and rendering
packages/bruno-lang/v2/src/jsonToBru.js, packages/bruno-app/.../StyledWrapper.js
Falsy WebSocket content defaults to an empty string, and accordion headers always receive sticky themed styling.
WebSocket test flow and coverage
tests/utils/page/actions.ts, tests/utils/page/locators.ts, tests/websockets/message-body-default.spec.ts, packages/bruno-lang/v2/tests/jsonToBru.spec.js
Shared locators, transient-request cleanup, and serialization assertions cover empty bodies on newly added and initial messages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: helloanoop, bijin-bruno, lohit-bruno, naman-bruno, vijayh-bruno, utkarsh-bruno, sid-bruno

Poem

Empty messages whisper, “...”
Sticky headers hold their place,
Tests close tabs and calm modals,
New frames bloom with vacant space,
{} fades without a trace.

🚥 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 accurately reflects the two main changes: removing the default '{}' WS body and making message headers sticky.
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.
✨ 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.

@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.

🧹 Nitpick comments (2)
packages/bruno-lang/v2/src/jsonToBru.js (1)

663-663: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a unit test for the empty-content fallback.

The existing jsonToBru.spec.js smoke test only covers non-empty content ({"foo":"bar"}). A unit test asserting that falsy content serializes to an empty content: ''' ... ''' block would lock in this behavioral change at the serialization layer.

🤖 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 `@packages/bruno-lang/v2/src/jsonToBru.js` at line 663, Add a unit test in
jsonToBru.spec.js covering the serialization path in jsonToBru where content is
falsy, such as an empty string or null. Assert that the generated Bru output
contains an empty content: ''' ... ''' block, while preserving the existing
non-empty content coverage.
tests/websockets/message-body-default.spec.ts (1)

27-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move inline .CodeMirror CSS selectors to the page module.

The spec uses inline CSS selectors (.CodeMirror, .CodeMirror-placeholder, .CodeMirror-code) directly in the test body. Per path instructions, selectors should be single-sourced in page modules under tests/utils/page/* rather than inline in specs. Consider adding a codeEditor locator (e.g., editor: (index: number) => ws.message.body(index).locator('.CodeMirror')) and placeholder/code-content sub-locators to buildWebsocketCommonLocators so the spec destructures them instead of chaining raw CSS classes.

♻️ Suggested page-module additions
 // in buildWebsocketCommonLocators, inside the message object:
     body: (index: number) => page.getByTestId(`ws-message-body-${index}`),
+    editor: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror'),
+    editorPlaceholder: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror-placeholder'),
+    editorCode: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror-code'),

Then in the spec:

-    const editor = newBody.locator('.CodeMirror');
-    await expect(editor.locator('.CodeMirror-placeholder')).toHaveText('...');
-    await expect(editor.locator('.CodeMirror-code')).not.toContainText('{}');
+    await expect(ws.message.editorPlaceholder(beforeCount)).toHaveText('...');
+    await expect(ws.message.editorCode(beforeCount)).not.toContainText('{}');

Also applies to: 46-50

🤖 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 `@tests/websockets/message-body-default.spec.ts` around lines 27 - 31, Move all
inline CodeMirror selectors from the test into the websocket page-module
locators. Extend buildWebsocketCommonLocators with an editor locator and
placeholder/code-content sub-locators, then update the spec to destructure and
use those shared locators instead of directly referencing .CodeMirror,
.CodeMirror-placeholder, or .CodeMirror-code.

Source: Path instructions

🤖 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.

Nitpick comments:
In `@packages/bruno-lang/v2/src/jsonToBru.js`:
- Line 663: Add a unit test in jsonToBru.spec.js covering the serialization path
in jsonToBru where content is falsy, such as an empty string or null. Assert
that the generated Bru output contains an empty content: ''' ... ''' block,
while preserving the existing non-empty content coverage.

In `@tests/websockets/message-body-default.spec.ts`:
- Around line 27-31: Move all inline CodeMirror selectors from the test into the
websocket page-module locators. Extend buildWebsocketCommonLocators with an
editor locator and placeholder/code-content sub-locators, then update the spec
to destructure and use those shared locators instead of directly referencing
.CodeMirror, .CodeMirror-placeholder, or .CodeMirror-code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d91e6b35-cf00-4286-a9c9-268526a78a05

📥 Commits

Reviewing files that changed from the base of the PR and between 8ceaf72 and c57c587.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.js
  • packages/bruno-lang/v2/src/jsonToBru.js
  • tests/utils/page/actions.ts
  • tests/utils/page/locators.ts
  • tests/websockets/message-body-default.spec.ts

@sachin-thakur-bruno sachin-thakur-bruno 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.

tested locally working fine. Added a non blocker comment

Comment thread tests/websockets/message-body-default.spec.ts Outdated

@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.

🧹 Nitpick comments (1)
packages/bruno-lang/v2/tests/jsonToBru.spec.js (1)

56-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider covering other falsy content values.

The upstream serialization uses content || '', so null, undefined, 0, and false all serialize identically to ''. Adding a quick parameterized case for null and undefined would strengthen confidence that the {} fallback removal holds across all falsy inputs, not just empty strings.

🤖 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 `@packages/bruno-lang/v2/tests/jsonToBru.spec.js` around lines 56 - 73, Add
parameterized test cases in the existing “serializes falsy content to an empty
content block” test in jsonToBru.spec.js for null and undefined content,
asserting each serializes as an empty content block and does not emit '{}'.
🤖 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.

Nitpick comments:
In `@packages/bruno-lang/v2/tests/jsonToBru.spec.js`:
- Around line 56-73: Add parameterized test cases in the existing “serializes
falsy content to an empty content block” test in jsonToBru.spec.js for null and
undefined content, asserting each serializes as an empty content block and does
not emit '{}'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a9793950-8f6e-4873-b367-c1352d4c7f0d

📥 Commits

Reviewing files that changed from the base of the PR and between a243c76 and 0fc9b41.

📒 Files selected for processing (3)
  • packages/bruno-lang/v2/tests/jsonToBru.spec.js
  • tests/utils/page/locators.ts
  • tests/websockets/message-body-default.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/utils/page/locators.ts
  • tests/websockets/message-body-default.spec.ts

@sid-bruno sid-bruno merged commit 61c495c into usebruno:main Jul 13, 2026
14 of 17 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.

3 participants