mirror of
https://github.com/stablyai/orca.git
synced 2026-10-15 16:02:49 +00:00
* fix(terminal): submit startup commands with Enter on every platform LF is Ctrl+J to a line editor, so a shell that remaps it left the command at the prompt. Fixes #23250 Co-authored-by: Aashish Mahato <145881415+aashish254@users.noreply.github.com> * test(terminal): expect CR in pty ipc startup tests * fix(terminal): submit every line of a raw multiline startup command with CR The CR switch only replaced the trailing terminator. On the raw path — a shell with no bracketed paste, so each line break submits its own line — interior LFs stayed LF, which is the same remappable Ctrl+J the fix set out to remove. A multiline startup command in sh/dash/nushell/PowerShell therefore still stalled partway through for a user who rebinds Ctrl+J. Normalise interior breaks to CR on that path only; the bracketed-paste payload keeps its literal newlines. * fix(terminal): quote multi-line PowerShell arguments on one line A multi-line agent prompt was quoted as a single-quoted PowerShell string with raw line breaks. Typed into Windows PowerShell 5.1 without PSReadLine, each break submits a line and the shell waits at `>>` forever. Values with CR/LF now become one double-quoted line with backtick escapes, keeping every byte; single-line values keep the single-quoted form unchanged. * style(terminal): keep typographic quotes as \u escapes in PowerShell quoting Restores the escape form the single-quoted regex used on main and applies it to the new double-quoted regex and the native argv test, so the diff against main stays minimal and the characters are visible in review. --------- Co-authored-by: Aashish Mahato <145881415+aashish254@users.noreply.github.com> Co-authored-by: Neil <neil@stably.ai> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
36 lines
1.6 KiB
TypeScript
36 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { quotePowerShellLiteral, quotePowerShellNativeArgument } from './powershell-native-argument'
|
|
|
|
describe('PowerShell native argument quoting', () => {
|
|
it('escapes literals for PowerShell source parsing', () => {
|
|
expect(quotePowerShellLiteral("WSL 'Preview'")).toBe("'WSL ''Preview'''")
|
|
expect(quotePowerShellLiteral('O\u2019Brien \u2018x\u201A\u201B')).toBe(
|
|
"'O\u2019\u2019Brien \u2018\u2018x\u201A\u201A\u201B\u201B'"
|
|
)
|
|
})
|
|
|
|
it('keeps a value with a line break on one physical line', () => {
|
|
expect(quotePowerShellLiteral('line one\nline two')).toBe('"line one`nline two"')
|
|
expect(quotePowerShellLiteral('a\r\nb\rc')).toBe('"a`r`nb`rc"')
|
|
})
|
|
|
|
it('escapes the double-quoted specials in a multi-line value', () => {
|
|
expect(
|
|
quotePowerShellLiteral('$(Remove-Item x) `t "q" \u201Cl\u201D \u201Elow \'single\'\nend')
|
|
).toBe('"`$(Remove-Item x) ``t `"q`" `\u201Cl`\u201D `\u201Elow \'single\'`nend"')
|
|
})
|
|
|
|
it('leaves single-line values on the single-quoted form', () => {
|
|
expect(quotePowerShellLiteral('a $b `c "d"')).toBe('\'a $b `c "d"\'')
|
|
})
|
|
|
|
it('pre-escapes embedded quotes for Windows native argv parsing', () => {
|
|
expect(quotePowerShellNativeArgument('eval "decoded"')).toBe(String.raw`'eval \"decoded\"'`)
|
|
expect(quotePowerShellNativeArgument(String.raw`before\"after`)).toBe(
|
|
String.raw`'before\\\"after'`
|
|
)
|
|
// Why: the argv pre-escape survives the multi-line form, so 5.1 still passes `\"` to argv.
|
|
expect(quotePowerShellNativeArgument('say "hi"\nbye')).toBe('"say \\`"hi\\`"`nbye"')
|
|
})
|
|
})
|