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:
Neil
2026-10-03 01:49:40 -07:00
committed by Neil
co-authored by czzczz
parent 33cab243ab
commit 7fb201f60f
15 changed files with 231 additions and 80 deletions
+5 -7
View File
@@ -11,13 +11,11 @@ export function cleanGeneratedCommitMessage(raw: string): string {
// answer field when the output is such an envelope.
if (text.startsWith('{')) {
try {
const parsed = JSON.parse(text) as unknown
if (
typeof parsed === 'object' &&
parsed !== null &&
typeof (parsed as Record<string, unknown>).text === 'string'
) {
text = (parsed as Record<string, string>).text.trim()
const parsed: unknown = JSON.parse(text)
const answer: unknown =
typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, 'text') : undefined
if (typeof answer === 'string') {
text = answer.trim()
}
} catch {
// not a JSON envelope; fall through to the plain-text cleanup