From 225401ceca433705d11c119b3373913c95129c56 Mon Sep 17 00:00:00 2001 From: "Kai (Tam Nhu) Tran" <61256810+kaitranntt@users.noreply.github.com> Date: Mon, 11 May 2026 20:43:26 -0400 Subject: [PATCH] fix(ui): render codex config as exact text (#1215) --- .../raw-json-settings-editor-panel.tsx | 3 + ui/src/components/shared/code-editor.tsx | 93 ++++++++++++------- ui/src/pages/codex.tsx | 1 + .../unit/components/ui/code-editor.test.tsx | 28 ++++++ 4 files changed, 93 insertions(+), 32 deletions(-) diff --git a/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx b/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx index 62dd91f6..fce059e5 100644 --- a/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx +++ b/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx @@ -23,6 +23,7 @@ interface RawConfigEditorPanelProps { onRefresh: () => Promise | void; onDiscard?: () => void; language?: 'json' | 'yaml' | 'toml'; + plainText?: boolean; loadingLabel?: string; parseWarningLabel?: string; ownershipNotice?: ReactNode; @@ -44,6 +45,7 @@ export function RawConfigEditorPanel({ onRefresh, onDiscard, language = 'json', + plainText = false, loadingLabel = 'Loading settings.json...', parseWarningLabel = 'Parse warning', ownershipNotice, @@ -128,6 +130,7 @@ export function RawConfigEditorPanel({ onChange={onChange} language={language} readonly={readOnly} + plainText={plainText} minHeight="100%" heightMode="fill-parent" /> diff --git a/ui/src/components/shared/code-editor.tsx b/ui/src/components/shared/code-editor.tsx index 311e0371..11860fbc 100644 --- a/ui/src/components/shared/code-editor.tsx +++ b/ui/src/components/shared/code-editor.tsx @@ -24,6 +24,7 @@ interface CodeEditorProps { onChange: (value: string) => void; language?: 'json' | 'yaml' | 'toml'; readonly?: boolean; + plainText?: boolean; className?: string; minHeight?: string; heightMode?: 'content' | 'fill-parent'; @@ -95,6 +96,7 @@ export function CodeEditor({ onChange, language = 'json', readonly = false, + plainText = false, className, minHeight = '300px', heightMode = 'content', @@ -211,40 +213,67 @@ export function CodeEditor({ className={cn(isFillParent && 'scrollbar-editor min-h-0 flex-1 overflow-auto')} data-slot={isFillParent ? 'code-editor-viewport' : undefined} > - {} : onChange} - highlight={highlightCode} - key={isDark ? 'dark-editor' : 'light-editor'} - padding={12} - disabled={readonly} - onFocus={() => setIsFocused(true)} - onBlur={() => setIsFocused(false)} - textareaClassName={cn( - 'focus:outline-none font-mono text-sm', - readonly && 'cursor-not-allowed' - )} - preClassName="font-mono text-sm" - style={{ - fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace', - fontSize: '0.875rem', - minHeight, - }} - /> + {plainText ? ( +