fix(desktop): keep preset gating from throwing on unparseable commands
Problem
The v2 workspace page falls to its error screen when any terminal preset command contains shell that shell-quote cannot tokenize, for example an unclosed ${. The page stays broken while that preset exists.
Root cause
commandPrograms in renderer/lib/agent-launch-command.ts calls shell-quote's parse on free-form preset text to find which agent binary a preset runs (feature-flag gating). parse throws Bad substitution on an unterminated or empty ${...} (shell-quote/parse.js, parseEnvVar). The call runs inside a useMemo in useV2PresetExecution via isLinkedPresetLaunchable → runsGatedAgent, so the throw escapes into render. The same helper backs isTerminalPresetEnabled in the v1 workspace view, presets bar and tab menus.
Fix
Tokenize through a small wrapper that returns no tokens when parse throws. A command we cannot read names no program we can match, so it is not gated; the user's shell reports the syntax error when the preset runs, as it did before gating existed.
Verification
- Probe (not committed):
runsGatedAgent(["echo ${"], …)and["echo ${}"]— throws onorigin/main, returnsfalsewith the fix. bunx biome check apps/desktop/src/renderer/lib/agent-launch-command.ts→Checked 1 file in 36ms. No fixes applied.cd apps/desktop && bun run typecheck→tsr generate+tsc --noEmit, no errors.bun test src/renderer/lib <useV2PresetExecution dir>→4373 pass, 0 fail.
Refs DESKTOP-1VC
Summary by cubic
Stops terminal preset gating from crashing the v2 workspace page when a preset command contains shell that shell-quote cannot tokenize, like an unclosed ${. The page no longer falls to its error screen; unparseable commands are treated as naming no program, so gating skips them and the user's shell reports the syntax error when the preset runs, as before gating existed.
Summary by CodeRabbit
- Bug Fixes
- Invalid command syntax no longer causes program detection to fail with an error.