mirror of
https://github.com/stablyai/orca.git
synced 2026-10-08 00:02:38 +00:00
fix(jcode): stop the OSC color skip from crashing every pane connect
Co-authored-by: czzczz <chanzrz_zbf@foxmail.com>
This commit is contained in:
committed by
Neil
co-authored by
czzczz
parent
33cab243ab
commit
7fb201f60f
@@ -16,19 +16,26 @@ export function resetJcodeDaemonPrewarmForTests(): void {
|
||||
prewarmedRuntimeDirs.clear()
|
||||
}
|
||||
|
||||
/** The runtime dir to warm, or null when this pane is not a local jcode launch. */
|
||||
export function resolveJcodePrewarmRuntimeDir(args: {
|
||||
launchAgent?: string
|
||||
runtimeDir?: string
|
||||
platform?: NodeJS.Platform
|
||||
}): string | null {
|
||||
// Why non-Windows only: the runtime dir is a unix-socket directory, and Orca
|
||||
// only stamps it off Windows (see shouldInjectJcodeRuntimeDir).
|
||||
if (args.launchAgent !== 'jcode' || (args.platform ?? process.platform) === 'win32') {
|
||||
return null
|
||||
}
|
||||
return args.runtimeDir !== undefined && args.runtimeDir.length > 0 ? args.runtimeDir : null
|
||||
}
|
||||
|
||||
export function shouldPrewarmJcodeDaemon(args: {
|
||||
launchAgent?: string
|
||||
runtimeDir?: string
|
||||
platform?: NodeJS.Platform
|
||||
}): boolean {
|
||||
// Why non-Windows only: the runtime dir is a unix-socket directory, and Orca
|
||||
// only stamps it off Windows (see shouldInjectJcodeRuntimeDir).
|
||||
return (
|
||||
args.launchAgent === 'jcode' &&
|
||||
typeof args.runtimeDir === 'string' &&
|
||||
args.runtimeDir.length > 0 &&
|
||||
(args.platform ?? process.platform) !== 'win32'
|
||||
)
|
||||
return resolveJcodePrewarmRuntimeDir(args) !== null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,10 +52,10 @@ export function prewarmJcodeDaemon(args: {
|
||||
env?: Record<string, string>
|
||||
platform?: NodeJS.Platform
|
||||
}): boolean {
|
||||
if (!shouldPrewarmJcodeDaemon(args) || prewarmedRuntimeDirs.has(args.runtimeDir as string)) {
|
||||
const runtimeDir = resolveJcodePrewarmRuntimeDir(args)
|
||||
if (runtimeDir === null || prewarmedRuntimeDirs.has(runtimeDir)) {
|
||||
return false
|
||||
}
|
||||
const runtimeDir = args.runtimeDir as string
|
||||
prewarmedRuntimeDirs.add(runtimeDir)
|
||||
try {
|
||||
const child = spawnProcess({
|
||||
|
||||
@@ -7,7 +7,7 @@ import { dirname, join } from 'node:path'
|
||||
|
||||
const { homedirMock } = vi.hoisted(() => ({ homedirMock: vi.fn<() => string>() }))
|
||||
vi.mock('os', async () => {
|
||||
const actual = (await vi.importActual('os')) as Record<string, unknown>
|
||||
const actual = await vi.importActual<typeof import('os')>('os') // eslint-disable-line @typescript-eslint/consistent-type-imports -- vi.importActual requires inline import()
|
||||
return { ...actual, homedir: homedirMock }
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const { homedirMock } = vi.hoisted(() => ({
|
||||
}))
|
||||
|
||||
vi.mock('os', async () => {
|
||||
const actual = (await vi.importActual('os')) as Record<string, unknown>
|
||||
const actual = await vi.importActual<typeof import('os')>('os') // eslint-disable-line @typescript-eslint/consistent-type-imports -- vi.importActual requires inline import()
|
||||
return { ...actual, homedir: homedirMock }
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user