🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(acceptance): improve flow readability and add fullscreen viewing (#19304)
Arvin Xu835379ec993c
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 4fb31c12d0c..b63984f2f79 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -1610,17 +1610,17 @@"taskDetail.acceptance.detailTitle": "Check details","taskDetail.acceptance.expandAll": "Expand all groups","taskDetail.acceptance.goal": "Acceptance goal",- "taskDetail.acceptance.loadError": "Could not load delivery acceptance.",+ "taskDetail.acceptance.loadError": "Could not load Acceptance.","taskDetail.acceptance.multimodalLlm": "Multimodal LLM","taskDetail.acceptance.openReport": "Acceptance report","taskDetail.acceptance.remove": "Remove acceptance","taskDetail.acceptance.removeConfirm.content": "This removes the task's acceptance goal, checklist, and recorded acceptance results. Task artifacts are unaffected.","taskDetail.acceptance.removeConfirm.ok": "Remove",- "taskDetail.acceptance.removeConfirm.title": "Remove delivery acceptance?",+ "taskDetail.acceptance.removeConfirm.title": "Remove Acceptance?","taskDetail.acceptance.requiredEvidence": "Required evidence","taskDetail.acceptance.retry": "Retry","taskDetail.acceptance.reviewError": "Could not save this review.",- "taskDetail.acceptance.title": "Delivery acceptance",+ "taskDetail.acceptance.title": "Acceptance","taskDetail.acceptance.verifier": "Verification method","taskDetail.acceptanceState.accepted": "Accepted","taskDetail.acceptanceState.awaitingDecision": "Not passed — your call",@@ -1628,7 +1628,7 @@"taskDetail.acceptanceState.awaitingVerification": "Awaiting verification","taskDetail.acceptanceState.closed": "Closed","taskDetail.acceptanceState.errored": "Verification errored",- "taskDetail.acceptanceState.hint": "Delivery acceptance — click to review",+ "taskDetail.acceptanceState.hint": "Acceptance — click to review","taskDetail.acceptanceState.rejected": "Sent back","taskDetail.acceptanceState.repairing": "Repairing","taskDetail.acceptanceState.verifying": "Verifying",@@ -2137,7 +2137,7 @@"verifyConfig.edit": "Edit","verifyConfig.empty.materializeHint": "This requirement is already in effect. You can break it down further into a structured, item-by-item checklist.","verifyConfig.empty.subtitle": "Describe how you want to accept the result in one sentence, and AI will turn it into an editable checklist.",- "verifyConfig.empty.title": "Delivery Acceptance",+ "verifyConfig.empty.title": "Acceptance","verifyConfig.enable": "Enable acceptance check","verifyConfig.fromTemplate": "Pick from template","verifyConfig.generate": "Generate acceptance plan",diff --git a/locales/en-US/labs.json b/locales/en-US/labs.jsonindex 81119477f40..36f985c67e9 100644--- a/locales/en-US/labs.json+++ b/locales/en-US/labs.json@@ -34,8 +34,8 @@"features.projects.title": "Project Workspaces","features.selfLearning.desc": "Show what each agent has learned from real practice — its rule base, which rules actually get used, and which layers are still blank.","features.selfLearning.title": "Self-evolving",- "features.taskVerify.desc": "Add a delivery-acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.",- "features.taskVerify.title": "Task Delivery Acceptance",+ "features.taskVerify.desc": "Add an Acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.",+ "features.taskVerify.title": "Acceptance","features.topicAcceptance.desc": "Author a delivery checklist for the current topic right above the composer, so the conversation is held to standards you can edit any time.","features.topicAcceptance.title": "Topic Acceptance","group.desktop": "Desktop",diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 442af502054..725a847408f 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -66,7 +66,7 @@"acceptance.checks.emptyFilter.needsFix": "No checks marked for fixing","acceptance.checks.emptyFilter.pending": "No checks left to review","acceptance.checks.finalRoundHint": "The final result and evidence come from this round — click to locate it.",- "acceptance.checks.holisticTitle": "Task delivery acceptance",+ "acceptance.checks.holisticTitle": "Acceptance","acceptance.checks.introduced": "Added in round {{round}}","acceptance.checks.introducedHint": "This check first appeared in that round — click to locate it.","acceptance.checks.iterated": "Iterated {{count}}×",@@ -226,7 +226,7 @@"acceptance.sharedNotice.title": "Shared with you","acceptance.sharedNotice.titleWithName": "Shared by {{name}}","acceptance.shell.back": "Back",- "acceptance.shell.menu": "Show deliveries",+ "acceptance.shell.menu": "Show Acceptance menu","acceptance.stats.failed": "{{count}} failed","acceptance.stats.notExecuted": "{{count}} not executed","acceptance.stats.passed": "{{count}} passed",@@ -248,7 +248,7 @@"acceptance.surface.other": "Other","acceptance.tabs.checks": "Checklist","acceptance.tabs.resources": "Files",- "acceptance.titleFallback": "Delivery acceptance",+ "acceptance.titleFallback": "Acceptance","acceptance.tray.addCheck": "Add tracking item","acceptance.tray.editModal.addTitle": "Add tracking item","acceptance.tray.editModal.editTitle": "Edit tracking item",@@ -306,7 +306,7 @@"acceptance.workspace.deleteConfirmTitle": "Delete acceptance","acceptance.workspace.deleteError": "Failed to delete acceptance","acceptance.workspace.deleteSuccess": "Acceptance deleted",- "acceptance.workspace.emptyDetail.description": "Open the deliveries menu to pick a record and inspect its checks, rounds and evidence.",+ "acceptance.workspace.emptyDetail.description": "Open the Acceptance menu to pick a record and inspect its checks, rounds and evidence.","acceptance.workspace.emptyDetail.title": "Select an acceptance","acceptance.workspace.filters.active": "In progress","acceptance.workspace.filters.all": "All acceptances",@@ -384,7 +384,7 @@"acceptance.workspace.searchScope": "Searched the {{count}} loaded acceptance(s).","acceptance.workspace.statusError": "Failed to update status","acceptance.workspace.statusSuccess": "Status updated",- "acceptance.workspace.title": "Deliveries",+ "acceptance.workspace.title": "Acceptance","actions.backToApp": "Back to {{name}}","actions.cancel": "Cancel","actions.delete": "Delete",@@ -489,9 +489,11 @@"flow.empty": "The agent will publish the verification flow here before running checks.","flow.enterGroup": "Open {{title}}","flow.evidence": "View evidence",+ "flow.exitFullscreen": "Exit full screen","flow.expandAll": "Expand all","flow.expandGroup": "Expand {{title}}","flow.expected": "Expected behavior",+ "flow.fullscreen": "Full screen","flow.graphView": "Graph","flow.groupProgress": "{{passed}} / {{total}} verified","flow.groupReviewed": "{{count}} accepted",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex 4b1f2d59e5b..1048d9a4d17 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -489,9 +489,11 @@"flow.empty": "Agent 将在开始验证前在这里发布验收流程。","flow.enterGroup": "进入{{title}}","flow.evidence": "查看证据",+ "flow.exitFullscreen": "退出全屏","flow.expandAll": "全部展开","flow.expandGroup": "展开{{title}}","flow.expected": "预期表现",+ "flow.fullscreen": "全屏查看","flow.graphView": "关系图","flow.groupProgress": "{{passed}} / {{total}} 项验证通过","flow.groupReviewed": "{{count}} 项已验收",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 03bc7336ad1..2201c2f441b 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1533,18 +1533,18 @@ export default {'taskDetail.acceptance.collapseAll': 'Collapse all groups','taskDetail.acceptance.expandAll': 'Expand all groups','taskDetail.acceptance.goal': 'Acceptance goal',- 'taskDetail.acceptance.loadError': 'Could not load delivery acceptance.',+ 'taskDetail.acceptance.loadError': 'Could not load Acceptance.','taskDetail.acceptance.multimodalLlm': 'Multimodal LLM','taskDetail.acceptance.openReport': 'Acceptance report','taskDetail.acceptance.remove': 'Remove acceptance','taskDetail.acceptance.removeConfirm.content':"This removes the task's acceptance goal, checklist, and recorded acceptance results. Task artifacts are unaffected.",'taskDetail.acceptance.removeConfirm.ok': 'Remove',- 'taskDetail.acceptance.removeConfirm.title': 'Remove delivery acceptance?',+ 'taskDetail.acceptance.removeConfirm.title': 'Remove Acceptance?','taskDetail.acceptance.retry': 'Retry','taskDetail.acceptance.requiredEvidence': 'Required evidence','taskDetail.acceptance.reviewError': 'Could not save this review.',- 'taskDetail.acceptance.title': 'Delivery acceptance',+ 'taskDetail.acceptance.title': 'Acceptance','taskDetail.acceptance.verifier': 'Verification method','taskDetail.acceptanceState.accepted': 'Accepted','taskDetail.acceptanceState.awaitingDecision': 'Not passed — your call',@@ -1552,7 +1552,7 @@ export default {'taskDetail.acceptanceState.awaitingVerification': 'Awaiting verification','taskDetail.acceptanceState.closed': 'Closed','taskDetail.acceptanceState.errored': 'Verification errored',- 'taskDetail.acceptanceState.hint': 'Delivery acceptance — click to review',+ 'taskDetail.acceptanceState.hint': 'Acceptance — click to review','taskDetail.acceptanceState.rejected': 'Sent back','taskDetail.acceptanceState.repairing': 'Repairing','taskDetail.acceptanceState.verifying': 'Verifying',@@ -2888,7 +2888,7 @@ export default {'verifyConfig.edit': 'Edit','verifyConfig.empty.materializeHint':'This requirement is already in effect. You can break it down further into a structured, item-by-item checklist.',- 'verifyConfig.empty.title': 'Delivery Acceptance',+ 'verifyConfig.empty.title': 'Acceptance','verifyConfig.empty.subtitle':'Describe how you want to accept the result in one sentence, and AI will turn it into an editable checklist.','verifyConfig.enable': 'Enable acceptance check',diff --git a/packages/locales/src/default/labs.ts b/packages/locales/src/default/labs.tsindex dfc0fac4e78..2f476f8cd54 100644--- a/packages/locales/src/default/labs.ts+++ b/packages/locales/src/default/labs.ts@@ -49,8 +49,8 @@ export default {'Organize long-running goals into dedicated workspaces with their own agents, knowledge bases, and tasks.','features.projects.title': 'Project Workspaces','features.taskVerify.desc':- 'Add a delivery-acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.',- 'features.taskVerify.title': 'Task Delivery Acceptance',+ 'Add an Acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.',+ 'features.taskVerify.title': 'Acceptance','features.selfLearning.desc':'Show what each agent has learned from real practice — its rule base, which rules actually get used, and which layers are still blank.','features.selfLearning.title': 'Self-evolving',diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex 8de4cbf112c..65ae80f9715 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -33,6 +33,8 @@ export default {'flow.groupProgress': '{{passed}} / {{total}} verified','flow.groupReviewed': '{{count}} accepted','flow.allGroups': 'All flows',+ 'flow.fullscreen': 'Full screen',+ 'flow.exitFullscreen': 'Exit full screen','flow.expandAll': 'Expand all','flow.collapseAll': 'Collapse all','flow.diff.required': 'Required',@@ -159,7 +161,7 @@ export default {'acceptance.checks.viewTrace': 'View verification run','acceptance.checks.finalRoundHint':'The final result and evidence come from this round — click to locate it.',- 'acceptance.checks.holisticTitle': 'Task delivery acceptance',+ 'acceptance.checks.holisticTitle': 'Acceptance','acceptance.checks.introduced': 'Added in round {{round}}','acceptance.checks.introducedHint':'This check first appeared in that round — click to locate it.',@@ -361,7 +363,7 @@ export default {'acceptance.status.repairing': 'Repair in progress','acceptance.status.verifying': 'Verification in progress','acceptance.shell.back': 'Back',- 'acceptance.shell.menu': 'Show deliveries',+ 'acceptance.shell.menu': 'Show Acceptance menu','acceptance.resources.empty': 'No files yet — rounds attach their evidence here.','acceptance.tabs.checks': 'Checklist','acceptance.tabs.resources': 'Files',@@ -398,7 +400,7 @@ export default {'acceptance.tray.trackCount': '· {{count}} tracked','acceptance.tray.trackSection': 'Tracking','acceptance.surface.other': 'Other',- 'acceptance.titleFallback': 'Delivery acceptance',+ 'acceptance.titleFallback': 'Acceptance','acceptance.verdict.inProgress': 'Acceptance in progress','acceptance.verdict.latestAt': 'last verified {{time}}','acceptance.viewFullReport': 'View full report',@@ -435,7 +437,7 @@ export default {'acceptance.workspace.deleteError': 'Failed to delete acceptance','acceptance.workspace.deleteSuccess': 'Acceptance deleted','acceptance.workspace.emptyDetail.description':- 'Open the deliveries menu to pick a record and inspect its checks, rounds and evidence.',+ 'Open the Acceptance menu to pick a record and inspect its checks, rounds and evidence.','acceptance.workspace.emptyDetail.title': 'Select an acceptance','acceptance.workspace.filters.active': 'In progress','acceptance.workspace.filters.all': 'All acceptances',@@ -525,7 +527,7 @@ export default {'acceptance.workspace.renameSuccess': 'Renamed','acceptance.workspace.statusError': 'Failed to update status','acceptance.workspace.statusSuccess': 'Status updated',- 'acceptance.workspace.title': 'Deliveries',+ 'acceptance.workspace.title': 'Acceptance','actions.backToApp': 'Back to {{name}}','actions.goToApp': 'Go to {{name}}','meta.description': 'Verification runs, delivery reports, and acceptance reviews.',diff --git a/src/features/Acceptance/Viewer/Flow/AcceptanceFlow.tsx b/src/features/Acceptance/Viewer/Flow/AcceptanceFlow.tsxindex 394c794f92e..eb91eebf89e 100644--- a/src/features/Acceptance/Viewer/Flow/AcceptanceFlow.tsx+++ b/src/features/Acceptance/Viewer/Flow/AcceptanceFlow.tsx@@ -2,11 +2,12 @@import '@xyflow/react/dist/style.css';-import { Empty, Flexbox } from '@lobehub/ui';-import { Button, Select, Text } from '@lobehub/ui/base-ui';+import { Empty, Flexbox, useAppElement } from '@lobehub/ui';+import { ActionIcon, Button, Select, Text } from '@lobehub/ui/base-ui';import { MarkerType, ReactFlowProvider } from '@xyflow/react';import { createStaticStyles, cssVar, useResponsive } from 'antd-style';-import { use, useState } from 'react';+import { Maximize2, Minimize2 } from 'lucide-react';+import { use, useEffect, useRef, useState } from 'react';import { createPortal } from 'react-dom';import { useTranslation } from 'react-i18next';@@ -24,6 +25,34 @@ import { FlowPanelHostContext } from './FlowPanelHost';import { FlowResults } from './FlowResults';const styles = createStaticStyles(({ css }) => ({+ fullscreen: css`+ position: fixed;+ z-index: ${cssVar.zIndexPopupBase};+ inset: 0;++ padding: 16px;++ background: ${cssVar.colorBgContainer};+ `,+ details: css`+ overflow: auto;+ flex: none;+ width: min(400px, 45vw);+ min-height: 0;++ @media (width <= 640px) {+ width: 100%;+ height: 40%;+ }+ `,+ workspace: css`+ min-width: 0;+ min-height: 0;++ @media (width <= 640px) {+ flex-direction: column;+ }+ `,toolbar: css`width: 100%;max-width: ${acceptanceContentLayout.maxWidth - 2 * acceptanceContentLayout.paddingInline}px;@@ -34,12 +63,28 @@ const nodeTypes = { state: FlowNode, flowGroup: FlowGroup };export function AcceptanceFlow() {const { t } = useTranslation('verify');+ const appElement = useAppElement();const panelHost = use(FlowPanelHostContext);const { md = true } = useResponsive();const [display, setDisplay] = useState<'graph' | 'outline'>();const showOutline = (display ?? (md ? 'graph' : 'outline')) === 'outline';const { acceptanceId } = useAcceptanceScope();const { data, mutate } = useAcceptanceBundle(acceptanceId);+ const [fullscreen, setFullscreen] = useState(false);+ const fullscreenButton = useRef<HTMLButtonElement>(null);+ useEffect(() => {+ if (!fullscreen) return;+ const focusToggle = () => fullscreenButton.current?.focus();+ focusToggle();+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key === 'Escape' && !event.defaultPrevented) setFullscreen(false);+ };+ window.addEventListener('keydown', onKeyDown);+ return () => {+ window.removeEventListener('keydown', onKeyDown);+ requestAnimationFrame(focusToggle);+ };+ }, [fullscreen]);const [roundKey, setRoundKey] = useState<string>();const [selected, setSelected] = useState<string>();const [focus, setFocus] = useState<string>();@@ -104,8 +149,26 @@ export function AcceptanceFlow() {strokeWidth: edge.id === selected ? 2 : 1.5,},}));- return (- <Flexbox gap={16}>+ const results = checkSelection ? (+ <FlowResults+ acceptanceId={acceptanceId!}+ attempts={attempts}+ edges={checkSelection.view.version.edges}+ key={`${checkSelection.view.id}:${selected}`}+ node={checkSelection.node}+ selectedEdge={edgeSelection?.edge}+ canReview={Boolean(+ data?.canReview &&+ checkSelection.view.roundIndex != null &&+ checkSelection.view.roundIndex ===+ Math.max(...(data?.rounds.map((r) => r.run.roundIndex ?? 0) ?? [0])),+ )}+ onClose={() => setSelected(undefined)}+ onSaved={mutate}+ />+ ) : null;+ const content = (+ <Flexbox className={fullscreen ? styles.fullscreen : undefined} gap={16}><Flexboxhorizontalalign="center"@@ -127,7 +190,7 @@ export function AcceptanceFlow() {</Flexbox>))}</Flexbox>- <Flexbox horizontal align="center" gap={8}>+ <Flexbox horizontal align="center" gap={8} wrap="wrap"><AcceptancePlanReview runId={candidates[0]?.run?.verifyRunId} /><Buttonsize="small"@@ -153,42 +216,40 @@ export function AcceptanceFlow() {setSelected(undefined);}}/>+ <ActionIcon+ aria-label={t(fullscreen ? 'flow.exitFullscreen' : 'flow.fullscreen')}+ icon={fullscreen ? Minimize2 : Maximize2}+ ref={fullscreenButton}+ title={t(fullscreen ? 'flow.exitFullscreen' : 'flow.fullscreen')}+ onClick={() => setFullscreen((value) => !value)}+ /></Flexbox></Flexbox>- {showOutline ? (- <FlowOutline edges={graphEdges} nodes={graph.nodes} onSelect={setSelected} />- ) : (- <ReactFlowProvider key={activeKey}>- <FlowCanvas- edges={graphEdges}- nodeTypes={nodeTypes}- nodes={graph.nodes}- viewKey={focus ?? activeKey}- onSelect={setSelected}- />- </ReactFlowProvider>- )}- {checkSelection &&- panelHost &&- createPortal(- <FlowResults- acceptanceId={acceptanceId!}- attempts={attempts}- edges={checkSelection.view.version.edges}- key={`${checkSelection.view.id}:${selected}`}- node={checkSelection.node}- selectedEdge={edgeSelection?.edge}- canReview={Boolean(- data?.canReview &&- checkSelection.view.roundIndex != null &&- checkSelection.view.roundIndex ===- Math.max(...(data?.rounds.map((r) => r.run.roundIndex ?? 0) ?? [0])),- )}- onClose={() => setSelected(undefined)}- onSaved={mutate}- />,- panelHost,+ <Flexbox horizontal className={styles.workspace} flex={fullscreen ? 1 : undefined}>+ {showOutline ? (+ <Flexbox flex={1} style={{ minWidth: 0, overflow: 'auto' }}>+ <FlowOutline edges={graphEdges} nodes={graph.nodes} onSelect={setSelected} />+ </Flexbox>+ ) : (+ <ReactFlowProvider key={activeKey}>+ <FlowCanvas+ edges={graphEdges}+ fullscreen={fullscreen}+ nodeTypes={nodeTypes}+ nodes={graph.nodes}+ viewKey={focus ?? activeKey}+ onSelect={setSelected}+ />+ </ReactFlowProvider>)}+ {results &&+ (fullscreen ? (+ <Flexbox className={styles.details}>{results}</Flexbox>+ ) : (+ panelHost && createPortal(results, panelHost)+ ))}+ </Flexbox></Flexbox>);+ return fullscreen ? createPortal(content, appElement ?? document.body) : content;}diff --git a/src/features/Acceptance/Viewer/Flow/FlowCanvas.tsx b/src/features/Acceptance/Viewer/Flow/FlowCanvas.tsxindex c119f6e0c94..6085ff03abd 100644--- a/src/features/Acceptance/Viewer/Flow/FlowCanvas.tsx+++ b/src/features/Acceptance/Viewer/Flow/FlowCanvas.tsx@@ -20,14 +20,14 @@ import type { FlowGraphData } from './flowGraph';const edgeTypes = { transition: FlowEdge };-const fitOptions = { maxZoom: 1, padding: 0.08 };+const fitOptions = { maxZoom: 1, minZoom: 0.65, padding: 0.08 };const styles = createStaticStyles(({ css }) => ({canvas: css`overflow: hidden;flex: none;width: 100%;- min-width: 320px;+ min-width: 0;height: clamp(520px, calc(100dvh - 400px), 900px);border-radius: ${cssVar.borderRadiusLG};@@ -46,12 +46,14 @@ const styles = createStaticStyles(({ css }) => ({}));export function FlowCanvas({+ fullscreen = false,nodes,edges,nodeTypes,onSelect,viewKey,}: {+ fullscreen?: boolean;nodes: Node<FlowGraphData>[];edges: Edge[];nodeTypes: NodeTypes;@@ -84,9 +86,13 @@ export function FlowCanvas({height: container?.clientHeight ?? 0,});};- }, [viewKey, fitView, getViewport, setViewport, viewports]);+ }, [viewKey, fullscreen, fitView, getViewport, setViewport, viewports]);return (- <Flexbox className={styles.canvas} ref={ref}>+ <Flexbox+ className={styles.canvas}+ ref={ref}+ style={fullscreen ? { flex: 1, height: '100%', minHeight: 0 } : undefined}+ ><ReactFlowfitViewpanOnDragdiff --git a/src/features/Acceptance/Viewer/Flow/FlowEdge.tsx b/src/features/Acceptance/Viewer/Flow/FlowEdge.tsxindex de4bea47ed4..3ba62a0d26d 100644--- a/src/features/Acceptance/Viewer/Flow/FlowEdge.tsx+++ b/src/features/Acceptance/Viewer/Flow/FlowEdge.tsx@@ -1,16 +1,25 @@import { Button } from '@lobehub/ui/base-ui';import type { Edge, EdgeProps } from '@xyflow/react';-import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath, useViewport } from '@xyflow/react';+import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath } from '@xyflow/react';import { createStaticStyles, cssVar, cx } from 'antd-style';+import { getFlowEdgeLabelLayout } from './flowEdgeLabel';+const styles = createStaticStyles(({ css }) => ({label: css`pointer-events: all;position: absolute;+ overflow: hidden;+ display: -webkit-box;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 2;++ max-width: 180px;height: auto;min-height: 0;+ max-height: 42px;padding-block: 3px;padding-inline: 2px;border-radius: 4px;@@ -18,6 +27,7 @@ const styles = createStaticStyles(({ css }) => ({font-size: 12px;line-height: 18px;color: ${cssVar.colorTextSecondary};+ overflow-wrap: anywhere;white-space: normal;background: ${cssVar.colorBgContainer};@@ -26,9 +36,8 @@ const styles = createStaticStyles(({ css }) => ({type TransitionEdge = Edge<{ onSelect: (id: string) => void; laneOffset?: number }>;-/** Keep branch labels readable when the map fits a wide graph into the viewport. */+/** Labels share the graph scale so zooming out preserves their spacing. */export function FlowEdge(props: EdgeProps<TransitionEdge>) {- const { zoom } = useViewport();const lane = props.data?.laneOffset ?? 0;const [path, labelX, labelY] = lane? ([@@ -37,6 +46,7 @@ export function FlowEdge(props: EdgeProps<TransitionEdge>) {(props.sourceY + props.targetY) / 2 + lane * 0.75,] as const): getSmoothStepPath({ ...props, borderRadius: 20, offset: 32 });+ const label = getFlowEdgeLabelLayout({ ...props, lane, labelX, labelY });return (<><BaseEdge id={props.id} markerEnd={props.markerEnd} path={path} style={props.style} />@@ -44,13 +54,11 @@ export function FlowEdge(props: EdgeProps<TransitionEdge>) {<ButtonclassName={cx(styles.label, 'nodrag', 'nopan')}size="small"+ title={typeof props.label === 'string' ? props.label : undefined}type="text"style={{- maxWidth:- Math.abs(props.sourceY - props.targetY) < 24- ? Math.max(40, Math.abs(props.targetX - props.sourceX) * zoom - 8)- : undefined,- transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px) scale(${1 / zoom})`,+ maxWidth: label.maxWidth,+ transform: `translate(-50%, -50%) translate(${label.x}px, ${label.y}px)`,}}onClick={() => props.data?.onSelect(props.id)}>diff --git a/src/features/Acceptance/Viewer/Flow/flowEdgeLabel.test.ts b/src/features/Acceptance/Viewer/Flow/flowEdgeLabel.test.tsnew file mode 100644index 00000000000..96e5a3c488e--- /dev/null+++ b/src/features/Acceptance/Viewer/Flow/flowEdgeLabel.test.ts@@ -0,0 +1,42 @@+import { Position } from '@xyflow/react';+import { describe, expect, it } from 'vitest';++import { getFlowEdgeLabelLayout } from './flowEdgeLabel';++const branch = {+ sourceX: 260,+ targetX: 372,+ targetY: 240,+ sourcePosition: Position.Right,+ targetPosition: Position.Left,+ lane: 0,+ labelX: 316,+ labelY: 120,+};++describe('forward branch labels', () => {+ it('keeps a diagonal branch caption inside the gutter and aligned with its destination', () => {+ const label = getFlowEdgeLabelLayout(branch);+ expect(label.y).toBe(branch.targetY);+ expect(label.x - label.maxWidth / 2).toBeGreaterThan(branch.sourceX);+ expect(label.x + label.maxWidth / 2).toBeLessThan(branch.targetX);+ });++ it('separates captions for branches with different destinations', () => {+ const first = getFlowEdgeLabelLayout(branch);+ const second = getFlowEdgeLabelLayout({ ...branch, targetY: 420 });+ expect(second.y - first.y).toBe(180);+ });++ it.each([+ { lane: 64 },+ { sourcePosition: Position.Bottom, targetPosition: Position.Top },+ { targetX: 100 },+ ])('preserves the routed caption position for non-forward edges: %j', (overrides) => {+ expect(getFlowEdgeLabelLayout({ ...branch, ...overrides })).toEqual({+ x: branch.labelX,+ y: branch.labelY,+ maxWidth: 180,+ });+ });+});diff --git a/src/features/Acceptance/Viewer/Flow/flowEdgeLabel.ts b/src/features/Acceptance/Viewer/Flow/flowEdgeLabel.tsnew file mode 100644index 00000000000..efee9f0bbce--- /dev/null+++ b/src/features/Acceptance/Viewer/Flow/flowEdgeLabel.ts@@ -0,0 +1,31 @@+import { Position } from '@xyflow/react';++/** Keep ordinary forward-branch captions in the gutter beside their destination. */+export function getFlowEdgeLabelLayout({+ sourceX,+ targetX,+ targetY,+ sourcePosition,+ targetPosition,+ lane,+ labelX,+ labelY,+}: {+ sourceX: number;+ targetX: number;+ targetY: number;+ sourcePosition: Position;+ targetPosition: Position;+ lane: number;+ labelX: number;+ labelY: number;+}) {+ const gap = targetX - sourceX;+ if (sourcePosition === Position.Right && targetPosition === Position.Left && gap > 16 && !lane)+ return {+ x: (sourceX + targetX) / 2,+ y: targetY,+ maxWidth: Math.min(180, gap - 16),+ };+ return { x: labelX, y: labelY, maxWidth: 180 };+}