feat(ui): suggest input on Combobox replaces datalists, RadioGroup for task pickers
Also records the combobox and radio-group components added in 63476393.
This commit is contained in:
1 parent
63476393d7
commit
ca597c3678
16 files changed
+192
-165
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import type { HTMLAttributes } from "vue";
|
||||
import { useVModel } from "@vueuse/core";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { inputClass } from "./classes";
|
||||
|
||||
const props = defineProps<{
|
||||
defaultValue?: string | number;
|
||||
@@ -25,7 +26,7 @@ const modelValue = useVModel(props, "modelValue", emits, {
|
||||
data-slot="input"
|
||||
:class="
|
||||
cn(
|
||||
'dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-9 rounded-lg border bg-card px-2.5 py-1 text-sm transition-colors pointer-coarse:text-base file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-fg-muted disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
|
||||
inputClass,
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export const inputClass =
|
||||
"dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-9 rounded-lg border bg-card px-2.5 py-1 text-sm transition-colors pointer-coarse:text-base file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-fg-muted disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50";
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { ComboboxAnchor, ComboboxContent, ComboboxInput, ComboboxItem, ComboboxPortal, ComboboxRoot, ComboboxViewport } from "reka-ui";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { inputClass } from "@/components/ui/input/classes";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = defineProps<{ options: string[]; class?: string }>();
|
||||
const model = defineModel<string>({ default: "" });
|
||||
const typed = ref(false);
|
||||
|
||||
const shown = computed(() => {
|
||||
const needle = typed.value ? model.value.toLowerCase() : "";
|
||||
return props.options.filter((o) => o.toLowerCase().includes(needle)).slice(0, 50);
|
||||
});
|
||||
|
||||
function type(value: string) {
|
||||
typed.value = true;
|
||||
model.value = value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ComboboxRoot v-model="model" ignore-filter open-on-focus :display-value="(v: string) => v" @update:open="typed = false">
|
||||
<ComboboxAnchor as-child>
|
||||
<ComboboxInput as-child :model-value="model" @update:model-value="type">
|
||||
<input v-bind="$attrs" data-slot="input" autocomplete="off" :class="cn(inputClass, props.class)" />
|
||||
</ComboboxInput>
|
||||
</ComboboxAnchor>
|
||||
<ComboboxPortal>
|
||||
<ComboboxContent
|
||||
v-if="shown.length"
|
||||
position="popper"
|
||||
:side-offset="4"
|
||||
class="z-50 max-h-60 w-(--reka-combobox-trigger-width) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10"
|
||||
>
|
||||
<ComboboxViewport class="max-h-60 overflow-y-auto p-1">
|
||||
<ComboboxItem
|
||||
v-for="option in shown"
|
||||
:key="option"
|
||||
:value="option"
|
||||
class="relative flex w-full cursor-default items-center rounded-md px-1.5 py-1 font-mono text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground"
|
||||
>{{ option }}</ComboboxItem>
|
||||
</ComboboxViewport>
|
||||
</ComboboxContent>
|
||||
</ComboboxPortal>
|
||||
</ComboboxRoot>
|
||||
</template>
|
||||
@@ -0,0 +1 @@
|
||||
export { default as SuggestInput } from './SuggestInput.vue'
|
||||
@@ -9,6 +9,7 @@ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SuggestInput } from "@/components/ui/suggest-input";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
@@ -138,7 +139,6 @@ interface OrgPolicy {
|
||||
}
|
||||
const policies = computed(() => store.draftValue("org-model-policy") as Record<string, OrgPolicy> | undefined);
|
||||
const otherOrgs = computed(() => (orgStore.instanceAdmin ? orgStore.orgs.filter((o) => o.id !== "org-sys") : []));
|
||||
const providerWildcards = computed(() => configuredIds.value.map((id) => `${id}/*`));
|
||||
function policyFor(id: string): OrgPolicy {
|
||||
return policies.value?.[id] ?? { allowed: [], own_providers: false };
|
||||
}
|
||||
@@ -166,9 +166,6 @@ function setAllowed(id: string, text: string) {
|
||||
</p>
|
||||
|
||||
<template v-if="aliases">
|
||||
<datalist id="alias-models">
|
||||
<option v-for="m in modelOptions" :key="m" :value="m" />
|
||||
</datalist>
|
||||
<Section title="Aliases">
|
||||
<p v-if="!aliases.default" class="mb-3 text-sm text-warn" role="alert">Set the default alias.</p>
|
||||
<div v-for="alias in aliasNames" :key="alias" class="flex flex-wrap items-center gap-3 border-b border-border py-2.5 last-of-type:border-b-0">
|
||||
@@ -191,10 +188,10 @@ function setAllowed(id: string, text: string) {
|
||||
<span v-if="!embeddingProviders.length" class="text-xs text-fg-subtle">Needs an openai, gemini, ollama, cohere or mistral provider.</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Input
|
||||
<SuggestInput
|
||||
:id="`alias-${alias}`"
|
||||
:model-value="aliases[alias] ?? ''"
|
||||
list="alias-models"
|
||||
:options="modelOptions"
|
||||
class="min-w-0 max-w-md flex-1 font-mono max-sm:max-w-none max-sm:basis-full"
|
||||
placeholder="unset"
|
||||
:aria-invalid="!!aliasIssue(alias)"
|
||||
@@ -216,15 +213,11 @@ function setAllowed(id: string, text: string) {
|
||||
</template>
|
||||
|
||||
<template v-if="policies && otherOrgs.length">
|
||||
<datalist id="org-allowed">
|
||||
<option v-for="m in [...providerWildcards, ...modelOptions]" :key="m" :value="m" />
|
||||
</datalist>
|
||||
<Section title="Org access">
|
||||
<div v-for="o in otherOrgs" :key="o.id" class="flex flex-wrap items-center gap-3 border-b border-border py-2.5 last-of-type:border-b-0">
|
||||
<span class="w-28 truncate text-sm font-medium max-sm:w-full" :title="o.id">{{ o.name }}</span>
|
||||
<Input
|
||||
:model-value="allowedText(o.id)"
|
||||
list="org-allowed"
|
||||
class="min-w-0 max-w-md flex-1 font-mono max-sm:max-w-none max-sm:basis-full"
|
||||
placeholder="no models"
|
||||
:aria-label="`Models ${o.name} may use`"
|
||||
@@ -239,9 +232,6 @@ function setAllowed(id: string, text: string) {
|
||||
</template>
|
||||
|
||||
<template v-if="providers">
|
||||
<datalist id="available-providers">
|
||||
<option v-for="p in available" :key="p.id" :value="p.id">{{ p.name }}</option>
|
||||
</datalist>
|
||||
<Section title="Providers">
|
||||
<Accordion type="multiple">
|
||||
<AccordionItem v-for="[name, provider] in providerEntries" :key="name" :value="name">
|
||||
@@ -317,7 +307,7 @@ function setAllowed(id: string, text: string) {
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
<form class="flex flex-wrap items-center gap-2 border-t border-border pt-3" @submit.prevent="addProvider">
|
||||
<Input v-model="newProvider" list="available-providers" class="max-w-56 font-mono" placeholder="provider" aria-label="New provider" />
|
||||
<SuggestInput v-model="newProvider" :options="available.map((p) => p.id)" class="max-w-56 font-mono" placeholder="provider" aria-label="New provider" />
|
||||
<Button type="submit" variant="outline" size="sm" :disabled="!newProvider.trim()"><Plus data-icon="inline-start" />Add provider</Button>
|
||||
<span v-if="available.length" class="text-xs text-fg-subtle">Available:
|
||||
<Button v-for="p in available" :key="p.id" type="button" variant="link" size="xs" class="h-auto px-1 font-mono text-fg-subtle" @click="newProvider = p.id; addProvider()">{{ p.id }}</Button>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { firstLine } from "./first-line";
|
||||
import { computed, onMounted, ref, useId, watchEffect } from "vue";
|
||||
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Kbd } from "@/components/ui/kbd";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { SuggestInput } from "@/components/ui/suggest-input";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { api } from "@/lib/api";
|
||||
@@ -103,41 +104,28 @@ async function submit() {
|
||||
<div v-if="repoMode !== 'none'" class="grid gap-1.5">
|
||||
<label :for="`${uid}-repo`" class="text-label font-medium">Repository<span v-if="!repoRequired" class="font-normal text-fg-subtle"> (optional)</span>
|
||||
</label>
|
||||
<Input :id="`${uid}-repo`" v-model="repository" class="font-mono" placeholder="owner/repository" :list="`${uid}-repos`" :required="repoRequired" />
|
||||
<datalist :id="`${uid}-repos`">
|
||||
<option v-for="r in recentRepos" :key="r" :value="r" />
|
||||
</datalist>
|
||||
<p v-if="recentRepos.length" class="text-xs text-fg-subtle">Configured:
|
||||
<Button
|
||||
v-for="r in recentRepos"
|
||||
:key="r"
|
||||
type="button"
|
||||
variant="link"
|
||||
size="xs"
|
||||
class="h-auto px-1 font-mono text-fg-subtle"
|
||||
@click="repository = r"
|
||||
>{{ r }}</Button
|
||||
>
|
||||
</p>
|
||||
<SuggestInput :id="`${uid}-repo`" v-model="repository" class="font-mono" placeholder="owner/repository" :options="recentRepos" :required="repoRequired" />
|
||||
</div>
|
||||
|
||||
<div v-if="!props.workflow" class="grid gap-1.5">
|
||||
<span :id="`${uid}-wf`" class="text-label font-medium">Workflow</span>
|
||||
<RadioGroupRoot v-model="workflow" :aria-labelledby="`${uid}-wf`" class="grid grid-cols-1 gap-2 sm:grid-cols-3" loop>
|
||||
<RadioGroupItem
|
||||
<RadioGroup v-model="workflow" :aria-labelledby="`${uid}-wf`" class="grid grid-cols-1 gap-2 sm:grid-cols-3" loop>
|
||||
<label
|
||||
v-for="d in definitions"
|
||||
:key="d.id"
|
||||
:value="d.id"
|
||||
class="rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-secondary focus-visible:outline-2 focus-visible:outline-ring data-[state=checked]:border-primary data-[state=checked]:bg-secondary"
|
||||
class="flex cursor-pointer items-start gap-3 rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-secondary has-data-checked:border-primary has-data-checked:bg-secondary"
|
||||
>
|
||||
<span class="block truncate text-label font-medium">{{ d.name || d.id }}</span>
|
||||
<span class="block text-xs text-fg-subtle">
|
||||
{{ statFor(d.id)?.runs || 0 }} runs<template v-if="statFor(d.id)?.runs">
|
||||
· {{ Math.round((delivered(statFor(d.id)) / (statFor(d.id)?.runs || 1)) * 100) }}% delivered</template
|
||||
>
|
||||
<RadioGroupItem :value="d.id" class="mt-0.5" />
|
||||
<span class="min-w-0">
|
||||
<span class="block truncate text-label font-medium">{{ d.name || d.id }}</span>
|
||||
<span class="block text-xs text-fg-subtle">
|
||||
{{ statFor(d.id)?.runs || 0 }} runs<template v-if="statFor(d.id)?.runs">
|
||||
· {{ Math.round((delivered(statFor(d.id)) / (statFor(d.id)?.runs || 1)) * 100) }}% delivered</template
|
||||
>
|
||||
</span>
|
||||
</span>
|
||||
</RadioGroupItem>
|
||||
</RadioGroupRoot>
|
||||
</label>
|
||||
</RadioGroup>
|
||||
<p v-if="!definitions.length && !loadError" class="text-xs text-fg-subtle">No enabled workflows.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import {
|
||||
@@ -372,7 +372,7 @@ function onConfirmationOpen(open: boolean) {
|
||||
<DialogTitle>Retry this task?</DialogTitle>
|
||||
<DialogDescription>Retry from</DialogDescription>
|
||||
</DialogHeader>
|
||||
<RadioGroupRoot
|
||||
<RadioGroup
|
||||
v-model="retryMode"
|
||||
class="grid grid-cols-1 gap-2"
|
||||
aria-label="Retry worktree mode"
|
||||
@@ -398,7 +398,7 @@ function onConfirmationOpen(open: boolean) {
|
||||
<span class="text-xs text-fg-subtle">{{ option.description }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</RadioGroupRoot>
|
||||
</RadioGroup>
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" :disabled="inFlight" @click="onRetryOpen(false)">Keep it parked</Button>
|
||||
<Button
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SuggestInput } from "@/components/ui/suggest-input";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { ArrowLeft, Braces, Type } from "@lucide/vue";
|
||||
@@ -287,7 +288,6 @@ const resume = () => transition(api.bindingResume, "pending_approval");
|
||||
|
||||
<section class="space-y-1.5">
|
||||
<div class="text-xs font-medium text-fg-muted">Inputs</div>
|
||||
<datalist id="bind-paths"><option v-for="path in paths" :key="path" :value="path" /></datalist>
|
||||
<div class="divide-y divide-border rounded-md border border-border">
|
||||
<div v-for="[name, spec] in inputs" :key="name" class="space-y-1 px-3 py-2">
|
||||
<div class="flex items-center gap-1.5 text-xs">
|
||||
@@ -306,10 +306,10 @@ const resume = () => transition(api.bindingResume, "pending_approval");
|
||||
<Type v-if="rows[name]!.from === 'path'" /><Braces v-else />
|
||||
</Button>
|
||||
</div>
|
||||
<Input
|
||||
<SuggestInput
|
||||
v-if="rows[name]!.from === 'path'"
|
||||
v-model="rows[name]!.path"
|
||||
list="bind-paths"
|
||||
:options="paths"
|
||||
:aria-label="`${name} payload path`"
|
||||
placeholder="payload path"
|
||||
class="h-8 w-full font-mono text-xs"
|
||||
@@ -326,9 +326,9 @@ const resume = () => transition(api.bindingResume, "pending_approval");
|
||||
</div>
|
||||
<div v-if="repository" class="space-y-1 px-3 py-2">
|
||||
<div class="text-xs" title="Optional: owner/name of a configured repository; blank uses the configured one">Repository</div>
|
||||
<Input
|
||||
<SuggestInput
|
||||
v-model="repositoryPath"
|
||||
list="bind-paths"
|
||||
:options="paths"
|
||||
aria-label="Repository payload path"
|
||||
placeholder="payload path"
|
||||
class="h-8 w-full font-mono text-xs"
|
||||
|
||||
@@ -6,6 +6,7 @@ import { parse, stringify } from "yaml";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DurationInput } from "@/components/ui/duration-input";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SuggestInput } from "@/components/ui/suggest-input";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { addBranch, branchingOf, deleteBranch, renameBranch, earlierStepIDs, replaceStep, stepAt, workflowField, type StepPath, type StepRecord } from "./workflow-edit";
|
||||
@@ -159,8 +160,7 @@ const ON_FAILURE = [{ value: "", label: "Park the task" }, { value: "continue",
|
||||
<section v-if="branching" class="space-y-3">
|
||||
<label v-if="type === 'switch'" class="block space-y-1.5">
|
||||
<span class="text-xs font-medium text-fg-muted" title="The value whose case runs; a case named default runs when none matches">Switch on</span>
|
||||
<Input :model-value="branching.on" class="font-mono" placeholder="steps.assess.result.fit" :list="`${uid}-switch-on`" @change="setOn(($event.target as HTMLInputElement).value.trim())" />
|
||||
<datalist :id="`${uid}-switch-on`"><option v-for="id in earlier" :key="id" :value="`steps.${id}.result.`" /></datalist>
|
||||
<SuggestInput :model-value="branching.on" class="font-mono" placeholder="steps.assess.result.fit" :options="earlier.map((id) => `steps.${id}.result.`)" @change="setOn(($event.target as HTMLInputElement).value.trim())" />
|
||||
</label>
|
||||
<div class="text-xs font-medium text-fg-muted">{{ type === "switch" ? "Cases" : "Branches" }}</div>
|
||||
<div v-for="name in branches" :key="name" class="flex items-center gap-2">
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { useId } from "vue";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SuggestInput } from "@/components/ui/suggest-input";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
|
||||
defineProps<{ value: string; workflows: { id: string }[]; label: string; class?: string; editable?: boolean }>();
|
||||
const listId = useId();
|
||||
const emit = defineEmits<{ pick: [string] }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="editable">
|
||||
<Input :model-value="value" :list="listId" :aria-label="label" :class="$props.class" placeholder="Workflow id or {{ reference }}" @update:model-value="emit('pick', String($event))" />
|
||||
<datalist :id="listId"><option v-for="entry in workflows" :key="entry.id" :value="entry.id" /></datalist>
|
||||
<SuggestInput :model-value="value" :options="workflows.map((entry) => entry.id)" :aria-label="label" :class="$props.class" placeholder="Workflow id or {{ reference }}" @update:model-value="emit('pick', $event)" />
|
||||
</template>
|
||||
<Select v-else :model-value="value || undefined" @update:model-value="emit('pick', String($event))">
|
||||
<SelectTrigger :aria-label="label" :class="$props.class"><SelectValue placeholder="Choose workflow" /></SelectTrigger>
|
||||
|
||||
Reference in new issue
Block a user