feat(webui): let the operator choose the retry worktree mode
A retry now carries the operator's worktree choice (refresh onto the base branch or continue the work already pushed on the task branch) from the dashboard through the task action to the daemon dispatch, and persists it on the task row so it survives a reload. The daemon resolves the mode from the task, never from the workflow; BeginRemediation records continue explicitly so a remediation still resumes its pull request branch.
This commit is contained in:
1 parent
ef203ce30a
commit
19520a63e5
58 files changed
+977
-252
No files matched your search
+8
-3
@@ -152,12 +152,17 @@ export const api = {
|
||||
request<T>(`/api/tasks/${encodeURIComponent(id)}/debug` + qs(params)),
|
||||
// taskAction posts an operator action. A review-gate answer may carry a
|
||||
// payload: the instructions a rereview requires, and the finding keys an
|
||||
// approve posts (an absent selection means every offered finding). Every
|
||||
// other action sends neither.
|
||||
// approve posts (an absent selection means every offered finding). A retry
|
||||
// carries the worktree mode the operator chose. Every other action sends
|
||||
// none.
|
||||
taskAction: <T = unknown>(
|
||||
id: string,
|
||||
action: string,
|
||||
payload?: { instructions?: string; findings?: string[] },
|
||||
payload?: {
|
||||
instructions?: string;
|
||||
findings?: string[];
|
||||
retry_mode?: string;
|
||||
},
|
||||
) =>
|
||||
request<T>(`/api/tasks/${encodeURIComponent(id)}/action`, {
|
||||
method: "POST",
|
||||
|
||||
@@ -24,6 +24,15 @@ export interface ChangeStatusMeta {
|
||||
label: string;
|
||||
}
|
||||
|
||||
/** A retry worktree mode as the server describes it. */
|
||||
export interface RetryModeMeta {
|
||||
id: string;
|
||||
label: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
requires_branch?: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_STATUSES: StatusMeta[] = [
|
||||
{ id: "queued", label: "Queued", kind: "idle" },
|
||||
{ id: "running", label: "Working", kind: "info" },
|
||||
@@ -88,4 +97,21 @@ export const DEFAULT_CHANGE_STATUSES: ChangeStatusMeta[] = [
|
||||
{ id: "typechange", label: "Type changed" },
|
||||
];
|
||||
|
||||
export const DEFAULT_RETRY_MODES: RetryModeMeta[] = [
|
||||
{
|
||||
id: "refresh_onto_base",
|
||||
label: "Refresh onto base",
|
||||
description:
|
||||
"Start the retry from the current base branch, discarding work already pushed on this task's branch.",
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: "continue_pushed_work",
|
||||
label: "Continue pushed work",
|
||||
description:
|
||||
"Resume the branch this task already pushed, keeping its commits.",
|
||||
requires_branch: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const DEFAULT_CONFIG_SCHEMA = "archie/task-config@1";
|
||||
+29
-1
@@ -28,14 +28,17 @@ import {
|
||||
DEFAULT_ACTIONS,
|
||||
DEFAULT_CHANGE_STATUSES,
|
||||
DEFAULT_CONFIG_SCHEMA,
|
||||
DEFAULT_RETRY_MODES,
|
||||
DEFAULT_STATUSES,
|
||||
type RetryModeMeta,
|
||||
type StatusMeta,
|
||||
} from "./task-meta-snapshot";
|
||||
|
||||
export type { ActionMeta, ChangeStatusMeta, StatusMeta };
|
||||
export type { ActionMeta, ChangeStatusMeta, RetryModeMeta, StatusMeta };
|
||||
|
||||
const statuses = shallowRef<StatusMeta[]>([...DEFAULT_STATUSES]);
|
||||
const actions = shallowRef<ActionMeta[]>([...DEFAULT_ACTIONS]);
|
||||
const retryModesRef = shallowRef<RetryModeMeta[]>([...DEFAULT_RETRY_MODES]);
|
||||
const changeStatuses = shallowRef<ChangeStatusMeta[]>([
|
||||
...DEFAULT_CHANGE_STATUSES,
|
||||
]);
|
||||
@@ -48,6 +51,9 @@ const actionById = computed(() => new Map(actions.value.map((a) => [a.id, a])));
|
||||
const changeStatusById = computed(
|
||||
() => new Map(changeStatuses.value.map((c) => [c.id, c])),
|
||||
);
|
||||
const retryModeById = computed(
|
||||
() => new Map(retryModesRef.value.map((m) => [m.id, m])),
|
||||
);
|
||||
|
||||
// loadTaskMeta upgrades the dashboard from the server catalog. It never throws:
|
||||
// a failed fetch keeps the defaults so the UI still renders.
|
||||
@@ -56,11 +62,13 @@ export async function loadTaskMeta(): Promise<void> {
|
||||
const data = await api.taskMeta<{
|
||||
statuses?: StatusMeta[];
|
||||
actions?: ActionMeta[];
|
||||
retry_modes?: RetryModeMeta[];
|
||||
change_statuses?: ChangeStatusMeta[];
|
||||
config_schema?: string;
|
||||
} | null>();
|
||||
if (Array.isArray(data?.statuses)) statuses.value = data.statuses;
|
||||
if (Array.isArray(data?.actions)) actions.value = data.actions;
|
||||
if (Array.isArray(data?.retry_modes)) retryModesRef.value = data.retry_modes;
|
||||
if (Array.isArray(data?.change_statuses))
|
||||
changeStatuses.value = data.change_statuses;
|
||||
if (data?.config_schema) configSchemaRef.value = data.config_schema;
|
||||
@@ -105,6 +113,26 @@ export function actionFor(id: string): ActionMeta | null {
|
||||
return actionById.value.get(id) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* retryModes returns the server's retry worktree modes in display order. The
|
||||
* retry dialog renders these and falls back to the frozen snapshot before the
|
||||
* catalog arrives.
|
||||
*/
|
||||
export function retryModes(): RetryModeMeta[] {
|
||||
return retryModesRef.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* retryModeFor returns one retry mode's metadata, or null if the server has
|
||||
* never described it.
|
||||
*/
|
||||
export function retryModeFor(
|
||||
id: string | null | undefined,
|
||||
): RetryModeMeta | null {
|
||||
if (!id) return null;
|
||||
return retryModeById.value.get(id) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* changeStatusLabel names a changes_captured file status. An id the catalog
|
||||
* does not know renders as itself rather than breaking the row.
|
||||
|
||||
@@ -20,6 +20,13 @@ export interface Task {
|
||||
tokens_used?: number;
|
||||
workflow?: string;
|
||||
attempt?: number;
|
||||
/** The branch this task pushed, if any. A retry that continues pushed work
|
||||
* resumes it; the retry dialog disables that mode when it is empty. */
|
||||
branch?: string;
|
||||
/** The operator's persisted worktree choice for the next retry dispatch
|
||||
* ("refresh_onto_base" or "continue_pushed_work"). The retry dialog opens
|
||||
* on this value so the choice survives a reload. */
|
||||
retry_mode?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
actions?: string[];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Ellipsis } from "@lucide/vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import {
|
||||
@@ -31,9 +32,14 @@ import {
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { api, classifyActionError, type ActionErrorKind } from "@/lib/api";
|
||||
import { actionFor, type ActionMeta } from "@/lib/task-meta";
|
||||
import { actionFor, retryModes, type ActionMeta } from "@/lib/task-meta";
|
||||
import type { Task } from "./TaskRow.vue";
|
||||
import { shownActionIds } from "./task-actions";
|
||||
import {
|
||||
initialRetryChoice,
|
||||
retryChoices,
|
||||
retryPayload,
|
||||
} from "./retry-mode";
|
||||
|
||||
/**
|
||||
* The lifecycle controls for one task. A task offers whatever the server says
|
||||
@@ -77,6 +83,17 @@ const rereviewOpen = ref(false);
|
||||
const rereviewId = ref<string | null>(null);
|
||||
const instructions = ref("");
|
||||
|
||||
// A retry carries the operator's worktree mode (taskstate.RetryMode). The
|
||||
// dialog opens on the task's persisted choice -- so a remediation retry keeps
|
||||
// continuing its branch -- and the operator may pick the other mode. The
|
||||
// chosen value travels in the action body and is persisted on the task.
|
||||
const retryOpen = ref(false);
|
||||
const retryId = ref<string | null>(null);
|
||||
const retryMode = ref("");
|
||||
const retryOptions = computed(() =>
|
||||
retryChoices(retryModes(), props.task.branch),
|
||||
);
|
||||
|
||||
const controls = computed<Control[]>(() =>
|
||||
shownActionIds(props.task.actions, props.only)
|
||||
.map((id) => actionFor(id))
|
||||
@@ -157,7 +174,8 @@ function variantFor(kind: string): ControlVariant {
|
||||
|
||||
// A control that names a consequence is confirmed first; the two that only open
|
||||
// a forge page are not, because they change nothing. A re-review needs
|
||||
// instructions, which its own dialog collects.
|
||||
// instructions, which its own dialog collects; a retry needs a worktree mode,
|
||||
// which its own dialog collects.
|
||||
function request(id: string) {
|
||||
error.value = null;
|
||||
if (id === "rereview") {
|
||||
@@ -165,6 +183,15 @@ function request(id: string) {
|
||||
rereviewOpen.value = true;
|
||||
return;
|
||||
}
|
||||
if (id === "retry") {
|
||||
retryId.value = id;
|
||||
retryMode.value = initialRetryChoice(
|
||||
retryOptions.value,
|
||||
props.task.retry_mode,
|
||||
);
|
||||
retryOpen.value = true;
|
||||
return;
|
||||
}
|
||||
if (actionFor(id)?.confirm) {
|
||||
confirmingId.value = id;
|
||||
confirming.value = id;
|
||||
@@ -173,7 +200,10 @@ function request(id: string) {
|
||||
void run(id);
|
||||
}
|
||||
|
||||
async function run(id: string, payload?: { instructions?: string }) {
|
||||
async function run(
|
||||
id: string,
|
||||
payload?: { instructions?: string; retry_mode?: string },
|
||||
) {
|
||||
confirming.value = null;
|
||||
inFlight.value = true;
|
||||
error.value = null;
|
||||
@@ -202,6 +232,17 @@ function submitRereview() {
|
||||
void run(id, { instructions: text });
|
||||
}
|
||||
|
||||
function onRetryOpen(open: boolean) {
|
||||
retryOpen.value = open;
|
||||
}
|
||||
|
||||
function submitRetry() {
|
||||
const id = retryId.value;
|
||||
if (!id || !retryMode.value) return;
|
||||
retryOpen.value = false;
|
||||
void run(id, retryPayload(retryMode.value));
|
||||
}
|
||||
|
||||
function onConfirmationOpen(open: boolean) {
|
||||
if (!open) confirming.value = null;
|
||||
}
|
||||
@@ -329,6 +370,60 @@ function requestFromMenu(id: string) {
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<!--
|
||||
A retry opens this dialog rather than firing immediately: the operator
|
||||
picks where the retry starts (taskstate.RetryMode), the choice rides the
|
||||
action body and is persisted on the task, and the daemon's worktree
|
||||
preparation reads it. Preselecting the task's persisted mode keeps a
|
||||
remediation retry continuing its branch.
|
||||
-->
|
||||
<Dialog :open="retryOpen" @update:open="onRetryOpen">
|
||||
<DialogContent class="sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Retry this task?</DialogTitle>
|
||||
<DialogDescription>
|
||||
Choose where the retry starts. The mode is saved on the task and
|
||||
the daemon prepares the worktree from it.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<RadioGroupRoot
|
||||
v-model="retryMode"
|
||||
class="grid grid-cols-1 gap-2"
|
||||
aria-label="Retry worktree mode"
|
||||
loop
|
||||
>
|
||||
<label
|
||||
v-for="option in retryOptions"
|
||||
:key="option.id"
|
||||
class="flex items-start gap-3 rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors"
|
||||
:class="
|
||||
option.disabled
|
||||
? 'cursor-not-allowed opacity-60'
|
||||
: 'cursor-pointer hover:bg-secondary'
|
||||
"
|
||||
>
|
||||
<RadioGroupItem
|
||||
:value="option.id"
|
||||
:disabled="option.disabled || inFlight"
|
||||
class="mt-0.5 shrink-0"
|
||||
/>
|
||||
<span class="grid gap-0.5">
|
||||
<span class="text-[13px] font-medium">{{ option.label }}</span>
|
||||
<span class="text-xs text-fg-subtle">{{ option.description }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</RadioGroupRoot>
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" :disabled="inFlight" @click="onRetryOpen(false)">
|
||||
Keep it parked
|
||||
</Button>
|
||||
<Button :disabled="inFlight || !retryMode" @click="submitRetry">
|
||||
Retry
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<AlertDialog :open="confirming !== null" @update:open="onConfirmationOpen">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* The retry worktree choice, as the dashboard builds it.
|
||||
*
|
||||
* The module exists so the wire shape, the disable rule and the
|
||||
* initial-selection rule are testable under the node module runner rather
|
||||
* than buried in the SFC. The choice the operator makes here must travel to
|
||||
* the daemon: the retry action carries it, the task row persists it, and the
|
||||
* daemon's worktree preparation reads it (taskstate.RetryMode).
|
||||
*/
|
||||
|
||||
/** The catalog shape /api/task-meta serves for one retry mode. */
|
||||
export interface RetryModeOption {
|
||||
id: string;
|
||||
label: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
requires_branch?: boolean;
|
||||
}
|
||||
|
||||
/** One option as the retry dialog renders it. */
|
||||
export interface RetryChoice {
|
||||
id: string;
|
||||
label: string;
|
||||
description: string;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* retryChoices is the operator's options for one task. A mode that needs a
|
||||
* branch is disabled when the task has none: the server refuses that
|
||||
* combination, so the dialog never sends a request it knows will conflict.
|
||||
*/
|
||||
export function retryChoices(
|
||||
modes: readonly RetryModeOption[],
|
||||
branch: string | null | undefined,
|
||||
): RetryChoice[] {
|
||||
const hasBranch = Boolean(branch && branch.trim());
|
||||
return modes.map((mode) => ({
|
||||
id: mode.id,
|
||||
label: mode.label,
|
||||
description: mode.description,
|
||||
disabled: Boolean(mode.requires_branch) && !hasBranch,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* initialRetryMode is the mode the dialog opens on: the task's own persisted
|
||||
* choice when the catalog still names it, otherwise the server's default.
|
||||
* Reading the persisted value is what keeps a remediation retry continuing
|
||||
* its branch rather than resetting over the pull request, while a first retry
|
||||
* still opens on the explicit refresh default.
|
||||
*/
|
||||
export function initialRetryMode(
|
||||
modes: readonly RetryModeOption[],
|
||||
persisted: string | null | undefined,
|
||||
): string {
|
||||
if (persisted && modes.some((mode) => mode.id === persisted)) {
|
||||
return persisted;
|
||||
}
|
||||
return modes.find((mode) => mode.default)?.id ?? modes[0]?.id ?? "";
|
||||
}
|
||||
|
||||
/**
|
||||
* initialRetryChoice is the option the dialog actually selects: the task's
|
||||
* persisted mode when it is offered and enabled, otherwise the first enabled
|
||||
* option. It exists so a persisted mode the task can no longer use -- say
|
||||
* continue_pushed_work on a task whose branch is gone -- cannot be submitted
|
||||
* as a preselected-but-disabled value.
|
||||
*/
|
||||
export function initialRetryChoice(
|
||||
choices: readonly RetryChoice[],
|
||||
persisted: string | null | undefined,
|
||||
): string {
|
||||
const match = persisted
|
||||
? choices.find((choice) => choice.id === persisted)
|
||||
: undefined;
|
||||
if (match && !match.disabled) return match.id;
|
||||
return choices.find((choice) => !choice.disabled)?.id ?? "";
|
||||
}
|
||||
|
||||
/** retryPayload is the action body a retry posts for the chosen mode. */
|
||||
export function retryPayload(mode: string): { retry_mode: string } {
|
||||
return { retry_mode: mode };
|
||||
}
|
||||
Reference in new issue
Block a user