fix: load skip-local-server flag from shell env at runtime

Reads OPENCHAMBER_SKIP_LOCAL_SERVER after inheriting the user shell environment
Applies the flag consistently during startup and initial URL resolution
Updates Electron docs to explain where the setting comes from
This commit is contained in:
Bohdan Triapitsyn
2026-07-22 20:30:50 +03:00
parent f8b41076e6
commit a1784b8697
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ Use an explicit override when testing a different OpenCode CLI build or when a u
|----------|-----|
| `OPENCHAMBER_ELECTRON_DEV=1` | Marks the runtime as desktop development mode |
| `OPENCHAMBER_ELECTRON_USE_BUNDLED_UI=1` | Uses staged web assets instead of the HMR dev server |
| `OPENCHAMBER_SKIP_LOCAL_SERVER=1` | Skips the in-process local OpenChamber server and uses the configured default remote instance; packaged/bundled UI remains available for connection recovery |
| `OPENCHAMBER_SKIP_LOCAL_SERVER=1` | Skips the in-process local OpenChamber server and uses the configured default remote instance; Desktop imports this from the user's login-shell environment, and packaged/bundled UI remains available for connection recovery |
| `OPENCHAMBER_HMR_UI_PORT` | Preferred Vite UI port for desktop dev, default `5173` |
| `OPENCHAMBER_HMR_API_PORT` | Preferred API port for desktop dev, default `3901` |
| `OPENCHAMBER_RUNTIME=desktop` | Set by Electron before starting the web server |
+8 -4
View File
@@ -183,8 +183,6 @@ const DISCORD_INVITE_URL = 'https://discord.gg/ZYRSdnwwKA';
const INSTALLED_APPS_CACHE_TTL_SECS = 60 * 60 * 24;
const INSTALLED_APPS_CACHE_FILE = 'discovered-apps.json';
const OPENCODE_SHUTDOWN_GRACE_MS = 100;
const SKIP_LOCAL_SERVER = process.env.OPENCHAMBER_SKIP_LOCAL_SERVER === '1';
const { autoUpdater } = updaterPkg;
const state = {
@@ -1325,6 +1323,11 @@ const inheritUserShellEnv = () => {
}
};
const shouldSkipLocalServer = () => {
inheritUserShellEnv();
return process.env.OPENCHAMBER_SKIP_LOCAL_SERVER === '1';
};
const spawnLocalServer = async () => {
inheritUserShellEnv();
@@ -2769,7 +2772,8 @@ const resolveInitialUrl = async () => {
const hmrUiPort = process.env.OPENCHAMBER_HMR_UI_PORT || '5173';
const hmrApiUrl = `http://127.0.0.1:${hmrApiPort}`;
const hmrUiUrl = `http://127.0.0.1:${hmrUiPort}`;
const localUrl = SKIP_LOCAL_SERVER
const skipLocalServer = shouldSkipLocalServer();
const localUrl = skipLocalServer
? null
: isDev && await waitForHealth(hmrApiUrl, 5_000, 100)
? hmrApiUrl
@@ -4925,7 +4929,7 @@ app.whenReady().then(async () => {
state.requestHeaders = sanitizeRuntimeRequestHeaders(requestHeaders || {});
// Serverless background startup re-probes the remote when a window is
// eventually opened instead of trusting reachability from login time.
state.startupResolved = !SKIP_LOCAL_SERVER;
state.startupResolved = !shouldSkipLocalServer();
state.initScript = buildInitScript(localOrigin, state.bootOutcome, apiBaseUrl, clientToken, state.requestHeaders);
log.info('[electron] started in background without window');
return;