Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(self-build): rebuild Built for you as a plain list page (#930)

Ruben Lütke4688ca2d0ce9
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json
index 0cb27263d5..4c9f5bf305 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json
@@ -34,13 +34,13 @@
"nothing": "Nichts Neues."
},
"shelf": {
- "waiting": "Braucht dich",
+ "waiting": "Wartet auf dein OK",
"waiting_hint": "Nichts wird gebaut, bevor du ja sagst.",
"kept": "Behalten",
"kept_hint": "Hat sich bewährt. Weiterhin rückgängig zu machen.",
- "past": "Archiviert und rückgängig gemacht",
+ "past": "Archiviert",
"past_hint": "Archivierte Helfer lassen sich wiederherstellen.",
- "live": "Arbeitet für dich",
+ "live": "Aktiv",
"live_hint": "Auf Probe und gekennzeichnet. Rückgängig entfernt es vollständig."
},
"show_past": "{count} anzeigen",
@@ -153,7 +153,7 @@
"code": "Code-Änderungen"
},
"noticed": {
- "title": "Bisher bemerkt",
+ "title": "Bemerkt",
"hint": "Es zählt nur, worum du selbst bittest.",
"empty": "Noch wiederholt sich nichts.",
"empty_hint": "Arbeite einfach wie gewohnt. {name} zählt still auf diesem Computer mit.",
@@ -199,6 +199,18 @@
"based_on_one": "Aus {count} Anfrage",
"based_on_other": "Aus {count} Anfragen",
"details": "Details",
- "stop_footer": "Soll alles auf einmal anhalten?"
+ "stop_footer": "Soll alles auf einmal anhalten?",
+ "page": {
+ "subtitle": "Wenn du {name} immer wieder um dasselbe bittest, bekommst du das Angebot, dafür einen kleinen Helfer einzurichten.",
+ "learning_title": "Lernt, wie du arbeitest · Tag {day} von {days}",
+ "learning_body": "Vorschläge kann es ab {date} geben. Bis dahin macht sich {name} nur Notizen.",
+ "learning_body_nodate": "In den ersten {days} Tagen macht sich {name} nur Notizen.",
+ "empty_title": "Noch nichts hier",
+ "empty_body": "Nutze {name} einfach wie gewohnt. Sobald du an {days} verschiedenen Tagen um dasselbe bittest, erscheint hier ein Vorschlag.",
+ "noticed_rule": "Ein Vorschlag erscheint, sobald du an {days} verschiedenen Tagen um dasselbe bittest.",
+ "how_toggle": "Wie funktioniert das?",
+ "pause_hint": "Es wird nichts Neues bemerkt oder gebaut. Deine Helfer laufen weiter.",
+ "stop_hint": "Stoppt alle laufenden Agents, Missionen und Routinen."
+ }
}
}
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json
index ec101eca48..a1b1c32df0 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json
@@ -34,13 +34,13 @@
"nothing": "Nothing new."
},
"shelf": {
- "waiting": "Needs you",
+ "waiting": "Waiting for your OK",
"waiting_hint": "Nothing is built until you say yes.",
"kept": "Kept",
"kept_hint": "Earned its place. Still undoable.",
- "past": "Archived and undone",
+ "past": "Archived",
"past_hint": "Archived helpers can be restored.",
- "live": "Working for you",
+ "live": "Active",
"live_hint": "On trial and labelled. Undo removes it completely."
},
"show_past": "Show {count}",
@@ -153,7 +153,7 @@
"code": "Code changes"
},
"noticed": {
- "title": "Noticed so far",
+ "title": "Noticed",
"hint": "Only what you ask for yourself counts.",
"empty": "Nothing repeated yet.",
"empty_hint": "Keep working as usual. {name} counts quietly on this computer.",
@@ -199,6 +199,18 @@
"based_on_one": "Based on {count} request",
"based_on_other": "Based on {count} requests",
"details": "Details",
- "stop_footer": "Need everything to stop at once?"
+ "stop_footer": "Need everything to stop at once?",
+ "page": {
+ "subtitle": "When you ask {name} for the same thing again and again, it offers to set up a small helper that does it for you.",
+ "learning_title": "Learning how you work · day {day} of {days}",
+ "learning_body": "Suggestions can appear from {date}. Until then {name} only takes notes.",
+ "learning_body_nodate": "For the first {days} days {name} only takes notes.",
+ "empty_title": "Nothing here yet",
+ "empty_body": "Keep using {name} as usual. Once you ask for the same thing on {days} different days, a suggestion shows up here.",
+ "noticed_rule": "A suggestion appears once something is asked on {days} different days.",
+ "how_toggle": "How does this work?",
+ "pause_hint": "Nothing new is noticed or built. Your helpers keep working.",
+ "stop_hint": "Stops every running agent, mission and routine."
+ }
}
}
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json
index 1d86d8b8a2..c02ac0561c 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json
@@ -34,13 +34,13 @@
"nothing": "Nada nuevo."
},
"shelf": {
- "waiting": "Te necesita",
+ "waiting": "Esperan tu visto bueno",
"waiting_hint": "Nada se crea hasta que digas que sí.",
"kept": "Conservado",
"kept_hint": "Se ganó su sitio. Aún se puede deshacer.",
- "past": "Archivado y deshecho",
+ "past": "Archivados",
"past_hint": "Los ayudantes archivados se pueden restaurar.",
- "live": "Trabajando para ti",
+ "live": "Activos",
"live_hint": "En prueba y señalado. Deshacer lo quita por completo."
},
"show_past": "Mostrar {count}",
@@ -153,7 +153,7 @@
"code": "Cambios de código"
},
"noticed": {
- "title": "Notado hasta ahora",
+ "title": "Detectado",
"hint": "Solo cuenta lo que pides tú.",
"empty": "Todavía no se repite nada.",
"empty_hint": "Sigue trabajando como siempre. {name} cuenta en silencio en este ordenador.",
@@ -199,6 +199,18 @@
"based_on_one": "Basado en {count} petición",
"based_on_other": "Basado en {count} peticiones",
"details": "Detalles",
- "stop_footer": "¿Necesitas que todo se detenga a la vez?"
+ "stop_footer": "¿Necesitas que todo se detenga a la vez?",
+ "page": {
+ "subtitle": "Cuando le pides a {name} lo mismo una y otra vez, te ofrece crear un pequeño ayudante que lo haga por ti.",
+ "learning_title": "Aprendiendo cómo trabajas · día {day} de {days}",
+ "learning_body": "Las sugerencias pueden aparecer a partir del {date}. Hasta entonces {name} solo toma notas.",
+ "learning_body_nodate": "Durante los primeros {days} días {name} solo toma notas.",
+ "empty_title": "Aún no hay nada",
+ "empty_body": "Sigue usando {name} como siempre. Cuando pidas lo mismo en {days} días distintos, aparecerá aquí una sugerencia.",
+ "noticed_rule": "Aparece una sugerencia cuando algo se pide en {days} días distintos.",
+ "how_toggle": "¿Cómo funciona?",
+ "pause_hint": "No se detecta ni se crea nada nuevo. Tus ayudantes siguen funcionando.",
+ "stop_hint": "Detiene todos los agentes, misiones y rutinas en marcha."
+ }
}
}
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json
index 2772c6d154..a2269d96d5 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json
@@ -34,13 +34,13 @@
"nothing": "Nada de novo."
},
"shelf": {
- "waiting": "Precisa de você",
+ "waiting": "Aguardando seu OK",
"waiting_hint": "Nada é criado até você dizer sim.",
"kept": "Mantido",
"kept_hint": "Mereceu seu lugar. Ainda pode ser desfeito.",
- "past": "Arquivado e desfeito",
+ "past": "Arquivados",
"past_hint": "Ajudantes arquivados podem ser restaurados.",
- "live": "Trabalhando para você",
+ "live": "Ativos",
"live_hint": "Em teste e identificado. Desfazer remove por completo."
},
"show_past": "Mostrar {count}",
@@ -153,7 +153,7 @@
"code": "Mudanças de código"
},
"noticed": {
- "title": "Percebido até agora",
+ "title": "Notado",
"hint": "Só conta o que você mesmo pede.",
"empty": "Nada se repetiu ainda.",
"empty_hint": "Continue trabalhando normalmente. {name} conta em silêncio neste computador.",
@@ -199,6 +199,18 @@
"based_on_one": "Com base em {count} pedido",
"based_on_other": "Com base em {count} pedidos",
"details": "Detalhes",
- "stop_footer": "Precisa que tudo pare de uma vez?"
+ "stop_footer": "Precisa que tudo pare de uma vez?",
+ "page": {
+ "subtitle": "Quando você pede a {name} a mesma coisa várias vezes, ele oferece criar um pequeno assistente que faz isso por você.",
+ "learning_title": "Aprendendo como você trabalha · dia {day} de {days}",
+ "learning_body": "Sugestões podem aparecer a partir de {date}. Até lá {name} só toma notas.",
+ "learning_body_nodate": "Nos primeiros {days} dias {name} só toma notas.",
+ "empty_title": "Nada aqui ainda",
+ "empty_body": "Continue usando {name} normalmente. Quando você pedir a mesma coisa em {days} dias diferentes, uma sugestão aparece aqui.",
+ "noticed_rule": "Uma sugestão aparece quando algo é pedido em {days} dias diferentes.",
+ "how_toggle": "Como funciona?",
+ "pause_hint": "Nada novo é notado ou criado. Seus assistentes continuam funcionando.",
+ "stop_hint": "Para todos os agentes, missões e rotinas em execução."
+ }
}
}
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json
index ffa742ae43..65ce24eebd 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json
@@ -34,13 +34,13 @@
"nothing": "没有新内容。"
},
"shelf": {
- "waiting": "需要你",
+ "waiting": "等待你确认",
"waiting_hint": "你同意之前,什么都不会构建。",
"kept": "已保留",
"kept_hint": "证明了自己的价值。仍可撤销。",
- "past": "已归档和已撤销",
+ "past": "已归档",
"past_hint": "已归档的助手可以恢复。",
- "live": "正在为你工作",
+ "live": "运行中",
"live_hint": "试用中并已标记。撤销会完全移除。"
},
"show_past": "显示 {count} 个",
@@ -153,7 +153,7 @@
"code": "代码改动"
},
"noticed": {
- "title": "目前留意到的",
+ "title": "已注意到",
"hint": "只统计你自己提出的请求。",
"empty": "还没有重复的事。",
"empty_hint": "照常工作就好。{name} 会在这台电脑上悄悄统计。",
@@ -199,6 +199,18 @@
"based_on_one": "基于 {count} 个请求",
"based_on_other": "基于 {count} 个请求",
"details": "详情",
- "stop_footer": "需要一次性停下所有东西吗?"
+ "stop_footer": "需要一次性停下所有东西吗?",
+ "page": {
+ "subtitle": "当你反复让 {name} 做同一件事时,它会提议为你设置一个小助手来自动完成。",
+ "learning_title": "正在了解你的工作方式 · 第 {day} 天,共 {days} 天",
+ "learning_body": "从 {date} 起可能会出现建议。在此之前 {name} 只做记录。",
+ "learning_body_nodate": "前 {days} 天 {name} 只做记录。",
+ "empty_title": "这里还没有内容",
+ "empty_body": "照常使用 {name} 即可。当你在 {days} 个不同的日子提出同样的请求时,这里会出现建议。",
+ "noticed_rule": "当某个请求在 {days} 个不同的日子出现时,就会生成建议。",
+ "how_toggle": "这是如何运作的?",
+ "pause_hint": "不再发现或构建新内容。现有的助手会继续工作。",
+ "stop_hint": "停止所有正在运行的智能体、任务和例程。"
+ }
}
}
diff --git a/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx b/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx
index c737a4d244..b50caa62c0 100644
--- a/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx
+++ b/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx
@@ -163,17 +163,17 @@ describe("SelfBuildView", () => {
renderWith(<SelfBuildView />);
const waiting = await screen.findByTestId("shelf-waiting");
expect(within(waiting).getAllByTestId("build-row").map((r) => r.dataset.buildId)).toEqual(["p1", "p2"]);
- expect(within(screen.getByTestId("shelf-live")).getByText("A standup digest")).toBeTruthy();
- expect(within(screen.getByTestId("shelf-kept")).getByText("Mail humanizer")).toBeTruthy();
+ // Trials and kept helpers read as one "Active" list.
+ const live = screen.getByTestId("shelf-live");
+ expect(within(live).getByText("A standup digest")).toBeTruthy();
+ expect(within(live).getByText("Mail humanizer")).toBeTruthy();
// The past shelf is folded until asked for.
const past = screen.getByTestId("shelf-past");
expect(within(past).queryByTestId("build-row")).toBeNull();
fireEvent.click(within(past).getByRole("button", { name: /show 1/i }));
expect(within(past).getByText("Fix the flaky test")).toBeTruthy();
- // The digest reads as one line.
- expect(screen.getByTestId("self-build-digest").textContent).toMatch(/2 proposed/);
- // Two ideas wait: the hero says so in a sentence.
- expect(screen.getByTestId("self-build-hero").textContent).toMatch(/has 2 ideas for you/);
+ // Simply watching is nothing to report: no banner.
+ expect(screen.queryByTestId("self-build-banner")).toBeNull();
});
it("builds a proposal or turns it down in one click; a kind without a builder cannot be built", async () => {
@@ -208,10 +208,14 @@ describe("SelfBuildView", () => {
it("pauses the loop, and stops every agent only after a confirm", async () => {
const calls = installFetch();
renderWith(<SelfBuildView />);
- fireEvent.click(await screen.findByTestId("self-build-pause"));
+ // Every page option sits behind the status pill.
+ await screen.findAllByTestId("build-row");
+ fireEvent.click(screen.getByTestId("self-build-menu"));
+ fireEvent.click(screen.getByTestId("self-build-pause"));
await waitFor(() =>
expect(calls.find((c) => c.url === "/api/self-build/pause")?.body).toEqual({ paused: true }),
);
+ fireEvent.click(screen.getByTestId("self-build-menu"));
fireEvent.click(screen.getByTestId("society-stop-all"));
expect(calls.some((c) => c.url === "/api/society/kill-switch")).toBe(false);
fireEvent.click(screen.getByTestId("stop-all-ok"));
@@ -223,6 +227,8 @@ describe("SelfBuildView", () => {
renderWith(<SelfBuildView />);
expect(await screen.findByTestId("note-paused")).toBeTruthy();
expect(await screen.findByTestId("note-stopped")).toBeTruthy();
+ expect(screen.getByTestId("self-build-banner").dataset.tone).toBe("stopped");
+ fireEvent.click(screen.getByTestId("self-build-menu"));
expect(screen.queryByTestId("society-stop-all")).toBeNull();
// Accepting would start a build, so it waits while building is paused.
const first = (await screen.findAllByTestId("build-row"))[0];
@@ -232,12 +238,13 @@ describe("SelfBuildView", () => {
it("teaches the idea and shows what it is counting during the quiet start", async () => {
installFetch({ ...STATUS, silent: true }, false, []);
renderWith(<SelfBuildView />);
- const hero = await screen.findByTestId("self-build-hero");
- expect(hero.dataset.tone).toBe("silent");
- expect(hero.textContent).toMatch(/getting to know how you work/);
- await waitFor(() => expect(screen.getByTestId("self-build-ring").getAttribute("aria-label")).toBe("Day 3 of 7"));
- expect(within(screen.getByTestId("self-build-reach")).getByText("Tries it, with undo")).toBeTruthy();
- expect(screen.getByTestId("self-build-how")).toBeTruthy();
+ const banner = await screen.findByTestId("self-build-banner");
+ expect(banner.dataset.tone).toBe("silent");
+ await waitFor(() => expect(banner.textContent).toMatch(/Learning how you work · day 3 of 7/));
+ // The three steps sit behind one quiet toggle.
+ const how = screen.getByTestId("self-build-how");
+ fireEvent.click(within(how).getByRole("button", { name: /how does this work/i }));
+ expect(how.textContent).toMatch(/It notices/);
const needs = await screen.findAllByTestId("noticed-need");
expect(needs[0].textContent).toMatch(/Did I get any important emails\?/);
expect(needs[0].textContent).toMatch(/Asked 4 times · on 2 days/);
@@ -256,8 +263,9 @@ describe("SelfBuildView", () => {
it("says nothing repeated yet when the miner has nothing", async () => {
installFetch(STATUS, false, [], { ...NOTICED, needs: [], once: 0 });
renderWith(<SelfBuildView />);
- expect(await screen.findByTestId("noticed-empty")).toBeTruthy();
- expect(screen.getByTestId("self-build-hero").textContent).toMatch(/watching for repeats/);
+ const empty = await screen.findByTestId("noticed-empty");
+ expect(empty.textContent).toMatch(/Nothing here yet/);
+ expect(empty.textContent).toMatch(/on 3 different days/);
});
it("opens on the build a badge asked for", async () => {
diff --git a/dodaios/ui/web/frontend/src/views/SelfBuildView.tsx b/dodaios/ui/web/frontend/src/views/SelfBuildView.tsx
index e415d51474..110f97011b 100644
--- a/dodaios/ui/web/frontend/src/views/SelfBuildView.tsx
+++ b/dodaios/ui/web/frontend/src/views/SelfBuildView.tsx
@@ -2,19 +2,19 @@
* "Built for you": what the assistant notices the person keeps doing, and the
* small helpers it builds to take that off them.
*
- * One reading column, top to bottom, in the order a person asks about it:
- * what is this and is it working (the hero), what needs me (suggestions),
- * what is running for me (trials, builds in progress), what has it noticed so
- * far (the repeats it is counting), what did I keep, and what is gone. A
- * build opens as a sheet on the right with its full case file
- * (`BuildDetail`). While nothing is built, the page teaches the idea in three
- * steps instead of standing empty.
+ * Built like the settings and library pages of a desktop chat app: a title
+ * with one sentence under it, one status pill that holds every page option,
+ * a slim line for the state (learning, paused, off, stopped), then plain
+ * lists in the order a person asks about them: what waits for my OK, what is
+ * running for me, what has it noticed, and what is archived. A build opens as
+ * a sheet on the right with its full case file (`BuildDetail`). An empty page
+ * says in two sentences what will appear here and when.
*
* It never interrupts: no toast, no sound, no voice. Live through
* `SelfBuildChanged` (hooks/useWebSocket.ts). docs/self-build.md.
*/
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
-import { ChevronDown, ChevronRight, Loader2, OctagonX, Pause, Play, Settings2 } from "lucide-react";
+import { ChevronDown, Loader2, Sparkles } from "lucide-react";
import { fill, useLocaleChunk, useT } from "@/i18n";
import { useRunLocale } from "@/components/runs/format";
import { cn } from "@/lib/utils";
@@ -23,7 +23,6 @@ import { useSettingsJump } from "@/store/settingsJump";
import { useSelfBuildFocus } from "@/store/selfBuildFocus";
import {
useBuildAction,
- useSelfBuildDigest,
useSelfBuildList,
useSelfBuildNoticed,
useSelfBuildPause,
@@ -32,18 +31,13 @@ import {
useSocietyKillSwitch,
type BuildAction,
} from "@/hooks/useSelfBuild";
-import {
- SelfBuildApiError,
- shelfOf,
- trialProgress,
- type Build,
- type BuildDigest,
- type SelfBuildStatus,
-} from "@/lib/selfBuildApi";
+import { SelfBuildApiError, shelfOf, trialProgress, type Build, type SelfBuildStatus } from "@/lib/selfBuildApi";
import { BuildActions } from "./selfBuild/BuildActions";
import { BuildDetail } from "./selfBuild/BuildDetail";
-import { Hero, heroTone, type HeroTone } from "./selfBuild/Hero";
-import { HowItWorks, NoticedSection, SectionHead } from "./selfBuild/Noticed";
+import { StatusBanner, heroTone, type BannerAction } from "./selfBuild/Hero";
+import { Group, Row, Section } from "./selfBuild/List";
+import { HowItWorks, NoticedSection } from "./selfBuild/Noticed";
+import { StatusMenu } from "./selfBuild/StatusMenu";
import { KindIcon, relativeTime } from "./selfBuild/shared";
type Limits = { trial_days: number; trial_uses: number } | undefined;
@@ -53,7 +47,6 @@ export function SelfBuildView() {
const t = useT();
const locale = useRunLocale();
const list = useSelfBuildList();
- const digest = useSelfBuildDigest(24);
const noticed = useSelfBuildNoticed();
const settings = useSelfBuildSettings();
const kill = useSocietyKillSwitch();
@@ -63,6 +56,7 @@ export function SelfBuildView() {
const act = useBuildAction();
const [selectedId, setSelectedId] = useState<string | null>(() => useSelfBuildFocus.getState().take());
const [error, setError] = useState<string | null>(null);
+ const [confirmStop, setConfirmStop] = useState(false);
const focusRequest = useSelfBuildFocus((s) => s.buildId);
// A badge elsewhere asked for a build while this view was already open.
@@ -112,12 +106,12 @@ export function SelfBuildView() {
if (!ready) return <Centered><Loader2 className="h-5 w-5 animate-spin text-muted-foreground" aria-hidden /></Centered>;
const unavailable = list.error instanceof SelfBuildApiError && list.error.status === 503;
- const helpersLive = groups.live.filter((b) => b.state === "trial").length + groups.kept.length;
- const nothingBuilt = builds.length === 0;
+ const hasNeeds = (noticed.data?.needs.length ?? 0) > 0;
+ const nothingYet = builds.length === 0 && !hasNeeds;
- const heroAction =
+ const bannerAction: BannerAction | undefined =
tone === "paused"
- ? { label: t("self_build.resume"), onClick: () => pause.mutate(false), busy: pause.isPending, testId: "self-build-resume", icon: <Play className="h-4 w-4" aria-hidden /> }
+ ? { label: t("self_build.resume"), onClick: () => pause.mutate(false), busy: pause.isPending, testId: "self-build-resume" }
: tone === "off"
? { label: t("self_build.notes.turn_on"), onClick: openSettings, testId: "self-build-turn-on" }
: tone === "stopped"
@@ -126,8 +120,24 @@ export function SelfBuildView() {
return (
<div data-testid="self-build-view" className="flex h-full min-h-0 flex-col overflow-y-auto">
- <div className="mx-auto flex w-full max-w-[1000px] flex-1 flex-col px-6 pb-12 pt-10 sm:px-10">
- <TopBar tone={tone} paused={Boolean(status?.paused)} enabled={Boolean(status?.enabled)} onSettings={openSettings} />
+ <div className="mx-auto w-full max-w-[760px] px-6 pb-16 pt-12 sm:px-8">
+ <header className="flex items-start gap-6">
+ <div className="min-w-0 flex-1">
+ <h1 className="font-display text-[26px] font-semibold leading-tight tracking-[-0.02em] text-foreground-strong">
+ {t("self_build.title")}
+ </h1>
+ <p className="mt-1.5 max-w-[56ch] text-[15px] leading-relaxed text-muted-foreground">{t("self_build.page.subtitle")}</p>
+ </div>
+ <StatusMenu
+ tone={tone}
+ enabled={Boolean(status?.enabled)}
+ paused={Boolean(status?.paused)}
+ pauseBusy={pause.isPending}
+ onPause={(next) => pause.mutate(next)}
+ onSettings={openSettings}
+ onStopAll={stopped ? undefined : () => setConfirmStop(true)}
+ />
+ </header>
{list.isPending ? (
<Centered><Loader2 className="h-5 w-5 animate-spin text-muted-foreground" aria-label={t("self_build.loading")} /></Centered>
@@ -135,54 +145,60 @@ export function SelfBuildView() {
<p role="alert" className="mt-10 text-base text-muted-foreground">{t("self_build.error.unavailable")}</p>
) : (
<>
- {tone && (
- <Hero
- tone={tone}
- status={status}
- quiet={noticed.data?.quiet_start}
- waiting={groups.waiting.length}
- live={helpersLive}
- locale={locale}
- action={heroAction}
- />
- )}
+ {tone && <StatusBanner tone={tone} quiet={noticed.data?.quiet_start} locale={locale} action={bannerAction} />}
<StateNotes status={status} stopped={stopped} />
- <DigestLine digest={digest.data} />
{error && (
<p role="alert" className="mt-4 rounded-lg border border-destructive/40 px-3 py-2 text-sm text-destructive">
{error}
</p>
)}
- {nothingBuilt && <HowItWorks />}
+ {nothingYet && <EmptyState days={noticed.data?.threshold.days ?? 3} once={noticed.data?.once ?? 0} />}
{groups.waiting.length > 0 && (
- <section data-testid="shelf-waiting" aria-labelledby="shelf-waiting-title" className="mt-12">
- <SectionHead id="shelf-waiting-title" title={t("self_build.shelf.waiting")} hint={t("self_build.shelf.waiting_hint")} count={groups.waiting.length} />
- <ul className="space-y-3">
+ <Section id="waiting" title={t("self_build.shelf.waiting")} count={groups.waiting.length}>
+ <Group>
{groups.waiting.map((build) => (
- <ProposalCard
+ <Row
+ key={build.id}
+ data={{ "build-id": build.id, state: build.state }}
+ selected={build.id === selectedId}
+ onClick={() => select(build)}
+ icon={<KindIcon kind={build.kind} />}
+ title={build.title}
+ sub={whyOf(build) || t(`self_build.suggested.${build.kind}`)}
+ right={
+ <BuildActions
+ build={build}
+ canBuild={canBuild(build)}
+ blockedTitle={blockedTitle(build)}
+ busy={busyId === build.id}
+ onAction={onAction}
+ />
+ }
+ />
+ ))}
+ </Group>
+ </Section>
+ )}
+
+ {groups.live.length + groups.kept.length > 0 && (
+ <Section id="live" title={t("self_build.shelf.live")} count={groups.live.length + groups.kept.length}>
+ <Group>
+ {[...groups.live, ...groups.kept].map((build) => (
+ <BuildRow
key={build.id}
build={build}
selected={build.id === selectedId}
onSelect={() => select(build)}
- canBuild={canBuild(build)}
- blockedTitle={blockedTitle(build)}
busy={busyId === build.id}
onAction={onAction}
+ limits={limits}
locale={locale}
/>
))}
- </ul>
- </section>
- )}
-
- {groups.live.length > 0 && (
- <Shelf id="live" title={t("self_build.shelf.live")} hint={t("self_build.shelf.live_hint")} count={groups.live.length}>
- {groups.live.map((build) => (
- <BuildRow key={build.id} build={build} selected={build.id === selectedId} onSelect={() => select(build)} busy={busyId === build.id} onAction={onAction} limits={limits} locale={locale} />
- ))}
- </Shelf>
+ </Group>
+ </Section>
)}
<NoticedSection
@@ -192,25 +208,34 @@ export function SelfBuildView() {
onOpenBuild={(id) => setSelectedId(id)}
/>
- {groups.kept.length > 0 && (
- <Shelf id="kept" title={t("self_build.shelf.kept")} hint={t("self_build.shelf.kept_hint")} count={groups.kept.length}>
- {groups.kept.map((build) => (
- <BuildRow key={build.id} build={build} selected={build.id === selectedId} onSelect={() => select(build)} busy={busyId === build.id} onAction={onAction} limits={limits} locale={locale} />
- ))}
- </Shelf>
- )}
-
{groups.past.length > 0 && (
- <PastShelf builds={groups.past} selectedId={selectedId} onSelect={select} busyId={busyId} onAction={onAction} limits={limits} locale={locale} />
+ <PastSection
+ builds={groups.past}
+ selectedId={selectedId}
+ onSelect={select}
+ busyId={busyId}
+ onAction={onAction}
+ limits={limits}
+ locale={locale}
+ />
)}
- {!nothingBuilt && <HowItWorks compact />}
+ <HowItWorks center={nothingYet} />
</>
)}
-
- <Footer stopped={stopped} busy={setKill.isPending} onStop={() => setKill.mutate(true)} />
</div>
+ {confirmStop && (
+ <ConfirmStop
+ busy={setKill.isPending}
+ onCancel={() => setConfirmStop(false)}
+ onConfirm={() => {
+ setKill.mutate(true);
+ setConfirmStop(false);
+ }}
+ />
+ )}
+
{selected && (
<DetailSheet onClose={() => setSelectedId(null)}>
<BuildDetail
@@ -229,71 +254,7 @@ export function SelfBuildView() {
);
}
-// ------------------------------------------------------------------ top bar
-
-function TopBar({
- tone,
- paused,
- enabled,
- onSettings,
-}: {
- tone: HeroTone | null;
- paused: boolean;
- enabled: boolean;
- onSettings: () => void;
-}) {
- const t = useT();
- const pause = useSelfBuildPause();
- return (
- <header className="flex flex-wrap items-center gap-x-4 gap-y-3">
- <div className="min-w-0 flex-1">
- <h1 className="font-display text-xl font-semibold text-foreground-strong">{t("self_build.title")}</h1>
- </div>
- {tone && (
- <span data-testid="self-build-status" data-tone={tone} className="inline-flex items-center gap-2 text-sm text-muted-foreground">
- <span
- aria-hidden
- className={cn(
- "h-2 w-2 rounded-full",
- tone === "running" && "bg-success",
- tone === "silent" && "bg-accent",
- tone === "paused" && "bg-warning",
- tone === "stopped" && "bg-destructive",
- tone === "off" && "bg-border-strong",
- )}
- />
- {t(`self_build.status.${tone}`)}
- </span>
- )}
- {enabled && (
- <button
- type="button"
- data-testid="self-build-pause"
- aria-pressed={paused}
- title={t("self_build.pause_hint")}
- disabled={pause.isPending}
- onClick={() => pause.mutate(!paused)}
- className="inline-flex h-8 items-center gap-1.5 rounded-md border border-border-strong px-3 text-sm font-medium text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"
- >
- {paused ? <Play className="h-3.5 w-3.5" aria-hidden /> : <Pause className="h-3.5 w-3.5" aria-hidden />}
- {paused ? t("self_build.resume") : t("self_build.pause")}
- </button>
- )}
- <button
- type="button"
- onClick={onSettings}
- aria-label={t("self_build.settings")}
- title={t("self_build.settings")}
- data-testid="self-build-settings"
- className="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- >
- <Settings2 className="h-4 w-4" aria-hidden />
- </button>
- </header>
- );
-}
-
-/** Machine-readable markers for the states the hero already explains in words. */
+/** Machine-readable markers for the states the banner already explains in words. */
function StateNotes({ status, stopped }: { status: SelfBuildStatus | undefined; stopped: boolean }) {
return (
<>
@@ -305,135 +266,90 @@ function StateNotes({ status, stopped }: { status: SelfBuildStatus | undefined;
);
}
-// ------------------------------------------------------------------ digest
-
-/** What changed since yesterday, as one quiet line; nothing when nothing did. */
-function DigestLine({ digest }: { digest: BuildDigest | undefined }) {
+/** Nothing built and nothing repeated yet: say what will appear here, and when. */
+function EmptyState({ days, once }: { days: number; once: number }) {
const t = useT();
- if (!digest) return null;
- const counts = digest.counts;
- const built = (counts.trial ?? 0) + (counts.building ?? 0) + (counts.proving ?? 0);
- const parts: [string, number][] = [
- ["proposed", counts.proposed ?? 0],
- ["built", built],
- ["kept", counts.kept ?? 0],
- ["archived", counts.archived ?? 0],
- ["undone", counts.undone ?? 0],
- ];
- const shown = parts.filter(([, n]) => n > 0);
- if (!shown.length) return null;
return (
- <p data-testid="self-build-digest" className="mt-4 flex flex-wrap items-baseline gap-x-2 gap-y-1 px-1 text-sm text-muted-foreground">
- <span className="font-medium">{t("self_build.digest.label")}</span>
- {shown.map(([key, n]) => (
- <span key={key} className="text-foreground">
- <span aria-hidden className="mr-2 text-border-strong">·</span>
- {fill(t(`self_build.digest.${key}`), { count: n })}
- </span>
- ))}
- </p>
+ <div data-testid="noticed-empty" className="mt-16 flex flex-col items-center text-center">
+ <span aria-hidden className="flex h-12 w-12 items-center justify-center rounded-2xl bg-secondary text-foreground">
+ <Sparkles className="h-5 w-5" strokeWidth={1.6} />
+ </span>
+ <p className="mt-5 text-base font-medium text-foreground-strong">{t("self_build.page.empty_title")}</p>
+ <p className="mt-1.5 max-w-[44ch] text-sm leading-relaxed text-muted-foreground">
+ {fill(t("self_build.page.empty_body"), { days })}
+ </p>
+ {once > 0 && (
+ <p className="mt-3 text-xs text-foreground-faint">
+ {fill(t(once === 1 ? "self_build.noticed.once_one" : "self_build.noticed.once_other"), { count: once })}
+ </p>
+ )}
+ </div>
);
}
-// ------------------------------------------------------------------ suggestions
-
/** The first sentence of the case: the plain "why" under a suggestion. */
function whyOf(build: Build): string {
const line = (build.case || "").split("\n").map((l) => l.trim()).find(Boolean) ?? "";
- return line.length > 220 ? `${line.slice(0, 219).trimEnd()}…` : line;
+ return line.length > 160 ? `${line.slice(0, 159).trimEnd()}…` : line;
}
-function ProposalCard({
+function BuildRow({
build,
selected,
onSelect,
- canBuild,
- blockedTitle,
busy,
onAction,
+ limits,
locale,
}: {
build: Build;
selected: boolean;
onSelect: () => void;
- canBuild: boolean;
- blockedTitle?: string;
busy: boolean;
onAction: (build: Build, action: BuildAction) => void;
+ limits: Limits;
locale: string;
}) {
const t = useT();
- const why = whyOf(build);
+ const trial = trialProgress(build, limits);
+ const shelf = shelfOf(build);
+ const quiet = shelf === "past";
+ const working = shelf === "working";
+ const ref = useRef<HTMLLIElement>(null);
+ useEffect(() => {
+ if (selected) ref.current?.scrollIntoView?.({ block: "nearest" });
+ }, [selected]);
+ const sub = useMemo(() => {
+ const bits = [t(`self_build.kind.${build.kind}`)];
+ if (trial) {
+ bits.push(fill(t("self_build.trial_progress"), { days: trial.days, dayLimit: trial.dayLimit, uses: trial.uses, useLimit: trial.useLimit }));
+ } else {
+ bits.push(t(`self_build.state.${build.state}`));
+ if (build.uses > 0) bits.push(fill(t("self_build.detail.uses"), { count: build.uses }));
+ bits.push(relativeTime(build.last_used_ms || build.updated_ms, locale));
+ }
+ return bits.join(" · ");
+ }, [build, t, locale, trial]);
return (
- <li>
- <div
- data-testid="build-row"
- data-build-id={build.id}
- data-state={build.state}
- data-selected={selected || undefined}
+ <Row
+ rowRef={ref}
+ data={{ "build-id": build.id, state: build.state }}
+ selected={selected}
onClick={onSelect}
- className={cn(
- "cursor-pointer rounded-xl border bg-card px-6 py-5 transition-colors",
- selected ? "border-accent/60" : "border-border hover:border-border-strong",
- )}
- >
- <p className="flex items-center gap-2 text-sm text-muted-foreground">
- <KindIcon kind={build.kind} />
- <span>{t(`self_build.suggested.${build.kind}`)}</span>
- <span aria-hidden>·</span>
- <span>{relativeTime(build.created_ms, locale)}</span>
- </p>
- <p className="mt-2 text-lg font-medium leading-snug text-foreground-strong">{build.title}</p>
- {why && <p className="mt-1.5 line-clamp-2 text-base leading-relaxed text-muted-foreground">{why}</p>}
- <div className="mt-4 flex flex-wrap items-center gap-x-4 gap-y-2">
- <BuildActions build={build} canBuild={canBuild} blockedTitle={blockedTitle} busy={busy} onAction={onAction} size="default" />
- <span className="text-sm text-muted-foreground">
- {build.evidence.length > 0
- ? fill(t(build.evidence.length === 1 ? "self_build.based_on_one" : "self_build.based_on_other"), { count: build.evidence.length })
- : ""}
- </span>
- <OpenButton selected={selected} onSelect={onSelect} className="ml-auto" />
- </div>
- </div>
- </li>
- );
-}
-
-/** The keyboard way into a build's case file (the whole card also opens it on click). */
-function OpenButton({ selected, onSelect, className }: { selected: boolean; onSelect: () => void; className?: string }) {
- const t = useT();
- return (
- <button
- type="button"
- data-testid="build-open"
- aria-expanded={selected}
- onClick={(event) => {
- event.stopPropagation();
- onSelect();
- }}
- className={cn(
- "inline-flex h-8 items-center gap-0.5 rounded-md px-2 text-sm text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- className,
- )}
- >
- {t("self_build.details")}
- <ChevronRight className="h-3.5 w-3.5" aria-hidden />
- </button>
- );
-}
-
-// ------------------------------------------------------------------ shelves
-
-function Shelf({ id, title, hint, count, children }: { id: string; title: string; hint: string; count: number; children: ReactNode }) {
- return (
- <section data-testid={`shelf-${id}`} aria-labelledby={`shelf-${id}-title`} className="mt-12">
- <SectionHead id={`shelf-${id}-title`} title={title} hint={hint} count={count} />
- <ul className="overflow-hidden rounded-xl border border-border bg-card">{children}</ul>
- </section>
+ muted={quiet}
+ icon={working ? <Loader2 className="h-4 w-4 animate-spin" /> : <KindIcon kind={build.kind} />}
+ title={build.title}
+ sub={sub}
+ right={
+ build.state === "trial" || build.state === "kept" || build.state === "archived" ? (
+ <BuildActions build={build} canBuild={false} busy={busy} onAction={onAction} />
+ ) : undefined
+ }
+ />
);
}
-function PastShelf({
+function PastSection({
builds,
selectedId,
onSelect,
@@ -454,108 +370,43 @@ function PastShelf({
const [open, setOpen] = useState(false);
const expanded = open || builds.some((b) => b.id === selectedId);
return (
- <section data-testid="shelf-past" aria-labelledby="shelf-past-title" className="mt-12">
- <div className="mb-3 flex items-baseline gap-3">
- <h2 id="shelf-past-title" className="text-lg font-semibold text-foreground-strong">
- {t("self_build.shelf.past")}
- <span className="ml-2 font-normal tabular-nums text-muted-foreground">{builds.length}</span>
- </h2>
- <p className="hidden truncate text-sm text-muted-foreground sm:block">{t("self_build.shelf.past_hint")}</p>
+ <Section
+ id="past"
+ title={t("self_build.shelf.past")}
+ count={builds.length}
+ aside={
<button
type="button"
onClick={() => setOpen((v) => !v)}
aria-expanded={expanded}
- className="ml-auto inline-flex shrink-0 items-center gap-1 rounded-sm text-sm text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ className="inline-flex items-center gap-1 rounded-sm text-sm text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
{expanded ? t("self_build.hide_past") : fill(t("self_build.show_past"), { count: builds.length })}
<ChevronDown className={cn("h-3.5 w-3.5 transition-transform", expanded && "rotate-180")} aria-hidden />
</button>
- </div>
+ }
+ >
{expanded && (
- <ul className="overflow-hidden rounded-xl border border-border">
+ <Group>
{builds.map((build) => (
- <BuildRow key={build.id} build={build} selected={build.id === selectedId} onSelect={() => onSelect(build)} busy={busyId === build.id} onAction={onAction} limits={limits} locale={locale} />
+ <BuildRow
+ key={build.id}
+ build={build}
+ selected={build.id === selectedId}
+ onSelect={() => onSelect(build)}
+ busy={busyId === build.id}
+ onAction={onAction}
+ limits={limits}
+ locale={locale}
+ />
))}
- </ul>
+ </Group>
)}
- </section>
- );
-}
-
-function BuildRow({
- build,
- selected,
- onSelect,
- busy,
- onAction,
- limits,
- locale,
-}: {
- build: Build;
- selected: boolean;
- onSelect: () => void;
- busy: boolean;
- onAction: (build: Build, action: BuildAction) => void;
- limits: Limits;
- locale: string;
-}) {
- const t = useT();
- const trial = trialProgress(build, limits);
- const shelf = shelfOf(build);
- const quiet = shelf === "past";
- const working = shelf === "working";
- const ref = useRef<HTMLLIElement>(null);
- useEffect(() => {
- if (selected) ref.current?.scrollIntoView?.({ block: "nearest" });
- }, [selected]);
- const meta = useMemo(() => {
- const bits = [t(`self_build.kind.${build.kind}`), t(`self_build.state.${build.state}`)];
- if (build.uses > 0) bits.push(fill(t("self_build.detail.uses"), { count: build.uses }));
- bits.push(relativeTime(build.last_used_ms || build.updated_ms, locale));
- return bits.join(" · ");
- }, [build, t, locale]);
- return (
- <li ref={ref} className="border-t border-border first:border-t-0">
- <div
- data-testid="build-row"
- data-build-id={build.id}
- data-state={build.state}
- data-selected={selected || undefined}
- onClick={onSelect}
- className={cn(
- "flex cursor-pointer flex-wrap items-center gap-x-4 gap-y-3 px-5 py-4 transition-colors",
- selected ? "bg-accent/10" : "hover:bg-secondary/60",
- )}
- >
- <span className={cn("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-secondary", quiet ? "text-muted-foreground" : "text-foreground")}>
- {working ? <Loader2 className="h-4 w-4 animate-spin" aria-hidden /> : <KindIcon kind={build.kind} />}
- </span>
- <div className="min-w-0 flex-1 basis-[260px]">
- <p className={cn("line-clamp-2 text-base leading-snug", quiet ? "text-muted-foreground" : "text-foreground-strong")}>{build.title}</p>
- <p className="mt-0.5 truncate text-sm text-muted-foreground">{meta}</p>
- {trial && (
- <div className="mt-2 flex items-center gap-3">
- <div className="h-1 w-32 overflow-hidden rounded-full bg-surface-raised" aria-hidden>
- <div className="h-full rounded-full bg-accent" style={{ width: `${Math.round(trial.share * 100)}%` }} />
- </div>
- <span className="truncate text-xs tabular-nums text-muted-foreground">
- {fill(t("self_build.trial_progress"), { days: trial.days, dayLimit: trial.dayLimit, uses: trial.uses, useLimit: trial.useLimit })}
- </span>
- </div>
- )}
- </div>
- <div className="flex shrink-0 items-center gap-3">
- {(build.state === "trial" || build.state === "kept") && (
- <BuildActions build={build} canBuild={false} busy={busy} onAction={onAction} />
- )}
- <OpenButton selected={selected} onSelect={onSelect} />
- </div>
- </div>
- </li>
+ </Section>
);
}
-// ------------------------------------------------------------------ sheet, footer
+// ------------------------------------------------------------------ sheet, confirm
function DetailSheet({ onClose, children }: { onClose: () => void; children: ReactNode }) {
const panel = useRef<HTMLDivElement>(null);
@@ -581,37 +432,6 @@ function DetailSheet({ onClose, children }: { onClose: () => void; children: Rea
);
}
-function Footer({ stopped, busy, onStop }: { stopped: boolean; busy: boolean; onStop: () => void }) {
- const t = useT();
- const [confirm, setConfirm] = useState(false);
- if (stopped) return null;
- return (
- <footer className="mt-16 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-border pt-5 text-sm text-muted-foreground">
- <span className="flex-1">{t("self_build.stop_footer")}</span>
- <button
- type="button"
- data-testid="society-stop-all"
- title={t("self_build.stop_all_hint")}
- onClick={() => setConfirm(true)}
- className="inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- >
- <OctagonX className="h-4 w-4" aria-hidden />
- {t("self_build.stop_all")}
- </button>
- {confirm && (
- <ConfirmStop
- busy={busy}
- onCancel={() => setConfirm(false)}
- onConfirm={() => {
- onStop();
- setConfirm(false);
- }}
- />
- )}
- </footer>
- );
-}
-
function Centered({ children }: { children: ReactNode }) {
return <div className="flex flex-1 items-center justify-center py-24">{children}</div>;
}
diff --git a/dodaios/ui/web/frontend/src/views/selfBuild/Hero.tsx b/dodaios/ui/web/frontend/src/views/selfBuild/Hero.tsx
index 47f9050701..1aa085e305 100644
--- a/dodaios/ui/web/frontend/src/views/selfBuild/Hero.tsx
+++ b/dodaios/ui/web/frontend/src/views/selfBuild/Hero.tsx
@@ -1,15 +1,13 @@
/**
- * The top of "Built for you": one sentence that says what this page is and
- * whether it is working, a ring that shows it at a glance (the quiet start's
- * days, the helpers running, or paused), and how far the assistant may go per
- * kind of helper, in plain words.
+ * The page's state in one calm line under the title: learning (with how far
+ * along), paused, off or stopped, each with the one button that changes it.
+ * While it is simply watching there is nothing to say, so nothing shows.
*/
import type { ReactNode } from "react";
-import { Loader2, OctagonX, Pause, Power } from "lucide-react";
+import { Loader2, OctagonX, Pause, Power, Sprout } from "lucide-react";
import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
-import { BUILD_KINDS, DAY_MS, type Autonomy, type SelfBuildStatus } from "@/lib/selfBuildApi";
-import { KindIcon } from "./shared";
+import { DAY_MS, type SelfBuildStatus } from "@/lib/selfBuildApi";
export type HeroTone = "silent" | "running" | "paused" | "off" | "stopped";
@@ -27,185 +25,98 @@ export function quietDay(sinceMs: number, days: number, now = Date.now()): numbe
return Math.min(days, Math.max(1, Math.floor((now - sinceMs) / DAY_MS) + 1));
}
-export function Hero({
+export interface BannerAction {
+ label: string;
+ onClick: () => void;
+ busy?: boolean;
+ testId: string;
+}
+
+export function StatusBanner({
tone,
- status,
quiet,
- waiting,
- live,
locale,
action,
}: {
tone: HeroTone;
- status: SelfBuildStatus | undefined;
quiet: { days: number; since_ms: number; until_ms: number } | undefined;
- waiting: number;
- live: number;
locale: string;
- action?: { label: string; onClick: () => void; busy?: boolean; testId: string; icon?: ReactNode };
+ action?: BannerAction;
}) {
const t = useT();
- const day = quiet ? quietDay(quiet.since_ms, quiet.days) : 0;
- const until =
- quiet && quiet.until_ms
- ? new Date(quiet.until_ms).toLocaleDateString(locale, { weekday: "long", day: "numeric", month: "long" })
- : "";
+ if (tone === "running") return null;
- let headline: string;
+ let icon: ReactNode;
+ let title: string;
let body: string;
+ let progress: number | null = null;
if (tone === "silent") {
- headline = t("self_build.hero.silent_title");
- body = fill(t(until ? "self_build.hero.silent_body" : "self_build.hero.silent_body_nodate"), {
- days: quiet?.days ?? 7,
- date: until,
- });
- } else if (tone === "running") {
- headline =
- waiting > 0
- ? fill(t(waiting === 1 ? "self_build.hero.ideas_title_one" : "self_build.hero.ideas_title_other"), { count: waiting })
- : t("self_build.hero.running_title");
- body = t(waiting > 0 ? "self_build.hero.ideas_body" : "self_build.hero.running_body");
+ const days = quiet?.days ?? 7;
+ const day = quiet ? quietDay(quiet.since_ms, days) : 1;
+ const date = quiet?.until_ms
+ ? new Date(quiet.until_ms).toLocaleDateString(locale, { weekday: "long", day: "numeric", month: "long" })
+ : "";
+ icon = <Sprout className="h-4 w-4" aria-hidden />;
+ title = fill(t("self_build.page.learning_title"), { day, days });
+ body = date
+ ? fill(t("self_build.page.learning_body"), { date })
+ : fill(t("self_build.page.learning_body_nodate"), { days });
+ progress = days > 0 ? day / days : 0;
} else {
- headline = t(`self_build.hero.${tone}_title`);
+ icon =
+ tone === "paused" ? (
+ <Pause className="h-4 w-4" aria-hidden />
+ ) : tone === "stopped" ? (
+ <OctagonX className="h-4 w-4" aria-hidden />
+ ) : (
+ <Power className="h-4 w-4" aria-hidden />
+ );
+ title = t(`self_build.hero.${tone}_title`);
body = t(`self_build.hero.${tone}_body`);
}
return (
<section
- data-testid="self-build-hero"
+ data-testid="self-build-banner"
data-tone={tone}
- aria-labelledby="self-build-hero-title"
- className="mt-6 overflow-hidden rounded-2xl border border-border bg-card"
- >
- <div className="flex flex-col gap-6 px-6 py-7 sm:flex-row sm:items-center sm:gap-8 sm:px-8 sm:py-8">
- <Ring tone={tone} day={day} days={quiet?.days ?? 0} live={live} />
- <div className="min-w-0 flex-1">
- <h2
- id="self-build-hero-title"
- className="font-display text-2xl font-semibold leading-[34px] tracking-[-0.02em] text-foreground-strong"
- >
- {headline}
- </h2>
- <p className="mt-2 max-w-[60ch] text-lg leading-relaxed text-muted-foreground">{body}</p>
- {action && (
- <button
- type="button"
- data-testid={action.testId}
- onClick={action.onClick}
- disabled={action.busy}
- className="mt-5 inline-flex h-9 items-center gap-2 rounded-md bg-primary px-4 text-base font-medium text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60"
- >
- {action.busy ? <Loader2 className="h-4 w-4 animate-spin" aria-hidden /> : action.icon}
- {action.label}
- </button>
- )}
- </div>
- </div>
- {status && tone !== "off" && <Reach status={status} />}
- </section>
- );
-}
-
-const RING_R = 44;
-const RING_C = 2 * Math.PI * RING_R;
-
-/**
- * The ring: the quiet start fills day by day; while watching it is whole and
- * holds the number of helpers running; paused, off and stopped are grey with
- * their glyph.
- */
-function Ring({ tone, day, days, live }: { tone: HeroTone; day: number; days: number; live: number }) {
- const t = useT();
- const share = tone === "silent" ? (days > 0 ? day / days : 0) : tone === "running" ? 1 : 0;
- const label =
- tone === "silent"
- ? fill(t("self_build.hero.ring_day"), { day, days })
- : tone === "running"
- ? fill(t(live === 1 ? "self_build.hero.ring_live_one" : "self_build.hero.ring_live_other"), { count: live })
- : t(`self_build.status.${tone}`);
- return (
- <div
- className="relative h-[112px] w-[112px] shrink-0"
- role="img"
- aria-label={label}
- data-testid="self-build-ring"
+ className="mt-8 flex flex-wrap items-center gap-x-4 gap-y-3 rounded-xl border border-border bg-card px-4 py-3.5"
>
- <svg viewBox="0 0 112 112" className="h-full w-full -rotate-90" aria-hidden>
- <circle cx="56" cy="56" r={RING_R} fill="none" strokeWidth="7" className="stroke-secondary" />
- <circle
- cx="56"
- cy="56"
- r={RING_R}
- fill="none"
- strokeWidth="7"
- strokeLinecap="round"
- strokeDasharray={RING_C}
- strokeDashoffset={RING_C * (1 - share)}
- className={cn(
- "transition-[stroke-dashoffset] duration-700 ease-out",
- tone === "running" ? "stroke-success" : "stroke-accent",
- )}
- />
- </svg>
- <div className="absolute inset-0 flex flex-col items-center justify-center text-center" aria-hidden>
- {tone === "silent" ? (
- <>
- <span className="font-display text-[30px] font-semibold leading-none tabular-nums text-foreground-strong">{day}</span>
- <span className="mt-1 text-xs text-muted-foreground">{fill(t("self_build.hero.ring_of_days"), { days })}</span>
- </>
- ) : tone === "running" ? (
- live > 0 ? (
- <>
- <span className="font-display text-[30px] font-semibold leading-none tabular-nums text-foreground-strong">{live}</span>
- <span className="mt-1 text-xs text-muted-foreground">{t(live === 1 ? "self_build.hero.ring_helper_one" : "self_build.hero.ring_helper_other")}</span>
- </>
- ) : (
- <span className="relative flex h-3 w-3">
- <span className="absolute inline-flex h-full w-full rounded-full bg-success opacity-60 motion-safe:animate-ping" />
- <span className="relative inline-flex h-3 w-3 rounded-full bg-success" />
- </span>
- )
- ) : tone === "paused" ? (
- <Pause className="h-7 w-7 text-muted-foreground" strokeWidth={1.6} />
- ) : tone === "stopped" ? (
- <OctagonX className="h-7 w-7 text-destructive" strokeWidth={1.6} />
- ) : (
- <Power className="h-7 w-7 text-muted-foreground" strokeWidth={1.6} />
+ <span
+ className={cn(
+ "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg",
+ tone === "stopped" ? "bg-destructive/10 text-destructive" : "bg-secondary text-foreground",
)}
+ >
+ {icon}
+ </span>
+ <div className="min-w-0 flex-1 basis-[240px]">
+ <p className="text-sm font-medium text-foreground-strong">{title}</p>
+ <p className="mt-0.5 text-sm text-muted-foreground">{body}</p>
</div>
- </div>
- );
-}
-
-const LEVEL_TONE: Record<Autonomy, string> = {
- off: "text-foreground-faint",
- suggest: "text-foreground",
- trial: "text-foreground",
- full: "text-foreground",
-};
-
-/** How far it may go, per kind of helper, in the words a person uses. */
-function Reach({ status }: { status: SelfBuildStatus }) {
- const t = useT();
- return (
- <div className="border-t border-border px-6 py-4 sm:px-8" data-testid="self-build-reach">
- <p className="mb-3 text-sm font-medium text-muted-foreground">{t("self_build.reach.title")}</p>
- <ul className="grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-3 lg:grid-cols-5">
- {BUILD_KINDS.map((kind) => {
- const level = status.autonomy[kind] ?? "suggest";
- return (
- <li key={kind} className="flex min-w-0 items-start gap-2.5" data-kind={kind} data-level={level}>
- <span className="mt-0.5 text-muted-foreground">
- <KindIcon kind={kind} />
- </span>
- <span className="min-w-0">
- <span className="block truncate text-sm text-muted-foreground">{t(`self_build.kinds.${kind}`)}</span>
- <span className={cn("block text-base leading-snug", LEVEL_TONE[level])}>{t(`self_build.reach.${level}`)}</span>
- </span>
- </li>
- );
- })}
- </ul>
- </div>
+ {progress !== null && (
+ <div
+ className="h-1.5 w-28 shrink-0 overflow-hidden rounded-full bg-secondary"
+ role="progressbar"
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={Math.round(progress * 100)}
+ aria-label={title}
+ >
+ <div className="h-full rounded-full bg-accent" style={{ width: `${Math.round(progress * 100)}%` }} />
+ </div>
+ )}
+ {action && (
+ <button
+ type="button"
+ data-testid={action.testId}
+ onClick={action.onClick}
+ disabled={action.busy}
+ className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60"
+ >
+ {action.busy && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}
+ {action.label}
+ </button>
+ )}
+ </section>
);
}
diff --git a/dodaios/ui/web/frontend/src/views/selfBuild/List.tsx b/dodaios/ui/web/frontend/src/views/selfBuild/List.tsx
new file mode 100644
index 0000000000..cc30c210e5
--- /dev/null
+++ b/dodaios/ui/web/frontend/src/views/selfBuild/List.tsx
@@ -0,0 +1,111 @@
+/**
+ * The two shapes every list on "Built for you" is made of: a section (a small
+ * label over one bordered group) and a row (an icon tile, a title, one quiet
+ * line under it, and whatever belongs on the right). One shape for
+ * suggestions, helpers and repeats keeps the page reading as one list.
+ */
+import type { KeyboardEvent, ReactNode, Ref } from "react";
+import { cn } from "@/lib/utils";
+
+export function Section({
+ id,
+ title,
+ count,
+ aside,
+ children,
+}: {
+ id: string;
+ title: string;
+ count?: number;
+ aside?: ReactNode;
+ children: ReactNode;
+}) {
+ return (
+ <section data-testid={`shelf-${id}`} aria-labelledby={`shelf-${id}-title`} className="mt-10">
+ <div className="mb-2.5 flex items-baseline gap-2 px-1">
+ <h2 id={`shelf-${id}-title`} className="text-sm font-medium text-foreground">
+ {title}
+ </h2>
+ {count !== undefined && <span className="text-sm tabular-nums text-muted-foreground">{count}</span>}
+ {aside && <div className="ml-auto">{aside}</div>}
+ </div>
+ {children}
+ </section>
+ );
+}
+
+export function Group({ children }: { children: ReactNode }) {
+ return <ul className="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">{children}</ul>;
+}
+
+export function Row({
+ icon,
+ title,
+ sub,
+ right,
+ muted = false,
+ selected = false,
+ onClick,
+ testId = "build-row",
+ data,
+ rowRef,
+}: {
+ icon: ReactNode;
+ title: ReactNode;
+ sub?: ReactNode;
+ right?: ReactNode;
+ muted?: boolean;
+ selected?: boolean;
+ onClick?: () => void;
+ testId?: string;
+ data?: Record<string, string | undefined>;
+ rowRef?: Ref<HTMLLIElement>;
+}) {
+ const dataAttrs = Object.fromEntries(Object.entries(data ?? {}).map(([k, v]) => [`data-${k}`, v]));
+ const onKey = (event: KeyboardEvent<HTMLDivElement>) => {
+ if (onClick && event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
+ event.preventDefault();
+ onClick();
+ }
+ };
+ return (
+ <li ref={rowRef}>
+ <div
+ data-testid={testId}
+ role={onClick ? "button" : undefined}
+ tabIndex={onClick ? 0 : undefined}
+ aria-pressed={onClick ? selected : undefined}
+ onKeyDown={onKey}
+ data-selected={selected || undefined}
+ {...dataAttrs}
+ onClick={onClick}
+ className={cn(
+ "flex items-center gap-4 px-4 py-3.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
+ onClick && "cursor-pointer",
+ selected ? "bg-secondary" : onClick && "hover:bg-secondary/60",
+ )}
+ >
+ <span
+ aria-hidden
+ className={cn(
+ "flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary",
+ muted ? "text-muted-foreground" : "text-foreground",
+ )}
+ >
+ {icon}
+ </span>
+ <div className="min-w-0 flex-1">
+ <p className={cn("truncate text-[15px] leading-snug", muted ? "text-muted-foreground" : "text-foreground-strong")}>
+ {title}
+ </p>
+ {sub && <p className="mt-0.5 truncate text-sm text-muted-foreground">{sub}</p>}
+ </div>
+ {right && (
+ <div className="flex shrink-0 items-center gap-3" onClick={(event) => event.stopPropagation()}>
+ {right}
+ </div>
+ )}
+ </div>
+ </li>
+ );
+}
diff --git a/dodaios/ui/web/frontend/src/views/selfBuild/Noticed.tsx b/dodaios/ui/web/frontend/src/views/selfBuild/Noticed.tsx
index be972793d8..7b2562ffd3 100644
--- a/dodaios/ui/web/frontend/src/views/selfBuild/Noticed.tsx
+++ b/dodaios/ui/web/frontend/src/views/selfBuild/Noticed.tsx
@@ -1,17 +1,18 @@
/**
- * "Noticed so far": the requests the person repeats, each with how often and
- * on how many days, and how far it is from becoming a suggestion. It is the
- * proof that the page is working before anything is built. Only the person's
- * own requests count (dodaios/self_build/miner.py); the labels are their own
- * latest wording, cut short by the route.
+ * "Noticed": the requests the person repeats, each with how close it is to
+ * becoming a suggestion. It is the proof that the page is working before
+ * anything is built. Only the person's own requests count
+ * (dodaios/self_build/miner.py); the labels are their own latest wording, cut
+ * short by the route.
*
- * Also "How it works": three steps, shown big while nothing is built yet and
- * small once there is.
+ * Also "How does this work?": three plain steps behind one quiet toggle.
*/
-import { Hand, MessageSquareText, Sparkles } from "lucide-react";
+import { useState } from "react";
+import { ChevronDown, MessageSquareText } from "lucide-react";
import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
import type { Noticed as NoticedData, NoticedNeed } from "@/lib/selfBuildApi";
+import { Group, Row, Section } from "./List";
import { relativeTime } from "./shared";
export function NoticedSection({
@@ -27,51 +28,36 @@ export function NoticedSection({
onOpenBuild: (id: string) => void;
}) {
const t = useT();
- if (!data) return null;
+ if (!data || data.needs.length === 0) return null;
const { needs, once, more, threshold } = data;
+ const footer = [
+ more > 0 ? fill(t("self_build.noticed.more"), { count: more }) : "",
+ once > 0 ? fill(t(once === 1 ? "self_build.noticed.once_one" : "self_build.noticed.once_other"), { count: once }) : "",
+ ]
+ .filter(Boolean)
+ .join(" · ");
return (
- <section data-testid="self-build-noticed" aria-labelledby="noticed-title" className="mt-12">
- <SectionHead id="noticed-title" title={t("self_build.noticed.title")} hint={t("self_build.noticed.hint")} />
- {needs.length === 0 ? (
- <div className="rounded-xl border border-dashed border-border px-6 py-8 text-center" data-testid="noticed-empty">
- <p className="text-base text-foreground">{t("self_build.noticed.empty")}</p>
- <p className="mt-1 text-sm text-muted-foreground">
- {once > 0
- ? fill(t(once === 1 ? "self_build.noticed.once_one" : "self_build.noticed.once_other"), { count: once })
- : t("self_build.noticed.empty_hint")}
- </p>
- </div>
- ) : (
- <>
- <ul className="overflow-hidden rounded-xl border border-border bg-card">
- {needs.map((need, index) => (
- <NeedRow
- key={need.id}
- need={need}
- days={threshold.days}
- times={threshold.times}
- locale={locale}
- paused={paused}
- first={index === 0}
- onOpenBuild={onOpenBuild}
- />
- ))}
- </ul>
- {(once > 0 || more > 0) && (
- <p className="mt-3 text-sm text-muted-foreground">
- {[
- more > 0 ? fill(t("self_build.noticed.more"), { count: more }) : "",
- once > 0
- ? fill(t(once === 1 ? "self_build.noticed.once_one" : "self_build.noticed.once_other"), { count: once })
- : "",
- ]
- .filter(Boolean)
- .join(" · ")}
- </p>
- )}
- </>
- )}
- </section>
+ <div data-testid="self-build-noticed">
+ <Section id="noticed" title={t("self_build.noticed.title")} count={needs.length}>
+ <Group>
+ {needs.map((need) => (
+ <NeedRow
+ key={need.id}
+ need={need}
+ days={threshold.days}
+ times={threshold.times}
+ locale={locale}
+ paused={paused}
+ onOpenBuild={onOpenBuild}
+ />
+ ))}
+ </Group>
+ <p className="mt-2.5 px-1 text-sm text-muted-foreground">
+ {fill(t("self_build.page.noticed_rule"), { days: threshold.days })}
+ {footer && <span className="text-foreground-faint"> · {footer}</span>}
+ </p>
+ </Section>
+ </div>
);
}
@@ -81,7 +67,6 @@ function NeedRow({
times,
locale,
paused,
- first,
onOpenBuild,
}: {
need: NoticedNeed;
@@ -89,69 +74,60 @@ function NeedRow({
times: number;
locale: string;
paused: boolean;
- first: boolean;
onOpenBuild: (id: string) => void;
}) {
const t = useT();
const reached = Math.min(need.days, days);
- const meta = [
+ const sub = [
fill(t("self_build.noticed.times"), { count: need.times }),
fill(t(need.days === 1 ? "self_build.noticed.days_one" : "self_build.noticed.days_other"), { count: need.days }),
relativeTime(need.last_ms, locale),
].join(" · ");
- const { text, tone } = stageText(need, days, times, paused, t);
- const stage =
- need.stage === "proposed" && need.build_id ? (
+
+ let right: React.ReactNode;
+ if (need.stage === "counting") {
+ right = (
+ <span className="flex items-center gap-3">
+ <span className="text-sm tabular-nums text-muted-foreground">{stageText(need, days, times, paused, t).text}</span>
+ <span
+ role="img"
+ aria-label={fill(t("self_build.noticed.progress"), { count: reached, total: days })}
+ className="h-1.5 w-16 overflow-hidden rounded-full bg-secondary"
+ >
+ <span className="block h-full rounded-full bg-foreground-strong" style={{ width: `${Math.round((reached / Math.max(1, days)) * 100)}%` }} />
+ </span>
+ </span>
+ );
+ } else if (need.stage === "proposed" && need.build_id) {
+ right = (
<button
type="button"
onClick={() => onOpenBuild(need.build_id)}
className="rounded-sm text-sm font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
- {text}
+ {t("self_build.noticed.stage.proposed")}
</button>
- ) : (
- <span className={cn("text-sm", tone)}>{text}</span>
);
+ } else {
+ const { text, tone } = stageText(need, days, times, paused, t);
+ right = <span className={cn("text-sm", tone)}>{text}</span>;
+ }
+
return (
- <li
- data-testid="noticed-need"
- data-stage={need.stage}
- className={cn("flex flex-wrap items-center gap-x-6 gap-y-2 px-5 py-4", !first && "border-t border-border")}
- >
- <div className="min-w-0 flex-1 basis-[280px]">
- <p className="truncate text-base text-foreground-strong" title={need.label}>
+ <Row
+ testId="noticed-need"
+ data={{ stage: need.stage }}
+ icon={<MessageSquareText className="h-4 w-4" strokeWidth={1.75} />}
+ title={
+ <span title={need.label}>
{t("self_build.noticed.quote_open")}
{need.label}
{t("self_build.noticed.quote_close")}
- </p>
- <p className="mt-0.5 text-sm text-muted-foreground">{meta}</p>
- </div>
- <div className="flex shrink-0 items-center gap-4">
- <span
- className="flex items-center gap-1.5"
- role="img"
- aria-label={fill(t("self_build.noticed.progress"), { count: reached, total: days })}
- >
- {Array.from({ length: days }, (_, i) => (
- <span
- key={i}
- aria-hidden
- className={cn(
- "h-2 w-2 rounded-full",
- i >= reached
- ? "bg-surface-raised"
- : need.stage === "counting"
- ? "bg-foreground-strong"
- : need.stage === "ready" || need.stage === "proposed"
- ? "bg-accent"
- : "bg-foreground-faint",
- )}
- />
- ))}
</span>
- <span className="w-[240px] text-right">{stage}</span>
- </div>
- </li>
+ }
+ sub={sub}
+ right={right}
+ />
);
}
@@ -188,62 +164,39 @@ function stageText(
}
}
-export function SectionHead({ id, title, hint, count }: { id: string; title: string; hint?: string; count?: number }) {
- return (
- <div className="mb-3 flex flex-wrap items-baseline gap-x-3 gap-y-0.5">
- <h2 id={id} className="text-lg font-semibold text-foreground-strong">
- {title}
- {count !== undefined && <span className="ml-2 font-normal tabular-nums text-muted-foreground">{count}</span>}
- </h2>
- {hint && <p className="text-sm text-muted-foreground">{hint}</p>}
- </div>
- );
-}
-
// ------------------------------------------------------------------ how it works
-const STEPS = [
- { key: "notice", Icon: MessageSquareText },
- { key: "suggest", Icon: Sparkles },
- { key: "try", Icon: Hand },
-] as const;
+const STEPS = ["notice", "suggest", "try"] as const;
-export function HowItWorks({ compact = false }: { compact?: boolean }) {
+export function HowItWorks({ center = false }: { center?: boolean }) {
const t = useT();
+ const [open, setOpen] = useState(false);
return (
- <section
- data-testid="self-build-how"
- data-compact={compact || undefined}
- aria-labelledby="how-title"
- className={compact ? "mt-14" : "mt-10"}
- >
- <h2 id="how-title" className={cn(compact ? "mb-3 text-sm font-medium text-muted-foreground" : "sr-only")}>
- {t("self_build.how.title")}
- </h2>
- <ol className="grid grid-cols-1 gap-4 sm:grid-cols-3">
- {STEPS.map(({ key, Icon }, index) => (
- <li key={key} className={cn("min-w-0", !compact && "rounded-xl border border-border px-5 py-5")}>
- <div className="flex items-center gap-3">
- <span
- aria-hidden
- className={cn(
- "inline-flex shrink-0 items-center justify-center rounded-lg bg-secondary text-foreground",
- compact ? "h-7 w-7" : "h-9 w-9",
- )}
- >
- <Icon className={compact ? "h-3.5 w-3.5" : "h-[18px] w-[18px]"} strokeWidth={1.6} />
+ <section data-testid="self-build-how" className={cn("mt-10 px-1", center && "flex flex-col items-center")}>
+ <button
+ type="button"
+ aria-expanded={open}
+ onClick={() => setOpen((v) => !v)}
+ className="inline-flex items-center gap-1.5 rounded-sm text-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {t("self_build.page.how_toggle")}
+ <ChevronDown aria-hidden className={cn("h-3.5 w-3.5 transition-transform", open && "rotate-180")} />
+ </button>
+ {open && (
+ <ol className={cn("mt-4 space-y-3", center && "max-w-[52ch] text-left")}>
+ {STEPS.map((key, index) => (
+ <li key={key} className="flex gap-3">
+ <span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-secondary text-xs tabular-nums text-foreground">
+ {index + 1}
</span>
- <p className={cn("font-medium text-foreground-strong", compact ? "text-base" : "text-lg")}>
- <span className="mr-1.5 tabular-nums text-muted-foreground">{index + 1}</span>
- {t(`self_build.how.${key}_title`)}
+ <p className="text-sm leading-relaxed text-muted-foreground">
+ <span className="font-medium text-foreground">{t(`self_build.how.${key}_title`)}.</span>{" "}
+ {t(`self_build.how.${key}_body`)}
</p>
- </div>
- <p className={cn("text-muted-foreground", compact ? "mt-1.5 text-sm" : "mt-3 text-base leading-relaxed")}>
- {t(`self_build.how.${key}_body`)}
- </p>
- </li>
- ))}
- </ol>
+ </li>
+ ))}
+ </ol>
+ )}
</section>
);
}
diff --git a/dodaios/ui/web/frontend/src/views/selfBuild/StatusMenu.tsx b/dodaios/ui/web/frontend/src/views/selfBuild/StatusMenu.tsx
new file mode 100644
index 0000000000..43a02e701b
--- /dev/null
+++ b/dodaios/ui/web/frontend/src/views/selfBuild/StatusMenu.tsx
@@ -0,0 +1,161 @@
+/**
+ * The page's one control: a status pill ("Learning", "Paused", ...) that opens
+ * a small menu with pause/resume, settings and the emergency stop. Everything
+ * the page used to spread over a toolbar, a hero button and a footer lives
+ * here, the way desktop chat apps tuck page options behind one button.
+ */
+import { useEffect, useRef, useState } from "react";
+import { ChevronDown, OctagonX, Pause, Play, Settings2 } from "lucide-react";
+import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+import type { HeroTone } from "./Hero";
+
+export function StatusMenu({
+ tone,
+ enabled,
+ paused,
+ pauseBusy,
+ onPause,
+ onSettings,
+ onStopAll,
+}: {
+ tone: HeroTone | null;
+ enabled: boolean;
+ paused: boolean;
+ pauseBusy: boolean;
+ onPause: (paused: boolean) => void;
+ onSettings: () => void;
+ /** Absent once everything is already stopped. */
+ onStopAll?: () => void;
+}) {
+ const t = useT();
+ const [open, setOpen] = useState(false);
+ const root = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ if (!open) return;
+ const onPointer = (event: PointerEvent) => {
+ if (!root.current?.contains(event.target as Node)) setOpen(false);
+ };
+ const onKey = (event: KeyboardEvent) => {
+ if (event.key === "Escape") setOpen(false);
+ };
+ document.addEventListener("pointerdown", onPointer);
+ document.addEventListener("keydown", onKey);
+ return () => {
+ document.removeEventListener("pointerdown", onPointer);
+ document.removeEventListener("keydown", onKey);
+ };
+ }, [open]);
+
+ const run = (fn: () => void) => () => {
+ setOpen(false);
+ fn();
+ };
+
+ return (
+ <div ref={root} className="relative shrink-0">
+ <button
+ type="button"
+ data-testid="self-build-menu"
+ aria-haspopup="menu"
+ aria-expanded={open}
+ onClick={() => setOpen((v) => !v)}
+ className={cn(
+ "inline-flex h-8 items-center gap-2 rounded-full border border-border px-3 text-sm text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ open && "bg-secondary",
+ )}
+ >
+ {tone && (
+ <span data-testid="self-build-status" data-tone={tone} className="inline-flex items-center gap-2">
+ <span aria-hidden className={cn("h-2 w-2 rounded-full", DOT[tone])} />
+ {t(`self_build.status.${tone}`)}
+ </span>
+ )}
+ <ChevronDown aria-hidden className={cn("h-3.5 w-3.5 text-muted-foreground transition-transform", open && "rotate-180")} />
+ </button>
+ {open && (
+ <div
+ role="menu"
+ className="absolute right-0 top-10 z-50 w-64 rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-float"
+ >
+ {enabled && (
+ <MenuItem
+ testId="self-build-pause"
+ icon={paused ? <Play className="h-4 w-4" aria-hidden /> : <Pause className="h-4 w-4" aria-hidden />}
+ label={paused ? t("self_build.resume") : t("self_build.pause")}
+ hint={paused ? undefined : t("self_build.page.pause_hint")}
+ disabled={pauseBusy}
+ onClick={run(() => onPause(!paused))}
+ />
+ )}
+ <MenuItem
+ testId="self-build-settings"
+ icon={<Settings2 className="h-4 w-4" aria-hidden />}
+ label={t("self_build.settings")}
+ onClick={run(onSettings)}
+ />
+ {onStopAll && (
+ <>
+ <div role="separator" className="mx-2 my-1 h-px bg-border" />
+ <MenuItem
+ testId="society-stop-all"
+ icon={<OctagonX className="h-4 w-4" aria-hidden />}
+ label={t("self_build.stop_all")}
+ hint={t("self_build.page.stop_hint")}
+ danger
+ onClick={run(onStopAll)}
+ />
+ </>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
+
+const DOT: Record<HeroTone, string> = {
+ running: "bg-success",
+ silent: "bg-accent",
+ paused: "bg-warning",
+ stopped: "bg-destructive",
+ off: "bg-border-strong",
+};
+
+function MenuItem({
+ testId,
+ icon,
+ label,
+ hint,
+ danger = false,
+ disabled = false,
+ onClick,
+}: {
+ testId: string;
+ icon: React.ReactNode;
+ label: string;
+ hint?: string;
+ danger?: boolean;
+ disabled?: boolean;
+ onClick: () => void;
+}) {
+ return (
+ <button
+ type="button"
+ role="menuitem"
+ data-testid={testId}
+ disabled={disabled}
+ onClick={onClick}
+ className={cn(
+ "flex w-full items-start gap-3 rounded-lg px-3 py-2 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
+ danger ? "text-destructive hover:bg-destructive/10" : "text-foreground hover:bg-secondary",
+ )}
+ >
+ <span className="mt-0.5 shrink-0">{icon}</span>
+ <span className="min-w-0">
+ <span className="block">{label}</span>
+ {hint && <span className="mt-0.5 block text-xs leading-snug text-muted-foreground">{hint}</span>}
+ </span>
+ </button>
+ );
+}