Skip to content

Fix WSL2 terminal rendering fallback - #116

Merged
gsvprharsha merged 1 commit into
tempestai-dev:mainfrom
bferanmi806-sketch:fix/wsl2-terminal-rendering
Sep 18, 2026
Merged

gsvprharsha merged 1 commit into
tempestai-dev:mainfrom
bferanmi806-sketch:fix/wsl2-terminal-rendering

Conversation

@bferanmi806-sketch

Copy link
Copy Markdown
Contributor

What changed

Under WSLg/WebKitGTK, WebGL context creation can succeed while landing on a software/slow rendering path, so Tempest's terminal silently falls into an extremely slow renderer. src/lib/webglPool.ts only falls back to xterm's canvas renderer when creating or loading the WebglAddon throws, which never happens in this environment - matching the severe terminal FPS collapse reported in #35 (the file is unchanged since v0.1.18, the reported version).

This PR makes Tempest deliberately skip WebglAddon when running inside WSL/WSLg, keeping xterm on its normal non-WebGL renderer there, and leaves WebGL behaviour unchanged for Windows, macOS and ordinary native Linux. It deliberately does not set WEBKIT_DISABLE_DMABUF_RENDERER or disable WebGL for all Linux users.

  • src-tauri/src/wsl.rs (new): cached WSL detection mirroring the semantics already used by Atlas in packages/atlas/src/sync/watch-policy.ts (non-Linux -> false; non-empty WSL_DISTRO_NAME or WSL_INTEROP -> true without I/O; fallback to /proc/version containing microsoft/wsl case-insensitively; unreadable /proc/version -> false). Detection inputs are injectable so tests do not depend on the build host OS.
  • src-tauri/src/lib.rs: register the new cached is_wsl Tauri command.
  • src/lib/terminalRendererPolicy.ts (new): small injectable policy that resolves the WSL fact once, caches it, and exposes allowsWebgl(). A failed probe logs and preserves the previous WebGL behaviour (fail-open).
  • src/lib/terminalRenderer.ts (new): wires the policy to the is_wsl command.
  • src/main.tsx: awaits the policy's single initialize() in the existing pre-mount Promise.all, so the platform fact is resolved before React mounts.
  • src/lib/webglPool.ts: acquire() stays synchronous and gains one guard line if (!terminalRendererPolicy.allowsWebgl()) return;.
  • src/lib/terminalRendererPolicy.check.ts (new): regression check for the renderer policy.

Resolving the fact once at startup keeps webglPool.acquire() synchronous, so pool size (6), context-loss handling, release behaviour, terminal show/hide re-acquire and PTY sizing logic are untouched. Zen windows load the same entrypoint, so they are covered too.

Related issue

Refs #35. Note: this addresses the severe FPS/rendering portion only. The reporter's startup warnings were never shared verbatim, so this PR does not claim to fix those unidentified warnings.

How was this tested

  • npx tsc --noEmit - clean.
  • npm run build:frontend (tsc && vite build) - passes.
  • cargo +1.97.1 check and cargo +1.97.1 test in src-tauri - 32/32 pass, including 9 new wsl:: unit tests covering WSL_DISTRO_NAME, WSL_INTEROP, /proc/version Microsoft/WSL markers (case-insensitive), ordinary Linux false, non-Linux false even with env markers, unreadable /proc/version false, and env short-circuit before any /proc read.
  • npm test terminalRendererPolicy (repo's tests/run.mjs node checks) - covers WSL -> non-WebGL, native Linux/Windows/macOS -> WebGL, pending-then-resolved caching, concurrent initialize() dedup, no per-pane IPC retries, and probe-failure fail-open behaviour.
  • git diff --check - clean.
  • Known pre-existing failure, unrelated and verified present on unpatched main via stash: src/components/AgentQuotaStrip.check.ts fails because it imports ../lib/quota without the .ts extension tests/run.mjs requires.

Manual verification on an actual WSL2/WSLg setup (Ubuntu 22.04/24.04) is still needed to confirm the FPS improvement end-to-end; I could not run the Linux WebKitGTK target from my dev machine.

Checklist

  • npx tsc --noEmit passes
  • cargo check passes (if backend changed)
  • I've tested this on my OS - noted which: Windows 11 (WSLg behaviour itself not reproducible locally; needs maintainer/manual WSL2 verification)
  • Docs updated if user-facing behaviour changed
  • No secrets, tokens, or personal paths in the diff

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

@bferanmi806-sketch is attempting to deploy a commit to the Tempest OSS Team on Vercel.

A member of the Team first needs to authorize it.

@bferanmi806-sketch
bferanmi806-sketch marked this pull request as ready for review September 18, 2026 09:08

@gsvprharsha gsvprharsha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Safe to merge

@gsvprharsha
gsvprharsha merged commit 30c8404 into tempestai-dev:main Sep 18, 2026
1 check failed
@bferanmi806-sketch

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge, Harsha. Appreciate it.

I had a look through the roadmap and I’d be keen to contribute more consistently rather than just pick up isolated issues.

If there’s anything on the roadmap or anything not yet turned into an issue where an extra pair of hands would help, feel free to point me at it. I’d be happy to dig into it properly and open a pr

@gsvprharsha

Copy link
Copy Markdown
Collaborator

That would be great. We are actually working on #117 right now. The issue has been in Windows. We are still exploring a standard solution across Mac, Windows, and Linux

@bferanmi806-sketch

Copy link
Copy Markdown
Contributor Author

I can check through #117 from the cross-platform packaging side and see if there’s a cleaner approach that works consistently across Windows, macOS, and Linux.

I’ll focus on understanding the current Atlas staging/resource flow first so I don’t duplicate anything you’re already working on.

@gsvprharsha

gsvprharsha commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Sure! Thank you! Also if you want to, then you can join the discord server, we will add you to the contributors channel.

We are actually planning on Moving atlas to rust and make it tightly integrated to avoid this.

@bferanmi806-sketch

bferanmi806-sketch commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Oh I would love to join the discord server

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