mirror of
https://github.com/stablyai/orca.git
synced 2026-10-02 00:02:05 +00:00
fix(cli): preserve text between terminal sequences
This commit is contained in:
@@ -28,7 +28,7 @@ export function formatArtifactRead(result: ArtifactReadResult): string {
|
||||
export function sanitizeArtifactTerminalContent(content: string): string {
|
||||
const escape = String.fromCharCode(27)
|
||||
const osc = new RegExp(
|
||||
`${escape}\\][^${String.fromCharCode(7)}]*(?:${String.fromCharCode(7)}|${escape}\\\\)`,
|
||||
`${escape}\\][^${String.fromCharCode(7)}]*?(?:${String.fromCharCode(7)}|${escape}\\\\)`,
|
||||
'g'
|
||||
)
|
||||
const csi = new RegExp(`${escape}(?:\\[[0-9;?]*[ -/]*[@-~])`, 'g')
|
||||
|
||||
@@ -5,6 +5,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { ArtifactListItem } from '../../shared/artifacts'
|
||||
import { ARTIFACT_HANDLERS } from './artifacts'
|
||||
import { ARTIFACT_CLI_MAX_RPC_BYTES } from '../../shared/artifacts'
|
||||
import { sanitizeArtifactTerminalContent } from '../artifact-format'
|
||||
import {
|
||||
ARTIFACT_SHARING_DISABLED_CODE,
|
||||
ARTIFACT_SHARING_DISABLED_MESSAGE,
|
||||
@@ -99,6 +100,16 @@ describe('artifact CLI handlers', () => {
|
||||
expect(log).toHaveBeenCalledWith(`Artifact written to ${JSON.stringify(resolve(cwd, output))}`)
|
||||
expect(String(log.mock.calls[0]?.[0])).not.toContain('\u001b]52;')
|
||||
})
|
||||
|
||||
it('preserves text between separate OSC terminal sequences', () => {
|
||||
const escape = String.fromCharCode(27)
|
||||
const bell = String.fromCharCode(7)
|
||||
expect(
|
||||
sanitizeArtifactTerminalContent(
|
||||
`${escape}]8;;https://example.com${bell}visible${escape}]0;title${bell}`
|
||||
)
|
||||
).toBe('visible')
|
||||
})
|
||||
it('reads a relative HTML file and sends sanitized content to the runtime', async () => {
|
||||
const cwd = await mkdtemp(join(tmpdir(), 'orca-artifact-cli-'))
|
||||
await writeFile(join(cwd, 'report.html'), '<h1>Hi</h1>', 'utf8')
|
||||
|
||||
Reference in New Issue
Block a user