Skip to content

Commit 8b9a5b0

Browse files
committed
fix(frontend): forward className in Editor noProvider mode and clean up workarounds
The shared Editor dropped `className`/`editorClassName` when rendered with `noProvider` (it only applied the class on the EditorProvider path). Forward it to EditorInner and apply it to the editor container in that mode too. With the prop working, clean up the call sites that relied on the drop: - ChatMessageEditor: move the message text/placeholder alignment from the globals.css workaround to editorClassName; globals.css now only carries the antd role-button override that cannot go through the prop. - VariableControlAdapter: stop forwarding the generation-row container class as editorClassName (it is a container/cell-strip style that would strip the editor's border and gutter); it stays on the container only. - GenerationComparisonChatOutput: pad the editor body via editorClassName instead of the [&_.agenta-editor-wrapper] container hack.
1 parent 5e2ccc6 commit 8b9a5b0

5 files changed

Lines changed: 45 additions & 30 deletions

File tree

web/oss/src/styles/globals.css

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,28 +206,14 @@ body {
206206
}
207207
}
208208

209-
/* Align the message text with the first character of the role label above it,
210-
with the same symmetric horizontal inset on the role, the text, and the
211-
placeholder. The single inset value lives in --ag-message-inline-pad.
212-
213-
Notes:
214-
- The role label is an antd Button whose default padding is wider than the
215-
inset (Tailwind's px-2 on it loses to antd), so it is pinned with !important.
216-
- The text is padded here in CSS rather than via an editor prop because
217-
ChatMessageEditor renders the Editor with `noProvider`, a mode where
218-
`className`/`editorClassName` is currently dropped (known bug, tracked
219-
separately). JSON/code editors are excluded; they have a line-number gutter. */
220-
.agenta-chat-message-editor {
221-
--ag-message-inline-pad: 8px;
222-
}
209+
/* Align the role label's first character with the message text below it.
210+
The message text and placeholder are inset 8px via ChatMessageEditor's
211+
editorClassName prop; this rule pins the role label to the same 8px. The role
212+
label is an antd Button whose default padding is wider than 8px and ignores
213+
Tailwind's px-2, so the override needs !important. Scoped to the message
214+
editor via the .agenta-chat-message-editor marker class. */
223215
.agenta-chat-message-editor .message-user-select {
224-
padding-inline: var(--ag-message-inline-pad) !important;
225-
}
226-
.agenta-chat-message-editor .editor-input:not(.code-only) {
227-
padding-inline: var(--ag-message-inline-pad);
228-
}
229-
.agenta-chat-message-editor .editor-placeholder {
230-
left: var(--ag-message-inline-pad);
216+
padding-inline: 8px !important;
231217
}
232218

233219
/** Align the input search with the search box **/

web/packages/agenta-playground-ui/src/components/ExecutionItemComparisonView/GenerationComparisonChatOutput/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ const GenerationComparisonChatOutputCell = ({
150150
allowFileUpload: true,
151151
}}
152152
messageProps={{
153-
className:
154-
"!p-0 [&_.agenta-editor-wrapper]:!p-3 !mt-0 [&:nth-child(1)]:!mt-0 mt-2",
153+
className: "!p-0 !mt-0 [&:nth-child(1)]:!mt-0 mt-2",
154+
// Editor body padding now goes through the
155+
// editorClassName prop (works after the noProvider
156+
// className fix), replacing the previous
157+
// `[&_.agenta-editor-wrapper]:!p-3` container hack.
155158
editorClassName: "!p-3",
156159
headerClassName:
157160
"min-h-[48px] px-2 border-0 border-b border-solid border-[var(--ag-rgba-051729-06)]",

web/packages/agenta-playground-ui/src/components/adapters/VariableControlAdapter.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,14 @@ const VariableControlAdapter: React.FC<VariableControlAdapterProps> = ({
549549
handleChange={handleChange}
550550
initialValue={effectiveValue}
551551
value={effectiveValue}
552-
editorClassName={className}
552+
// NOTE: the parent's `className` is a container/cell-strip style
553+
// (e.g. `*:!border-none px-3`) and is applied to the container
554+
// below. It must NOT be forwarded to the editor body, where it
555+
// would strip the editor's own border and gutter (see the
556+
// matching note on the code-editor branch above). It was
557+
// previously passed as `editorClassName` but silently dropped by
558+
// the `noProvider` className bug; now that the bug is fixed, the
559+
// forward is removed so it stays a container-only style.
553560
placeholder={effectivePlaceholder}
554561
disabled={isEffectivelyDisabled}
555562
className={clsx(

web/packages/agenta-ui/src/ChatMessage/components/ChatMessageEditor.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,21 @@ const ChatMessageEditorInner: React.FC<ChatMessageEditorProps> = ({
210210
//
211211
// Kaosiso QA 2026-06-02 (also reproduces in production).
212212
disableDebounce
213-
editorClassName={editorClassName}
213+
// Inset the message text and its placeholder by 8px so they line up
214+
// with the role label above. Goes through editorClassName (the proper
215+
// prop) now that the noProvider className bug is fixed. Code editors
216+
// (JSON/tool) keep their own gutter, so they are excluded via
217+
// `:not(.code-only)`. The role label is an antd button outside the
218+
// editor and is aligned via the scoped rule in globals.css.
219+
editorClassName={cn(
220+
"[&_.editor-input:not(.code-only)]:px-2 [&_.editor-placeholder]:left-2",
221+
editorClassName,
222+
)}
214223
placeholder={placeholder}
215224
disabled={disabled}
216225
state={disabled ? "readOnly" : state}
217-
// `agenta-chat-message-editor` is the styling hook used in globals.css
218-
// to align the message text with the role label (see that file). The
219-
// padding can't go through `editorClassName` because ChatMessageEditor
220-
// renders the Editor with `noProvider`, where `className` is dropped.
226+
// `agenta-chat-message-editor` scopes the role-label alignment rule in
227+
// globals.css (the role is an antd button, not part of the editor).
221228
className={cn(
222229
"agenta-chat-message-editor relative",
223230
flexLayouts.column,

web/packages/agenta-ui/src/Editor/Editor.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ const EditorInner = forwardRef<HTMLDivElement, EditorProps>(
173173
disableIndentationPlugin = false,
174174
useNativeCodeNodes = false,
175175
diffExtensionConfig,
176+
className,
176177
...rest
177178
}: EditorProps,
178179
ref,
@@ -755,7 +756,17 @@ const EditorInner = forwardRef<HTMLDivElement, EditorProps>(
755756
}, [codeOnly, editor, effectiveValue, hydrateRichTextFromControlledValue])
756757

757758
return (
758-
<div className="editor-container w-full overflow-hidden relative min-h-[inherit]">
759+
<div
760+
className={clsx(
761+
"editor-container w-full overflow-hidden relative min-h-[inherit]",
762+
// In `noProvider` mode there is no EditorProvider to carry the
763+
// consumer's `className` (it normally lands on
764+
// `.agenta-rich-text-editor`), so apply it to the container here.
765+
// In provider mode EditorInner receives no `className`, so this is
766+
// a no-op and the class still lands on `.agenta-rich-text-editor`.
767+
className,
768+
)}
769+
>
759770
<div
760771
ref={ref}
761772
className={clsx("editor-inner border rounded-lg min-h-[inherit]", {
@@ -1119,6 +1130,7 @@ const Editor = ({
11191130
<EditorInner
11201131
dimensions={dimension}
11211132
id={id}
1133+
className={className}
11221134
customRender={customRender}
11231135
initialValue={initialValue}
11241136
value={value}

0 commit comments

Comments
 (0)