From 9ff3eda40aff2d872d2099a0b3fcdeedfe19e49d Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 12 Nov 2026 00:34:16 -0800 Subject: [PATCH] fix(cloud): inline-code segments keyed by text offset (react-doctor) --- .../CloudAgentSignInStrip.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx index b54ad6f0c78..35fd233059c 100644 --- a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx @@ -129,17 +129,23 @@ function StatusSlot({ status }: { status: CloudStripStatus }): React.JSX.Element /** `…` in a detail is a command: shown as inline code (design-squad). */ function withInlineCode(text: string): React.ReactNode { - const parts = text.split(/`([^`]+)`/) - if (parts.length === 1) { + if (!text.includes('`')) { return text } - return parts.map((part, index) => - index % 2 === 1 ? ( - - {part} + // Segments keyed by where they start in the text: fixed for a given string. + const segments: { at: number; text: string; code: boolean }[] = [] + let at = 0 + text.split(/`([^`]+)`/).forEach((part, i) => { + segments.push({ at, text: part, code: i % 2 === 1 }) + at += part.length + (i % 2 === 1 ? 2 : 0) + }) + return segments.map((segment) => + segment.code ? ( + + {segment.text} ) : ( - part + {segment.text} ) ) }