Skip to content

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

Merged
merged 10 commits into from
Jun 10, 2025
Merged

Adds realtime through SSE #86

merged 10 commits into from
Jun 10, 2025

Conversation

BernardGatt
Copy link
Collaborator

@BernardGatt BernardGatt commented May 15, 2025

Part of: INAPP-13259

@BernardGatt BernardGatt requested a review from a team as a code owner May 15, 2025 12:30
@BernardGatt BernardGatt requested review from Copilot and a team and removed request for a team May 15, 2025 12:30
Copy link

@Copilot Copilot AI left a 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 an EventSource.

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 to isSSEEnabled or isUsingSSE for clearer intent.
useSSE: function() {

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);
Copy link
Preview

Copilot AI May 15, 2025

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.

Suggested change
useSSE && useSSE.toLowerCase() === "true" ? settings.setUseSSEFlag(true) : settings.setUseSSEFlag(false);
settings.setUseSSEFlag(useSSE?.toLowerCase() === "true");

Copilot uses AI. Check for mistakes.

Copy link

@mvanderlinde mvanderlinde left a 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.

sseSource.addEventListener("error", async (event) => {
log("SSE error received:", event);
stopSSEListener();
Copy link
Contributor

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?

Copy link
Collaborator Author

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);

@BernardGatt BernardGatt merged commit 2e11e6a into develop Jun 10, 2025
1 check passed
@BernardGatt BernardGatt deleted the feature/INAPP-13259 branch June 10, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants