Skip to content

feat(ws): add protobuf body mode for websocket messages#7936

Open
DevRajah wants to merge 2 commits into
usebruno:mainfrom
DevRajah:feat/ws-protobuf-body-mode
Open

feat(ws): add protobuf body mode for websocket messages#7936
DevRajah wants to merge 2 commits into
usebruno:mainfrom
DevRajah:feat/ws-protobuf-body-mode

Conversation

@DevRajah
Copy link
Copy Markdown

@DevRajah DevRajah commented May 7, 2026

Description

Adds PROTOBUF as a selectable body mode for WebSocket messages.

This improves consistency between WebSocket and gRPC workflows by allowing protobuf-formatted WebSocket payloads to be selected and displayed correctly in the editor UI.

Changes

  • Added PROTOBUF option to the WebSocket body mode dropdown
  • Added protobuf type mapping for WebSocket messages
  • Added protobuf label handling in humanizeRequestBodyMode

Screenshot

image

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.

Summary by CodeRabbit

  • New Features

    • Added Protocol Buffer (Protobuf) support for WebSocket message bodies — users can select and work with protobuf-formatted messages and see appropriate editor highlighting.
  • Improvements

    • Editor “Format”/prettify control is now only enabled for JSON or XML payloads to prevent invalid formatting attempts.
    • Human-readable request body mode list now includes a Protobuf label.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4364a623-de19-4c36-8069-4fd86f3d1752

📥 Commits

Reviewing files that changed from the base of the PR and between ecd51fd and fd4023e.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js

Walkthrough

Protobuf support is added as a new WebSocket request body mode. RAW_MODES and TYPE_BY_DECODER register the mode; CodeMirror configuration maps it to a syntax mode; humanizeRequestBodyMode provides a "PROTOBUF" label; the Format (prettify) button is now enabled only for JSON or XML.

Changes

Protobuf Body Mode

Layer / File(s) Summary
Mode and Type Definitions
packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js, packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
RAW_MODES gains protobuf entry; TYPE_BY_DECODER maps protobuf: 'protobuf'.
Editor and Display Integration
packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
CodeMirror mode mapping updated to include protobuf mapping.
Prettify Enablement
packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
The Format (prettify) button is disabled unless codeType is json or xml.
Humanized Label
packages/bruno-app/src/utils/collections/index.js
humanizeRequestBodyMode returns "PROTOBUF" for protobuf mode.

Sequence Diagram(s)

sequenceDiagram
  participant User as User UI
  participant Single as SingleWSMessage
  participant CM as CodeMirrorConfig
  participant Util as humanizeRequestBodyMode
  User->>Single: select protobuf mode / open editor
  Single->>CM: request codemirror mode for 'protobuf'
  CM-->>Single: return editor mode
  Single->>Util: request human label for 'protobuf'
  Util-->>Single: return "PROTOBUF"
  Single->>Single: compute codeType -> (not json/xml)
  Single-->>User: Prettify button disabled
Loading

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

size/M

Suggested reviewers

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

Poem

🔧 Protocol buffers find their place,
A compact mode joins the race,
Editor maps and labels show,
Prettify guards when types don't flow,
Protobuf now has a home to grace! 📡

🚥 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 summarizes the main change: adding protobuf as a body mode option for WebSocket messages, which is the core feature across all modified files.
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js (1)

104-143: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

onPrettify silently does nothing for protobuf — no user feedback.

The wand button is visible and clickable when protobuf is selected, but onPrettify only handles json and xml. Clicking it for a protobuf message produces no action and no toast, leaving the user wondering if it worked.

Either disable the prettify button when codeType === 'protobuf', or add a toast informing the user it's not supported.

🛠️ Quick fix — disable prettify for unsupported types
-          <ToolHint text="Format" toolhintId={`prettify-msg-${index}`}>
-            <button onClick={onPrettify} className="toolbar-btn">
-              <IconWand size={16} strokeWidth={1.5} />
-            </button>
-          </ToolHint>
+          <ToolHint text="Format" toolhintId={`prettify-msg-${index}`}>
+            <button
+              onClick={onPrettify}
+              className="toolbar-btn"
+              disabled={!['json', 'xml'].includes(codeType)}
+            >
+              <IconWand size={16} strokeWidth={1.5} />
+            </button>
+          </ToolHint>
🤖 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-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js`
around lines 104 - 143, onPrettify currently handles only json and xml, leaving
protobuf clicks silent; either disable the prettify button in the
SingleWSMessage render when codeType === 'protobuf' or add an explicit branch in
onPrettify to call toastError (e.g., toastError(new Error('Prettify not
supported for protobuf'))) so users get feedback; locate the handler onPrettify
and the prettify button click wiring in SingleWSMessage, and update either the
button's disabled prop when codeType === 'protobuf' or add an else-if (codeType
=== 'protobuf') branch that calls toastError.
🤖 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
`@packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js`:
- Around line 97-102: Update the codemirrorMode mapping so the protobuf entry
uses text/plain instead of application/ld+json: locate the codemirrorMode
constant and change the 'protobuf' key's value from 'application/ld+json' to
'text/plain' (this ensures protobuf messages fall back to plain text
highlighting in the SingleWSMessage component).

---

Outside diff comments:
In
`@packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js`:
- Around line 104-143: onPrettify currently handles only json and xml, leaving
protobuf clicks silent; either disable the prettify button in the
SingleWSMessage render when codeType === 'protobuf' or add an explicit branch in
onPrettify to call toastError (e.g., toastError(new Error('Prettify not
supported for protobuf'))) so users get feedback; locate the handler onPrettify
and the prettify button click wiring in SingleWSMessage, and update either the
button's disabled prop when codeType === 'protobuf' or add an else-if (codeType
=== 'protobuf') branch that calls toastError.
🪄 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: 9ccc1c19-53fb-4ca3-bb66-7529ee4e530a

📥 Commits

Reviewing files that changed from the base of the PR and between f8bf146 and ecd51fd.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js
  • packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
  • packages/bruno-app/src/utils/collections/index.js

@DevRajah
Copy link
Copy Markdown
Author

DevRajah commented May 7, 2026 via email

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