refactor(ui): merge the harness settings page into agent profiles
deploy / plan (push) Failing after 2s
deploy / gate (push) Skipped
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped

The harness page's setup terminal targets the Kit agent profiles, so the
two pages were two halves of one flow split across routes: with no Kit
profile the harness page dead-ended in a disabled 'No profiles
configured' select while the place to create one sat on another page.

/settings/agent-profiles now carries the profiles editor and a 'Harness
sign-in' section (setup terminal plus the credential-bindings sign-in
table), and /settings/harness redirects to it. The bindings re-read when
a terminal session ends so a fresh capture shows immediately, and a
null-seeded agent-profiles document now renders the empty state instead
of a bare add form. The gateway page registry names the merged page.
This commit is contained in:
sam committed 2026-11-09 02:03:20 +11:00
1 parent d1b1bac4fb
commit 98f5af3eef
5 files changed
+170 -208

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ var dashboardPages = []DashboardPage{
{Path: "/settings/plugins", Label: "Plugins", Description: "Extension directories loaded at startup."},
{Path: "/settings/secret-engines", Label: "Secret engines"},
{Path: "/settings/container-runtime", Label: "Container runtime"},
{Path: "/settings/harness", Label: "Harness", Description: "OAuth credential bindings and setup terminal."},
{Path: "/settings/agent-profiles", Label: "Agent profiles", Description: "Execution profiles (image or Kit harness), credential sign-in status and the harness setup terminal."},
}
// DashboardPages returns a copy of the dashboard page registry.
-188
View File
@@ -1,188 +0,0 @@
<script setup lang="ts">
/**
* Harness: the OAuth credential bindings a Kit profile resolves, and the
* setup terminal that captures a binding's tokens
* (docs/prds/external-agent-harness.md). The binding list is a State Store
* read; the terminal is the webui route's WebSocket, and it reports
* explicitly when this process cannot open one rather than offering a
* control that would fail.
*/
import { onMounted, ref } from "vue";
import PageHeader from "@/base/PageHeader.vue";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { ReadError } from "@/components/ui/read-error";
import { Badge } from "@/components/ui/badge";
import type { BadgeVariants } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Section } from "@/components/ui/section";
import { Timestamp } from "@/components/ui/timestamp";
import {
Empty,
EmptyHeader,
EmptyTitle,
} from "@/components/ui/empty";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Skeleton } from "@/components/ui/skeleton";
import {
Table,
TableBody,
TableEmpty,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { api, ApiError } from "@/lib/api";
import SetupTerminal from "./SetupTerminal.vue";
import {
bindingStatus,
type BindingStatus,
type HarnessBinding,
type HarnessState,
} from "./harness";
const state = ref<HarnessState | null>(null);
const loading = ref(true);
const failure = ref<string | null>(null);
// "unconfigured" is a process with no control-plane resource or no token
// store (501/503) -- the feature is off, which reads differently from a
// process that answered badly.
const unconfigured = ref(false);
const profile = ref("");
const terminalOpen = ref(false);
const statuses: Record<
BindingStatus,
{ label: string; variant: BadgeVariants["variant"] }
> = {
ready: { label: "Ready", variant: "ok" },
expiring: { label: "Expiring soon", variant: "warn" },
expired: { label: "Expired", variant: "danger" },
unconfigured: { label: "Not set up", variant: "idle" },
};
onMounted(load);
async function load(): Promise<void> {
loading.value = true;
failure.value = null;
unconfigured.value = false;
try {
const got = await api.harnessBindings<HarnessState>();
state.value = {
terminal: got.terminal,
bindings: got.bindings ?? [],
profiles: got.profiles ?? [],
};
profile.value = state.value.profiles[0] ?? "";
} catch (err) {
const status = err instanceof ApiError ? err.status : undefined;
if (status === 501 || status === 503) {
unconfigured.value = true;
} else {
failure.value = err instanceof Error ? err.message : String(err);
}
state.value = null;
} finally {
loading.value = false;
}
}
function openTerminal(): void {
if (!state.value?.terminal || !profile.value) return;
terminalOpen.value = true;
}
function scopes(binding: HarnessBinding): string {
return binding.scopes?.length ? binding.scopes.join(", ") : "–";
}
</script>
<template>
<div>
<PageHeader title="Harness" />
<ReadError v-if="failure" :message="`Could not load the harness: ${failure}`" retry-label="Retry" class="mb-4" @retry="load" />
<div v-if="loading" class="flex flex-col gap-2">
<Skeleton class="h-24 w-full" />
<Skeleton class="h-40 w-full" />
</div>
<Empty v-else-if="unconfigured">
<EmptyHeader>
<EmptyTitle>Harness bindings are not configured</EmptyTitle>
</EmptyHeader>
</Empty>
<template v-else-if="state">
<Alert v-if="!state.terminal" class="mb-4">
<AlertTitle>Setup terminal unavailable</AlertTitle>
<AlertDescription>Start the daemon with a container runtime and a harness token to log in to a CLI from here.</AlertDescription>
</Alert>
<Section v-else>
<div class="flex flex-wrap items-end gap-3">
<div class="flex flex-col gap-1 text-label">
<Label for="harness-profile" class="text-fg-muted">Profile</Label>
<Select v-model="profile" :disabled="!state.profiles.length">
<SelectTrigger id="harness-profile" size="sm" class="min-w-48">
<SelectValue placeholder="No profiles configured" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="name in state.profiles" :key="name" :value="name">
{{ name }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</div>
<Button :disabled="!profile" @click="openTerminal">Open setup terminal</Button>
</div>
</Section>
<Section v-if="terminalOpen && profile" title="Setup terminal">
<template #action><Button variant="outline" size="sm" @click="terminalOpen = false">Close terminal</Button></template>
<div class="h-96"><SetupTerminal :profile="profile" @ended="terminalOpen = false" /></div>
</Section>
<Section>
<Table>
<TableHeader>
<TableRow>
<TableHead>Service</TableHead>
<TableHead>Status</TableHead>
<TableHead>Expires</TableHead>
<TableHead>Scopes</TableHead>
<TableHead>Updated</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableEmpty v-if="!state.bindings.length" :colspan="5">No credential bindings.</TableEmpty>
<TableRow v-for="binding in state.bindings" :key="binding.service">
<TableCell class="font-medium">{{ binding.service }}</TableCell>
<TableCell>
<Badge :variant="statuses[bindingStatus(binding)].variant">
{{ statuses[bindingStatus(binding)].label }}
</Badge>
</TableCell>
<TableCell><Timestamp :at="binding.expires_at" absolute /></TableCell>
<TableCell class="text-fg-muted">{{ scopes(binding) }}</TableCell>
<TableCell class="text-fg-muted"><Timestamp :at="binding.updated_at" /></TableCell>
</TableRow>
</TableBody>
</Table>
</Section>
</template>
</div>
</template>
-1
View File
@@ -77,7 +77,6 @@ const settings: NavSpec = {
"/settings/task-execution",
"/settings/container-runtime",
"/settings/agent-profiles",
"/settings/harness",
"/settings/status",
],
},
+3 -13
View File
@@ -395,19 +395,9 @@ const routes = [
component: () => import("@/settings/AgentProfilesPage.vue"),
meta: { navPath: "/settings", settings: true, label: "Agent profiles", section: "settings" },
},
{
path: "/settings/harness",
name: "settings-harness",
// Lazy so xterm.js stays out of the shell every page loads.
component: () => import("@/harness/HarnessPage.vue"),
meta: {
navPath: "/settings",
settings: true,
label: "Harness",
description: "OAuth credential bindings and setup terminal.",
section: "settings",
},
},
// The harness sign-in section lives on the agent-profiles page: its setup
// terminal targets the Kit profiles that page edits.
{ path: "/settings/harness", redirect: "/settings/agent-profiles", meta: { nav: false } },
{ path: "/settings/history", redirect: (to: RouteLocationGeneric) => ({ path: "/org/audit", query: to.query, hash: to.hash }), meta: { nav: false } },
{ path: "/settings/audit", redirect: (to: RouteLocationGeneric) => ({ path: "/org/audit", query: to.query, hash: to.hash }), meta: { nav: false } },
{
+166 -5
View File
@@ -1,13 +1,25 @@
<script setup lang="ts">
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { computed, onMounted, ref } from "vue";
import PageHeader from "@/base/PageHeader.vue";
import { Badge } from "@/components/ui/badge";
import type { BadgeVariants } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { ReadError } from "@/components/ui/read-error";
import { Section } from "@/components/ui/section";
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Skeleton } from "@/components/ui/skeleton";
import { Table, TableBody, TableEmpty, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from "@/components/ui/tags-input";
import { Timestamp } from "@/components/ui/timestamp";
import { api, ApiError } from "@/lib/api";
import { useSettingsStore } from "@/stores/settings";
import SetupTerminal from "@/harness/SetupTerminal.vue";
import { bindingStatus, type BindingStatus, type HarnessBinding, type HarnessState } from "@/harness/harness";
import ApplyStatusRows from "./ApplyStatusRows.vue";
import CardAccordion from "./CardAccordion.vue";
import HistoryLink from "./HistoryLink.vue";
@@ -15,8 +27,13 @@ import HistoryLink from "./HistoryLink.vue";
interface Profile { image?: string; kit?: string; adapter?: string; tools?: string[] }
const KIND = "agent-profiles";
const store = useSettingsStore();
onMounted(store.load);
const profiles = computed(() => store.draftValue(KIND) as Record<string, Profile> | null);
// A fresh instance seeds the document as null; once the form exists that is
// an empty map, so the empty state shows rather than a bare add form.
const profiles = computed(() => {
const value = store.draftValue(KIND) as Record<string, Profile> | null;
return value ?? (store.formFor(KIND) ? {} : null);
});
const name = ref("");
const open = ref("");
const unsaved = computed(() => store.changesFor(KIND).length > 0);
@@ -41,6 +58,78 @@ function removeProfile(index: number) {
function patch(key: string, changes: Partial<Profile>) {
store.setDraftEntry(KIND, key, { ...profiles.value?.[key], ...changes });
}
// Harness sign-in: the credential bindings' captured OAuth state and the
// setup terminal a Kit profile is signed in from, one read of
// /api/harness/bindings serving both (the profile list is the agent profiles
// above that name a Kit).
const harness = ref<HarnessState | null>(null);
const harnessLoading = ref(true);
const harnessFailure = ref<string | null>(null);
// "unconfigured" is a process with no control-plane resource or no token
// store (501/503) -- the feature is off, which reads differently from a
// process that answered badly.
const harnessUnconfigured = ref(false);
const kitProfile = ref("");
const terminalOpen = ref(false);
// A read that started before the route changed must not land after it.
let harnessLoad = 0;
const statuses: Record<BindingStatus, { label: string; variant: BadgeVariants["variant"] }> = {
ready: { label: "Ready", variant: "ok" },
expiring: { label: "Expiring soon", variant: "warn" },
expired: { label: "Expired", variant: "danger" },
unconfigured: { label: "Not set up", variant: "idle" },
};
onMounted(() => {
void store.load();
void loadHarness();
});
async function loadHarness(): Promise<void> {
const id = ++harnessLoad;
harnessLoading.value = true;
harnessFailure.value = null;
harnessUnconfigured.value = false;
try {
const got = await api.harnessBindings<HarnessState>();
if (id !== harnessLoad) return;
harness.value = {
terminal: got.terminal,
bindings: got.bindings ?? [],
profiles: got.profiles ?? [],
};
kitProfile.value = harness.value.profiles[0] ?? "";
} catch (err) {
if (id !== harnessLoad) return;
const status = err instanceof ApiError ? err.status : undefined;
if (status === 501 || status === 503) {
harnessUnconfigured.value = true;
} else {
harnessFailure.value = err instanceof Error ? err.message : String(err);
}
harness.value = null;
} finally {
if (id === harnessLoad) harnessLoading.value = false;
}
}
function openTerminal(): void {
if (!harness.value?.terminal || !kitProfile.value) return;
terminalOpen.value = true;
}
// A capture lands while the terminal runs; re-read so the bindings table
// shows the sign-in the session just made.
function terminalEnded(): void {
terminalOpen.value = false;
void loadHarness();
}
function scopes(binding: HarnessBinding): string {
return binding.scopes?.length ? binding.scopes.join(", ") : "–";
}
</script>
<template>
<div>
@@ -51,7 +140,7 @@ function patch(key: string, changes: Partial<Profile>) {
<Input v-model="name" aria-label="Profile name" placeholder="Profile name" class="max-w-xs" :disabled="unsaved" />
<Button type="submit" :disabled="unsaved || !name.trim() || !!profiles?.[name.trim()]">Add profile</Button>
</form>
<Empty v-if="profiles && !Object.keys(profiles).length"><EmptyHeader><EmptyTitle>No agent profiles</EmptyTitle></EmptyHeader></Empty>
<Empty v-if="profiles && !entries.length"><EmptyHeader><EmptyTitle>No agent profiles</EmptyTitle></EmptyHeader></Empty>
<CardAccordion v-model:open="open" :items="entries" :title="([key]) => key" remove-label="Remove" mono @remove="removeProfile">
<template #default="{ item: [key, profile] }">
<FieldGroup class="@container/field-group">
@@ -91,5 +180,77 @@ function patch(key: string, changes: Partial<Profile>) {
</FieldGroup>
</template>
</CardAccordion>
<Section title="Harness sign-in" class="mt-4">
<ReadError v-if="harnessFailure" :message="`Could not load the harness: ${harnessFailure}`" retry-label="Retry" @retry="loadHarness" />
<div v-else-if="harnessLoading" class="flex flex-col gap-2">
<Skeleton class="h-10 w-full" />
<Skeleton class="h-24 w-full" />
</div>
<Empty v-else-if="harnessUnconfigured">
<EmptyHeader><EmptyTitle>Harness bindings are not configured</EmptyTitle></EmptyHeader>
</Empty>
<template v-else-if="harness">
<Alert v-if="!harness.terminal" class="mb-4">
<AlertTitle>Setup terminal unavailable</AlertTitle>
<AlertDescription>Start the daemon with a container runtime and a harness token to log in to a CLI from here.</AlertDescription>
</Alert>
<Empty v-else-if="!harness.profiles.length">
<EmptyHeader>
<EmptyTitle>No Kit profiles yet</EmptyTitle>
<EmptyDescription>Add a profile with a Kit above, then sign its services in from a terminal.</EmptyDescription>
</EmptyHeader>
</Empty>
<div v-else class="flex flex-wrap items-end gap-3">
<div class="flex flex-col gap-1 text-label">
<Label for="harness-profile" class="text-fg-muted">Profile</Label>
<Select v-model="kitProfile">
<SelectTrigger id="harness-profile" size="sm" class="min-w-48">
<SelectValue placeholder="No profiles configured" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="profileName in harness.profiles" :key="profileName" :value="profileName">
{{ profileName }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</div>
<Button :disabled="!kitProfile" @click="openTerminal">Open setup terminal</Button>
</div>
<p class="text-label text-fg-muted mb-2 mt-6">Credential bindings</p>
<Table>
<TableHeader>
<TableRow>
<TableHead>Service</TableHead>
<TableHead>Status</TableHead>
<TableHead>Expires</TableHead>
<TableHead>Scopes</TableHead>
<TableHead>Updated</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableEmpty v-if="!harness.bindings.length" :colspan="5">No credential bindings.</TableEmpty>
<TableRow v-for="binding in harness.bindings" :key="binding.service">
<TableCell class="font-medium">{{ binding.service }}</TableCell>
<TableCell>
<Badge :variant="statuses[bindingStatus(binding)].variant">
{{ statuses[bindingStatus(binding)].label }}
</Badge>
</TableCell>
<TableCell><Timestamp :at="binding.expires_at" absolute /></TableCell>
<TableCell class="text-fg-muted">{{ scopes(binding) }}</TableCell>
<TableCell class="text-fg-muted"><Timestamp :at="binding.updated_at" /></TableCell>
</TableRow>
</TableBody>
</Table>
</template>
</Section>
<Section v-if="terminalOpen && kitProfile" title="Setup terminal">
<template #action><Button variant="outline" size="sm" @click="terminalOpen = false">Close terminal</Button></template>
<div class="h-96"><SetupTerminal :profile="kitProfile" @ended="terminalEnded" /></div>
</Section>
</div>
</template>