-
Notifications
You must be signed in to change notification settings - Fork 4
Adds realtime through SSE #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements real-time message handling using Server-Sent Events (SSE) alongside the existing polling approach.
- Adds SSE-related flags and methods to
settings.js
for tracking usage and connection activity. - Extends
queue-service.js
to detect SSE support from response headers, store the flag, and provide an SSE endpoint. - Updates
queue-manager.js
to use SSE where enabled, including setup and teardown of anEventSource
.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
src/services/settings.js | New local-store keys and methods to track SSE usage/activity. |
src/services/queue-service.js | Reads x-cio-use-sse header, defines setQueueUseSSE , and stubs getQueueSSEEndpoint . |
src/managers/queue-manager.js | Implements setupSSEQueueListener , stopSSEListener , and conditional SSE vs. polling logic. |
Comments suppressed due to low confidence (1)
src/services/settings.js:36
- [nitpick] The method name
useSSE
returns a boolean; consider renaming toisSSEEnabled
orisUsingSSE
for clearer intent.
useSSE: function() {
src/services/queue-service.js
Outdated
function setQueueUseSSE(response) { | ||
if (response && response.headers) { | ||
var useSSE = response.headers["x-cio-use-sse"]; | ||
useSSE && useSSE.toLowerCase() === "true" ? settings.setUseSSEFlag(true) : settings.setUseSSEFlag(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The ternary with &&
is hard to read. Simplify to settings.setUseSSEFlag(useSSE?.toLowerCase() === 'true')
for clarity.
useSSE && useSSE.toLowerCase() === "true" ? settings.setUseSSEFlag(true) : settings.setUseSSEFlag(false); | |
settings.setUseSSEFlag(useSSE?.toLowerCase() === "true"); |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some readability nitpicks, feel free to ignore if not relevant. I'm not confident enough in this part of the codebase (yet) to give this the green checkmark, so I'll wait for someone with more knowledge here to do a review, as well.
* master: Bump version to 3.15.7 Add support for mailto on same page links Added origin check for message events
…ere modal overlays were getting stuck.
sseSource.addEventListener("error", async (event) => { | ||
log("SSE error received:", event); | ||
stopSSEListener(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this switch back to polling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, stopSSEListener
has settings.setUseSSEFlag(false);
Part of: INAPP-13259