Skip to content

Make PowerShell the Windows default shell, add configurable shell selection, and remove per-command shim overhead#11

Merged
codomium merged 10 commits intomainfrom
copilot/make-powershell-default-shell
Apr 20, 2026
Merged

Make PowerShell the Windows default shell, add configurable shell selection, and remove per-command shim overhead#11
codomium merged 10 commits intomainfrom
copilot/make-powershell-default-shell

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

  • Update root README.md: rename to freeCode, add vibe-coder tagline, add v2.4 feature section (voice input, file-watcher toast, tool-error inject, CLAUDE.md offer), fix Quick Start stale vsix/command-palette references, fix in-prose "FreeCode" → "freeCode"
  • Update electron-app/README.md: rename to freeCode with vibe-coder subtitle, add v2.4 feature section, fix data storage path (%APPDATA%\freeCode\), fix installer filenames (freeCode Setup 1.0.0.exe, freeCode-1.0.0-portable.exe)
  • Resolve merge conflicts with origin/main — merged multi-agent settings, provider management (validateProvider), and system-prompt preset alongside our defaultShell, MCP marketplace, voice input, and CLAUDE.md features
Original prompt

Problem

The current shell detection in both electron-app/main.js and vscode-extension/extension.js wastes tokens and time by:

  1. Always trying WSL/Ubuntu first (even on systems without it), causing failed attempts before falling back to PowerShell.
  2. Running spawnSync('wsl.exe', ['--status']) and spawnSync('wsl.exe', ['-d', 'Ubuntu', ...]) as detection probes on every cold start — these are slow and burn tokens when the agent retries shell commands.
  3. No user-facing setting to choose their preferred shell — users are stuck with whatever the auto-detect picks.
  4. PowerShell shims for POSIX tools (grep, cat, find, etc.) are injected as a string prefix on every single command, which is extremely verbose and wasteful.
  5. The agent doesn't know which shell it's running in, so it may emit bash-syntax commands that fail in PowerShell, causing retry loops.

Goal

Make PowerShell the default and first-tried shell on Windows. Stop burning tokens on incompatible retries. Let users configure their preferred shell in Settings. Teach the agent to emit shell-appropriate commands.


Changes Required

1. New Setting: defaultShell

electron-app/main.jsDEFAULT_SETTINGS

Add:

defaultShell: 'auto', // 'auto' | 'powershell' | 'wsl' | 'ubuntu' | 'bash' | 'cmd'

vscode-extension/package.json — configuration properties

Add:

"openClaudeCode.defaultShell": {
  "type": "string",
  "enum": ["auto", "powershell", "wsl", "ubuntu", "bash", "cmd"],
  "enumDescriptions": [
    "Auto-detect best available shell (PowerShell preferred on Windows)",
    "Windows PowerShell (default on Windows)",
    "WSL — Windows Subsystem for Linux (generic)",
    "WSL Ubuntu distro specifically",
    "Bash (macOS/Linux default)",
    "Windows Command Prompt (cmd.exe)"
  ],
  "default": "auto",
  "description": "Default shell used by the AI agent for running commands. PowerShell is the default on Windows."
}

electron-app/renderer/index.html — Settings Panel

Add a "Default Shell" dropdown in the settings panel under a new "Terminal & Shell" section:

┌─ Terminal & Shell ──────────────────────────────────┐
│  Default Shell:  [PowerShell ▼]                    │
│  (Used by the AI agent for all terminal commands)  │
│                                                    │
│  Available: ✅ PowerShell  ✅ WSL  ❌ Ubuntu       │
│  [Detect Available Shells]                         │
└────────────────────────────────────────────────────┘

The "Detect Available Shells" button sends a detectShells IPC message and shows which shells are actually available on this machine.


2. Rewrite detectPreferredShell() — PowerShell First

electron-app/main.js

Replace the current detectPreferredShell() with a new version that:

  1. Reads user setting first — if defaultShell is not 'auto', use it directly without any probing:

    function detectPreferredShell() {
      if (_preferredShell) return _preferredShell;
      const s = getSettings();
      const pref = s.defaultShell || 'auto';
      
      if (pref !== 'auto') {
        // User explicitly chose — use it directly, no probing
        _preferredShell = resolveShellByName(pref);
        return _preferredShell;
      }
      
      // auto-detect: PowerShell first on Windows
      if (process.platform !== 'win32') {
        _preferredShell = { type: 'bash', exe: 'bash', args: ['-c'], syntax: 'bash' };
        return _preferredShell;
      }
      
      // Windows: try PowerShell first (it's always available on modern Windows)
      if (isPowerShellAvailable()) {
        _preferredShell = { type: 'powershell', exe: 'powershell.exe', args: ['-NoProfile', '-NonInteractive', '-Command'], syntax: 'powershell' };
        return _preferredShell;
      }
      
      // Fallback: cmd
      _preferredShell = { type: 'cmd', exe: 'cmd.exe', args: ['/c'], syntax: 'cmd' };
      return _preferredShell;
    }
  2. isPowerShellAvailable() — fast synchronous check:

    function isPowerShellAvailable() {
      try {
        const r = spawnSync('powershell.exe', ['-NoProfile', '-Command', 'exit 0'], {
          encoding: 'utf-8', timeout: 2000, windowsHide: true,
        });
        return r.status === 0;
      } catch { return false; }
    }
  3. resolveShellByName(name) — maps setting value to shell config:

    function resolveShellByName(name) {
      const map = {
        powershell: { type: 'powershell', exe: 'powershell.exe', args: ['-NoProfile', '-NonInteractive', '-Command'], syntax: 'powershell' },
        wsl:        { type: 'wsl', exe: 'wsl.exe', args: ['bash', '-c'], syntax: 'bash' },
        ubuntu:     { type: 'ubuntu', exe: 'wsl.exe', args: ['-d', 'Ubuntu', '--', 'bash', '-c'], syntax: 'bash' },
        bash:       { type: 'bash', exe: 'bash', args: ['-c'], syntax: 'bash' },
        cmd:        { type: 'cmd', exe: 'cmd.exe', args: ['/c'], syntax: 'cmd' },
      };
      return map[name] || map['pow...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Set PowerShell as the default shell for Windows Make PowerShell the Windows default shell, add configurable shell selection, and remove per-command shim overhead Apr 20, 2026
Copilot AI requested a review from codomium April 20, 2026 11:31
Copilot AI and others added 3 commits April 20, 2026 13:19
Copilot AI and others added 2 commits April 20, 2026 14:00
…or inject, CLAUDE.md offer

Agent-Logs-Url: https://github.com/codomium/FreeCode/sessions/d0d2cae7-7283-4d47-977b-c3e390aed2d3

Co-authored-by: codomium <255525663+codomium@users.noreply.github.com>
…oast, tool-error, CLAUDE.md)

Agent-Logs-Url: https://github.com/codomium/FreeCode/sessions/e3eff261-6842-4968-b991-d0612edfcc20

Co-authored-by: codomium <255525663+codomium@users.noreply.github.com>
@codomium codomium marked this pull request as ready for review April 20, 2026 15:59
@codomium
Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

@codomium
Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

…ll-default-shell

# Conflicts:
#	electron-app/main.js
#	electron-app/package.json
#	electron-app/renderer/chat.js

Co-authored-by: codomium <255525663+codomium@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 8091d47. The three conflicting files (main.js, package.json, renderer/chat.js) were merged to include both sets of changes — our branch's defaultShell, MCP marketplace, and freeCode rebrand alongside origin/main's multi-agent settings, validateProvider case, and system-prompt preset.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot resolve the merge conflicts in this pull request

The merge conflicts were already resolved in commit 8091d47. The branch is clean and up to date — all three conflicting files (electron-app/main.js, electron-app/package.json, electron-app/renderer/chat.js) were merged to include both sets of changes.

Copilot stopped work on behalf of codomium due to an error April 20, 2026 16:06
@codomium codomium merged commit d15fa93 into main Apr 20, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants