fix(ui): approve a plan from a card that holds the plan and both answers

This commit is contained in:
sam committed 2026-10-25 00:16:10 +11:00
1 parent 348c08cebb
commit 4b0cd45c00
4 files changed
+159 -108

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
<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 type { 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's own heading names what is being decided; the card shows it once.
const heading = computed(() => plan.value.match(/^#{1,3}\s+(.+)$/m)?.[1]?.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="mt-4 mb-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="relative">
<div :class="['overflow-hidden text-sm', long && !open && 'max-h-96']">
<ChatMarkdown :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>
</Section>
</template>
+7 -13
View File
@@ -23,7 +23,7 @@ import { MetadataList } from "@/components/ui/metadata-list";
import { Section } from "@/components/ui/section";
import StartNewRun from "./StartNewRun.vue";
import TaskRowActions from "./TaskRowActions.vue";
import ChatMarkdown from "@/chat/ChatMarkdown.vue";
import TaskApproval from "./TaskApproval.vue";
import { shownActionIds } from "./task-actions";
import { useTaskRun } from "./use-task-run";
@@ -78,15 +78,11 @@ async function jumpToLog(): Promise<void> {
}
}
// The head holds the decision a waiting task needs and the reap an operator
// reaches for once a task is finished with. Whether this task offers them is
// the server's action list, never this page's opinion about the status. A
// review gate answers through its findings panel instead.
const HEAD_ACTIONS = computed(() =>
run.task?.review_gate ? ["archive", "merge"] : ["approve", "reject", "archive", "merge"],
);
// The plan a waiting task asks the operator to approve.
const plan = computed(() => (run.task?.approval === "plan" ? run.task?.plan?.trim() : "") || "");
// The head has room for the reap an operator reaches for once a task is
// finished with. Whether this task offers it is the server's action list,
// never this page's opinion about the status. Approval answers live with the
// thing being approved.
const HEAD_ACTIONS = computed(() => ["archive", "merge"]);
// The run's inputs and written outputs, one row per name.
const rows = (values?: Record<string, unknown>) =>
@@ -152,9 +148,7 @@ const headerActions = computed(() =>
</div>
</div>
<Section v-if="plan" title="Plan to approve" class="mt-4 mb-0">
<ChatMarkdown :text="plan" class="text-sm" />
</Section>
<TaskApproval v-if="run.task?.approval === 'plan' && run.task.plan" :task="run.task" @done="run.refreshAll()" />
<Section v-if="description" title="Description" class="mt-4 mb-0">
<p class="whitespace-pre-wrap break-words text-sm text-fg-muted">{{ description }}</p>