Repository navigation
fix: truncate long node names in workflow execution details - #8299
Conversation
| </el-scrollbar> | ||
| </div> | ||
|
|
||
| <!-- 思考过程 --> |
There was a problem hiding this comment.
No syntax/structural issues are obvious in the shown diff. Main points to review:
Potential issues
-
max-height="500"is implicit- Prefer explicit
max-height="500px"or:max-height="500"to avoid relying on Element Plus numeric-string parsing.
- Prefer explicit
-
Multiple independent
el-scrollbarregions- All three sections use
max-height="500", which can create nested/awkward scrolling on one page. Consider a single outer scroll container or collapsible sections if content is long.
- All three sections use
-
Direct text inside
el-scrollbar- This is legal, but wrapping it in a
<div>is clearer:<el-scrollbar max-height="500px" class="-mr-3" view-class="pr-3"> <div class="whitespace-pre-wrap break-words">{{ data.system || '-' }}</div> </el-scrollbar>
- If system prompts contain newlines, add
whitespace-pre-wrapto preserve them.
- This is legal, but wrapping it in a
-
Negative margin + padding scrollbar trick
class="-mr-3"andview-class="pr-3"can cause horizontal overflow or clipping in some layouts, especially RTL or overlay-scrollbar environments. Verify visually; considerscrollbar-gutter: stableor onlypr-3.
-
v-forkey uses index:key="historyIndex"/qIndexcan cause rendering/state issues if lists reorder or update. Prefer a stable ID if available.
-
Inconsistent optional chaining
data.systemis not optional while other places usedata?.. Ifdatacan be undefined, this can throw. Usedata?.system.
-
MkVideoname fallback is missing:src="videoItem.url || videoItem"handles string items, but:name="videoItem.url"does not. Use::name="videoItem.url || videoItem"
Optimization suggestions
- Normalize
image_listandvideo_listinto computed arrays to avoid repeateditem.url || itemexpressions. - Extract the repeated card + scrollbar wrapper into a small component or shared class.
- Avoid creating inline object literals repeatedly, e.g. the
ImageUploadCard :fileobject andgetFileIconUrl('video.mp4'). - Ensure scrollable regions are keyboard accessible; users should not need a mouse wheel to reach hidden content.
- Simplify
length > 0checks to justdata.history_message?.lengthif only truthiness matters, though the current form is fine.
| </el-scrollbar> | ||
| </div> | ||
|
|
||
| <!-- 思考过程 --> |
There was a problem hiding this comment.
Review of the Diff
Overall the change is straightforward (wrapping two blocks in el-scrollbar), but there are several correctness risks, inconsistencies, and maintainability concerns.
1. Bugs / Potential Runtime Issues
a) :name is not normalized like :src (video branch)
<MkVideo :src="videoItem.url || videoItem" :name="videoItem.url" ... />
<span>{{ videoItem.url || videoItem }}</span>If videoItem is a plain string (which the || videoItem fallback implies is a supported shape), videoItem.url is undefined, so MkVideo receives no name. Use the same fallback:
:name="videoItem.url || videoItem"Same pattern should be extracted once instead of repeated three times (see §4).
b) max-height="500" without a unit
Element Plus runs maxHeight through addUnit, so a number usually becomes 500px, but this depends on the version. Prefer an explicit unit to be safe and self-documenting:
<el-scrollbar max-height="500px" ...>c) Fragile coupling of -mr-3 / view-class="pr-3" to the card's padding
This only lines up if .mk-gray-card-sm uses exactly padding-right: 0.75rem. If the card class changes, the scrollbar will visibly overlap or be inset. Either (a) drop the negative margin and let the gutter sit inside the padding, or (b) drive both from a shared token/class rather than two magic Tailwind values.
d) Long/unbroken content in the system prompt
<el-scrollbar ...>
{{ data.system || '-' }}
</el-scrollbar>.el-scrollbar__wrap has overflow: auto, so a long URL/token or multi-line prompt will either produce an ugly horizontal scrollbar or be clipped. Add wrapping:
<div class="whitespace-pre-wrap break-words">{{ data.system || '-' }}</div>(You also lose an explicit wrapper element elsewhere — text directly in the slot is fine, but a <div> gives you a styling hook and keeps parity with the original markup.)
e) Nested scroll containers / scroll chaining
Two independent 500px scroll regions inside what is likely an already-scrollable drawer/dialog creates bad UX on touch devices (scroll chaining) and double scrollbars. Consider:
- a single scrollbar for the whole panel, or
overscroll-behavior: containon the scroll views, andmax-heightin relative units (50vh,%, or flexmin-height: 0) instead of a fixed500px.
f) Keyboard accessibility
The scroll region content is not focusable by default, so keyboard-only users may be unable to scroll it. Verify el-scrollbar's wrap node has tabindex="0" (or add it), and give the region an aria-label/role="region".
2. Minor Issues
v-if="data?.image_list?.length > 0"— works (undefined > 0 === false), butdata?.image_list?.lengthalone is clearer; if you want an explicit comparison use(data?.image_list?.length ?? 0) > 0.:key="qIndex"— index keys are acceptable for a static, non-reordering list, butqIndexis a misleading name for both the image and video loops; rename toimgIndex/videoIndex, and prefer a stable id if items have one.:preview-src-list="[imageItem.url || imageItem]"— only the clicked image is in the preview list, so users can't page through the gallery. Consider passing the full normalized list.:size="58"magic number — extract to a named constant or component prop.- The diff also drops a blank line before
<MdPreview>; harmless, but keep whitespace changes out of a behavioural diff to ease review.
3. Performance
MdPreviewrenders the entire markdown inside the scroll container; large content with many images will still fully render. If long histories are expected, consider lazy rendering or virtualization.- The two
el-scrollbars are cheap, but if this panel is re-rendered frequently, hoisting the media normalization into acomputedavoids re-evaluatingitem.url || itemin the template on every render.
4. Refactor Suggestions
Normalize media items once (types are clearly string | { url: string }):
type MediaItem = string | { url: string }
const toSrc = (item: MediaItem) => (typeof item === 'string' ? item : item.url)
const images = computed(() => (data.image_list ?? []).map(toSrc))
const videos = computed(() => (data.video_list ?? []).map(toSrc))Then the template becomes v-for="(src, i) in images" :key="src + i" and there are no repeated url || item expressions to drift out of sync.
Extract the repeated scroll shell:
Both blocks use the identical max-height / -mr-3 / view-class="pr-3" combination. Wrap it in a small local component (e.g. <ScrollCard>) so the magic numbers live in one place.
Or use a single scroll region for the whole "details" card and drop the per-section fixed heights — simpler layout, no nesting, and it adapts to the drawer height.
Suggested corrected snippet (system prompt block)
<div class="mk-gray-card-sm overflow-hidden">
<h6 class="mb-2">{{ t('workflow.systemPrompt.label') }}</h6>
<el-scrollbar max-height="500px" class="overscroll-contain" view-class="pr-3">
<div class="whitespace-pre-wrap break-words">{{ data.system || '-' }}</div>
</el-scrollbar>
</div>...and in the video loop:
<MkVideo :src="toSrc(videoItem)" :name="toSrc(videoItem)" class="w-60 max-w-full">
...
<span class="min-w-0 truncate">{{ toSrc(videoItem) }}</span>
</MkVideo>| </el-scrollbar> | ||
| </div> | ||
| <!-- 结束原因 --> | ||
| <div class="mk-gray-card-sm"> |
There was a problem hiding this comment.
Code Review
1. Type-safety issue with data.message_list?.length > 0
<template v-if="data.message_list?.length > 0">With strictNullChecks, data.message_list?.length is typed number | undefined, which TypeScript rejects when compared with >. Safer:
<template v-if="(data.message_list?.length ?? 0) > 0">
<!-- or -->
<template v-if="data.message_list?.length">2. :key="messageIndex" — index used as key
Index keys break identity when the list is prepended/reordered (and cause avoidable re-renders). Use a stable id if the API provides one (message.id), or at minimum combine role+index.
3. Message content is not guaranteed to be a string
Newer LLM APIs return content as an array of parts ([{type:'text'}, {type:'image_url'}]). {{ message.content }} would render [object Object]. Normalize it:
const textOf = (c: unknown) => typeof c === 'string' ? c : JSON.stringify(c, null, 2)4. Long unbroken strings overflow horizontally
whitespace-pre-wrap preserves newlines but does not break long tokens (URLs, JSON, base64). Add:
<p class="whitespace-pre-wrap break-words [overflow-wrap:anywhere] ...">5. data.system || '-' treats falsy values too broadly
|| also swallows 0, false, whitespace-only strings. Prefer data.system?.trim() || '-' if you want "blank means empty", or ?? '-' if only null/undefined should fall back.
Also note the system/user prompt blocks lost the whitespace-pre-wrap behavior the context block has (plain <div>/text in scrollbar collapses multi-line prompts). Add it for consistency:
<el-scrollbar max-height="500" ...>
<div class="whitespace-pre-wrap">{{ data.system || '-' }}</div>
</el-scrollbar>6. Repeated markup — DRY
Three identical el-scrollbar max-height="500" class="-mr-3" view-class="pr-3" wrappers. Extract one component or drive it from a config:
<ScrollBox>…</ScrollBox>
<!-- or -->
<el-scrollbar v-for="s in sections" :key="s.key" max-height="500" ...>7. Magic number 500 duplicated
Move to a single constant / CSS var / prop so the three panels can't drift:
const SCROLL_MAX_H = 500 // or 'var(--mk-scroll-max-h)'Fixed 500px × 3 cards = up to 1500px of content; consider a smaller default and/or a "show more" collapse toggle.
8. Negative-margin + view-padding hack is fragile
class="-mr-3" + view-class="pr-3" cancels the scrollbar gutter. This relies on the card's padding value (p-3 = 12px). If the card padding changes, the layout breaks. Prefer one of:
- put padding on the inner view only, no negative margin;
- style the scrollbar via CSS (
--el-scrollbar-*/ scoped class) instead of utility hacks. Note-mr-3on the root also shifts the hover/hit area of the scrollbar track outward, which can look off.
9. Element Plus API/version check
view-class / view-style / wrap-class exist only in newer Element Plus builds. Confirm the installed version supports view-class; otherwise the padding silently does nothing (the class ends up unwrapped). Also max-height accepts string | number — "500" is fine because addUnit adds px, but passing 500 (number) or '500px' is clearer.
10. Scrollbar sizing inside hidden containers
el-scrollbar measures via ResizeObserver. If this detail view is mounted inside a hidden tab/drawer/dialog and shown later, the thumb may be missing until a resize. If so, keep a ref and call scrollbarRef.update() when the panel becomes visible, or use :native="true" for these simple read-only blocks (cheaper, no wrapper/resize observer — usually the better choice here).
11. No auto-scroll for streaming content
If data.message_list / prompts update while streaming, the scrollbar stays at the old offset. Consider watching length and calling setScrollTop(Infinity) (with nextTick), or only do so when the user was already at the bottom.
12. Print / export / copy
Content inside a max-height scroll container is clipped when printed or serialized by DOM-to-image. If this panel supports "copy raw" or "export screenshot/PDF", read from data rather than the DOM, and add @media print { .el-scrollbar__wrap { max-height:none !important; overflow: visible !important } }.
13. Minor / nitpicks
commentchanged from消息列表→上下文; make sureworkflow.llm.context.labelwording matches (it does — good), and update the corresponding i18n keys if the original ones only said "messages".el-scrollbaron a single short string ('-') still renders a wrapper + resize observer for nothing. Acceptable, but combined with the DRY refactor worth noting.pelements insidespace-y-2with leading/trailing whitespace from the pre-wrap text node may render odd gap; consider wrapping text in a<div>and trimming.- If the surrounding file has a
formatJsonhelper (visible at the top of the hunk), the messages' content could be piped through it when it's object-like — currently that helper appears unused by this block. - Role label
{{ message.role }}is user-controlled by the backend; fine for escaping, but capitalize/normalize display (e.g.,role.toUpperCase()) for consistency with the rest of the UI.
Suggested minimal fix
<el-scrollbar
v-for="section in promptSections"
:key="section.key"
max-height="500"
:native="true"
class="mk-scroll"
>
<div class="whitespace-pre-wrap break-words">{{ section.text || '-' }}</div>
</el-scrollbar>
fix: truncate long node names in workflow execution details