Skip to content

allow synnax console to run in the browser #1232

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

Open
wants to merge 6 commits into
base: rc
Choose a base branch
from

Conversation

ritikmishra
Copy link

Issue Pull Request

Key Information

Description

I'm trying to run the Synnax Console on Linux. Unfortunately, the Tauri backend for linux (libwebkit2gtk) does not support webgl2 inside OffscreenCanvas, which breaks the renderer. The easiest workaround for me is to run the console inside Chrome. To achieve this, this PR adds web-compatible stubs for the few tauri-dependent bits of the console (kv store and drift runtime).

Basic Readiness

  • I have performed a self-review of my code.
  • I have added relevant tests to cover the changes to CI.
  • I have added needed QA steps to the release candidate template that cover these changes.
  • I have updated in-code documentation to reflect the changes.
  • I have updated user-facing documentation to reflect the changes.

Backwards Compatibility

Data Structures

I have ensured that previous versions of stored data structures are properly migrated to new formats in the following projects:

  • Server
  • Console

API Changes

The following projects have backwards-compatible APIs:

  • Python Client
  • Server
  • TypeScript Client

Breaking Changes

@emilbon99 emilbon99 requested a review from pjdotson April 15, 2025 19:51
@pjdotson pjdotson changed the base branch from main to rc April 15, 2025 20:42
Copy link
Contributor

@pjdotson pjdotson left a comment

Choose a reason for hiding this comment

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

Awesome PR! I got it to work fine on my mac with one extra line as well (our fault for doing type assertions a long time ago, lol). I have a couple requests, as well as the comments on the PR, before we can merge:

  1. The code needs to be formatted and linted to our standards (which is why it is failing CI). If you have pnpm installed, you should be able to call pnpm fix:drift and pnpm fix:console to fix linting issues (and call pnpm lint if they still exist), and format files by calling pnpm prettier -w drift/src and pnpm prettier -w console/src.
  2. Optional request and is not needed to merge since most of the app's functionality is already here, but we do have some other uses of tauri - for example, opening the file explorer (see console/src/import/import.ts for use cases. If you are up to it, it would be great to replace those Tauri calls with the equivalent browser APIs.

We can work on embedding it into the server later - right now the console can still be run from source code in a browser without Tauri, which is a step in the right direction.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having this code be in drift/src/tauri/index.ts, you should make a new file that is drift/src/noop.ts that implements Runtime<S, A>.

Copy link
Author

Choose a reason for hiding this comment

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

/**
* An object that looks like `Window` from `@tauri-apps/api/window`.
*/
export interface WindowLike {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just define this as Pick<Window, "label" | ... | "theme"> instead? Seems cleaner.

Copy link
Author

Choose a reason for hiding this comment

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

async setDecorations(value: boolean): Promise<void> { };
async setTitle(title: string): Promise<void> { };
async configure(): Promise<void> {
// throw new Error("Method not implemented.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should remove the commented out code and TODOs here.

Copy link
Author

Choose a reason for hiding this comment

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

21e6f0b oops 🫣

Copy link
Author

@ritikmishra ritikmishra left a comment

Choose a reason for hiding this comment

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

i tried it out and fixed import/export for the browser: 064dc77

i implemented it by creating ephemeral <a>/<input> elements because Mozilla seems ideologically opposed to the File System Access API (which provides window.showSaveFilePicker/window.showOpenFilePicker)

Copy link
Author

Choose a reason for hiding this comment

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

/**
* An object that looks like `Window` from `@tauri-apps/api/window`.
*/
export interface WindowLike {
Copy link
Author

Choose a reason for hiding this comment

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

async setDecorations(value: boolean): Promise<void> { };
async setTitle(title: string): Promise<void> { };
async configure(): Promise<void> {
// throw new Error("Method not implemented.");
Copy link
Author

Choose a reason for hiding this comment

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

21e6f0b oops 🫣

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.

2 participants