Repository navigation
Fix HITL operator body losing line breaks in the approval form - #74366
Mola-maker wants to merge 4 commits into
Conversation
|
Please provide a before/after screenshot |
|
Thanks for the review! Here are the before/after screenshots, rendered from the actual Before — single line breaks collapse, the multi-line body wraps into one paragraph: After — each line of the body is preserved with (Test body: |
| @@ -195,7 +195,48 @@ const createMarkdownComponents = (style: SyntaxTheme): Components => ({ | |||
| ul: UlComponent, | |||
| }); | |||
|
|
|||
| const ReactMarkdown = ({ children, components: componentOverrides, ...restProps }: Options) => { | |||
| type MdastNode = { | |||
There was a problem hiding this comment.
| type MdastNode = { | |
| type MarkdownNode = { |
Nit. A more readable name here would help.
|
Also let's fix the CI |
|
I just want to hint to my comment on the main issue. If the HITLOperator body actually renders Markdown, then the current behaviour would be correct, wouldn't it? The issue I had in this case then is not realizing, that the body is rendered in Markdown, which is mentioned nowhere on the HITLOperator tutorial. Implementing this PR would therefore break the Markdown support, which is actually mentioned here. |
Good point. Let's update the docs first. |
bbovenzi
left a comment
There was a problem hiding this comment.
Let's update docs before all of this remarkSoftBreaks
|
Can't reproduce on main, #66809 fixed it. Closing as stale we just need to update the doc: |
|
well,ok |
Why
The HITL (human-in-the-loop) approval form renders
hitlDetail.bodyas Markdown viaFlexibleForm'sflexFormDescription. A single\nin the body is a Markdown soft break, which collapses to a space when rendered — so multi-line bodies (e.g. a dry-run result pushed through{{ ti.xcom_pull(...) }}) display as one long line, even though the Rendered Template tab shows them correctly.This PR covers the HITL body part of #74018. The XCom tab part of the same issue is already handled separately by #74112, so this uses
related:rather thancloses:.What changed
src/components/ReactMarkdown.tsxremarkPlugins; they are merged with the built-inremark-gfminstead of being silently overridden (previously a passedremarkPluginsprop was discarded).remarkSoftBreaksthat splits text nodes on single line breaks (\n/\r\n) into explicitbreaknodes, which render as<br />.src/components/FlexibleForm/FlexibleForm.tsxflexFormDescriptionwithremarkSoftBreaksenabled.flexFormDescriptionis only used for the HITL operator body, so Dag docs, notes, param descriptions and all other Markdown rendering are unaffected and keep the previous soft-break behavior.src/components/ReactMarkdown.test.tsx<br>with the plugin enabled, and keep collapsing to a space without it (default behavior unchanged).Verification
pnpm vitest run src/components/FlexibleForm src/components/ReactMarkdown.test.tsx— 7 files / 50 tests pass, including the 2 new tests.tsc --p tsconfig.app.json— clean.related: #74018
Was generative AI tooling used to co-author this PR?
Generated-by: Kimi (Moonshot AI) following the guidelines