diff --git a/app/src/components/responsibilities/goal-page.tsx b/app/src/components/responsibilities/goal-page.tsx index 6f8b1a812a..ecd516dcfb 100644 --- a/app/src/components/responsibilities/goal-page.tsx +++ b/app/src/components/responsibilities/goal-page.tsx @@ -266,43 +266,45 @@ export function GoalPage({ return ( + + action.mutate({ + id: goal.id, + action: active ? "resume" : "pause", + }) + } + /> + + + ) + } + description={ + <> + + {summaryFor(goal, triggers.data, routines)} + + {/* What starts it. A paused goal's summary already says nothing does. */} + {goal.status === "active" ? ( + {`Its ${starters} start it.`} + ) : null} + + } title={goal.title} > - {/* What can be done to it now. The page title names it, so this first section has no heading. */} + {/* What else can be done to it. The page title names it, so this first section has no heading. */} - {goal.status !== "completed" ? ( - <> - - - - - - Active - - {goal.status === "active" - ? `Its ${starters} start it.` - : `Paused. Its ${starters} won't start it.`} - - - - - action.mutate({ - id: goal.id, - action: active ? "resume" : "pause", - }) - } - /> - - - - - ) : null} {goal.status === "active" ? ( <> - - { - remove.reset(); - setConfirmingDelete(true); - }} - title="Delete goal" - /> {action.error ? (

@@ -555,6 +547,21 @@ export function GoalPage({ + {/* Away from the everyday controls, at the bottom. */} + + + { + remove.reset(); + setConfirmingDelete(true); + }} + title="Delete goal" + /> + + +

@@ -603,7 +610,7 @@ export function GoalPage({ const RUN_LABEL: Record = { queued: "Queued", - running: "Running", + running: "Running now", waiting: "Waiting for you", succeeded: "Succeeded", failed: "Failed", diff --git a/app/src/components/routines/bot-group.tsx b/app/src/components/routines/bot-group.tsx index 78e6e80a20..d75de32942 100644 --- a/app/src/components/routines/bot-group.tsx +++ b/app/src/components/routines/bot-group.tsx @@ -1,175 +1,73 @@ +import { useQuery } from "@tanstack/react-query"; import { Link } from "@tanstack/react-router"; import { AnimatePresence } from "motion/react"; import { BotOrb } from "@/components/agents/bot-orb"; -import { - IconClock, - IconEye, - IconLoader2, - IconPlayerPause, - IconTarget, -} from "@/components/icons"; -import { KIND_LABEL } from "@/components/responsibilities/triggers"; -import { useGoalTriggers } from "@/components/responsibilities/use-goal-reads"; +import { PageRows } from "@/components/layout/page-shell"; +import { RoutineRow, routineCount } from "@/components/routines/routine-row"; import { Unfold } from "@/components/routines/unfold"; -import { - type BotGroup, - isOff, - isRunning, - type RowTone, - rowFact, - rowName, -} from "@/lib/routines/by-bot"; -import { describeEvent } from "@/lib/routines/events"; -import { goalStarts, type MergedRoutine } from "@/lib/routines/merged"; -import { cn } from "@/lib/utils"; +import { Separator } from "@/components/ui/separator"; +import { agentQueryOptions } from "@/lib/agents/queries"; +import type { BotGroup } from "@/lib/routines/by-bot"; +import type { MergedRoutine } from "@/lib/routines/merged"; -const ROW_CLASS = - "flex flex-col gap-0.5 rounded-lg px-2 py-2 text-sm hover:bg-muted sm:flex-row sm:items-center sm:gap-3"; - -const FACT_CLASS: Record = { - running: "text-foreground", - warning: "text-warning", - muted: "text-muted-foreground", - normal: "text-muted-foreground", -}; - -function RowIcon({ row }: { row: MergedRoutine }) { - const className = "size-4 shrink-0 text-muted-foreground"; - if (isRunning(row)) - return ( - - ); - if (isOff(row)) return ; - switch (row.kind) { - case "routine": - return ; - case "goal": - return ; - case "check-in": - return ; - } -} - -/** A row's one line: its icon, its name, and the one fact about it. */ -function RowLine({ - row, - starts, -}: { - row: MergedRoutine; - /** A goal's starts in words; the others have none. */ - starts: string | null; -}) { - const fact = rowFact(row, starts); - return ( - <> - - - {rowName(row)} - - - {fact.text} - - - ); -} - -/** Dimmed when its fact is the muted one: paused, or a goal that is completed. */ -function rowClass(row: MergedRoutine, starts: string | null) { - return cn(ROW_CLASS, rowFact(row, starts).tone === "muted" && "opacity-60"); +/** + * One row as the Routines page draws it. The shared row (`RoutineRow`), kept under this name for the + * Bot's page, which draws it too. + */ +export function GroupRow({ row }: { row: MergedRoutine }) { + return ; } /** - * A goal's row. Its own component, so only an active goal reads its triggers (`useGoalTriggers`), - * which its starts are made of. + * The name a group heads with. A Bot no list has (one shared with you, or not listed for this + * person) is read on its own, so its group says its real name; "A Bot" only while that read is on + * its way or when it fails, as for a Bot that was deleted. */ -function GoalRow({ row }: { row: Extract }) { - const triggers = useGoalTriggers(row.goal.id, { - enabled: row.goal.status === "active", +function useGroupName(group: BotGroup): string { + const bot = useQuery({ + ...agentQueryOptions(group.botId), + enabled: !group.known, + retry: false, }); - const starts = goalStarts( - row.goal, - triggers.data - ?.filter((trigger) => trigger.enabled) - .map((trigger) => `${KIND_LABEL[trigger.kind]} trigger`), - row.routines, - describeEvent, - ); - return ( - - - - ); -} - -/** One row as the Routines page draws it, opening the routine, goal or check-in it is. */ -export function GroupRow({ row }: { row: MergedRoutine }) { - switch (row.kind) { - case "routine": - return ( - - - - ); - case "goal": - return ; - case "check-in": - return ( - - - - ); - } + return group.known ? group.name : (bot.data?.name ?? group.name); } /** - * One Bot's routines on the Routines page: the Bot's orb, name and how many it has, then one line - * per row. The name opens the Bot's own Routines page, except for "A Bot", a Bot no list knows, - * which has none. + * One Bot's routines on the Routines page: the Bot's orb, name and how many it has, then its rows in + * one card. The name opens the Bot's own Routines page, except for a Bot no list knows, which has none. */ export function BotGroupSection({ group }: { group: BotGroup }) { + const name = useGroupName(group); return ( // Spaced with padding, not margin: the group's height opens and folds, and a margin outside it // would jump. -
-
- +
+
+ {group.known ? ( - {group.name} + {name} ) : ( - {group.name} + {name} )} - {group.rows.length} + {routineCount(group.rows.length)}
- {/* A routine made or removed while the page is open opens or folds; the rest just appear. */} - - {group.rows.map((row) => ( - - - - ))} - + + {/* A routine made or removed while the page is open opens or folds; the rest just appear. */} + + {group.rows.map((row, index) => ( + + {index > 0 ? : null} + + + ))} + +
); } diff --git a/app/src/components/routines/delete-row.tsx b/app/src/components/routines/delete-row.tsx index 3cea2ccdb9..c35569d356 100644 --- a/app/src/components/routines/delete-row.tsx +++ b/app/src/components/routines/delete-row.tsx @@ -8,9 +8,9 @@ import { } from "@/components/ui/item"; /** - * The last row of a goal's, a schedule's or a check-in's actions card: delete it, after a - * confirmation the page opens. A row in the card with the page's other actions, never a button left - * on its own under the page, which reads as something that fell out of the layout. + * Delete a goal, a schedule or a check-in, after a confirmation the page opens. A row in a card of + * its own, in the last section of the page: away from the everyday controls, so it is never pressed + * on the way to Run now, and still a row, never a button left on its own under the page. */ export function DeleteRow({ title, diff --git a/app/src/components/routines/new-routine-page.tsx b/app/src/components/routines/new-routine-page.tsx index db7b45088a..b406175cb6 100644 --- a/app/src/components/routines/new-routine-page.tsx +++ b/app/src/components/routines/new-routine-page.tsx @@ -1,18 +1,20 @@ import { useSelector } from "@tanstack/react-form"; import { useInfiniteQuery, useMutation, useQuery } from "@tanstack/react-query"; import { Link, linkOptions, useNavigate } from "@tanstack/react-router"; -import { useEffect, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; import { AbstractAvatar } from "@/components/agents/abstract-avatar"; -import { - PageCard, - PageSection, - PageShell, -} from "@/components/layout/page-shell"; +import { IconChevronRight } from "@/components/icons"; +import { PageCard, PageShell } from "@/components/layout/page-shell"; import { ScheduleWhen, useRoutineForm, } from "@/components/routines/schedule-when"; import { Button } from "@/components/ui/button"; +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from "@/components/ui/collapsible"; import { Field, FieldDescription, @@ -67,6 +69,7 @@ import { import { openingOf } from "@/lib/voice/cut"; import { queryClient } from "@/query-client"; import { failureSaid } from "@/lib/load-failure"; +import { cn } from "@/lib/utils"; /** The conversations a routine for this Bot may post in: live ones the Bot is in. */ function conversationsWith( @@ -266,10 +269,106 @@ export function NewRoutinePage({ if (saved) goToRoutines.current?.focus(); }, [saved]); + /* + * Advanced settings: open from the start when what fills the form already set one of them (a + * sentence that named it, or the clock beside a conversation), and held open while one of them has + * a message, so Create can move focus to it. + */ + const [advanced, setAdvanced] = useState( + Boolean( + defaultValues.doneWhen || + defaultValues.title || + defaultValues.channelId !== NEW_CONVERSATION, + ), + ); + const advancedOpen = + advanced || "doneWhen" in shown || "title" in shown || "channelId" in shown; + const botItems = Object.fromEntries( (agents.data ?? []).map((agent) => [agent.id, agent.name]), ) as Record; + const startsSelect = ( + + {(field) => ( + + )} + + ); + + const buttons = saved ? ( + // Cancel says nothing was kept. After a partial or uncertain save the work is kept, and Go to + // Routines goes to the same list. + + ) : ( + <> + {createFromPlan.isPending ? ( + // Not a link while the writes are on their way: leaving now would hide what they answer. + + ) : ( + + )} + {/* Enabled while a message shows: pressing it takes the person to the first one. A + disabled button says nothing about why, and a keyboard can't reach it. */} + state.isSubmitting}> + {(isSubmitting) => ( + + )} + + + ); + return (
- {/* Sections rather than one card, as New skill is: who does it and what, when it starts, - when it is done, and where it shows up. Each is one decision with room for its words. */} - - - - - {(field) => { - const isInvalid = field.name in shown; - return ( - - Bot - - {isInvalid ? ( - - {shown[field.name]} - - ) : null} - - ); - }} - - - - {(field) => { - const isInvalid = field.name in shown; - return ( - - What to do - - Write it as one run of the work. Leave the schedule out. - -