Repository navigation
Adding support for GraphQL Subscriptions - #8802
ZaninAndrea wants to merge 22 commits into
Conversation
Introduce the graphql-subscription-request item type in the shared schema types and JSON-schema validation, laying the ground work for the filestore, transport, and UI layers built on top of it.
… support Teach bruno-lang, bruno-filestore, bruno-cli, and the OpenCollection converter to read and write graphql-subscription-request items, including connection params, so the request type round-trips through every on-disk representation Bruno supports.
Implement the graphql-transport-ws protocol and a subscription client built on it, so the request pipeline has a runtime piece that can open a subscription, stream events, and tear the connection down cleanly.
Add the graphql-subscription IPC event handlers, request preparation, and connectionParams interpolation, and extract a shared registerAppQuitTeardown helper (reused by the existing WS client) so both socket-based transports tear down cleanly on app quit.
Add subscribe/unsubscribe actions and reducers, IPC event listeners that feed subscription messages into the store, and recognize graphql-subscription-request across the tabs/snapshot/collections utils that key behavior off request type.
…ntry points Add the ConnectionParams and GraphQLSubscriptionQueryUrl panes, and recognize graphql-subscription-request across every entry point and display surface: new-request menus, request tabs, the timeline and messages list, the runner, sharing, presets, and the sidebar icon.
Add graphql-ws powered subscriptions to the local test GraphQL server so e2e specs and manual testing have something real to subscribe to.
…e and persistence Cover subscribing/unsubscribing, message history, and collection persistence for graphql-subscription-request items end to end.
… and GraphQL Subscription messages panel
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughGraphQL subscription requests are added across request creation, schema and file formats, WebSocket transport, Redux lifecycle state, response rendering, collection handling, and end-to-end coverage. ChangesGraphQL subscription support
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant BrunoApp
participant Redux
participant ElectronIPC
participant GraphQLSubscriptionClient
participant GraphQLServer
User->>BrunoApp: Open GraphQL subscription request
BrunoApp->>ElectronIPC: Connect and subscribe
ElectronIPC->>GraphQLSubscriptionClient: Prepare WebSocket transport
GraphQLSubscriptionClient->>GraphQLServer: connection_init and subscribe
GraphQLServer-->>GraphQLSubscriptionClient: connection_ack and next frames
GraphQLSubscriptionClient-->>ElectronIPC: Lifecycle and frame events
ElectronIPC-->>Redux: Dispatch subscription response events
Redux-->>BrunoApp: Render messages and connection status
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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.
Actionable comments posted: 15
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/providers/ReduxStore/slices/collections/actions.js (1)
400-440: 🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
saveMultipleCollectionsnever actually waits for the saves — outersavePromisesis always empty.The inner
const savePromises = [](Line 414) shadows the outer array declared at Line 405. Only the inner array is awaited per-collection; the outerPromise.all(savePromises)(Line 433) always resolves on an empty array almost immediately, so the returned promise settles before the IPC saves finish. Any laterreject(err)from a failed collection save is then a no-op on an already-resolved promise — failures get silently swallowed and callers believe the multi-collection save succeeded.🐛 Proposed fix
const savePromises = []; each(collectionDrafts, (collectionDraft) => { const collection = findCollectionByUid(collections, collectionDraft.collectionUid); if (collection) { const collectionCopy = cloneDeep(collection); const collectionRootToSave = transformCollectionRootToSave(collectionCopy); const { ipcRenderer } = window; - const savePromises = []; + const collectionSavePromises = []; - savePromises.push(ipcRenderer.invoke('renderer:save-collection-root', collectionCopy.pathname, collectionRootToSave, collectionCopy.brunoConfig)); + collectionSavePromises.push(ipcRenderer.invoke('renderer:save-collection-root', collectionCopy.pathname, collectionRootToSave, collectionCopy.brunoConfig)); if (collectionCopy.draft?.brunoConfig) { - savePromises.push(ipcRenderer.invoke('renderer:update-bruno-config', collectionCopy.draft.brunoConfig, collectionCopy.pathname, collectionCopy.root)); + collectionSavePromises.push(ipcRenderer.invoke('renderer:update-bruno-config', collectionCopy.draft.brunoConfig, collectionCopy.pathname, collectionCopy.root)); } - Promise.all(savePromises) - .then(() => { - dispatch(saveCollectionDraft({ collectionUid: collectionDraft.collectionUid })); - }) - .catch((err) => { - toast.error('Failed to save collection settings!'); - reject(err); - }); + savePromises.push( + Promise.all(collectionSavePromises) + .then(() => { + dispatch(saveCollectionDraft({ collectionUid: collectionDraft.collectionUid })); + }) + .catch((err) => { + toast.error('Failed to save collection settings!'); + reject(err); + }) + ); } });🤖 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/providers/ReduxStore/slices/collections/actions.js` around lines 400 - 440, Fix saveMultipleCollections so its returned promise tracks every collection’s IPC save operation. Remove the shadowing inner savePromises in the collectionDraft loop, add each per-collection save promise to the outer array, and preserve dispatch on success plus rejection propagation for failures so Promise.all does not resolve early.
🧹 Nitpick comments (9)
packages/bruno-converters/src/opencollection/items/graphql-subscription.ts (1)
57-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer the real request/settings shapes over
as any.This PR adds
packages/bruno-schema-types/src/requests/graphql-subscription.ts; reusing it here (or wideningBrunoItem['request']to carryconnectionParams) keeps the converter type-checked instead of opting out twice.As per path instructions, "When a file is converted to TypeScript, flag use of
anyused as a shortcut rather than a genuinely unknown/dynamic type — prefer modeling the real shape (reuse types from@usebruno/schema-typeswhere applicable)."🤖 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-converters/src/opencollection/items/graphql-subscription.ts` around lines 57 - 75, Replace the `as any` casts on the converted GraphQL subscription `request` and `settings` objects with the real types from the new `graphql-subscription` schema definition, or widen `BrunoItem['request']` to include `connectionParams`. Keep the existing field mappings while preserving full type checking in the converter.Source: Path instructions
packages/bruno-app/src/utils/network/index.js (1)
429-454: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePromise constructor wrapper is redundant here.
These three only forward resolve/reject;
return ipcRenderer.invoke(...)is equivalent. Non-blocking if you're matching the surrounding file style.♻️ Proposed simplification
export const unsubscribeGraphqlSubscription = async (requestId) => { - return new Promise((resolve, reject) => { - const { ipcRenderer } = window; - ipcRenderer.invoke('renderer:gql-sub:unsubscribe', requestId).then(resolve).catch(reject); - }); + const { ipcRenderer } = window; + return ipcRenderer.invoke('renderer:gql-sub:unsubscribe', requestId); };🤖 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/utils/network/index.js` around lines 429 - 454, Remove the redundant Promise constructors from unsubscribeGraphqlSubscription, disconnectGraphqlSubscription, and getGraphqlSubscriptionConnectionStatus, returning the corresponding ipcRenderer.invoke(...) promise directly while preserving each channel and argument list.packages/bruno-app/src/utils/network/graphql-subscription-event-listeners.js (1)
25-95: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNine identical listeners could be table-driven.
Optional: map channel suffix → eventType and register in a loop; cleanup becomes a single
unsubscribes.forEach((fn) => fn()).♻️ Sketch
- const removeConnectingListener = ipcRenderer.on('main:gql-sub:connecting', (requestId, collectionUid, eventData) => { - dispatch(graphqlSubscriptionResponseReceived({ ... })); - }); - ... + const responseEvents = ['connecting', 'upgrade', 'redirect', 'open', 'frames', 'operation-state', 'close', 'error']; + const unsubscribes = responseEvents.map((eventType) => + ipcRenderer.on(`main:gql-sub:${eventType}`, (requestId, collectionUid, eventData) => { + dispatch(graphqlSubscriptionResponseReceived({ itemUid: requestId, collectionUid, eventType, eventData })); + }));🤖 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/utils/network/graphql-subscription-event-listeners.js` around lines 25 - 95, Consolidate the repeated GraphQL subscription listener registrations around graphqlSubscriptionResponseReceived into a table-driven mapping of channel suffixes to eventType values, then register them in a loop while preserving the existing requestId, collectionUid, and eventData dispatch payload. Collect each returned unsubscribe function and update cleanup to invoke all of them via a single iteration.packages/bruno-app/src/components/Sidebar/NewRequest/index.js (1)
153-270: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
onSubmitduplicates the same dispatch→toast→onClose flow four times.Each new request type (grpc/ws/graphql-subscription/default/from-curl) repeats the same
.then(toast.success + onClose).catch(toast.error)boilerplate. Worth extracting into a small helper (e.g.,createRequestAndNotify(actionPromise)) to avoid this growing with each future request type.♻️ Sketch of a shared helper
+const dispatchAndNotify = (promise) => + promise + .then(() => { + toast.success('New request created!'); + onClose(); + }) + .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + if (isGrpcRequest) { - dispatch(newGrpcRequest({ ... })) - .then(() => { toast.success('New request created!'); onClose(); }) - .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + dispatchAndNotify(dispatch(newGrpcRequest({ ... }))); } else if (isWsRequest) { - dispatch(newWsRequest({ ... })) - .then(...) - .catch(...); + dispatchAndNotify(dispatch(newWsRequest({ ... }))); } else if (isGraphqlSubscriptionRequest) { - dispatch(newGraphqlSubscriptionRequest({ ... })) - .then(...) - .catch(...); + dispatchAndNotify(dispatch(newGraphqlSubscriptionRequest({ ... }))); }🤖 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/Sidebar/NewRequest/index.js` around lines 153 - 270, Extract the repeated dispatch promise handling in onSubmit into a shared helper such as createRequestAndNotify, covering the success toast, onClose call, and error toast. Update the grpc, WebSocket, GraphQL subscription, from-curl, default, and ephemeral request branches to pass their dispatch result through this helper while preserving their existing request payloads and ephemeral tab behavior.packages/bruno-app/src/components/ResponsePane/SocketMessagesList/index.js (2)
108-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExpand/collapse row is mouse-only.
The toggle handler lives on a plain
divwith norole="button",tabIndex, or key handler, so keyboard users can't open a message. Carried over from the oldWSMessagesList, but now it's the shared path for both WS and GraphQL subscriptions — cheap to fix here once.♿ Suggested change
<div className={classnames('flex items-center justify-between', { 'cursor-pointer': canOpenMessage, 'cursor-not-allowed': !canOpenMessage })} + role={canOpenMessage ? 'button' : undefined} + tabIndex={canOpenMessage ? 0 : undefined} + aria-expanded={canOpenMessage ? isOpen : undefined} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + handleToggle(); + } + }} onClick={handleToggle} >🤖 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/ResponsePane/SocketMessagesList/index.js` around lines 108 - 137, Add keyboard accessibility to the row containing handleToggle: give the interactive div an appropriate button role and tabIndex, and invoke handleToggle for Enter and Space key presses while preserving the existing click behavior. Use the existing canOpenMessage state so non-openable rows are not presented as actionable.
10-36: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueDouble parse/stringify round-trip in
parseContent.
getContentMetastringifies with indent 0, thenparseContentre-parses that string just to stringify it again with indent 2. Two extra JSON passes per message per render; return the parsed value once.♻️ Suggested simplification
-const getContentMeta = (content) => { - if (typeof content === 'object') { - return { - isJSON: true, - content: JSON.stringify(content, null, 0) - }; - } - try { - return { - isJSON: true, - content: JSON.stringify(JSON.parse(content), null, 0) - }; - } catch { - return { - isJSON: false, - content: content - }; - } -}; - -const parseContent = (content) => { - const contentMeta = getContentMeta(content); - return { - type: contentMeta.isJSON ? 'application/json' : 'text/plain', - content: contentMeta.isJSON ? JSON.stringify(JSON.parse(contentMeta.content), null, 2) : contentMeta.content - }; -}; +const parseContent = (content) => { + if (typeof content === 'object') { + return { type: 'application/json', content: JSON.stringify(content, null, 2) }; + } + try { + return { type: 'application/json', content: JSON.stringify(JSON.parse(content), null, 2) }; + } catch { + return { type: 'text/plain', content }; + } +};🤖 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/ResponsePane/SocketMessagesList/index.js` around lines 10 - 36, Update getContentMeta and parseContent to retain and reuse the parsed JSON value instead of stringifying it with indent 0 and parsing it again before formatting with indent 2. Ensure valid object and JSON-string inputs still produce type application/json with two-space formatting, while invalid JSON continues returning text/plain unchanged.packages/bruno-app/src/components/ResponsePane/SocketResponsePane/index.js (1)
8-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffShared pane depends on WS-specific folder.
SocketResponsePaneis now the shell for bothws-requestandgraphql-subscription-request, but pullsWSStatusCode/WSResponseHeadersout of../WsResponsePane/. Dependency points the wrong way — worth relocating them next to the shared pane (or a neutral folder) soWsResponsePanestays a leaf wrapper.🤖 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/ResponsePane/SocketResponsePane/index.js` around lines 8 - 16, Relocate the shared WSStatusCode and WSResponseHeaders components from WsResponsePane into SocketResponsePane or another neutral shared location, then update imports in SocketResponsePane and WsResponsePane to use the new location. Keep WsResponsePane as a leaf wrapper without being a dependency of the shared pane.packages/bruno-electron/src/ipc/network/graphql-subscription-event-handlers.js (1)
71-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueWarning is computed from pre-merge headers.
droppedProtocolHeaderscansrawHeaders(captured beforemergeHeaders), while the deletion below operates on the mergedheaders. ASec-WebSocket-Protocolinherited from a folder/collection gets silently dropped with no warning. Deriving the warning fromheaderswould keep both in sync.🤖 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-electron/src/ipc/network/graphql-subscription-event-handlers.js` around lines 71 - 81, Update the warning logic in the subscription event handler to inspect the merged headers object rather than the pre-merge rawHeaders collection. Preserve the existing detection and warning message for enabled Sec-WebSocket-Protocol headers, keeping it aligned with the subsequent deletion loop over headers.tests/utils/page/graphql-subscription.ts (1)
8-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftCentralize stable semantic GraphQL-subscription locators.
The page module and specs currently rely on CSS/id selectors, contrary to the E2E locator contract. Add stable test IDs or semantic roles in the UI, expose them through page-module builders/actions, and consume only those helpers from specs.
tests/utils/page/graphql-subscription.ts#L8-L19: replace CSS-class-based message/editor locators with semantic test-ID or role-based locators.tests/graphql/subscription/subscription-persistence.spec.ts#L8-L9: expose collection and request-opening actions through page helpers.tests/graphql/subscription/subscription-persistence.spec.ts#L19-L20: expose the connection-params editing target/action through the GraphQL subscription page module.tests/graphql/subscription/subscription-persistence.spec.ts#L32-L33: reuse the page helpers after restart.tests/graphql/subscription/subscription.spec.ts#L6-L10: expose sidebar request-item locators through the page module.tests/graphql/subscription/subscription.spec.ts#L17-L18: use a page-module request-opening action.tests/graphql/subscription/subscription.spec.ts#L59-L60: use the same sidebar locator/action rather than inline CSS.tests/graphql/subscription/subscription.spec.ts#L87-L87: expose the subscription message scroller through the page module.As per path instructions, GraphQL subscription specs must avoid inline raw selectors and page modules must use semantic selectors.
🤖 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/utils/page/graphql-subscription.ts` around lines 8 - 19, Centralize stable semantic GraphQL-subscription locators and remove raw CSS/id selectors. In tests/utils/page/graphql-subscription.ts:8-19, update the messages, infoMessage, connectionParams, and connectionParamsEditor builders to use UI test IDs or semantic roles; add the required UI hooks if absent. In tests/graphql/subscription/subscription-persistence.spec.ts:8-9, :19-20, and :32-33, expose collection, request-opening, and connection-params editing actions through the page module and reuse them after restart. In tests/graphql/subscription/subscription.spec.ts:6-10, :17-18, :59-60, and :87, expose and reuse sidebar request-item, request-opening, and message-scroller helpers so both specs contain no inline raw selectors.Sources: Coding guidelines, 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.
Inline comments:
In
`@packages/bruno-app/src/components/RequestPane/GraphQLSubscriptionQueryUrl/index.js`:
- Around line 78-120: Replace the clickable div controls in the save, subscribe,
and unsubscribe branches with semantic button type="button" elements, preserving
their existing click behavior and test identifiers while adding accessible
labels. Move cursor and animation styling from Tailwind className values into
the relevant StyledWrapper components, keeping Tailwind only for layout classes
and retaining the existing visual state differences.
In `@packages/bruno-app/src/components/RequestTabs/RequestTab/index.js`:
- Around line 90-91: Update the handleMouseUp middle-click close path to
disconnect active WS and GraphQL subscription connections before dispatching
closeTabs, matching the existing cleanup in the other close paths. Reuse
closeWsConnection and disconnectGraphqlSubscription with the tab item’s uid,
while preserving the current behavior for other tab types.
In `@packages/bruno-app/src/components/ResponsePane/SocketMessagesList/index.js`:
- Around line 266-268: Update the empty-state branch in the messages list
component to apply the same `${classPrefix}-messages-list` class used by the
populated branch, while preserving the existing `empty-state` content and
StyledWrapper behavior.
- Around line 194-210: Reset the openMessages state in SocketMessagesList when
messages becomes empty or responseCleared is observed, so reused message keys do
not inherit prior expansion state. Add the necessary effect or existing
clear-state integration near handleMessageToggle, preserving current toggle
behavior for non-empty message lists.
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js`:
- Around line 4040-4059: Clone the seeded responses array when constructing
updatedResponse so it never aliases the module-level
initiatedGraphqlSubscriptionResponse.responses array, especially when
item.response is absent. Apply the same defensive array clone in
runGraphqlSubscriptionRequestEvent, preserving existing entries while allowing
pushResponse to mutate only the current subscription item.
In `@packages/bruno-app/src/utils/collections/index.js`:
- Line 409: Wrap the `case 'oauth2'` branch in braces so the `grantType`
declaration and its associated statements are scoped to that case, while
preserving the existing OAuth2 behavior and switch flow.
In `@packages/bruno-converters/tests/opencollection/graphql-subscription.spec.js`:
- Around line 34-59: Update the round-trip assertions in the subscription
conversion test to verify the fixture’s X-Test WebSocket handshake header.
Assert its expected value in both ocItem.graphqlSubscription.headers and
item.request.headers, while preserving the existing URL, auth, body, and
settings checks.
In `@packages/bruno-electron/src/ipc/collection.js`:
- Line 1521: Update the request-type filter used by clone-folder to include
ws-request alongside the existing HTTP, GraphQL, gRPC, and subscription request
types, ensuring WebSocket requests are preserved when cloning a folder.
In
`@packages/bruno-electron/src/ipc/network/graphql-subscription-event-handlers.js`:
- Around line 196-197: Update the token-placement logic in the GraphQL
subscription event handler to assign the Authorization header only when
credentials?.access_token is present, matching the tokenValue guard used by
configureRequest. Leave the request without an Authorization header when token
retrieval fails or returns no token.
In `@packages/bruno-filestore/src/formats/yml/stringifyItem.spec.ts`:
- Around line 90-104: Extend the round-trip assertions in the parseItem test for
the graphql-subscription-request fixture to verify that supplied headers,
authentication, and tags are preserved after stringify and reparsing. Assert the
expected values alongside the existing request and settings checks, using the
fixture’s corresponding fields.
In `@packages/bruno-requests/src/graphql/graphql-subscription-client.js`:
- Around line 408-434: Update `#writeFrame` to track whether an outgoing frame was
actually sent, setting the flag only when record.socket is OPEN and send(raw)
executes. Include this sent status on buffered frame records, ensuring skipped
writes during CONNECTING or after closure are represented as unsent rather than
implying transmission.
In `@packages/bruno-schema/src/collections/index.js`:
- Around line 610-618: Update longLivedConnectionSettingsSchema in
packages/bruno-schema/src/collections/index.js:610-618 to mark both timeout and
keepAliveInterval Yup.number() fields as nullable, while preserving their
existing defaults and object-level validation. The corresponding
GraphqlSubscriptionItemSettings definitions in
packages/bruno-schema-types/src/collection/item.ts:30-35 require no direct
change.
In `@packages/bruno-tests/src/graphql/subscriptions.js`:
- Around line 33-37: In the upgrade callback returned by the surrounding
WebSocket setup, attach an error listener to the raw socket before calling
wss.handleUpgrade. Reuse the existing socket-error handling pattern from
wsRouter so handshake errors are handled without becoming unhandled events,
while preserving the current connection emission flow.
In `@tests/graphql/subscription/subscription-persistence.spec.ts`:
- Line 5: Update the test named “connectionParams and query persist across save
and app restart” to either add assertions that save and verify query persistence
through the restart flow, or narrow the test title to describe only
connectionParams persistence. Ensure the test title accurately reflects the
behavior it exercises.
In `@tests/graphql/subscription/subscription.spec.ts`:
- Around line 4-5: Remove serial execution from the graphql subscription test
suite and update each test, including “graphql-subscription-request items are
visible in the sidebar,” to independently open the required request/tab through
its own setup. Ensure every test cleans up its created subscription and relies
only on isolated fixture state so retries and parallel execution remain safe.
---
Outside diff comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`:
- Around line 400-440: Fix saveMultipleCollections so its returned promise
tracks every collection’s IPC save operation. Remove the shadowing inner
savePromises in the collectionDraft loop, add each per-collection save promise
to the outer array, and preserve dispatch on success plus rejection propagation
for failures so Promise.all does not resolve early.
---
Nitpick comments:
In `@packages/bruno-app/src/components/ResponsePane/SocketMessagesList/index.js`:
- Around line 108-137: Add keyboard accessibility to the row containing
handleToggle: give the interactive div an appropriate button role and tabIndex,
and invoke handleToggle for Enter and Space key presses while preserving the
existing click behavior. Use the existing canOpenMessage state so non-openable
rows are not presented as actionable.
- Around line 10-36: Update getContentMeta and parseContent to retain and reuse
the parsed JSON value instead of stringifying it with indent 0 and parsing it
again before formatting with indent 2. Ensure valid object and JSON-string
inputs still produce type application/json with two-space formatting, while
invalid JSON continues returning text/plain unchanged.
In `@packages/bruno-app/src/components/ResponsePane/SocketResponsePane/index.js`:
- Around line 8-16: Relocate the shared WSStatusCode and WSResponseHeaders
components from WsResponsePane into SocketResponsePane or another neutral shared
location, then update imports in SocketResponsePane and WsResponsePane to use
the new location. Keep WsResponsePane as a leaf wrapper without being a
dependency of the shared pane.
In `@packages/bruno-app/src/components/Sidebar/NewRequest/index.js`:
- Around line 153-270: Extract the repeated dispatch promise handling in
onSubmit into a shared helper such as createRequestAndNotify, covering the
success toast, onClose call, and error toast. Update the grpc, WebSocket,
GraphQL subscription, from-curl, default, and ephemeral request branches to pass
their dispatch result through this helper while preserving their existing
request payloads and ephemeral tab behavior.
In
`@packages/bruno-app/src/utils/network/graphql-subscription-event-listeners.js`:
- Around line 25-95: Consolidate the repeated GraphQL subscription listener
registrations around graphqlSubscriptionResponseReceived into a table-driven
mapping of channel suffixes to eventType values, then register them in a loop
while preserving the existing requestId, collectionUid, and eventData dispatch
payload. Collect each returned unsubscribe function and update cleanup to invoke
all of them via a single iteration.
In `@packages/bruno-app/src/utils/network/index.js`:
- Around line 429-454: Remove the redundant Promise constructors from
unsubscribeGraphqlSubscription, disconnectGraphqlSubscription, and
getGraphqlSubscriptionConnectionStatus, returning the corresponding
ipcRenderer.invoke(...) promise directly while preserving each channel and
argument list.
In `@packages/bruno-converters/src/opencollection/items/graphql-subscription.ts`:
- Around line 57-75: Replace the `as any` casts on the converted GraphQL
subscription `request` and `settings` objects with the real types from the new
`graphql-subscription` schema definition, or widen `BrunoItem['request']` to
include `connectionParams`. Keep the existing field mappings while preserving
full type checking in the converter.
In
`@packages/bruno-electron/src/ipc/network/graphql-subscription-event-handlers.js`:
- Around line 71-81: Update the warning logic in the subscription event handler
to inspect the merged headers object rather than the pre-merge rawHeaders
collection. Preserve the existing detection and warning message for enabled
Sec-WebSocket-Protocol headers, keeping it aligned with the subsequent deletion
loop over headers.
In `@tests/utils/page/graphql-subscription.ts`:
- Around line 8-19: Centralize stable semantic GraphQL-subscription locators and
remove raw CSS/id selectors. In tests/utils/page/graphql-subscription.ts:8-19,
update the messages, infoMessage, connectionParams, and connectionParamsEditor
builders to use UI test IDs or semantic roles; add the required UI hooks if
absent. In tests/graphql/subscription/subscription-persistence.spec.ts:8-9,
:19-20, and :32-33, expose collection, request-opening, and connection-params
editing actions through the page module and reuse them after restart. In
tests/graphql/subscription/subscription.spec.ts:6-10, :17-18, :59-60, and :87,
expose and reuse sidebar request-item, request-opening, and message-scroller
helpers so both specs contain no inline raw selectors.
🪄 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 Plus
Run ID: 2080dd74-98a5-4fc8-a82b-80ffad4c465e
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (90)
packages/bruno-app/src/components/AiChatSidebar/index.jspackages/bruno-app/src/components/AppPreviewKeepAlive/index.jspackages/bruno-app/src/components/CollectionSettings/Presets/index.jspackages/bruno-app/src/components/CreateUntitledRequest/index.jspackages/bruno-app/src/components/RequestPane/ConnectionParams/index.jspackages/bruno-app/src/components/RequestPane/GraphQLRequestPane/index.jspackages/bruno-app/src/components/RequestPane/GraphQLSchemaActions/useGraphqlSchema.jspackages/bruno-app/src/components/RequestPane/GraphQLSubscriptionQueryUrl/StyledWrapper.jspackages/bruno-app/src/components/RequestPane/GraphQLSubscriptionQueryUrl/index.jspackages/bruno-app/src/components/RequestTabPanel/index.jspackages/bruno-app/src/components/RequestTabs/RequestTab/index.jspackages/bruno-app/src/components/RequestTabs/RequestTab/resolveNewRequestTarget.jspackages/bruno-app/src/components/ResponsePane/GraphqlSubscriptionResponsePane/GraphqlSubscriptionMessagesList/index.jspackages/bruno-app/src/components/ResponsePane/GraphqlSubscriptionResponsePane/index.jspackages/bruno-app/src/components/ResponsePane/SocketMessagesList/StyledWrapper.jspackages/bruno-app/src/components/ResponsePane/SocketMessagesList/index.jspackages/bruno-app/src/components/ResponsePane/SocketResponsePane/StyledWrapper.jspackages/bruno-app/src/components/ResponsePane/SocketResponsePane/index.jspackages/bruno-app/src/components/ResponsePane/Timeline/index.jspackages/bruno-app/src/components/ResponsePane/WsResponsePane/WSMessagesList/index.jspackages/bruno-app/src/components/ResponsePane/WsResponsePane/index.jspackages/bruno-app/src/components/RunnerResults/RunConfigurationPanel/index.jsxpackages/bruno-app/src/components/ShareCollection/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RequestMethod/index.jspackages/bruno-app/src/components/Sidebar/NewRequest/index.jspackages/bruno-app/src/pages/Bruno/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/graphql-subscription-events.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs.jspackages/bruno-app/src/utils/collections/emptyStateRequest.jspackages/bruno-app/src/utils/collections/export.jspackages/bruno-app/src/utils/collections/index.jspackages/bruno-app/src/utils/common/constants.jspackages/bruno-app/src/utils/network/graphql-subscription-event-listeners.jspackages/bruno-app/src/utils/network/index.jspackages/bruno-app/src/utils/snapshot/index.jspackages/bruno-app/src/utils/tabs/index.jspackages/bruno-cli/src/utils/bru.jspackages/bruno-converters/src/opencollection/items/graphql-subscription.tspackages/bruno-converters/src/opencollection/items/index.tspackages/bruno-converters/tests/opencollection/graphql-subscription.spec.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/ipc/network/graphql-subscription-event-handlers.jspackages/bruno-electron/src/ipc/network/index.jspackages/bruno-electron/src/ipc/network/interpolate-vars.jspackages/bruno-electron/src/ipc/network/register-app-quit-teardown.jspackages/bruno-electron/src/ipc/network/ws-event-handlers.jspackages/bruno-electron/src/utils/collection.jspackages/bruno-electron/src/utils/constants.jspackages/bruno-electron/tests/network/interpolate-vars.spec.jspackages/bruno-electron/tests/network/prepare-graphql-subscription-request.spec.jspackages/bruno-filestore/src/formats/bru/index.tspackages/bruno-filestore/src/formats/bru/tests/graphql-subscription-request.spec.jspackages/bruno-filestore/src/formats/yml/items/parseGraphQLSubscriptionRequest.tspackages/bruno-filestore/src/formats/yml/items/stringifyGraphQLSubscriptionRequest.tspackages/bruno-filestore/src/formats/yml/parseItem.spec.tspackages/bruno-filestore/src/formats/yml/parseItem.tspackages/bruno-filestore/src/formats/yml/stringifyItem.spec.tspackages/bruno-filestore/src/formats/yml/stringifyItem.tspackages/bruno-filestore/src/formats/yml/types/graphql-subscription.tspackages/bruno-filestore/src/formats/yml/utils.tspackages/bruno-lang/v2/src/bruToJson.jspackages/bruno-lang/v2/src/jsonToBru.jspackages/bruno-lang/v2/tests/bruToJson.spec.jspackages/bruno-lang/v2/tests/jsonToBru.spec.jspackages/bruno-requests/src/graphql/graphql-subscription-client.jspackages/bruno-requests/src/graphql/graphql-subscription-client.spec.jspackages/bruno-requests/src/graphql/graphql-transport-ws-protocol.jspackages/bruno-requests/src/graphql/graphql-transport-ws-protocol.spec.jspackages/bruno-requests/src/index.tspackages/bruno-schema-types/src/collection/item.tspackages/bruno-schema-types/src/requests/graphql-subscription.tspackages/bruno-schema-types/src/requests/index.tspackages/bruno-schema/src/collections/index.jspackages/bruno-schema/src/collections/itemSchema.spec.jspackages/bruno-tests/package.jsonpackages/bruno-tests/src/graphql/index.jspackages/bruno-tests/src/graphql/schema.jspackages/bruno-tests/src/graphql/subscriptions.jspackages/bruno-tests/src/index.jstests/graphql/subscription/fixtures/collection/bruno.jsontests/graphql/subscription/fixtures/collection/on-countdown.brutests/graphql/subscription/fixtures/collection/on-counter.brutests/graphql/subscription/fixtures/collection/on-failing.brutests/graphql/subscription/init-user-data/preferences.jsontests/graphql/subscription/subscription-persistence.spec.tstests/graphql/subscription/subscription.spec.tstests/utils/page/graphql-subscription.tstests/utils/page/locators.ts
| import { buildCommonLocators } from '../../utils/page/locators'; | ||
| import { saveRequest } from '../../utils/page/actions'; | ||
|
|
||
| test('connectionParams and query persist across save and app restart', async ({ pageWithUserData: page, restartApp }) => { |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Test query persistence or narrow the title.
This test only mutates and verifies connectionParams; it does not exercise query persistence across the restart.
As per coding guidelines, tests should cover meaningful new functionality.
🤖 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/graphql/subscription/subscription-persistence.spec.ts` at line 5,
Update the test named “connectionParams and query persist across save and app
restart” to either add assertions that save and verify query persistence through
the restart flow, or narrow the test title to describe only connectionParams
persistence. Ensure the test title accurately reflects the behavior it
exercises.
Source: Coding guidelines
| test.describe.serial('graphql subscription', () => { | ||
| test('graphql-subscription-request items are visible in the sidebar', async ({ pageWithUserData: page }) => { |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Remove the cross-test state dependency.
describe.serial masks shared UI state, and the later test explicitly relies on a tab opened by the earlier one. Make each test independently open its request and clean up its subscription so retries and parallel execution are reliable.
As per coding guidelines, each E2E test must be parallel-safe and use isolated fixture state.
🤖 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/graphql/subscription/subscription.spec.ts` around lines 4 - 5, Remove
serial execution from the graphql subscription test suite and update each test,
including “graphql-subscription-request items are visible in the sidebar,” to
independently open the required request/tab through its own setup. Ensure every
test cleans up its created subscription and relies only on isolated fixture
state so retries and parallel execution remain safe.
Source: Coding guidelines
…}-messages-list class.
…dGraphqlSubscriptionResponse.responses array.
… before upgrading.
Description
Add support for GraphQL subscriptions as a new type of request. It is built on the already existing Websocket and GraphQL request implementations.
The implementation is built for the
graphql-transport-wsprotocol, but it can be extended to also supportgraphql-wsprotocol. I have not added it yet to keep the PR smaller.The PR contains many changes from
lettoconstdone by the pre-commit hook, I think these are files that were not up to date with the linting configuration.I am open to any suggestion on how to improve the implementation.
AI disclosure
I have used Claude to help in the implementation, but all the code has been reviewed by me.
Problem
#5801
Screenshots
Contribution Checklist:
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.
Summary by CodeRabbit
ws:///wss://) and ensured correct long-lived connection cleanup on tab close.