From 08ff46525e3e9aa95f29d780c5624983fb41d8bd Mon Sep 17 00:00:00 2001 From: pphua Date: Tue, 25 Aug 2026 00:28:21 +0800 Subject: [PATCH] fix(ui): limit worker asset badge to domains and IPs --- .../tasks/detail/_tabs/sessions-tab.tsx | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx b/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx index ad385f9..2e313bf 100644 --- a/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx +++ b/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx @@ -430,24 +430,33 @@ function SessionItem({ ); } +function truncateWorkerAssetLabel(value: string, maxChars = 30): string { + const chars = Array.from(value.trim()); + if (chars.length <= maxChars) return chars.join(""); + return `${chars.slice(0, Math.max(0, maxChars - 1)).join("")}…`; +} + function WorkerAssetBadge({ assets }: { assets: IntentAsset[] }) { - const first = assets[0]; - const firstLabel = first.label.trim() ? first.label : `#${first.asset_id}`; + const displayAssets = assets.filter( + (asset) => asset.type === "root_domain" || asset.type === "subdomain" || asset.type === "ip", + ); + if (displayAssets.length === 0) return null; + + const first = displayAssets[0]; + const firstLabel = truncateWorkerAssetLabel(first.label || `#${first.asset_id}`); return ( - + 当前资产:{firstLabel} - {assets.length > 1 && +{assets.length - 1}} + {displayAssets.length > 1 && +{displayAssets.length - 1}}
- {assets.map((asset) => ( + {displayAssets.map((asset) => (
-
- {asset.label.trim() ? asset.label : `#${asset.asset_id}`} -
+
{asset.label || `#${asset.asset_id}`}
{taskAssetTypeLabel(asset.type)} · {taskAssetSourceLabel(asset.source)} {asset.inherited ? ` · 来源任务 #${asset.source_task_id}` : ""}