perf(ui): mount row action dialogs only while open and keep unchanged live reloads (#1798)
deploy / gate (push) Failing after 13m59s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped

This commit is contained in:
sam committed 2026-11-08 16:55:59 +11:00
1 parent c8a46fd9e7
commit 64bb195700
6 files changed
+20 -13

No files matched your search

+2 -1
View File
@@ -1,6 +1,7 @@
import { ref } from "vue";
import { api } from "@/lib/api";
import { keepRows } from "@/lib/keep-unchanged";
import { useLiveResource } from "@/stores/session";
import { loadEventTypes } from "./event-type-state";
@@ -68,7 +69,7 @@ export async function load(): Promise<void> {
const res = await api.captures<CapturesResponse>(LIST_LIMIT);
if (current !== generation) return;
enabled.value = res.enabled !== false;
captures.value = res.captures || [];
captures.value = keepRows(captures.value, res.captures || []);
error.value = null;
} catch (err) {
if (current !== generation) return;
+5 -3
View File
@@ -270,6 +270,8 @@ function onConfirmationOpen(open: boolean) {
<template>
<div class="flex flex-col items-end gap-1">
<!-- The dialogs below mount only while open: a board holds hundreds of rows
and each would otherwise carry three idle dialog trees. -->
<Alert
v-if="error"
variant="destructive"
@@ -332,7 +334,7 @@ function onConfirmationOpen(open: boolean) {
</MoreMenu></span>
</div>
<Dialog :open="rereviewOpen" @update:open="onRereviewOpen">
<Dialog v-if="rereviewOpen" :open="rereviewOpen" @update:open="onRereviewOpen">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Re-review this pull request?</DialogTitle>
@@ -366,7 +368,7 @@ function onConfirmationOpen(open: boolean) {
preparation reads it. Preselecting the task's persisted mode keeps a
remediation retry continuing its branch.
-->
<Dialog :open="retryOpen" @update:open="onRetryOpen">
<Dialog v-if="retryOpen" :open="retryOpen" @update:open="onRetryOpen">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Retry this task?</DialogTitle>
@@ -411,7 +413,7 @@ function onConfirmationOpen(open: boolean) {
</DialogContent>
</Dialog>
<AlertDialog :open="confirming !== null" @update:open="onConfirmationOpen">
<AlertDialog v-if="confirming !== null" :open="confirming !== null" @update:open="onConfirmationOpen">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{{ confirmLabel }} this task?</AlertDialogTitle>
+5 -4
View File
@@ -25,6 +25,7 @@ import {
import { useRoute, useRouter } from "vue-router";
import { api, classifyActionError, type ActionErrorKind } from "@/lib/api";
import { keepValue } from "@/lib/keep-unchanged";
import { actionFor } from "@/lib/task-meta";
import { useLiveResource } from "@/stores/session";
@@ -194,7 +195,7 @@ export function provideTaskRun(id: ComputedRef<number | null>): TaskRun {
Promise.race([fetcher(), timeout])
.then((res) => {
if (loadGenerations.get(cacheKey) !== current) return;
cache.value = new Map(cache.value).set(cacheKey, res);
cache.value = new Map(cache.value).set(cacheKey, keepValue(cache.value.get(cacheKey), res));
})
.catch(() => {
if (loadGenerations.get(cacheKey) !== current) return;
@@ -208,7 +209,7 @@ export function provideTaskRun(id: ComputedRef<number | null>): TaskRun {
api
.tasks<TaskRecord[]>()
.then((res) => {
taskList.value = res;
taskList.value = keepValue(taskList.value, res);
})
.catch(() => {
// Keep the last known list: a failed refresh must not flash the
@@ -223,7 +224,7 @@ export function provideTaskRun(id: ComputedRef<number | null>): TaskRun {
api
.taskAttempts<AttemptsState>(String(id.value))
.then((res) => {
attempts.value = res;
attempts.value = keepValue(attempts.value, res);
})
.catch((err) => {
if ((err as { status?: number })?.status === 404) missing.value = true;
@@ -237,7 +238,7 @@ export function provideTaskRun(id: ComputedRef<number | null>): TaskRun {
api
.task<TaskEvent[]>(String(id.value))
.then((res) => {
events.value = res || [];
events.value = keepValue(events.value, res || []);
})
.catch(() => {
events.value = null;
+2 -1
View File
@@ -20,6 +20,7 @@ import {
} from "@/components/ui/trace";
import ChatMarkdown from "@/chat/ChatMarkdown.vue";
import { api } from "@/lib/api";
import { keepValue } from "@/lib/keep-unchanged";
import { useLiveResource } from "@/stores/session";
import { duration } from "@/tasks/timeline-event";
import type { TaskEvent } from "@/tasks/task-run";
@@ -49,7 +50,7 @@ async function load(): Promise<void> {
try {
const view = await api.taskTranscript<{ entries?: TaskEvent[] }>(String(props.taskId), { attempt: props.attempt });
if (current !== generation) return;
events.value = view.entries ?? [];
events.value = keepValue(events.value, view.entries ?? []);
failed.value = false;
} catch {
if (current === generation) failed.value = true;
+2 -1
View File
@@ -13,6 +13,7 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import { api } from "@/lib/api";
import { keepRows } from "@/lib/keep-unchanged";
import { useLiveResource } from "@/stores/session";
import { statusKind, statusLabel, takesRepository, type Binding } from "@/bindings/binding-draft";
import type { Capture } from "@/captures/state";
@@ -82,7 +83,7 @@ const status = ref(props.binding?.status ?? "");
async function loadCaptures(): Promise<void> {
const listed = await api.captures<{ captures?: Capture[] }>(100).catch(() => null);
captures.value = listed?.captures ?? [];
captures.value = keepRows(captures.value, listed?.captures ?? []);
}
async function loadAll(): Promise<void> {
+4 -3
View File
@@ -3,6 +3,7 @@ import { Item, ItemGroup } from "@/components/ui/item";
import { Button } from "@/components/ui/button";
import { computed, onUnmounted, ref, watch } from "vue";
import { api } from "@/lib/api";
import { keepValue } from "@/lib/keep-unchanged";
import { useLiveResource } from "@/stores/session";
import { Badge } from "@/components/ui/badge";
import ChangeCapture from "@/tasks/ChangeCapture.vue";
@@ -42,10 +43,10 @@ async function refresh(): Promise<void> {
if (current !== generation) return;
const [activity, capture, log] = results;
activityError.value = activity.status === "rejected" ? "Could not load step activity" : "";
if (activity.status === "fulfilled") events.value = activity.value.events ?? [];
if (activity.status === "fulfilled") events.value = keepValue(events.value, activity.value.events ?? []);
changesError.value = capture.status === "rejected" ? "Could not load captured changes" : "";
if (capture.status === "fulfilled") changes.value = capture.value;
logs.value = log.status === "fulfilled" ? log.value : null;
if (capture.status === "fulfilled") changes.value = keepValue(changes.value, capture.value);
logs.value = log.status === "fulfilled" ? keepValue(logs.value, log.value) : null;
loading = false;
if (queued) { queued = false; void refresh(); }
}