Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(copyable-label): wrap long tool-call params instead of truncating (#14640)

Arvin Xu60a127b1e592
diff --git a/src/components/CopyableLabel/index.tsx b/src/components/CopyableLabel/index.tsx
index 3d6dd931918..36347f8b165 100644
--- a/src/components/CopyableLabel/index.tsx
+++ b/src/components/CopyableLabel/index.tsx
@@ -6,9 +6,42 @@ interface CopyableLabelProps {
className?: string;
style?: CSSProperties;
value?: string | null;
+ wrap?: boolean;
}
-const CopyableLabel = memo<CopyableLabelProps>(({ className, style, value = '--' }) => {
+const CopyableLabel = memo<CopyableLabelProps>(({ className, style, value = '--', wrap }) => {
+ if (wrap) {
+ return (
+ <Flexbox
+ horizontal
+ align={'flex-start'}
+ className={className}
+ gap={4}
+ style={{
+ position: 'relative',
+ width: '100%',
+ ...style,
+ }}
+ >
+ <Text
+ style={{
+ color: 'inherit',
+ flex: 1,
+ fontFamily: 'inherit',
+ fontSize: 'inherit',
+ margin: 0,
+ minWidth: 0,
+ overflowWrap: 'anywhere',
+ whiteSpace: 'pre-wrap',
+ }}
+ >
+ {value || '--'}
+ </Text>
+ <CopyButton content={value || '--'} size={'small'} />
+ </Flexbox>
+ );
+ }
+
return (
<Flexbox
horizontal
diff --git a/src/components/Descriptions/index.tsx b/src/components/Descriptions/index.tsx
index f83949c43ff..561a03bd16e 100644
--- a/src/components/Descriptions/index.tsx
+++ b/src/components/Descriptions/index.tsx
@@ -46,7 +46,7 @@ export interface DescriptionItem {
value: ReactNode;
}
-interface DescriptionsProps extends Omit<GridProps, 'children'> {
+interface DescriptionsProps extends Omit<GridProps, 'children' | 'wrap'> {
bordered?: boolean;
classNames?: {
item?: string;
@@ -60,6 +60,7 @@ interface DescriptionsProps extends Omit<GridProps, 'children'> {
label?: CSSProperties;
value?: CSSProperties;
};
+ wrap?: boolean;
}
const Descriptions = memo<DescriptionsProps>(
@@ -71,6 +72,7 @@ const Descriptions = memo<DescriptionsProps>(
items,
classNames,
styles: customStyles,
+ wrap,
...rest
}) => {
return (
@@ -85,12 +87,12 @@ const Descriptions = memo<DescriptionsProps>(
{items.map((item) => (
<Flexbox
horizontal
- align={'center'}
+ align={wrap ? 'flex-start' : 'center'}
className={cx(bordered && styles.cell, item.className, classNames?.item)}
flex={1}
key={item.key}
style={{
- overflow: 'hidden',
+ overflow: wrap ? undefined : 'hidden',
position: 'relative',
...customStyles?.item,
...item.style,
@@ -122,24 +124,37 @@ const Descriptions = memo<DescriptionsProps>(
</Flexbox>
<Flexbox
horizontal
- align={'center'}
+ align={wrap ? 'flex-start' : 'center'}
flex={1}
justify={'flex-start'}
paddingBlock={bordered ? 12 : 4}
paddingInline={16}
- style={{ height: '100%', overflow: 'hidden', position: 'relative' }}
+ style={{
+ height: '100%',
+ overflow: wrap ? undefined : 'hidden',
+ position: 'relative',
+ }}
>
{item.copyable ? (
<CopyableLabel
className={cx(classNames?.value, item.classNames?.value)}
style={{ ...customStyles?.value, ...item.styles?.value }}
value={item.value ? String(item.value) : '--'}
+ wrap={wrap}
/>
) : (
<Text
- ellipsis
className={cx(classNames?.value, item.classNames?.value)}
- style={{ ...customStyles?.value, ...item.styles?.value }}
+ ellipsis={!wrap}
+ style={{
+ ...(wrap && {
+ overflowWrap: 'anywhere',
+ whiteSpace: 'pre-wrap',
+ wordBreak: 'break-word',
+ }),
+ ...customStyles?.value,
+ ...item.styles?.value,
+ }}
>
{item.value}
</Text>
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Arguments/index.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Arguments/index.tsx
index 60181c78e4c..c609a70f62d 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Arguments/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Arguments/index.tsx
@@ -66,6 +66,7 @@ const Arguments = memo<ArgumentsProps>(({ arguments: args = '', loading, actions
contentNode = (
<Flexbox paddingBlock={4} paddingInline={16}>
<Descriptions
+ wrap
bordered={false}
items={items}
labelWidth={140}