feat: 完善创作工作台与用户诊断支持 (#295)
* feat(canvas): 参考素材 - 增加移除按钮并删除对应连线 * feat(canvas): 完善节点面板交互与拖拽反馈 * fix(canvas): 画布交互与小地图 - 统一浮层层级并完善节点识别 * feat(prompt-optimizer): 增加 AI 提示词优化器及宿主接入 * feat(canvas): 画布 - 增加自动整理节点按钮并补充文档 * chore(web): 前端 - 修正提示词优化器格式 * chore(backend): 后端 - 修正 Go 格式检查 * feat(workspace): 完善诊断导出与本地排障支持 * chore(web): 格式化诊断导出文件 * fix(web-test): 兼容 Bun 测试运行时 * fix(web-test): 对齐模型目录协议断言
This commit is contained in:
1 parent
625a97560b
commit
cf6c78d540
70 files changed
+6863
-1708
No files matched your search
@@ -64,8 +64,9 @@ import { CanvasVersionCompareModal } from "@/components/canvas/canvas-version-co
|
||||
import { CanvasLocalAgentPanel } from "@/components/canvas/canvas-local-agent-panel";
|
||||
import { useFocusMode } from "@/hooks/use-focus-mode";
|
||||
import { useCanvasAgentStore } from "@/stores/canvas/use-canvas-agent-store";
|
||||
import { getContextResourceNodes, type CanvasResourceReference } from "@/lib/canvas/canvas-resource-references";
|
||||
import { getContextResourceNodes, removeCanvasResourceMention, type CanvasResourceReference } from "@/lib/canvas/canvas-resource-references";
|
||||
import { CanvasConnectionCreateMenu, CanvasNodePanelOverlay } from "@/components/canvas/canvas-workspace-overlays";
|
||||
import { CanvasOverlayLayerContainer, CanvasOverlayLayerProvider } from "@/components/canvas/canvas-overlay-layer";
|
||||
import { CanvasLeaferGraphicsLayer } from "@/components/canvas/canvas-leafer-graphics-layer";
|
||||
import { CanvasFreeformEmptyState, CanvasLinkedProjectEmptyState, CanvasShortDramaEmptyState, CanvasShortDramaGuide, CanvasStoryInputNodeContent, CanvasStylePlaceholderNodeContent } from "@/components/canvas/canvas-short-drama-entry";
|
||||
import { failedImageBatchChildren, markImageBatchRetrying, reconcileImageBatchRoot, restoreUnsubmittedImageBatchChild } from "@/lib/canvas/canvas-image-batch-retry";
|
||||
@@ -500,7 +501,6 @@ function InfiniteCanvasPage() {
|
||||
handleViewportChange,
|
||||
handleViewportPreviewChange,
|
||||
previewViewport,
|
||||
resetViewport,
|
||||
screenToCanvas,
|
||||
setZoomScale,
|
||||
zoomCanvasIn,
|
||||
@@ -825,6 +825,7 @@ function InfiniteCanvasPage() {
|
||||
|
||||
const {
|
||||
alignSelectedNodes,
|
||||
autoArrangeCanvasNodes,
|
||||
arrangeSelectedNodes,
|
||||
copyNodesToClipboard,
|
||||
copySelectedNodes,
|
||||
@@ -898,7 +899,6 @@ function InfiniteCanvasPage() {
|
||||
|
||||
const handleCanvasSelectionStart = useCallback(() => {
|
||||
setContextMenu(null);
|
||||
setDialogNodeId(null);
|
||||
}, []);
|
||||
|
||||
const handleNodeInteractionStart = useCallback((selectionModifier: boolean) => {
|
||||
@@ -925,7 +925,6 @@ function InfiniteCanvasPage() {
|
||||
setContextMenu(null);
|
||||
setHoveredNodeId(null);
|
||||
setToolbarNodeId(null);
|
||||
setDialogNodeId(null);
|
||||
}, []);
|
||||
|
||||
const { alignmentGuides, cancelSelectionBox, deselectCanvas, dragPreview, frameDropTargetId, handleCanvasMouseDown, handleNodeMouseDown, isNodeDragging, nodeDraggingRef, selectionBoundsElementRef, selectionBox } = useCanvasSelectionController({
|
||||
@@ -997,6 +996,29 @@ function InfiniteCanvasPage() {
|
||||
setHoveredNodeId,
|
||||
});
|
||||
|
||||
const handleRemoveNodeReference = useCallback((targetNodeId: string, reference: CanvasResourceReference) => {
|
||||
const referenceNodeId = reference.nodeId;
|
||||
if (!referenceNodeId) return;
|
||||
// 生成节点可能通过配置节点接收参考,只移除参考来源边,保留目标到配置节点的主链。
|
||||
const configNodeId = connectionsRef.current.find((connection) => {
|
||||
if (connection.fromNodeId !== targetNodeId) return false;
|
||||
return nodesRef.current.find((node) => node.id === connection.toNodeId)?.type === CanvasNodeType.Config;
|
||||
})?.toNodeId;
|
||||
const removedConnectionIds = new Set(
|
||||
connectionsRef.current
|
||||
.filter((connection) => connection.fromNodeId === referenceNodeId && (connection.toNodeId === targetNodeId || connection.toNodeId === configNodeId))
|
||||
.map((connection) => connection.id),
|
||||
);
|
||||
const targetNode = nodesRef.current.find((node) => node.id === targetNodeId);
|
||||
const currentPrompt = targetNode?.metadata?.composerContent ?? targetNode?.metadata?.prompt ?? "";
|
||||
const nextPrompt = removeCanvasResourceMention(currentPrompt, reference);
|
||||
if (nextPrompt !== currentPrompt) handleNodePromptChange(targetNodeId, nextPrompt);
|
||||
if (!removedConnectionIds.size) return;
|
||||
connectionsRef.current = connectionsRef.current.filter((connection) => !removedConnectionIds.has(connection.id));
|
||||
setConnections(connectionsRef.current);
|
||||
setSelectedConnectionId((current) => current && removedConnectionIds.has(current) ? null : current);
|
||||
}, [connectionsRef, handleNodePromptChange, nodesRef, setConnections, setSelectedConnectionId]);
|
||||
|
||||
const handleProjectFolderInsert = useCallback((folderId: string) => {
|
||||
const folder = linkedProjectQuery.data?.assetFolders.find((item) => item.id === folderId);
|
||||
if (!folder || !linkedProjectId) throw new Error("素材文件夹已不存在,请刷新后重试");
|
||||
@@ -1574,6 +1596,9 @@ function InfiniteCanvasPage() {
|
||||
onPromptChange={handleNodePromptChange}
|
||||
onConfigChange={handleConfigNodeChange}
|
||||
onGenerate={handleGenerateNode}
|
||||
onRemoveReference={handleRemoveNodeReference}
|
||||
onClose={() => setDialogNodeId(null)}
|
||||
onNodeMouseDown={handleNodeMouseDown}
|
||||
workspaceMode={workspaceMode}
|
||||
onImageSettingsOpenChange={(open) => {
|
||||
setNodeImageSettingsOpen(open);
|
||||
@@ -1582,7 +1607,7 @@ function InfiniteCanvasPage() {
|
||||
/>
|
||||
);
|
||||
},
|
||||
[configInputsById, handleConfigNodeChange, handleGenerateNode, handleNodePromptChange, mentionReferencesByNodeId, runningNodeId, skillMentionReferences, workspaceMode],
|
||||
[configInputsById, handleConfigNodeChange, handleGenerateNode, handleNodePromptChange, handleRemoveNodeReference, mentionReferencesByNodeId, runningNodeId, skillMentionReferences, workspaceMode],
|
||||
);
|
||||
|
||||
const renderCanvasNodeContent = useCallback(
|
||||
@@ -1793,7 +1818,8 @@ function InfiniteCanvasPage() {
|
||||
{!focusMode && shortDramaEnabled && currentProject?.projectId ? (
|
||||
<CanvasProjectSidebar projectId={currentProject.projectId} detail={linkedProjectQuery.data} onAddChapter={handleProjectChapterInsert} onLocateStyle={locateProjectStyleNode} onOpenAssets={() => openProjectAssets()} />
|
||||
) : null}
|
||||
<section className="relative min-w-0 flex-1 flex flex-col min-h-0 overflow-hidden">
|
||||
<CanvasOverlayLayerProvider>
|
||||
<section className="relative min-w-0 flex-1 flex flex-col min-h-0 overflow-hidden">
|
||||
{!focusMode ? (
|
||||
<CanvasTopBar
|
||||
title={currentProject?.title || "未命名画布"}
|
||||
@@ -2001,7 +2027,7 @@ function InfiniteCanvasPage() {
|
||||
onExit={exitFocusMode}
|
||||
onZoomIn={zoomCanvasIn}
|
||||
onZoomOut={zoomCanvasOut}
|
||||
onFit={resetViewport}
|
||||
onFit={fitCanvasContent}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -2079,7 +2105,15 @@ function InfiniteCanvasPage() {
|
||||
</div>
|
||||
|
||||
{angleNode?.metadata?.content ? (
|
||||
<CanvasNodePanelOverlay node={angleNode} viewport={viewport} containerRef={containerRef} panelWidth={580} panelHeight={350}>
|
||||
<CanvasNodePanelOverlay
|
||||
node={angleNode}
|
||||
viewport={viewport}
|
||||
containerRef={containerRef}
|
||||
panelWidth={580}
|
||||
panelHeight={350}
|
||||
dragOffset={dragPreview?.nodeIds.has(angleNode.id) ? { x: dragPreview.x, y: dragPreview.y } : null}
|
||||
isDragging={isNodeDragging && Boolean(dragPreview?.nodeIds.has(angleNode.id))}
|
||||
>
|
||||
<CanvasNodeAnglePanel
|
||||
dataUrl={angleNode.metadata.content}
|
||||
onClose={() => setAngleNodeId(null)}
|
||||
@@ -2095,6 +2129,8 @@ function InfiniteCanvasPage() {
|
||||
node={emotionNode}
|
||||
viewport={viewport}
|
||||
containerRef={containerRef}
|
||||
dragOffset={dragPreview?.nodeIds.has(emotionNode.id) ? { x: dragPreview.x, y: dragPreview.y } : null}
|
||||
isDragging={isNodeDragging && Boolean(dragPreview?.nodeIds.has(emotionNode.id))}
|
||||
onClose={() => setEmotionNodeId(null)}
|
||||
onConfirm={(payload: CanvasImageEmotionPayload) => {
|
||||
void generateEmotionNode(emotionNode, payload);
|
||||
@@ -2103,7 +2139,13 @@ function InfiniteCanvasPage() {
|
||||
) : null}
|
||||
|
||||
{dialogNode && dialogNode.type !== CanvasNodeType.Script && dialogNode.type !== CanvasNodeType.Drawing && !selectionBox ? (
|
||||
<CanvasNodePanelOverlay node={dialogNode} viewport={viewport} containerRef={containerRef}>
|
||||
<CanvasNodePanelOverlay
|
||||
node={dialogNode}
|
||||
viewport={viewport}
|
||||
containerRef={containerRef}
|
||||
dragOffset={dragPreview?.nodeIds.has(dialogNode.id) ? { x: dragPreview.x, y: dragPreview.y } : null}
|
||||
isDragging={isNodeDragging && Boolean(dragPreview?.nodeIds.has(dialogNode.id))}
|
||||
>
|
||||
{renderCanvasNodePanel(dialogNode)}
|
||||
</CanvasNodePanelOverlay>
|
||||
) : null}
|
||||
@@ -2201,9 +2243,10 @@ function InfiniteCanvasPage() {
|
||||
{isMiniMapOpen && !focusMode ? <Minimap nodes={nodes} viewport={viewport} viewportSize={size} canvasContainerRef={containerRef} onViewportPreviewChange={previewViewport} onViewportChange={handleViewportChange} /> : null}
|
||||
|
||||
{!focusMode ? (
|
||||
<div
|
||||
data-canvas-no-zoom
|
||||
className="absolute bottom-[calc(var(--canvas-inset-y)+var(--space-16))] left-[var(--canvas-inset-x)] z-[var(--z-panel)] flex items-end gap-2 lg:bottom-[var(--canvas-inset-y)]"
|
||||
<CanvasOverlayLayerContainer
|
||||
overlayId="asset-tray"
|
||||
fallbackZIndex="var(--z-panel)"
|
||||
className="absolute bottom-[calc(var(--canvas-inset-y)+var(--space-16))] left-[var(--canvas-inset-x)] flex items-end gap-2 lg:bottom-[var(--canvas-inset-y)]"
|
||||
onMouseDown={(event) => event.stopPropagation()}
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onWheel={(event) => event.stopPropagation()}
|
||||
@@ -2212,7 +2255,8 @@ function InfiniteCanvasPage() {
|
||||
scale={viewport.k}
|
||||
containerRef={containerRef}
|
||||
onScaleChange={setZoomScale}
|
||||
onReset={resetViewport}
|
||||
onFitContent={fitCanvasContent}
|
||||
onAutoArrange={autoArrangeCanvasNodes}
|
||||
isMiniMapOpen={isMiniMapOpen}
|
||||
onToggleMiniMap={() => setIsMiniMapOpen((value) => !value)}
|
||||
onOpenShortcuts={() => setShortcutRequestNonce((value) => value + 1)}
|
||||
@@ -2225,7 +2269,7 @@ function InfiniteCanvasPage() {
|
||||
onInsertAssetImage={(asset) => void createImageAssetNode(asset)}
|
||||
onFocusCanvasImage={focusCanvasImageNode}
|
||||
/>
|
||||
</div>
|
||||
</CanvasOverlayLayerContainer>
|
||||
) : null}
|
||||
|
||||
<CanvasProjectContextMenu
|
||||
@@ -2478,7 +2522,8 @@ function InfiniteCanvasPage() {
|
||||
{codexCompactAgent && !assistantMounted ? (
|
||||
<CanvasLocalAgentPanel headless snapshot={agentSnapshot} canUndoOps={canUndoAgentOps} undoOpsCount={agentUndoCount} onApplyOps={applyAgentOps} onUndoOps={undoAgentOps} autoConnect={codexAutoConnect} />
|
||||
) : null}
|
||||
</section>
|
||||
</section>
|
||||
</CanvasOverlayLayerProvider>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user