Feature: support socket.io - [INS-5024]#8405
Conversation
4918986 to
d214087
Compare
d214087 to
2572464
Compare
9007359 to
c93cc0a
Compare
757fe38 to
e1430c1
Compare
40795f0 to
24dc2cb
Compare
5c10711 to
f085109
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for Socket.IO requests in the Insomnia app. The changes span multiple layers including models, UI components, IPC handlers, and network operations, ensuring Socket.IO requests, responses, and payloads are handled consistently across the app.
Reviewed Changes
Copilot reviewed 45 out of 46 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/ui/components/modals/export-requests-modal.tsx | Extended request node types and conditionals to include SocketIORequest. |
| packages/insomnia/src/ui/components/dropdowns/response-history-dropdown.tsx | Updated response dropdown logic and IPC calls to support SocketIOResponse. |
| packages/insomnia/src/ui/components/dropdowns/request-actions-dropdown.tsx | Added SocketIORequest to the union type for request actions. |
| packages/insomnia/src/templating/types.ts | Incorporated SocketIORequest into templating context types. |
| packages/insomnia/src/sync/git/ne-db-client.ts | Updated type filters and sync logic for SocketIOPayload and SocketIORequest. |
| packages/insomnia/src/preload.ts | Added and configured the SocketIO bridge API. |
| packages/insomnia/src/plugins/index.ts | Extended plugin types to include SocketIORequest support. |
| packages/insomnia/src/network/network.ts | Updated network authentication handling to include SocketIORequest. |
| packages/insomnia/src/models/socket-io-response.ts | New model with CRUD methods for SocketIOResponse. |
| packages/insomnia/src/models/socket-io-request.ts | New model defining SocketIORequest and its helper methods. |
| packages/insomnia/src/models/socket-io-payload.ts | New model for SocketIOPayload with creation, duplicate, and update operations. |
| packages/insomnia/src/models/request-version.ts | Updated versioning logic to support SocketIORequest. |
| packages/insomnia/src/models/index.ts | Exported new Socket.IO related models. |
| packages/insomnia/src/models/helpers/request-operations.ts | Updated helper operations to support SocketIORequest. |
| packages/insomnia/src/main/network/websocket.ts | Added a debug log line for WebSocket connection open events. |
| packages/insomnia/src/main/ipc/main.ts, electron.ts, main.development.ts | Extended IPC handlers and channels to include SocketIO methods. |
| packages/insomnia/src/common/render.ts | Updated render functions to include SocketIORequest in context ancestors. |
Files not reviewed (1)
- packages/insomnia/package.json: Language not supported
| } | ||
|
|
||
| return database.duplicate<SocketIOPayload>(request, { | ||
| name, |
There was a problem hiding this comment.
The duplicate function references an undefined variable 'name'. Consider using patch.name or setting a default name before passing it to the duplicate function.
| } | |
| return database.duplicate<SocketIOPayload>(request, { | |
| name, | |
| } else if (!patch.name) { | |
| patch.name = ''; | |
| } | |
| return database.duplicate<SocketIOPayload>(request, { |
704ec31 to
a1744bd
Compare
c31c6fd to
c1b5829
Compare
4c7a0a5 to
d8dc4c2
Compare
|
What have you scoped out? |
| ipcMainHandle('socketIO.event.findMany', (_, options: Parameters<typeof findMany>[0]) => findMany(options)); | ||
| }; | ||
|
|
||
| electron.app.on('window-all-closed', closeAllSocketIOConnections); |
There was a problem hiding this comment.
Can eventLogFileStreams and timelineFileStreams end correctly here?
There was a problem hiding this comment.
I think yes. These will be closed in 'disconnect' event callback.
|
|
||
| socket.off(options.eventName); | ||
| }; | ||
|
|
There was a problem hiding this comment.
| // Get the event log for a specific response in history |
| direction: 'INCOMING', | ||
| type: 'message', | ||
| timestamp: Date.now(), | ||
| eventName, |
There was a problem hiding this comment.
Why is the eventName for ack is the same as event name of the message sent, is it by socket-io spec?
There was a problem hiding this comment.
The same event name is used here to mark which event the ack is from
| settingEncodeUrl: boolean; | ||
| settingStoreCookies: boolean; | ||
| settingSendCookies: boolean; |
There was a problem hiding this comment.
Do not find these settings on UI
There was a problem hiding this comment.
Will check if we could delete them
| initialPayload?: string; | ||
| } | ||
|
|
||
| const getCertificates = async ({ |
There was a problem hiding this comment.
Maybe we can reuse it for both socket-io and websocket requests.
There was a problem hiding this comment.
Agree, we can do some extraction in a separate pr.
| eventLogFileStreams.get(options.requestId)?.write(JSON.stringify(openEvent) + '\n'); | ||
|
|
||
| if (!openedEvents.length) { | ||
| const infoEvent: SocketIOInfoEvent = { |
There was a problem hiding this comment.
Will this info event be shown in UI?
There was a problem hiding this comment.
Yes, you can see this event message when you connect to a socket.io server
@jackkav This pr implements basic support for the socket protocol, and I think this is ready for a beta version. There are some UX optimizations that can be done later, such as adding a loading state for the connection button, and others can be continuously optimized based on user feedback. Other things I can think of are:
|
d8dc4c2 to
e1e5887
Compare
|
@CurryYangxx Good work so far. Can you explain the difference between open close and on off somewhere in the PR. The usage is quite ambiguous, is it possible to eliminate either of them or do they have special differences? Secondly I would encourage you to reuse the websocket components rather than duplciating them all. Thankfully there is an earlier PR which adds the realtime protocol SSE. #6147 Its much cheaper to do right away in this scope than leave it until later. If its not viable to do in this scope please list where the ui deviates enough to justify 1500 lines of what appears to be largely duplication. Thanks. |
@jackkav Socket.io is event-based communication, when the connection is established, the client side can subscribe or unsubscribe to an event to control which event messages will be received from the server side. The open&close is used for connection, and the on & off is for event subscription. You can get more details from here: https://socket.io/docs/v4/listening-to-events/
I agree, I will try to reuse websocket components as much as possible, and I think this may need some UI abstraction. |
4738249 to
70607c6
Compare
* init socket.io model * socket.io request panel UI * init socket.io response pane(use RealtimeResponsePane) * adaptive for new socketio tab type * payload panel ui * socketIO event tab UI * fix event switch style * feat: socketIO payload persist * feat: event panel * feat: socketIO IPC * update ui * feat: add query * build response * fix: add db type * add useFetcherWithPromise hook * fix todo * prettier format * attach cert to request * fix minor bugs * fix lint * fix unit test * feat: add proxy for socket.io * Adapt to multiple tabs * disable proxy * fix enable proxy * support git&cloud sync * fix: ci * del console * chore: adapt to react-router v7 * fix bugs * fix: lint * feat: reuse websocket component (Kong#8828) * del unuse field * fix: conflict * fix: lint * fix: type check
Close #5884
socket.io-request-1080.mov
Support Socket.io
Feature list:
Changes:
socket.io-clientas socket.io clientsocket-io-requestsocket-io-responsesocket-io-payloadpackages/insomnia/src/ui/components/socket-iodirectory