feat(ui): select review gate findings before approval

This commit is contained in:
sam committed 2026-10-05 14:43:07 +11:00
1 parent 6a8481f203
commit fe30a02072
7 files changed
+168 -67

No files matched your search

+2
View File
@@ -8,6 +8,7 @@ import { Tabs } from "@/components/ui/tabs";
import TabBar from "./TabBar.vue";
import TaskDetailNotice from "./TaskDetailNotice.vue";
import TaskHeader from "./TaskHeader.vue";
import TaskReviewGate from "./TaskReviewGate.vue";
import TaskNotes from "./TaskNotes.vue";
import TaskRunPanels from "./TaskRunPanels.vue";
import TaskRail from "./TaskRail.vue";
@@ -48,6 +49,7 @@ const run = provideTaskRun(taskId);
<div v-else>
<TaskHeader :id="rawId" />
<TaskNotes :id="rawId" />
<TaskReviewGate v-if="run.task" :task="run.task" @done="run.refreshAll()" />
<div class="grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]">
<Card class="min-w-0">
+52
View File
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import TaskRowActions from "./TaskRowActions.vue";
import type { Task } from "./TaskRow.vue";
import { reviewGateOffer } from "./review-gate";
const props = defineProps<{ task: Task }>();
const emit = defineEmits<{ done: [taskId: Task["id"]] }>();
const gate = computed(() => props.task.status === "waiting_human" ? reviewGateOffer(props.task.review_gate) : null);
const selected = ref<string[]>([]);
watch(() => props.task.review_gate, () => {
selected.value = gate.value?.findings.map((entry) => entry.key) ?? [];
}, { immediate: true });
</script>
<template>
<Card v-if="gate" class="mb-6">
<CardHeader>
<CardTitle>Review findings</CardTitle>
<p class="text-sm text-muted-foreground">Select the findings to post to the pull request.</p>
<p v-if="gate.head_sha" class="break-all font-mono text-xs text-muted-foreground">Head commit: {{ gate.head_sha }}</p>
</CardHeader>
<CardContent class="space-y-4">
<ul class="divide-y divide-border rounded-md border border-border">
<li v-for="entry in gate.findings" :key="entry.key" class="space-y-2 p-4">
<label class="flex cursor-pointer items-start gap-3">
<input v-model="selected" type="checkbox" :value="entry.key" :aria-label="entry.finding.Title" class="mt-1 shrink-0" />
<span class="min-w-0 space-y-1">
<span class="block text-sm font-medium">{{ entry.finding.Title }}</span>
<span class="block break-all font-mono text-xs text-muted-foreground">{{ entry.finding.File }}<template v-if="entry.finding.LineStart">:{{ entry.finding.LineStart }}<template v-if="entry.finding.LineEnd > entry.finding.LineStart">–{{ entry.finding.LineEnd }}</template></template></span>
</span>
</label>
<div class="flex flex-wrap items-center gap-2 text-xs">
<Badge variant="outline">{{ entry.finding.Severity }}</Badge>
<Badge v-if="entry.finding.Blocking" variant="danger">Blocking</Badge>
<span>Score: {{ entry.finding.Score }}</span>
<span>Confidence: {{ entry.finding.Confidence }}</span>
</div>
<p class="whitespace-pre-wrap break-words text-sm">{{ entry.finding.Body }}</p>
<p v-if="entry.finding.Evidence" class="whitespace-pre-wrap break-words text-xs text-muted-foreground">Evidence: {{ entry.finding.Evidence }}</p>
<pre v-if="entry.finding.Suggestion" class="overflow-x-auto rounded-md bg-secondary p-2 text-xs">{{ entry.finding.Suggestion }}</pre>
</li>
</ul>
<div class="flex flex-wrap items-center justify-between gap-3">
<p class="text-xs text-muted-foreground">{{ selected.length }} of {{ gate.findings.length }} selected<template v-if="!selected.length">. Select at least one finding to approve.</template></p>
<TaskRowActions :task="task" :only="['approve', 'rereview', 'reject']" :findings="selected" @done="emit('done', $event)" />
</div>
</CardContent>
</Card>
</template>
+18 -3
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { Ellipsis } from "@lucide/vue";
import { computed, ref } from "vue";
import { useRouter } from "vue-router";
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
@@ -35,6 +36,7 @@ import { api, classifyActionError, type ActionErrorKind } from "@/lib/api";
import { actionFor, retryModes, type ActionMeta } from "@/lib/task-meta";
import type { Task } from "./TaskRow.vue";
import { shownActionIds } from "./task-actions";
import { reviewGateOffer } from "./review-gate";
import {
initialRetryChoice,
retryChoices,
@@ -64,9 +66,14 @@ const props = defineProps<{
task: Task;
/** Render only these action ids, still only if the server offered them. */
only?: string[];
findings?: string[];
}>();
const emit = defineEmits<{ done: [taskId: Task["id"]] }>();
const router = useRouter();
const gate = computed(() => props.task.status === "waiting_human" ? reviewGateOffer(props.task.review_gate) : null);
// An empty selection means all findings to the server.
const approveDisabled = computed(() => !!gate.value && props.findings?.length === 0);
const inFlight = ref(false);
const error = ref<{ kind: ActionErrorKind; message: string } | null>(null);
@@ -178,6 +185,10 @@ function variantFor(kind: string): ControlVariant {
// which its own dialog collects.
function request(id: string) {
error.value = null;
if (id === "approve" && gate.value && props.findings === undefined) {
void router.push(`/tasks/${props.task.id}`);
return;
}
if (id === "rereview") {
rereviewId.value = id;
rereviewOpen.value = true;
@@ -202,8 +213,12 @@ function request(id: string) {
async function run(
id: string,
payload?: { instructions?: string; retry_mode?: string },
payload?: { instructions?: string; retry_mode?: string; findings?: string[] },
) {
if (id === "approve" && gate.value) {
if (!props.findings?.length) return;
payload = { ...payload, findings: props.findings };
}
confirming.value = null;
inFlight.value = true;
error.value = null;
@@ -281,7 +296,7 @@ function requestFromMenu(id: string) {
v-if="primaryControl"
:variant="variantFor(primaryControl.kind)"
size="sm"
:disabled="inFlight"
:disabled="inFlight || (primaryControl.id === 'approve' && approveDisabled)"
@click.stop="request(primaryControl.id)"
>
{{ primaryControl.label }}
@@ -325,7 +340,7 @@ function requestFromMenu(id: string) {
v-for="control in overflowControls"
:key="control.id"
:variant="control.kind === 'danger' ? 'destructive' : 'default'"
:disabled="inFlight"
:disabled="inFlight || (control.id === 'approve' && approveDisabled)"
@click.stop="requestFromMenu(control.id)"
>
{{ control.label }}
+30
View File
@@ -0,0 +1,30 @@
export interface ReviewGate {
head_sha?: string;
outcome?: string;
findings: {
key: string;
finding: {
Title: string;
Body: string;
File: string;
LineStart: number;
LineEnd: number;
Severity: string;
Score: number;
Confidence: number;
Evidence?: string;
Suggestion?: string;
Blocking?: boolean;
};
}[];
}
export function reviewGateOffer(stored?: string): ReviewGate | null {
if (!stored) return null;
try {
const gate = JSON.parse(stored) as ReviewGate;
return !gate.outcome && Array.isArray(gate.findings) && gate.findings.length ? gate : null;
} catch {
return null;
}
}
+2
View File
@@ -54,6 +54,8 @@ export interface TaskRecord {
park_reason?: string;
tokens_used?: number;
actions?: string[];
review_gate?: string;
rereview_rounds?: number;
}
/** One stage of one attempt, as `GET /api/tasks/{id}/attempts` returns it. */
+1 -1
View File
@@ -196,7 +196,7 @@ export function provideTaskRun(id: ComputedRef<number | null>): TaskRun {
function loadTaskList(): void {
if (id.value == null) return;
taskList.value = undefined;
// Keep the current gate mounted so a refresh preserves its selection.
api
.tasks<TaskRecord[]>()
.then((res) => {