Revert "feat(ui): add an isolated UI SDK lab under devtools"
This reverts commit fe4d574976.
This commit is contained in:
12 files changed
-737
No files matched your search
@@ -101,11 +101,6 @@ state; the UI presents them and submits operator choices.
|
||||
and table semantics. A hover action must also be reachable by keyboard.
|
||||
- Keep filtering and pagination consistent with the server. State limitations
|
||||
such as sorting only loaded rows when they affect the operator's decision.
|
||||
- UI SDK is an isolated beta experiment in `src/devtools/ui-sdk` and
|
||||
`ui-sdk-lab.html`. When editing it, read the installed skill at
|
||||
`node_modules/@ui-sdk/core/skills/ui-sdk/SKILL.md` and matching package docs.
|
||||
Keep patterns dev-only until the beta terms and package-age exception are
|
||||
reviewed.
|
||||
|
||||
## Tests
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
"@types/hast": "^3.0.5",
|
||||
"@types/node": "^26.6.4",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@ui-sdk/core": "0.1.0-beta.16",
|
||||
"@ui-sdk/vue": "0.1.0-beta.16",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@vue/tsconfig": "^0.9.1",
|
||||
"typescript": "~6.0.3",
|
||||
|
||||
Generated
-32
@@ -254,12 +254,6 @@ importers:
|
||||
'@types/qrcode':
|
||||
specifier: ^1.5.6
|
||||
version: 1.5.6
|
||||
'@ui-sdk/core':
|
||||
specifier: 0.1.0-beta.16
|
||||
version: 0.1.0-beta.16
|
||||
'@ui-sdk/vue':
|
||||
specifier: 0.1.0-beta.16
|
||||
version: 0.1.0-beta.16(@ui-sdk/core@0.1.0-beta.16)(vue@3.5.44(typescript@6.0.3))
|
||||
'@vitejs/plugin-vue':
|
||||
specifier: ^6.0.8
|
||||
version: 6.0.10(vite@8.3.5(@types/node@26.6.5)(jiti@2.7.0)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))
|
||||
@@ -656,25 +650,6 @@ packages:
|
||||
'@types/web-bluetooth@0.0.21':
|
||||
resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==}
|
||||
|
||||
'@ui-sdk/core@0.1.0-beta.16':
|
||||
resolution: {integrity: sha512-I2GMqOviLS/lYfIj2lTqKLbae0V9uSnysK+bSdbhuw2De8zNvrLZiDTc0qzsPNiZvB/bMmUZJS5UDA5Q2Pq4Ng==}
|
||||
|
||||
'@ui-sdk/vue@0.1.0-beta.16':
|
||||
resolution: {integrity: sha512-9Y4aMVrrYrYDNBgiJs1AWW1S6giJQ7wfmyEvN6fU0j3gyO5qmLQ1xLBmZmuCQv1Wt0AIL9VfGpAclW4ZF45IOA==}
|
||||
peerDependencies:
|
||||
'@nuxt/kit': ^4.0.0 || ^5.0.0-0
|
||||
'@nuxt/schema': ^4.0.0 || ^5.0.0-0
|
||||
'@ui-sdk/core': ^0.1.0-beta.16
|
||||
nuxt: ^4.0.0 || ^5.0.0-0
|
||||
vue: '>=3.5'
|
||||
peerDependenciesMeta:
|
||||
'@nuxt/kit':
|
||||
optional: true
|
||||
'@nuxt/schema':
|
||||
optional: true
|
||||
nuxt:
|
||||
optional: true
|
||||
|
||||
'@ungap/structured-clone@1.4.0':
|
||||
resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==}
|
||||
|
||||
@@ -2041,13 +2016,6 @@ snapshots:
|
||||
|
||||
'@types/web-bluetooth@0.0.21': {}
|
||||
|
||||
'@ui-sdk/core@0.1.0-beta.16': {}
|
||||
|
||||
'@ui-sdk/vue@0.1.0-beta.16(@ui-sdk/core@0.1.0-beta.16)(vue@3.5.44(typescript@6.0.3))':
|
||||
dependencies:
|
||||
'@ui-sdk/core': 0.1.0-beta.16
|
||||
vue: 3.5.44(typescript@6.0.3)
|
||||
|
||||
'@ungap/structured-clone@1.4.0': {}
|
||||
|
||||
'@vitejs/plugin-vue@6.0.10(vite@8.3.5(@types/node@26.6.5)(jiti@2.7.0)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))':
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
allowBuilds:
|
||||
vue-demi: true
|
||||
minimumReleaseAgeExclude:
|
||||
- '@ui-sdk/core@0.1.0-beta.16'
|
||||
- '@ui-sdk/vue@0.1.0-beta.16'
|
||||
@@ -1,480 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { checkPattern } from "@ui-sdk/core/testing";
|
||||
import { createAgent, type AgentComponent } from "@ui-sdk/vue/agent";
|
||||
import { Field, FieldLabel } from "@ui-sdk/vue/field";
|
||||
import { CheckIcon } from "@lucide/vue";
|
||||
import { Checkbox, CheckboxGroup, CheckboxIndicator } from "@ui-sdk/vue/checkbox";
|
||||
import { NumberInput, NumberInputControl, NumberInputGroup } from "@ui-sdk/vue/number-input";
|
||||
import { Radio, RadioGroup, RadioIndicator } from "@ui-sdk/vue/radio";
|
||||
import { TimeInput } from "@ui-sdk/vue/time-input";
|
||||
import {
|
||||
TokenInput,
|
||||
TokenInputEditor,
|
||||
TokenInputToken,
|
||||
TokenInputTokenRemove,
|
||||
type TokenInputValue,
|
||||
} from "@ui-sdk/vue/token-input";
|
||||
import {
|
||||
type TriggerMenuDataItem,
|
||||
TriggerMenu,
|
||||
TriggerMenuContent,
|
||||
TriggerMenuEmpty,
|
||||
TriggerMenuItem,
|
||||
TriggerMenuList,
|
||||
} from "@ui-sdk/vue/trigger-menu";
|
||||
import { XIcon } from "@lucide/vue";
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Section from "@/components/ui/section/Section.vue";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { cronWords } from "@/schedules/schedule";
|
||||
import { cronForRule } from "./schedule-rule";
|
||||
import { TriageScore, TriageScoreOption } from "./triage-score-parts";
|
||||
|
||||
const cadence = ref("daily");
|
||||
const scheduleTime = ref<string | null>("09:00");
|
||||
const weekdays = ref(["1", "2", "3", "4", "5"]);
|
||||
const monthDay = ref<number | null>(1);
|
||||
const cadenceOptions = [
|
||||
{ value: "daily", label: "Daily" },
|
||||
{ value: "weekly", label: "Weekly" },
|
||||
{ value: "monthly", label: "Monthly" },
|
||||
];
|
||||
const weekdayOptions = [
|
||||
{ value: "0", label: "Sun" },
|
||||
{ value: "1", label: "Mon" },
|
||||
{ value: "2", label: "Tue" },
|
||||
{ value: "3", label: "Wed" },
|
||||
{ value: "4", label: "Thu" },
|
||||
{ value: "5", label: "Fri" },
|
||||
{ value: "6", label: "Sat" },
|
||||
];
|
||||
const cronExpression = computed(() => {
|
||||
const time = scheduleTime.value;
|
||||
if (!time) return null;
|
||||
if (cadence.value === "weekly") {
|
||||
return cronForRule({ cadence: "weekly", time, weekdays: weekdays.value.map(Number) });
|
||||
}
|
||||
if (cadence.value === "monthly") {
|
||||
return monthDay.value === null ? null : cronForRule({ cadence: "monthly", time, day: monthDay.value });
|
||||
}
|
||||
return cronForRule({ cadence: "daily", time });
|
||||
});
|
||||
const scheduleWords = computed(() => cronExpression.value ? cronWords(cronExpression.value) : "");
|
||||
|
||||
const scoreLabels = ["Very low", "Low", "Moderate", "High", "Very high"];
|
||||
const tab = ref("custom");
|
||||
const score = ref(3);
|
||||
const lastChange = ref("Default sample value");
|
||||
const actionResult = ref("Run a keyboard check or an agent action to see the change source.");
|
||||
const snapshot = ref<AgentComponent[]>([]);
|
||||
const scoreRoot = ref<HTMLElement | null>(null);
|
||||
const scoreLabel = computed(() => scoreLabels[score.value - 1] ?? "Not rated");
|
||||
const activeSnapshot = computed(() => snapshot.value.filter((component) => !component.offPage));
|
||||
const scoreComponent = computed(() =>
|
||||
activeSnapshot.value.find((component) => component.component === "triage-score"),
|
||||
);
|
||||
const snapshotScore = computed(() => {
|
||||
const value = scoreComponent.value?.value;
|
||||
return typeof value === "number" ? value : null;
|
||||
});
|
||||
const snapshotActions = computed(() => scoreComponent.value?.actions ?? []);
|
||||
const snapshotItems = computed(() => scoreComponent.value?.items ?? []);
|
||||
|
||||
const agent = createAgent();
|
||||
const stopObserving = agent.subscribe((change) => {
|
||||
lastChange.value = `${change.source} · ${change.reason} · ${change.value}`;
|
||||
snapshot.value = agent.snapshot();
|
||||
});
|
||||
|
||||
function updateScore(value: number, details: { source?: string; reason?: string }) {
|
||||
score.value = value;
|
||||
lastChange.value = `${details.source ?? "person"} · ${details.reason ?? "value-change"} · ${value}`;
|
||||
}
|
||||
|
||||
function refreshSnapshot() {
|
||||
snapshot.value = agent.snapshot();
|
||||
}
|
||||
|
||||
async function setScoreAsAgent() {
|
||||
const result = await agent.act({
|
||||
steps: [{ ref: "Task result confidence", action: "rate", args: [4] }],
|
||||
});
|
||||
actionResult.value = result.ok
|
||||
? "Bridge action accepted · confidence set to 4 of 5"
|
||||
: `Bridge action refused · ${result.error?.message ?? "unknown error"}`;
|
||||
refreshSnapshot();
|
||||
}
|
||||
|
||||
async function checkRadioPattern() {
|
||||
const root = scoreRoot.value;
|
||||
if (!root) return;
|
||||
try {
|
||||
await checkPattern(root, "radio-group");
|
||||
actionResult.value = "Passed · roles, names, checked state and keyboard behavior";
|
||||
} catch (error) {
|
||||
actionResult.value = `Failed · ${(error as Error).message}`;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(refreshSnapshot);
|
||||
watch(tab, async () => {
|
||||
await nextTick();
|
||||
refreshSnapshot();
|
||||
});
|
||||
onBeforeUnmount(stopObserving);
|
||||
|
||||
const files = [
|
||||
{ value: "workflows/review.yaml", label: "review.yaml" },
|
||||
{ value: "workflows/triage.yaml", label: "triage.yaml" },
|
||||
{ value: "WORKFLOWS.md", label: "WORKFLOWS.md" },
|
||||
{ value: "internal/domain/workflow", label: "workflow domain" },
|
||||
];
|
||||
|
||||
const contextDraft: TokenInputValue = [
|
||||
"Review the retry behavior in ",
|
||||
{ type: "file", value: "workflows/review.yaml", label: "review.yaml" },
|
||||
" against ",
|
||||
{ type: "file", value: "WORKFLOWS.md", label: "WORKFLOWS.md" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-theme="light" class="min-h-screen bg-background text-foreground">
|
||||
<main class="mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8">
|
||||
<div class="mb-1 flex flex-wrap items-center justify-between gap-3">
|
||||
<PageHeader title="UI SDK agent lab" />
|
||||
<Badge variant="outline">Development prototypes</Badge>
|
||||
</div>
|
||||
<p class="mb-5 max-w-2xl text-label text-muted-foreground">
|
||||
Four isolated patterns: build behavior, compose Vue components, generate a schedule rule, and inspect an agent-facing contract. Sample data only; no live workflow or task is changed.
|
||||
</p>
|
||||
|
||||
<Tabs v-model="tab" class="space-y-4">
|
||||
<TabsList variant="line" aria-label="UI SDK use cases" class="w-full justify-start">
|
||||
<TabsTrigger value="custom"><span class="hidden sm:inline">Custom primitive</span><span class="sm:hidden">Core</span></TabsTrigger>
|
||||
<TabsTrigger value="vue"><span class="hidden sm:inline">Vue component</span><span class="sm:hidden">Vue UI</span></TabsTrigger>
|
||||
<TabsTrigger value="schedule"><span class="hidden sm:inline">Schedule rule</span><span class="sm:hidden">Schedule</span></TabsTrigger>
|
||||
<TabsTrigger value="agent"><span class="hidden sm:inline">Agent actions</span><span class="sm:hidden">Agent</span></TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="custom">
|
||||
<Section
|
||||
title="Review an agent finding"
|
||||
description="A Core behavior exercise for a confidence rating; the SDK also ships Rating, which should be preferred for production."
|
||||
>
|
||||
<div class="grid gap-4 lg:grid-cols-[minmax(0,1.15fr)_minmax(19rem,0.85fr)]">
|
||||
<article class="overflow-hidden rounded-lg border border-border bg-card shadow-sm">
|
||||
<header class="border-b border-border bg-background px-5 py-4">
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<Badge variant="info">Workflow run</Badge>
|
||||
<span class="font-mono text-caption text-muted-foreground">RUN-0416</span>
|
||||
<Badge class="ml-auto" variant="warn">Needs review</Badge>
|
||||
</div>
|
||||
<h3 class="text-base font-semibold tracking-tight">Retry policy has no upper bound</h3>
|
||||
<p class="mt-1 max-w-xl text-sm leading-6 text-muted-foreground">
|
||||
The run found a workflow that can retry indefinitely when its event source is unavailable.
|
||||
</p>
|
||||
</header>
|
||||
<dl class="grid gap-4 px-5 py-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Workflow</dt>
|
||||
<dd class="mt-1 text-sm font-medium">Event triage</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Finding</dt>
|
||||
<dd class="mt-1 text-sm font-medium">Unbounded retry window</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<footer class="border-t border-border bg-muted/40 px-5 py-3 text-caption text-muted-foreground">
|
||||
Illustrative run record · local component state only
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
<section class="rounded-lg border border-border bg-card p-5 shadow-sm">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">Reviewer confidence</h3>
|
||||
<p class="mt-1 text-caption text-muted-foreground">How likely is this finding to be correct?</p>
|
||||
</div>
|
||||
<Badge variant="outline">Interactive</Badge>
|
||||
</div>
|
||||
|
||||
<div ref="scoreRoot" class="mt-5">
|
||||
<TriageScore
|
||||
v-model="score"
|
||||
aria-label="Task result confidence"
|
||||
class="flex w-full gap-2"
|
||||
@value-change="updateScore"
|
||||
>
|
||||
<TriageScoreOption
|
||||
v-for="(label, index) in scoreLabels"
|
||||
:key="label"
|
||||
:value="String(index + 1)"
|
||||
:aria-label="`${index + 1} of 5 · ${label} confidence`"
|
||||
class="flex min-w-0 flex-1 flex-col items-center gap-1 rounded-md border border-border bg-background px-1 py-2 text-foreground transition-colors hover:border-primary/60 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-ring aria-checked:border-primary aria-checked:bg-primary/5 aria-checked:text-primary motion-reduce:transition-none"
|
||||
>
|
||||
<span class="text-sm font-semibold tabular-nums">{{ index + 1 }}</span>
|
||||
<span class="text-micro leading-3 text-muted-foreground">{{ label }}</span>
|
||||
</TriageScoreOption>
|
||||
</TriageScore>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex items-center justify-between rounded-md bg-muted/50 px-3 py-2">
|
||||
<span class="text-sm font-semibold tabular-nums">{{ score }} / 5</span>
|
||||
<Badge :variant="score >= 4 ? 'ok' : 'secondary'">{{ scoreLabel }} confidence</Badge>
|
||||
</div>
|
||||
<p class="mt-2 min-h-4 text-caption text-muted-foreground" aria-live="polite">{{ lastChange }}</p>
|
||||
|
||||
<div data-agent-hidden class="mt-4 flex flex-wrap gap-2 border-t border-border pt-4">
|
||||
<Button size="sm" variant="outline" @click="checkRadioPattern">Run keyboard check</Button>
|
||||
<Button size="sm" variant="outline" @click="setScoreAsAgent">Set via agent bridge</Button>
|
||||
</div>
|
||||
<p class="mt-3 min-h-4 text-caption text-muted-foreground" aria-live="polite">{{ actionResult }}</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<details class="mt-4 rounded-md border border-border bg-background px-4 py-3">
|
||||
<summary class="cursor-pointer text-label font-medium">Behavior contract used by the primitive</summary>
|
||||
<pre class="mt-3 overflow-auto rounded-md bg-muted/50 p-3 text-xs leading-5 text-foreground"><code>createRovingFocus(context, { slot: "score", key: "focused", orientation: () => "both", loop: () => true })
|
||||
createChange(context) // shared pointer, keyboard and agent updates
|
||||
agent: { actions: ["rate"], items: scoreOptions }</code></pre>
|
||||
</details>
|
||||
</Section>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="vue">
|
||||
<Section
|
||||
title="Compose a file-aware prompt"
|
||||
description="The SDK’s Token Input and Trigger Menu preserve file references as editable, keyboard-operable tokens."
|
||||
>
|
||||
<div class="grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(17rem,0.65fr)]">
|
||||
<article class="overflow-hidden rounded-lg border border-border bg-card shadow-sm">
|
||||
<header class="flex flex-wrap items-center justify-between gap-2 border-b border-border bg-background px-5 py-3">
|
||||
<div>
|
||||
<p class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Prompt composer</p>
|
||||
<h3 class="mt-1 text-sm font-semibold">Review a workflow change</h3>
|
||||
<p class="mt-1 text-caption text-muted-foreground">Type @ to search · ↑↓ choose · Enter insert · Backspace remove</p>
|
||||
</div>
|
||||
<Badge variant="secondary">Preview only</Badge>
|
||||
</header>
|
||||
<div class="p-5">
|
||||
<Field class="gap-2">
|
||||
<FieldLabel>Request</FieldLabel>
|
||||
<TokenInput :default-value="contextDraft" class="min-h-24 rounded-md border border-input bg-background px-3 py-3 text-sm shadow-sm focus-within:ring-2 focus-within:ring-ring/40">
|
||||
<TokenInputEditor
|
||||
aria-label="Workflow context prompt"
|
||||
placeholder="Ask about a workflow. Type @ to attach context."
|
||||
class="min-h-16 w-full bg-transparent leading-6 outline-none"
|
||||
/>
|
||||
<TriggerMenu :triggers="[{ char: '@', type: 'file', items: files }]">
|
||||
<TriggerMenuContent class="z-50 min-w-64 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg">
|
||||
<div class="px-2 py-1.5 text-caption font-medium text-muted-foreground">Attach a project file</div>
|
||||
<TriggerMenuEmpty class="px-2 py-2 text-sm text-muted-foreground">No matching files</TriggerMenuEmpty>
|
||||
<TriggerMenuList v-slot="{ state }" class="max-h-56 overflow-auto">
|
||||
<TriggerMenuItem
|
||||
v-for="item in state.items as TriggerMenuDataItem[]"
|
||||
:key="item.value"
|
||||
:value="item.value"
|
||||
:label="item.label"
|
||||
class="cursor-default rounded-sm px-2 py-2 text-sm outline-none data-highlighted:bg-accent data-highlighted:text-accent-foreground"
|
||||
>
|
||||
{{ item.label }}
|
||||
</TriggerMenuItem>
|
||||
</TriggerMenuList>
|
||||
</TriggerMenuContent>
|
||||
</TriggerMenu>
|
||||
<template #token="{ token }">
|
||||
<TokenInputToken class="inline-flex items-center gap-1 rounded-sm border border-primary/20 bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary">
|
||||
{{ token.label }}
|
||||
<TokenInputTokenRemove
|
||||
:aria-label="`Remove ${token.label}`"
|
||||
class="rounded-sm text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<XIcon aria-hidden="true" class="size-3" />
|
||||
</TokenInputTokenRemove>
|
||||
</TokenInputToken>
|
||||
</template>
|
||||
</TokenInput>
|
||||
</Field>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<aside class="rounded-lg border border-border bg-card p-5 shadow-sm">
|
||||
<p class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Why this helps</p>
|
||||
<h3 class="mt-1 text-sm font-semibold">Context travels with the draft</h3>
|
||||
<ul class="mt-4 space-y-3 text-sm leading-5">
|
||||
<li class="flex gap-2"><span class="font-semibold text-primary">01</span><span>Autocomplete searches the project’s file catalogue.</span></li>
|
||||
<li class="flex gap-2"><span class="font-semibold text-primary">02</span><span>A selected file stays a named, removable token.</span></li>
|
||||
<li class="flex gap-2"><span class="font-semibold text-primary">03</span><span>The app can map token values into its existing prompt contract.</span></li>
|
||||
</ul>
|
||||
<p class="mt-4 border-t border-border pt-3 text-caption text-muted-foreground">The sample uses fixture paths and does not send a prompt.</p>
|
||||
</aside>
|
||||
</div>
|
||||
</Section>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="schedule">
|
||||
<Section
|
||||
title="Build a recurrence rule"
|
||||
description="Choose a common cadence and time. Archie generates the five-field cron expression and reads it back in plain language."
|
||||
>
|
||||
<div class="grid gap-4 lg:grid-cols-[minmax(0,1.15fr)_minmax(19rem,0.85fr)]">
|
||||
<section class="rounded-lg border border-border bg-card p-5 shadow-sm">
|
||||
<div class="mb-5 flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Recurrence</p>
|
||||
<h3 class="mt-1 text-sm font-semibold">When should it run?</h3>
|
||||
</div>
|
||||
<Badge variant="secondary">Preview only</Badge>
|
||||
</div>
|
||||
|
||||
<Field class="gap-2">
|
||||
<FieldLabel>Repeats</FieldLabel>
|
||||
<RadioGroup v-model:value="cadence" class="grid grid-cols-3 gap-2">
|
||||
<label v-for="option in cadenceOptions" :key="option.value" class="flex cursor-pointer items-center gap-2 rounded-md border border-border bg-background px-3 py-2.5 text-sm font-medium transition-colors hover:bg-muted/50 focus-within:ring-2 focus-within:ring-ring has-[[data-checked]]:border-primary has-[[data-checked]]:bg-primary/5 has-[[data-checked]]:text-primary motion-reduce:transition-none">
|
||||
<Radio :value="option.value" class="grid size-4 shrink-0 place-items-center rounded-full border border-input bg-background text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-checked:border-primary">
|
||||
<RadioIndicator class="size-2 rounded-full bg-current" />
|
||||
</Radio>
|
||||
{{ option.label }}
|
||||
</label>
|
||||
</RadioGroup>
|
||||
</Field>
|
||||
|
||||
<div class="mt-5 grid gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
|
||||
<Field class="gap-2">
|
||||
<FieldLabel>Time</FieldLabel>
|
||||
<TimeInput v-model:value="scheduleTime" :hour-cycle="24" class="inline-flex min-h-10 items-center gap-1 rounded-md border border-input bg-background px-3 py-2 font-mono text-sm shadow-sm focus-within:ring-2 focus-within:ring-ring/40" />
|
||||
</Field>
|
||||
<Field v-if="cadence === 'monthly'" class="gap-2">
|
||||
<FieldLabel>Day of month</FieldLabel>
|
||||
<NumberInput v-model:value="monthDay" :min="1" :max="31" class="w-full">
|
||||
<NumberInputGroup class="flex min-h-10 items-center rounded-md border border-input bg-background shadow-sm focus-within:ring-2 focus-within:ring-ring/40">
|
||||
<NumberInputControl aria-label="Day of month" class="h-10 w-full bg-transparent px-3 text-sm outline-none" />
|
||||
</NumberInputGroup>
|
||||
</NumberInput>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<Field v-if="cadence === 'weekly'" class="mt-5 gap-2">
|
||||
<FieldLabel>Days</FieldLabel>
|
||||
<CheckboxGroup v-model:value="weekdays" class="grid grid-cols-4 gap-2 sm:grid-cols-7">
|
||||
<label v-for="day in weekdayOptions" :key="day.value" class="flex cursor-pointer items-center justify-center gap-1.5 rounded-md border border-border bg-background px-2 py-2 text-xs font-medium transition-colors hover:bg-muted/50 focus-within:ring-2 focus-within:ring-ring has-[[data-checked]]:border-primary has-[[data-checked]]:bg-primary/5 has-[[data-checked]]:text-primary motion-reduce:transition-none">
|
||||
<Checkbox :value="day.value" class="grid size-4 shrink-0 place-items-center rounded border border-input bg-background text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-checked:border-primary">
|
||||
<CheckboxIndicator class="size-3"><CheckIcon aria-hidden="true" class="size-3" /></CheckboxIndicator>
|
||||
</Checkbox>
|
||||
{{ day.label }}
|
||||
</label>
|
||||
</CheckboxGroup>
|
||||
</Field>
|
||||
<p v-if="cadence === 'monthly'" class="mt-2 text-caption text-muted-foreground">Months without this day are skipped.</p>
|
||||
</section>
|
||||
|
||||
<aside class="flex flex-col rounded-lg border border-border bg-card p-5 shadow-sm">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Generated rule</p>
|
||||
<h3 class="mt-1 text-sm font-semibold">Cron preview</h3>
|
||||
</div>
|
||||
<Badge variant="info">Sample</Badge>
|
||||
</div>
|
||||
<div class="mt-5 rounded-md border border-border bg-background p-4">
|
||||
<output aria-live="polite" class="block font-mono text-lg font-semibold tracking-wide text-foreground">{{ cronExpression ?? "— — — — —" }}</output>
|
||||
<p class="mt-2 text-sm leading-5 text-muted-foreground">{{ scheduleWords || "Choose a time and complete the recurrence to preview it." }}</p>
|
||||
</div>
|
||||
<p v-if="!cronExpression" class="mt-3 text-caption text-destructive" role="status">
|
||||
{{ !scheduleTime ? "Choose a valid time." : cadence === 'weekly' && weekdays.length === 0 ? "Select at least one day." : "Choose a day from 1 to 31." }}
|
||||
</p>
|
||||
<p class="mt-auto border-t border-border pt-4 text-caption leading-5 text-muted-foreground">
|
||||
Cron runs in the schedule’s configured time zone. This sample does not save a schedule or call an API.
|
||||
</p>
|
||||
</aside>
|
||||
</div>
|
||||
</Section>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="agent">
|
||||
<Section
|
||||
title="Expose a component contract"
|
||||
description="The Vue bridge turns a named component into a snapshot and bounded actions; it does not include an LLM loop."
|
||||
>
|
||||
<div class="grid gap-4 lg:grid-cols-2">
|
||||
<section class="rounded-lg border border-border bg-card p-5 shadow-sm">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-caption font-medium uppercase tracking-wide text-muted-foreground">Live component</p>
|
||||
<h3 class="mt-1 text-sm font-semibold">Task result confidence</h3>
|
||||
</div>
|
||||
<Badge variant="info">triage-score</Badge>
|
||||
</div>
|
||||
<TriageScore
|
||||
v-model="score"
|
||||
aria-label="Task result confidence"
|
||||
class="mt-4 flex w-full gap-2"
|
||||
@value-change="updateScore"
|
||||
>
|
||||
<TriageScoreOption
|
||||
v-for="(label, index) in scoreLabels"
|
||||
:key="label"
|
||||
:value="String(index + 1)"
|
||||
:aria-label="`${index + 1} of 5 · ${label} confidence`"
|
||||
class="flex min-w-0 flex-1 flex-col items-center gap-1 rounded-md border border-border bg-background px-1 py-2 text-foreground transition-colors hover:border-primary/60 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-ring aria-checked:border-primary aria-checked:bg-primary/5 aria-checked:text-primary motion-reduce:transition-none"
|
||||
>
|
||||
<span class="text-sm font-semibold tabular-nums">{{ index + 1 }}</span>
|
||||
<span class="text-micro leading-3 text-muted-foreground">{{ label }}</span>
|
||||
</TriageScoreOption>
|
||||
</TriageScore>
|
||||
<div data-agent-hidden class="mt-4 flex flex-wrap gap-2 border-t border-border pt-4">
|
||||
<Button size="sm" @click="setScoreAsAgent">Run bridge action: set to 4</Button>
|
||||
</div>
|
||||
<p class="mt-3 min-h-4 text-caption text-muted-foreground" aria-live="polite">{{ actionResult }}</p>
|
||||
</section>
|
||||
|
||||
<section class="rounded-lg border border-border bg-card p-5 shadow-sm">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-caption font-medium uppercase tracking-wide text-muted-foreground">What the agent can see</p>
|
||||
<h3 class="mt-1 text-sm font-semibold">Component snapshot</h3>
|
||||
</div>
|
||||
<Badge variant="outline">{{ activeSnapshot.length }} component</Badge>
|
||||
</div>
|
||||
<div v-if="scoreComponent" class="mt-4 divide-y divide-border rounded-md border border-border">
|
||||
<div class="flex items-center justify-between gap-3 px-3 py-2.5">
|
||||
<span class="text-caption text-muted-foreground">Accessible name</span>
|
||||
<span class="text-sm font-medium">{{ scoreComponent.label }}</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between gap-3 px-3 py-2.5">
|
||||
<span class="text-caption text-muted-foreground">Current value</span>
|
||||
<span class="text-sm font-semibold tabular-nums">{{ snapshotScore ?? "—" }} / 5</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between gap-3 px-3 py-2.5">
|
||||
<span class="text-caption text-muted-foreground">Allowed action</span>
|
||||
<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-xs">{{ snapshotActions.join(", ") || "none" }}</code>
|
||||
</div>
|
||||
<div class="px-3 py-2.5">
|
||||
<span class="text-caption text-muted-foreground">Valid values</span>
|
||||
<div class="mt-2 flex flex-wrap gap-1.5">
|
||||
<Badge v-for="item in snapshotItems" :key="item.value" variant="secondary">
|
||||
{{ item.label }}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="mt-4 rounded-md border border-dashed border-border p-4 text-sm text-muted-foreground">
|
||||
Waiting for the active component to register.
|
||||
</p>
|
||||
<details class="mt-4 border-t border-border pt-3">
|
||||
<summary class="cursor-pointer text-label font-medium">Raw snapshot for implementation review</summary>
|
||||
<pre class="mt-3 max-h-64 overflow-auto rounded-md bg-muted/50 p-3 text-xs leading-5 text-foreground">{{ JSON.stringify(activeSnapshot, null, 2) }}</pre>
|
||||
</details>
|
||||
</section>
|
||||
</div>
|
||||
</Section>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,43 +0,0 @@
|
||||
export type CronRule =
|
||||
| { cadence: "daily"; time: string }
|
||||
| { cadence: "weekly"; time: string; weekdays: readonly number[] }
|
||||
| { cadence: "monthly"; time: string; day: number };
|
||||
|
||||
function clockFields(time: string): [number, number] | null {
|
||||
const match = /^(\d{2}):(\d{2})$/.exec(time);
|
||||
if (!match) return null;
|
||||
const hour = Number(match[1]);
|
||||
const minute = Number(match[2]);
|
||||
if (hour > 23 || minute > 59) return null;
|
||||
return [hour, minute];
|
||||
}
|
||||
|
||||
function weekdayField(values: readonly number[]): string | null {
|
||||
if (!values.length || values.some((day) => !Number.isInteger(day) || day < 0 || day > 6)) {
|
||||
return null;
|
||||
}
|
||||
const days = [...new Set(values)].sort((a, b) => a - b);
|
||||
if (days.length === 7) return "*";
|
||||
if (days.join(",") === "1,2,3,4,5") return "1-5";
|
||||
if (days.join(",") === "0,6") return "0,6";
|
||||
return days.join(",");
|
||||
}
|
||||
|
||||
export function cronForRule(rule: CronRule): string | null {
|
||||
if ("cadence" in rule && "time" in rule) {
|
||||
const clock = clockFields(rule.time);
|
||||
if (!clock) return null;
|
||||
const [hour, minute] = clock;
|
||||
if (rule.cadence === "daily") return `${minute} ${hour} * * *`;
|
||||
if (rule.cadence === "weekly") {
|
||||
const weekdays = weekdayField(rule.weekdays);
|
||||
return weekdays === null ? null : `${minute} ${hour} * * ${weekdays}`;
|
||||
}
|
||||
if (rule.cadence === "monthly") {
|
||||
return Number.isInteger(rule.day) && rule.day >= 1 && rule.day <= 31
|
||||
? `${minute} ${hour} ${rule.day} * *`
|
||||
: null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { createApp } from "vue";
|
||||
|
||||
import UiSdkLabPage from "./UiSdkLabPage.vue";
|
||||
import "../../style.css";
|
||||
|
||||
createApp(UiSdkLabPage).mount("#app");
|
||||
@@ -1,10 +0,0 @@
|
||||
import { createParts } from "@ui-sdk/vue/primitive";
|
||||
|
||||
import { triageScore } from "./triage-score";
|
||||
|
||||
const { Root: TriageScore, Score: TriageScoreOption } = createParts(
|
||||
triageScore,
|
||||
{ root: "div", score: "button" },
|
||||
);
|
||||
|
||||
export { TriageScore, TriageScoreOption };
|
||||
@@ -1,100 +0,0 @@
|
||||
import {
|
||||
createChange,
|
||||
createRovingFocus,
|
||||
definePrimitive,
|
||||
type ChangeDetails,
|
||||
} from "@ui-sdk/core";
|
||||
|
||||
type TriageScoreOptions = {
|
||||
value?: number;
|
||||
defaultValue?: number;
|
||||
onValueChange?: (
|
||||
value: number,
|
||||
details: ChangeDetails<"item-press" | "list-navigation">,
|
||||
) => void;
|
||||
};
|
||||
|
||||
const scores = [
|
||||
{ value: 1, label: "Very low" },
|
||||
{ value: 2, label: "Low" },
|
||||
{ value: 3, label: "Moderate" },
|
||||
{ value: 4, label: "High" },
|
||||
{ value: 5, label: "Very high" },
|
||||
];
|
||||
|
||||
const triageScore = definePrimitive({
|
||||
name: "triage-score",
|
||||
options: {
|
||||
value: "number",
|
||||
defaultValue: "number",
|
||||
onValueChange: "callback",
|
||||
},
|
||||
controlled: ["value"],
|
||||
state: (options: TriageScoreOptions) => ({
|
||||
value: options.value ?? options.defaultValue ?? 0,
|
||||
focused: null as string | null,
|
||||
}),
|
||||
sync: (options) =>
|
||||
options.value === undefined ? {} : { value: options.value },
|
||||
api: (context) => {
|
||||
const change = createChange(context);
|
||||
const roving = createRovingFocus(context, {
|
||||
slot: "score",
|
||||
key: "focused",
|
||||
remember: false,
|
||||
preferred: (score) => Number(score.key) === context.store.get().value,
|
||||
claims: (state, score) =>
|
||||
state.value ? Number(score.key) === state.value : score.key === "1",
|
||||
orientation: () => "both",
|
||||
loop: () => true,
|
||||
});
|
||||
|
||||
return {
|
||||
roving,
|
||||
rate: (value: number, event?: Event) => {
|
||||
if (!Number.isInteger(value) || value < 1 || value > 5) return;
|
||||
change("value", value, { reason: "item-press", event });
|
||||
},
|
||||
keydown(event: KeyboardEvent, el: HTMLElement) {
|
||||
const moved = roving.keydown(event, el);
|
||||
if (moved) {
|
||||
change("value", Number(moved.key), {
|
||||
reason: "list-navigation",
|
||||
event,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
slots: (slot) => ({
|
||||
root: slot({
|
||||
attrs: () => ({ role: "radiogroup" }),
|
||||
}),
|
||||
score: slot<{ value: string }>({
|
||||
props: { value: "string" },
|
||||
attrs: (state, part) => ({
|
||||
type: "button",
|
||||
role: "radio",
|
||||
"aria-checked": String(Number(part.key) === state.value),
|
||||
tabindex: part.api.roving.tabIndex(state, part),
|
||||
"data-filled": Number(part.key) <= state.value ? "" : undefined,
|
||||
}),
|
||||
press: ({ api, key }, event) => api.rate(Number(key), event),
|
||||
on: {
|
||||
keydown: (event, { el, api }) => {
|
||||
if (el) api.keydown(event, el);
|
||||
},
|
||||
},
|
||||
bind: (el, part) => part.api.roving.bind(el, part),
|
||||
}),
|
||||
}),
|
||||
agent: {
|
||||
actions: ["rate"],
|
||||
items: () => scores.map(({ value, label }) => ({
|
||||
value: String(value),
|
||||
label: `${value} of 5 · ${label} confidence`,
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
||||
export { triageScore, type TriageScoreOptions };
|
||||
@@ -498,14 +498,6 @@ export const routes: RouteRecordRaw[] = [
|
||||
description: "Every instance-wide setting: models, prompts, connections, runtime and status.",
|
||||
},
|
||||
},
|
||||
...(import.meta.env.DEV
|
||||
? [{
|
||||
path: "/dev/ui-sdk-lab",
|
||||
name: "ui-sdk-lab",
|
||||
component: () => import("@/devtools/ui-sdk/UiSdkLabPage.vue"),
|
||||
meta: { label: "UI SDK Lab", nav: false },
|
||||
}]
|
||||
: []),
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
name: "not-found",
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { cronForRule } from "../src/devtools/ui-sdk/schedule-rule.ts";
|
||||
|
||||
test("cronForRule emits canonical cron for guided recurrence patterns", () => {
|
||||
const cases = [
|
||||
[{ cadence: "daily", time: "09:05" }, "5 9 * * *"],
|
||||
[{ cadence: "weekly", time: "08:00", weekdays: [1, 2, 3, 4, 5] }, "0 8 * * 1-5"],
|
||||
[{ cadence: "weekly", time: "23:15", weekdays: [0, 6] }, "15 23 * * 0,6"],
|
||||
[{ cadence: "weekly", time: "08:00", weekdays: [6, 0, 2, 2] }, "0 8 * * 0,2,6"],
|
||||
[{ cadence: "weekly", time: "07:30", weekdays: [0, 1, 2, 3, 4, 5, 6] }, "30 7 * * *"],
|
||||
[{ cadence: "monthly", time: "09:30", day: 31 }, "30 9 31 * *"],
|
||||
] as const;
|
||||
|
||||
for (const [rule, expected] of cases) {
|
||||
assert.equal(cronForRule(rule), expected, JSON.stringify(rule));
|
||||
}
|
||||
});
|
||||
|
||||
test("cronForRule rejects invalid times and incomplete patterns", () => {
|
||||
const cases = [
|
||||
{ cadence: "daily", time: "9:05" },
|
||||
{ cadence: "daily", time: "24:00" },
|
||||
{ cadence: "daily", time: "09:60" },
|
||||
{ cadence: "weekly", time: "09:00", weekdays: [] },
|
||||
{ cadence: "weekly", time: "09:00", weekdays: [7] },
|
||||
{ cadence: "monthly", time: "09:00", day: 0 },
|
||||
{ cadence: "monthly", time: "09:00", day: 32 },
|
||||
] as const;
|
||||
|
||||
for (const rule of cases) {
|
||||
assert.equal(cronForRule(rule), null, JSON.stringify(rule));
|
||||
}
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en" data-theme="light">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#e9e7e2" />
|
||||
<title>UI SDK Lab | Archie</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/devtools/ui-sdk/standalone.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user