Skip to content

Websocket refactoring and improvements - #35

Merged
Doru991 merged 10 commits into
mainfrom
ws-improvements
Dec 6, 2025
Merged

Websocket refactoring and improvements#35
Doru991 merged 10 commits into
mainfrom
ws-improvements

Conversation

@Doru991

@Doru991 Doru991 commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

In this PR, the following changes were made to the websocket implementation:
* Extracted the WS initialization procedure from the data() function to its own method initWebsocket which is called from the data function instead.

  • The spellcaster connection is now fully managed by the wsConnection class.
    • wsConnection emits events when requiring the main application to complete a token exchange/handshake with od-spell-caster (when first opening the app, or when connection is temporarily lost)
    • wsConnection will forward all message-received events to the main app for decoding.
    • Once fully initialized, wsConnection is fully autonomous as long as handshake requests are properly handled. The main app binds to wsConnection once and doesn't need to keep track of web sockets opening or closing when connection is lost and restored.
  • When the websocket is closed, it will attempt to reinitialize itself every 5 seconds until re-establishing connection.
  • Messages received from spellcaster are now timestamped correctly.

Minor: Minutes are now padded properly (ex. 18:6 -> 18:06)

Because this is a relatively complicated architecture (compared to the rest of the frontend) I'll include the following diagram to help understand the sequence
of events:
ws drawio

@kickhead13 kickhead13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holy FUCK this is cool. Lers get this merged

@Doru991
Doru991 removed the request for review from AlexDuna December 3, 2025 18:06

@kickhead13 kickhead13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to move the websockets stuff into its own file.

Comment thread src/app.js Outdated

@catyuzu23 catyuzu23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work

@Doru991
Doru991 requested a review from kickhead13 December 3, 2025 21:35

@kickhead13 kickhead13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a weird issue on Ubuntu X11 i3WM running tauri ontop of webkit. I will be creating a github issue for this and we will investigate it.

I approve this change as is.

@Doru991
Doru991 merged commit 8851e31 into main Dec 6, 2025
6 checks passed
@Doru991
Doru991 deleted the ws-improvements branch December 6, 2025 01:38
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