You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Fix: Use tilde path in SSH runtime to avoid process.env in renderer (#458)
Fixes regression from #451 where was using `process.env.USER` in
renderer code, causing "process is not defined" error during workspace
creation.
## Problem
After merging #451, workspace creation fails with:
```
ReferenceError: process is not defined
at parseRuntimeString (chatCommands.ts:56:66)
```
The issue: `chatCommands.ts` is renderer code that was trying to access
`process.env.USER` to construct SSH default paths. The `process` global
is not available in Electron renderer processes.
## Solution
**Use tilde paths instead** - Now that we have tilde resolution from
#451, we can simply use `~/cmux` as the default SSH `srcBaseDir`. The
backend will resolve it via `runtime.resolvePath()`.
Before:
```typescript
const user = atIndex > 0 ? hostPart.substring(0, atIndex) : (process.env.USER ?? "user");
const homeDir = user === "root" ? "/root" : `/home/${user}`;
return {
type: "ssh",
host: hostPart,
srcBaseDir: `${homeDir}/cmux`,
};
```
After:
```typescript
return {
type: "ssh",
host: hostPart,
srcBaseDir: "~/cmux", // Backend resolves via runtime.resolvePath()
};
```
## ESLint Rule
Added `no-restricted-globals` and `no-restricted-syntax` rules to
prevent future `process.env` usage in renderer code:
- Applies to: `src/**/*.ts(x)`
- Excludes: main, preload, services, runtime, telemetry, utils/main,
utils/providers, tests
- Error message guides developers to use IPC or constants instead
This catches the issue at development time rather than runtime.
## Testing
- Unit tests updated to expect `~/cmux` instead of computed paths
- ESLint passes with new rules
- Workspace creation now works without process.env
_Generated with `cmux`_
// Renderer process (frontend) architectural boundary - prevent Node.js API usage
396
+
files: ["src/**/*.ts","src/**/*.tsx"],
397
+
ignores: [
398
+
"src/main*.ts",
399
+
"src/preload.ts",
400
+
"src/services/**",
401
+
"src/runtime/**",
402
+
"src/utils/main/**",
403
+
"src/utils/providers/**",
404
+
"src/telemetry/**",
405
+
"src/git.ts",
406
+
"src/config.ts",
407
+
"src/debug/**",
408
+
"**/*.test.ts",
409
+
"**/*.test.tsx",
410
+
],
411
+
rules: {
412
+
"no-restricted-globals": [
413
+
"error",
414
+
{
415
+
name: "process",
416
+
message:
417
+
"Renderer code cannot access 'process' global (not available in renderer). Use IPC to communicate with main process or use constants for environment-agnostic values.",
0 commit comments