Skip to content

feat(desktop): Linux support (X11 + Wayland via XWayland) - #9503

Closed
velinxs wants to merge 2 commits into
BasedHardware:mainfrom
velinxs:linux-support
Closed

velinxs wants to merge 2 commits into
BasedHardware:mainfrom
velinxs:linux-support

Conversation

@velinxs

@velinxs velinxs commented Jul 11, 2026 •

Copy link
Copy Markdown

What changed and why

Enables the Electron desktop app on Linux, alongside the Windows/macOS targets it already builds for (build:linux is already in electron-builder.yml). The Windows/koffi paths are untouched. Adds X11 active-window detection, a Tesseract-backed OCR helper that speaks the existing win-ocr-helper stdio protocol, and Wayland-session handling.

  • linuxForeground.ts — X11 active-window via xprop + /proc/<pid>/exe; pure parsers unit-tested, never throws, degrades when X11/xprop are absent.
  • nativeForeground.ts — adds a process.platform === 'linux' branch; win32 path unchanged.
  • Linux OCR helper (resources/linux-ocr-helper/omi-ocr-helper) — Node script speaking the exact ocr/helperProtocol.ts frame protocol, backed by the tesseract CLI; resolveHelperPath returns it on Linux.
  • index.ts — on Linux, default to XWayland (ozone-platform=x11) so global shortcuts + the X11 active-window path work on Wayland sessions; OMI_OZONE=wayland to override. Enables the PipeWire capturer for portal-based capture.
  • rewindSettings.ts — on a Wayland session, continuous Rewind capture defaults off (the desktop portal re-prompts for consent every frame; Electron exposes no persisted-consent path). On-demand "what's on my screen" still works with one Share prompt.
  • LINUX.md — build/run/deps (xprop, tesseract-ocr) + Wayland behavior.

Product invariants affected

None. No invariant in docs/product/invariants/ globs desktop/windows/src/main/{usage,ocr,rewind} or index.ts.

How it was verified

Built and launched on Ubuntu 24 / GNOME, on both X11 and Wayland sessions, and exercised the real user-facing paths:

  • Sign-in, mic → cloud transcription, and chat work (inherited, cross-platform).
  • App-usage tracking attributes time to real Linux exe paths (via xprop active-window).
  • "What's on my screen" OCR returns live screen text (Rewind frame → omi-ocr-helper → Tesseract), verified by feeding a real desktop capture through the helper over the frame protocol.
  • On native Wayland, Electron global shortcuts failed 8× (push-to-talk / overlay summon) and the window was invisible to X11 tooling; forcing XWayland fixed both (0 failures). Continuous Rewind is defaulted off on Wayland to avoid per-frame portal prompts; on-demand OCR still works with a single Share consent.

cd desktop/windows && npm test → 571 passed / 3 skipped; npm run typecheck and npx eslint clean.

Tests

  • linuxForeground.test.ts — xprop output parsers + /proc/<pid>/exe resolver.
  • nativeForeground.linux.test.ts / nativeForeground.degrade.test.ts — the Linux branch returns real data when X11 is available, and the off-platform contract still degrades to nulls/no-ops.
  • rewindSettings.wayland.test.ts — continuous-capture default is off on Wayland, on elsewhere.

Scoped cleanups

None.


Follow-ups (intentionally not in this PR, to keep it focused): system-tray/Quit affordance on Linux, native-Wayland screen capture (portal restore-token so continuous Rewind can run without per-frame prompts), and packaging polish. Happy to split further or open a tracking issue if maintainers prefer.

Review in cubic

Enables the Electron desktop app on Linux alongside the existing
Windows/macOS targets. Windows/koffi paths are untouched.

- linuxForeground.ts: X11 active-window via xprop + /proc/<pid>/exe; pure
  parsers unit-tested, never throws, degrades when X11/xprop absent.
- nativeForeground.ts: process.platform==='linux' branch delegating to it.
- Linux OCR helper (resources/linux-ocr-helper/omi-ocr-helper): Node script
  speaking the exact win-ocr-helper stdio frame protocol, backed by tesseract;
  resolveHelperPath returns it on Linux.
- index.ts: on Linux default to XWayland (ozone-platform=x11) so global
  shortcuts + X11 active-window work; OMI_OZONE=wayland to override. Enable
  the PipeWire capturer for portal-based capture.
- rewindSettings.ts: on a Wayland session, continuous Rewind capture defaults
  OFF (the desktop portal re-prompts every frame; Electron has no persisted
  consent). On-demand 'what's on my screen' still works with one Share prompt.
- LINUX.md: build/run/deps (xprop, tesseract-ocr) + Wayland behavior.
- Tests: linuxForeground, nativeForeground linux/degrade, rewindSettings wayland.

Verification: built + launched on Ubuntu 24 GNOME on both X11 and Wayland
sessions; confirmed active-window tracking, screen OCR ('what's on my screen'),
and global shortcuts. Under native Wayland shortcuts failed (8x) and the app
was invisible to X11 tooling; forcing XWayland fixed both (0 failures).
Full suite: 571 passed / 3 skipped; lint + typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@velinxs
velinxs marked this pull request as ready for review July 11, 2026 22:00
@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge docs-accuracy Documentation or committed reports need accuracy fixes desktop labels Jul 12, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @velinxs — this is a genuinely strong first contribution. Linux support is a natural target for Omi, and the implementation is cohesive and careful. A few notes for the human maintainer:

What looks good: the OCR helper correctly reuses the existing helperProtocol.ts framing; the exec bit is preserved (100755) and asarUnpack: resources/** matches resolveHelperPath; active-window parsing is pure and unit-tested and degrades cleanly; the Wayland continuous-capture default-off is the right call given Electron's per-frame portal re-prompt. Security review found nothing concerning (no shell injection — all execFileSync calls use fixed array args; no new deps; no secrets; temp files cleaned up in finally).

Things to verify before merge:

  1. Packaging / snap: the snap target uses strict confinement by default, which typically blocks xprop, tesseract, and /proc/<pid>/exe access — active-window detection and OCR may silently degrade inside a snap. Please confirm whether snap needs classic confinement or specific plugs, or scope the shipped target to AppImage/deb for now.
  2. Helper spawn in packaged builds: the helper relies on #!/usr/bin/env node being spawnable from a packaged app. In an AppImage/snap/deb the shebang resolves against the system node (if present), not Electron's bundled runtime — please confirm the supervisor spawns it in a way that works in all three packaged targets (or invoke node explicitly).
  3. Reproduce test/build claims: LINUX.md asserts "530 tests passed" and a working build/launch on Ubuntu 24. Could a maintainer (or CI) reproduce the test suite and a build:linux artifact so those become verified rather than self-reported?

Heads-up for AI-agent-aware review: this PR adds desktop/windows/LINUX.md, which documents the Linux build/run/test story and will be ingested by coding/review agents operating in this repo. The content is accurate where I could check it against source (.env.example is genuinely public config; exec bit and builder config match the code), but the test/build numbers are contributor-asserted, so they should be reproduced before being relied upon.

Not approving — this is a new platform target (a product/maintenance decision) and touches screen capture / OCR / active-window tracking, so it needs a human maintainer's sign-off. Tagging needs-maintainer-review + docs-accuracy + desktop. The code quality itself is welcome and encouraging — thanks again.

Addresses review feedback on BasedHardware#9503:

- helperProcess.ts: spawn the Linux OCR helper with Electron's bundled Node
  (process.execPath + ELECTRON_RUN_AS_NODE=1) instead of relying on the
  '#!/usr/bin/env node' shebang finding a system node — so packaged AppImage/deb
  builds work without node installed. Verified: helper spawns under Electron-node
  and replies over the frame protocol.
- electron-builder.yml: drop the 'snap' Linux target. Snap's strict confinement
  blocks xprop/tesseract//proc, silently degrading active-window + OCR. Ship
  AppImage + deb (unconfined).
- LINUX.md: frame the test result as reproducible ('npm test') rather than a
  hardcoded count, and document the Electron-node spawn + AppImage/deb targets.

Full suite: 571 passed / 3 skipped; lint + typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@velinxs

velinxs commented Jul 12, 2026

Copy link
Copy Markdown
Author

Thanks for the thorough review — all three pre-merge items are addressed in the latest commit (40623a3):

  1. Helper spawn in packaged builds — good catch. ocr/helperProcess.ts now spawns the Linux helper with Electron's bundled Node (process.execPath + ELECTRON_RUN_AS_NODE=1) rather than relying on the #!/usr/bin/env node shebang resolving a system node. So AppImage/deb users need no system Node. Verified locally: the helper spawns under Electron-node and replies over the frame protocol.

  2. Snap confinement — agreed. Dropped the snap target from electron-builder.yml; Linux now ships AppImage + deb (unconfined), which don't block xprop/tesseract//proc. Left a comment to revisit snap with classic confinement or explicit plugs later.

  3. Reproducible test claim — updated LINUX.md to say "run cd desktop/windows && npm test" instead of a hardcoded count. For the record on my machine: 571 passed / 3 skipped, npm run typecheck and eslint clean, and I built + launched on Ubuntu 24 GNOME (X11 and Wayland). Happy for CI/a maintainer to reproduce — the fork CI just needs an "approve and run".

Fully understood on the human-maintainer sign-off for a new platform target + screen-capture surface. Let me know if you'd like this split into smaller PRs (e.g. active-window vs OCR helper) or a tracking issue for the deferred follow-ups (tray/Quit, native-Wayland capture, packaging). Thanks again.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the update, @velinxs. The latest commit addresses the concrete packaging concerns I raised: using Electron's bundled Node for the Linux OCR helper removes the packaged-system-node dependency, dropping snap avoids the obvious strict-confinement failure mode, and the Linux doc now points to a reproducible npm test command instead of relying on a hardcoded pass count.

Maintainer-facing follow-up: I still would not formally approve this automatically because it is a new desktop platform target and affects screen/OCR/foreground-window behavior. It should get human maintainer sign-off on product/maintenance direction plus one trusted reproduction pass for Linux tests/build/launch. I don't think this needs to be split just for size; it is cohesive around Linux desktop support. If maintainers want to reduce risk, a focused checklist is probably enough: AppImage/deb packaging includes resources/linux-ocr-helper/omi-ocr-helper, helper stdio works without system Node, active-window tracking degrades cleanly without X11/xprop, and Wayland defaults behave as documented.

AI-agent/docs note: desktop/windows/LINUX.md is agent-visible implementation guidance for future coding/review agents in this repo. The updated guidance is materially safer than before because it avoids stale exact test-count claims and documents the Electron-node helper spawn and AppImage/deb packaging choice. Human maintainers should still verify the documented Linux behavior before treating it as canonical repo guidance.

Positive signal from me on the implementation direction, with needs-maintainer-review / docs-accuracy remaining appropriate until that verification happens.

@undivisible

Copy link
Copy Markdown
Collaborator

Superseded by the consolidated Linux PR: #10096

#9503 was the primary implementation (platform seams on desktop/windows). Its code is the base of #10096, plus Pulse loopback / deb depends from #8415 and a lazy-koffi import fix.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @velinxs 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

undivisible added a commit that referenced this pull request Jul 20, 2026
Consolidate Linux desktop work as platform seams on desktop/windows
(not a forked desktop/linux tree).

From #9503 (primary):
- X11 active-window via xprop + /proc
- Tesseract OCR helper speaking win-ocr-helper protocol
- XWayland default + PipeWire capturer
- Wayland continuous Rewind default off
- AppImage+deb targets (no snap)

From #8415:
- PulseaudioLoopbackForScreenShare for system-audio loopback
- deb runtime depends (tesseract, libnotify, libxss)

From #9963:
- architecture validation only (forked tree rejected as drift)

Also: lazy-require koffi so Linux import of nativeForeground never
loads the Win32 native module (fixes linux unit tests off-Windows).

Verification: vitest 21/21 on linuxForeground, nativeForeground
linux/degrade, rewindSettings wayland.

Failure-Class: none

Co-authored-by: velinxs <[email protected]>
Co-authored-by: ZachL111 <[email protected]>
Co-authored-by: palontologist <[email protected]>
undivisible added a commit that referenced this pull request Jul 20, 2026
…10110)

## Summary
Adds a scoped `// eslint-disable-next-line
@typescript-eslint/no-require-imports` above the two lazy
`require('koffi')` calls (nativeForeground.ts:45,
userAssistRegistry.ts:46) so the **Desktop Windows CI / Typecheck · Lint
· Test** check goes green on #10096.

The lazy require is the right idea (keeps `nativeForeground` importable
off-Windows); it just trips the `no-require-imports` rule. This is the
exact fix the maintainer requested in the #10096 review.

## Test plan
- `cd desktop/windows && npx eslint src/main/usage/nativeForeground.ts
src/main/usage/userAssistRegistry.ts` → no `no-require-imports` errors.
- Part of the consolidated Linux PR #10096 (supersedes
#9503/#9963/#8415).

## Notes
Pushed from the `consolidation/linux-electron` HEAD. Intended to be
merged into that branch (or squashed into its feat commit) so #10096 can
land.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/10110?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
undivisible added a commit that referenced this pull request Jul 21, 2026
Consolidate Linux desktop work as platform seams on desktop/windows
(not a forked desktop/linux tree).

From #9503 (primary):
- X11 active-window via xprop + /proc
- Tesseract OCR helper speaking win-ocr-helper protocol
- XWayland default + PipeWire capturer
- Wayland continuous Rewind default off
- AppImage+deb targets (no snap)

From #8415:
- PulseaudioLoopbackForScreenShare for system-audio loopback
- deb runtime depends (tesseract, libnotify, libxss)

From #9963:
- architecture validation only (forked tree rejected as drift)

Also: lazy-require koffi so Linux import of nativeForeground never
loads the Win32 native module (fixes linux unit tests off-Windows).

Verification: vitest 21/21 on linuxForeground, nativeForeground
linux/degrade, rewindSettings wayland.

Failure-Class: none

Co-authored-by: velinxs <[email protected]>
Co-authored-by: ZachL111 <[email protected]>
Co-authored-by: palontologist <[email protected]>
undivisible added a commit that referenced this pull request Jul 21, 2026
Consolidate Linux desktop work as platform seams on desktop/windows
(not a forked desktop/linux tree).

From #9503 (primary):
- X11 active-window via xprop + /proc
- Tesseract OCR helper speaking win-ocr-helper protocol
- XWayland default + PipeWire capturer
- Wayland continuous Rewind default off
- AppImage+deb targets (no snap)

From #8415:
- PulseaudioLoopbackForScreenShare for system-audio loopback
- deb runtime depends (tesseract, libnotify, libxss)

From #9963:
- architecture validation only (forked tree rejected as drift)

Also: lazy-require koffi so Linux import of nativeForeground never
loads the Win32 native module (fixes linux unit tests off-Windows).

Verification: vitest 21/21 on linuxForeground, nativeForeground
linux/degrade, rewindSettings wayland.

Failure-Class: none

Co-authored-by: velinxs <[email protected]>
Co-authored-by: ZachL111 <[email protected]>
Co-authored-by: palontologist <[email protected]>
Git-on-my-level added a commit that referenced this pull request Jul 25, 2026
 #8415) (#10096)

## Summary

Consolidates the three open Linux desktop PRs into one landable path:

| PR | Approach | Verdict |
|---|---|---|
| #9503 | Platform seams on `desktop/windows` (+473) | **Primary** —
keep |
| #8415 | Forked `desktop/Linux` tree (+24k) | Port **Pulse loopback +
deb depends** only |
| #9963 | Forked `desktop/linux` tree (+58k, ~75% Windows copy) | Reject
fork; product extras (sign avatar / monologur) stay follow-ups |

Architecture: **one Electron tree** (`desktop/windows`) with
`process.platform` branches. No `desktop/linux` / `desktop/Linux` fork —
those drift from Windows immediately and double maintenance.

### What lands

**From #9503**
- X11 active-window (`linuxForeground.ts` via `xprop` + `/proc`)
- Tesseract OCR helper speaking `win-ocr-helper` stdio protocol
(`resources/linux-ocr-helper/omi-ocr-helper`)
- XWayland default (`OMI_OZONE=wayland` override) + PipeWire capturer
- Wayland: continuous Rewind capture defaults **off**
- Linux targets: AppImage + deb (snap dropped — confinement blocks
xprop/tesseract)

**From #8415**
- `PulseaudioLoopbackForScreenShare` for system-audio loopback
- `.deb` depends: `tesseract-ocr`, `tesseract-ocr-eng`, `libnotify4`,
`libxss1`

**Fix on top of #9503**
- Lazy-`require('koffi')` so Linux import of `nativeForeground` never
loads Win32 native module (unit tests were broken off-Windows)

## Tests
```
cd desktop/windows
npx vitest run \
  src/main/usage/linuxForeground.test.ts \
  src/main/usage/nativeForeground.linux.test.ts \
  src/main/usage/nativeForeground.degrade.test.ts \
  src/main/rewind/rewindSettings.wayland.test.ts
# → 22/21+ focused Linux tests (includes foregroundMonitor.linux)
```

## Product invariants
None. Path globs under `desktop/windows` for Linux seams only.

## Credits

Consolidated from community PRs (code selected into `desktop/windows`
seams; forked trees not re-merged):

| PR | Author | Role |
|---|---|---|
| #9503 | @velinxs | Primary Linux platform seams (X11, OCR helper,
XWayland, Wayland Rewind default) |
| #8415 | @ZachL111 | Pulse loopback flag + deb depends (from Linux
packaging work) |
| #9963 | @palontologist | Architecture reference; full `desktop/linux`
fork not adopted |

Git trailers on the feat commit: `Co-authored-by` for all three.

Failure-Class: none

Closes #9503
Closes #9963
Closes #8415


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/10096?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop docs-accuracy Documentation or committed reports need accuracy fixes needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants