feat(desktop): allow slim pro overlay when VITE_PRO_BUILD + VITE_DESKTOP both set

v0.3.x main.tsx explicitly REFUSED to load @pro when VITE_DESKTOP was
true ("desktop owns its own license + auth UI"). v0.4.0 brings the
AI agent into the desktop bundle, so the refusal needs to relax for
that one use case.

New routing inside the if(VITE_PRO_BUILD) branch:
  - VITE_DESKTOP also set → load @pro/desktop_index (slim entry that
    only mounts AgentChatPanel + DiagnoseCompileButton, no analytics
    / sessions / billing / admin / save overrides - those expect
    velxio.dev cookies the desktop has no way to send)
  - VITE_DESKTOP not set → load @pro/index (existing web behavior)

VITE_DESKTOP alone (no pro) still loads zero overlay - that's the
pure-OSS desktop build path for self-hosters who don't have the
pro source tree at $PRO_OVERLAY_PATH.

Companion commit in velxio-prod creates @pro/desktop_index, adapts
the agent client for license-key Bearer auth, and updates
build-frontend.sh to pass both flags.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Montero Crespo 2026-05-26 14:09:07 -03:00
parent b2474bf5d1
commit 3bd6f144f2
1 changed files with 17 additions and 9 deletions

View File

@ -47,15 +47,23 @@ requestAnimationFrame(() => {
// VITE_PRO_BUILD=true at build time. The dynamic import keeps the pro chunk
// out of the OSS bundle entirely (Vite tree-shakes the never-taken branch).
//
// VITE_DESKTOP=true is set by the Tauri desktop build. The desktop shell
// owns its own license + auth UI (Phase 3 of paid-clients) and runs against
// a locally spawned sidecar, so the velxio.dev-coupled overlay (trackers,
// billing, cloud auth, admin) is intentionally NOT loaded — even if a
// build accidentally sets both flags.
if (import.meta.env.VITE_PRO_BUILD && !import.meta.env.VITE_DESKTOP) {
import('@pro/index')
.then((m) => m.mountPro?.())
.catch((err) => console.warn('[pro] failed to load overlay:', err));
// Two desktop modes since v0.4.0:
// - VITE_PRO_BUILD + VITE_DESKTOP → slim pro entry (@pro/desktop_index)
// that ONLY mounts the AI agent + DiagnoseCompileButton, no analytics
// / sessions / billing / admin / save overrides (those talk to
// velxio.dev with cookies the desktop doesn't have).
// - VITE_PRO_BUILD only (web) → full mountPro with every surface.
// VITE_DESKTOP alone (no pro) stays a pure-OSS desktop build.
if (import.meta.env.VITE_PRO_BUILD) {
if (import.meta.env.VITE_DESKTOP) {
import('@pro/desktop_index')
.then((m) => m.mountProDesktop?.())
.catch((err) => console.warn('[pro-desktop] failed to load slim overlay:', err));
} else {
import('@pro/index')
.then((m) => m.mountPro?.())
.catch((err) => console.warn('[pro] failed to load overlay:', err));
}
}
// Desktop-only hooks (ESP32 QEMU prompt now, welcome screen in Phase 3).