refactor(HEL-752): type menu and blend contracts and document local exceptions

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-22 02:18:32 +08:00
co-authored by multica-agent
parent bfcf542e59
commit 4e200cc8ac
14 changed files with 27 additions and 26 deletions
@@ -47,14 +47,12 @@
</header>
<div class="media">
{#if videoSrc}
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
<button
type="button"
class="media-btn"
onclick={openPreview}
title={t('canvas.openPreview')}
>
<!-- svelte-ignore a11y_media_has_caption -->
<video
class="media-el"
src={videoSrc}
@@ -64,7 +62,6 @@
></video>
</button>
{:else if mediaSrc}
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
<button
type="button"
class="media-btn"
@@ -76,7 +76,6 @@
<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. -->
<!-- svelte-ignore a11y_media_has_caption -->
<video
class="media-el"
src={videoSrc}
@@ -229,6 +229,7 @@
{#if inputs.length === 0}
<p class="muted">
<!-- eslint-disable-next-line svelte/no-at-html-tags -- This fixed key comes only from the seven bundled translation dictionaries, without interpolation or remote overrides. Retain the existing HTML-capable translation contract. -->
{@html t('cdf.noInputs')}
</p>
{:else}
@@ -1,16 +1,9 @@
<script lang="ts">
<script lang="ts" generics="Item extends { id?: number; name: string; kind?: string; description?: string | null }">
import { t } from '$lib/i18n.svelte';
interface MenuItem {
id?: number;
name: string;
kind?: string;
description?: string | null;
}
interface Props {
open: boolean;
items: MenuItem[];
items: Item[];
activeIndex: number;
/** Caret / `@` viewport box — menu opens above this (composer is bottom-docked). */
anchor: { top: number; bottom: number; left: number };
@@ -18,7 +11,7 @@
lockReason?: string | null;
/** Skill mode: rows show `/name` + a description subtitle, no kind chip. */
skillMode?: boolean;
onSelect: (item: any) => void;
onSelect: (item: Item) => void;
onHover: (index: number) => void;
}
@@ -166,7 +166,6 @@
>
<div class="thumb">
{#if isVideo}
<!-- svelte-ignore a11y_media_has_caption -->
<video src={src} muted playsinline preload="metadata" onerror={hideBroken}></video>
{:else if (opt.kind ?? kind) === 'audio'}
<Icon name="music" size={28} />
@@ -144,7 +144,6 @@
{:else if value && thumbSrc && isImageKind}
<img class="tile-thumb" src={thumbSrc} alt={displayLabel} onerror={hideBrokenThumb} />
{:else if value && isVideoKind && thumbSrc}
<!-- svelte-ignore a11y_media_has_caption -->
<video class="tile-thumb" src={thumbSrc} muted playsinline></video>
{:else if value}
<div class="tile-file">
@@ -24,6 +24,7 @@
stroke-linejoin="round"
aria-hidden="true"
>
<!-- eslint-disable-next-line svelte/no-at-html-tags -- content is selected only from the bundled icons.ts SVG registry; no API/user strings enter it. HTML preserves the authored SVG child elements. -->
{@html content}
</svg>
{/if}
@@ -98,7 +98,6 @@
>
<div class="thumb">
{#if opt.path}
<!-- svelte-ignore a11y_media_has_caption -->
<video
src={assetUrl(opt.path)}
muted
@@ -100,7 +100,6 @@ title={t('filmstrip.clipTitle', {
{#if thumb?.kind === 'image'}
<img class="thumb-media" src={thumb.src} alt="" loading="lazy" />
{:else if thumb?.kind === 'video'}
<!-- svelte-ignore a11y_media_has_caption -->
<video class="thumb-media" src={thumb.src + '#t=0.1'} muted playsinline preload="metadata"></video>
{:else}
<span class="thumb-slate">{entry.label}</span>
@@ -62,6 +62,7 @@ export function videoBaseName(src: string): string {
name = "";
}
name = name.replace(/\.[a-z0-9]{1,5}$/i, "");
// eslint-disable-next-line no-control-regex -- U+0000–001F are intentionally rejected in filenames. Keep one underscore per contiguous invalid run, including mixed punctuation/control characters.
name = name.replace(/[\\/:*?"<>|\u0000-\u001f]+/g, "_").trim();
return name || "video";
}
@@ -30,7 +30,7 @@ export interface SampledTrack {
let blendFn: ((a: Posture, b: Posture, k: number) => Posture) | null = null;
import("mannequin-js/src/mannequin.js")
.then((mod) => {
blendFn = (mod as any).blend ?? null;
blendFn = mod.blend ?? null;
})
.catch(() => {
blendFn = null;
+5 -1
View File
@@ -1,5 +1,9 @@
declare module "mannequin-js/src/mannequin.js" {
export function blend(a: any, b: any, k: number): any;
export function blend(
a: import("../helpers/posture").Posture,
b: import("../helpers/posture").Posture,
k: number,
): import("../helpers/posture").Posture;
}
declare module "mannequin-js/src/scene.js" {
export function getStage():
+15 -5
View File
@@ -765,7 +765,9 @@
workingDrafts = JSON.parse(
sessionStorage.getItem('calliope.agent.workingDrafts') ?? '{}',
);
} catch {}
} catch {
// Unavailable or malformed session storage leaves the initial in-memory drafts intact.
}
$effect(() => {
const id = latestAssistant
? String(activeId) + ':' + latestAssistant.id
@@ -788,7 +790,9 @@
'calliope.agent.workingDrafts',
JSON.stringify(workingDrafts),
);
} catch {}
} catch {
// Storage quota/access failures do not discard the working in-memory draft.
}
}
let agentFile = $state<HTMLInputElement>(null!);
@@ -819,7 +823,9 @@
key,
value as { text: string; files: AgentAttachment[] },
);
} catch {}
} catch {
// Unavailable or malformed session storage leaves the in-memory composition cache intact.
}
$effect(() => {
const key = activeKey,
sid = activeId;
@@ -851,7 +857,9 @@
'calliope.agent.compositions',
JSON.stringify(Object.fromEntries(compositionCache)),
);
} catch {}
} catch {
// Persistence is best effort; the in-memory composition remains available.
}
});
});
@@ -931,7 +939,9 @@
agentPreferences = JSON.parse(
localStorage.getItem('calliope.reference.agentPreferences') || '{}',
);
} catch {}
} catch {
// Unavailable or malformed local storage keeps the default agent preferences.
}
});
function pinAgent(key: string) {
pinnedAgents = pinnedAgents.includes(key)
@@ -385,7 +385,6 @@
}
const local = restoreViewportFromStorage();
const chosen = validViewport(parsed) ? parsed : (local ?? undefined);
// svelte-ignore state_referenced_locally
initialViewport = chosen;
if (chosen) viewport = chosen;
}