Repository navigation
Revert "feat: ws multi message" - #7921
Conversation
This reverts commit a305b41.
WalkthroughThis PR refactors WebSocket request handling from a multi-message, selected-message paradigm to a single-message, simpler flow. UI components, state management, serialization, and network queueing are updated to remove the ChangesWebSocket Request UI and Message Handling Simplification
Sequence DiagramsequenceDiagram
participant UI as WsBody UI
participant State as Redux Store
participant Queue as Network Queue
participant IPC as Electron IPC
participant WS as WebSocket Client
UI->>UI: Render single message (first in array)
UI->>UI: User edits content + selects format
UI->>State: dispatch updateRequestBody<br/>(all messages, no selection)
State->>State: Store all messages (no selected flag)
UI->>State: User clicks Run
State->>Queue: Call queueWsMessage<br/>(messageContent: null)
Note over Queue: Locate message by content<br/>or queue all if null
Queue->>IPC: Send queue-message IPC<br/>(messageContent)
IPC->>WS: Queue interpolated message<br/>from body.ws array
WS->>WS: Send all queued messages
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes The PR spans heterogeneous changes across UI components, Redux state management, multiple serialization formats (BRU, YAML, JSON, OpenCollection), schema types, network/IPC layers, and test cleanup. While many changes are repetitive removal of the Possibly Related PRs
Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR reverts the previously introduced “WebSocket multi-message” feature (#7719), removing multi-message support and related UI/schema/format handling so the app returns to a single-message WebSocket workflow.
Changes:
- Removes Playwright test suites and fixtures that validated WebSocket multi-message behavior (BRU and YML).
- Drops the
selectedflag from WebSocket message schema and all associated parsing/serialization logic across BRU/YML/OpenCollection converters. - Simplifies the WebSocket request UI to a single message editor and updates send/queue plumbing accordingly.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/websockets/multi-message-yml/multi-message.spec.ts | Removes YML-based multi-message WebSocket E2E coverage. |
| tests/websockets/multi-message-yml/init-user-data/preferences.json | Removes user-data setup used by the deleted YML E2E tests. |
| tests/websockets/multi-message-yml/fixtures/collection/ws-single-msg.yml | Removes YML fixture used for WebSocket single/migration scenarios in deleted tests. |
| tests/websockets/multi-message-yml/fixtures/collection/ws-multi-msg.yml | Removes YML fixture used for multi-message scenarios in deleted tests. |
| tests/websockets/multi-message-yml/fixtures/collection/opencollection.yml | Removes OpenCollection metadata fixture for deleted YML test collection. |
| tests/websockets/multi-message-bru/multi-message.spec.ts | Removes BRU-based multi-message WebSocket E2E coverage. |
| tests/websockets/multi-message-bru/init-user-data/preferences.json | Removes user-data setup used by the deleted BRU E2E tests. |
| tests/websockets/multi-message-bru/fixtures/collection/ws-single-msg.bru | Removes BRU fixture used by deleted multi-message tests. |
| tests/websockets/multi-message-bru/fixtures/collection/ws-multi-msg.bru | Removes BRU multi-message fixture used by deleted tests. |
| tests/websockets/multi-message-bru/fixtures/collection/collection.bru | Removes BRU collection fixture used by deleted tests. |
| tests/websockets/multi-message-bru/fixtures/collection/bruno.json | Removes collection metadata fixture used by deleted tests. |
| packages/bruno-schema-types/src/requests/websocket.ts | Removes selected from WebSocketMessage schema type. |
| packages/bruno-lang/v2/tests/bruToJson.spec.js | Updates BRU parser tests to stop asserting selected and adjusts fixtures. |
| packages/bruno-lang/v2/src/jsonToBru.js | Stops emitting selected: true in BRU serialization. |
| packages/bruno-lang/v2/src/bruToJson.js | Stops parsing selected in BRU → JSON conversion for ws bodies. |
| packages/bruno-filestore/src/formats/yml/items/stringifyWebsocketRequest.ts | Reverts YML serialization to single WebSocket message output. |
| packages/bruno-filestore/src/formats/yml/items/parseWebsocketRequest.ts | Reverts YML parsing to single WebSocket message input handling. |
| packages/bruno-electron/src/utils/collection.js | Stops assigning per-message uid for ws messages during hydration. |
| packages/bruno-electron/src/ipc/network/ws-event-handlers.js | Updates IPC handler for ws message queuing (signature + queuing behavior). |
| packages/bruno-converters/src/opencollection/items/websocket.ts | Removes selected mapping when converting WebSocket messages to/from OpenCollection. |
| packages/bruno-app/src/utils/network/index.js | Simplifies sendWsRequest / queueWsMessage API to queue messages without selected-index. |
| packages/bruno-app/src/utils/collections/index.js | Removes selected from ws body persistence transformation and stops refreshing ws message uids. |
| packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js | Stops treating body.ws as requiring uid refresh paths. |
| packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js | Removes selected-message logic when sending WS requests and removes ws message uid on creation. |
| packages/bruno-app/src/components/RequestPane/WSRequestPane/index.js | Removes “Add Message” / “Prettify All” toolbar actions; passes hide props to WsBody. |
| packages/bruno-app/src/components/RequestPane/WsBody/StyledWrapper.js | Adjusts ws body layout (single vs multi container behavior + footer styling). |
| packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.js | Replaces accordion layout with a simplified toolbar + editor layout. |
| packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js | Refactors message editor UI/behavior to match single-message approach (format + prettify + delete). |
| packages/bruno-app/src/components/RequestPane/WsBody/index.js | Restricts rendered ws messages to the first message and updates empty-state/add-message behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 4
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)
41-59:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDerive
messageFormatfrom the current message's type prop instead of using stale local state.
useState(autoDetectLang(content))only runs on first mount. Since this component is keyed byindexinWsBody, switching to another request with the same index reuses the previous component instance, leavingmessageFormatstale and potentially causing the new message to be saved with the wrong editor format.♻️ Suggested fix
-import React, { useState } from 'react'; +import React from 'react'; @@ - const [messageFormat, setMessageFormat] = useState(autoDetectLang(content)); + const messageFormat = TYPE_BY_DECODER[type] ?? autoDetectLang(content); @@ - const onUpdateMessageType = (type) => { - setMessageFormat(type); - + const onUpdateMessageType = (nextFormat) => { const currentMessages = [...(body.ws || [])]; currentMessages[index] = { ...currentMessages[index], - type: DECODER_BY_TYPE[type] + type: DECODER_BY_TYPE[nextFormat] };🤖 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 41 - 59, The component currently initializes messageFormat with useState(autoDetectLang(content)) which becomes stale when the component instance is reused; instead derive the editor format from the incoming message props (message.type or content) so it always reflects the current message: replace the persistent local initialization with a computed value (or synchronise state via useEffect) that maps message.type through DECODER_BY_TYPE (or runs autoDetectLang(content) if type is missing), and update onUpdateMessageType to both dispatch and ensure the derived messageFormat follows message.type; update references to messageFormat/setMessageFormat, autoDetectLang, onUpdateMessageType and DECODER_BY_TYPE accordingly.
🤖 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/index.js`:
- Around line 41-58: The guard currently skips empty arrays so requests with
body.ws = [] render no editor or footer; update the conditional in WsBody (where
body.ws and addNewMessage are used) to treat empty arrays as empty state by
changing the check to also test for body.ws.length === 0 (e.g., if (!body?.ws ||
!Array.isArray(body.ws) || body.ws.length === 0) ) and ensure the
footer/add-message UI (and any canClientSendMultipleMessages logic) shows the
"Add Message" control when ws is an empty array so users can create the first
message.
In `@packages/bruno-app/src/utils/network/index.js`:
- Around line 237-238: sendWsRequest currently calls queueWsMessage(item,
collection, environment, runtimeVariables, null) which causes every stored
body.ws entry to be enqueued; since WsBody only exposes the first (visible)
message in single-message mode, change the call so queueWsMessage receives the
visible-message selector instead of null (e.g., pass the visible index or a
single-message flag). Locate sendWsRequest and modify the last argument to
convey "only the visible message" (for example pass 0 or a { single: true } flag
or the visibleIndex obtained from WsBody) so queueWsMessage enqueues only the
displayed payload; ensure queueWsMessage's signature is used consistently and
update any callers if needed.
In `@packages/bruno-filestore/src/formats/yml/items/parseWebsocketRequest.ts`:
- Around line 38-45: The parse is incorrectly assuming websocket.message is a
single WebSocketMessage so array-form messages are dropped; update
parseWebsocketRequest to detect when websocket.message is an array
(Array.isArray(websocket.message)) and normalize it into the
brunoRequest.body.ws array by mapping each entry to { name: '', type: entry.type
|| 'text', content: ensureString(entry.data) } (and for single-message cases
keep the existing branch), ensuring you handle empty/whitespace-only content the
same way as the current trim() check; adjust references to websocket.message,
WebSocketMessage, and brunoRequest.body.ws accordingly.
In `@packages/bruno-filestore/src/formats/yml/items/stringifyWebsocketRequest.ts`:
- Around line 44-59: The code in stringifyWebsocketRequest.ts silently drops
extra brunoRequest.body.ws entries by only taking messages[0]; don't truncate
user data—either preserve all messages or fail explicitly. Update the logic
around brunoRequest.body?.mode === 'ws' / brunoRequest.body.ws to handle
multiple messages: if the target schema supports multiple messages, map each msg
to a WebSocketMessage and assign to a plural field (e.g., websocket.messages)
instead of websocket.message; otherwise, detect messages.length > 1 and throw or
return an explicit migration/error so the caller knows data would be lost
(include the count and details), and remove the misleading todo comment. Ensure
you reference and update the WebSocketMessage mapping (type/data) and the
websocket.message assignment accordingly.
---
Outside diff comments:
In
`@packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js`:
- Around line 41-59: The component currently initializes messageFormat with
useState(autoDetectLang(content)) which becomes stale when the component
instance is reused; instead derive the editor format from the incoming message
props (message.type or content) so it always reflects the current message:
replace the persistent local initialization with a computed value (or
synchronise state via useEffect) that maps message.type through DECODER_BY_TYPE
(or runs autoDetectLang(content) if type is missing), and update
onUpdateMessageType to both dispatch and ensure the derived messageFormat
follows message.type; update references to messageFormat/setMessageFormat,
autoDetectLang, onUpdateMessageType and DECODER_BY_TYPE accordingly.
🪄 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: 1f1e4881-1dbd-4bdb-b91f-9e5a09be6b7f
📒 Files selected for processing (29)
packages/bruno-app/src/components/RequestPane/WSRequestPane/index.jspackages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.jspackages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.jspackages/bruno-app/src/components/RequestPane/WsBody/StyledWrapper.jspackages/bruno-app/src/components/RequestPane/WsBody/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/utils/collections/index.jspackages/bruno-app/src/utils/network/index.jspackages/bruno-converters/src/opencollection/items/websocket.tspackages/bruno-electron/src/ipc/network/ws-event-handlers.jspackages/bruno-electron/src/utils/collection.jspackages/bruno-filestore/src/formats/yml/items/parseWebsocketRequest.tspackages/bruno-filestore/src/formats/yml/items/stringifyWebsocketRequest.tspackages/bruno-lang/v2/src/bruToJson.jspackages/bruno-lang/v2/src/jsonToBru.jspackages/bruno-lang/v2/tests/bruToJson.spec.jspackages/bruno-schema-types/src/requests/websocket.tstests/websockets/multi-message-bru/fixtures/collection/bruno.jsontests/websockets/multi-message-bru/fixtures/collection/collection.brutests/websockets/multi-message-bru/fixtures/collection/ws-multi-msg.brutests/websockets/multi-message-bru/fixtures/collection/ws-single-msg.brutests/websockets/multi-message-bru/init-user-data/preferences.jsontests/websockets/multi-message-bru/multi-message.spec.tstests/websockets/multi-message-yml/fixtures/collection/opencollection.ymltests/websockets/multi-message-yml/fixtures/collection/ws-multi-msg.ymltests/websockets/multi-message-yml/fixtures/collection/ws-single-msg.ymltests/websockets/multi-message-yml/init-user-data/preferences.jsontests/websockets/multi-message-yml/multi-message.spec.ts
💤 Files with no reviewable changes (13)
- tests/websockets/multi-message-bru/fixtures/collection/collection.bru
- packages/bruno-schema-types/src/requests/websocket.ts
- tests/websockets/multi-message-yml/multi-message.spec.ts
- tests/websockets/multi-message-yml/fixtures/collection/ws-single-msg.yml
- tests/websockets/multi-message-bru/multi-message.spec.ts
- tests/websockets/multi-message-yml/fixtures/collection/opencollection.yml
- tests/websockets/multi-message-bru/fixtures/collection/ws-single-msg.bru
- tests/websockets/multi-message-bru/init-user-data/preferences.json
- tests/websockets/multi-message-bru/fixtures/collection/bruno.json
- tests/websockets/multi-message-yml/init-user-data/preferences.json
- packages/bruno-electron/src/utils/collection.js
- tests/websockets/multi-message-bru/fixtures/collection/ws-multi-msg.bru
- tests/websockets/multi-message-yml/fixtures/collection/ws-multi-msg.yml
This reverts commit a305b41.
* feat: implement proxy-aware API fetching using axios instance (usebruno#7767) * fix(cli): skip headers with empty name when building request (usebruno#7869) * Revert "feat: ws multi message (usebruno#7719)" (usebruno#7921) This reverts commit a305b41. * fix: remove dragbar z-index that was bleeding through modals (usebruno#7924) * feat: ui state snapshots (usebruno#7794) * feat(snapshot): add session snapshot persistence and restoration - Add snapshot middleware to persist UI state (tabs, workspaces, environments) - Add SnapshotManager service in electron for atomic snapshot storage - Add accessor-based tab serialization using pathname for reliable restoration - Add loading states for tabs while collections are mounting - Add hydrateTabs to restore tabs from snapshots on app load - Add devTools state persistence (console open/height/tab) * fix(snapshot): preserve unloaded collections and fix async serialization Make serializeSnapshot async to fetch existing snapshot before saving, ensuring collections not currently loaded in Redux are preserved. Fix activeTab serialization to pass collection object instead of just UID. * refactor(snapshot): rewrite storage to map-based schema with granular IPC Replace array-based snapshot storage with key-value maps keyed by pathname for O(1) lookups. Separate tabs into their own top-level map, decoupled from collections. - Rewrite SnapshotManager with map-based schema and granular read/write methods (getWorkspace, getTabs, setCollection, removeWorkspace, etc.) - Add 12 granular IPC handlers (renderer:snapshot:*) replacing 4 coarse ones - Update middleware serialization to produce maps; remove activeCollectionUidCache in favor of lastActiveCollectionPathname on workspace objects - Fix mountCollection passing collectionUid instead of collection to restoreTabs - Preserve non-active workspace state from existing snapshot on save * wip * refactor: allow migration of old snapshot * refactor: trim down redundancy * fix: for workspace state * feat: fix for finalised schema * fix: schema cleanup * chore: simplify * chore: wait on hydration to finish * chore: snapshot changes to schema * chore: fix typo * fix: switch schema for saving and restoring extras * chore: correctness changes * chore: add active in the schema check * chore: fix lint * chore: comments * chore: make writes async * fix: sorting and cross workspace shared collection fixes * chore: add version * fix: wait on hydration * chore: fix backward compat for ui-snapshots * chore: dead code removal * Fix optional chaining in snapshot lookup --------- Co-authored-by: Chirag Chandrashekhar <[email protected]> * fix: scrollbar restoration (usebruno#7926) * fix: restore scrollbar * chore: remove comments --------- Co-authored-by: shubh-bruno <[email protected]> * fix: message in ConnectGitRemote and RemoveGitRemote (usebruno#7929) * fix: allow empty header names in CLI and gRPC request preparation (usebruno#7925) * refactor: remove idx from HeaderList, extend ReadOnlyPropertyList, add positional method translations (usebruno#7917) * refactor: remove 'idx' method from headerList and update related tests - Eliminated the 'idx' method from both req.headerList and res.headerList to streamline header management. - Updated associated tests and documentation to reflect the removal, ensuring clarity in the API usage and maintaining consistency across the header management system. * refactor: block unimplemented HeaderList methods with error messages - Added error handling for unimplemented methods in HeaderList, including idx, add, upsert, remove, each, prepend, insert, and insertAfter. - Each method now throws a descriptive error indicating the appropriate alternative methods to use, enhancing clarity in the API and guiding users towards correct usage. * refactor: update error message in idx() method of HeaderList for clarity - Modified the error message in the idx() method to guide users towards using all()[index] or get(name) instead of the unsupported idx() method, enhancing the clarity of the API documentation. * refactor: update HeaderList to extend ReadOnlyPropertyList and remove unimplemented methods - Changed HeaderList to extend ReadOnlyPropertyList instead of PropertyList, streamlining its functionality. - Removed unimplemented methods (prepend, insert, insertAfter) from HeaderList, clarifying the API and guiding users towards using supported methods. - Updated related tests to reflect these changes, ensuring consistency and accuracy in header management. * test: add translations for pm.request.headers methods in request tests - Introduced new tests to validate the translation of pm.request.headers methods (prepend, insert, insertAfter) to their corresponding req.headerList.append method. - Enhanced existing tests to ensure accurate conversion and functionality of header management in the Bruno converters. * feat: enhance header translation methods for pm.request.headers - Added translations for additional pm.request.headers methods (get, has, one, all, count, indexOf, find, filter, each, map, reduce, toObject, clear) to their corresponding req.headerList methods. - Updated tests to validate the new translations and ensure accurate header management functionality in the Bruno converters. --------- Co-authored-by: Pragadesh-45 <[email protected]> Co-authored-by: Sid <[email protected]> Co-authored-by: gopu-bruno <[email protected]> Co-authored-by: Chirag Chandrashekhar <[email protected]> Co-authored-by: shubh-bruno <[email protected]> Co-authored-by: shubh-bruno <[email protected]> Co-authored-by: naman-bruno <[email protected]> Co-authored-by: sanish chirayath <[email protected]>
Reverts #7719
Summary by CodeRabbit