Skip to content

Commit 17ab8b5

Browse files
authored
Merge pull request #234 from easyops-cn/steve/ai-portal-720
fix(): refine node size
2 parents 361eda0 + add66f0 commit 17ab8b5

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

bricks/ai-portal/src/cruise-canvas/CmdbInstanceDetail/CmdbInstanceDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function CmdbInstanceDetail({
9191
>
9292
<AsyncWrappedDescriptions
9393
themeVariant="elevo"
94-
column={1}
94+
column={list.length > 6 ? 2 : 1}
9595
dataSource={detail}
9696
list={list}
9797
/>

bricks/ai-portal/src/cruise-canvas/EnhancedMarkdown/EnhancedMarkdown.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export function EnhancedMarkdown(props: MarkdownComponentProps) {
2121
if (el === ref.current) {
2222
break;
2323
}
24-
if (el instanceof HTMLTableElement && el.scrollWidth > el.clientWidth) {
24+
if (
25+
(el instanceof HTMLTableElement || el instanceof HTMLPreElement) &&
26+
el.scrollWidth > el.clientWidth
27+
) {
2528
found = true;
2629
break;
2730
}

bricks/ai-portal/src/cruise-canvas/NodeJob/NodeJob.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function NodeJob({ job, state, active }: NodeJobProps): JSX.Element {
5959
const [toolMarkdownContent, cmdbInstanceDetails, sizeLarge] = useMemo(() => {
6060
const contents: string[] = [];
6161
const instanceDetails: CmdbInstanceDetailData[] = [];
62+
let large = false;
6263
job.messages?.forEach((message) => {
6364
if (message.role === "tool") {
6465
for (const part of message.parts) {
@@ -69,6 +70,14 @@ export function NodeJob({ job, state, active }: NodeJobProps): JSX.Element {
6970
break;
7071
case "cmdb_instance_detail":
7172
instanceDetails.push(part.data as CmdbInstanceDetailData);
73+
if (!large) {
74+
large =
75+
Object.keys(
76+
part.data?.outputSchema?.type === "object"
77+
? part.data.outputSchema.properties
78+
: part.data.detail
79+
).length > 6;
80+
}
7281
break;
7382
}
7483
}
@@ -78,7 +87,7 @@ export function NodeJob({ job, state, active }: NodeJobProps): JSX.Element {
7887

7988
const markdownContent = contents.join("");
8089

81-
const large = RegExpLargeTableInMarkdown.test(markdownContent);
90+
large = large || RegExpLargeTableInMarkdown.test(markdownContent);
8291

8392
return [markdownContent, instanceDetails, large] as const;
8493
}, [job.messages]);
@@ -90,7 +99,7 @@ export function NodeJob({ job, state, active }: NodeJobProps): JSX.Element {
9099
[styles["ask-user"]]: generalAskUser,
91100
[styles["fit-content"]]: hasGraph,
92101
[styles.active]: active,
93-
[styles.large]: sizeLarge,
102+
[styles.large]: sizeLarge || toolName === "llm_answer",
94103
})}
95104
>
96105
<div className={styles.background} />
@@ -180,7 +189,10 @@ export function NodeJob({ job, state, active }: NodeJobProps): JSX.Element {
180189
) : null}
181190
{!generalAskUser && job.toolCall && <ToolCallStatus job={job} />}
182191
{toolMarkdownContent && (
183-
<div className={classNames(styles.message, sharedStyles.markdown)}>
192+
<div
193+
className={classNames(styles.message, sharedStyles.markdown)}
194+
style={{ padding: "0 8px" }}
195+
>
184196
<EnhancedMarkdown content={toolMarkdownContent} />
185197
</div>
186198
)}

bricks/ai-portal/src/cruise-canvas/shared.module.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
pre[class*="language-"] {
9292
padding: 1em;
9393
margin: 0.5em 0;
94-
overflow: auto;
94+
overflow-x: auto;
9595
border-radius: 9px;
9696
}
9797

@@ -270,10 +270,7 @@
270270

271271
.markdown {
272272
table {
273-
display: block;
274273
width: 100%;
275-
width: max-content;
276-
max-width: 100%;
277274
overflow-x: auto;
278275
border-collapse: collapse;
279276
}

0 commit comments

Comments
 (0)