refactor(HEL-752): remove unused locals while preserving evaluation and props

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-22 02:16:48 +08:00
co-authored by multica-agent
parent 3d1c4ca5af
commit bfcf542e59
18 changed files with 17 additions and 90 deletions
@@ -18,7 +18,7 @@
import { createUploadManager } from '$lib/comfy/useUpload.svelte';
import { normalizeInputRole } from '$lib/comfy/parser';
import type { AssetOption } from '$lib/assetPicker';
import { assetUrl } from '$lib/api';
import '$lib/api';
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
import PillSelect from './omni/PillSelect.svelte';
@@ -48,7 +48,7 @@
onchanged,
}: Props = $props();
const client = useQueryClient();
useQueryClient();
let endpointId = $state('');
let values = $state<Record<string, string | number>>({});
@@ -146,7 +146,7 @@
if (stageLog[stageLog.length - 1] !== line) stageLog = [...stageLog, line];
});
$effect(() => {
stageLog.length;
void stageLog.length;
if (logBox) logBox.scrollTop = logBox.scrollHeight;
});
@@ -71,13 +71,8 @@
job,
wf,
nowMs,
open,
inactive,
canSendToSlot,
crossfade,
videoEl = $bindable(null),
params,
onClose,
onReuse,
onRetry,
onCancel,
@@ -119,7 +114,6 @@
const output = $derived(
outputs[Math.min(outIndex, outputs.length - 1)] ?? null,
);
const allOutputs = $derived(job && st?.tone === 'ok' ? job.output_paths : []);
const video = $derived(!!job && !!output && isVideoOutput(job, output));
const wfDeleted = $derived(!!job && job.workflow_id == null);
const prompt = $derived(job ? promptOf(job, wf) : '');
@@ -8,7 +8,7 @@
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
import { page } from '$app/state';
import { goto } from '$app/navigation';
import Icon from '$lib/components/ui/Icon.svelte';
import '$lib/components/ui/Icon.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import AppShell from '$lib/components/shell/AppShell.svelte';
import Composer from '$lib/components/generate/Composer.svelte';
@@ -39,7 +39,7 @@
workbenchCtxOf,
type FeedFilter,
} from '$lib/components/generate/takes';
import InputRequirementBadge from './InputRequirementBadge.svelte';
import './InputRequirementBadge.svelte';
import WorkflowBay from './WorkflowBay.svelte';
import DeskWorkflowRail from './DeskWorkflowRail.svelte';
import {
@@ -322,15 +322,6 @@
}
});
async function toggleFavorite(id: number, fav: boolean) {
try {
await workflows.update(id, { favorite: fav });
await client.invalidateQueries({ queryKey: ['workflows-meta'] });
await client.invalidateQueries({ queryKey: ['workflows'] });
} catch (err) {
toast.error(apiErrorMessage(err));
}
}
// ------------------------------------------------------------------
// Form state
@@ -724,8 +715,6 @@
sentTimer = setTimeout(() => (sent = false), 900);
// C 批审核:从「参数」页提交后自动切到「结果」页,进行中进度可见。
tab = 'result';
if (wide) inspOff = false;
else if (!narrow) inspOpen = true;
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
await client.invalidateQueries({ queryKey: ['jobs'] });
// 最近使用由后端在入队时记录 (queue/manager);这里只刷新轻量列表。
@@ -747,8 +736,6 @@
let historyJobId = $state<number | null>(null);
let busyId = $state<number | null>(null);
let tab = $state<'result' | 'params'>('result');
let inspOff = $state(false);
let inspOpen = $state(false);
let wide = $state(true);
let narrow = $state(false);
let crossfade = $state(false);
@@ -807,7 +794,6 @@
tab = 'result';
crossfade = via === 'pointer';
if (via === 'pointer') {
if (!wide) inspOpen = true;
void tick().then(() => feed?.slideFrom(from));
} else {
feed?.scrollToJob(job.id);
@@ -1111,14 +1097,6 @@
// 键盘 (§四.8): Ctrl/⌘+Enter 生成 · / 聚焦搜索/提示词 · ↑↓/J/K 切换
// Ctrl/⌘+Enter 仅在创作输入区提交;Esc 退出选工具。媒体与记录使用显式控件。
// ------------------------------------------------------------------
function typing(target: EventTarget | null): boolean {
const el = target as HTMLElement | null;
return (
!!el &&
(el.isContentEditable ||
['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName))
);
}
function inLayer(target: EventTarget | null): boolean {
const el = target instanceof Element ? target : null;
@@ -18,10 +18,6 @@
let { kind, metas, active, onSelect, onPickWorkflow }: Props = $props();
interface ModeEntry {
usage: WorkflowUsage;
count: number;
}
const modes = $derived.by(() => {
const counts = new Map<WorkflowUsage, number>();
for (const m of metas) {
@@ -26,7 +26,6 @@
pendingCount,
selectedId,
activeId = $bindable(null),
endpoints,
onPick,
onClose,
catalogue = false,
@@ -63,7 +63,6 @@
slotBusy = $bindable(false),
promptEl = $bindable(null),
onSet,
onOpenBay,
onPickEndpoint,
onSubmit,
onReveal,
@@ -62,7 +62,6 @@
open,
inactive,
canSendToSlot,
crossfade,
videoEl = $bindable(null),
params,
onClose,
@@ -62,10 +62,6 @@
(j) => j.kind === "image" || j.kind === "video",
),
);
const activeJobs = $derived(
genJobs.filter((j) => j.status === "pending" || j.status === "running")
.length,
);
// The ACTIVE ComfyUI connection (HEL-611). Its status dot comes from a
// real server-side probe (GET /system_stats from the workbench server,
@@ -115,11 +111,6 @@
return $probeQuery.data?.ok ? "ok" : "fail";
});
const endpointName = $derived(activeEndpoint?.name?.trim() || "ComfyUI");
const latencyMs = $derived(
probeState === "ok" && $probeQuery.data?.elapsed_ms != null
? Math.round($probeQuery.data.elapsed_ms)
: null,
);
const connDetail = $derived.by(() => {
if (probeState === "unset") return t("shell.comfyUnset");
const state = t(`shell.comfy_${probeState}`, { name: endpointName });
@@ -103,7 +103,8 @@
return Number.isFinite(ms) ? ms : fallback;
}
function popIn(_node: Element) {
function popIn(node: Element) {
void node;
const reduced = document.documentElement.dataset.reduce === '1';
const sheet = window.matchMedia(SHEET_QUERY).matches;
if (reduced) {
@@ -123,7 +124,8 @@
};
}
function fadeScrim(_node: Element) {
function fadeScrim(node: Element) {
void node;
return { duration: cssMs('--d-pop', 180), css: (t: number) => `opacity: ${t}` };
}
</script>
@@ -11,7 +11,7 @@
import Button from '$lib/components/ui/Button.svelte';
import Icon from '$lib/components/ui/Icon.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import SafeMedia from '$lib/components/SafeMedia.svelte';
import '$lib/components/SafeMedia.svelte';
import { assetUrl } from '$lib/api';
import { t } from '$lib/i18n.svelte';
@@ -11,7 +11,7 @@
import ClipMonitor from './ClipMonitor.svelte';
import ClipSourceModal from './ClipSourceModal.svelte';
import JobInputsDrawer from './JobInputsDrawer.svelte';
import PromptPreviewModal from './PromptPreviewModal.svelte';
import './PromptPreviewModal.svelte';
import SceneFilmstrip, { type FilmstripClip } from './SceneFilmstrip.svelte';
import SceneScriptDrawer from './SceneScriptDrawer.svelte';
import { t } from '$lib/i18n.svelte';
@@ -87,7 +87,6 @@ import { t } from '$lib/i18n.svelte';
}
let {
scenes,
filmClips,
selectedClip,
selectedClipId,
@@ -5,8 +5,8 @@
* values feed the viewport's shot solver.
*/
import { shotStore } from '$lib/shot/shotStore.svelte';
import { JOINT_CONFIGS, getDOF, setDOF, type JointConfig } from '$lib/shot/helpers/jointConfig';
import { readPosture, clonePosture, type Posture } from '$lib/shot/helpers/posture';
import { JOINT_CONFIGS, type JointConfig } from '$lib/shot/helpers/jointConfig';
import '$lib/shot/helpers/posture';
import type { ShotParams } from '$lib/shot/calibration/shotSolver';
import { SHOT_SIZE_OPTIONS, ANGLE_OPTIONS, ELEVATION_OPTIONS } from '$lib/shot/calibration/shotAxes';
import { COMPOSITION_PRESETS } from '$lib/shot/calibration/compositionPresets';
@@ -23,7 +23,7 @@
// reference editor used; the viewport applies it with writePosture.
let jointsOpen = $state(true);
function dofValue(cfg: JointConfig, figure: any, dofIndex: number): number {
function dofValue(cfg: JointConfig, figure: { posture?: unknown } | null, dofIndex: number): number {
const joint = figure?.posture ? figure : figure; // DOF read from posture data below
void joint;
// We don't have a live mannequin here — read from the stored posture
@@ -63,10 +63,6 @@
shotStore.addKeyframe(selectedObject.id, elapsed);
}
function commitStagedKeyframe() {
if (!selectedObject) return;
shotStore.commitLiveKeyframe(selectedObject.id);
}
function deleteSelectedKeyframe() {
if (!selectedObject || !selectedKeyframeId) return;
@@ -704,15 +704,6 @@
return label === key ? dir : label;
}
function formatUpdatedAt(ts: number | null): string {
if (!ts) return '';
return new Date(ts * 1000).toLocaleString([], {
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
});
}
/** SQLite CURRENT_TIMESTAMP ships as "YYYY-MM-DD HH:MM:SS" in UTC —
* parse it as such and render in the viewer's local timezone. */
@@ -740,14 +731,7 @@
: '',
);
function avatarStyle(n: number): string {
return `var(--avatar-${Math.min(Math.max(n, 1), 5)})`;
}
// HEL-680 灰阶头像:1–2 亮阶配深字,3–5 暗阶配浅字,按阶数决定。
function avatarLight(n: number | undefined): boolean {
return Math.min(Math.max(n ?? 1, 1), 5) <= 2;
}
// Reference agent interface: all task actions continue through existing APIs.
let agentSearch = $state(''),
skillSearch = $state('');
@@ -1115,10 +1099,6 @@
? $sessionQuery.data.project_id
: currentPreference.project,
);
const projectName = $derived(
($linkableProjectsQuery.data ?? []).find((p) => p.id === sessionProject)
?.title ?? '不关联项目',
);
function useInspiration() {
draft =
suggestions[0]?.prompt ??
@@ -7,7 +7,6 @@
import AgentComposer from '$lib/components/agent/AgentComposer.svelte';
import {
agentApi,
playgroundApi,
workflows,
type AgentMessage,
type AgentPlan,
@@ -40,7 +40,6 @@
type AgentTask,
type Character,
type Item,
type Job,
type Location,
type Scene,
} from '$lib/api';
@@ -67,7 +66,7 @@
});
const canvas = $derived($canvasQuery.data?.canvas ?? null);
const canvasNodes = $derived($canvasQuery.data?.nodes ?? []);
type CanvasNode = import('$lib/api').CanvasNode;
const projectId = $derived(canvas?.project_id ?? null);
const assetsQuery = createQuery(
@@ -87,7 +86,7 @@
);
function mediaFor(
node: (typeof canvasNodes)[number],
node: CanvasNode,
characters: Character[],
locations: Location[],
items: Item[],
@@ -154,7 +153,6 @@
// ---- graph sync ----------------------------------------------------------
let syncVersion = $state(0);
let loadedGraphAt = $state(0);
// While a drag is active the persisted-graph effect must NOT rebuild: any
// SSE-driven refetch (job.started, canvas.updated from another tab, …)
// would replace `nodes` with stale DB positions mid-drag and snap the
@@ -172,11 +170,10 @@
rebuildPending = false;
const graph = $canvasQuery.data;
if (!graph) {
loadedGraphAt = 0;
nodes = [];
return;
}
loadedGraphAt = Date.now();
Date.now();
const characters = $assetsQuery.data?.characters ?? [];
const locations = $assetsQuery.data?.locations ?? [];
const items = $assetsQuery.data?.items ?? [];
@@ -12,7 +12,6 @@
jobsApi,
settings,
workbenchApi,
type WorkbenchStage,
type WorkbenchStageKey,
} from '$lib/api';
import { connectEvents } from '$lib/events';
@@ -72,7 +71,6 @@
const overview = $derived($overviewQuery.data);
const stages = $derived(overview?.stages ?? []);
const anyRunning = $derived(stages.some((s) => s.status === 'running'));
// ?stage= selects the open stage; default = first not-confirmed one.
const urlStage = $derived(