Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(web): translate the Routines panel
Kilyn3187041d6d71
diff --git a/apps/web/src/features/rooms/agent-templates/agent-template-contents.tsx b/apps/web/src/features/rooms/agent-templates/agent-template-contents.tsxindex d140ef5b..087fb409 100644--- a/apps/web/src/features/rooms/agent-templates/agent-template-contents.tsx+++ b/apps/web/src/features/rooms/agent-templates/agent-template-contents.tsx@@ -100,7 +100,7 @@ export function TemplateContents({name: routine.name,instruction: routine.instruction,detail: t(routine.enabled ? m.routineEnabled : m.routinePaused, {- cadence: cadenceLabel(routine.cadence),+ cadence: cadenceLabel(routine.cadence, t),timezone: routine.cadence.timezone,}),})),diff --git a/apps/web/src/features/rooms/task-sidebar/reminders-panel.tsx b/apps/web/src/features/rooms/task-sidebar/reminders-panel.tsxindex dda9d441..b86b6662 100644--- a/apps/web/src/features/rooms/task-sidebar/reminders-panel.tsx+++ b/apps/web/src/features/rooms/task-sidebar/reminders-panel.tsx@@ -23,6 +23,7 @@ import type {TeamHubRoutine,TeamHubScheduledRoutine,} from "@/features/teamhub/teamhub-types";+import { useT } from "@/i18n/use-translation";import { connectedAppDisplayName } from "../cards/connected-app-names";@@ -41,6 +42,7 @@ import {} from "./routine-cadence";import { deleteRoomRoutine, RoutineDialog } from "./routine-dialog";import { PanelLoading } from "./panel-loading";+import { routinesMessages as m } from "./routines.messages";/** One Agent's Routines in a Room, laid out by the day they next run. */export function RemindersPanel({@@ -57,6 +59,7 @@ export function RemindersPanel({roomId: string;tenantId: string;}) {+ const t = useT();const { client } = useTeamHubRuntime();const queryClient = useQueryClient();const listQuery = useQuery(@@ -79,7 +82,7 @@ export function RemindersPanel({return (<section- aria-label="Routines"+ aria-label={t(m.routines)}className="workspace-scrollbar flex h-full min-h-0 flex-col overflow-y-auto [scrollbar-gutter:stable_both-edges]"data-testid="panel-routines"hidden={hidden || undefined}@@ -151,6 +154,7 @@ function RoutineAgenda({routines: TeamHubRoutine[];tenantId: string;}) {+ const t = useT();const queryClient = useQueryClient();const [showDone, setShowDone] = useState(false);const [deleteError, setDeleteError] = useState<string | null>(null);@@ -193,12 +197,12 @@ function RoutineAgenda({return () => window.clearTimeout(timer);}, [offer, undo.isPending]);if (loading) {- return <PanelLoading label="Loading routines" />;+ return <PanelLoading label={t(m.loading)} />;}if (failed) {return (<p className="px-4 py-6 text-sm text-destructive" role="alert">- Routines could not be loaded.+ {t(m.loadFailed)}</p>);}@@ -244,23 +248,22 @@ function RoutineAgenda({</p>) : null}{scheduled.length === 0 && listeners.length === 0 ? (- <SettingsGroup ariaLabel="No routines">+ <SettingsGroup ariaLabel={t(m.noRoutines)}><SettingsRow icon={<Icon icon={Clock01Icon} size={16} />}><span className="min-w-0 flex-1 py-1"><span className="block text-[14px] font-medium leading-[18px] text-foreground">- No routines in this room yet.+ {t(m.emptyTitle)}</span><span className="mt-0.5 block text-xs leading-[17px] text-muted-foreground">- Run something once at a set time, or daily, weekly, or every few- hours.+ {t(m.emptyBody)}</span></span></SettingsRow></SettingsGroup>) : null}{listeners.length > 0 ? (- <SettingsGroup label="Watching">- <ul aria-label="App listeners">+ <SettingsGroup label={t(m.watching)}>+ <ul aria-label={t(m.appListeners)}>{listeners.map((routine) => (<ListenerRowclient={client}@@ -274,17 +277,25 @@ function RoutineAgenda({</SettingsGroup>) : null}{upcoming.length > 0 ? (- <SettingsGroup label="Upcoming" meta={upcoming.length}>+ <SettingsGroup label={t(m.upcoming)} meta={upcoming.length}><ul>{upcoming.map((routine) => {- const { day, distance } = dayHeading(new Date(runTime(routine)));+ const { day, distance } = dayHeading(+ new Date(runTime(routine)),+ new Date(),+ t,+ );const time = formatTimeOfDay(new Date(runTime(routine)).toISOString(),);return (<RoutineRow{...rowProps}- detail={[day, time, distance].filter(Boolean).join(" · ")}+ detail={+ distance+ ? t(m.upcomingDetailDistance, { day, time, distance })+ : t(m.upcomingDetail, { day, time })+ }key={routine.id}routine={routine}onOpen={() => onOpen(routine.id)}@@ -295,12 +306,12 @@ function RoutineAgenda({</SettingsGroup>) : null}{recurring.length > 0 ? (- <SettingsGroup label="Recurring" meta={recurring.length}>+ <SettingsGroup label={t(m.recurring)} meta={recurring.length}><ul>{recurring.map((routine) => (<RoutineRow{...rowProps}- detail={cadenceLabel(routine.cadence)}+ detail={cadenceLabel(routine.cadence, t)}key={routine.id}routine={routine}onOpen={() => onOpen(routine.id)}@@ -310,7 +321,7 @@ function RoutineAgenda({</SettingsGroup>) : null}{paused.length > 0 ? (- <SettingsGroup label="Paused" meta={paused.length}>+ <SettingsGroup label={t(m.paused)} meta={paused.length}><ul>{paused.map((routine) => (<RoutineRow@@ -318,7 +329,7 @@ function RoutineAgenda({detail={routine.cadence.kind === "once"? formatWhen(routine.cadence.run_at ?? "")- : cadenceLabel(routine.cadence)+ : cadenceLabel(routine.cadence, t)}key={routine.id}routine={routine}@@ -329,7 +340,7 @@ function RoutineAgenda({</SettingsGroup>) : null}{done.length > 0 ? (- <section aria-label="Done">+ <section aria-label={t(m.done)}><div className="px-1.5"><buttonaria-expanded={showDone}@@ -337,7 +348,7 @@ function RoutineAgenda({onClick={() => setShowDone((current) => !current)}type="button">- Done+ {t(m.done)}<span className="tabular-nums text-muted-foreground/80">{done.length}</span>@@ -348,7 +359,7 @@ function RoutineAgenda({</button></div>{showDone ? (- <SettingsGroup ariaLabel="Done routines">+ <SettingsGroup ariaLabel={t(m.doneRoutines)}><ul>{done.map((routine) => (<li key={routine.id}>@@ -382,7 +393,7 @@ function RoutineAgenda({><SettingsRow icon={<Icon icon={PlusSignIcon} size={16} />}><span className="flex-1 text-[14px] font-medium text-foreground">- New routine+ {t(m.newRoutine)}</span><IconclassName="text-muted-foreground/70"@@ -432,6 +443,7 @@ function RoutineRow({onOpen: () => void;routine: TeamHubScheduledRoutine;}) {+ const t = useT();const wakesOther = Boolean(routine.mention_actor_id && routine.mention_actor_id !== agentActorId,);@@ -443,12 +455,13 @@ function RoutineRow({(item) => item.actor.id === routine.mention_actor_id,);// The Agent whose Info this is goes without saying; say who else wakes.- const audience = !routine.mention_actor_id- ? "Message only"- : wakesOther- ? `Wakes ${target?.actor.display_name ?? "an Agent"}`- : undefined;- const description = [detail, audience].filter(Boolean).join(" · ");+ const description = !routine.mention_actor_id+ ? t(m.detailMessageOnly, { detail })+ : !wakesOther+ ? detail+ : target+ ? t(m.detailWakes, { detail, name: target.actor.display_name })+ : t(m.detailWakesAgent, { detail });if (!isEditableRoutine(routine)) {return (<li>@@ -505,6 +518,7 @@ function RoutineDeleteButton({routine: TeamHubScheduledRoutine;tenantId: string;}) {+ const t = useT();const queryClient = useQueryClient();const remove = useMutation({mutationFn: () => deleteRoomRoutine(client, routine),@@ -516,17 +530,16 @@ function RoutineDeleteButton({});},onError: (cause) =>- onError(- cause instanceof Error ? cause.message : "Could not delete routine.",- ),+ onError(cause instanceof Error ? cause.message : t(m.deleteFailed)),});return (<button- aria-label="Delete routine"+ data-voice-risk="never"+ aria-label={t(m.deleteRoutine)}className="flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"disabled={remove.isPending}onClick={() => remove.mutate()}- title="Delete routine"+ title={t(m.deleteRoutine)}type="button"><Icon icon={Delete02Icon} size={14} />@@ -538,6 +551,7 @@ function ListenerRow({routine,...toggle}: ToggleProps & { routine: TeamHubRoutine }) {+ const t = useT();const app = connectedAppDisplayName(routine.listener?.app);return (<li>@@ -551,7 +565,7 @@ function ListenerRow({<SettingsRowTextdescription={routine.name}muted={!routine.enabled}- title={routine.enabled ? `Watching ${app}` : `Not watching ${app}`}+ title={t(routine.enabled ? m.watchingApp : m.notWatchingApp, { app })}/><RoutineSwitch routine={routine} {...toggle} /></SettingsRow>@@ -565,6 +579,7 @@ function RoutineSwitch({routine,tenantId,}: ToggleProps & { routine: TeamHubRoutine }) {+ const t = useT();const queryClient = useQueryClient();const toggle = useMutation({mutationFn: (enabled: boolean) =>@@ -587,7 +602,7 @@ function RoutineSwitch({return (<buttonaria-checked={routine.enabled}- aria-label={routine.enabled ? "Pause routine" : "Enable routine"}+ aria-label={t(routine.enabled ? m.pauseRoutine : m.enableRoutine)}className={`relative h-4 w-7 shrink-0 rounded-full shadow-sm transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${routine.enabled ? "bg-primary" : "bg-input"}`}disabled={toggle.isPending}onClick={() => toggle.mutate(!routine.enabled)}@@ -614,6 +629,7 @@ function UndoToast({routine: TeamHubRoutine;secondsLeft: number;}) {+ const t = useT();return (<divclassName="town-toast-enter flex items-center gap-3 rounded-xl bg-popover px-4 py-2.5 text-sm text-foreground shadow-lg"@@ -621,8 +637,10 @@ function UndoToast({><span className="min-w-0 flex-1 truncate">{failed- ? "Could not undo."- : `${routine.enabled ? "Enabled" : "Paused"} “${routine.name}”`}+ ? t(m.undoFailed)+ : t(routine.enabled ? m.enabledRoutine : m.pausedRoutine, {+ name: routine.name,+ })}</span>{failed ? null : (<>@@ -659,7 +677,7 @@ function UndoToast({onClick={onUndo}type="button">- Undo+ {t(m.undo)}</button></>)}diff --git a/apps/web/src/features/rooms/task-sidebar/routine-cadence.ts b/apps/web/src/features/rooms/task-sidebar/routine-cadence.tsindex 4ce8eb0f..ce3dc237 100644--- a/apps/web/src/features/rooms/task-sidebar/routine-cadence.ts+++ b/apps/web/src/features/rooms/task-sidebar/routine-cadence.ts@@ -3,6 +3,9 @@ import type {TeamHubRoutineCadence,TeamHubScheduledRoutine,} from "@/features/teamhub/teamhub-types";+import { type Translate, formatLocale, translate } from "@/i18n/language";++import { routinesMessages as m } from "./routines.messages";export const WEEKDAYS = ["monday",@@ -52,7 +55,7 @@ export function draftFromRoutine(routine: TeamHubScheduledRoutine,): RoutineDraft {if (routine.cadence.kind === "every_n_minutes") {- throw new Error("Minute-interval routines can only be edited by an Agent.");+ throw new Error(translate(m.minuteIntervalAgentOnly));}const hour = String(routine.cadence.hour ?? 9).padStart(2, "0");const minute = String(routine.cadence.minute ?? 0).padStart(2, "0");@@ -82,7 +85,7 @@ export function cadenceFromDraft(draft: RoutineDraft): TeamHubRoutineCadence {if (draft.kind === "once") {const runAt = new Date(draft.runAt);if (!draft.runAt || Number.isNaN(runAt.getTime()))- throw new Error("Choose when the Routine runs.");+ throw new Error(translate(m.chooseWhen));return { kind: "once", timezone, run_at: runAt.toISOString() };}if (draft.kind === "every_n_hours") {@@ -97,7 +100,7 @@ export function cadenceFromDraft(draft: RoutineDraft): TeamHubRoutineCadence {const minute = Number(minuteRaw);if (draft.kind === "weekly") {if (draft.weekdays.length === 0)- throw new Error("Choose at least one weekday.");+ throw new Error(translate(m.chooseWeekday));return {kind: "weekly",timezone,@@ -109,90 +112,110 @@ export function cadenceFromDraft(draft: RoutineDraft): TeamHubRoutineCadence {return { kind: "daily", timezone, hour, minute };}-export function cadenceLabel(cadence: TeamHubRoutineCadence) {- if (cadence.kind === "every_n_hours" || cadence.kind === "every_n_minutes")- return repeatLabel(cadence);- return `${repeatLabel(cadence)} · ${cadenceClock(cadence)}`;-}--/** How often a Routine runs, without its time of day. */-function repeatLabel(cadence: TeamHubRoutineCadence) {+/**+ * A Routine's schedule as one sentence in the language on screen, such as+ * "Mon–Fri · 9:00 AM". Times and weekday names come from Intl.+ */+export function cadenceLabel(+ cadence: TeamHubRoutineCadence,+ t: Translate = translate,+) {if (cadence.kind === "every_n_minutes") {- return `Every ${cadence.interval_minutes ?? 10} min`;+ return t(m.everyMinutes, { count: cadence.interval_minutes ?? 10 });}if (cadence.kind === "every_n_hours") {- const hours = cadence.interval_hours ?? 1;- return hours === 1 ? "Every hour" : `Every ${hours} hours`;+ return t(m.everyHours, { count: cadence.interval_hours ?? 1 });}- if (cadence.kind === "once") return "Once";- if (cadence.kind === "daily") return "Daily";+ if (cadence.kind === "once") {+ return cadence.run_at+ ? t(m.onceAt, { when: formatWhen(cadence.run_at) })+ : t(m.once);+ }+ const time = formatClock(cadence.hour ?? 0, cadence.minute ?? 0);+ if (cadence.kind === "daily") return t(m.dailyAt, { time });const days = cadence.weekdays ?? [];const ordered = WEEKDAYS.filter((day) => days.includes(day));- if (ordered.length === 7) return "Every day";- if (ordered.join(",") === WEEKDAYS.slice(0, 5).join(",")) return "Mon–Fri";- return (- ordered- .map(- (day) =>- day[0]!.toUpperCase() +- day.slice(1, ordered.length === 1 ? undefined : 3),- )- .join(", ") || "Weekly"- );-}--/** When in the day a Routine runs; a once Routine also names its date. */-function cadenceClock(cadence: TeamHubRoutineCadence) {- if (cadence.kind === "every_n_minutes")- return `${cadence.interval_minutes ?? 10}m`;- if (cadence.kind === "every_n_hours")- return `${cadence.interval_hours ?? 1}h`;- if (cadence.kind === "once") {- return cadence.run_at ? formatWhen(cadence.run_at) : "";+ if (ordered.length === 7) return t(m.everyDayAt, { time });+ if (ordered.join(",") === WEEKDAYS.slice(0, 5).join(",")) {+ return t(m.mondayToFridayAt, { time });}- return formatClock(cadence.hour ?? 0, cadence.minute ?? 0);+ if (ordered.length === 0) return t(m.weeklyAt, { time });+ const width = ordered.length === 1 ? "long" : "short";+ return t(m.weekdaysAt, {+ days: ordered+ .map((day) => weekdayName(day, width))+ .join(t(m.weekdaySeparator)),+ time,+ });}-const nextRunFormat = new Intl.DateTimeFormat("en-US", {- month: "short",- day: "numeric",- hour: "numeric",- minute: "2-digit",-});--const clockFormat = new Intl.DateTimeFormat("en-US", {- hour: "numeric",- minute: "2-digit",-});--const dayFormat = new Intl.DateTimeFormat("en-US", {- month: "short",- day: "numeric",-});+/** The name of a weekday in the language on screen, such as "Monday" or "Mon". */+export function weekdayName(+ weekday: (typeof WEEKDAYS)[number],+ width: "long" | "short",+) {+ // 1 January 2024 was a Monday.+ return new Intl.DateTimeFormat(formatLocale(), {+ weekday: width,+ timeZone: "UTC",+ }).format(new Date(Date.UTC(2024, 0, 1 + WEEKDAYS.indexOf(weekday))));+}export function formatTimeOfDay(value: string) {const date = new Date(value);- return Number.isNaN(date.getTime()) ? value : clockFormat.format(date);+ return Number.isNaN(date.getTime()) ? value : clockFormat().format(date);}/** "Today", "Tomorrow", or the date, plus how many days away it is. */-export function dayHeading(date: Date, now = new Date()) {+export function dayHeading(+ date: Date,+ now = new Date(),+ t: Translate = translate,+) {const startOf = (value: Date) =>new Date(value.getFullYear(), value.getMonth(), value.getDate()).getTime();const days = Math.round((startOf(date) - startOf(now)) / 86_400_000);- if (days <= 0) return { day: "Today", distance: "" };- if (days === 1) return { day: "Tomorrow", distance: "" };- return { day: dayFormat.format(date), distance: `in ${days} days` };+ if (days <= 0) return { day: t(m.today), distance: "" };+ if (days === 1) return { day: t(m.tomorrow), distance: "" };+ return {+ day: new Intl.DateTimeFormat(formatLocale(), {+ month: "short",+ day: "numeric",+ }).format(date),+ distance: t(m.inDays, { count: days }),+ };}export function formatWhen(value: string) {const date = new Date(value);if (Number.isNaN(date.getTime())) return value;- return nextRunFormat.format(date);+ return new Intl.DateTimeFormat(formatLocale(), {+ month: "short",+ day: "numeric",+ hour: "numeric",+ minute: "2-digit",+ }).format(date);}-function formatClock(hour: number, minute: number) {+/** A time of day such as "9:00 AM", in the language on screen. */+export function formatClock(hour: number, minute: number) {const date = new Date();date.setHours(hour, minute, 0, 0);- return clockFormat.format(date);+ return clockFormat().format(date);+}++/** A whole hour such as "9 AM", in the language on screen. */+export function formatHour(hour: number) {+ const date = new Date();+ date.setHours(hour, 0, 0, 0);+ return new Intl.DateTimeFormat(formatLocale(), { hour: "numeric" }).format(+ date,+ );+}++function clockFormat() {+ return new Intl.DateTimeFormat(formatLocale(), {+ hour: "numeric",+ minute: "2-digit",+ });}diff --git a/apps/web/src/features/rooms/task-sidebar/routine-dialog.tsx b/apps/web/src/features/rooms/task-sidebar/routine-dialog.tsxindex d661141b..a75ab657 100644--- a/apps/web/src/features/rooms/task-sidebar/routine-dialog.tsx+++ b/apps/web/src/features/rooms/task-sidebar/routine-dialog.tsx@@ -10,6 +10,10 @@ import type {TeamHubActorRef,TeamHubScheduledRoutine,} from "@/features/teamhub/teamhub-types";+import { commonMessages } from "@/i18n/common.messages";+import { translate } from "@/i18n/language";+import type { Message } from "@/i18n/messages";+import { useT } from "@/i18n/use-translation";import {WEEKDAYS,@@ -17,28 +21,26 @@ import {cadenceLabel,draftFromRoutine,emptyRoutineDraft,+ formatHour,formatWhen,type RoutineDraft,+ weekdayName,} from "./routine-cadence";import { RoutineTimeField } from "./routine-time-field";+import { routinesMessages as m } from "./routines.messages";type When = "tomorrow" | "date" | "daily" | "weekdays" | "weekly" | "hours";-const WHENS: [When, string][] = [- ["tomorrow", "Tomorrow"],- ["date", "Pick a date"],- ["daily", "Every day"],- ["weekdays", "Weekdays"],- ["weekly", "Every week"],- ["hours", "Every few hours"],+const WHENS: [When, Message<string>][] = [+ ["tomorrow", m.whenTomorrow],+ ["date", m.whenDate],+ ["daily", m.whenDaily],+ ["weekdays", m.whenWeekdays],+ ["weekly", m.whenWeekly],+ ["hours", m.whenHours],];const MON_FRI = WEEKDAYS.slice(0, 5);-const QUICK_TIMES = [- ["08:00", "8 AM"],- ["09:00", "9 AM"],- ["12:00", "12 PM"],- ["18:00", "6 PM"],-] as const;+const QUICK_HOURS = [8, 9, 12, 18];const INTERVALS = [1, 2, 3, 4, 6, 12];function localDay(offset = 0) {@@ -106,6 +108,7 @@ export function RoutineDialog({roomId: string;routine?: TeamHubScheduledRoutine;}) {+ const t = useT();const [draft, setDraft] = useState<RoutineDraft>(() => initialDraft(routine));const [name, setName] = useState(routine?.name ?? "");const [mention, setMention] = useState(@@ -116,15 +119,15 @@ export function RoutineDialog({const [error, setError] = useState<string | null>(null);const update = (patch: Partial<RoutineDraft>) =>setDraft((current) => ({ ...current, ...patch }));- const fail = (fallback: string) => (cause: unknown) =>- setError(cause instanceof Error ? cause.message : fallback);+ const fail = (fallback: Message<string>) => (cause: unknown) =>+ setError(cause instanceof Error ? cause.message : translate(fallback));const save = useMutation({mutationFn: async () => {const cadence = cadenceFromDraft(draft);const nextName = name.trim() || routineName(draft);if (!draft.instruction.trim())- throw new Error("Say what the Routine should do.");+ throw new Error(translate(m.instructionRequired));if (routine) {await teamHubData(client.api.PATCH("/v0/routines/{routineId}", {@@ -154,7 +157,7 @@ export function RoutineDialog({);},onSuccess: onSaved,- onError: fail("Could not save routine."),+ onError: fail(m.saveFailed),});const remove = useMutation({mutationFn: async () => {@@ -162,7 +165,7 @@ export function RoutineDialog({await deleteRoomRoutine(client, routine);},onSuccess: onSaved,- onError: fail("Could not delete routine."),+ onError: fail(m.deleteFailed),});const runNow = useMutation({mutationFn: async () => {@@ -174,7 +177,7 @@ export function RoutineDialog({);},onSuccess: onSaved,- onError: fail("Could not run routine."),+ onError: fail(m.runFailed),});const cadence = (() => {@@ -191,8 +194,9 @@ export function RoutineDialog({mention === (routine.mention_actor_id ?? "");const nextRun =unchanged && routine.enabled && routine.next_run_at- ? `Next ${formatWhen(routine.next_run_at)}`+ ? formatWhen(routine.next_run_at): "";+ const schedule = cadence ? cadenceLabel(cadence, t) : t(m.chooseTime);return (<ModalDialog@@ -201,13 +205,14 @@ export function RoutineDialog({<>{routine ? (<Button+ data-voice-risk="never"className="mr-auto text-destructive hover:text-destructive"disabled={remove.isPending}onClick={() => remove.mutate()}tone="ghost"type="button">- Delete+ {t(commonMessages.delete)}</Button>) : null}{routine ? (@@ -216,7 +221,7 @@ export function RoutineDialog({onClick={() => runNow.mutate()}type="button">- Run now+ {t(m.runNow)}</Button>) : null}<Button@@ -225,13 +230,13 @@ export function RoutineDialog({tone="primary"type="submit">- {routine ? "Save" : "Create"}+ {routine ? t(commonMessages.save) : t(m.create)}</Button></>}onClose={onClose}size="md"- title={routine ? "Edit routine" : "New routine"}+ title={routine ? t(m.editRoutine) : t(m.newRoutine)}><formclassName="flex flex-col gap-4 px-5 py-4"@@ -244,7 +249,7 @@ export function RoutineDialog({><div><span className="block text-xs font-medium text-foreground">- When+ {t(m.when)}</span><WhenEditordraft={draft}@@ -253,23 +258,24 @@ export function RoutineDialog({update={update}/><p className="mt-2 truncate text-xs tabular-nums text-muted-foreground">- {cadence ? cadenceLabel(cadence) : "Choose a time"}- {cadence && nextRun ? ` · ${nextRun}` : ""}+ {cadence && nextRun+ ? t(m.summaryWithNext, { cadence: schedule, when: nextRun })+ : schedule}</p></div><label className="block text-xs font-medium text-foreground">- Instruction+ {t(m.instruction)}<textareaclassName={`${FIELD} mt-1 min-h-28 w-full py-2 leading-relaxed`}onChange={(event) => update({ instruction: event.target.value })}- placeholder="What should it do then?"+ placeholder={t(m.instructionPlaceholder)}requiredvalue={draft.instruction}/></label>{!agentScoped ? (<label className="block text-xs font-medium text-foreground">- Name (optional)+ {t(m.nameOptional)}<inputclassName={`${FIELD} mt-1 h-9 w-full`}maxLength={120}@@ -280,15 +286,15 @@ export function RoutineDialog({) : null}{!agentScoped && (mentionOptions.length > 0 || mention) ? (<label className="block text-xs font-medium text-foreground">- Mention+ {t(m.mention)}<Select- aria-label="Mention"+ aria-label={t(m.mention)}className="mt-1 w-full font-normal"disabled={!routine && Boolean(mentionActorId)}onValueChange={setMention}value={mention}>- <SelectItem value="">None</SelectItem>+ <SelectItem value="">{t(m.mentionNone)}</SelectItem>{mentionOptions.map((agent) => (<SelectItem key={agent.id} value={agent.id}>{agent.display_name}@@ -296,7 +302,7 @@ export function RoutineDialog({))}{mention &&!mentionOptions.some((agent) => agent.id === mention) ? (- <SelectItem value={mention}>Current Agent</SelectItem>+ <SelectItem value={mention}>{t(m.currentAgent)}</SelectItem>) : null}</Select></label>@@ -325,6 +331,7 @@ function WhenEditor({pickDate: boolean;update: (patch: Partial<RoutineDraft>) => void;}) {+ const t = useT();const when = whenOf(draft, pickDate);const day = draft.runAt.slice(0, 10) || localDay(1);const setTime = (time: string) =>@@ -360,24 +367,24 @@ function WhenEditor({return (<div className="mt-1 flex flex-col gap-2.5"><Select- aria-label="When"+ aria-label={t(m.when)}className="w-full font-normal"onValueChange={(value) => choose(value as When)}value={when}>{WHENS.map(([value, label]) => (<SelectItem key={value} value={value}>- {label}+ {t(label)}</SelectItem>))}</Select>{draft.kind === "weekly" ? (<fieldset className="flex flex-wrap gap-1.5">- <legend className="sr-only">Weekdays</legend>+ <legend className="sr-only">{t(m.weekdays)}</legend>{WEEKDAYS.map((weekday) => (<label className="cursor-pointer" key={weekday}><input- aria-label={weekday[0]!.toUpperCase() + weekday.slice(1)}+ aria-label={weekdayName(weekday, "long")}checked={draft.weekdays.includes(weekday)}className="sr-only"onChange={(event) =>@@ -392,7 +399,7 @@ function WhenEditor({type="checkbox"/><span className="select-pill w-11 justify-center px-0">- {weekday[0]!.toUpperCase() + weekday.slice(1, 3)}+ {weekdayName(weekday, "short")}</span></label>))}@@ -400,7 +407,9 @@ function WhenEditor({) : null}{draft.kind === "every_n_hours" ? (<div className="flex flex-wrap items-center gap-1.5">- <span className="mr-1 text-xs text-muted-foreground">Every</span>+ <span className="mr-1 text-xs text-muted-foreground">+ {t(m.every)}+ </span>{[...new Set([...INTERVALS, draft.intervalHours])].sort((left, right) => left - right).map((hours) => (@@ -411,7 +420,7 @@ function WhenEditor({onClick={() => update({ intervalHours: hours })}type="button">- {hours}h+ {t(m.hoursShort, { count: hours })}</button>))}</div>@@ -419,7 +428,7 @@ function WhenEditor({<>{when === "date" ? (<input- aria-label="Date"+ aria-label={t(m.date)}className="ui-field-control h-9 w-44 text-sm text-foreground"min={localDay()}onChange={(event) =>@@ -435,17 +444,20 @@ function WhenEditor({<div className="w-32 [&>div]:mt-0"><RoutineTimeField onChange={setTime} value={draft.time} /></div>- {QUICK_TIMES.map(([time, label]) => (- <button- aria-pressed={draft.time === time}- className="select-pill"- key={time}- onClick={() => setTime(time)}- type="button"- >- {label}- </button>- ))}+ {QUICK_HOURS.map((hour) => {+ const time = `${String(hour).padStart(2, "0")}:00`;+ return (+ <button+ aria-pressed={draft.time === time}+ className="select-pill"+ key={time}+ onClick={() => setTime(time)}+ type="button"+ >+ {formatHour(hour)}+ </button>+ );+ })}</div></>)}diff --git a/apps/web/src/features/rooms/task-sidebar/routine-language.test.ts b/apps/web/src/features/rooms/task-sidebar/routine-language.test.tsnew file mode 100644index 00000000..c95cc62e--- /dev/null+++ b/apps/web/src/features/rooms/task-sidebar/routine-language.test.ts@@ -0,0 +1,90 @@+// @vitest-environment jsdom+import { afterEach, describe, expect, it } from "vitest";++import { resetLanguageForTest, setLanguage } from "@/i18n/language";+import zhCN from "@/i18n/locales/zh-CN.json";++import { cadenceLabel, dayHeading, weekdayName } from "./routine-cadence";++const words = zhCN.routines;++function weekly(...weekdays: Parameters<typeof weekdayName>[0][]) {+ return {+ kind: "weekly" as const,+ timezone: "UTC",+ hour: 9,+ minute: 0,+ weekdays,+ };+}++function clock(locale: string) {+ return new Intl.DateTimeFormat(locale, {+ hour: "numeric",+ minute: "2-digit",+ }).format(new Date(2026, 0, 1, 9, 0));+}++describe("Routine schedules in the language on screen", () => {+ afterEach(() => resetLanguageForTest());++ it("keeps the English sentences", () => {+ expect(cadenceLabel(weekly("monday"))).toBe("Monday · 9:00 AM");+ expect(cadenceLabel(weekly("friday", "monday", "wednesday"))).toBe(+ "Mon, Wed, Fri · 9:00 AM",+ );+ expect(+ cadenceLabel(+ weekly("monday", "tuesday", "wednesday", "thursday", "friday"),+ ),+ ).toBe("Mon–Fri · 9:00 AM");+ expect(cadenceLabel(weekly())).toBe("Weekly · 9:00 AM");+ expect(+ cadenceLabel({ kind: "daily", timezone: "UTC", hour: 18, minute: 30 }),+ ).toBe("Daily · 6:30 PM");+ expect(cadenceLabel({ kind: "every_n_hours", timezone: "UTC" })).toBe(+ "Every hour",+ );+ expect(+ cadenceLabel({+ kind: "every_n_hours",+ timezone: "UTC",+ interval_hours: 3,+ }),+ ).toBe("Every 3 hours");+ expect(dayHeading(new Date(2026, 9, 30), new Date(2026, 9, 28))).toEqual({+ day: "Oct 30",+ distance: "in 2 days",+ });+ });++ it("words the pattern from the catalog and names days and times with Intl", async () => {+ await setLanguage("zh-CN");+ const time = clock("zh-CN");+ expect(+ cadenceLabel(+ weekly("monday", "tuesday", "wednesday", "thursday", "friday"),+ ),+ ).toBe(words.mondayToFridayAt.replace("{time}", time));+ const days = (["monday", "wednesday"] as const)+ .map((day) => weekdayName(day, "short"))+ .join(words.weekdaySeparator);+ expect(weekdayName("monday", "short")).not.toBe("Mon");+ expect(cadenceLabel(weekly("wednesday", "monday"))).toBe(+ words.weekdaysAt.replace("{days}", days).replace("{time}", time),+ );+ expect(+ cadenceLabel({+ kind: "every_n_hours",+ timezone: "UTC",+ interval_hours: 3,+ }),+ ).toBe(words.everyHours.other.replace("{count}", "3"));+ expect(dayHeading(new Date(2026, 9, 29), new Date(2026, 9, 28)).day).toBe(+ words.tomorrow,+ );+ expect(+ dayHeading(new Date(2026, 9, 30), new Date(2026, 9, 28)).distance,+ ).toBe(words.inDays.other.replace("{count}", "2"));+ });+});diff --git a/apps/web/src/features/rooms/task-sidebar/routine-time-field.tsx b/apps/web/src/features/rooms/task-sidebar/routine-time-field.tsxindex 64b7a788..87babc32 100644--- a/apps/web/src/features/rooms/task-sidebar/routine-time-field.tsx+++ b/apps/web/src/features/rooms/task-sidebar/routine-time-field.tsx@@ -1,5 +1,9 @@import { useEffect, useLayoutEffect, useRef, useState } from "react";+import { useT } from "@/i18n/use-translation";++import { routinesMessages as m } from "./routines.messages";+const HOURS = Array.from({ length: 24 }, (_, hour) =>String(hour).padStart(2, "0"),);@@ -14,6 +18,7 @@ export function RoutineTimeField({onChange: (value: string) => void;value: string;}) {+ const t = useT();const rootRef = useRef<HTMLDivElement>(null);const minuteInputRef = useRef<HTMLInputElement>(null);const hourOptionRef = useRef<HTMLButtonElement>(null);@@ -64,7 +69,7 @@ export function RoutineTimeField({<div className="relative mt-1 w-full" ref={rootRef}><div className="relative grid grid-cols-2 rounded-md border border-input bg-card transition-colors duration-150 hover:border-border-hover focus-within:border-foreground focus-within:ring-2 focus-within:ring-ring"><input- aria-label="Hour"+ aria-label={t(m.hour)}className="h-[34px] w-full bg-transparent px-3 py-1 text-center text-sm tabular-nums text-foreground outline-none"inputMode="numeric"maxLength={2}@@ -81,7 +86,7 @@ export function RoutineTimeField({value={hourText}/><input- aria-label="Minute"+ aria-label={t(m.minute)}className="h-[34px] w-full bg-transparent px-3 py-1 text-center text-sm tabular-nums text-foreground outline-none"inputMode="numeric"maxLength={2}@@ -107,14 +112,14 @@ export function RoutineTimeField({{open ? (<div className="app-floating-enter absolute inset-x-0 top-full z-20 mt-1 grid grid-cols-2 overflow-hidden rounded-lg bg-popover shadow-lg"><TimeColumn- label="Hours"+ label={t(m.hours)}onSelect={(nextHour) => commit(nextHour, parsed.minute)}options={HOURS}selected={parsed.hour}selectedRef={hourOptionRef}/><TimeColumn- label="Minutes"+ label={t(m.minutes)}onSelect={(nextMinute) => {commit(parsed.hour, nextMinute);setOpen(false);diff --git a/apps/web/src/features/rooms/task-sidebar/routines.messages.ts b/apps/web/src/features/rooms/task-sidebar/routines.messages.tsnew file mode 100644index 00000000..daedd543--- /dev/null+++ b/apps/web/src/features/rooms/task-sidebar/routines.messages.ts@@ -0,0 +1,88 @@+import { defineMessages } from "@/i18n/messages";++/**+ * The Routines panel of a Room and of an Agent, and the dialog that creates+ * or edits one. "Routine" is a product name and stays as it is.+ */+export const routinesMessages = defineMessages("routines", {+ routines: "Routines",+ loading: "Loading routines",+ loadFailed: "Routines could not be loaded.",+ noRoutines: "No routines",+ emptyTitle: "No routines in this room yet.",+ emptyBody:+ "Run something once at a set time, or daily, weekly, or every few hours.",+ watching: "Watching",+ appListeners: "App listeners",+ upcoming: "Upcoming",+ recurring: "Recurring",+ paused: "Paused",+ done: "Done",+ doneRoutines: "Done routines",+ newRoutine: "New routine",+ editRoutine: "Edit routine",+ deleteRoutine: "Delete routine",+ pauseRoutine: "Pause routine",+ enableRoutine: "Enable routine",+ watchingApp: "Watching {app}",+ notWatchingApp: "Not watching {app}",+ // What a row says under the Routine's name: its schedule, then who it wakes.+ detailMessageOnly: "{detail} · Message only",+ detailWakes: "{detail} · Wakes {name}",+ detailWakesAgent: "{detail} · Wakes an Agent",+ upcomingDetail: "{day} · {time}",+ upcomingDetailDistance: "{day} · {time} · {distance}",+ today: "Today",+ tomorrow: "Tomorrow",+ inDays: { one: "in {count} day", other: "in {count} days" },+ // The undo offer after pausing or enabling.+ enabledRoutine: "Enabled “{name}”",+ pausedRoutine: "Paused “{name}”",+ undo: "Undo",+ undoFailed: "Could not undo.",+ // Schedules, one whole sentence per pattern.+ everyMinutes: "Every {count} min",+ everyHours: { one: "Every hour", other: "Every {count} hours" },+ once: "Once",+ onceAt: "Once · {when}",+ dailyAt: "Daily · {time}",+ everyDayAt: "Every day · {time}",+ mondayToFridayAt: "Mon–Fri · {time}",+ weekdaysAt: "{days} · {time}",+ weeklyAt: "Weekly · {time}",+ weekdaySeparator: ", ",+ // The dialog.+ when: "When",+ whenTomorrow: "Tomorrow",+ whenDate: "Pick a date",+ whenDaily: "Every day",+ whenWeekdays: "Weekdays",+ whenWeekly: "Every week",+ whenHours: "Every few hours",+ weekdays: "Weekdays",+ every: "Every",+ hoursShort: "{count}h",+ date: "Date",+ hour: "Hour",+ minute: "Minute",+ hours: "Hours",+ minutes: "Minutes",+ chooseTime: "Choose a time",+ summaryWithNext: "{cadence} · Next {when}",+ instruction: "Instruction",+ instructionPlaceholder: "What should it do then?",+ nameOptional: "Name (optional)",+ mention: "Mention",+ mentionNone: "None",+ currentAgent: "Current Agent",+ runNow: "Run now",+ create: "Create",+ chooseWhen: "Choose when the Routine runs.",+ chooseWeekday: "Choose at least one weekday.",+ instructionRequired: "Say what the Routine should do.",+ minuteIntervalAgentOnly:+ "Minute-interval routines can only be edited by an Agent.",+ saveFailed: "Could not save routine.",+ deleteFailed: "Could not delete routine.",+ runFailed: "Could not run routine.",+});diff --git a/apps/web/src/i18n/locales/zh-CN.glossary.md b/apps/web/src/i18n/locales/zh-CN.glossary.mdindex 75177e7c..448dd873 100644--- a/apps/web/src/i18n/locales/zh-CN.glossary.md+++ b/apps/web/src/i18n/locales/zh-CN.glossary.md@@ -65,6 +65,10 @@ elsewhere.| Run (an Agent's work) | 运行 | Noun: `运行已停止`. || Activity | 活动 | What an Agent is doing or did. || Scheduled task | 定时任务 | |+| Undo | 撤销 | Takes back the change just made. |+| Pause / Enable (a Routine) | 暂停 / 启用 | |+| Wake (an Agent) | 唤醒 | A Routine starting an Agent. |+| Watch (an app) | 监听 | A Routine waiting for an app event. || Follow-up | 后续消息 | A Message sent while the Agent is working. || Instructions | 指令 | An Agent's instructions. || Template | 模板 | |diff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.jsonindex 5693dac3..d46d62cb 100644--- a/apps/web/src/i18n/locales/zh-CN.json+++ b/apps/web/src/i18n/locales/zh-CN.json@@ -2574,5 +2574,81 @@"messageFrom": "{name} 的消息","imageUnavailable": "图片不可用:{filename}","loadingImage": "正在加载图片…"+ },+ "routines": {+ "routines": "Routine",+ "loading": "正在加载 Routine",+ "loadFailed": "无法加载 Routine。",+ "noRoutines": "没有 Routine",+ "emptyTitle": "这个 Room 里还没有 Routine。",+ "emptyBody": "可以在指定时间运行一次,也可以每天、每周或每隔几小时运行。",+ "watching": "监听中",+ "appListeners": "应用监听",+ "upcoming": "即将运行",+ "recurring": "重复运行",+ "paused": "已暂停",+ "done": "已完成",+ "doneRoutines": "已完成的 Routine",+ "newRoutine": "新建 Routine",+ "editRoutine": "编辑 Routine",+ "deleteRoutine": "删除 Routine",+ "pauseRoutine": "暂停 Routine",+ "enableRoutine": "启用 Routine",+ "watchingApp": "正在监听 {app}",+ "notWatchingApp": "未监听 {app}",+ "detailMessageOnly": "{detail} · 只发消息",+ "detailWakes": "{detail} · 唤醒 {name}",+ "detailWakesAgent": "{detail} · 唤醒一个 Agent",+ "upcomingDetail": "{day} · {time}",+ "upcomingDetailDistance": "{day} · {time} · {distance}",+ "today": "今天",+ "tomorrow": "明天",+ "inDays": { "other": "{count} 天后" },+ "enabledRoutine": "已启用“{name}”",+ "pausedRoutine": "已暂停“{name}”",+ "undo": "撤销",+ "undoFailed": "无法撤销。",+ "everyMinutes": "每 {count} 分钟",+ "everyHours": { "other": "每 {count} 小时" },+ "once": "一次",+ "onceAt": "一次 · {when}",+ "dailyAt": "每天 · {time}",+ "everyDayAt": "每天 · {time}",+ "mondayToFridayAt": "周一至周五 · {time}",+ "weekdaysAt": "每{days} · {time}",+ "weeklyAt": "每周 · {time}",+ "weekdaySeparator": "、",+ "when": "时间",+ "whenTomorrow": "明天",+ "whenDate": "选择日期",+ "whenDaily": "每天",+ "whenWeekdays": "工作日",+ "whenWeekly": "每周",+ "whenHours": "每隔几小时",+ "weekdays": "星期",+ "every": "每隔",+ "hoursShort": "{count} 小时",+ "date": "日期",+ "hour": "小时",+ "minute": "分钟",+ "hours": "小时",+ "minutes": "分钟",+ "chooseTime": "请选择时间",+ "summaryWithNext": "{cadence} · 下次运行 {when}",+ "instruction": "指令",+ "instructionPlaceholder": "到时候要它做什么?",+ "nameOptional": "名称(可选)",+ "mention": "提及",+ "mentionNone": "无",+ "currentAgent": "当前 Agent",+ "runNow": "立即运行",+ "create": "创建",+ "chooseWhen": "请选择 Routine 的运行时间。",+ "chooseWeekday": "请至少选择一天。",+ "instructionRequired": "请说明 Routine 要做什么。",+ "minuteIntervalAgentOnly": "按分钟间隔运行的 Routine 只能由 Agent 编辑。",+ "saveFailed": "无法保存 Routine。",+ "deleteFailed": "无法删除 Routine。",+ "runFailed": "无法运行 Routine。"}}