From e6d4797e6a31fbde5b5ab434b4ff7ea897d064fc Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 14 Sep 2026 06:06:30 -0700 Subject: [PATCH] fix(omp): preserve unmodelled shell launch commands --- src/shared/omp-fresh-launch.test.ts | 11 +++++++++-- src/shared/omp-fresh-launch.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/shared/omp-fresh-launch.test.ts b/src/shared/omp-fresh-launch.test.ts index 49bc83a996f..eb8c94e2e5c 100644 --- a/src/shared/omp-fresh-launch.test.ts +++ b/src/shared/omp-fresh-launch.test.ts @@ -27,9 +27,16 @@ describe('OMP fresh launch intent', () => { 'omp --model', 'omp -- hello', 'echo omp', - 'omp && echo hi' + 'omp && echo hi', + 'omp --model foo;', + 'omp --model $(preferred-model)', + 'omp --model `preferred-model`' ])('preserves %s', (command) => { - expect(withFreshOmpLaunch(command, 'posix')).toContain(command) + expect(withFreshOmpLaunch(command, 'posix')).toBe(command) + }) + it.each(['cmd', 'powershell'] as const)('preserves compound values in %s', (shell) => { + const command = 'omp --model foo&' + expect(withFreshOmpLaunch(command, shell)).toBe(command) }) it('quotes the host config path for each Windows shell', () => { expect(withFreshOmpLaunch('omp', 'powershell')).toContain( diff --git a/src/shared/omp-fresh-launch.ts b/src/shared/omp-fresh-launch.ts index 11d9bf0d3e0..085d7e5976b 100644 --- a/src/shared/omp-fresh-launch.ts +++ b/src/shared/omp-fresh-launch.ts @@ -25,7 +25,7 @@ const SWITCH_FLAGS = new Set(['--no-extensions', '--no-skills', '--no-prompt-tem /** Apply fresh intent to one launch command, never the saved resume configuration. */ export function withFreshOmpLaunch(command: string, shell: AgentStartupShell, suffix = ''): string { const parsed = tokenizeStartupCommand(command, shell) - if (!parsed.ok) { + if (!parsed.ok || parsed.spans.some((span) => span.divergesFromShell)) { return command + suffix } const executable = parsed.tokens[0]?.split(/[\\/]/).at(-1)?.toLowerCase()