feat: apply approved four-theme canvas design (HEL-818)
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { type Node, type NodeProps } from '@xyflow/svelte';
|
||||
import { untrack } from 'svelte';
|
||||
import { reduceMotion } from '$lib/reduceMotion.svelte';
|
||||
import { finishAnimations } from '$lib/actions/finishAnimations';
|
||||
import SafeMedia from '$lib/components/SafeMedia.svelte';
|
||||
import { assetUrl } from '$lib/api';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
|
||||
interface ArtifactNodeData extends Record<string, unknown> {
|
||||
canvasNodeId: number;
|
||||
jobId: number | null;
|
||||
title: string;
|
||||
/** Generated media file (image or video) — absolute path served via /assets. */
|
||||
artifactPath: string | null;
|
||||
@@ -17,39 +21,66 @@
|
||||
|
||||
type ArtifactNode = Node<ArtifactNodeData, 'image' | 'video'>;
|
||||
|
||||
let { data }: NodeProps<ArtifactNode> = $props();
|
||||
let { data, selected }: NodeProps<ArtifactNode> = $props();
|
||||
|
||||
const mediaSrc = $derived(data.artifactPath ? assetUrl(data.artifactPath) : null);
|
||||
const mediaSrc = $derived(
|
||||
data.artifactPath ? assetUrl(data.artifactPath) : null,
|
||||
);
|
||||
// '#t=0.1' fragment paints the first frame (same trick as ClipMonitor).
|
||||
const videoSrc = $derived(
|
||||
data.kind === 'video' && mediaSrc ? mediaSrc + '#t=0.1' : null,
|
||||
);
|
||||
|
||||
const running = $derived(data.status === 'running' || data.status === 'pending');
|
||||
const running = $derived(
|
||||
data.status === 'running' || data.status === 'pending',
|
||||
);
|
||||
|
||||
let arriving = $state(false);
|
||||
let previous: { id: number | null; status: string } | null = null;
|
||||
$effect(() => {
|
||||
void reduceMotion.mode;
|
||||
void reduceMotion.loopRevision;
|
||||
arriving = false;
|
||||
});
|
||||
$effect(() => {
|
||||
const id = data.jobId,
|
||||
status = data.status;
|
||||
if (!id || previous?.id !== id || status !== 'done') arriving = false;
|
||||
else if (previous.status === 'pending' || previous.status === 'running')
|
||||
arriving = !untrack(() => reduceMotion.mode === 'off');
|
||||
previous = { id, status };
|
||||
});
|
||||
$effect(() => {
|
||||
if (!arriving) return;
|
||||
const skip = () => (arriving = false);
|
||||
window.addEventListener('pointerdown', skip, true);
|
||||
return () => window.removeEventListener('pointerdown', skip, true);
|
||||
});
|
||||
function openPreview() {
|
||||
if (!mediaSrc) return;
|
||||
data.onOpenMedia?.(data.kind);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="artifact-node" class:running>
|
||||
<div
|
||||
class="canvas-card artifact-node a-viewfinder"
|
||||
class:a-in-frame={selected}
|
||||
data-kind={data.kind}
|
||||
>
|
||||
<header>
|
||||
<span class="type-chip">{data.kind}</span>
|
||||
<span class="title" title={data.title}>{data.title}</span>
|
||||
{#if running}
|
||||
<span class="status running-badge">{t('canvas.running')}</span>
|
||||
{:else if data.status === 'failed'}
|
||||
<span class="status failed-badge">{t('canvas.failed')}</span>
|
||||
{:else if videoSrc}
|
||||
<span class="play-badge" aria-hidden="true">▶</span>
|
||||
{/if}
|
||||
</header>
|
||||
<div class="media">
|
||||
<div
|
||||
class="media"
|
||||
use:finishAnimations
|
||||
onanimationend={() => (arriving = false)}
|
||||
>
|
||||
{#if videoSrc}
|
||||
<button
|
||||
type="button"
|
||||
class="media-btn"
|
||||
class:a-result-develop={arriving}
|
||||
onclick={openPreview}
|
||||
title={t('canvas.openPreview')}
|
||||
>
|
||||
@@ -65,6 +96,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="media-btn"
|
||||
class:a-result-develop={arriving}
|
||||
onclick={openPreview}
|
||||
title={t('canvas.openPreview')}
|
||||
>
|
||||
@@ -81,131 +113,12 @@
|
||||
{:else}
|
||||
<span class="placeholder">{t('canvas.noMedia')}</span>
|
||||
{/if}
|
||||
<span class="out-kind">{data.kind}</span>
|
||||
</div>
|
||||
<span class="out-kind">{data.kind}</span>
|
||||
<footer>
|
||||
{#if running}<span class="status running-badge">{t('canvas.running')}</span
|
||||
>{:else if data.status === 'failed'}<span class="status failed-badge"
|
||||
>{t('canvas.failed')}</span
|
||||
>{/if}<span class="node-id">#{data.canvasNodeId}</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.artifact-node {
|
||||
width: 220px;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.artifact-node.running {
|
||||
border-color: var(--run);
|
||||
box-shadow: 0 0 18px var(--run-soft);
|
||||
}
|
||||
:global(.svelte-flow__node.selected) .artifact-node {
|
||||
border-color: var(--accent);
|
||||
box-shadow:
|
||||
0 0 0 1px var(--accent),
|
||||
0 0 30px var(--accent-glow);
|
||||
}
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
.type-chip {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-2);
|
||||
background: var(--bg-4);
|
||||
border: 1px solid var(--line-2);
|
||||
border-radius: 999px;
|
||||
padding: 2px 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.status {
|
||||
font-size: 9.5px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.running-badge {
|
||||
color: var(--run);
|
||||
background: var(--run-soft);
|
||||
}
|
||||
.failed-badge {
|
||||
color: var(--err);
|
||||
background: var(--err-soft);
|
||||
}
|
||||
.play-badge {
|
||||
font-size: 9px;
|
||||
color: var(--text-primary);
|
||||
background: color-mix(in srgb, var(--accent) 22%, transparent);
|
||||
border-radius: 50%;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.media {
|
||||
height: 124px;
|
||||
background: var(--bg-elevated);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* SafeMedia renders the <img> inside a child component, so the scoped
|
||||
* `.media-el` below never lands on it — the :global() reach is what
|
||||
* makes it fill the frame (same pattern as EntityNode). Without it the
|
||||
* image renders at natural size and only a slice is visible. */
|
||||
.media :global(.media-el),
|
||||
.media-el {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.media-btn {
|
||||
appearance: none;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
.placeholder {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
/* Identical to EntityNode's kind badge: transparent-black pill, muted
|
||||
* white text — one style across project and non-project cards. */
|
||||
.out-kind {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
bottom: 10px;
|
||||
font-size: 8.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: lowercase;
|
||||
color: var(--on-media);
|
||||
pointer-events: none;
|
||||
background: var(--media-scrim);
|
||||
padding: 1px 5px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -32,13 +32,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
let { data }: NodeProps<EntityNode> = $props();
|
||||
let { data, selected }: NodeProps<EntityNode> = $props();
|
||||
|
||||
const posterSrc = $derived(assetUrl(data.imagePath));
|
||||
// '#t=0.1' media fragment: with preload="metadata" browsers paint nothing
|
||||
// until playback, so the thumbnail sat black. The fragment seeks+paints
|
||||
// the first frame without playing (same trick as ClipMonitor).
|
||||
const videoSrc = $derived(data.videoPath ? assetUrl(data.videoPath) + '#t=0.1' : null);
|
||||
const videoSrc = $derived(
|
||||
data.videoPath ? assetUrl(data.videoPath) + '#t=0.1' : null,
|
||||
);
|
||||
|
||||
function activate() {
|
||||
// One rule for every card (artifact and entity alike): click opens the
|
||||
@@ -52,7 +54,9 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="entity-node"
|
||||
class="canvas-card entity-node a-viewfinder"
|
||||
class:a-in-frame={selected}
|
||||
data-kind={data.entityType}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
onclick={activate}
|
||||
@@ -61,7 +65,9 @@
|
||||
}}
|
||||
>
|
||||
<header>
|
||||
<Icon name={iconFor(data.entityType)} size={14} />
|
||||
<span class="kind-icon"
|
||||
><Icon name={iconFor(data.entityType)} size={14} /></span
|
||||
>
|
||||
<span class="title" title={data.title}>{data.title}</span>
|
||||
{#if videoSrc}
|
||||
<span class="play-badge" aria-hidden="true">
|
||||
@@ -73,7 +79,13 @@
|
||||
{#if videoSrc && posterSrc}
|
||||
<!-- Idle video card: show the poster (cheap static file, never a
|
||||
mounted <video>). Click opens the modal player. -->
|
||||
<SafeMedia class="media-el" src={posterSrc} alt={data.title} kind="image" controls={false} />
|
||||
<SafeMedia
|
||||
class="media-el"
|
||||
src={posterSrc}
|
||||
alt={data.title}
|
||||
kind="image"
|
||||
controls={false}
|
||||
/>
|
||||
{:else if videoSrc}
|
||||
<!-- No poster available: #t=0.1 first-frame thumbnail. -->
|
||||
<video
|
||||
@@ -84,101 +96,23 @@
|
||||
preload="metadata"
|
||||
></video>
|
||||
{:else if posterSrc}
|
||||
<SafeMedia class="media-el" src={posterSrc} alt={data.title} kind="image" controls={false} />
|
||||
<SafeMedia
|
||||
class="media-el"
|
||||
src={posterSrc}
|
||||
alt={data.title}
|
||||
kind="image"
|
||||
controls={false}
|
||||
/>
|
||||
{:else}
|
||||
<span class="placeholder">{data.entityType}</span>
|
||||
{/if}
|
||||
{#if videoSrc}<span class="out-kind">video</span>{:else if posterSrc}<span
|
||||
class="out-kind">image</span
|
||||
>{/if}
|
||||
</div>
|
||||
{#if videoSrc}
|
||||
<span class="out-kind">video</span>
|
||||
{:else if posterSrc}
|
||||
<span class="out-kind">image</span>
|
||||
{/if}
|
||||
<footer>
|
||||
<span>{data.entityType}</span><span class="node-id"
|
||||
>#{data.canvasNodeId}</span
|
||||
>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.entity-node {
|
||||
width: 240px;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
overflow: visible;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.entity-node:hover {
|
||||
border-color: var(--line-2);
|
||||
}
|
||||
/* Svelte Flow marks the selected node wrapper with .selected */
|
||||
:global(.svelte-flow__node.selected) .entity-node {
|
||||
border-color: var(--accent);
|
||||
box-shadow:
|
||||
0 0 0 1px var(--accent),
|
||||
0 0 40px var(--accent-glow);
|
||||
}
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 9px 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.play-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: color-mix(in srgb, var(--accent) 22%, transparent);
|
||||
color: var(--text-primary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.media {
|
||||
height: 132px;
|
||||
background: var(--bg-elevated);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
border-radius: 0 0 14px 14px;
|
||||
}
|
||||
.media :global(.media-el),
|
||||
.media-el {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.placeholder {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.out-kind {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
bottom: 10px;
|
||||
font-size: 8.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: lowercase;
|
||||
color: var(--on-media);
|
||||
pointer-events: none;
|
||||
background: var(--media-scrim);
|
||||
padding: 1px 5px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/* Scope border-box to the canvas; shared legacy chat uses content-box elsewhere. */
|
||||
.canvas-root,
|
||||
.canvas-root *,
|
||||
.canvas-root *::before,
|
||||
.canvas-root *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* Canvas surfaces consume the approved shared theme and motion tokens. */
|
||||
.canvas-root .svelte-flow {
|
||||
--xy-background-color-default: var(--board-bg);
|
||||
--xy-background-pattern-color-default: var(--board-dot);
|
||||
--xy-controls-button-background-color-default: transparent;
|
||||
--xy-controls-button-background-color-hover-default: rgb(var(--ink) / 0.06);
|
||||
--xy-controls-button-color-default: var(--tx-2);
|
||||
--xy-controls-button-color-hover-default: var(--tx-1);
|
||||
--xy-controls-button-border-color-default: transparent;
|
||||
}
|
||||
.canvas-root .svelte-flow__panel {
|
||||
margin: 14px;
|
||||
}
|
||||
.canvas-root .svelte-flow__controls,
|
||||
.canvas-root .svelte-flow__minimap {
|
||||
padding: 4px;
|
||||
border: 1px solid var(--line-2);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--glass);
|
||||
backdrop-filter: blur(14px);
|
||||
box-shadow: var(--sh-1);
|
||||
overflow: hidden;
|
||||
}
|
||||
.canvas-root .svelte-flow__controls {
|
||||
gap: 2px;
|
||||
height: 160px;
|
||||
}
|
||||
.canvas-root .svelte-flow__controls-button {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 7px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
.canvas-root .svelte-flow__minimap {
|
||||
padding: 10px;
|
||||
}
|
||||
.canvas-root .svelte-flow__minimap svg {
|
||||
display: block;
|
||||
background: rgb(var(--ink) / 0.04);
|
||||
border-radius: 5px;
|
||||
}
|
||||
.canvas-root .svelte-flow__minimap-mask {
|
||||
fill: rgb(var(--ink) / 0.04);
|
||||
stroke: color-mix(in srgb, var(--gold) 80%, var(--hi));
|
||||
}
|
||||
.canvas-card {
|
||||
position: relative;
|
||||
width: 240px;
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--bg-2);
|
||||
border: 1px solid var(--line-2);
|
||||
box-shadow: var(--sh-1);
|
||||
cursor: grab;
|
||||
transition:
|
||||
box-shadow var(--t-base),
|
||||
border-color var(--t-base);
|
||||
--scene: var(--sc-image);
|
||||
}
|
||||
.canvas-card.artifact-node {
|
||||
width: 220px;
|
||||
border-radius: var(--r-md);
|
||||
}
|
||||
.canvas-card:hover {
|
||||
box-shadow: var(--sh-2);
|
||||
border-color: var(--line-3);
|
||||
}
|
||||
.canvas-card.a-in-frame,
|
||||
.canvas-root .svelte-flow__node:focus-visible .canvas-card {
|
||||
border-color: color-mix(in srgb, var(--scene) 45%, transparent);
|
||||
}
|
||||
.canvas-card:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
.canvas-card:focus-visible::after,
|
||||
.canvas-root .svelte-flow__node:focus-visible .canvas-card::after {
|
||||
opacity: 1;
|
||||
inset: var(--viewfinder-selected-inset);
|
||||
}
|
||||
.canvas-card header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 9px 10px 8px;
|
||||
}
|
||||
.canvas-card .title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
color: var(--tx-1);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.canvas-card .kind-icon {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
border-radius: 6px;
|
||||
color: var(--kind-color);
|
||||
background: color-mix(in srgb, var(--kind-color) 12%, transparent);
|
||||
}
|
||||
.canvas-card[data-kind="character"] {
|
||||
--kind-color: var(--sc-agent);
|
||||
}
|
||||
.canvas-card[data-kind="location"],
|
||||
.canvas-card[data-kind="scene"],
|
||||
.canvas-card[data-kind="video"] {
|
||||
--kind-color: var(--sc-video);
|
||||
}
|
||||
.canvas-card[data-kind="item"] {
|
||||
--kind-color: var(--sc-project);
|
||||
}
|
||||
.canvas-card[data-kind="image"] {
|
||||
--kind-color: var(--sc-image);
|
||||
}
|
||||
.canvas-card .play-badge {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
background: rgb(var(--ink) / 0.06);
|
||||
color: var(--tx-2);
|
||||
}
|
||||
.canvas-card .media {
|
||||
position: relative;
|
||||
height: 132px;
|
||||
margin: 0 8px 8px;
|
||||
border-radius: calc(var(--r-md) - 2px);
|
||||
background: var(--desk-media-bg);
|
||||
box-shadow: var(--media-shadow);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.canvas-card.artifact-node .media {
|
||||
height: 124px;
|
||||
}
|
||||
.canvas-card .media-el {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.canvas-card .media-btn {
|
||||
appearance: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
.canvas-card .placeholder {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--tx-3);
|
||||
}
|
||||
.canvas-card .out-kind {
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
bottom: 6px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 10.5px;
|
||||
color: var(--on-media);
|
||||
background: var(--media-scrim);
|
||||
border: 1px solid var(--line-2);
|
||||
pointer-events: none;
|
||||
}
|
||||
.canvas-card footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 0 10px 9px;
|
||||
font-size: 11px;
|
||||
color: var(--tx-3);
|
||||
}
|
||||
.canvas-card footer .node-id {
|
||||
margin-left: auto;
|
||||
font-family: var(--mono);
|
||||
}
|
||||
.canvas-card .type-chip {
|
||||
font-size: 10.5px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
color: var(--kind-color);
|
||||
background: color-mix(in srgb, var(--kind-color) 12%, transparent);
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
.canvas-card .status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 10.5px;
|
||||
}
|
||||
.canvas-card .running-badge {
|
||||
color: var(--info);
|
||||
}
|
||||
.canvas-card .running-badge::before {
|
||||
content: "";
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--info);
|
||||
}
|
||||
.canvas-card .failed-badge {
|
||||
color: var(--err);
|
||||
}
|
||||
@@ -488,38 +488,38 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: var(--fs-mini);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
font-size: var(--chat-tag-size, var(--fs-mini));
|
||||
font-weight: var(--chat-tag-weight, 700);
|
||||
letter-spacing: var(--chat-tag-spacing, 0.06em);
|
||||
text-transform: var(--chat-tag-transform, uppercase);
|
||||
color: var(--agent, var(--text-2));
|
||||
margin-bottom: 4px;
|
||||
padding-left: 2px;
|
||||
}
|
||||
.agent-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
width: var(--chat-dot-size, 8px);
|
||||
height: var(--chat-dot-size, 8px);
|
||||
border-radius: 999px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--agent, var(--text-2)) 25%, transparent);
|
||||
box-shadow: var(--chat-identity-shadow, 0 0 0 2px color-mix(in srgb, var(--agent, var(--text-2)) 25%, transparent));
|
||||
}
|
||||
.reasoning-wrap {
|
||||
margin-bottom: 4px;
|
||||
max-width: 86%;
|
||||
}
|
||||
.bubble {
|
||||
max-width: 86%;
|
||||
border-radius: var(--r-lg);
|
||||
padding: 10px 14px;
|
||||
font-size: 13.5px;
|
||||
max-width: var(--chat-bubble-width, 86%);
|
||||
border-radius: var(--chat-bubble-radius, var(--r-lg));
|
||||
padding: var(--chat-bubble-padding, 10px 14px);
|
||||
font-size: var(--chat-bubble-font, 13.5px);
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
/* 对话气泡按规范 §3.2/§3.6:用户 --bg-3,Agent --bg-2 + --line 描边。 */
|
||||
.user-bubble {
|
||||
background: var(--bg-3);
|
||||
border: 1px solid var(--line);
|
||||
background: var(--chat-user-bg, var(--bg-3));
|
||||
border: 1px solid var(--chat-user-border, var(--line));
|
||||
color: var(--text);
|
||||
}
|
||||
.user-bubble.steering {
|
||||
@@ -574,7 +574,7 @@
|
||||
.assistant-bubble {
|
||||
background: var(--bg-2);
|
||||
border: 1px solid var(--line);
|
||||
border-left: 3px solid var(--agent, var(--text-2));
|
||||
border-left: var(--chat-agent-border-width, 3px) solid var(--chat-agent-border, var(--agent, var(--text-2)));
|
||||
color: var(--text);
|
||||
}
|
||||
.question-card {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
interface Props {
|
||||
studio?: boolean;
|
||||
primaryAction?: boolean;
|
||||
running: boolean;
|
||||
onSend: (payload: AgentComposerPayload) => void;
|
||||
onCancel: () => void;
|
||||
@@ -36,6 +37,7 @@ interface Props {
|
||||
|
||||
let {
|
||||
studio = false,
|
||||
primaryAction = false,
|
||||
running,
|
||||
onSend,
|
||||
onCancel,
|
||||
@@ -578,7 +580,7 @@ let {
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
class={studio ? "a-btn sm primary" : "send"}
|
||||
class={studio ? "a-btn sm primary" : primaryAction ? "a-btn primary" : "send"}
|
||||
class:steer={running}
|
||||
onclick={submit}
|
||||
disabled={!sendable}
|
||||
@@ -622,7 +624,7 @@ let {
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding-top: var(--composer-top-padding, 10px);
|
||||
padding: var(--composer-padding, var(--composer-top-padding, 10px) 0 0);
|
||||
border-top: var(--composer-top-border, 1px) solid var(--border);
|
||||
}
|
||||
.composer.drag-over .box {
|
||||
|
||||
@@ -201,8 +201,8 @@
|
||||
.sidebar {
|
||||
width: 240px;
|
||||
flex-shrink: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
background: var(--bg-surface);
|
||||
border-right: 1px solid var(--line);
|
||||
background: var(--bg-1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
@@ -243,8 +243,8 @@
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px dashed var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
border: 0;
|
||||
border-radius: var(--r-sm);
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
@@ -267,32 +267,34 @@
|
||||
min-height: 0;
|
||||
}
|
||||
.rail-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-elevated);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border: 0;
|
||||
border-radius: var(--r-sm);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
.rail-dot::after {
|
||||
content: '';
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--tx-3);
|
||||
}
|
||||
.rail-dot:hover {
|
||||
border-color: var(--accent);
|
||||
background: rgb(var(--ink) / 0.05);
|
||||
}
|
||||
.rail-dot.active {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
background: color-mix(in srgb, var(--sc-agent) 12%, transparent);
|
||||
}
|
||||
.rail-dot.run {
|
||||
animation: var(--decorative-loop-name, motion-agentsessionsidebar-rail-pulse) 1.4s ease-in-out infinite;
|
||||
.rail-dot.active::after {
|
||||
background: var(--sc-agent);
|
||||
}
|
||||
@keyframes -global-motion-agentsessionsidebar-rail-pulse {
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 var(--accent-glow);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 0 5px transparent;
|
||||
}
|
||||
.rail-dot.run::after {
|
||||
background: var(--ok);
|
||||
}
|
||||
.new-chat {
|
||||
display: flex;
|
||||
@@ -399,7 +401,8 @@
|
||||
.dot.run {
|
||||
background: var(--warning);
|
||||
opacity: 1;
|
||||
animation: var(--decorative-loop-name, motion-agentsessionsidebar-pulse) 1.1s ease-in-out infinite;
|
||||
animation: var(--decorative-loop-name, motion-agentsessionsidebar-pulse)
|
||||
1.1s ease-in-out infinite;
|
||||
}
|
||||
@keyframes -global-motion-agentsessionsidebar-pulse {
|
||||
0%,
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { toStore } from 'svelte/store';
|
||||
import { createMutation, createQuery, useQueryClient } from '@tanstack/svelte-query';
|
||||
import {
|
||||
createMutation,
|
||||
createQuery,
|
||||
useQueryClient,
|
||||
} from '@tanstack/svelte-query';
|
||||
import {
|
||||
SvelteFlow,
|
||||
Controls,
|
||||
@@ -16,6 +20,7 @@
|
||||
type Viewport,
|
||||
} from '@xyflow/svelte';
|
||||
import '@xyflow/svelte/dist/style.css';
|
||||
import '$lib/canvas/canvas.css';
|
||||
import AppShell from '$lib/components/shell/AppShell.svelte';
|
||||
import AgentChat from '$lib/components/agent/AgentChat.svelte';
|
||||
import AgentComposer from '$lib/components/agent/AgentComposer.svelte';
|
||||
@@ -44,7 +49,11 @@
|
||||
type Location,
|
||||
type Scene,
|
||||
} from '$lib/api';
|
||||
import type { AgentComposerPayload, SkillOption, WorkflowOption } from '$lib/agentComposer';
|
||||
import type {
|
||||
AgentComposerPayload,
|
||||
SkillOption,
|
||||
WorkflowOption,
|
||||
} from '$lib/agentComposer';
|
||||
import { connectEvents } from '$lib/events';
|
||||
import { toast } from '$lib/toast';
|
||||
|
||||
@@ -145,7 +154,11 @@
|
||||
caption: string;
|
||||
} | null>(null);
|
||||
|
||||
function openMediaPreview(kind: 'image' | 'video', path: string | null, caption: string) {
|
||||
function openMediaPreview(
|
||||
kind: 'image' | 'video',
|
||||
path: string | null,
|
||||
caption: string,
|
||||
) {
|
||||
const src = assetUrl(path);
|
||||
if (!src) return;
|
||||
preview = { src, kind, caption };
|
||||
@@ -184,10 +197,13 @@
|
||||
// eslint-disable-next-line svelte/prefer-svelte-reactivity -- Effect-local job lookup is built and synchronously consumed into nodes, then discarded; graph/jobs already drive the effect.
|
||||
const nodeRunning = new Map<number, boolean>();
|
||||
for (const n of graph.nodes) {
|
||||
const tracked = n.job_id != null ? jobs.find((j) => j.id === n.job_id) : undefined;
|
||||
const tracked =
|
||||
n.job_id != null ? jobs.find((j) => j.id === n.job_id) : undefined;
|
||||
nodeRunning.set(
|
||||
n.id,
|
||||
tracked ? tracked.status === 'running' || tracked.status === 'pending' : false,
|
||||
tracked
|
||||
? tracked.status === 'running' || tracked.status === 'pending'
|
||||
: false,
|
||||
);
|
||||
}
|
||||
nodes = graph.nodes
|
||||
@@ -204,7 +220,10 @@
|
||||
title: n.title ?? 'Artifact',
|
||||
artifactPath: n.artifact_path,
|
||||
kind: n.type,
|
||||
status: nodeRunning.get(n.id) ? 'running' : n.status,
|
||||
status: nodeRunning.get(n.id)
|
||||
? 'running'
|
||||
: (jobs.find((j) => j.id === n.job_id)?.status ?? n.status),
|
||||
jobId: n.job_id,
|
||||
onOpenMedia: (kind: 'image' | 'video') =>
|
||||
openMediaPreview(kind, n.artifact_path, n.title ?? 'Artifact'),
|
||||
},
|
||||
@@ -216,14 +235,23 @@
|
||||
position: { x: n.x, y: n.y },
|
||||
data: {
|
||||
canvasNodeId: n.id,
|
||||
entityType: n.entity_type as 'character' | 'location' | 'item' | 'scene',
|
||||
entityType: n.entity_type as
|
||||
'character' | 'location' | 'item' | 'scene',
|
||||
title: n.title ?? 'Untitled',
|
||||
imagePath: media.imagePath,
|
||||
videoPath: media.videoPath,
|
||||
onOpenMedia: (kind: 'image' | 'video') =>
|
||||
kind === 'video'
|
||||
? openMediaPreview('video', media.videoPath, n.title ?? 'Untitled')
|
||||
: openMediaPreview('image', media.imagePath, n.title ?? 'Untitled'),
|
||||
? openMediaPreview(
|
||||
'video',
|
||||
media.videoPath,
|
||||
n.title ?? 'Untitled',
|
||||
)
|
||||
: openMediaPreview(
|
||||
'image',
|
||||
media.imagePath,
|
||||
n.title ?? 'Untitled',
|
||||
),
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -238,7 +266,9 @@
|
||||
y: node.position.y,
|
||||
});
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.savePosFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.savePosFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +288,11 @@
|
||||
// Group drags: targetNode is null, `nodes` is the whole selection.
|
||||
// Single drags: nodes[0] is the dragged node. Persist EVERYTHING —
|
||||
// persisting only the last node dropped the rest of a group's moves.
|
||||
const moved = e.nodes?.length ? e.nodes : e.targetNode ? [e.targetNode] : [];
|
||||
const moved = e.nodes?.length
|
||||
? e.nodes
|
||||
: e.targetNode
|
||||
? [e.targetNode]
|
||||
: [];
|
||||
if (moved.length > 0) void persistNodePositions(moved);
|
||||
// A refetch landed during the drag: rebuild now that positions are
|
||||
// settled (and re-ordered by the just-saved values on the next fetch).
|
||||
@@ -277,7 +311,11 @@
|
||||
return typeof id === 'number' ? id : null;
|
||||
}
|
||||
|
||||
async function onBeforeDeleteCanvas({ nodes }: { nodes: Node[] }): Promise<boolean> {
|
||||
async function onBeforeDeleteCanvas({
|
||||
nodes,
|
||||
}: {
|
||||
nodes: Node[];
|
||||
}): Promise<boolean> {
|
||||
const blocked = nodes.filter(
|
||||
(n) =>
|
||||
n.type === 'entity' ||
|
||||
@@ -292,11 +330,15 @@
|
||||
}
|
||||
|
||||
async function onDeleteCanvas({ nodes }: { nodes: Node[] }) {
|
||||
const ids = nodes.map(nodeServerId).filter((id): id is number => id != null);
|
||||
const ids = nodes
|
||||
.map(nodeServerId)
|
||||
.filter((id): id is number => id != null);
|
||||
if (ids.length === 0) return;
|
||||
let fileDeletedCount = 0;
|
||||
let keptCount = 0;
|
||||
const results = await Promise.allSettled(ids.map((id) => canvasApi.deleteNode(canvasId, id)));
|
||||
const results = await Promise.allSettled(
|
||||
ids.map((id) => canvasApi.deleteNode(canvasId, id)),
|
||||
);
|
||||
for (const r of results) {
|
||||
if (r.status === 'fulfilled') {
|
||||
if (r.value.file_deleted) fileDeletedCount++;
|
||||
@@ -310,7 +352,9 @@
|
||||
return;
|
||||
}
|
||||
if (fileDeletedCount > 0 && keptCount > 0) {
|
||||
toast.success(t('canvas.deletedMixed', { files: fileDeletedCount, kept: keptCount }));
|
||||
toast.success(
|
||||
t('canvas.deletedMixed', { files: fileDeletedCount, kept: keptCount }),
|
||||
);
|
||||
} else if (fileDeletedCount > 0) {
|
||||
toast.success(t('canvas.deletedWithFile', { count: fileDeletedCount }));
|
||||
} else {
|
||||
@@ -365,7 +409,9 @@
|
||||
// localStorage first (synchronous, survives navigation + reloads
|
||||
// even if the request never lands), backend per canvas second.
|
||||
storageSet(viewportLocalStorageKey(canvasId), json);
|
||||
void canvasApi.patchCanvas(canvasId, { viewport_json: json }).catch(() => undefined);
|
||||
void canvasApi
|
||||
.patchCanvas(canvasId, { viewport_json: json })
|
||||
.catch(() => undefined);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
@@ -433,7 +479,9 @@
|
||||
const activeSession = $derived(
|
||||
activeId != null ? (sessions.find((s) => s.id === activeId) ?? null) : null,
|
||||
);
|
||||
const running = $derived(Boolean(activeSession?.running || activeSession?.status === 'running'));
|
||||
const running = $derived(
|
||||
Boolean(activeSession?.running || activeSession?.status === 'running'),
|
||||
);
|
||||
|
||||
const sessionQuery = createQuery(
|
||||
toStore(() => ({
|
||||
@@ -448,7 +496,8 @@
|
||||
const jobsQuery = createQuery(
|
||||
toStore(() => ({
|
||||
queryKey: ['agent-project-jobs', projectId ?? 'sandbox'],
|
||||
queryFn: () => (projectId != null ? jobsApi.list(projectId) : playgroundApi.jobs()),
|
||||
queryFn: () =>
|
||||
projectId != null ? jobsApi.list(projectId) : playgroundApi.jobs(),
|
||||
enabled: activeId != null,
|
||||
})),
|
||||
);
|
||||
@@ -492,7 +541,9 @@
|
||||
activeId = pid;
|
||||
// Deep-link handoff (/agents?project=&task=) pre-fills the composer once.
|
||||
try {
|
||||
const prefill = sessionStorage.getItem('calliope.canvas.composerPrefill');
|
||||
const prefill = sessionStorage.getItem(
|
||||
'calliope.canvas.composerPrefill',
|
||||
);
|
||||
if (prefill) {
|
||||
sessionStorage.removeItem('calliope.canvas.composerPrefill');
|
||||
setComposerDraft(prefill);
|
||||
@@ -550,7 +601,9 @@
|
||||
: await canvasApi.ensureForSession(s.id);
|
||||
goto(resolve(`/canvas/${graph.canvas.id}?session=${s.id}`));
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.openThatFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.openThatFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +639,9 @@
|
||||
const graph = await canvasApi.ensureForSession(s.id);
|
||||
goto(resolve(`/canvas/${graph.canvas.id}?session=${s.id}`));
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.sessionCreateFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.sessionCreateFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,7 +658,9 @@
|
||||
goto(resolve(`/canvas/${graph.canvas.id}?session=${s.id}`));
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.sessionCreateFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.sessionCreateFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +672,9 @@
|
||||
await client.invalidateQueries({ queryKey: ['agent-sessions'] });
|
||||
toast.success(t('canvas.sessionDeleted'));
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.sessionDeleteFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.sessionDeleteFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,12 +696,15 @@
|
||||
goto(resolve(`/canvas/${graph.canvas.id}?session=${sid}`));
|
||||
toast.success(t('canvas.chatUnlinked'));
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.unlinkFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.unlinkFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const sendMutation = createMutation({
|
||||
mutationFn: (payload: AgentComposerPayload) => agentApi.postMessage(activeId!, payload),
|
||||
mutationFn: (payload: AgentComposerPayload) =>
|
||||
agentApi.postMessage(activeId!, payload),
|
||||
onMutate: () => {
|
||||
if (activeId != null) {
|
||||
const s = sessions.find((x) => x.id === activeId);
|
||||
@@ -653,9 +715,10 @@
|
||||
thinkingAgent = null;
|
||||
liveTools = [];
|
||||
livePlan = null;
|
||||
client.setQueryData<AgentSession & { messages: AgentMessage[]; plan?: AgentPlan | null }>(
|
||||
['agent-session', activeId],
|
||||
(old) => (old ? { ...old, plan: null } : old),
|
||||
client.setQueryData<
|
||||
AgentSession & { messages: AgentMessage[]; plan?: AgentPlan | null }
|
||||
>(['agent-session', activeId], (old) =>
|
||||
old ? { ...old, plan: null } : old,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -680,7 +743,9 @@
|
||||
await client.invalidateQueries({ queryKey: ['agent-session', activeId] });
|
||||
toast.info(t('canvas.runCancelled'));
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.cancelFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.cancelFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,13 +762,19 @@
|
||||
activeId = s.id;
|
||||
$sendMutation.mutate(payload);
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.sessionCreateFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.sessionCreateFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Question-card click: the option text is the reply, stamped with the
|
||||
* question seq so the backend records a structured approval. */
|
||||
function handleQuestionAnswer(option: string, _scope: string, questionSeq: number) {
|
||||
function handleQuestionAnswer(
|
||||
option: string,
|
||||
_scope: string,
|
||||
questionSeq: number,
|
||||
) {
|
||||
if (running || activeId == null) return;
|
||||
handleSend({
|
||||
content: option,
|
||||
@@ -804,7 +875,9 @@
|
||||
...liveTools[real],
|
||||
result: ev.data?.result,
|
||||
phase:
|
||||
(ev.data?.result as { ok?: boolean } | undefined)?.ok === false ? 'error' : 'done',
|
||||
(ev.data?.result as { ok?: boolean } | undefined)?.ok === false
|
||||
? 'error'
|
||||
: 'done',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -823,7 +896,9 @@
|
||||
livePlan = livePlan
|
||||
? {
|
||||
...livePlan,
|
||||
tasks: livePlan.tasks.map((t, i) => (i === index ? { ...t, status } : t)),
|
||||
tasks: livePlan.tasks.map((t, i) =>
|
||||
i === index ? { ...t, status } : t,
|
||||
),
|
||||
}
|
||||
: livePlan;
|
||||
}
|
||||
@@ -855,7 +930,9 @@
|
||||
|
||||
// ---- artifacts from job events -------------------------------------------
|
||||
|
||||
async function materializeJobArtifact(data: Record<string, unknown> | undefined) {
|
||||
async function materializeJobArtifact(
|
||||
data: Record<string, unknown> | undefined,
|
||||
) {
|
||||
const jobId = Number(data?.job_id ?? NaN);
|
||||
if (!Number.isFinite(jobId)) return;
|
||||
// Scope: project canvases take their own project's jobs; sandbox
|
||||
@@ -962,7 +1039,7 @@
|
||||
|
||||
// Stored in px; capped against the live window so a resized window can
|
||||
// never restore an oversize panel (max 30% of window width).
|
||||
let chatWidth = $state(300);
|
||||
let chatWidth = $state(320);
|
||||
let dragging = $state(false);
|
||||
|
||||
function clampChatWidth(px: number): number {
|
||||
@@ -972,9 +1049,15 @@
|
||||
|
||||
$effect(() => {
|
||||
const raw = Number(storageGet(CHAT_W_KEY));
|
||||
if (Number.isFinite(raw) && raw > 0) chatWidth = clampChatWidth(raw);
|
||||
chatWidth = clampChatWidth(
|
||||
Number.isFinite(raw) && raw > 0
|
||||
? raw
|
||||
: window.innerWidth <= 1280
|
||||
? 300
|
||||
: 320,
|
||||
);
|
||||
// Keep the panel within the cap when the window shrinks.
|
||||
const onResize = () => (chatWidth = clampChatWidth(chatWidth));
|
||||
const onResize = () => (chatWidth = clampChatWidth(storageGet(CHAT_W_KEY) ? chatWidth : window.innerWidth <= 1280 ? 300 : 320));
|
||||
window.addEventListener('resize', onResize);
|
||||
return () => window.removeEventListener('resize', onResize);
|
||||
});
|
||||
@@ -1007,6 +1090,8 @@
|
||||
let titleDraft = $state('');
|
||||
let titleEditing = $state(false);
|
||||
let savedFlash = $state(false);
|
||||
let savedTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
onDestroy(() => clearTimeout(savedTimer));
|
||||
|
||||
$effect(() => {
|
||||
if (!titleEditing) titleDraft = canvas?.title ?? '';
|
||||
@@ -1020,20 +1105,25 @@
|
||||
await canvasApi.patchCanvas(canvasId, { title: next });
|
||||
await client.invalidateQueries({ queryKey: ['canvas', canvasId] });
|
||||
savedFlash = true;
|
||||
setTimeout(() => (savedFlash = false), 1400);
|
||||
clearTimeout(savedTimer);
|
||||
savedTimer = setTimeout(() => (savedFlash = false), 2400);
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t('canvas.renameFailed'));
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : t('canvas.renameFailed'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const SUGGESTIONS: { label: string; prompt: string }[] = [
|
||||
{
|
||||
label: t('canvas.suggestFilm'),
|
||||
prompt: 'Create a new film project and guide me through drafting the story.',
|
||||
prompt:
|
||||
'Create a new film project and guide me through drafting the story.',
|
||||
},
|
||||
{
|
||||
label: t('canvas.suggestStory'),
|
||||
prompt: 'Draft a storyline — beats, characters, environments, and misc. items.',
|
||||
prompt:
|
||||
'Draft a storyline — beats, characters, environments, and misc. items.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
@@ -1080,14 +1170,19 @@
|
||||
title={t('canvas.rename')}
|
||||
>
|
||||
{canvas.title}
|
||||
<span class="rename-icon"><Icon name="edit" size={14} /></span>
|
||||
</button>
|
||||
{/if}
|
||||
{#if savedFlash}
|
||||
<span class="saved">saved</span>
|
||||
{/if}
|
||||
<span class="title-separator"></span>
|
||||
{#if canvas.project}
|
||||
<a class="project-chip" href={resolve(`/workbench/${canvas.project.id}`)}>
|
||||
<Icon name="folder" size={12} />
|
||||
<a
|
||||
class="project-chip"
|
||||
href={resolve(`/workbench/${canvas.project.id}`)}
|
||||
>
|
||||
<Icon name="folder" size={14} />
|
||||
{canvas.project.title}
|
||||
</a>
|
||||
<button
|
||||
@@ -1104,12 +1199,12 @@
|
||||
title: canvas.project.title,
|
||||
})}
|
||||
>
|
||||
<Icon name="link-off" size={12} />
|
||||
<Icon name="link-off" size={14} />
|
||||
{t('canvas.unlinkButton')}
|
||||
</button>
|
||||
{:else}
|
||||
<span class="sandbox-chip">
|
||||
<Icon name="sparkle" size={12} />
|
||||
<Icon name="sparkle" size={14} />
|
||||
Sandbox
|
||||
</span>
|
||||
{/if}
|
||||
@@ -1119,7 +1214,7 @@
|
||||
bind:nodes
|
||||
bind:viewport
|
||||
{nodeTypes}
|
||||
colorMode="light"
|
||||
colorMode="system"
|
||||
minZoom={0.05}
|
||||
maxZoom={4}
|
||||
{initialViewport}
|
||||
@@ -1135,9 +1230,24 @@
|
||||
onmoveend={(_event, vp) => scheduleViewportSave(vp)}
|
||||
oninit={assertViewportOnInit}
|
||||
>
|
||||
<Background variant={BackgroundVariant.Dots} gap={26} size={1} />
|
||||
<Controls />
|
||||
<MiniMap />
|
||||
<Background
|
||||
variant={BackgroundVariant.Dots}
|
||||
gap={26 / viewport.zoom}
|
||||
size={2 / viewport.zoom}
|
||||
patternColor="var(--board-dot)"
|
||||
/>
|
||||
<Controls
|
||||
><span class="zoom-value">{Math.round(viewport.zoom * 100)}%</span
|
||||
></Controls
|
||||
>
|
||||
<MiniMap
|
||||
width={150}
|
||||
height={88}
|
||||
nodeColor={(node) => node.type === 'video' ? 'color-mix(in srgb, var(--sc-video) 60%, var(--tx-3))' : 'color-mix(in srgb, var(--sc-image) 55%, var(--tx-3))'}
|
||||
maskColor="rgb(var(--ink) / 0.04)"
|
||||
maskStrokeColor="var(--gold)"
|
||||
maskStrokeWidth={1.5}
|
||||
/>
|
||||
<Panel position="bottom-center">
|
||||
<button
|
||||
type="button"
|
||||
@@ -1187,8 +1297,15 @@
|
||||
<div class="chat-title-block">
|
||||
{#if activeSession}
|
||||
<span class="chat-title">{activeSession.title}</span>
|
||||
<span class="chat-subtitle"
|
||||
>{activeSession.project_id
|
||||
? (canvas?.project?.title ?? 'Sandbox')
|
||||
: 'Sandbox'}</span
|
||||
>
|
||||
{:else}
|
||||
<span class="chat-title muted">{t('canvas.noChatSelected')}</span>
|
||||
<span class="chat-title muted"
|
||||
>{t('canvas.noChatSelected')}</span
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
<button
|
||||
@@ -1217,7 +1334,7 @@
|
||||
<AgentPlanPanel {plan} />
|
||||
{/if}
|
||||
{#key activeId}
|
||||
<AgentComposer
|
||||
<AgentComposer primaryAction
|
||||
{running}
|
||||
draft={composerDraft}
|
||||
draftNonce={composerNonce}
|
||||
@@ -1265,57 +1382,28 @@
|
||||
flex: 1;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
position: relative;
|
||||
background: var(--bg-1);
|
||||
--scene: var(--sc-image);
|
||||
}
|
||||
.flow-panel {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
position: relative;
|
||||
background: var(--board-bg);
|
||||
}
|
||||
.load-error {
|
||||
padding: 24px;
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
margin: 24px;
|
||||
color: var(--tx-2);
|
||||
}
|
||||
.tidy-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
.tidy-btn:hover:not(:disabled) {
|
||||
color: var(--text-primary);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.tidy-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.canvas-empty-hint {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
max-width: 340px;
|
||||
padding: 10px 14px;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.canvas-empty-hint strong {
|
||||
color: var(--text-primary);
|
||||
font-size: 12.5px;
|
||||
.titlecard,
|
||||
.tidy-btn,
|
||||
.canvas-empty-hint,
|
||||
.chat-expand {
|
||||
background: var(--glass);
|
||||
backdrop-filter: blur(14px);
|
||||
border: 1px solid var(--line-2);
|
||||
box-shadow: var(--sh-1);
|
||||
}
|
||||
.titlecard {
|
||||
position: absolute;
|
||||
@@ -1324,139 +1412,224 @@
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
|
||||
gap: 8px;
|
||||
height: 42px;
|
||||
max-width: calc(100% - 28px);
|
||||
padding: 0 8px 0 14px;
|
||||
border-radius: var(--r-lg);
|
||||
}
|
||||
.title-btn {
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--text-primary);
|
||||
color: var(--tx-1);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.2px;
|
||||
cursor: text;
|
||||
padding: 2px 4px;
|
||||
border-radius: var(--radius-sm);
|
||||
max-width: 280px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.title-btn:hover {
|
||||
background: var(--bg-elevated);
|
||||
.rename-icon {
|
||||
color: var(--tx-3);
|
||||
opacity: 0;
|
||||
}
|
||||
.title-btn:hover .rename-icon,
|
||||
.title-btn:focus-visible .rename-icon {
|
||||
opacity: 1;
|
||||
}
|
||||
.title-input {
|
||||
border: 1px solid var(--accent);
|
||||
background: var(--bg-elevated);
|
||||
color: var(--text-primary);
|
||||
min-width: 0;
|
||||
width: 180px;
|
||||
border: 1px solid var(--gold);
|
||||
background: var(--well);
|
||||
color: var(--tx-1);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
padding: 2px 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
max-width: 280px;
|
||||
outline: none;
|
||||
border-radius: var(--r-sm);
|
||||
}
|
||||
.title-separator {
|
||||
flex-shrink: 0;
|
||||
width: 1px;
|
||||
height: 18px;
|
||||
background: var(--line-2);
|
||||
}
|
||||
.saved {
|
||||
font-size: 10.5px;
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.05em;
|
||||
font-size: 11px;
|
||||
color: var(--ok);
|
||||
}
|
||||
.project-chip,
|
||||
.sandbox-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 11.5px;
|
||||
color: var(--text-secondary);
|
||||
text-decoration: none;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
border-radius: var(--r-pill);
|
||||
border: 1px solid var(--line-2);
|
||||
font-size: 12px;
|
||||
color: var(--tx-2);
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
max-width: 40%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.project-chip {
|
||||
background: color-mix(in srgb, var(--sc-project) 12%, transparent);
|
||||
border-color: color-mix(in srgb, var(--sc-project) 38%, transparent);
|
||||
color: color-mix(in srgb, var(--sc-project) 82%, var(--hi));
|
||||
}
|
||||
.project-chip:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--text-primary);
|
||||
background: color-mix(in srgb, var(--sc-project) 18%, transparent);
|
||||
}
|
||||
.unlink-btn {
|
||||
flex-shrink: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-size: 11.5px;
|
||||
color: var(--text-secondary);
|
||||
padding: 3px 9px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
height: 28px;
|
||||
padding: 0 9px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
border-radius: var(--r-sm);
|
||||
color: var(--tx-3);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
color 0.15s;
|
||||
}
|
||||
.unlink-btn:hover:not(:disabled) {
|
||||
border-color: var(--err-line);
|
||||
color: var(--err);
|
||||
background: color-mix(in srgb, var(--err) 8%, transparent);
|
||||
}
|
||||
.unlink-btn:disabled {
|
||||
.unlink-btn:disabled,
|
||||
.tidy-btn:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.tidy-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
height: 34px;
|
||||
padding: 0 16px;
|
||||
border-radius: var(--r-pill);
|
||||
color: var(--tx-1);
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
box-shadow var(--t-base),
|
||||
border-color var(--t-base);
|
||||
}
|
||||
.tidy-btn:hover:not(:disabled) {
|
||||
border-color: var(--line-3);
|
||||
box-shadow: var(--sh-2);
|
||||
}
|
||||
.canvas-empty-hint {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
width: 380px;
|
||||
max-width: 100%;
|
||||
padding: 14px 18px;
|
||||
border-radius: var(--r-lg);
|
||||
text-align: center;
|
||||
color: var(--tx-2);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.canvas-empty-hint strong {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--tx-1);
|
||||
}
|
||||
/* Empty canvas title and instruction share the top edge: reserve a second row. */
|
||||
.flow-panel :global(.svelte-flow__panel.top.center) {
|
||||
margin-top: 70px;
|
||||
max-width: calc(100% - 28px);
|
||||
}
|
||||
.zoom-value {
|
||||
padding: 3px 0;
|
||||
margin-top:2px;
|
||||
border-top:1px solid var(--line);
|
||||
font: 10px var(--mono);
|
||||
color: var(--tx-3);
|
||||
text-align: center;
|
||||
}
|
||||
.chat-panel {
|
||||
flex-shrink: 0;
|
||||
border-left: 1px solid var(--border);
|
||||
background: var(--bg-surface);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
border-left: 1px solid var(--line);
|
||||
background: var(--bg-1);
|
||||
--chat-padding: 14px 12px;
|
||||
--chat-bubble-width:100%; --chat-bubble-font:13px; --chat-bubble-radius:12px;
|
||||
--chat-bubble-padding:9px 12px; --chat-agent-border-width:1px; --chat-agent-border:var(--line);
|
||||
--chat-tag-size:11px; --chat-tag-weight:400; --chat-tag-transform:none; --chat-tag-spacing:.4px;
|
||||
--chat-identity-shadow:none; --chat-dot-size:7px;
|
||||
--chat-user-bg:color-mix(in srgb,var(--gold) 10%,transparent);
|
||||
--chat-user-border:color-mix(in srgb,var(--gold) 25%,transparent);
|
||||
--id-1:var(--tx-1); --id-2:var(--tx-2); --id-3:var(--tx-3); --id-4:var(--tx-2); --id-5:var(--tx-3);
|
||||
--composer-send-bg: var(--grad-gold);
|
||||
--composer-box-bg: var(--well);
|
||||
--composer-padding: 10px 12px 12px;
|
||||
--composer-send-height: 32px;
|
||||
}
|
||||
.chat-splitter {
|
||||
width: 7px;
|
||||
flex-shrink: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: col-resize;
|
||||
margin-left: -3px;
|
||||
margin-right: -3px;
|
||||
margin: 0 -3px;
|
||||
z-index: 6;
|
||||
position: relative;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.chat-splitter:hover,
|
||||
.chat-splitter.dragging,
|
||||
.chat-splitter:focus-visible {
|
||||
background: color-mix(in srgb, var(--accent) 45%, transparent);
|
||||
background: color-mix(in srgb, var(--gold) 45%, transparent);
|
||||
outline: none;
|
||||
}
|
||||
.chat-splitter.dragging {
|
||||
/* Svelte Flow's pane captures pointer events while dragging near the
|
||||
graph edge — suppress text selection app-wide during the drag. */
|
||||
cursor: col-resize;
|
||||
}
|
||||
.chat-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-sm);
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 8px;
|
||||
height: 46px;
|
||||
padding: 0 12px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.chat-title-block {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
.chat-title {
|
||||
font-size: 13px;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
color: var(--tx-1);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-subtitle {
|
||||
font-size: 11px;
|
||||
color: var(--tx-3);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-title.muted {
|
||||
color: var(--text-muted);
|
||||
color: var(--tx-3);
|
||||
font-weight: 400;
|
||||
}
|
||||
.chat-toggle,
|
||||
@@ -1464,30 +1637,34 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-secondary);
|
||||
border-radius: var(--radius-sm);
|
||||
flex-shrink: 0;
|
||||
color: var(--tx-2);
|
||||
border-radius: var(--r-md);
|
||||
cursor: pointer;
|
||||
}
|
||||
.chat-toggle {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.chat-toggle:hover,
|
||||
.chat-expand:hover {
|
||||
color: var(--text-primary);
|
||||
border-color: var(--accent);
|
||||
color: var(--tx-1);
|
||||
}
|
||||
.chat-expand {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 12px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
position: absolute;
|
||||
right: 14px;
|
||||
top: 14px;
|
||||
z-index: 5;
|
||||
}
|
||||
/* ── ≤760px 可用级适配(F 批):解除 100vh 固定布局,画布与对话纵向堆叠。 ── */
|
||||
@media (max-width: 1280px) {
|
||||
.titlecard {
|
||||
height: 38px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.shell {
|
||||
height: auto;
|
||||
@@ -1502,7 +1679,7 @@
|
||||
}
|
||||
.chat-panel {
|
||||
width: 100% !important;
|
||||
border-left: none;
|
||||
border-left: 0;
|
||||
border-top: 1px solid var(--line);
|
||||
min-height: 50vh;
|
||||
}
|
||||
@@ -1510,34 +1687,4 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.flow-panel {
|
||||
background: #eae9e3;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 17px;
|
||||
margin: 20px 0 20px 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.workspace {
|
||||
background: var(--bg);
|
||||
}
|
||||
.titlecard {
|
||||
background: var(--surface);
|
||||
border-color: var(--line);
|
||||
box-shadow: 0 4px 12px #292a2d0a;
|
||||
}
|
||||
.chat-panel {
|
||||
margin: 20px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
background: var(--surface);
|
||||
}
|
||||
:global(.svelte-flow) {
|
||||
--xy-background-color-default: #eae9e3;
|
||||
--xy-background-pattern-color-default: #c8c9bc;
|
||||
--xy-edge-stroke-default: #a7b0e4;
|
||||
}
|
||||
.canvas-empty-hint {
|
||||
color: var(--text-3);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
color-scheme: dark;
|
||||
/* surfaces: ink black with a faint blue cast, never pure #000 */
|
||||
--board-bg: #0a0c12;
|
||||
--board-dot: rgb(var(--ink) / 0.11);
|
||||
--bg-0: #07080c;
|
||||
--bg-1: #0c0e14;
|
||||
--bg-2: #12151d;
|
||||
@@ -441,6 +443,8 @@
|
||||
--project-draft-shadow: none;
|
||||
--rail-active-shadow: none;
|
||||
color-scheme: light;
|
||||
--board-bg: #e6e0d3;
|
||||
--board-dot: rgb(var(--ink) / 0.16);
|
||||
--bg-0: #e9e4da;
|
||||
--bg-1: #f4f1ea;
|
||||
--bg-2: #fbf9f5;
|
||||
@@ -540,6 +544,8 @@
|
||||
--desk-filter-radius: 3px;
|
||||
--desk-connection-radius: 3px;
|
||||
color-scheme: dark;
|
||||
--board-bg: #1e1e21;
|
||||
--board-dot: rgb(var(--ink) / 0.12);
|
||||
--bg-0: #1b1b1c;
|
||||
--bg-1: #222223;
|
||||
--bg-2: #29292b;
|
||||
@@ -644,6 +650,8 @@
|
||||
--rail-nav-radius: 14px;
|
||||
--desk-head-bg: color-mix(in srgb, #0f1838 55%, transparent);
|
||||
color-scheme: dark;
|
||||
--board-bg: #0c1330;
|
||||
--board-dot: rgb(var(--ink) / 0.13);
|
||||
--bg-0: #0a1029;
|
||||
--bg-1: #0f1838;
|
||||
--bg-2: #162148;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# HEL-818 · 已批准四主题画布外观
|
||||
|
||||
继续原草稿 PR #12(远端 `agent/agent/8ec6e532b3ac`),本轮起点 `fe4759b788ea82747e1085f94cfe749756b08fb3`,base `leefer/hel-731-studio-project@2952af42b6232483640f1f27803980367cd62dd0`。HEL-801 的画布线程已明确批准;静态外观以 HEL-814 HTML/规范为依据,动效冲突按总管补充与 HEL-805 v3,不复制演示脚本。
|
||||
|
||||
- `static/themes.css` 仅新增四主题 `--board-bg` 与 `--board-dot` 八行;不改共享主题/三档动效状态机、滤镜和时序。
|
||||
- `canvas/[id]/+page.svelte` 合并重复样式,移除固定浅灰和 light 锁定。浮条、项目胶囊、空态、整理按钮、助手头和收展钮消费已有主题 token;默认助手 320px,小窗口 300px,保留手动宽度、视口、真实数据与已有操作。
|
||||
- `lib/canvas/canvas.css` 是两类卡片与 xyflow 画布控件的共同样式来源。实体 240、产物 220;媒体 132/124;统一玻璃缩放控件与 172×110 小地图;复用 `a-viewfinder`,选中及键盘焦点采用既有 −1→−3px 规则。
|
||||
- 两类卡片保留真实文件、视频首帧及预览回调,不放演示卡和示例标记。产物只在同一个 job 的 pending/running→done 时使用既有 `a-result-develop`(700/350ms),切档终态、历史不播、重复 done 不重播、点击跳过;运行状态静态显示。
|
||||
- `AgentChat` 通过有原值 fallback 的样式参数复用原有聊天组件;仅画布传入批准外观的尺寸/中性身份色。`AgentComposer` 增加 opt-in `primaryAction` 复用现成 `a-btn primary`,其它调用方保持原路径;会话轨在原组件中统一 48/240px 与 32px 按钮/6px 状态点。没有第二套对话、偏好或动效控件。
|
||||
|
||||
验证脚本 `e2e/run-hel818.py` 前台启动本 checkout 的一次性 SQLite 与假 ComfyUI/LLM,使用独立端口 18247/15173/19188/19189,不接触其它任务的服务。浏览器脚本交四主题×三窗口原图、运行时真实内容映射图、应用图、几何数值、显影逐帧和录屏。映射文件独立保存,原 HTML/批准图不改;不声称整页像素一致。退出前比对 multica daemon PID,只停自己的进程,并删除隔离库。
|
||||
|
||||
需要明确的差异:外壳顶栏保持既有 1px 边框几何;真实内容、项目/节点编号和默认视口不是演示排布。空态提示下移到画布内 70px,避开真实标题/项目操作(原样本两者同处 14px,长标题会相叠);此位置附图交最终视觉审核。输入提示误写技能、saved/Sandbox/建议和确认框硬编码英文继续列为已有问题,未顺手改文案。源码的既有删除快捷键是 Backspace,演示规范写成 Delete;本轮保留原键位,未增加交互。
|
||||
|
||||
前端 lint/check/test/build、画布相关后端隔离测试及浏览器最终记录见 HEL-818 附件。本轮后端代码零修改;HEL-812/817 的五项全量隔离失败仍按原版本基线保留,不新增忽略或跳过。原 HEL-813 审核证据仅属于旧头,最终集成审核需核本轮新头。未合并、部署或改线上配置/数据。
|
||||
|
||||
同状态画布比较明确采用离线字体条件:浏览器同时阻止应用和映射样本的 Google Fonts 请求,两者使用同机同字体栈的 fallback,数表保留 computed font;这不是产品字体来源调整,也不是联网字体一致性证明。原样图(未映射)单独保留,真实内容/节点位置/视口/视频首帧和会话文本只在测试运行 DOM 映射。
|
||||
|
||||
最终验证:前端 lint/check(0错误0警告)、test/build 通过;浏览器173/173通过、pageerror=0;画布相关后端隔离测试43通过(保留一项依赖弃用提示)。完整/克制四主题显影与三档主题切换共11组动画记录,四主题×三窗口12组比较。标题、实体/产物、缩放控件40×160、小地图172×110的同状态尺寸吻合,助手320/300;顶栏保留既有1px差异。点阵按样图保持屏幕26px网格/1px半径,抵消图形视口缩放;小地图保留10px内衬和按媒体种类的真实色块。
|
||||
|
||||
本轮未单独回归计划/推理面板的所有分支、完整档不支持ViewTransition浏览器的回退路径、联网字体及后端全量套件;相关实现保留既有版本,旧证据不冒充新头实测。浏览器操作覆盖框选、多选保护、Backspace删除、命名、项目解绑、缩放持久化、拖动、整理、助手收展/键盘调宽、图片/视频预览、上传保留、工作流/技能菜单、工具参数展开、引导与停止。
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Disposable canvas data. Only touches this checkout's isolated test database."""
|
||||
import json,sqlite3,urllib.request,subprocess,shutil
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
state=root/'e2e/shots/reference'
|
||||
def api(path,body=None,method=None):
|
||||
r=urllib.request.Request('http://127.0.0.1:18247'+path,data=json.dumps(body).encode() if body is not None else None,headers={'Content-Type':'application/json'},method=method or ('POST' if body is not None else 'GET'))
|
||||
with urllib.request.urlopen(r) as response:return json.load(response)
|
||||
settings=api('/api/settings');assert Path(settings['data_dir']).resolve()==(state/'data').resolve()
|
||||
project=api('/api/projects',{'title':'海岸纸船','idea':'隔离画布视觉与操作夹具'})
|
||||
session=api('/api/agent/sessions',{'title':'海岸纸船 · 故事板','project_id':project['id']})
|
||||
assets=state/'data/assets';assets.mkdir(exist_ok=True,parents=True)
|
||||
img=assets/'coast.jpg';shutil.copy(root/'calliope-web/static/refract/coast.jpg',img)
|
||||
video=assets/'coast.mp4'
|
||||
shutil.copy(root/'e2e/tiny.mp4',video)
|
||||
db=next((state/'data').glob('*.db'));conn=sqlite3.connect(db)
|
||||
for table,name,field in [('characters','小满 · 角色','sheet_path'),('locations','清晨海岸 · 场景','reference_image_path'),('items','旧纸船 · 道具','reference_image_path')]:conn.execute(f'INSERT INTO {table}(project_id,name,{field}) VALUES(?,?,?)',(project['id'],name,str(img.resolve())))
|
||||
for role,content,agent in [('user','请按当前项目素材整理画布。',None),('assistant','已将角色、场景和道具整理到画布。','main')]:conn.execute('INSERT INTO agent_messages(session_id,role,content,agent_name) VALUES(?,?,?,?)',(session['id'],role,content,agent))
|
||||
conn.commit()
|
||||
canvas=api('/api/canvas',{'project_id':project['id'],'title':'海岸纸船 · 灵感画布'})
|
||||
for node,(x,y) in zip(canvas['nodes'],[(40,84),(360,84),(656,130)]):api(f"/api/canvas/{canvas['canvas']['id']}/nodes/{node['id']}",{'x':x,'y':y},'PATCH')
|
||||
a=api(f"/api/canvas/{canvas['canvas']['id']}/nodes",{'type':'image','title':'镜头01 · 纸船入海','x':320,'y':330,'artifact_path':str(img.resolve()),'status':'done'})
|
||||
v=api(f"/api/canvas/{canvas['canvas']['id']}/nodes",{'type':'video','title':'片段 · 潮水退去','x':616,'y':348,'artifact_path':str(video.resolve()),'status':'running'})
|
||||
# Terminal job is held by the fixture, never queued for a worker. Lifecycle tests
|
||||
# explicitly patch this local row and publish canvas.updated via the real API.
|
||||
jid=conn.execute("INSERT INTO jobs(project_id,kind,status,output_paths_json) VALUES(?,'video','done',?)",(project['id'],json.dumps([str(video.resolve())]))).lastrowid
|
||||
conn.execute('UPDATE canvas_node SET job_id=? WHERE id=?',(jid,v['id']));conn.commit();conn.close()
|
||||
api(f"/api/canvas/{canvas['canvas']['id']}",{'viewport_json':json.dumps({'x':0,'y':0,'zoom':.8})},'PATCH')
|
||||
emptySession=api('/api/agent/sessions',{'title':'空白画布隔离会话'});empty=api('/api/canvas',{'agent_session_id':emptySession['id']})
|
||||
(state/'canvas818.json').write_text(json.dumps({'project':project,'session':session,'canvas':canvas['canvas'],'artifact':a,'video':v,'job':jid,'empty':empty['canvas'],'image':str(img.resolve()),'db':str(db.resolve())}))
|
||||
print('SEEDED HEL818',canvas['canvas']['id'])
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Render evidence comparisons and a numeric table from captured browser results."""
|
||||
import json,csv,hashlib
|
||||
from pathlib import Path
|
||||
from PIL import Image,ImageDraw,ImageFont
|
||||
out=Path('../evidence/hel818');data=json.loads((out/'results.json').read_text())
|
||||
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',20)
|
||||
comparisons=out/'comparisons';comparisons.mkdir(exist_ok=True)
|
||||
thumbs=[]
|
||||
for row in data['geometry']:
|
||||
theme,width,height=row['id'],row['width'],row['height']
|
||||
left=Image.open(out/f'shots/reference-mapped-{theme}-{width}.png').convert('RGB');right=Image.open(out/f'shots/app-{theme}-{width}.png').convert('RGB')
|
||||
im=Image.new('RGB',(width*2,height+44),'#202127');draw=ImageDraw.Draw(im);draw.text((12,10),f'Approved sample + real data/state mapping | {theme} {width}x{height}',font=font,fill='white');draw.text((width+12,10),'Application | same data/state | offline font condition',font=font,fill='white');im.paste(left,(0,44));im.paste(right,(width,44));im.save(comparisons/f'compare-{theme}-{width}.png');im.thumbnail((960,350));thumbs.append(im.copy())
|
||||
# Rows follow viewport-major browser capture order, keeping labels visible.
|
||||
overview=Image.new('RGB',(1920,350*((len(thumbs)+1)//2)),'#202127')
|
||||
for i,im in enumerate(thumbs):overview.paste(im,((i%2)*960,(i//2)*350))
|
||||
overview.save(out/'comparison-overview.png')
|
||||
with (out/'geometry.csv').open('w',newline='') as f:
|
||||
w=csv.writer(f);w.writerow(['theme','viewport','component','app_x','app_y','app_width','app_height','reference_x','reference_y','reference_width','reference_height','delta_width','delta_height','app_font','reference_font','app_bg','reference_bg','app_border','reference_border','app_radius','reference_radius'])
|
||||
for row in data['geometry']:
|
||||
for key,a in row['actual'].items():
|
||||
b=row['reference'][key]
|
||||
w.writerow([row['id'],row['width'],key,a['x'],a['y'],a['width'],a['height'],b['x'],b['y'],b['width'],b['height'],a['width']-b['width'],a['height']-b['height'],a['font'],b['font'],a['bg'],b['bg'],a['border'],b['border'],a['radius'],b['radius']])
|
||||
references=Path('../references')
|
||||
(out/'reference-sha256.json').write_text(json.dumps({p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in references.iterdir() if p.is_file()},ensure_ascii=False,indent=2))
|
||||
print('BROWSER CHECKS',len(data['checks']),'PASS',sum(bool(x['pass']) for x in data['checks']),'ERRORS',len(data['errors']))
|
||||
print('ANIMATION RECORDS',len(data['animations']))
|
||||
for row in data['geometry']:
|
||||
if row['id']=='night':print('GEOMETRY',row['width'],{k:[row['actual'][k]['width'],row['actual'][k]['height'],row['reference'][k]['width'],row['reference'][k]['height']] for k in ['title','controls','minimap','chat','entity','artifact']})
|
||||
@@ -0,0 +1,8 @@
|
||||
// Test-only static build server. Every API request goes to our isolated API.
|
||||
const http=require('node:http'),fs=require('node:fs'),path=require('node:path');
|
||||
const build=path.resolve('calliope-web/build');
|
||||
http.createServer((req,res)=>{
|
||||
if(req.url.startsWith('/api/')||req.url.startsWith('/assets/')){const q=http.request('http://127.0.0.1:18247'+req.url,{method:req.method,headers:req.headers},r=>{res.writeHead(r.statusCode,r.headers);r.pipe(res)});q.on('error',()=>{res.statusCode=502;res.end()});res.on('close',()=>q.destroy());req.pipe(q);return}
|
||||
let file=path.join(build,new URL(req.url,'http://localhost').pathname);if(!fs.existsSync(file)||fs.statSync(file).isDirectory())file=path.join(build,'index.html');
|
||||
res.setHeader('Content-Type',({'.js':'text/javascript','.css':'text/css','.html':'text/html','.png':'image/png','.jpg':'image/jpeg','.woff2':'font/woff2','.svg':'image/svg+xml'})[path.extname(file)]||'application/octet-stream');fs.createReadStream(file).pipe(res);
|
||||
}).listen(15173,'127.0.0.1');
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH||'playwright');
|
||||
const fs=require('node:fs'),assert=require('node:assert/strict'),http=require('node:http'),cp=require('node:child_process');
|
||||
const OUT='../evidence/hel818',WEB='http://127.0.0.1:15173',API='http://127.0.0.1:18247';
|
||||
fs.mkdirSync(OUT+'/shots',{recursive:true});
|
||||
const report={checks:[],geometry:[],errors:[],animations:[],differences:[]};
|
||||
const ok=(name,value)=>{report.checks.push({name,pass:!!value});assert(value,name);console.log('PASS',name)};
|
||||
const wait=ms=>new Promise(r=>setTimeout(r,ms));
|
||||
const api=async(p,body,method)=>{const r=await fetch(API+p,{method:method||(body?'POST':'GET'),headers:{'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined});assert(r.ok,p+' '+await r.clone().text());const text=await r.text();return text?JSON.parse(text):null};
|
||||
const geom=(p,selectors)=>p.evaluate(selectors=>Object.fromEntries(Object.entries(selectors).map(([k,sel])=>{const e=document.querySelector(sel);if(!e)return[k,null];const r=e.getBoundingClientRect(),s=getComputedStyle(e);return[k,{x:r.x,y:r.y,width:r.width,height:r.height,font:s.font,color:s.color,bg:s.backgroundColor,border:s.border,shadow:s.boxShadow,radius:s.borderRadius}]})),selectors);
|
||||
const mode=async(p,name)=>{await p.locator('.sidebar-bottom button[title="主题"]').click();await p.locator('.theme-motion').getByRole('button',{name,exact:true}).click();await p.keyboard.press('Escape');await wait(50)};
|
||||
const theme=async(p,id)=>{await p.evaluate(id=>{document.documentElement.dataset.theme=id;window.dispatchEvent(new StorageEvent('storage',{key:'aigc-theme',newValue:id}))},id);await wait(100)};
|
||||
(async()=>{
|
||||
cp.execFileSync(process.env.HEL732_PYTHON||'python3',['e2e/hel818-fixture.py'],{stdio:'inherit'});
|
||||
const f=JSON.parse(fs.readFileSync('e2e/shots/reference/canvas818.json'));
|
||||
const server=http.createServer((req,res)=>{res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fs.readFileSync('../references/canvas-sample.html'))});await new Promise(r=>server.listen(0,'127.0.0.1',r));
|
||||
const browser=await chromium.launch({args:['--no-sandbox','--disable-dev-shm-usage']});
|
||||
try{
|
||||
const ctx=await browser.newContext({viewport:{width:1440,height:900},recordVideo:{dir:OUT+'/recordings'}});
|
||||
await ctx.route('https://fonts.googleapis.com/**',r=>r.abort());await ctx.route('https://fonts.gstatic.com/**',r=>r.abort());report.fontNetwork='Both app and reference use the same offline fallback fonts; product font sources unchanged.';
|
||||
await ctx.addInitScript(()=>{if(!localStorage.getItem('calliope.canvas.viewport.1'))localStorage.setItem('calliope.canvas.viewport.1',JSON.stringify({x:0,y:0,zoom:.8}));localStorage.setItem('aigc-lang','zh');if(!localStorage.getItem('aigc-motion'))localStorage.setItem('aigc-motion','off');window.vtCalls=0;const vt=document.startViewTransition?.bind(document);if(vt)document.startViewTransition=(...args)=>{window.vtCalls++;return vt(...args)}});
|
||||
const p=await ctx.newPage();p.setDefaultTimeout(12000);p.on('pageerror',e=>report.errors.push(e.stack));
|
||||
await p.goto(WEB+'/canvas/'+f.canvas.id+'?session='+f.session.id);await p.locator('.canvas-card').first().waitFor();await wait(700);
|
||||
await p.locator('.artifact-node header').first().click();await p.mouse.move(5,5);await p.screenshot({path:OUT+'/shots/initial.png'});
|
||||
ok('five real cards loaded',await p.locator('.canvas-card').count()===5);
|
||||
ok('real image files loaded',await p.locator('.canvas-card img').evaluateAll(es=>es.every(e=>e.complete&&e.naturalWidth>0)));
|
||||
ok('video first frame without autoplay',await p.locator('.canvas-card video').evaluate(e=>e.paused&&e.readyState>=2));
|
||||
const sample=await ctx.newPage();
|
||||
for(const [width,height] of [[1440,900],[1366,768],[1280,720]])for(const id of ['night','day','grade','bluehour']){
|
||||
await p.setViewportSize({width,height});await theme(p,id);await wait(100);
|
||||
await sample.setViewportSize({width,height});await sample.goto('http://127.0.0.1:'+server.address().port+'/?theme='+id+'&chrome=0');await wait(150);
|
||||
await sample.screenshot({path:`${OUT}/shots/reference-original-${id}-${width}.png`});
|
||||
// Runtime-only data/state mapping: source HTML and its CSS stay untouched.
|
||||
const mapping=await p.evaluate(()=>{const board=document.querySelector('.flow-panel').getBoundingClientRect();return {title:document.querySelector('.title-btn').textContent,cards:[...document.querySelectorAll('.canvas-card')].map(e=>{const r=e.getBoundingClientRect(),m=e.querySelector('.media');return {title:e.querySelector('.title').textContent,foot:e.querySelector('footer').innerText,kind:e.dataset.kind,x:r.x-board.x,y:r.y-board.y,scale:r.width/parseFloat(getComputedStyle(e).width),image:m.querySelector('img')?.src,selected:e.classList.contains('a-in-frame'),status:e.querySelector('.status')?.textContent||''}}),messages:[...document.querySelectorAll('.chat-panel .row')].filter(e=>e.matches('.user,.assistant')).map(e=>({user:e.classList.contains('user'),name:e.querySelector('.agent-tag')?.innerText,text:e.querySelector('.bubble')?.innerText}))}});
|
||||
const frame=await p.locator('.canvas-card video').screenshot();mapping.video='data:image/png;base64,'+frame.toString('base64');
|
||||
await sample.evaluate(mapping=>{
|
||||
document.querySelector('.demo-badge').remove();document.querySelector('.titlecard .saved').remove();document.querySelector('.tname').firstChild.nodeValue=mapping.title.trim();
|
||||
document.querySelectorAll('.card').forEach((e,i)=>{const d=mapping.cards[i];e.classList.toggle('sel',d.selected);e.classList.toggle('on',d.selected);e.classList.remove('running');e.style.setProperty('left',d.x+'px','important');e.style.setProperty('top',d.y+'px','important');e.style.transform='scale('+d.scale+')';e.style.transformOrigin='top left';e.querySelector('.t').textContent=d.title;const m=e.querySelector('.media');m.replaceChildren();const img=document.createElement('img');img.src=d.image||mapping.video;img.style.cssText='display:block;width:100%;height:100%;object-fit:cover';m.append(img);const badge=document.createElement('span');badge.className='kind';badge.textContent=d.kind==='video'?'video':'image';m.append(badge);const foot=e.querySelector('.cfoot');foot.replaceChildren();const left=document.createElement('span');left.textContent=d.foot.replace(/\s*#\d+$/,'');const grow=document.createElement('span');grow.className='grow';const number=document.createElement('span');number.className='mono';number.textContent=d.foot.match(/#\d+$/)?.[0]||'';foot.append(left,grow,number);const chip=e.querySelector('.chead .pill');if(chip)chip.textContent=d.kind;});
|
||||
const body=document.querySelector('.chat-body');body.replaceChildren();for(const d of mapping.messages){const row=document.createElement('div');row.className='msg '+(d.user?'me':'ai');const wrap=document.createElement('div');if(!d.user){const tag=document.createElement('div');tag.className='agent-tag';tag.textContent=d.name;wrap.append(tag)}const b=document.createElement('div');b.className='bub';b.textContent=d.text;wrap.append(b);row.append(wrap);body.append(row)}
|
||||
},mapping);await wait(50);
|
||||
fs.writeFileSync(`${OUT}/mapping-${id}-${width}.json`,JSON.stringify(mapping,null,2));
|
||||
const actual=await geom(p,{board:'.flow-panel',title:'.titlecard',controls:'.svelte-flow__controls',minimap:'.svelte-flow__minimap',chat:'.chat-panel',head:'.chat-head',entity:'.entity-node',artifact:'.artifact-node',media:'.entity-node .media'});
|
||||
const reference=await geom(sample,{board:'.board-wrap',title:'.titlecard',controls:'.ctl',minimap:'.minimap',chat:'.chat',head:'.chat-head',entity:'.card.entity',artifact:'.card.artifact',media:'.card.entity .media'});
|
||||
report.geometry.push({id,width,height,actual,reference});
|
||||
ok(id+' '+width+' 26px grid and 1px dot radius',await p.locator('.svelte-flow__background').evaluate(e=>Math.abs(parseFloat(e.querySelector('pattern').getAttribute('width'))-26)<.01&&Math.abs(parseFloat(e.querySelector('circle').getAttribute('r'))-1)<.01));
|
||||
ok(id+' '+width+' no document overflow',await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth));
|
||||
for(const sel of ['.titlecard','.tidy-btn','.svelte-flow__controls','.svelte-flow__minimap','.chat-head','.composer button.primary'])ok(id+' '+width+' '+sel+' reachable',await p.locator(sel).evaluate(e=>{const r=e.getBoundingClientRect();return r.x>=0&&r.y>=0&&r.right<=innerWidth&&r.bottom<=innerHeight}));
|
||||
ok(id+' '+width+' board matches token',actual.board.bg===({night:'rgb(10, 12, 18)',day:'rgb(230, 224, 211)',grade:'rgb(30, 30, 33)',bluehour:'rgb(12, 19, 48)'}[id]));
|
||||
await p.screenshot({path:`${OUT}/shots/app-${id}-${width}.png`});
|
||||
await sample.screenshot({path:`${OUT}/shots/reference-mapped-${id}-${width}.png`});
|
||||
}
|
||||
await sample.close();
|
||||
|
||||
// Box selection and guarded delete use the real graph interaction.
|
||||
await p.setViewportSize({width:1440,height:900});await wait(200);const area=await p.locator('.flow-panel').boundingBox();
|
||||
await p.keyboard.down('Shift');await p.mouse.move(area.x+12,area.y+62);await p.mouse.down();await p.mouse.move(area.x+area.width-190,area.y+510,{steps:12});await p.mouse.up();await p.keyboard.up('Shift');
|
||||
ok('box selection selects multiple cards',await p.locator('.svelte-flow__node.selected').count()>=2);await p.keyboard.press('Backspace');await wait(150);ok('project entity delete is protected',(await api('/api/canvas/'+f.canvas.id)).nodes.length===5);
|
||||
const temporary=await api('/api/canvas/'+f.canvas.id+'/nodes',{type:'image',title:'可删除的隔离产物',artifact_path:f.image,status:'done',x:10,y:540});await p.locator('[data-id="cn-'+temporary.id+'"] header').waitFor();await p.locator('.svelte-flow__pane').click({position:{x:20,y:450}});await p.locator('[data-id="cn-'+temporary.id+'"] header').click();await p.locator('[data-id="cn-'+temporary.id+'"]').focus();ok('delete targets only the temporary artifact',await p.locator('.svelte-flow__node.selected').count()===1);await p.keyboard.press('Backspace');await wait(250);ok('unprotected artifact deletes through real API',!(await api('/api/canvas/'+f.canvas.id)).nodes.some(n=>n.id===temporary.id));
|
||||
const cw=await p.locator('.chat-panel').evaluate(e=>e.getBoundingClientRect().width);await p.locator('.chat-splitter').focus();await p.keyboard.press('ArrowLeft');await wait(100);report.resize={before:cw,after:await p.locator('.chat-panel').evaluate(e=>({width:e.getBoundingClientRect().width,style:e.getAttribute('style')}))};ok('assistant keyboard resizing works',await p.locator('.chat-panel').evaluate(e=>e.getBoundingClientRect().width)>cw);await p.keyboard.press('ArrowRight');
|
||||
// Rename, editing and theme/mode changes preserve live DOM and view state.
|
||||
await p.setViewportSize({width:1440,height:900});await theme(p,'night');
|
||||
await p.locator('.title-btn').click();await p.locator('.title-input').fill('HEL818 画布命名');await p.locator('.title-input').press('Enter');await wait(250);
|
||||
ok('rename persisted',(await api('/api/canvas/'+f.canvas.id)).canvas.title==='HEL818 画布命名');
|
||||
const editor=p.locator('.composer .editor');await editor.fill('尚未发送的画布输入');await editor.evaluate(e=>window.keptEditor=e);
|
||||
const before=await api('/api/canvas/'+f.canvas.id);
|
||||
await mode(p,'克制');await theme(p,'day');await mode(p,'完整');await theme(p,'grade');await mode(p,'关闭');
|
||||
ok('theme and modes preserve input DOM/value',await editor.evaluate(e=>e===window.keptEditor&&e.innerText==='尚未发送的画布输入'));
|
||||
const after=await api('/api/canvas/'+f.canvas.id);ok('theme and modes preserve card/project/viewport state',JSON.stringify(before)===JSON.stringify(after));
|
||||
|
||||
for(const label of ['完整','克制','关闭']){
|
||||
await mode(p,label);const before=await p.evaluate(()=>window.vtCalls);await p.locator('.sidebar-bottom button[title="主题"]').click();const next=(await p.locator('html').getAttribute('data-theme'))==='day'?'夜片场':'日光棚';await p.locator('.choices.compact .choice').filter({hasText:next}).click();await wait(30);
|
||||
const transition=await p.evaluate(()=>({vtCalls:window.vtCalls,classes:document.documentElement.className,circular:getComputedStyle(document.documentElement).getPropertyValue('--theme-reveal-duration').trim(),fallback:getComputedStyle(document.documentElement).getPropertyValue('--theme-fallback-duration').trim()}));report.animations.push({theme:label,...transition});ok(label+' approved theme transition',label==='完整'?transition.vtCalls>before&&transition.circular==='520ms':label==='克制'?transition.vtCalls===before&&transition.classes.includes('theme-anim')&&transition.fallback==='280ms':transition.vtCalls===before&&!transition.classes.includes('theme-anim'));await wait(550);await p.keyboard.press('Escape');ok(label+' theme UI preserves editor',await editor.evaluate(e=>e===window.keptEditor&&e.innerText==='尚未发送的画布输入'));
|
||||
}
|
||||
// Zoom/pan and persistence, lock and tidy still use real controls/API.
|
||||
await p.locator('.svelte-flow__controls-zoomin').click();await wait(600);const zoomed=(await api('/api/canvas/'+f.canvas.id)).canvas.viewport_json;
|
||||
ok('zoom persists viewport',JSON.parse(zoomed).zoom>.8);
|
||||
await p.reload();await p.locator('.canvas-card').first().waitFor();await wait(350);ok('viewport survives reload',(await p.locator('.zoom-value').innerText())===Math.round(JSON.parse(zoomed).zoom*100)+'%');
|
||||
await p.locator('.svelte-flow__controls-interactive').click();ok('lock toggles interactivity',await p.locator('.svelte-flow__node.draggable').count()===0);await p.locator('.svelte-flow__controls-interactive').click();
|
||||
await p.locator('.svelte-flow__controls-fitview').click();await wait(300);
|
||||
const card=p.locator('.entity-node').first();await card.click();await wait(100);ok('entity opens preview',await p.locator('.lightbox').count()>0||await p.getByRole('dialog').count()>0);await p.keyboard.press('Escape');await p.locator('.artifact-node[data-kind=video] .media-btn').click();ok('video card opens preview without inline autoplay',await p.getByRole('dialog').count()>0||await p.locator('.lightbox').count()>0);await p.keyboard.press('Escape');
|
||||
const box=await card.boundingBox();await p.mouse.move(box.x+60,box.y+18);await p.mouse.down();await p.mouse.move(box.x+100,box.y+50,{steps:8});await p.mouse.up();await wait(400);
|
||||
ok('drag persists real coordinates',(await api('/api/canvas/'+f.canvas.id)).nodes.some(n=>n.type==='entity'&&n.x!==40&&n.x!==360&&n.x!==656));
|
||||
await p.locator('.tidy-btn').click();await wait(450);ok('tidy remains usable',await p.locator('.canvas-card').count()===5);
|
||||
await p.locator('.chat-toggle').click();await wait(100);ok('assistant collapses',await p.locator('.chat-panel').count()===0);await theme(p,'night');await p.screenshot({path:OUT+'/shots/collapsed.png'});await p.locator('.chat-expand').click();
|
||||
ok('assistant expands',await editor.count()===1);
|
||||
await p.goto(WEB+'/canvas/'+f.empty.id);await p.locator('.canvas-empty-hint').waitFor();await wait(150);ok('real empty canvas has zero fake cards',await p.locator('.canvas-card').count()===0);await theme(p,'night');await p.screenshot({path:OUT+'/shots/empty-night.png'});await theme(p,'day');await p.screenshot({path:OUT+'/shots/empty-day.png'});
|
||||
|
||||
// Upload, workflow and skill menus keep their existing real behavior.
|
||||
const input=p.locator('.composer .editor');await input.fill('@Qwen');await input.press('End');await input.press('n');await p.locator('.mention-menu').waitFor();ok('workflow menu remains usable',await p.getByRole('option').count()>0);await p.keyboard.press('Escape');await input.fill('/');await input.press('End');await input.press('h');await p.locator('.mention-menu').waitFor();ok('skill menu remains usable',await p.getByRole('option').count()>0);await p.keyboard.press('Escape');await input.fill('未发送的附件与编辑状态');
|
||||
await p.locator('input[type=file]').setInputFiles(f.image);await p.locator('.tile:not(.uploading)').waitFor();await input.evaluate(e=>window.uploadEditor=e);const tiles=await p.locator('.tile').count();await mode(p,'克制');await theme(p,'grade');ok('theme/motion preserve uploaded attachments and editor',await p.locator('.tile').count()===tiles&&await input.evaluate(e=>e===window.uploadEditor&&e.innerText.includes('未发送')));
|
||||
// Run only against our fake ComfyUI, capturing real pending/running -> done.
|
||||
const workflows=JSON.parse(fs.readFileSync('e2e/shots/reference/fixtures.json'));
|
||||
await p.evaluate(()=>{window.canvasAnimations=[];document.addEventListener('animationstart',e=>{if(e.animationName.startsWith('a-develop')&&e.target.closest('.canvas-card')){const a=e.target.getAnimations()[0];a.pause();a.currentTime=0;window.canvasAnimations.push({name:e.animationName,duration:a.effect.getTiming().duration,frames:a.effect.getKeyframes()})}},true)});
|
||||
for(const [label,id] of [['完整','night'],['完整','day'],['完整','grade'],['完整','bluehour'],['克制','night'],['克制','day'],['克制','grade'],['克制','bluehour'],['关闭','night']]){
|
||||
const animationCount=await p.evaluate(()=>window.canvasAnimations.length);await mode(p,label);await theme(p,id);fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',delay_sec:1,unique_filename:true,image_file:f.image}));
|
||||
const created=await api('/api/playground/generate',{workflow_id:workflows.dual,input_values:{prompt:'HEL818 isolated canvas arrival',negative:'',seed:42}});
|
||||
const n=await api('/api/canvas/'+f.empty.id+'/nodes',{type:'image',title:'当前隔离任务 '+created.job.id,job_id:created.job.id,artifact_path:f.image,status:'running',x:80,y:160});
|
||||
await p.waitForFunction(()=>document.querySelector('.running-badge'));
|
||||
await p.waitForFunction(id=>!document.querySelector('[data-id="cn-'+id+'"] .running-badge'),n.id,{timeout:30000});
|
||||
const node=p.locator('[data-id="cn-'+n.id+'"]');
|
||||
if(label==='关闭'){ok('off has no arrival replay',await node.locator('.a-result-develop').count()===0)}else{
|
||||
await node.locator('.a-result-develop').waitFor();await p.waitForFunction(count=>window.canvasAnimations.length>count,animationCount);const data=await p.evaluate(()=>window.canvasAnimations.at(-1));report.animations.push({label,id,...data});ok(label+' '+id+' correct reveal duration',data.duration===(label==='完整'?700:350));
|
||||
await p.screenshot({path:`${OUT}/shots/reveal-${label}-${id}-000.png`});await node.locator('.media-el').evaluate(e=>e.getAnimations()[0].currentTime=e.getAnimations()[0].effect.getTiming().duration/2);await p.screenshot({path:`${OUT}/shots/reveal-${label}-${id}-mid.png`});
|
||||
await node.locator('.media-btn').dispatchEvent('pointerdown');ok(label+' '+id+' click skips reveal',await node.locator('.a-result-develop').count()===0);
|
||||
}
|
||||
await theme(p,id==='day'?'night':'day');ok(label+' '+id+' theme does not replay',await node.locator('.a-result-develop').count()===0);
|
||||
}
|
||||
await p.reload();await p.locator('.canvas-card').first().waitFor();ok('history does not replay reveal',await p.locator('.a-result-develop').count()===0);
|
||||
await p.emulateMedia({reducedMotion:'reduce'});await wait(100);ok('OS reduced motion forces off',await p.locator('html').getAttribute('data-motion')==='off');await p.emulateMedia({reducedMotion:'no-preference'});
|
||||
|
||||
// Real chat/tool execution and cancellation against the loopback fake model.
|
||||
fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',agent_delay:0}));await p.locator('.composer .editor').fill('请查看画布项目素材');await p.locator('.composer button.primary').click();await p.locator('.chat-panel .tool-card').first().waitFor();await p.locator('.chat-panel .tool-card .head').first().click();ok('real tool parameters expand',await p.locator('.chat-panel .tool-card .head').first().getAttribute('aria-expanded')==='true');await p.waitForFunction(()=>!document.querySelector('.composer .stop'),null,{timeout:30000});
|
||||
fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',agent_delay:3}));await p.locator('.composer .editor').fill('请继续整理');await p.locator('.composer button.primary').click();await p.locator('.composer .stop').waitFor();await p.locator('.composer .editor').fill('调整为近景');await p.locator('.composer button.primary').click();await p.locator('.user-bubble').filter({hasText:'调整为近景'}).waitFor();ok('running chat accepts guidance',true);await p.locator('.composer .stop').click();await p.waitForFunction(()=>!document.querySelector('.composer .stop'),null,{timeout:30000});ok('stop cancels real isolated agent run',true);
|
||||
// Unlink uses the existing confirmation and leaves the project intact.
|
||||
await p.goto(WEB+'/canvas/'+f.canvas.id+'?session='+f.session.id);await p.locator('.unlink-btn').waitFor();p.once('dialog',d=>d.accept());await p.locator('.unlink-btn').click();await p.waitForURL(u=>!u.pathname.endsWith('/'+f.canvas.id));ok('unlink preserves project and session history',(await api('/api/projects/'+f.project.id)).id===f.project.id&&(await api('/api/agent/sessions/'+f.session.id)).project_id===null);
|
||||
await p.goto(WEB+'/build-scene');await p.locator('.composer .editor').waitFor();ok('shared composer retains original default button',await p.locator('.composer button.send:not(.stop)').count()===1);await p.screenshot({path:OUT+'/shots/shared-build-scene.png'});
|
||||
await ctx.close();
|
||||
const blocked=await browser.newContext({viewport:{width:1280,height:720}});await blocked.addInitScript(()=>{Storage.prototype.getItem=()=>{throw new DOMException('blocked')};Storage.prototype.setItem=()=>{throw new DOMException('blocked')}});const q=await blocked.newPage();q.on('pageerror',e=>report.errors.push(e.stack));await q.goto(WEB+'/canvas/'+f.canvas.id);await q.locator('.canvas-card').first().waitFor();ok('storage unavailable still renders real canvas',await q.locator('.canvas-card').count()===5);await q.screenshot({path:OUT+'/shots/storage-blocked.png'});await blocked.close();
|
||||
|
||||
ok('no page errors',report.errors.length===0);
|
||||
}finally{fs.writeFileSync(OUT+'/results.json',JSON.stringify(report,null,2));await browser.close();await new Promise(r=>server.close(r))}
|
||||
})().catch(e=>{console.error(e);process.exitCode=1});
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Foreground isolated stack with task-local ports; owns and cleans exact children."""
|
||||
import os,signal,socket,subprocess,time,urllib.request,json,shutil
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parents[1];os.chdir(root)
|
||||
py=os.environ['HEL732_PYTHON'];env=os.environ.copy();env['PYTHONPATH']=str(root/'calliope-backend/src')
|
||||
logs=root.parent/'evidence/hel818/logs';logs.mkdir(parents=True,exist_ok=True)
|
||||
state=root/'e2e/shots/reference';assert not state.exists(),'Preserve unexpected test data'
|
||||
ports=[18247,15173,19188,19189]
|
||||
for port in ports:
|
||||
with socket.socket() as s:assert s.connect_ex(('127.0.0.1',port))!=0,f'port {port} is busy'
|
||||
processes=[];handles=[];mode=root/'e2e/fake_mode.json';saved=mode.read_bytes() if mode.exists() else None
|
||||
code="""from pathlib import Path
|
||||
from calliope import config
|
||||
root=Path('e2e/shots/reference').resolve();root.mkdir(parents=True)
|
||||
config.CONFIG_FILE=root/'settings.json'
|
||||
config.settings=config.Settings(data_dir=root/'data',assets_dir=root/'data/assets',llm_base_url='http://127.0.0.1:19189/v1',llm_model='reference-test',comfyui_base_url='http://127.0.0.1:19188',dry_run=False)
|
||||
config.settings.ensure_storage_dirs();config.settings.ensure_llm_profiles();config.settings.save_config_file()
|
||||
from calliope.main import create_app
|
||||
import uvicorn
|
||||
uvicorn.run(create_app(),host='127.0.0.1',port=18247)
|
||||
"""
|
||||
try:
|
||||
commands=[('api',[py,'-c',code]),('comfy',[py,'-c',(root/'e2e/fake_comfy.py').read_text().replace('18188','19188').replace('Path(__file__).parent', 'Path('+repr(str(root/'e2e'))+')')]),('llm',[py,'-c',(root/'e2e/fake_agent_b4.py').read_text().replace('18189','19189').replace('import json', 'import json,time').replace(" msgs=payload.get", " time.sleep(json.loads(Path('e2e/fake_mode.json').read_text()).get('agent_delay',0) if Path('e2e/fake_mode.json').exists() else 0)\n msgs=payload.get")]),('web',['npm','--prefix','calliope-web','run','preview','--','--host','127.0.0.1','--port','15173','--strictPort'])]
|
||||
# preview proxy is fixed at 8247; use an owned HTTP proxy at a dynamic port
|
||||
# in front of static build, forwarding API to the task's isolated backend.
|
||||
commands[-1]=('web',['node','e2e/hel818-web.cjs'])
|
||||
for name,cmd in commands:
|
||||
h=open(logs/(name+'.log'),'w');handles.append(h);processes.append(subprocess.Popen(cmd,stdout=h,stderr=subprocess.STDOUT,env=env,start_new_session=True))
|
||||
for url in ['http://127.0.0.1:18247/api/health','http://127.0.0.1:15173']:
|
||||
for i in range(100):
|
||||
try:urllib.request.urlopen(url,timeout=2);break
|
||||
except Exception:
|
||||
if any(p.poll() is not None for p in processes):raise RuntimeError('service failed; see logs')
|
||||
if i==99:raise
|
||||
time.sleep(.2)
|
||||
for name in ['reference/seed.py']:
|
||||
seed=(root/'e2e'/name).read_text().replace('8247','18247').replace('18188','19188').replace('18189','19189')
|
||||
seed=seed.replace('Path(__file__).resolve().parents[1]',repr(root/'e2e')) if name=='reference/seed.py' else seed
|
||||
if name=='reference/seed.py':seed=seed.replace(repr(root/'e2e'),"Path("+repr(str(root/'e2e'))+")")
|
||||
subprocess.run([py,'-c',seed],env=env,check=True)
|
||||
subprocess.run(['node','e2e/hel818.cjs'],env=env,check=True)
|
||||
finally:
|
||||
daemon=json.loads(subprocess.check_output(['multica','daemon','status','--output','json']))['pid'];assert all(p.pid!=daemon for p in processes)
|
||||
for p in processes:
|
||||
if p.poll() is None:os.killpg(p.pid,signal.SIGTERM)
|
||||
for p in processes:
|
||||
try:p.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:os.killpg(p.pid,signal.SIGKILL);p.wait()
|
||||
print('STOPPED OWN CHILDREN',[(p.pid,p.returncode) for p in processes],flush=True)
|
||||
for h in handles:h.close()
|
||||
if state.exists():shutil.rmtree(state)
|
||||
if saved is None:
|
||||
if mode.exists():mode.unlink()
|
||||
else:mode.write_bytes(saved)
|
||||
Reference in New Issue
Block a user