Skip to content

Commit 2bc3876

Browse files
committed
fix(frontend): stop role-alignment inset stacking with comparison cell padding
The comparison view renders messages with their own editor padding (!p-3 cells). The role-alignment inset added by ChatMessageEditor stacked on top of that, over-padding the message text, and the assistant output cell also double-padded (the [&_.agenta-editor-wrapper]:!p-3 hack plus editorClassName). Add an alignTextWithRole prop (default true) to ChatMessageEditor; the comparison view passes false so the inset and role pin are skipped there. Remove the leftover wrapper-padding hack so the comparison cells pad the editor once, via editorClassName.
1 parent 28c478f commit 2bc3876

2 files changed

Lines changed: 29 additions & 10 deletions

File tree

  • web/packages
    • agenta-playground-ui/src/components/ExecutionItemComparisonView/GenerationComparisonChatOutput
    • agenta-ui/src/ChatMessage/components

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,14 @@ const GenerationComparisonChatOutputCell = ({
151151
}}
152152
messageProps={{
153153
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
154+
// Comparison cells set their own editor padding via
155+
// editorClassName (works after the noProvider className
156+
// fix), replacing the previous
157157
// `[&_.agenta-editor-wrapper]:!p-3` container hack.
158+
// alignTextWithRole is off so the role-alignment inset
159+
// does not stack on top of this padding.
158160
editorClassName: "!p-3",
161+
alignTextWithRole: false,
159162
headerClassName:
160163
"min-h-[48px] px-2 border-0 border-b border-solid border-[var(--ag-rgba-051729-06)]",
161164
footerClassName: "px-2",
@@ -201,9 +204,14 @@ const GenerationComparisonChatOutputCell = ({
201204
withControls={false}
202205
hideUserMessage
203206
messageProps={{
204-
className:
205-
"!p-0 [&_.agenta-editor-wrapper]:!p-3 !mt-0 [&:nth-child(1)]:!mt-0 mt-2",
207+
// Padding via editorClassName only (the
208+
// [&_.agenta-editor-wrapper]:!p-3 hack is removed so it does
209+
// not double up now that editorClassName works), and
210+
// alignTextWithRole off so the role-alignment inset does not
211+
// stack on top.
212+
className: "!p-0 !mt-0 [&:nth-child(1)]:!mt-0 mt-2",
206213
editorClassName: "!p-3",
214+
alignTextWithRole: false,
207215
headerClassName:
208216
"min-h-[48px] border-0 border-b border-solid border-[var(--ag-rgba-051729-06)]",
209217
footerClassName: "px-2 !m-0",

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ export interface ChatMessageEditorProps {
7474
* up via an internal synchronizer mounted inside the EditorProvider.
7575
*/
7676
markdownView?: boolean
77+
/**
78+
* Inset the message text + placeholder so they line up with the role label
79+
* above (the default tight message layout). Set to false for surfaces that
80+
* apply their own editor padding (e.g. the comparison view's `!p-3` cells),
81+
* where the alignment inset would stack on top and over-pad the text.
82+
* @default true
83+
*/
84+
alignTextWithRole?: boolean
7785
}
7886

7987
/**
@@ -134,6 +142,7 @@ const ChatMessageEditorInner: React.FC<ChatMessageEditorProps> = ({
134142
onFocusChange,
135143
maxPasteChars = DEFAULT_MAX_TEXT_PASTE_CHARS,
136144
onPasteLimitExceeded,
145+
alignTextWithRole = true,
137146
...props
138147
}) => {
139148
const selectOptions = useMemo(
@@ -215,18 +224,20 @@ const ChatMessageEditorInner: React.FC<ChatMessageEditorProps> = ({
215224
// prop) now that the noProvider className bug is fixed. Code editors
216225
// (JSON/tool) keep their own gutter, so they are excluded via
217226
// `:not(.code-only)`. The role label is an antd button outside the
218-
// editor and is aligned via the scoped rule in globals.css.
227+
// editor and is aligned via the `.agenta-chat-message-editor` rule in
228+
// globals.css. Both are skipped when alignTextWithRole is false (e.g.
229+
// the comparison view, which applies its own editor padding).
219230
editorClassName={cn(
220-
"[&_.editor-input:not(.code-only)]:px-2 [&_.editor-placeholder]:left-2",
231+
alignTextWithRole &&
232+
"[&_.editor-input:not(.code-only)]:px-2 [&_.editor-placeholder]:left-2",
221233
editorClassName,
222234
)}
223235
placeholder={placeholder}
224236
disabled={disabled}
225237
state={disabled ? "readOnly" : state}
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).
228238
className={cn(
229-
"agenta-chat-message-editor relative",
239+
alignTextWithRole && "agenta-chat-message-editor",
240+
"relative",
230241
flexLayouts.column,
231242
gapClasses.xs,
232243
"rounded-md",

0 commit comments

Comments
 (0)