Files
archie/ui/src/tasks/TaskApproval.vue
T
sam 94f79177a2
deploy / gate (push) Successful in 4m53s
Quality / check (push) Successful in 6m42s
deploy / archied-image (push) Successful in 3m20s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped
fix(ui): adopt the type scale across components/ui and pages (#1758)
components/ui and the pages now use only the style.css scale:
text-[0.8rem]→text-label, text-[0.625rem]→text-micro, text-base/text-sm→
text-label (rows and controls), text-xs→text-caption (captions and
secondary text), text-lg/text-xl/text-2xl→text-title (panel and page
titles). Rendered markdown (ChatMarkdown/ChatInline/markdown.ts) keeps
Tailwind steps as the issue allows. 196 files, class-token swaps only.
2026-11-06 23:07:46 +11:00

105 lines
3.1 KiB
Vue

<script setup lang="ts">
import { computed, ref } from "vue";
import { ChevronDown } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Section } from "@/components/ui/section";
import ChatMarkdown from "@/chat/ChatMarkdown.vue";
import PlanDocumentView from "./PlanDocument.vue";
import type { PlanDocument, TaskRecord } from "./task-run";
import type { Task } from "./task";
import TaskRowActions from "./TaskRowActions.vue";
/**
* The decision a task waiting on a plan asks for: the plan, and the two
* answers beside it. A long plan is held to a readable height until opened,
* so the decision stays in reach.
*/
const props = defineProps<{ task: TaskRecord }>();
const emit = defineEmits<{ done: [] }>();
const plan = computed(() => props.task.plan?.trim() ?? "");
// A plan written as a document is laid out from its fields; one that does not
// decode is shown as its text, which the server rendered from the same fields.
const doc = computed<PlanDocument | null>(() => {
try {
const parsed = JSON.parse(props.task.plan_document || "null");
return parsed?.problem && parsed?.solution ? parsed : null;
} catch {
return null;
}
});
// A plan's own heading names what is being decided; the card shows it once.
const heading = computed(
() =>
doc.value?.title?.trim() ||
(plan.value
.match(/^#{1,3}\s+(.+)$/m)?.[1]
?.replace(/[`*_]/g, "")
.trim() ??
""),
);
const body = computed(() =>
heading.value ? plan.value.replace(/^#{1,3}\s+.+$/m, "").trim() : plan.value,
);
const open = ref(false);
// A plan short enough to read whole is never folded.
const long = computed(() => body.value.length > 1200);
</script>
<template>
<Section
title="Approve the plan"
:description="heading || undefined"
class="mb-0 min-w-0 ring-1 ring-warn/40"
>
<template #action>
<div class="flex items-center gap-2">
<TaskRowActions
:task="task as Task"
:only="['reject']"
@done="emit('done')"
/>
<TaskRowActions
:task="task as Task"
:only="['approve']"
@done="emit('done')"
/>
</div>
</template>
<div class="mx-auto max-w-[75ch]">
<div class="relative">
<div
:class="[
'overflow-hidden text-label leading-relaxed',
long && !open && 'max-h-96',
]"
>
<PlanDocumentView v-if="doc" :doc="doc" />
<ChatMarkdown v-else :text="body" />
</div>
<div
v-if="long && !open"
class="pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-card to-transparent"
/>
</div>
<Button
v-if="long"
variant="ghost"
size="sm"
class="mt-2"
:aria-expanded="open"
@click="open = !open"
>
{{ open ? "Collapse plan" : "Read the full plan" }}
<ChevronDown
:class="[
'size-4 transition-transform motion-reduce:transition-none',
open && 'rotate-180',
]"
/>
</Button>
</div>
</Section>
</template>