fix: resolve shell tabs via OS user shell#58
fix: resolve shell tabs via OS user shell#58ASRagab wants to merge 4 commits intojohannesjo:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves default shell selection in the Electron main process by resolving the user’s login shell from the OS (via os.userInfo().shell) before falling back to process.env.SHELL, and reuses the same resolver for both PTY shell tabs and PATH bootstrapping.
Changes:
- Add a shared
resolveUserShell()helper with OS-first, env fallback, then/bin/sh(orcmd.exe) fallback behavior. - Use
resolveUserShell()infixPath()(Electron main) and PTY shell tab spawning. - Add Vitest coverage for OS shell preference and fallback scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| electron/user-shell.ts | Introduces shared shell-resolution logic (OS shell → env SHELL → platform default). |
| electron/user-shell.test.ts | Adds tests validating preference and fallback behavior for shell resolution. |
| electron/main.ts | Switches PATH bootstrap to use the shared shell resolver. |
| electron/ipc/pty.ts | Switches PTY default shell command to use the shared shell resolver. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| const osShell = normalizeShell(userInfo().shell); | ||
| if (osShell) return osShell; | ||
| } catch { | ||
| // Fall back to inherited environment if the OS lookup is unavailable. |
There was a problem hiding this comment.
resolveUserShell() returns the OS-reported shell path without verifying it exists/is executable. If a user's account shell is misconfigured (or points to a removed binary), this will now cause shell tabs to fail (via validateCommand) even if env.SHELL or /bin/sh would work. Consider checking executability before returning osShell, and fall back to env.SHELL//bin/sh when the OS shell isn't runnable.
electron/user-shell.ts
Outdated
| @@ -0,0 +1,30 @@ | |||
| import * as os from 'node:os'; | |||
There was a problem hiding this comment.
For consistency with the rest of the Electron code (e.g., electron/main.ts and electron/ipc/pty.ts), consider importing the Node built-in as import * as os from 'os' instead of using the node:-prefixed specifier.
| import * as os from 'node:os'; | |
| import * as os from 'os'; |
|
@johannesjo welcome back. Updated. |
|
Review notes (Copilot's two comments appear already addressed in the current version — Two new items worth considering: 1. Unrelated The diff includes two lines added to These appear to be local developer config that crept in. They have no relation to the shell-resolution fix and should be dropped from this PR. 2. Missing test for
No correctness bugs found. The core logic ( |
|
Thank you very much! <3 |
johannesjo
left a comment
There was a problem hiding this comment.
The resolveUserShell() implementation is correct and the tests are comprehensive. One minor scope issue: the diff includes .prettierignore entries that appear unrelated to the shell-resolution fix — please check if these were accidentally included from another branch and clean up the diff. Once that's resolved this is ready to merge. Details in the review comment.
|
removed entries...thanks |
Summary
os.userInfo().shellbefore falling back toprocess.env.SHELL/bin/shfallback behaviorWhy
Parallel Code currently falls back to the inherited
SHELLenvironment variable when no explicit shell command is provided. That can cause shell tabs to launchbasheven when the user's actual account login shell iszsh(or another shell), depending on how Electron was launched.Using the OS-reported user shell first makes the default shell selection more faithful and predictable.
Test Plan
npm run typechecknpm test