diff --git a/webui/src/components/settings/SettingsPage.tsx b/webui/src/components/settings/SettingsPage.tsx index 7b9fb7196..2be379df4 100644 --- a/webui/src/components/settings/SettingsPage.tsx +++ b/webui/src/components/settings/SettingsPage.tsx @@ -97,8 +97,6 @@ export function SettingsPage({ automationsError, automationsFilter, automationsLoading, - automationsQuery, - automationsSort, beginModelPresetCreation, cancelModelPresetCreation, changeModelCallOrder, @@ -195,8 +193,6 @@ export function SettingsPage({ setAutomationPendingDelete, setAutomationPendingEdit, setAutomationsFilter, - setAutomationsQuery, - setAutomationsSort, setCliAppsError, setCliAppsMessage, setCustomMcpForm, @@ -578,14 +574,10 @@ export function SettingsPage({ settingsSnapshot={controller.settings} onStartChat={onStartAutomationChat} loading={automationsLoading} - query={automationsQuery} filter={automationsFilter} - sort={automationsSort} actionKey={automationAction} error={automationsError} - onQueryChange={setAutomationsQuery} onFilterChange={setAutomationsFilter} - onSortChange={setAutomationsSort} onAction={handleAutomationAction} onRequestEdit={(job) => { setAutomationDetailReturn(null); diff --git a/webui/src/components/settings/system/AutomationCalendar.tsx b/webui/src/components/settings/system/AutomationCalendar.tsx index 0fe46dbfa..211d64050 100644 --- a/webui/src/components/settings/system/AutomationCalendar.tsx +++ b/webui/src/components/settings/system/AutomationCalendar.tsx @@ -1,8 +1,10 @@ -import { ChevronDown, CircleAlert, Clock3, Loader2 } from "lucide-react"; -import { useLayoutEffect, useMemo, useRef, useState } from "react"; +import { CircleAlert, Loader2, X } from "lucide-react"; +import { useId, useLayoutEffect, useMemo, useRef, useState } from "react"; +import type { ReactNode } from "react"; import { Button } from "@/components/ui/button"; import { formControlFocusClassName } from "@/components/ui/form-control"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import type { SessionAutomationJob } from "@/lib/types"; import { cn } from "@/lib/utils"; @@ -24,10 +26,8 @@ type CalendarCopy = { running: string; failed: string; more: (count: number) => string; + close: string; noEntries: string; - outsideMonth: string; - paused: string; - attention: string; completed: string; }; @@ -35,6 +35,7 @@ interface AutomationCalendarProps { jobs: SessionAutomationJob[]; locale: string; copy: CalendarCopy; + filters?: ReactNode; onInspect: (job: SessionAutomationJob, trigger: HTMLElement) => void; } @@ -173,7 +174,72 @@ function CalendarEntryRow({ entry, locale, copy, onInspect, compact = false }: { ); } -export function AutomationCalendar({ jobs, locale, copy, onInspect }: AutomationCalendarProps) { +function CalendarOverflowEntries({ entries, dayLabel, locale, copy, onInspect }: { + entries: CalendarEntry[]; + dayLabel: string; + locale: string; + copy: CalendarCopy; + onInspect: AutomationCalendarProps["onInspect"]; +}) { + const [open, setOpen] = useState(false); + const titleId = useId(); + const triggerRef = useRef(null); + const pendingSelection = useRef(null); + + return ( + + + + + { + const job = pendingSelection.current; + pendingSelection.current = null; + if (!job || !triggerRef.current?.isConnected) return; + // Hand off after the day popover exits, retaining a mounted return target. + event.preventDefault(); + onInspect(job, triggerRef.current); + }} + > +
+

{dayLabel}

+ +
+ {entries.map((entry) => ( + { + pendingSelection.current = job; + setOpen(false); + }} + compact + /> + ))} +
+
+ ); +} + +export function AutomationCalendar({ jobs, locale, copy, filters, onInspect }: AutomationCalendarProps) { const [month, setMonth] = useState(() => startOfMonth(new Date())); const calendarRef = useRef(null); const [wideCalendar, setWideCalendar] = useState(true); @@ -190,16 +256,12 @@ export function AutomationCalendar({ jobs, locale, copy, onInspect }: Automation const key = dateKey(entry.startMs); entriesByDay.set(key, [...(entriesByDay.get(key) ?? []), entry]); }); - const visibleJobIds = new Set(visibleEntries.map((entry) => entry.job.id)); - const outsideJobs = jobs.filter((job) => !visibleJobIds.has(job.id)); const monthLabel = new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(month); const weekdayFormatter = new Intl.DateTimeFormat(locale, { weekday: "short" }); const dayFormatter = new Intl.DateTimeFormat(locale, { day: "numeric" }); const agendaDateFormatter = new Intl.DateTimeFormat(locale, { month: "short", day: "numeric", weekday: "short" }); const weekdayLabels = Array.from({ length: 7 }, (_, index) => weekdayFormatter.format(addDays(new Date(2026, 0, 5), index))); - const inspectOutsideJob = (job: SessionAutomationJob, target: HTMLElement) => onInspect(job, target); - useLayoutEffect(() => { const calendar = calendarRef.current; if (!calendar) return; @@ -214,52 +276,50 @@ export function AutomationCalendar({ jobs, locale, copy, onInspect }: Automation }, []); return ( -
-
-

{monthLabel}

-
- - - +
+
+
+

{monthLabel}

+ {filters ?
{filters}
: null} +
+ + + +
+ + {wideCalendar ?
+ {weekdayLabels.map((label) =>
{label}
)} +
: null}
- {!jobs.length ? ( -
- {copy.noEntries} -
- ) : null} - - {jobs.length > 0 && wideCalendar ?
-
- {weekdayLabels.map((label) =>
{label}
)} -
+ {wideCalendar ?
{days.map((day) => { const entries = entriesByDay.get(dateKey(day)) ?? []; @@ -295,25 +355,13 @@ export function AutomationCalendar({ jobs, locale, copy, onInspect }: Automation /> ))} {entries.length > 3 ? ( -
- - {copy.more(entries.length - 3)} - -
- {entries.slice(3).map((entry) => ( - - ))} -
-
+ ) : null}
@@ -322,7 +370,7 @@ export function AutomationCalendar({ jobs, locale, copy, onInspect }: Automation
: null} - {jobs.length > 0 && !wideCalendar ?
+ {!wideCalendar ?
{visibleEntries.length ? (
    {days.filter((day) => entriesByDay.has(dateKey(day))).map((day) => ( @@ -363,47 +411,6 @@ export function AutomationCalendar({ jobs, locale, copy, onInspect }: Automation
) : null} - {outsideJobs.length ? ( -
- - - - {copy.outsideMonth} - {outsideJobs.length} - - - -
    - {outsideJobs.map((job) => ( -
  • - -
  • - ))} -
-
- ) : null}
); } diff --git a/webui/src/components/settings/system/AutomationsSettings.tsx b/webui/src/components/settings/system/AutomationsSettings.tsx index c8b34cafa..e27288c31 100644 --- a/webui/src/components/settings/system/AutomationsSettings.tsx +++ b/webui/src/components/settings/system/AutomationsSettings.tsx @@ -2,21 +2,18 @@ import { useEffect, useId, useMemo, useRef, useState } from "react"; import type { FormEvent, ReactNode } from "react"; import type { TFunction } from "i18next"; import { - ArrowUpDown, Check, ChevronDown, - ChevronRight, CircleAlert, Clipboard, Loader2, - Search, } from "lucide-react"; import { useTranslation } from "react-i18next"; import { channelTranslator } from "@/channel-plugins/i18n"; import { channelUiOwner, channelUiPresentation } from "@/channel-plugins/registry"; import { AutomationCalendar } from "@/components/settings/system/AutomationCalendar"; -import { SETTINGS_SEARCH_INPUT_CLASS, SettingsGroup } from "@/components/settings/shared/SettingsControls"; +import { SettingsGroup } from "@/components/settings/shared/SettingsControls"; import { modelPresetOptionsFromSettings, toModelBadgeInfo, @@ -33,12 +30,6 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; import { formControlFocusClassName } from "@/components/ui/form-control"; import { Input } from "@/components/ui/input"; import { SegmentedControl } from "@/components/ui/segmented-control"; @@ -56,17 +47,16 @@ import type { import { cn } from "@/lib/utils"; export type AutomationFilter = "all" | "active" | "paused" | "failed" | "system"; -export type AutomationSort = "next" | "last" | "updated" | "name"; export type AutomationAction = "enable" | "disable" | "delete" | "run"; const EMPTY_TITLE_OVERRIDES: Record = {}; const SYSTEM_TASKS_OPEN_STORAGE_KEY = "nanobot-webui.automation-system-tasks-open"; export function AutomationsSettings({ - payload, loading, query, filter, sort, actionKey, error, + payload, loading, filter, actionKey, error, titleOverrides = EMPTY_TITLE_OVERRIDES, settingsSnapshot = null, - onQueryChange, onFilterChange, onSortChange, onAction, + onFilterChange, onAction, onRequestEdit, onRequestDelete, onStartChat, onManageModels, returnToDetailJob = null, onReturnToDetailHandled, }: { @@ -74,14 +64,10 @@ export function AutomationsSettings({ titleOverrides?: Record; settingsSnapshot?: SettingsPayload | null; loading: boolean; - query: string; filter: AutomationFilter; - sort: AutomationSort; actionKey: string | null; error: string | null; - onQueryChange: (value: string) => void; onFilterChange: (value: AutomationFilter) => void; - onSortChange: (value: AutomationSort) => void; onAction: (action: AutomationAction, job: SessionAutomationJob) => void | Promise; onRequestEdit: (job: SessionAutomationJob) => void; onRequestDelete: (job: SessionAutomationJob) => void; @@ -118,16 +104,13 @@ export function AutomationsSettings({ return true; } }); - const searchInput = useRef(null); const pageTitle = useRef(null); const selectedTrigger = useRef(null); const afterDetailClose = useRef<((job: SessionAutomationJob) => void) | null>(null); const filtered = useMemo(() => { - const searchTokens = parseAutomationSearchQuery(query); - return sortAutomationJobs(jobs, sort) - .filter((job) => automationMatchesFilter(job, filter)) - .filter((job) => !searchTokens.length || automationMatchesSearch(job, searchTokens)); - }, [filter, jobs, query, sort]); + return jobs + .filter((job) => automationMatchesFilter(job, filter)); + }, [filter, jobs]); const personalJobs = jobs.filter((job) => !job.protected); const personal = filtered.filter((job) => !job.protected); const system = filtered.filter((job) => job.protected); @@ -144,12 +127,6 @@ export function AutomationsSettings({ { value: "failed", label: tx("settings.automations.filters.failed", "Needs attention"), count: personalJobs.filter(automationNeedsAttention).length }, ]; - const sortLabel = { - next: tx("settings.automations.sort.next", "Next run"), - last: tx("settings.automations.sort.last", "Last run"), - updated: tx("settings.automations.sort.updated", "Updated"), - name: tx("settings.automations.sort.name", "Name"), - } satisfies Record; const configuredPresetNames = useMemo( () => new Set(settingsSnapshot?.model_presets?.map((preset) => preset.name) ?? []), [settingsSnapshot], @@ -178,10 +155,6 @@ export function AutomationsSettings({ else setDetailOpen(false); }, [liveSelectedJob]); - useEffect(() => { - if (query) setSystemOpen(true); - }, [query]); - useEffect(() => { if (!returnToDetailJob) return; const currentJob = jobs.find((job) => job.id === returnToDetailJob.id) ?? returnToDetailJob; @@ -248,9 +221,10 @@ export function AutomationsSettings({ inputAriaLabel={tx("settings.automations.createInput", "Describe an automation")} placeholder={tx( "settings.automations.createPrompt", - "Describe an automation, for example: summarize project updates every weekday at 9:00", + "What would you like nanobot to schedule?", )} variant="thread" + compactWhenIdle modelLabel={modelBadgeLabel} modelDetail={modelBadge.model} modelPreset={activeModelPreset} @@ -265,74 +239,30 @@ export function AutomationsSettings({ ) : null} - {jobs.length ? ( -
-
- - onQueryChange(event.target.value)} - aria-label={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} - placeholder={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} - className={cn("h-10 ps-11 text-[13px]", SETTINGS_SEARCH_INPUT_CLASS)} - /> -
-
- ({ - value: option.value, - label: <>{option.label} {option.count}, - }))} - onChange={onFilterChange} - /> -
- - - - - - {(Object.keys(sortLabel) as AutomationSort[]).map((value) => ( - onSortChange(value)}> - {sortLabel[value]} - {sort === value ? : null} - - ))} - - -
- ) : null} - {error ? : null} {loading && !payload ? (
{tx("settings.automations.loading", "Loading automations...")}
- ) : payload && jobs.length && !filtered.length ? ( -
- {tx("settings.automations.noMatches", "No automations match this view.")} - -
) : ( + ({ + value: option.value, + label: <>{option.label} {option.count}, + }))} + onChange={onFilterChange} + /> + + ) : null} copy={{ previousMonth: tx("settings.automations.calendar.previousMonth", "Previous month"), nextMonth: tx("settings.automations.calendar.nextMonth", "Next month"), @@ -342,14 +272,12 @@ export function AutomationsSettings({ running: tx("settings.automations.status.running", "Running"), failed: tx("settings.automations.status.failed", "Failed"), more: (count) => tx("settings.automations.calendar.more", "+{{count}} more", { count }), + close: tx("common.close", "Close"), noEntries: personal.length ? tx("settings.automations.calendar.noEntries", "No runs in this month.") : personalJobs.length ? tx("settings.automations.noMatches", "No automations match this view.") : tx("settings.automations.empty", "No automations yet."), - outsideMonth: tx("settings.automations.calendar.outsideMonth", "Without a date in this month"), - paused: tx("settings.automations.filters.paused", "Paused"), - attention: tx("settings.automations.filters.failed", "Needs attention"), completed: tx("settings.automations.status.completed", "Completed"), }} onInspect={inspectJob} @@ -412,7 +340,7 @@ export function AutomationsSettings({ if (detailOpen) return; setInspectedJob(null); const target = selectedTrigger.current?.isConnected - ? selectedTrigger.current : searchInput.current ?? pageTitle.current; + ? selectedTrigger.current : pageTitle.current; target?.focus({ preventScroll: true }); const next = afterDetailClose.current; afterDetailClose.current = null; @@ -452,7 +380,6 @@ export function AutomationDetailDialog({ onOpenChange(false)} onAction={onAction} onRequestEdit={onRequestEdit} onRequestDelete={onRequestDelete} @@ -525,13 +451,12 @@ function AutomationListItem({ job, locale, disabled, onSelect }: { } function AutomationDetailPanel({ - job, locale, actionKey, error, onClose, onAction, onRequestEdit, onRequestDelete, + job, locale, actionKey, error, onAction, onRequestEdit, onRequestDelete, }: { job: SessionAutomationJob; locale: string; actionKey: string | null; error: string | null; - onClose: () => void; onAction: (action: AutomationAction, job: SessionAutomationJob) => void | Promise; onRequestEdit: (job: SessionAutomationJob) => void; onRequestDelete: (job: SessionAutomationJob) => void; @@ -564,19 +489,16 @@ function AutomationDetailPanel({ return ( <> - -
- {job.name || job.id} - -
+ + {job.name || job.id} {canManage ? ( - - {formatAutomationSchedule(job, locale, tx)} - {timezone ? {timezone} : null} - - {formatAutomationNext(job, tx)} + + {formatAutomationSchedule(job, locale, tx)} + + {tx("settings.automations.labels.next", "Next")} + + {formatAutomationNext(job, tx)} + ) : null} @@ -633,17 +555,12 @@ function AutomationDetailPanel({ {!job.protected ? ( - {originHref ? ( - - {origin} - - - ) : origin} + {origin} ) : null} {tx("settings.automations.moreDetails", "More details")} @@ -651,6 +568,11 @@ function AutomationDetailPanel({ } >
+ {timezone && canManage ? ( + + {timezone} + + ) : null} {job.delete_after_run ? {tx("settings.automations.oneShotHint", "Removed after running")} : null} {job.created_at_ms ? {fmtDateTime(job.created_at_ms, locale)} : null} {job.updated_at_ms ? {fmtDateTime(job.updated_at_ms, locale)} : null} @@ -659,27 +581,29 @@ function AutomationDetailPanel({ {canManage ? ( -
- - {!localTrigger ? ( - - ) : null} - -
+ {!localTrigger ? ( + + ) : null} + +
+
@@ -723,7 +647,7 @@ function automationMessageNeedsExpansion(message: string): boolean { function AutomationDetail({ label, title, children }: { label: string; title?: string; children: ReactNode }) { return ( -
+
{label}
{children}
@@ -1077,23 +1001,6 @@ function automationStatusKey( return "active"; } -function sortAutomationJobs(jobs: SessionAutomationJob[], sort: AutomationSort): SessionAutomationJob[] { - const byName = (left: SessionAutomationJob, right: SessionAutomationJob) => - (left.name || left.id).localeCompare(right.name || right.id); - return [...jobs].sort((left, right) => { - if (sort === "name") return byName(left, right); - if (sort === "last") { - return (right.state.last_run_at_ms ?? 0) - (left.state.last_run_at_ms ?? 0) || byName(left, right); - } - if (sort === "updated") { - return (right.updated_at_ms ?? 0) - (left.updated_at_ms ?? 0) || byName(left, right); - } - const leftNext = left.state.next_run_at_ms ?? Number.MAX_SAFE_INTEGER; - const rightNext = right.state.next_run_at_ms ?? Number.MAX_SAFE_INTEGER; - return leftNext - rightNext || byName(left, right); - }); -} - function automationDraftFromJob(job: SessionAutomationJob | null): AutomationEditDraft { const every = automationIntervalDraft(job?.schedule.every_ms ?? 3_600_000); const scheduleKind = job?.schedule.kind === "at" || job?.schedule.kind === "cron" @@ -1209,148 +1116,11 @@ function automationScheduleChanged( return draft.atLocal !== formatLocalDateTimeInput(job.schedule.at_ms ?? NaN); } -type AutomationSearchField = "id" | "name" | "message" | "chat" | "cron" | "schedule" | "status"; - -interface AutomationSearchToken { - field: AutomationSearchField | null; - value: string; -} - -const AUTOMATION_SEARCH_FIELDS = new Set([ - "id", - "name", - "message", - "chat", - "cron", - "schedule", - "status", -]); - const HOST_AUTOMATION_CHANNEL_LABELS: Record = { api: "API", cli: "CLI", }; -function parseAutomationSearchQuery(query: string): AutomationSearchToken[] { - return (query.match(/[^\s:]+:"[^"]+"|"[^"]+"|\S+/g) ?? []) - .map((rawPart): AutomationSearchToken | null => { - const part = trimAutomationSearchValue(rawPart); - if (!part) return null; - const fieldMatch = part.match(/^([A-Za-z]+):(.*)$/); - if (!fieldMatch) return { field: null, value: part.toLowerCase() }; - const field = fieldMatch[1].toLowerCase() as AutomationSearchField; - const value = trimAutomationSearchValue(fieldMatch[2]).toLowerCase(); - if (!value) return null; - return AUTOMATION_SEARCH_FIELDS.has(field) - ? { field, value } - : { field: null, value: part.toLowerCase() }; - }) - .filter((token): token is AutomationSearchToken => Boolean(token)); -} - -function trimAutomationSearchValue(value: string): string { - return value.trim().replace(/^"|"$/g, "").trim(); -} - -function automationMatchesSearch(job: SessionAutomationJob, tokens: AutomationSearchToken[]): boolean { - return tokens.every((token) => automationSearchText(job, token.field).includes(token.value)); -} - -function automationSearchText(job: SessionAutomationJob, field: AutomationSearchField | null = null): string { - return automationSearchParts(job, field) - .filter(Boolean) - .join(" ") - .toLowerCase(); -} - -function automationSearchParts( - job: SessionAutomationJob, - field: AutomationSearchField | null, -): Array { - const originParts = automationOriginSearchParts(job); - const scheduleParts = automationScheduleSearchParts(job); - if (field === "id") return [job.id]; - if (field === "name") return [job.name, job.id]; - if (field === "message") return [job.payload.message, job.payload.command, job.trigger?.command]; - if (field === "chat") return originParts; - if (field === "cron" || field === "schedule") return scheduleParts; - if (field === "status") return [automationStatusKey(job), job.enabled ? "enabled" : "disabled"]; - return [ - job.id, - job.name, - job.payload.message, - job.payload.command, - job.trigger?.command, - isLocalTriggerAutomation(job) ? "trigger local" : null, - ...scheduleParts, - automationStatusKey(job), - ...originParts, - ]; -} - -function automationOriginSearchParts(job: SessionAutomationJob): Array { - const origin = job.origin; - if (!origin) return []; - const channel = origin.channel.trim().toLowerCase(); - return [ - origin.session_key, - origin.title, - origin.preview, - origin.channel, - automationChannelDisplayName(channel), - ]; -} - -function automationScheduleSearchParts(job: SessionAutomationJob): Array { - const schedule = job.schedule; - const parts: Array = [ - schedule.kind, - schedule.expr, - schedule.tz, - schedule.every_ms, - schedule.at_ms, - ]; - if (schedule.kind === "cron" && schedule.expr) { - parts.push(...automationCronSearchParts(schedule.expr)); - } - return parts; -} - -function automationCronSearchParts(expr: string): string[] { - const parts = expr.trim().split(/\s+/); - if (parts.length !== 5) return []; - const [minute, hour, dayOfMonth, month, dayOfWeek] = parts; - const everyDay = dayOfMonth === "*" && month === "*" && dayOfWeek === "*"; - const numericMinute = cronNumericToken(minute, 59); - const numericHour = cronNumericToken(hour, 23); - if (numericMinute === null) return []; - const paddedMinute = String(numericMinute).padStart(2, "0"); - - if (numericHour !== null) { - const time = `${String(numericHour).padStart(2, "0")}:${paddedMinute}`; - return [time, `:${paddedMinute}`]; - } - - if (everyDay && hour === "*") { - return [`:${paddedMinute}`, `hourly at :${paddedMinute}`]; - } - - const range = /^(\d{1,2})-(\d{1,2})$/.exec(hour); - if (!everyDay || !range) return []; - const start = Number(range[1]); - const end = Number(range[2]); - if (start > 23 || end > 23) return []; - const paddedRange = `${String(start).padStart(2, "0")}-${String(end).padStart(2, "0")}`; - const rawRange = `${start}-${end}`; - return [ - paddedRange, - rawRange, - `:${paddedMinute}`, - `${paddedRange} at :${paddedMinute}`, - `hourly ${paddedRange} at :${paddedMinute}`, - ]; -} - function automationMatchesFilter(job: SessionAutomationJob, filter: AutomationFilter): boolean { const status = automationStatusKey(job); if (filter === "active") return status === "active" || status === "running"; @@ -1387,11 +1157,6 @@ function automationChannelLabel( : channel; } -function automationChannelDisplayName(channel: string): string | undefined { - const key = channel.trim().toLowerCase(); - return channelUiPresentation(key)?.displayName ?? HOST_AUTOMATION_CHANNEL_LABELS[key]; -} - function formatAutomationSchedule( job: SessionAutomationJob, locale: string, diff --git a/webui/src/components/settings/system/useSystemSettingsState.ts b/webui/src/components/settings/system/useSystemSettingsState.ts index 2add8f17e..fe79f9217 100644 --- a/webui/src/components/settings/system/useSystemSettingsState.ts +++ b/webui/src/components/settings/system/useSystemSettingsState.ts @@ -1,9 +1,6 @@ import { useRef, useState } from "react"; -import type { - AutomationFilter, - AutomationSort, -} from "@/components/settings/system/AutomationsSettings"; +import type { AutomationFilter } from "@/components/settings/system/AutomationsSettings"; import { DEFAULT_CUSTOM_MCP_FORM, type AppsKindFilter, @@ -53,9 +50,7 @@ export function useSystemSettingsState() { const [apiServiceAction, setApiServiceAction] = useState<"start" | "stop" | null>(null); const [apiServiceError, setApiServiceError] = useState(null); const [appsQuery, setAppsQuery] = useState(""); - const [automationsQuery, setAutomationsQuery] = useState(""); const [automationsFilter, setAutomationsFilter] = useState("all"); - const [automationsSort, setAutomationsSort] = useState("next"); const [cliAppsMessage, setCliAppsMessage] = useState(null); const [cliAppsError, setCliAppsError] = useState(null); const [nanobotFeaturesError, setNanobotFeaturesError] = useState(null); @@ -87,8 +82,6 @@ export function useSystemSettingsState() { automationsError, automationsFilter, automationsLoading, - automationsQuery, - automationsSort, cliApps, cliAppsAction, cliAppsError, @@ -130,8 +123,6 @@ export function useSystemSettingsState() { setAutomationsError, setAutomationsFilter, setAutomationsLoading, - setAutomationsQuery, - setAutomationsSort, setCliApps, setCliAppsAction, setCliAppsError, diff --git a/webui/src/components/settings/useSettingsController.ts b/webui/src/components/settings/useSettingsController.ts index ac05b4974..19cbdf536 100644 --- a/webui/src/components/settings/useSettingsController.ts +++ b/webui/src/components/settings/useSettingsController.ts @@ -116,7 +116,7 @@ export function useSettingsController({ const { apiService, apiServiceAction, apiServiceError, apiServiceLoading, appsKindFilter, appsQuery, automationAction, automationPendingDelete, automationPendingEdit, automations, - automationsError, automationsFilter, automationsLoading, automationsQuery, automationsSort, + automationsError, automationsFilter, automationsLoading, cliApps, cliAppsAction, cliAppsError, cliAppsFocusName, cliAppsLoading, cliAppsMessage, customMcpForm, mcpConfigImport, mcpError, mcpFieldValues, mcpMessage, mcpOAuthCallbackError, mcpOAuthCallbackUrl, mcpOAuthCompleting, mcpOAuthFlow, @@ -124,7 +124,6 @@ export function useSettingsController({ nanobotFeatureConfirm, nanobotFeatures, nanobotFeaturesError, nanobotFeaturesLoading, setAppsKindFilter, setAppsQuery, setAutomationPendingDelete, setAutomationPendingEdit, setAutomationsFilter, - setAutomationsQuery, setAutomationsSort, setCliAppsError, setCliAppsMessage, setCustomMcpForm, setMcpConfigImport, setMcpError, setMcpFieldValues, setMcpMessage, setMcpOAuthCallbackError, setMcpOAuthCallbackUrl, @@ -481,8 +480,6 @@ export function useSettingsController({ automationsError, automationsFilter, automationsLoading, - automationsQuery, - automationsSort, beginModelPresetCreation, cancelModelPresetCreation, changeModelCallOrder, @@ -579,8 +576,6 @@ export function useSettingsController({ setAutomationPendingDelete, setAutomationPendingEdit, setAutomationsFilter, - setAutomationsQuery, - setAutomationsSort, setCliAppsError, setCliAppsMessage, setCustomMcpForm, diff --git a/webui/src/components/thread/ThreadComposer.tsx b/webui/src/components/thread/ThreadComposer.tsx index d2cfa2039..70d25a6b3 100644 --- a/webui/src/components/thread/ThreadComposer.tsx +++ b/webui/src/components/thread/ThreadComposer.tsx @@ -194,6 +194,7 @@ interface ThreadComposerProps { disabled?: boolean; placeholder?: string; inputAriaLabel?: string; + compactWhenIdle?: boolean; isStreaming?: boolean; modelLabel?: string | null; modelDetail?: string | null; @@ -895,6 +896,7 @@ export function ThreadComposer({ disabled, placeholder, inputAriaLabel, + compactWhenIdle = false, isStreaming = false, modelLabel = null, modelDetail = null, @@ -936,6 +938,8 @@ export function ThreadComposer({ }: ThreadComposerProps) { const { t } = useTranslation(); const [value, setValue] = useState(""); + const [composerFocused, setComposerFocused] = useState(false); + const blurFrame = useRef(null); const [selectedSessionMentions, setSelectedSessionMentions] = useState([]); const [sessionDragPreview, setSessionDragPreview] = useState<{ mention: SessionMention; @@ -1058,14 +1062,18 @@ export function ThreadComposer({ } = useClipboardAndDrop(addFiles); useEffect(() => { - if (interactionDisabled || hasTouchPrimaryPointer || (workspaceError && showProjectPicker)) { + if (compactWhenIdle || interactionDisabled || hasTouchPrimaryPointer || (workspaceError && showProjectPicker)) { return; } const el = textareaRef.current; if (!el) return; const id = requestAnimationFrame(() => el.focus()); return () => cancelAnimationFrame(id); - }, [hasTouchPrimaryPointer, interactionDisabled, showProjectPicker, workspaceError]); + }, [compactWhenIdle, hasTouchPrimaryPointer, interactionDisabled, showProjectPicker, workspaceError]); + + useEffect(() => () => { + if (blurFrame.current !== null) cancelAnimationFrame(blurFrame.current); + }, []); useEffect(() => { if (!focusRequest || interactionDisabled) return; @@ -2188,6 +2196,10 @@ export function ThreadComposer({ : t("thread.composer.voice.hint"); const showStopButton = isStreaming && !!onStop; const relaxedHeroInput = isHero && images.length === 0 && !isStreaming; + const compactIdle = compactWhenIdle && !isHero && !composerFocused + && value.length === 0 && images.length === 0 && !inlineError + && !normalizedQuotedContext && !queuedPrompts.length && !goalState?.active + && !isDragging && !sessionDragPreview && !voiceRecorder.isRecording && !showProjectPicker; const inputTextClasses = cn( "w-full resize-none bg-transparent", isHero @@ -2201,6 +2213,20 @@ export function ThreadComposer({ return (
{ + if (!compactWhenIdle) return; + // Portaled model controls belong to this composer too: keep its layout + // stable while moving between the input, toolbar, and model picker. + if (blurFrame.current !== null) cancelAnimationFrame(blurFrame.current); + }} + onBlurCapture={() => { + if (!compactWhenIdle) return; + if (blurFrame.current !== null) cancelAnimationFrame(blurFrame.current); + blurFrame.current = requestAnimationFrame(() => { + blurFrame.current = null; + setComposerFocused(false); + }); + }} onSubmit={(e) => { e.preventDefault(); submit(); @@ -2224,7 +2250,11 @@ export function ThreadComposer({ onDrop={(event) => { if (!handleSessionDrop(event)) onDrop(event); }} - className={cn("relative w-full", isHero ? "px-0" : "px-1 pb-1.5 pt-1 sm:px-0")} + className={cn( + "relative w-full", + isHero ? "px-0" : "px-1 pb-1.5 pt-1 sm:px-0", + compactWhenIdle && "thread-composer-collapsible-layout", + )} > {showSlashMenu ? ( ) : null} -
+
{hasMentionDecorations ? ( { + if (compactWhenIdle) setComposerFocused(true); + }} onChange={(e) => { secondEnterPromptIdRef.current = null; setValue(e.target.value); diff --git a/webui/src/globals.css b/webui/src/globals.css index 3830a6291..8c273b451 100644 --- a/webui/src/globals.css +++ b/webui/src/globals.css @@ -1031,6 +1031,71 @@ .automation-create-composer .thread-composer-surface { max-inline-size: none; } + .automation-calendar-toolbar { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + align-items: center; + gap: 0.75rem 1rem; + min-block-size: 4rem; + padding: 1rem; + } + .automation-calendar-navigation { + grid-column: 2; + grid-row: 1; + justify-self: end; + } + .automation-calendar-filters { + grid-column: 1 / -1; + grid-row: 2; + } + @container automations (max-width: 20rem) { + .automation-calendar-filters .segmented-control { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + inline-size: 100%; + border-radius: 1rem; + } + } + @container automations (min-width: 48rem) { + .automation-calendar-toolbar { + grid-template-columns: minmax(0, 1fr) auto auto; + padding-inline: 1.5rem; + } + .automation-calendar-filters { + grid-column: 2; + grid-row: 1; + } + .automation-calendar-navigation { grid-column: 3; } + } + .thread-composer-collapsible-layout { + container: composer-layout / inline-size; + } + @container composer-layout (min-width: 40rem) { + .thread-composer-collapsible[data-compact] { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + align-items: center; + } + .thread-composer-collapsible[data-compact] .thread-composer-input textarea { + display: block; + block-size: 3.5rem !important; + min-block-size: 3.5rem; + padding-block: 1.125rem; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .thread-composer-collapsible[data-compact] .thread-composer-footer { + padding: 0.5rem; + transition: none; + } + .thread-composer-collapsible[data-compact] .thread-composer-footer-primary { + flex: none; + } + .thread-composer-collapsible[data-compact] .thread-composer-footer-actions { + max-inline-size: none; + } + } .automation-meta-row { display: grid; grid-template-columns: 1rem minmax(0, 1fr) auto; @@ -1050,7 +1115,6 @@ .automation-calendar-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); - border-block-end: 1px solid hsl(var(--border) / 0.6); } .automation-calendar-weekdays > div { padding: 8px 10px; diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json index 78a3c3cb2..d5641f438 100644 --- a/webui/src/i18n/locales/en/common.json +++ b/webui/src/i18n/locales/en/common.json @@ -1088,9 +1088,8 @@ "notEnabled": "Not enabled" }, "automations": { - "viewOptions": "Search and filter", "create": "Create automation", - "createPrompt": "Describe an automation, for example: summarize project updates every weekday at 9:00", + "createPrompt": "What would you like nanobot to schedule?", "createInput": "Describe an automation", "createRequest": "Create an automation for this request:\n\n{{request}}", "errors": { @@ -1103,8 +1102,8 @@ "planned": "Planned", "recorded": "Recorded", "more": "+{{count}} more", - "noEntries": "No runs in this month.", - "outsideMonth": "Without a date in this month" + "less": "Show less", + "noEntries": "No runs in this month." }, "yourTasks": "Your automations", "systemTasks": "System tasks", @@ -1128,7 +1127,6 @@ "updated": "Updated", "name": "Name" }, - "search": "Search task, message, linked chat, or schedule", "queue": "Queue", "loading": "Loading automations...", "noMatches": "No automations match this view.", diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json index 66a812119..67f9f10d3 100644 --- a/webui/src/i18n/locales/es/common.json +++ b/webui/src/i18n/locales/es/common.json @@ -889,9 +889,8 @@ "notEnabled": "No activado" }, "automations": { - "viewOptions": "Buscar y filtrar", "create": "Crear automatización", - "createPrompt": "Describe una automatización, por ejemplo: resume las novedades del proyecto cada día laborable a las 9:00", + "createPrompt": "¿Qué te gustaría programar con nanobot?", "createInput": "Describe una automatización", "createRequest": "Crea una automatización para esta solicitud:\n\n{{request}}", "errors": { @@ -904,8 +903,8 @@ "planned": "Planificado", "recorded": "Registrado", "more": "+{{count}} más", - "noEntries": "No hay ejecuciones este mes.", - "outsideMonth": "Sin fecha en este mes" + "less": "Mostrar menos", + "noEntries": "No hay ejecuciones este mes." }, "yourTasks": "Tus automatizaciones", "systemTasks": "Tareas del sistema", @@ -929,7 +928,6 @@ "updated": "Actualizada", "name": "Nombre" }, - "search": "Buscar tarea, mensaje, chat vinculado u horario", "queue": "Cola", "loading": "Cargando automatizaciones...", "noMatches": "No hay automatizaciones que coincidan con esta vista.", diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json index 3e046c5bb..582c60d30 100644 --- a/webui/src/i18n/locales/fr/common.json +++ b/webui/src/i18n/locales/fr/common.json @@ -888,9 +888,8 @@ "notEnabled": "Non activé" }, "automations": { - "viewOptions": "Rechercher et filtrer", "create": "Créer une automatisation", - "createPrompt": "Décrivez une automatisation, par exemple : résumer l’avancement du projet chaque jour ouvré à 9 h", + "createPrompt": "Que voulez-vous planifier avec nanobot ?", "createInput": "Décrire une automatisation", "createRequest": "Crée une automatisation pour cette demande :\n\n{{request}}", "errors": { @@ -903,8 +902,8 @@ "planned": "Planifié", "recorded": "Enregistré", "more": "+{{count}} de plus", - "noEntries": "Aucune exécution ce mois-ci.", - "outsideMonth": "Sans date ce mois-ci" + "less": "Afficher moins", + "noEntries": "Aucune exécution ce mois-ci." }, "yourTasks": "Vos automatisations", "systemTasks": "Tâches système", @@ -928,7 +927,6 @@ "updated": "Mise à jour", "name": "Nom" }, - "search": "Rechercher tâche, message, discussion liée ou planning", "queue": "File", "loading": "Chargement des automatisations...", "noMatches": "Aucune automatisation ne correspond à cette vue.", diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json index 168813123..bae5d789a 100644 --- a/webui/src/i18n/locales/id/common.json +++ b/webui/src/i18n/locales/id/common.json @@ -888,9 +888,8 @@ "notEnabled": "Belum aktif" }, "automations": { - "viewOptions": "Cari dan filter", "create": "Buat otomatisasi", - "createPrompt": "Jelaskan otomatisasi, misalnya: rangkum perkembangan proyek setiap hari kerja pukul 09.00", + "createPrompt": "Apa yang ingin kamu jadwalkan dengan nanobot?", "createInput": "Jelaskan otomatisasi", "createRequest": "Buat otomatisasi untuk permintaan ini:\n\n{{request}}", "errors": { @@ -903,8 +902,8 @@ "planned": "Terjadwal", "recorded": "Tercatat", "more": "+{{count}} lainnya", - "noEntries": "Tidak ada eksekusi bulan ini.", - "outsideMonth": "Tanpa tanggal di bulan ini" + "less": "Tampilkan lebih sedikit", + "noEntries": "Tidak ada eksekusi bulan ini." }, "yourTasks": "Otomatisasi Anda", "systemTasks": "Tugas sistem", @@ -928,7 +927,6 @@ "updated": "Diperbarui", "name": "Nama" }, - "search": "Cari tugas, pesan, chat terkait, atau jadwal", "queue": "Antrean", "loading": "Memuat otomasi...", "noMatches": "Tidak ada otomasi yang cocok dengan tampilan ini.", diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json index aba5e5a80..0ea25474a 100644 --- a/webui/src/i18n/locales/ja/common.json +++ b/webui/src/i18n/locales/ja/common.json @@ -888,9 +888,8 @@ "notEnabled": "無効" }, "automations": { - "viewOptions": "検索と絞り込み", "create": "自動タスクを作成", - "createPrompt": "作成する自動タスクを説明してください。例:平日の9時にプロジェクトの進捗を要約", + "createPrompt": "nanobot にいつ、何をしてほしいですか?", "createInput": "自動タスクを説明", "createRequest": "次の依頼に対する自動タスクを作成してください:\n\n{{request}}", "errors": { @@ -903,8 +902,8 @@ "planned": "予定", "recorded": "実績", "more": "ほか{{count}}件", - "noEntries": "今月の実行はありません。", - "outsideMonth": "今月の日付なし" + "less": "折りたたむ", + "noEntries": "今月の実行はありません。" }, "yourTasks": "自分の自動化", "systemTasks": "システムタスク", @@ -928,7 +927,6 @@ "updated": "更新日時", "name": "名前" }, - "search": "タスク、メッセージ、関連チャット、予定を検索", "queue": "キュー", "loading": "自動タスクを読み込み中...", "noMatches": "この表示に一致する自動タスクはありません。", diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json index e512e3153..023ff2d8a 100644 --- a/webui/src/i18n/locales/ko/common.json +++ b/webui/src/i18n/locales/ko/common.json @@ -888,9 +888,8 @@ "notEnabled": "비활성화됨" }, "automations": { - "viewOptions": "검색 및 필터", "create": "자동화 만들기", - "createPrompt": "만들 자동화를 설명하세요. 예: 평일 오전 9시에 프로젝트 진행 상황 요약", + "createPrompt": "nanobot이 언제 무엇을 해주면 좋을까요?", "createInput": "자동화 설명", "createRequest": "다음 요청에 맞는 자동화를 만들어 주세요:\n\n{{request}}", "errors": { @@ -903,8 +902,8 @@ "planned": "예정", "recorded": "기록", "more": "+{{count}}개 더", - "noEntries": "이번 달 실행 기록이 없습니다.", - "outsideMonth": "이번 달 날짜 없음" + "less": "접기", + "noEntries": "이번 달 실행 기록이 없습니다." }, "yourTasks": "내 자동화", "systemTasks": "시스템 작업", @@ -928,7 +927,6 @@ "updated": "업데이트", "name": "이름" }, - "search": "작업, 메시지, 연결된 채팅 또는 일정 검색", "queue": "대기열", "loading": "자동화를 불러오는 중...", "noMatches": "이 보기와 일치하는 자동화가 없습니다.", diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json index f8e6c28a9..04134cb94 100644 --- a/webui/src/i18n/locales/pt-BR/common.json +++ b/webui/src/i18n/locales/pt-BR/common.json @@ -902,9 +902,8 @@ "notEnabled": "Não habilitado" }, "automations": { - "viewOptions": "Buscar e filtrar", "create": "Criar automação", - "createPrompt": "Descreva uma automação, por exemplo: resumir o andamento do projeto todo dia útil às 9:00", + "createPrompt": "O que você gostaria de agendar com o nanobot?", "createInput": "Descreva uma automação", "createRequest": "Crie uma automação para esta solicitação:\n\n{{request}}", "errors": { @@ -917,8 +916,8 @@ "planned": "Planejado", "recorded": "Registrado", "more": "+{{count}} mais", - "noEntries": "Nenhuma execução neste mês.", - "outsideMonth": "Sem data neste mês" + "less": "Mostrar menos", + "noEntries": "Nenhuma execução neste mês." }, "yourTasks": "Suas automações", "systemTasks": "Tarefas do sistema", @@ -942,7 +941,6 @@ "updated": "Atualizada", "name": "Nome" }, - "search": "Buscar tarefa, mensagem, conversa vinculada ou agendamento", "queue": "Fila", "loading": "Carregando automações...", "noMatches": "Nenhuma automação corresponde a esta visualização.", diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json index 291bfdb9f..09c0cfe9e 100644 --- a/webui/src/i18n/locales/vi/common.json +++ b/webui/src/i18n/locales/vi/common.json @@ -888,9 +888,8 @@ "notEnabled": "Chưa bật" }, "automations": { - "viewOptions": "Tìm kiếm và lọc", "create": "Tạo tự động hóa", - "createPrompt": "Mô tả tác vụ tự động, ví dụ: tóm tắt tiến độ dự án lúc 9:00 mỗi ngày làm việc", + "createPrompt": "Bạn muốn nanobot làm gì theo lịch?", "createInput": "Mô tả tác vụ tự động", "createRequest": "Tạo một tác vụ tự động cho yêu cầu này:\n\n{{request}}", "errors": { @@ -903,8 +902,8 @@ "planned": "Đã lên lịch", "recorded": "Đã ghi nhận", "more": "+{{count}} mục khác", - "noEntries": "Không có lần chạy nào trong tháng này.", - "outsideMonth": "Không có ngày trong tháng này" + "less": "Thu gọn", + "noEntries": "Không có lần chạy nào trong tháng này." }, "yourTasks": "Tác vụ tự động của bạn", "systemTasks": "Tác vụ hệ thống", @@ -928,7 +927,6 @@ "updated": "Đã cập nhật", "name": "Tên" }, - "search": "Tìm tác vụ, tin nhắn, cuộc trò chuyện liên kết hoặc lịch", "queue": "Hàng đợi", "loading": "Đang tải tự động hóa...", "noMatches": "Không có tự động hóa phù hợp với chế độ xem này.", diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json index 84dc19c4f..f7f56ba4f 100644 --- a/webui/src/i18n/locales/zh-CN/common.json +++ b/webui/src/i18n/locales/zh-CN/common.json @@ -1088,9 +1088,8 @@ "notEnabled": "未启用" }, "automations": { - "viewOptions": "搜索与筛选", "create": "创建自动任务", - "createPrompt": "描述要创建的自动任务,例如:每个工作日 9:00 汇总项目进展", + "createPrompt": "想让 nanobot 定时帮你做什么?", "createInput": "描述一个自动任务", "createRequest": "请为以下需求创建自动任务:\n\n{{request}}", "errors": { @@ -1103,8 +1102,8 @@ "planned": "计划运行", "recorded": "实际记录", "more": "还有 {{count}} 项", - "noEntries": "本月没有运行记录。", - "outsideMonth": "本月没有日期的任务" + "less": "收起", + "noEntries": "本月没有运行记录。" }, "yourTasks": "你的自动任务", "systemTasks": "系统任务", @@ -1128,7 +1127,6 @@ "updated": "更新时间", "name": "名称" }, - "search": "搜索任务、消息、关联会话或计划", "queue": "任务队列", "loading": "正在加载自动任务...", "noMatches": "当前视图没有匹配的自动任务。", diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json index d4bb451e3..fe2806e86 100644 --- a/webui/src/i18n/locales/zh-TW/common.json +++ b/webui/src/i18n/locales/zh-TW/common.json @@ -888,9 +888,8 @@ "notEnabled": "未啟用" }, "automations": { - "viewOptions": "搜尋與篩選", "create": "建立自動任務", - "createPrompt": "描述要建立的自動任務,例如:每個工作日 9:00 彙整專案進度", + "createPrompt": "想讓 nanobot 定時幫你做什麼?", "createInput": "描述自動任務", "createRequest": "請為以下需求建立自動任務:\n\n{{request}}", "errors": { @@ -903,8 +902,8 @@ "planned": "預定執行", "recorded": "實際記錄", "more": "另有 {{count}} 項", - "noEntries": "本月沒有執行記錄。", - "outsideMonth": "本月沒有日期的任務" + "less": "收合", + "noEntries": "本月沒有執行記錄。" }, "yourTasks": "你的自動任務", "systemTasks": "系統任務", @@ -928,7 +927,6 @@ "updated": "更新時間", "name": "名稱" }, - "search": "搜尋任務、訊息、關聯對話或排程", "queue": "任務佇列", "loading": "正在載入自動任務…", "noMatches": "目前沒有符合條件的自動任務。", diff --git a/webui/src/tests/app-layout.test.tsx b/webui/src/tests/app-layout.test.tsx index 30a234b7c..3253949ea 100644 --- a/webui/src/tests/app-layout.test.tsx +++ b/webui/src/tests/app-layout.test.tsx @@ -67,6 +67,11 @@ function mockFetchRoutes(routes: Record): void { ); } +function currentMonthTimestamp(day: number, hour = 10, minute = 0): number { + const now = new Date(); + return new Date(now.getFullYear(), now.getMonth(), day, hour, minute).getTime(); +} + function baseSettingsPayload() { return { agent: { @@ -1380,7 +1385,7 @@ describe("App layout", () => { kind: "agent_turn", }, state: { - next_run_at_ms: Date.UTC(2026, 3, 17, 10, 0, 0), + next_run_at_ms: currentMonthTimestamp(17), last_status: "ok", pending: false, run_history: [], @@ -1405,7 +1410,7 @@ describe("App layout", () => { kind: "agent_turn", }, state: { - next_run_at_ms: Date.UTC(2026, 3, 17, 11, 30, 0), + next_run_at_ms: currentMonthTimestamp(17, 11, 30), last_status: "ok", pending: false, run_history: [], @@ -1440,22 +1445,30 @@ describe("App layout", () => { fireEvent.click(automationsButton); - const heading = await screen.findByRole("heading", { name: "Automations" }); + const heading = await screen.findByRole( + "heading", + { name: "Automations" }, + { timeout: 5_000 }, + ); expect(heading).toBeInTheDocument(); const automationsMain = heading.closest("main"); expect(automationsMain).not.toBeNull(); expect(within(automationsMain as HTMLElement).queryByText("Settings")).not.toBeInTheDocument(); - expect(screen.getAllByText("Daily repo check").length).toBeGreaterThanOrEqual(1); + expect((await screen.findAllByText( + "Daily repo check", + {}, + { timeout: 5_000 }, + )).length).toBeGreaterThanOrEqual(1); expect(screen.queryByText("Check the repo status")).not.toBeInTheDocument(); expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: /Daily repo check/ })); expect(within(screen.getByRole("dialog", { name: "Daily repo check" })).getByText("Check the repo status")).toBeVisible(); expect(screen.getAllByText("Release prep").length).toBeGreaterThanOrEqual(1); - fireEvent.click(screen.getByRole("button", { name: "Done", exact: true })); + fireEvent.click(screen.getByRole("button", { name: "Close", exact: true })); expect(screen.getByText("WeChat quiz")).toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: /WeChat quiz/ })); expect(screen.getByText("WeChat")).toBeInTheDocument(); - fireEvent.click(screen.getByRole("button", { name: "Done", exact: true })); + fireEvent.click(screen.getByRole("button", { name: "Close", exact: true })); expect(screen.queryByText("weixin:wx-chat")).not.toBeInTheDocument(); expect(screen.queryByText("memory with dream state")).not.toBeInTheDocument(); expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible(); @@ -1467,16 +1480,6 @@ describe("App layout", () => { ); expect(document.title).toBe("Automations · nanobot"); - const searchInput = within(automationsMain as HTMLElement).getByPlaceholderText( - "Search task, message, linked chat, or schedule", - ); - fireEvent.change(searchInput, { target: { value: "WeChat" } }); - await waitFor(() => expect(screen.queryByText("Daily repo check")).not.toBeInTheDocument()); - expect(screen.getAllByText("WeChat quiz").length).toBeGreaterThanOrEqual(1); - - fireEvent.change(searchInput, { target: { value: "09-23" } }); - await waitFor(() => expect(screen.queryByText("Daily repo check")).not.toBeInTheDocument()); - expect(screen.getAllByText("WeChat quiz").length).toBeGreaterThanOrEqual(1); }); it("keeps automation linked-chat titles in sync with live sidebar renames", async () => { @@ -1498,7 +1501,8 @@ describe("App layout", () => { "/api/webui/automations": { jobs: [{ id: "reminder", name: "Drink water", enabled: true, schedule: { kind: "every", every_ms: 60_000 }, - payload: { message: "Take a break" }, state: {}, + payload: { message: "Take a break" }, + state: { next_run_at_ms: currentMonthTimestamp(17) }, origin: { session_key: key, channel: "websocket", chat_id: "linked-chat", title: "Stored title", preview: "Original preview" }, }] }, @@ -1509,7 +1513,8 @@ describe("App layout", () => { fireEvent.click(within(sidebar).getByRole("button", { name: "Automations" })); fireEvent.click(await screen.findByRole("button", { name: /Drink water/ })); const dialog = screen.getByRole("dialog", { name: "Drink water" }); - expect(within(dialog).getByRole("link", { name: "推特大战场" })).toHaveAttribute( + expect(within(dialog).getByText("推特大战场")).toBeVisible(); + expect(within(dialog).getByRole("link", { name: "Open a chat" })).toHaveAttribute( "href", "#/chat/websocket%3Alinked-chat", ); for (const title of ["新会话名称", ""]) { @@ -1520,9 +1525,7 @@ describe("App layout", () => { }); const expected = title || "Stored title"; expect(within(sidebar).getByText(expected)).toBeInTheDocument(); - expect(within(dialog).getByRole("link", { name: expected })).toHaveAttribute( - "href", "#/chat/websocket%3Alinked-chat", - ); + expect(within(dialog).getByText(expected)).toBeVisible(); } expect(requestMutationSpy).not.toHaveBeenCalled(); }); @@ -1541,6 +1544,7 @@ describe("App layout", () => { }, state: { next_run_at_ms: null, + last_run_at_ms: currentMonthTimestamp(12), last_status: "ok", pending: false, run_history: [], @@ -1613,12 +1617,12 @@ describe("App layout", () => { "The full content should remain available without forcing the user into a small nested scroll area.", ].join("\n"); const history = [ - { run_at_ms: Date.UTC(2026, 3, 12, 10, 0, 0), status: "error", duration_ms: 900, error: "oldest failure" }, - { run_at_ms: Date.UTC(2026, 3, 13, 10, 0, 0), status: "error", duration_ms: 800, error: "second oldest failure" }, - { run_at_ms: Date.UTC(2026, 3, 14, 10, 0, 0), status: "ok", duration_ms: 700 }, - { run_at_ms: Date.UTC(2026, 3, 15, 10, 0, 0), status: "ok", duration_ms: 600 }, - { run_at_ms: Date.UTC(2026, 3, 16, 10, 0, 0), status: "ok", duration_ms: 500 }, - { run_at_ms: Date.UTC(2026, 3, 17, 10, 0, 0), status: "ok", duration_ms: 400 }, + { run_at_ms: currentMonthTimestamp(12), status: "error", duration_ms: 900, error: "oldest failure" }, + { run_at_ms: currentMonthTimestamp(13), status: "error", duration_ms: 800, error: "second oldest failure" }, + { run_at_ms: currentMonthTimestamp(14), status: "ok", duration_ms: 700 }, + { run_at_ms: currentMonthTimestamp(15), status: "ok", duration_ms: 600 }, + { run_at_ms: currentMonthTimestamp(16), status: "ok", duration_ms: 500 }, + { run_at_ms: currentMonthTimestamp(17), status: "ok", duration_ms: 400 }, ]; mockFetchRoutes({ "/api/settings": baseSettingsPayload(), @@ -1636,7 +1640,7 @@ describe("App layout", () => { kind: "agent_turn", }, state: { - next_run_at_ms: Date.UTC(2026, 3, 18, 10, 0, 0), + next_run_at_ms: currentMonthTimestamp(18), last_status: "ok", pending: false, run_history: history, @@ -1659,7 +1663,11 @@ describe("App layout", () => { const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" }); fireEvent.click(within(sidebar).getByRole("button", { name: "Automations" })); - fireEvent.click(await screen.findByRole("button", { name: /Long detail automation/ })); + fireEvent.click(await screen.findByRole( + "button", + { name: /Long detail automation.*Planned/ }, + { timeout: 5_000 }, + )); const detailPanel = await screen.findByRole("dialog", { name: "Long detail automation" }); const message = Array.from(detailPanel.querySelectorAll("section p")).find( (node) => node.textContent === longMessage, @@ -1697,13 +1705,13 @@ describe("App layout", () => { kind: "agent_turn", }, state: { - next_run_at_ms: Date.UTC(2026, 3, 17, 10, 0, 0), - last_run_at_ms: Date.UTC(2026, 3, 16, 10, 0, 0), + next_run_at_ms: currentMonthTimestamp(17), + last_run_at_ms: currentMonthTimestamp(16), last_status: "ok", pending: false, run_history: [ { - run_at_ms: Date.UTC(2026, 3, 16, 10, 0, 0), + run_at_ms: currentMonthTimestamp(16), status: "ok", duration_ms: 500, }, @@ -1735,7 +1743,7 @@ describe("App layout", () => { expect(screen.queryByText("任务队列")).not.toBeInTheDocument(); expect(screen.getAllByText("每日检查").length).toBeGreaterThanOrEqual(1); expect(screen.queryByText("检查仓库状态")).not.toBeInTheDocument(); - fireEvent.click(screen.getByRole("button", { name: /每日检查/ })); + fireEvent.click(screen.getByRole("button", { name: /每日检查.*计划运行/ })); const detail = within(screen.getByRole("dialog", { name: "每日检查" })); expect(detail.getByText("检查仓库状态")).toBeVisible(); expect(detail.getByText(/每 1天/)).toBeInTheDocument(); diff --git a/webui/src/tests/automations-settings.test.tsx b/webui/src/tests/automations-settings.test.tsx index 461e3800b..c14b8d40e 100644 --- a/webui/src/tests/automations-settings.test.tsx +++ b/webui/src/tests/automations-settings.test.tsx @@ -4,7 +4,7 @@ import userEvent from "@testing-library/user-event"; import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from "vitest"; import { AutomationDeleteDialog, AutomationEditDialog, AutomationsSettings } from "@/components/settings/system/AutomationsSettings"; -import type { AutomationFilter, AutomationSort } from "@/components/settings/system/AutomationsSettings"; +import type { AutomationFilter } from "@/components/settings/system/AutomationsSettings"; import i18n from "@/i18n"; import type { SessionAutomationJob, SettingsPayload } from "@/lib/types"; @@ -39,13 +39,11 @@ type Props = Partial>; const SYSTEM_TASKS_OPEN_STORAGE_KEY = "nanobot-webui.automation-system-tasks-open"; function Harness({ payload = { jobs: [task, systemTask] }, ...props }: Props) { - const [query, setQuery] = useState(""); const [filter, setFilter] = useState("all"); - const [sort, setSort] = useState("next"); return {}} onRequestEdit={() => {}} + payload={payload} loading={false} filter={filter} + actionKey={null} error={null} onFilterChange={setFilter} + onAction={() => {}} onRequestEdit={() => {}} onRequestDelete={() => {}} {...props} />; } @@ -90,16 +88,6 @@ describe("Automation task list and detail sheet", () => { expect(window.localStorage.getItem(SYSTEM_TASKS_OPEN_STORAGE_KEY)).toBe("true"); }); - it("does not replace a remembered collapse when search reveals system tasks", () => { - window.localStorage.setItem(SYSTEM_TASKS_OPEN_STORAGE_KEY, "false"); - const view = render(); - expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible(); - expect(window.localStorage.getItem(SYSTEM_TASKS_OPEN_STORAGE_KEY)).toBe("false"); - view.unmount(); - render(); - expect(screen.getByRole("button", { name: "System tasks 1" })).toHaveAttribute("aria-expanded", "false"); - }); - it("keeps the system toggle usable when browser storage is unavailable", () => { vi.spyOn(window.localStorage, "getItem").mockImplementation(() => { throw new Error("Blocked"); }); vi.spyOn(window.localStorage, "setItem").mockImplementation(() => { throw new Error("Blocked"); }); @@ -112,7 +100,7 @@ describe("Automation task list and detail sheet", () => { expect(toggle).toHaveAttribute("aria-expanded", "true"); }); - it.each(["Done", "Escape", "removed", "Edit", "Edit removed"])("finishes the detail exit before cleanup and handoff: %s", async (action) => { + it.each(["Close", "Escape", "removed", "Edit", "Edit removed"])("finishes the detail exit before cleanup and handoff: %s", async (action) => { // Happy DOM has no CSS animations. Give Radix live animation names so its // real presence lifecycle runs, including the outer portal's ref boundary. const getStyle = window.getComputedStyle.bind(window); @@ -159,7 +147,8 @@ describe("Automation task list and detail sheet", () => { const user = userEvent.setup(); render(); expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); - expect(screen.getByRole("textbox")).toBeVisible(); + expect(screen.getByRole("group", { name: "Automations" })).toBeVisible(); + expect(screen.queryByRole("textbox")).not.toBeInTheDocument(); expect(screen.getByRole("button", { name: /^Active/ })).toBeVisible(); expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible(); expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument(); @@ -172,7 +161,7 @@ describe("Automation task list and detail sheet", () => { "href", "#/chat/websocket%3Ademo", ); expect(within(dialog).getByRole("button", { name: "More details" })).toHaveAttribute("aria-expanded", "false"); - await user.click(within(dialog).getByRole("button", { name: "Done" })); + await user.click(within(dialog).getByRole("button", { name: "Close" })); await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument()); expect(row).toHaveFocus(); await user.keyboard("{Enter}"); @@ -206,6 +195,70 @@ describe("Automation task list and detail sheet", () => { ); }); + it("opens the whole day in a popover and hands off to details without expanding the grid", async () => { + const user = userEvent.setup(); + const crowded = Array.from({ length: 5 }, (_, index): SessionAutomationJob => ({ + ...task, + id: `crowded-${index + 1}`, + name: `Crowded ${index + 1}`, + state: { next_run_at_ms: now + 540_000 }, + })); + render(); + + const more = screen.getByRole("button", { name: "+2 more" }); + const day = more.closest(".automation-calendar-day")!; + const dayLabel = day.getAttribute("aria-label")!; + + await user.click(more); + const popover = screen.getByRole("dialog", { name: dayLabel }); + expect(within(popover).getAllByRole("button", { name: /Crowded.*Planned/ })).toHaveLength(5); + expect(within(day as HTMLElement).getAllByRole("button", { name: /Crowded.*Planned/ })).toHaveLength(3); + expect(more).toHaveAttribute("aria-expanded", "true"); + await user.keyboard("{Escape}"); + await waitFor(() => expect(more).toHaveFocus()); + expect(screen.queryByRole("button", { name: /Crowded 4.*Planned/ })).not.toBeInTheDocument(); + + await user.click(more); + await user.click(within(screen.getByRole("dialog", { name: dayLabel })).getByRole("button", { name: /Crowded 4.*Planned/ })); + const detail = await screen.findByRole("dialog", { name: "Crowded 4" }); + expect(screen.queryByRole("dialog", { name: dayLabel })).not.toBeInTheDocument(); + expect(within(detail).getByRole("link", { name: "Open a chat" })).toBeVisible(); + await user.click(within(detail).getByRole("button", { name: "Close" })); + await waitFor(() => expect(more).toHaveFocus()); + }); + + it("keeps the calendar and filters available when a status has no matches", async () => { + const user = userEvent.setup(); + render(); + const month = screen.getByRole("heading", { level: 2 }); + await user.click(screen.getByRole("button", { name: "Paused 0" })); + expect(month).toBeVisible(); + expect(screen.queryByRole("button", { name: /PR watch.*Planned/ })).not.toBeInTheDocument(); + await user.click(screen.getByRole("button", { name: "All 1" })); + expect(screen.getByRole("button", { name: /PR watch.*Planned/ })).toBeVisible(); + }); + + it("keeps creation compact until focused and preserves an unfocused draft", async () => { + const user = userEvent.setup(); + render(); + const input = screen.getByRole("textbox", { name: "Describe an automation" }); + const surface = input.closest(".thread-composer-surface")!; + expect(input).not.toHaveFocus(); + expect(surface).toHaveAttribute("data-compact", "true"); + await user.click(input); + expect(surface).not.toHaveAttribute("data-compact"); + await user.type(input, "Review this project every Monday"); + await user.click(screen.getByRole("button", { name: "Today" })); + expect(input).toHaveValue("Review this project every Monday"); + expect(surface).not.toHaveAttribute("data-compact"); + await user.clear(input); + await user.click(screen.getByRole("button", { name: "Today" })); + await waitFor(() => expect(surface).toHaveAttribute("data-compact", "true")); + await user.click(screen.getByRole("button", { name: "fast" })); + expect(screen.getByRole("dialog", { name: "Switch model for this chat" })).toBeVisible(); + expect(surface).toHaveAttribute("data-compact", "true"); + }); + it("starts an automation conversation from the inline composer without opening a dialog", async () => { const user = userEvent.setup(); const onStartChat = vi.fn().mockResolvedValue(true); @@ -268,16 +321,28 @@ describe("Automation task list and detail sheet", () => { render( {}} settingsSnapshot={modelSettings} />); expect(screen.getByRole("textbox", { name: "Describe an automation" })).toHaveAttribute( "placeholder", - "Describe an automation, for example: summarize project updates every weekday at 9:00", + "What would you like nanobot to schedule?", ); }); - it("keeps a text-only empty state when only system tasks exist", () => { + it("uses a short, conversational Chinese creation prompt", async () => { + await act(() => i18n.changeLanguage("zh-CN")); + render( {}} settingsSnapshot={modelSettings} />); + expect(screen.getByRole("textbox", { name: "描述一个自动任务" })).toHaveAttribute( + "placeholder", "想让 nanobot 定时帮你做什么?", + ); + }); + + it("keeps the complete month grid visible when no personal automations exist", () => { render(); - expect(screen.getByText("No automations yet.")).toBeVisible(); + expect(screen.queryByText("No automations yet.")).not.toBeInTheDocument(); + const calendar = document.querySelector(".automation-calendar")!; + expect(calendar.querySelector(".automation-calendar-grid")).toBeInTheDocument(); + expect(calendar.querySelectorAll(".automation-calendar-weekdays > div")).toHaveLength(7); + expect(calendar.querySelectorAll(".automation-calendar-day").length).toBeGreaterThanOrEqual(35); expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Open a chat" })).not.toBeInTheDocument(); - expect(screen.getByRole("region", { name: "Search and filter" })).toBeVisible(); + expect(screen.getByRole("group", { name: "Automations" })).toBeVisible(); fireEvent.click(screen.getByRole("button", { name: /heartbeat/ })); const dialog = screen.getByRole("dialog", { name: "heartbeat" }); expect(within(dialog).queryByRole("button", { name: "Edit" })).not.toBeInTheDocument(); @@ -288,7 +353,7 @@ describe("Automation task list and detail sheet", () => { it("distinguishes a finished one-time task from a task with no scheduled run", () => { render(); + state: { last_status: "ok", last_run_at_ms: now - 60_000, next_run_at_ms: null } }] }} />); expect(screen.getByRole("button", { name: /PR watch.*Completed/ })).toBeVisible(); expect(screen.queryByText("No next run")).not.toBeInTheDocument(); }); @@ -310,7 +375,7 @@ describe("Automation task list and detail sheet", () => { expect(within(dialog).getByText("Every 30 minutes")).toBeVisible(); expect(within(dialog).getByText("Not run yet")).toBeVisible(); expect(within(dialog).getAllByRole("button")).toHaveLength(2); - expect(within(dialog).getByRole("button", { name: "Done" })).toHaveClass("rounded-control", "h-9"); + expect(within(dialog).getByRole("button", { name: "Close" })).toHaveClass("rounded-full", "h-7", "w-7"); const toggle = within(dialog).getByRole("button", { name: "More details" }); const metadata = document.getElementById(toggle.getAttribute("aria-controls")!)!; expect(metadata).toHaveAttribute("data-state", "closed"); @@ -346,22 +411,42 @@ describe("Automation task list and detail sheet", () => { const title = within(dialog).getByRole("heading", { name: job.name }); expect(title).toHaveClass("text-lg", "leading-6"); expect(title).not.toHaveClass("text-[22px]"); - const done = within(dialog).getByRole("button", { name: "Done" }); - expect(done).toHaveClass("rounded-control", "h-9"); - expect(done).not.toHaveClass("rounded-full"); + const close = within(dialog).getByRole("button", { name: "Close" }); + expect(close).toHaveClass("rounded-full", "h-7", "w-7"); const lastRun = within(dialog).getByText("Last run"); expect(lastRun.closest("dl")).not.toHaveClass("divide-y", "border-y"); expect(lastRun.parentElement).toHaveClass("py-2.5"); const details = within(dialog).getByRole("button", { name: "More details" }); - expect(details.parentElement).toHaveClass("border-t"); + expect(details.parentElement).not.toHaveClass("border-t"); expect(details).toHaveAttribute("aria-expanded", "false"); if (!job.protected) { + const taskActions = within(dialog).getByRole("button", { name: "Pause" }).parentElement; + expect(within(dialog).getByRole("button", { name: "Run now" }).parentElement).toBe(taskActions); + expect(within(dialog).getByRole("button", { name: "Delete" }).parentElement).toBe(taskActions); const edit = within(dialog).getByRole("button", { name: "Edit" }); - expect(edit.parentElement).toHaveClass("ml-auto", "flex-wrap", "justify-end"); + expect(edit.parentElement).toHaveClass("sm:ml-auto", "flex-wrap", "justify-end"); expect(within(dialog).getByRole("link", { name: "Open a chat" }).parentElement).toBe(edit.parentElement); } }); + it("keeps the header summary concise and moves timezone into more details", async () => { + const user = userEvent.setup(); + render(); + + await user.click(screen.getByRole("button", { name: /PR watch/ })); + const dialog = screen.getByRole("dialog", { name: "PR watch" }); + const description = within(dialog).getByText("Weekdays at 09:15").parentElement!; + expect(description).toHaveTextContent("Next"); + expect(description).not.toHaveTextContent("Asia/Shanghai"); + + await user.click(within(dialog).getByRole("button", { name: "More details" })); + expect(within(dialog).getByText("Timezone")).toBeVisible(); + expect(within(dialog).getByText("Asia/Shanghai")).toBeVisible(); + }); + it("uses the existing settings surfaces for the calendar and system task group", async () => { const user = userEvent.setup(); render( { const list = screen.getByRole("list", { name: "System tasks" }); expect(taskBlock.closest("section")).toHaveClass("rounded-panel", "bg-[hsl(var(--settings-surface))]"); expect(list.closest(".bg-settings-surface")).not.toBe(taskBlock.closest("section")); - const search = screen.getByRole("textbox"); - expect(search.closest(".rounded-panel")).toBeNull(); - expect(search).toHaveClass("h-10", "bg-settings-surface", "focus-visible:bg-background"); + const filters = screen.getByRole("group", { name: "Automations" }); + expect(filters.closest(".automation-calendar-header")).toBeInTheDocument(); expect(screen.getByRole("button", { name: "All 1" }).parentElement).toHaveClass("segmented-control", "flex-wrap"); const heartbeat = within(list).getByRole("button", { name: /heartbeat/ }); expect(heartbeat).toHaveClass("rounded-control", "settings-hover"); @@ -391,7 +475,7 @@ describe("Automation task list and detail sheet", () => { await waitFor(() => expect(heartbeat).toHaveFocus()); }); - it("keeps separators inside the date grid and uses spacing for calendar metadata", () => { + it("keeps separators inside the date grid and omits an outside-month task list", () => { const outsideTask: SessionAutomationJob = { ...task, id: "outside-month", @@ -402,11 +486,14 @@ describe("Automation task list and detail sheet", () => { render(); const calendar = screen.getByRole("button", { name: /PR watch.*Planned/ }).closest("section")!; - expect(calendar.firstElementChild).not.toHaveClass("border-b"); + expect(calendar).not.toHaveClass("border"); + const header = calendar.querySelector(".automation-calendar-header"); + expect(header).toHaveClass("bg-foreground/[0.025]"); + expect(header).not.toHaveClass("border-b"); + expect(header?.querySelector(".automation-calendar-weekdays")).toBeInTheDocument(); expect(calendar.querySelector(".automation-meta-row")).not.toHaveClass("border-t"); - const outside = within(calendar).getByText("Without a date in this month").closest("details")!; - expect(outside).not.toHaveClass("border-t"); - expect(outside.querySelector("ul")).not.toHaveClass("border-t"); + expect(calendar.querySelector(":scope > details")).toBeNull(); + expect(screen.queryByRole("button", { name: /Paused backlog review/ })).not.toBeInTheDocument(); expect(calendar).not.toHaveTextContent("·"); }); @@ -465,59 +552,53 @@ describe("Automation task list and detail sheet", () => { expect(screen.getByRole("button", { name: /heartbeat/ })).toBe(row); }); - it("keeps search, status filters and sorting immediately available", async () => { + it("keeps status filters immediately available", async () => { const user = userEvent.setup(); - render(); - const search = screen.getByRole("textbox"); - expect(search).toBeVisible(); - expect(search).toBeEnabled(); - expect(screen.queryByRole("button", { name: "Search and filter" })).not.toBeInTheDocument(); - await user.type(search, "chat:nanobot"); - expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible(); - await user.clear(search); - await user.type(search, "heartbeat"); - expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible(); - expect(screen.getByRole("button", { name: "System tasks 1" })).toHaveAttribute("aria-expanded", "true"); - await user.clear(search); + render(); + expect(screen.queryByRole("textbox")).not.toBeInTheDocument(); await user.click(screen.getByRole("button", { name: "Paused 1" })); expect(screen.queryByRole("button", { name: /PR watch/ })).not.toBeInTheDocument(); expect(screen.getByRole("button", { name: /Weekly review/ })).toBeVisible(); - expect(search).toBeVisible(); expect(screen.getByRole("button", { name: "Paused 1" })).toHaveAttribute("aria-pressed", "true"); await user.click(screen.getByRole("button", { name: "All 2" })); - await user.click(screen.getByRole("button", { name: "Next run" })); - await user.click(screen.getByRole("menuitem", { name: "Name" })); - expect(screen.getByRole("button", { name: "Name", exact: true })).toBeVisible(); + expect(screen.queryByRole("button", { name: "Next run", exact: true })).not.toBeInTheDocument(); expect(screen.getByRole("button", { name: /PR watch.*Planned/ })).toBeVisible(); }); - it("uses live renamed chat titles in details and search without changing the bound task", async () => { + it("uses live renamed chat titles in details without changing the bound task", async () => { const user = userEvent.setup(); const action = vi.fn(); const payload = { jobs: [task] }; + const longTitle = "Daily summary with completed work, blockers, and tomorrow's plan from the current conversation"; const { rerender } = render(); + titleOverrides={{ "websocket:demo": longTitle }} />); await user.click(screen.getByRole("button", { name: /PR watch/ })); const dialog = screen.getByRole("dialog", { name: "PR watch" }); - const chatLink = within(dialog).getByRole("link", { name: "推特大战场" }); - expect(chatLink).toHaveAttribute("href", "#/chat/websocket%3Ademo"); + const chatLabel = within(dialog).getByText(longTitle); + expect(chatLabel.closest("a")).toBeNull(); + expect(chatLabel).toHaveClass("truncate"); + expect(chatLabel).toHaveAttribute("title", longTitle); + expect(dialog.querySelector(".lucide-chevron-right")).toBeNull(); rerender(); - expect(within(dialog).getByRole("link", { name: "新会话名称" })).toBe(chatLink); + expect(within(dialog).getByText("新会话名称")).toBe(chatLabel); await user.click(within(dialog).getByRole("button", { name: "Pause" })); expect(action).toHaveBeenCalledWith("disable", expect.objectContaining({ id: task.id, payload: task.payload, origin: expect.objectContaining({ session_key: "websocket:demo" }), })); expect(task.origin?.title).toBe("nanobot-development"); - await user.click(within(dialog).getByRole("button", { name: "Done" })); - await user.type(screen.getByRole("textbox"), "chat:新会话名称"); - expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible(); + await user.click(within(dialog).getByRole("button", { name: "Close" })); rerender(); - expect(screen.queryByRole("button", { name: /PR watch/ })).not.toBeInTheDocument(); - await user.clear(screen.getByRole("textbox")); await user.click(screen.getByRole("button", { name: /PR watch/ })); - expect(screen.getByRole("link", { name: "nanobot-development" })).toHaveAttribute("href", "#/chat/websocket%3Ademo"); + expect(screen.getByText("nanobot-development").closest("a")).toBeNull(); + expect(screen.getByRole("link", { name: "Open a chat" })).toHaveAttribute("href", "#/chat/websocket%3Ademo"); }); it("retains the inspected task across refreshes and closes if it is removed", () => { @@ -534,43 +615,21 @@ describe("Automation task list and detail sheet", () => { expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); }); - it("keeps controls visible and preserves search when Escape dismisses sorting", async () => { - const user = userEvent.setup(); - render(); - const search = screen.getByRole("textbox"); - expect(search).not.toHaveFocus(); - await user.tab(); - expect(search).toHaveFocus(); - await user.type(search, "PR"); - await user.keyboard("{Escape}"); - expect(search).toHaveValue("PR"); - expect(search).toHaveFocus(); - expect(search).toBeEnabled(); - fireEvent.keyDown(search, { key: "Escape", isComposing: true }); - expect(search).toBeVisible(); - await user.click(screen.getByRole("button", { name: "Next run", exact: true })); - await user.keyboard("{Escape}"); - expect(screen.queryByRole("menu")).not.toBeInTheDocument(); - expect(screen.getByRole("button", { name: "Next run", exact: true })).toHaveFocus(); - await user.keyboard("{Escape}"); - expect(screen.getByRole("region", { name: "Search and filter" })).toBeVisible(); - expect(search).toHaveValue("PR"); - }); - - it("returns focus to search or the page heading when the inspected row is no longer present", async () => { + it("returns focus to the page heading when the inspected row is no longer present", async () => { const user = userEvent.setup(); const { rerender } = render(); await user.click(screen.getByRole("button", { name: /PR watch/ })); rerender(); - await user.click(screen.getByRole("button", { name: "Done" })); - await waitFor(() => expect(screen.getByRole("textbox")).toHaveFocus()); + await user.click(screen.getByRole("button", { name: "Close" })); + await waitFor(() => expect(screen.getByRole("heading", { name: "Automations" })).toHaveFocus()); rerender(); await user.click(screen.getByRole("button", { name: /PR watch/ })); rerender(); await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument()); expect(screen.getByRole("heading", { name: "Automations" })).toHaveFocus(); - expect(screen.getByText("No automations yet.")).toBeVisible(); + expect(document.querySelectorAll(".automation-calendar-day").length).toBeGreaterThanOrEqual(35); + expect(screen.queryByText("No automations yet.")).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: /PR watch/ })).not.toBeInTheDocument(); }); @@ -594,7 +653,7 @@ describe("Automation task list and detail sheet", () => { await user.click(details); expect(details).toHaveAttribute("aria-expanded", "true"); expect(screen.getByRole("dialog")).toBeVisible(); - await user.click(screen.getByRole("button", { name: "Done" })); + await user.click(screen.getByRole("button", { name: "Close" })); } }); @@ -740,7 +799,9 @@ describe("Automation task list and detail sheet", () => { it("does not allow running a pending task or resuming an unlinked task", async () => { const user = userEvent.setup(); - const { rerender } = render(); + const { rerender } = render(); await user.click(screen.getByRole("button", { name: /PR watch/ })); expect(screen.getByRole("button", { name: "Run now" })).toBeDisabled(); rerender(); @@ -764,11 +825,11 @@ describe("Automation task list and detail sheet", () => { it("shows paused failures honestly and does not fabricate successful runs", () => { render(); - const row = screen.getByRole("button", { name: /PR watch/ }); - expect(row).toHaveTextContent("Needs attention"); - expect(row).toHaveTextContent("Paused"); + const row = screen.getByRole("button", { name: /PR watch.*Failed/ }); expect(screen.getByRole("button", { name: /System tasks 1 Needs attention/ })).toBeVisible(); fireEvent.click(row); expect(within(screen.getByRole("dialog")).getByText("Failed")).toBeVisible(); @@ -776,7 +837,11 @@ describe("Automation task list and detail sheet", () => { }); it("allows expanding long instructions without exposing technical metadata by default", () => { - render(); + render(); fireEvent.click(screen.getByRole("button", { name: /PR watch/ })); const dialog = screen.getByRole("dialog"); expect(within(dialog).getByText("Not run yet")).toBeVisible(); diff --git a/webui/src/tests/settings-automations.test.tsx b/webui/src/tests/settings-automations.test.tsx index e5b77aca8..713b1c4d4 100644 --- a/webui/src/tests/settings-automations.test.tsx +++ b/webui/src/tests/settings-automations.test.tsx @@ -15,18 +15,14 @@ function renderAutomationDetail(channel: string) { enabled: true, schedule: { kind: "every", every_ms: 60_000 }, payload: { message: "Summarize updates" }, - state: {}, + state: { next_run_at_ms: Date.now() + 60_000 }, origin: { channel }, }] }} loading={false} - query="" filter="all" - sort="name" actionKey={null} error={null} - onQueryChange={vi.fn()} onFilterChange={vi.fn()} - onSortChange={vi.fn()} onAction={vi.fn()} onRequestEdit={vi.fn()} onRequestDelete={vi.fn()} diff --git a/webui/src/tests/settings-system.test.tsx b/webui/src/tests/settings-system.test.tsx index 55ff89628..f6e96a073 100644 --- a/webui/src/tests/settings-system.test.tsx +++ b/webui/src/tests/settings-system.test.tsx @@ -233,11 +233,12 @@ describe("Settings system domains", () => { }); expect(screen.getByRole("heading", { name: "Automations" })).toBeInTheDocument(); - expect(await screen.findByText("No automations yet.")).toBeInTheDocument(); + await waitFor(() => expect(document.querySelectorAll(".automation-calendar-day").length).toBeGreaterThanOrEqual(35)); + expect(screen.queryByText("No automations yet.")).not.toBeInTheDocument(); const input = screen.getByRole("textbox", { name: "Describe an automation" }); expect(input).toHaveAttribute( "placeholder", - "Describe an automation, for example: summarize project updates every weekday at 9:00", + "What would you like nanobot to schedule?", ); fireEvent.change(input, { target: { value: "Summarize updates every weekday at 9" } }); fireEvent.click(screen.getByRole("button", { name: "Send message" })); @@ -263,7 +264,7 @@ describe("Settings system domains", () => { enabled: true, schedule: { kind: "cron", expr: "0 9 * * *" }, payload: { message: "Summarize the day" }, - state: {}, + state: { next_run_at_ms: Date.now() + 60_000 }, }], }); } @@ -278,8 +279,9 @@ describe("Settings system domains", () => { expect(await screen.findByRole("button", { name: /Daily summary/ })).toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: "Paused 0" })); - expect(await screen.findByText("No automations match this view.")).toBeInTheDocument(); - fireEvent.click(screen.getByRole("button", { name: "Clear filters" })); + expect(screen.queryByRole("button", { name: /Daily summary/ })).not.toBeInTheDocument(); + expect(screen.getByRole("button", { name: "Today" })).toBeVisible(); + fireEvent.click(screen.getByRole("button", { name: "All 1" })); expect(await screen.findByRole("button", { name: /Daily summary/ })).toBeInTheDocument(); }); @@ -296,7 +298,8 @@ describe("Settings system domains", () => { { id: "paused-job", name: "Paused reminder", enabled: false, schedule: { kind: "every", every_ms: 86_400_000 }, - payload: { message: "Check the repo" }, state: {}, + payload: { message: "Check the repo" }, + state: { last_run_at_ms: Date.now() - 60_000, last_status: "ok" }, }, ] }); }