Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Routines setup: sidebar row, empty state, quiet time zone, Weekdays chip (UX audit #9) (#591)
Oleksandr Ivanchenkod1fcf92b021f
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 4c57adec..d497aa78 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -4056,6 +4056,11 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({showPage('board');playSfx('click');}}+ onOpenRoutines={() => {+ // From the sidebar, no card's Edit or Pause focus carries over.+ setRoutineFocus(null);+ openSpaceSettings('routines');+ }}devDeskActive={page === 'dev'}onOpenDevDesk={() => {showPage('dev');diff --git a/frontend/src/components/RoutinesPanel.tsx b/frontend/src/components/RoutinesPanel.tsxindex 19002780..62e075e3 100644--- a/frontend/src/components/RoutinesPanel.tsx+++ b/frontend/src/components/RoutinesPanel.tsx@@ -10,16 +10,21 @@ import {RunStatus,ScheduleForm,WEEKDAYS,+ WORK_WEEK,channelLabel,continuityApi,defaultTimeZone,emptyScheduleForm,+ firstLine,formFromSchedule,formatWhen,sortMonthDays,onContinuity,+ sameDays,scheduleFromForm,timeZoneOptions,+ zoneLabel,+ zoneOffset,} from '../continuity';import { asSchedule, scheduleWords } from '../botActions';import type { Channel, Kwant } from './Sidebar';@@ -31,6 +36,8 @@ import type { MessageTarget } from './DoneDetail';const smallBtn ='inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium border transition-colors disabled:opacity-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500';const quietBtn = `${smallBtn} border-zinc-700/70 bg-zinc-800/70 text-zinc-200 hover:bg-zinc-700`;+const rowSmallBtn = smallBtn.replace('text-[11px]', 'text-xs sm:text-[11px]');+const rowQuietBtn = quietBtn.replace('text-[11px]', 'text-xs sm:text-[11px]');const inputClass ='w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors';const labelClass = 'block text-xs font-medium text-zinc-400 mb-1';@@ -129,6 +136,13 @@ export const RoutineForm: React.FC<{const [saving, setSaving] = useState(false);const [error, setError] = useState<string | null>(null);const s = f.schedule;+ // Routines setup D: the zone shows as a city with Change; a zone Intl doesn't know starts open, so what's saved shows.+ const [tzOpen, setTzOpen] = useState(() => !s.tz.trim() || zoneOffset(s.tz) === null);+ const tzRef = useRef<HTMLInputElement>(null);+ const openTz = () => {+ setTzOpen(true);+ requestAnimationFrame(() => tzRef.current?.focus());+ };const setS = (patch: Partial<ScheduleForm>) => setF((prev) => ({ ...prev, schedule: { ...prev.schedule, ...patch } }));const submit = async (e: React.FormEvent) => {@@ -171,7 +185,7 @@ export const RoutineForm: React.FC<{<div className="grid grid-cols-1 sm:grid-cols-2 gap-3"><div><label htmlFor={id('name')} className={labelClass}>Name</label>- <input id={id('name')} value={f.name} onChange={(e) => setF({ ...f, name: e.target.value })} placeholder="Morning digest" className={inputClass} autoFocus />+ <input id={id('name')} value={f.name} onChange={(e) => setF({ ...f, name: e.target.value })} placeholder="Competitor prices" className={inputClass} autoFocus /></div>{!fixedKwantId && (<div>@@ -202,7 +216,7 @@ export const RoutineForm: React.FC<{rows={3}value={f.instructions}onChange={(e) => setF({ ...f, instructions: e.target.value })}- placeholder="Summarise yesterday's open pull requests and flag anything blocked."+ placeholder="Check our 3 competitors' prices and tell me what changed since last time."className={`${inputClass} resize-y`}/></div>@@ -217,7 +231,7 @@ export const RoutineForm: React.FC<{role="radio"aria-checked={s.type === t.id}onClick={() => setS({ type: t.id })}- className={`py-1.5 sm:py-1 rounded-md text-[11px] font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${s.type === t.id ? 'bg-sky-500/15 text-sky-200' : 'text-zinc-500 hover:text-zinc-300'}`}+ className={`min-h-10 sm:min-h-0 py-1.5 sm:py-1 rounded-md text-[11px] font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${s.type === t.id ? 'bg-sky-500/15 text-sky-200' : 'text-zinc-500 hover:text-zinc-300'}`}>{t.label}</button>@@ -228,7 +242,7 @@ export const RoutineForm: React.FC<{<div><label htmlFor={id('at')} className="sr-only">Date and time</label><input id={id('at')} type="datetime-local" value={s.onceAt} onChange={(e) => setS({ onceAt: e.target.value })} className={inputClass} />- <p className="mt-1 text-[11px] text-zinc-500">In your browser's time zone ({defaultTimeZone()}). Turns itself off after it runs.</p>+ <p className="mt-1 text-[11px] text-zinc-500">In your time zone ({zoneLabel(defaultTimeZone())}). Turns itself off after it runs.</p></div>)}@@ -260,36 +274,75 @@ export const RoutineForm: React.FC<{<input id={id('time')} type="time" value={s.time} onChange={(e) => setS({ time: e.target.value })} className={inputClass} /></div>)}- <div>- <label htmlFor={id('tz')} className="text-[11px] text-zinc-500">Time zone</label>- <input id={id('tz')} list={id('tzs')} value={s.tz} onChange={(e) => setS({ tz: e.target.value })} className={inputClass} spellCheck={false} />- <datalist id={id('tzs')}>- {timeZoneOptions(s.tz).map((z) => (- <option key={z} value={z} />- ))}- </datalist>- </div>+ {tzOpen ? (+ <div>+ <label htmlFor={id('tz')} className="text-[11px] text-zinc-500">Time zone</label>+ <input ref={tzRef} id={id('tz')} list={id('tzs')} value={s.tz} onChange={(e) => setS({ tz: e.target.value })} className={inputClass} spellCheck={false} />+ <datalist id={id('tzs')}>+ {timeZoneOptions(s.tz).map((z) => (+ <option key={z} value={z} />+ ))}+ </datalist>+ </div>+ ) : (+ <div>+ <span id={id('tz-label')} className="text-[11px] text-zinc-500">Time zone</span>+ <div className="min-h-11 sm:min-h-[34px] flex items-center gap-2 text-sm sm:text-xs" title={s.tz} role="group" aria-labelledby={id('tz-label')} data-tz-row>+ <span className="text-zinc-100">{zoneLabel(s.tz)}</span>+ {zoneOffset(s.tz) && <span className="text-zinc-400">{zoneOffset(s.tz)}</span>}+ <button+ type="button"+ onClick={openTz}+ aria-label={`Change time zone, now ${zoneLabel(s.tz)}`}+ className="ml-auto rounded font-medium text-sky-300 hover:text-sky-200 kw-focus kw-hit"+ data-tz-change+ >+ Change+ </button>+ </div>+ </div>+ )}</div>)}{s.type === 'weekly' && (- <div className="flex flex-wrap gap-1" role="group" aria-label="Days">- {WEEKDAYS.map((d) => {- const on = s.weekdays.includes(d.id);+ <div className="flex flex-col gap-1 sm:flex-row sm:flex-wrap sm:items-center" role="group" aria-label="Days">+ <div className="grid grid-cols-7 gap-1 sm:flex sm:flex-wrap">+ {WEEKDAYS.map((d) => {+ const on = s.weekdays.includes(d.id);+ return (+ <button+ key={d.id}+ type="button"+ aria-pressed={on}+ onClick={() => setS({ weekdays: on ? s.weekdays.filter((w) => w !== d.id) : [...s.weekdays, d.id] })}+ className={`min-h-11 sm:min-h-0 px-1 sm:px-2 py-1 rounded-md text-[11px] font-medium border transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${+ on ? 'border-sky-500/50 bg-sky-500/15 text-sky-200' : 'border-zinc-800 text-zinc-500 hover:text-zinc-300'+ }`}+ >+ {d.label}+ </button>+ );+ })}+ </div>+ <span className="hidden sm:block w-px h-[18px] mx-1 bg-white/[0.14]" aria-hidden="true" />+ {(() => {+ const on = sameDays(s.weekdays, WORK_WEEK);return (<button- key={d.id}type="button"aria-pressed={on}- onClick={() => setS({ weekdays: on ? s.weekdays.filter((w) => w !== d.id) : [...s.weekdays, d.id] })}- className={`px-2 py-1 rounded-md text-[11px] font-medium border transition-colors ${- on ? 'border-sky-500/50 bg-sky-500/15 text-sky-200' : 'border-zinc-800 text-zinc-500 hover:text-zinc-300'+ aria-label="Weekdays, Monday to Friday"+ onClick={() => !on && setS({ weekdays: [...WORK_WEEK] })}+ className={`self-start min-h-11 sm:min-h-0 px-3.5 sm:px-2 py-1 rounded-md text-[11px] font-medium border transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${+ on ? 'border-sky-500/50 bg-sky-500/15 text-sky-200' : 'border-dashed border-zinc-700 text-zinc-300 hover:text-zinc-100'}`}+ data-weekdays-chip>- {d.label}+ Weekdays<span className="sm:hidden"> (Mon–Fri)</span></button>);- })}+ })()}</div>)}@@ -373,6 +426,16 @@ export const RoutineForm: React.FC<{);};+/** Phone: 44 px, centred, one line each, so the four buttons share one row at 390 px. */+const rowBtn = 'min-h-11 sm:min-h-0 justify-center whitespace-nowrap';++/** "Mon, Nov 9": the card's last run, date only; the time is in History. */+const lastRanDate = (iso: string | null | undefined): string | null => {+ if (!iso) return null;+ const d = new Date(iso);+ return Number.isNaN(d.getTime()) ? null : d.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' });+};+/** 0.9.5 F: where a run's result message lives, for its History row's link. */export const runResultTarget = (routine: Routine, run: RoutineRun): MessageTarget | null =>run.message_id ? { message_id: run.message_id, channel_id: routine.channel_id, kwant_id: routine.kwant_id, thread_id: routine.thread_id ?? null } : null;@@ -483,6 +546,9 @@ export const RoutineRow: React.FC<{playSfx('click');});+ const what = firstLine(routine.instructions);+ const lastRan = lastRanDate(routine.last_run_at);+if (removal.pending) return <UndoNotice as="li" text={`Deleted “${routine.name}”. It won’t run again.`} onUndo={removal.undo} />;return (@@ -504,41 +570,56 @@ export const RoutineRow: React.FC<{</label><div className="flex-1 min-w-0"><div className="flex flex-wrap items-center gap-x-2 gap-y-1">- <span className="text-xs font-medium text-zinc-100 break-words">{routine.name}</span>+ <span className={`text-xs font-medium break-words ${routine.enabled ? 'text-zinc-100' : 'text-zinc-400'}`}>{routine.name}</span>{routine.origin === 'discovery' && <SuggestedBadge />}{routine.last_status && <StatusBadge status={routine.last_status} />}</div>- <p className="text-[11px] text-zinc-500 break-words">- {kwantName ? `${kwantName} · ` : ''}- {placeLabel} · <span title={routine.schedule_text || undefined}>{scheduleWords(routine.schedule, routine.schedule_text)}</span>+ {/* Routines setup F: what it does, then when it runs next, then the schedule, bot and place. */}+ {what.line && (+ <p className={`text-xs leading-[18px] truncate ${routine.enabled ? 'text-zinc-200' : 'text-zinc-400'}`} title={routine.instructions} data-routine-what>+ {what.line}+ {what.more ? ' …' : ''}+ </p>+ )}+ <p className="text-[11px] text-zinc-400" data-routine-next>+ {routine.enabled ? (+ <>+ Next <span className="text-zinc-100 font-medium">{formatWhen(routine.next_run_at)}</span>+ </>+ ) : (+ <span className="text-zinc-300 font-medium">Paused</span>+ )}+ {lastRan && <span className="hidden sm:inline"> · last ran {lastRan}</span>}</p>- <p className="text-[11px] text-zinc-400">- Next run: <span className="text-zinc-200">{routine.enabled ? formatWhen(routine.next_run_at) : 'off'}</span>- {routine.last_run_at && <span className="text-zinc-500"> · last {formatWhen(routine.last_run_at)}</span>}+ <p className="text-[11px] text-zinc-500 break-words">+ <span title={routine.schedule_text || undefined}>{scheduleWords(routine.schedule, routine.schedule_text)}</span>+ {kwantName ? ` · ${kwantName}` : ''} · {placeLabel}+ {lastRan && <span className="sm:hidden"> · last ran {lastRan}</span>}</p></div></div>- <div className="flex flex-wrap items-center gap-1.5 pl-9">- <button type="button" onClick={runNow} disabled={busy} className={`${smallBtn} border-sky-500/40 bg-sky-500/10 text-sky-200 hover:bg-sky-500/20`}>- <Play size={11} /> Run now+ {/* Phone: four 44 px buttons in one row, no indent, so Delete never wraps. Desktop is as before. */}+ <div className="grid grid-cols-4 gap-1.5 sm:flex sm:flex-wrap sm:items-center sm:pl-9">+ <button type="button" onClick={runNow} disabled={busy} className={`${rowSmallBtn} ${rowBtn} border-sky-500/40 bg-sky-500/10 text-sky-200 hover:bg-sky-500/20`}>+ <Play size={11} aria-hidden="true" className="hidden sm:block" /> Run now</button>- <button type="button" onClick={() => setOpen((v) => !v)} aria-expanded={open} aria-controls={historyId} className={quietBtn}>- {open ? <ChevronDown size={11} /> : <ChevronRight size={11} />} <History size={11} /> History+ <button type="button" onClick={() => setOpen((v) => !v)} aria-expanded={open} aria-controls={historyId} className={`${rowQuietBtn} ${rowBtn}`}>+ <span className="hidden sm:inline-flex" aria-hidden="true">{open ? <ChevronDown size={11} /> : <ChevronRight size={11} />}</span> <History size={11} aria-hidden="true" /> History</button>- <button type="button" onClick={onEdit} className={quietBtn} data-routine-edit={routine.id}>- <Pencil size={11} /> Edit+ <button type="button" onClick={onEdit} className={`${rowQuietBtn} ${rowBtn}`} data-routine-edit={routine.id}>+ <Pencil size={11} aria-hidden="true" /> Edit</button><buttontype="button"disabled={busy}onClick={() => removal.start(() => continuityApi.removeRoutine(routine.id))}- className={`${smallBtn} border-zinc-700/70 bg-zinc-800/70 text-zinc-300 hover:text-rose-200`}+ className={`${rowSmallBtn} ${rowBtn} border-zinc-700/70 bg-zinc-800/70 text-zinc-300 hover:text-rose-200`}>- <Trash2 size={11} /> Delete+ <Trash2 size={11} aria-hidden="true" /> Delete</button>- {notice && <span className="text-[11px] text-zinc-400" role="status">{notice}</span>}+ {notice && <span className="col-span-4 text-[11px] text-zinc-400" role="status">{notice}</span>}{highlight && routine.enabled && !notice && (- <span className="text-[11px] text-sky-200" role="status">Turn the switch off to pause it.</span>+ <span className="col-span-4 text-[11px] text-sky-200" role="status">Turn the switch off to pause it.</span>)}</div>{(error ?? removal.error) && <p className="pl-9 text-[11px] text-rose-400" role="alert">{error ?? `Couldn’t delete it: ${removal.error}`}</p>}@@ -621,26 +702,30 @@ export const RoutinesPanel: React.FC<{wrapRef.current?.querySelector<HTMLElement>(was === 'new' ? '[data-routine-new]' : `[data-routine-edit="${was.id}"]`)?.focus();}, [editing]);+ // The empty card only once routines loaded; a load error keeps today's rose box instead.+ const empty = !!routines && routines.length === 0 && !loadError;+ // Over a list, or after a load error (so New routine stays reachable); not while loading, so it never flickers away.+ const showTop = (!!routines && routines.length > 0) || !!loadError;+return (<div ref={wrapRef} className="space-y-3">- <div className="flex items-center justify-between gap-2">- <p className="text-[11px] text-zinc-500 leading-relaxed">- A routine posts its instructions to the bot on a schedule, then the bot answers as usual.- </p>- {editing !== 'new' && (- <button- type="button"- onClick={() => setEditing('new')}- disabled={kwants.length === 0}- data-routine-new- className={`${smallBtn} shrink-0 border-sky-500/50 bg-sky-600 text-white hover:bg-sky-500`}- >- <Plus size={11} /> New routine- </button>- )}- </div>-- {!kwantId && <SuggestedRoutines kwants={kwants} channels={channels} onAccepted={reload} onOpenSettings={onOpenSettings} />}+ {/* Routines setup B: with nothing saved, the empty card below leads; the top row only shows over a list. */}+ {showTop && (+ <div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">+ <p className="text-[11px] text-zinc-500 leading-relaxed">A routine has a bot do something on a schedule. Its answer lands where you chose.</p>+ {editing !== 'new' && (+ <button+ type="button"+ onClick={() => setEditing('new')}+ disabled={kwants.length === 0}+ data-routine-new+ className={`${smallBtn} shrink-0 justify-center min-h-11 sm:min-h-0 border-sky-500/50 bg-sky-600 text-white hover:bg-sky-500`}+ >+ <Plus size={11} aria-hidden="true" /> New routine+ </button>+ )}+ </div>+ )}{editing === 'new' && (<RoutineForm fixedKwantId={kwantId} kwants={kwants} channels={channels} onCancel={() => setEditing(null)} onSaved={saved} />@@ -664,10 +749,23 @@ export const RoutinesPanel: React.FC<{That routine no longer exists. It may have been undone or deleted.</p>)}- {routines && routines.length === 0 && editing !== 'new' && (- <div className="text-xs text-zinc-500 border border-dashed border-zinc-800 rounded-lg p-4 text-center space-y-1">- <CalendarClock size={18} className="mx-auto text-zinc-600" aria-hidden="true" />- <p>No routines yet.</p>+ {empty && editing !== 'new' && (+ <div className="rounded-2xl border border-dashed border-white/[0.12] px-6 py-7 flex flex-col items-center text-center gap-3" data-routines-empty>+ <span className="flex h-10 w-10 items-center justify-center rounded-xl bg-accent-soft text-sky-200" aria-hidden="true">+ <CalendarClock size={20} />+ </span>+ <p className="text-sm leading-[21px] text-zinc-200 max-w-[420px]">+ A routine has a bot do something for you on a schedule, like checking competitors' prices every Monday.+ </p>+ <button+ type="button"+ onClick={() => setEditing('new')}+ disabled={kwants.length === 0}+ data-routine-new+ className="inline-flex h-11 w-full items-center justify-center gap-1.5 rounded-xl bg-gradient-to-b from-[#7a62f0] to-[#5b47d6] px-4 text-sm font-semibold text-white hover:brightness-110 disabled:opacity-50 disabled:hover:brightness-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-300 focus-visible:ring-offset-2 focus-visible:ring-offset-[#120e26] sm:h-9 sm:w-auto"+ >+ <Plus size={15} aria-hidden="true" /> New routine+ </button></div>)}{routines && routines.length > 0 && (@@ -693,6 +791,13 @@ export const RoutinesPanel: React.FC<{)}</ul>)}++ {/* Suggestions come after what's saved (B3). */}+ {!kwantId && (+ <div className="mt-3">+ <SuggestedRoutines kwants={kwants} channels={channels} onAccepted={reload} onOpenSettings={onOpenSettings} />+ </div>+ )}</div>);};diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsxindex d78049d3..01244aa2 100644--- a/frontend/src/components/Sidebar.tsx+++ b/frontend/src/components/Sidebar.tsx@@ -1,5 +1,5 @@import React, { useCallback, useEffect, useState } from 'react';-import { Hash, Plus, CheckCircle2, ShieldCheck, KeyRound, Loader2, Users, ChevronDown, Settings, Settings2, X, Crown, UserPlus, Pencil, Inbox, Search, Split, Hand, MoreHorizontal, UserMinus, MessageSquare, KanbanSquare } from 'lucide-react';+import { Hash, Plus, CheckCircle2, ShieldCheck, KeyRound, Loader2, Users, ChevronDown, Settings, Settings2, X, Crown, UserPlus, Pencil, Inbox, Search, Split, Hand, MoreHorizontal, UserMinus, MessageSquare, KanbanSquare, CalendarClock } from 'lucide-react';import { ModernAvatar, useModelBadge } from './ModernAvatar';import { playSfx } from '../audio/chiptune';import { badgeText } from '../away';@@ -162,6 +162,8 @@ export interface SidebarProps {missionBoard?: boolean;missionsActive?: boolean;onOpenMissions?: () => void;+ /** Routines setup A (0.9.9): opens Space settings › Routines. Without it the row isn't drawn. */+ onOpenRoutines?: () => void;/** Dev mode (0.7): the Dev desk row's page is open, and how to open it. */devDeskActive?: boolean;onOpenDevDesk?: () => void;@@ -396,6 +398,7 @@ export const Sidebar: React.FC<SidebarProps> = ({onOpenMoved,onHideMoved,onOpenMissions,+ onOpenRoutines,ideaJarCount = 0,ideaJarActive = false,onOpenIdeaJar,@@ -1009,6 +1012,13 @@ export const Sidebar: React.FC<SidebarProps> = ({<span className="truncate flex-1">Mission board</span></button>)}+ {/* Routines setup A: no count or badge; Settings covers the sidebar while open, so never aria-current. */}+ {onOpenRoutines && (+ <button type="button" onClick={onOpenRoutines} className={navRow(false)} data-routines-row>+ <CalendarClock size={15} className="text-zinc-500" aria-hidden="true" />+ <span className="truncate flex-1">Routines</span>+ </button>+ )}{onOpenIdeaJar && onDropIdea && !phone && (<IdeaJarRow active={ideaJarActive} count={ideaJarCount} onOpen={onOpenIdeaJar} onDrop={onDropIdea} className={navRow(ideaJarActive)} />)}diff --git a/frontend/src/components/SpaceSettings.tsx b/frontend/src/components/SpaceSettings.tsxindex 2afeb36c..97edf72d 100644--- a/frontend/src/components/SpaceSettings.tsx+++ b/frontend/src/components/SpaceSettings.tsx@@ -132,6 +132,12 @@ export const SpaceSettings: React.FC<Props> = (p) => {if (rootRef.current?.contains(a) || a?.closest('[data-rail-space]')) return;rootRef.current?.querySelector<HTMLElement>('#space-settings-title')?.focus();}, []);+ // Phone: the tab strip scrolls sideways, so bring the open tab into view (from the sidebar's+ // Routines row it would sit off the right edge; scroll-mx-6 keeps it clear of the edge fade). Instant: no motion.+ const currentTabRef = useRef<HTMLButtonElement>(null);+ useEffect(() => {+ currentTabRef.current?.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });+ }, [tab, scope]);return (// A full-screen dialog on phones. On desktop it fills the space's area beside the space rail,@@ -186,12 +192,13 @@ export const SpaceSettings: React.FC<Props> = (p) => {<buttonkey={t.id}type="button"+ ref={tab === t.id ? currentTabRef : undefined}aria-current={tab === t.id ? 'page' : undefined}onClick={() => {playSfx('click');onTab(t.id);}}- className={`shrink-0 flex items-center gap-2 px-3 py-1.5 md:py-2 rounded-full md:rounded-lg text-xs font-medium transition-colors ${+ className={`shrink-0 scroll-mx-6 flex items-center gap-2 px-3 py-1.5 md:py-2 rounded-full md:rounded-lg text-xs font-medium transition-colors ${tab === t.id ? 'bg-zinc-800 text-zinc-100 border border-zinc-700/60' : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50 border border-transparent'}`}>diff --git a/frontend/src/components/SuggestedRoutines.tsx b/frontend/src/components/SuggestedRoutines.tsxindex 76de6573..be45bbc0 100644--- a/frontend/src/components/SuggestedRoutines.tsx+++ b/frontend/src/components/SuggestedRoutines.tsx@@ -1,5 +1,5 @@import React, { useCallback, useEffect, useId, useRef, useState } from 'react';-import { AlertTriangle, CalendarClock, Check, ChevronDown, ChevronRight, Eye, Loader2, RefreshCw, Search, ShieldCheck, Sparkles, X } from 'lucide-react';+import { AlertTriangle, Check, ChevronDown, ChevronRight, Eye, Loader2, RefreshCw, Search, ShieldCheck, Sparkles, X } from 'lucide-react';import {AcceptIntent,DISCOVERY_SETTING_EVENT,@@ -365,6 +365,10 @@ const ScanReport: React.FC<{ result: ScanResult; onClose: () => void }> = ({ res* "Suggested routines" on top of the Routines list (Automation Discovery, docs §20): what kwant* noticed you ask for on a rhythm, to accept (with edits) or dismiss. Hidden on servers without it.*/+/** No offers, accepts or dismissals in 30 days and no scan yet. */+export const statsAllZero = (l: { stats: { offered_30d: number; accepted_30d: number; dismissed_30d: number }; last_scan_at?: string | null }) =>+ !l.stats.offered_30d && !l.stats.accepted_30d && !l.stats.dismissed_30d && !l.last_scan_at;+export const SuggestedRoutines: React.FC<{kwants: Kwant[];channels: Channel[];@@ -543,14 +547,11 @@ export const SuggestedRoutines: React.FC<{)}{list && blocked.length === 0 && offers.length === 0 && (- <div className="text-[11px] text-zinc-500 border border-dashed border-zinc-800 rounded-lg px-3 py-2.5 flex items-start gap-2" data-testid="discovery-empty">- <CalendarClock size={14} className="mt-0.5 shrink-0 text-zinc-600" aria-hidden="true" />- <p>- {list.daily_cap === 0- ? 'No suggestions. The daily limit in Settings is 0, so nothing new is suggested; Preview shows what it would suggest.'- : `No suggestions right now. The board is checked every hour for tasks you ask for on a regular rhythm, with at most ${list.daily_cap} new ${list.daily_cap === 1 ? 'suggestion' : 'suggestions'} a day.`}- </p>- </div>+ <p className="text-[11px] text-zinc-400" data-testid="discovery-empty">+ {list.daily_cap === 0+ ? 'No suggestions. The daily limit in Settings is 0, so nothing new is suggested; Preview shows what it would suggest.'+ : `None right now. When you ask a bot for the same thing on a regular rhythm, a suggestion shows up here (at most ${list.daily_cap} a day).`}+ </p>)}{offers.length > 0 && (@@ -561,7 +562,8 @@ export const SuggestedRoutines: React.FC<{</ul>)}- {list && (list.setting === 'on' || list.stats.offered_30d > 0) && (+ {/* Routines setup B3: nothing has happened yet (all zero, never looked), so the line would only add noise. */}+ {list && (list.setting === 'on' || list.stats.offered_30d > 0) && !statsAllZero(list) && (<p className="text-[11px] text-zinc-500" data-testid="discovery-stats">{statsLine(list.stats)} {list.last_scan_at ? `Last looked ${formatWhen(list.last_scan_at)}.` : list.setting === 'on' ? 'Hasn’t looked yet.' : ''}</p>diff --git a/frontend/src/continuity.ts b/frontend/src/continuity.tsindex a86be53c..ea991881 100644--- a/frontend/src/continuity.ts+++ b/frontend/src/continuity.ts@@ -369,6 +369,16 @@ export function toLocalInput(d: Date): string {return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;}+/** Date.getDay() (0 = Sunday) as a `Weekday`. */+const DAY_OF: Weekday[] = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];+/** Monday to Friday, the set the Weekdays chip sets and "Weekdays at …" names. */+export const WORK_WEEK: Weekday[] = ['mon', 'tue', 'wed', 'thu', 'fri'];+/** True when `days` is exactly the set `want`, in any order and ignoring repeats. */+export const sameDays = (days: Weekday[], want: Weekday[]) => {+ const set = new Set(days);+ return set.size === want.length && want.every((d) => set.has(d));+};+export function emptyScheduleForm(now = new Date(), tz = defaultTimeZone()): ScheduleForm {const soon = new Date(now.getTime() + 60 * 60 * 1000);soon.setMinutes(0, 0, 0);@@ -376,7 +386,8 @@ export function emptyScheduleForm(now = new Date(), tz = defaultTimeZone()): Schtype: 'daily',onceAt: toLocalInput(soon),time: '09:00',- weekdays: ['mon', 'tue', 'wed', 'thu', 'fri'],+ // Routines setup E: Weekly starts on today only; the Weekdays chip sets Mon–Fri in one click.+ weekdays: [DAY_OF[now.getDay()]],tz,everyMinutes: '60',monthDays: [1],@@ -466,24 +477,72 @@ export function monthDaysText(days: MonthDay[]): string {return `the ${list}`;}+const DAY_NAMES: Record<Weekday, string> = {+ mon: 'Monday', tue: 'Tuesday', wed: 'Wednesday', thu: 'Thursday', fri: 'Friday', sat: 'Saturday', sun: 'Sunday',+};++/** "Every Monday", "Weekdays", "Weekends", "Every day" or "Mon, Wed and Fri" (always Monday first). */+export function weekdaysText(days: Weekday[]): string {+ const sorted = WEEKDAYS.map((d) => d.id).filter((d) => days.includes(d));+ if (sorted.length === 7) return 'Every day';+ if (sameDays(sorted, WORK_WEEK)) return 'Weekdays';+ if (sameDays(sorted, ['sat', 'sun'])) return 'Weekends';+ if (sorted.length === 1) return `Every ${DAY_NAMES[sorted[0]]}`;+ const labels = sorted.map((d) => WEEKDAYS.find((w) => w.id === d)?.label ?? d);+ if (labels.length === 0) return 'No day';+ return `${labels.slice(0, -1).join(', ')} and ${labels[labels.length - 1]}`;+}++/**+ * Routines setup D: a saved time zone as people say it. "Europe/Kyiv" is "Kyiv time",+ * "Etc/GMT-3" is "UTC+3" (Etc signs are inverted), UTC stays "UTC", anything else comes back unchanged.+ */+export function zoneLabel(tz: string): string {+ const z = (tz ?? '').trim();+ if (z === 'UTC' || z === 'Etc/UTC' || z === 'Etc/GMT' || z === 'Etc/UCT' || z === 'Etc/Universal' || z === 'Etc/Zulu' || z === 'GMT') return 'UTC';+ const etc = /^Etc\/GMT([+-])(\d{1,2})$/.exec(z);+ if (etc) return etc[2] === '0' ? 'UTC' : `UTC${etc[1] === '-' ? '+' : '\u2212'}${etc[2]}`;+ const parts = z.split('/');+ if (parts.length >= 2 && parts.every((p) => /^[A-Za-z][A-Za-z0-9_+-]*$/.test(p)) && !z.startsWith('Etc/')) {+ return `${parts[parts.length - 1].replace(/_/g, ' ')} time`;+ }+ return tz;+}++/** "GMT+2" for a zone right now, from Intl; null when Intl can't say (an unknown zone). */+export function zoneOffset(tz: string, now = new Date()): string | null {+ try {+ const part = new Intl.DateTimeFormat('en', { timeZone: tz, timeZoneName: 'shortOffset' }).formatToParts(now).find((p) => p.type === 'timeZoneName');+ return part ? part.value.replace(/^GMT\+0$/, 'GMT') : null;+ } catch {+ return null;+ }+}++/** Routines setup F: the first non-empty line of a routine's instructions, trimmed, and whether more follows. */+export function firstLine(text: string): { line: string; more: boolean } {+ const lines = (text ?? '').split(/\r?\n/);+ const i = lines.findIndex((l) => l.trim() !== '');+ if (i < 0) return { line: '', more: false };+ return { line: lines[i].trim(), more: lines.slice(i + 1).some((l) => l.trim() !== '') };+}+export function describeSchedule(s: Schedule): string {switch (s.type) {case 'once':return `Once, ${formatWhen(s.at)}`;case 'daily':- return `Every day at ${s.time} (${s.tz})`;- case 'weekly': {- const days = s.weekdays.length === 7 ? 'every day' : s.weekdays.map((d) => WEEKDAYS.find((w) => w.id === d)?.label ?? d).join(', ');- return `${days} at ${s.time} (${s.tz})`;- }+ return `Every day at ${s.time}, ${zoneLabel(s.tz)}`;+ case 'weekly':+ return `${weekdaysText(s.weekdays)} at ${s.time}, ${zoneLabel(s.tz)}`;case 'interval':return s.every_minutes % 60 === 0? `Every ${s.every_minutes / 60} h`: `Every ${s.every_minutes} min`;case 'monthly':- return `Every month on ${monthDaysText(s.days)} at ${s.time} (${s.tz})`;+ return `Every month on ${monthDaysText(s.days)} at ${s.time}, ${zoneLabel(s.tz)}`;case 'cron':- return `Custom rule ${s.expression} (${s.tz})`;+ return `Custom rule ${s.expression}, ${zoneLabel(s.tz)}`;default:return 'Unknown schedule';}diff --git a/frontend/tests/automationDiscovery.test.mjs b/frontend/tests/automationDiscovery.test.mjsindex 0acfecdd..de3b0bb8 100644--- a/frontend/tests/automationDiscovery.test.mjs+++ b/frontend/tests/automationDiscovery.test.mjs@@ -305,7 +305,7 @@ test('Accept → edit → Add routine sends one key, only the edits, and shows tassert.equal(form.querySelector('input[type="checkbox"]:not([role])')?.closest('label').textContent.includes('Enabled'), false, 'no Enabled box: it starts on');// Masked specs are text, never an input that could be edited back into a secretfor (const input of form.querySelectorAll('input, textarea')) assert.ok(!String(input.value).includes('••••'), 'no masked spec in an input');- const name = form.querySelector('input[placeholder="Morning digest"]');+ const name = form.querySelector('input[placeholder="Competitor prices"]');assert.equal(name.value, 'Weekly status report');await act(async () => setValue(name, 'Monday report'));const keepBoxes = [...form.querySelectorAll('fieldset input[type="checkbox"]')];@@ -411,7 +411,7 @@ test('blocked: off is one quiet line; board off and no time zone each show theirtest('empty, loading and error states', async () => {let v = await renderSection({ 'GET /api/automation-discovery': listing({ suggestions: [] }) });- assert.match(v.host.querySelector('[data-testid="discovery-empty"]').textContent, /No suggestions right now\..*at most 2 new suggestions a day/);+ assert.match(v.host.querySelector('[data-testid="discovery-empty"]').textContent, /None right now\..*at most 2 a day\)\./);v.done();g.fetch = () => new Promise(() => {});diff --git a/frontend/tests/botActions.test.mjs b/frontend/tests/botActions.test.mjsindex 7f5fbf3a..23c491da 100644--- a/frontend/tests/botActions.test.mjs+++ b/frontend/tests/botActions.test.mjs@@ -47,7 +47,7 @@ test('applied routine card: summary, routine facts, Undo, Edit and Pause', () =>const t = text(html);assert.match(t, /Coach set up a routine/);assert.match(t, /Created routine 'Morning motivation'/);- assert.match(t, /When Every day at 07:00 \(Europe\/Berlin\)/);+ assert.match(t, /When Every day at 07:00, Berlin time/);assert.match(t, /Runs as Coach/);assert.match(t, /Posts in #general/);assert.match(t, /Next run/);@@ -138,8 +138,8 @@ test('non-routine actions: no routine facts, verb fallback', () => {});test('schedules in words: ours for known shapes, the server text otherwise', () => {- assert.equal(b.scheduleWords({ type: 'monthly', time: '09:00', days: [1, 'last'], tz: 'UTC' }), 'Every month on the 1st and last day at 09:00 (UTC)');- assert.equal(b.scheduleWords({ type: 'cron', expression: '0 9 * * MON#2', tz: 'UTC' }), 'Custom rule 0 9 * * MON#2 (UTC)');+ assert.equal(b.scheduleWords({ type: 'monthly', time: '09:00', days: [1, 'last'], tz: 'UTC' }), 'Every month on the 1st and last day at 09:00, UTC');+ assert.equal(b.scheduleWords({ type: 'cron', expression: '0 9 * * MON#2', tz: 'UTC' }), 'Custom rule 0 9 * * MON#2, UTC');assert.equal(b.scheduleWords({ type: 'lunar' }, 'when the moon is full'), 'When the moon is full');assert.equal(b.scheduleWords(null, ''), 'Unknown schedule');assert.equal(b.asSchedule({ type: 'monthly', time: '09:00', days: [0, 5, 'last', 'x'], tz: 'UTC' }).days.join(), '5,last');diff --git a/frontend/tests/continuity.test.mjs b/frontend/tests/continuity.test.mjsindex dcdc8f69..f703e129 100644--- a/frontend/tests/continuity.test.mjs+++ b/frontend/tests/continuity.test.mjs@@ -196,8 +196,8 @@ test('monthly and cron schedules in plain words', () => {assert.equal(c.monthDaysText([15, 'last', 1]), 'the 1st, 15th and last day');assert.equal(c.monthDaysText([2, 3, 11, 12, 13, 21, 22, 23]), 'the 2nd, 3rd, 11th, 12th, 13th, 21st, 22nd and 23rd');assert.equal(c.monthDaysText(['last']), 'the last day');- assert.equal(c.describeSchedule({ type: 'monthly', time: '09:00', days: [1], tz: 'UTC' }), 'Every month on the 1st at 09:00 (UTC)');- assert.equal(c.describeSchedule({ type: 'cron', expression: '0 9 * * MON#2', tz: 'UTC' }), 'Custom rule 0 9 * * MON#2 (UTC)');+ assert.equal(c.describeSchedule({ type: 'monthly', time: '09:00', days: [1], tz: 'UTC' }), 'Every month on the 1st at 09:00, UTC');+ assert.equal(c.describeSchedule({ type: 'cron', expression: '0 9 * * MON#2', tz: 'UTC' }), 'Custom rule 0 9 * * MON#2, UTC');assert.equal(c.describeSchedule({ type: 'lunar' }), 'Unknown schedule');});@@ -208,3 +208,58 @@ test('memory tab lists pinned notes first, then newest first', () => {assert.deepEqual(c.memoriesForDisplay([m('x', undefined)]).map((x) => x.id), ['x'], 'older servers send no pinned field');assert.equal(c.MAX_PINNED, 10);});++// Routines setup D, E, F (0.9.9)++test('zoneLabel: a saved time zone as a city', () => {+ assert.equal(c.zoneLabel('Europe/Kyiv'), 'Kyiv time');+ assert.equal(c.zoneLabel('America/New_York'), 'New York time');+ assert.equal(c.zoneLabel('America/Argentina/Buenos_Aires'), 'Buenos Aires time');+ for (const z of ['UTC', 'Etc/UTC', 'Etc/GMT']) assert.equal(c.zoneLabel(z), 'UTC', z);+ assert.equal(c.zoneLabel('Etc/GMT-3'), 'UTC+3', 'Etc signs are inverted');+ assert.equal(c.zoneLabel('Etc/GMT+5'), 'UTC\u22125');+ for (const odd of ['', 'Kyiv', 'EST5EDT', 'not a zone/ x', '<b>/x']) assert.equal(c.zoneLabel(odd), odd, odd);+});++test('zoneOffset: Intl shortOffset, or null for a zone Intl does not know', () => {+ assert.equal(c.zoneOffset('UTC'), 'GMT');+ assert.equal(c.zoneOffset('Europe/Kyiv', new Date('2026-11-13T12:00:00Z')), 'GMT+2');+ assert.equal(c.zoneOffset('Europe/Kyiv', new Date('2026-07-01T12:00:00Z')), 'GMT+3');+ assert.equal(c.zoneOffset('Mars/Olympus'), null);+});++test('Weekly starts on today only (a pinned Friday gives Fri)', () => {+ assert.deepEqual(c.emptyScheduleForm(new Date(2026, 10, 13, 12), 'UTC').weekdays, ['fri']);+ assert.deepEqual(c.emptyScheduleForm(new Date(2026, 10, 15, 12), 'UTC').weekdays, ['sun']);+ // A saved Mon–Fri routine keeps its days.+ const saved = { type: 'weekly', time: '08:30', weekdays: ['mon', 'tue', 'wed', 'thu', 'fri'], tz: 'Europe/Kyiv' };+ assert.deepEqual(c.formFromSchedule(saved, new Date(2026, 10, 13, 12)).weekdays, saved.weekdays);+ assert.deepEqual(c.scheduleFromForm(c.formFromSchedule(saved), NOW).schedule, saved);+});++test('sameDays: the Weekdays chip is on only for exactly Mon–Fri', () => {+ assert.equal(c.sameDays(['fri', 'mon', 'tue', 'wed', 'thu'], c.WORK_WEEK), true);+ assert.equal(c.sameDays(['mon', 'tue', 'wed', 'thu'], c.WORK_WEEK), false);+ assert.equal(c.sameDays(['mon', 'tue', 'wed', 'thu', 'fri', 'sat'], c.WORK_WEEK), false);+});++test('describeSchedule writes the zone as a city and names common day sets', () => {+ const w = (weekdays) => c.describeSchedule({ type: 'weekly', time: '09:00', weekdays, tz: 'Europe/Kyiv' });+ assert.equal(c.describeSchedule({ type: 'daily', time: '09:00', tz: 'Europe/Kyiv' }), 'Every day at 09:00, Kyiv time');+ assert.equal(w(['mon']), 'Every Monday at 09:00, Kyiv time');+ assert.equal(w(['fri', 'mon', 'wed']), 'Mon, Wed and Fri at 09:00, Kyiv time');+ assert.equal(w(['mon', 'tue', 'wed', 'thu', 'fri']), 'Weekdays at 09:00, Kyiv time');+ assert.equal(w(['sat', 'sun']), 'Weekends at 09:00, Kyiv time');+ assert.equal(w(['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']), 'Every day at 09:00, Kyiv time');+ assert.equal(w(['tue', 'thu']), 'Tue and Thu at 09:00, Kyiv time');+ assert.equal(c.describeSchedule({ type: 'monthly', time: '07:00', days: [1], tz: 'Europe/Kyiv' }), 'Every month on the 1st at 07:00, Kyiv time');+ assert.equal(c.describeSchedule({ type: 'cron', expression: '0 9 * * MON#2', tz: 'Europe/Kyiv' }), 'Custom rule 0 9 * * MON#2, Kyiv time');+ assert.equal(c.describeSchedule({ type: 'interval', every_minutes: 120 }), 'Every 2 h');+});++test('firstLine: the first non-empty line, and whether more follows', () => {+ assert.deepEqual(c.firstLine('Check prices.'), { line: 'Check prices.', more: false });+ assert.deepEqual(c.firstLine('\n \n Check prices. \r\nThen post.\n'), { line: 'Check prices.', more: true });+ assert.deepEqual(c.firstLine('Only one\n\n \n'), { line: 'Only one', more: false });+ assert.deepEqual(c.firstLine(''), { line: '', more: false });+});diff --git a/frontend/tests/routinesSetup.test.mjs b/frontend/tests/routinesSetup.test.mjsnew file mode 100644index 00000000..bb9112b2--- /dev/null+++ b/frontend/tests/routinesSetup.test.mjs@@ -0,0 +1,123 @@+// Routines setup (0.9.9, Mira's audit #9): the sidebar row, the card's first line and next run,+// the time zone as a city with Change, and the Weekdays shortcut chip.+import assert from 'node:assert/strict';+import test from 'node:test';+import { loadBundled } from './bundle.mjs';++globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };++const ui = await loadBundled(`+ import React from 'react';+ import { renderToStaticMarkup } from 'react-dom/server.browser';+ import { RoutineRow, RoutineForm } from './src/components/RoutinesPanel';+ import { Sidebar } from './src/components/Sidebar';+ const r = (C) => (props) => renderToStaticMarkup(React.createElement(C, props));+ export const row = r(RoutineRow);+ export const form = r(RoutineForm);+ export const sidebar = r(Sidebar);+`);++const noop = () => {};+const text = (html) => html.replace(/<[^>]+>/g, '').replace(/\s+/g, ' ');+const routine = (over = {}) => ({+ id: 'r1', kwant_id: 'k1', channel_id: null, name: 'Competitor prices',+ instructions: 'Check Beanline and RoastCo prices and tell me what changed since last week.',+ schedule: { type: 'weekly', time: '09:00', weekdays: ['mon'], tz: 'Europe/Kyiv' }, enabled: true,+ next_run_at: '2026-11-16T07:00:00Z', last_run_at: '2026-11-09T07:00:00Z', last_status: 'ok', created_at: '2026-10-20T08:00:00Z', ...over,+});+const rowProps = (over = {}) => ({ routine: routine(over), kwantName: 'Ben', placeLabel: '#spring-launch', tick: 0, onEdit: noop, onChanged: noop });++test('the card says what it does, then when it runs next, then schedule · bot · place', () => {+ const h = ui.row(rowProps());+ const t = text(h);+ assert.match(h, /data-routine-what[^>]*>Check Beanline and RoastCo prices and tell me what changed since last week\.</);+ assert.match(h, /title="Check Beanline/);+ assert.match(t, /Next [A-Z][a-z]{2}, Nov 1[56]/);+ assert.match(t, /last ran Mon, Nov 9/);+ assert.match(t, /Every Monday at 09:00, Kyiv time · Ben · #spring-launch/);+ assert.doesNotMatch(t, /Next run:|\(Europe\/Kyiv\)/);+ // Order: name, first line, next, meta.+ assert.ok(t.indexOf('Competitor prices') < t.indexOf('Check Beanline'));+ assert.ok(t.indexOf('Check Beanline') < t.indexOf('Next '));+ assert.ok(t.indexOf('Next ') < t.indexOf('Every Monday'));+});++test('a multi-line routine shows its first line with an ellipsis; the whole text is in the title', () => {+ const h = ui.row(rowProps({ instructions: '\n Summarise new web orders.\nThen list anyone waiting on a reply.' }));+ assert.match(h, /data-routine-what[^>]*>Summarise new web orders\. …</);+});++test('a paused routine says Paused and mutes its name and first line', () => {+ const h = ui.row(rowProps({ enabled: false }));+ assert.match(h, /text-zinc-300 font-medium">Paused</);+ assert.doesNotMatch(text(h), /Next /);+ assert.match(h, /font-medium break-words text-zinc-400">Competitor prices</);+});++test('a Mon–Fri routine reads "Weekdays at …"', () => {+ const t = text(ui.row(rowProps({ schedule: { type: 'weekly', time: '08:30', weekdays: ['mon', 'tue', 'wed', 'thu', 'fri'], tz: 'Europe/Kyiv' } })));+ assert.match(t, /Weekdays at 08:30, Kyiv time/);+});++test('phone: the four actions sit in a 4-column grid of 44 px buttons; desktop keeps the indented row', () => {+ const h = ui.row(rowProps());+ assert.match(h, /grid grid-cols-4 gap-1\.5 sm:flex sm:flex-wrap sm:items-center sm:pl-9/);+ assert.equal((h.match(/min-h-11 sm:min-h-0 justify-center whitespace-nowrap/g) || []).length, 4, 'each label stays on one line');+ // Like History's chevron, Run now's Play icon is desktop only, so "Run now" fits a phone column.+ assert.match(h, /hidden sm:block[^"]*lucide-play|lucide-play[^"]*hidden sm:block/);+});++test('Settings scrolls the open tab into view (phone tab strip), without motion', async () => {+ const { readFileSync } = await import('node:fs');+ const s = readFileSync(new URL('../src/components/SpaceSettings.tsx', import.meta.url), 'utf8');+ assert.match(s, /ref=\{tab === t\.id \? currentTabRef : undefined\}\s*aria-current=\{tab === t\.id \? 'page'/);+ assert.match(s, /currentTabRef\.current\?\.scrollIntoView\?\.\(\{ block: 'nearest', inline: 'nearest' \}\);\s*\}, \[tab, scope\]\)/);+});++const kwants = [{ id: 'k1', name: 'Ben' }];+const weekly = { kwant_id: 'k1', channel_id: null, name: 'x', instructions: 'y', schedule: { type: 'weekly', time: '09:00', weekdays: ['fri'], tz: 'Europe/Kyiv' } };++test('the new form has the paired example placeholders', () => {+ const h = ui.form({ kwants, channels: [], onCancel: noop, onSaved: noop });+ assert.match(h, /placeholder="Competitor prices"/);+ assert.match(h, /placeholder="Check our 3 competitors' prices and tell me what changed since last time\."/);+});++test('the time zone shows as a city with its offset and Change; the full id is in the title', () => {+ const h = ui.form({ kwants, channels: [], seed: weekly, onCancel: noop, onSaved: noop });+ assert.match(h, /title="Europe\/Kyiv"[^>]*data-tz-row/);+ assert.match(text(h), /Kyiv time\s*GMT\+[23]\s*Change/);+ assert.match(h, /data-tz-change/);+ assert.doesNotMatch(h, /<datalist/);+});++test('a zone Intl does not know starts open, so the saved value shows', () => {+ const h = ui.form({ kwants, channels: [], seed: { ...weekly, schedule: { ...weekly.schedule, tz: 'Mars/Olympus' } }, onCancel: noop, onSaved: noop });+ assert.match(h, /value="Mars\/Olympus"/);+ assert.doesNotMatch(h, /data-tz-change/);+});++test('Weekly has a Weekdays chip, pressed only for exactly Mon–Fri, and every day chip has a focus ring', () => {+ const one = ui.form({ kwants, channels: [], seed: weekly, onCancel: noop, onSaved: noop });+ assert.match(one, /aria-pressed="false" aria-label="Weekdays, Monday to Friday"/);+ assert.match(one, /Weekdays<span class="sm:hidden"> \(Mon–Fri\)<\/span>/);+ const days = one.match(/<button[^>]*aria-pressed="(true|false)"[^>]*>(Mon|Tue|Wed|Thu|Fri|Sat|Sun)</g);+ assert.equal(days.length, 7);+ for (const d of days) assert.match(d, /focus-visible:outline-sky-500/);+ const five = ui.form({ kwants, channels: [], seed: { ...weekly, schedule: { ...weekly.schedule, weekdays: ['mon', 'tue', 'wed', 'thu', 'fri'] } }, onCancel: noop, onSaved: noop });+ assert.match(five, /aria-pressed="true" aria-label="Weekdays, Monday to Friday"/);+});++test('the sidebar has a Routines row after Mission board only when it can open them', () => {+ const space = { id: 'spc_default', name: 'Default', icon: '💼', color: '#f59e0b', sort: 0, is_default: true, archived_at: null,+ created_at: '', general_channel_id: null, counts: { bots: 0, ready_accounts: 0, unread: 0 } };+ const base = { space, spaces: [space], onSwitchSpace: noop, onCreateSpace: noop, onOpenSpaceSettings: noop, onOpenArchived: noop,+ onOpenSearch: noop, kwants: [], channels: [], teams: [], selectedId: '', isChannel: true, onSelectKwant: noop, onSelectChannel: noop,+ onSelectTeam: noop, onSummonKwant: noop, onCreateTeam: noop, onOpenInbox: noop, missionBoard: true, onOpenMissions: noop };+ assert.doesNotMatch(ui.sidebar(base), /data-routines-row/);+ const h = ui.sidebar({ ...base, onOpenRoutines: noop });+ assert.match(h, /data-routines-row/);+ const row = h.slice(h.indexOf('data-routines-row') - 300, h.indexOf('data-routines-row') + 600);+ assert.doesNotMatch(row.slice(row.lastIndexOf('<button')), /aria-current/);+ assert.ok(h.indexOf('Mission board') < h.indexOf('>Routines<'), 'after Mission board');+});