From 062e97c8405ba9931dba1c613646b1deb0ab3ed0 Mon Sep 17 00:00:00 2001 From: Stu Alexander Date: Sat, 7 Nov 2026 11:47:34 +0000 Subject: [PATCH 1/2] feat(webui): show timestamps in the user's timezone instead of IST Timestamps across the WebUI and the services CLI were hard-coded to Asia/Kolkata. Add one display-timezone authority (utils/datetime.ts) and a component. The zone follows the user's saved timezone, falling back to the browser's, and updates when the Timeline saves a new zone. - formatDateTime/formatTime/formatDate replace per-page toLocaleString calls; PRECISE_* presets keep seconds on queue, audit and log views - recording context and chat source refs send the display zone, not IST - CLI operation stamps use the host's local zone Co-Authored-By: Claude Opus 5.5 --- .../components/AutomationSettings.test.tsx | 10 ++- .../src/components/AutomationSettings.tsx | 6 +- .../webui/src/components/ChatRunViewer.tsx | 7 +- backend/webui/src/components/DateTime.tsx | 27 ++++++ .../src/components/RecordingMemoryContext.tsx | 30 +++---- .../webui/src/components/SourceResults.tsx | 15 +--- .../src/components/VoiceLatencyReport.tsx | 3 +- .../webui/src/components/dataAudit/format.ts | 3 +- .../timeline/SessionMemoryBoard.tsx | 5 +- backend/webui/src/contexts/AuthContext.tsx | 4 + .../webui/src/hooks/useTimelineTimezone.ts | 2 + backend/webui/src/pages/Chat.tsx | 11 +-- backend/webui/src/pages/Finetuning.tsx | 3 +- .../webui/src/pages/MemorySpaceWorkspace.tsx | 3 +- backend/webui/src/pages/Network.tsx | 5 +- .../src/pages/OperationalClarity.test.tsx | 8 +- backend/webui/src/pages/Queue.tsx | 29 +++--- backend/webui/src/pages/RecordingDetail.tsx | 5 +- backend/webui/src/pages/Recordings.tsx | 7 +- backend/webui/src/pages/System.tsx | 3 +- backend/webui/src/pages/SystemEvents.tsx | 24 ++--- backend/webui/src/pages/WakeWordLab.tsx | 3 +- backend/webui/src/utils/datetime.test.ts | 36 ++++++++ backend/webui/src/utils/datetime.ts | 88 +++++++++++++++++++ docs/init-system.md | 2 +- service_cli.py | 10 ++- 26 files changed, 247 insertions(+), 102 deletions(-) create mode 100644 backend/webui/src/components/DateTime.tsx create mode 100644 backend/webui/src/utils/datetime.test.ts create mode 100644 backend/webui/src/utils/datetime.ts diff --git a/backend/webui/src/components/AutomationSettings.test.tsx b/backend/webui/src/components/AutomationSettings.test.tsx index c2a14239..96887b40 100644 --- a/backend/webui/src/components/AutomationSettings.test.tsx +++ b/backend/webui/src/components/AutomationSettings.test.tsx @@ -3,17 +3,19 @@ import '@testing-library/jest-dom/vitest' import { afterEach, beforeEach, expect, it, vi } from 'vitest' import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react' import AutomationSettings from './AutomationSettings' +import { formatDateTime, setDisplayTimezone } from '../utils/datetime' const state = vi.hoisted(() => ({ next: '2026-09-14T04:30:00+00:00' as string | null, update: vi.fn() })) vi.mock('../hooks/useFinetuning', () => ({ useCronJobs: () => ({ data: [{ job_id: 'daily', description: '', enabled: true, schedule: '30 4 * * *', last_run: null, next_run: state.next }], isLoading: false, refetch: vi.fn() }), useToggleCronJob: () => ({ mutateAsync: vi.fn() }), useRunCronJob: () => ({ mutateAsync: vi.fn() }), useUpdateCronSchedule: () => ({ mutateAsync: state.update }), })) -beforeEach(() => { state.next = '2026-09-14T04:30:00+00:00'; state.update.mockReset().mockResolvedValue({}) }) -afterEach(cleanup) -it('shows the UTC next-run instant in IST while preserving the UTC expression when edited', async () => { +beforeEach(() => { setDisplayTimezone('Asia/Kolkata'); state.next = '2026-09-14T04:30:00+00:00'; state.update.mockReset().mockResolvedValue({}) }) +afterEach(() => { cleanup(); setDisplayTimezone(null) }) +it('shows the UTC next-run instant in the display timezone while preserving the UTC expression when edited', async () => { render() - expect(screen.getByText(/Next:/)).toHaveTextContent(/10:00 am IST/i) + expect(screen.getByText(/Next:/)).toHaveTextContent(formatDateTime('2026-09-14T04:30:00Z')) + expect(screen.getByText(/Next:/)).toHaveTextContent(/10:00/) fireEvent.click(screen.getByText('Schedule and last run')) expect(screen.getByText(/At 04:30 AM/)).toHaveTextContent('(UTC)') fireEvent.click(screen.getByRole('button', { name: 'Edit schedule' })) diff --git a/backend/webui/src/components/AutomationSettings.tsx b/backend/webui/src/components/AutomationSettings.tsx index fbd39fb6..27479af8 100644 --- a/backend/webui/src/components/AutomationSettings.tsx +++ b/backend/webui/src/components/AutomationSettings.tsx @@ -3,6 +3,7 @@ import { Clock, ToggleLeft, ToggleRight, Edit3, Check, X, Play, RefreshCw, Eye } import cronstrue from 'cronstrue' import { useCronJobs, useToggleCronJob, useUpdateCronSchedule, useRunCronJob } from '../hooks/useFinetuning' import { Alert, Button, Card, IconButton, StateBadge, StateTone } from './ui' +import { formatDateTime, useDisplayTimezone } from '../utils/datetime' // Human-friendly names + what kind of automation each job is. Trigger-now lives // on the Training page; this card owns only "should it run / when". @@ -34,10 +35,11 @@ function humanCron(expr: string): string { function formatTs(iso: string | null): string { if (!iso) return 'Never' - return `${new Date(iso).toLocaleString('en-IN', { timeZone: 'Asia/Kolkata', dateStyle: 'medium', timeStyle: 'short' })} IST` + return formatDateTime(iso) } export default function AutomationSettings({ isAdmin }: { isAdmin: boolean }) { + const timezone = useDisplayTimezone() const { data: jobs = [], isLoading, refetch } = useCronJobs() const toggleJob = useToggleCronJob() const updateSchedule = useUpdateCronSchedule() @@ -96,7 +98,7 @@ export default function AutomationSettings({ isAdmin }: { isAdmin: boolean }) { Automation & Schedules

- Next runs are shown in IST. Enabling or disabling a job takes effect immediately. + Next runs are shown in {timezone}. Enabling or disabling a job takes effect immediately.

{error && ( diff --git a/backend/webui/src/components/ChatRunViewer.tsx b/backend/webui/src/components/ChatRunViewer.tsx index db7c2c19..994a6383 100644 --- a/backend/webui/src/components/ChatRunViewer.tsx +++ b/backend/webui/src/components/ChatRunViewer.tsx @@ -2,6 +2,7 @@ import { useEffect, useRef } from 'react' import { useQuery } from '@tanstack/react-query' import { X } from 'lucide-react' import { chatApi } from '../services/api' +import { formatDateTime } from '../utils/datetime' export interface ChatRun { run_id: string @@ -26,9 +27,9 @@ interface RunStep { response_unavailable?: boolean } -const stamp = (value: string) => new Date(value).toLocaleString('en-IN', { - timeZone: 'Asia/Kolkata', day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit', -}) + ' IST' +const stamp = (value: string) => formatDateTime(value, { + day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit', timeZoneName: 'short', +}) function Payload({ label, value }: { label: string; value: unknown }) { if (value === undefined) return null diff --git a/backend/webui/src/components/DateTime.tsx b/backend/webui/src/components/DateTime.tsx new file mode 100644 index 00000000..d03554e4 --- /dev/null +++ b/backend/webui/src/components/DateTime.tsx @@ -0,0 +1,27 @@ +import { formatDate, formatDateTime, formatTime, toDate, useDisplayTimezone, type DateInput, type FormatOptions } from '../utils/datetime' + +const FORMATTERS = { datetime: formatDateTime, date: formatDate, time: formatTime } + +interface DateTimeProps { + value: DateInput + /** Defaults to "datetime". */ + format?: keyof typeof FORMATTERS + options?: FormatOptions + className?: string +} + +/** A timestamp shown in the user's display timezone; hover shows the full date and time. */ +export default function DateTime({ value, format = 'datetime', options, className }: DateTimeProps) { + useDisplayTimezone() + const date = toDate(value) + if (Number.isNaN(date.getTime())) return null + return ( + + ) +} diff --git a/backend/webui/src/components/RecordingMemoryContext.tsx b/backend/webui/src/components/RecordingMemoryContext.tsx index 7742a615..bba679a1 100644 --- a/backend/webui/src/components/RecordingMemoryContext.tsx +++ b/backend/webui/src/components/RecordingMemoryContext.tsx @@ -1,4 +1,3 @@ -import { sourceDate } from "../utils/sourceTime"; import { useState } from "react"; import { Link, useSearchParams } from "react-router-dom"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; @@ -13,6 +12,7 @@ import { Button } from "./ui"; import { CandidateChanges } from "./timeline/ReviewDesk"; import ContextRefreshes from "./ContextRefreshes"; import { sourceLabel } from "./timeline/SessionMemoryBoard"; +import { formatDateTime, formatTime, useDisplayTimezone } from '../utils/datetime' interface Context { organization_requests?: { request_id?: string }[]; @@ -54,15 +54,16 @@ export default function RecordingMemoryContext({ const client = useQueryClient(); const [params] = useSearchParams(); const space = params.get("memory_space_id") || undefined; + const timezone = useDisplayTimezone(); const [clarification, setClarification] = useState(""); const [requestId, setRequestId] = useState(); const [inspect, setInspect] = useState(false); const query = useQuery({ - queryKey: ["recording-context", recordingId, space], + queryKey: ["recording-context", recordingId, space, timezone], queryFn: async () => ( await api.get(`/api/recordings/${recordingId}/context`, { - params: { timezone: "Asia/Kolkata", memory_space_id: space }, + params: { timezone, memory_space_id: space }, }) ).data, refetchInterval: 5000, @@ -80,7 +81,7 @@ export default function RecordingMemoryContext({ mutationFn: (day: string) => api.post(`/api/recordings/${recordingId}/organize-day`, { local_date: day, - timezone: "Asia/Kolkata", + timezone, }), onSuccess: (response) => { setRequestId(response.data.request_id); @@ -170,10 +171,8 @@ export default function RecordingMemoryContext({ {!data.event_date_known && (

Recording date unknown. Uploaded{" "} - {sourceDate(data.uploaded_at).toLocaleString("en-IN", { - timeZone: "Asia/Kolkata", - })}{" "} - IST. This session stays undated. + {formatDateTime(data.uploaded_at)}. This session stays + undated.

)} {data.event_date_known && !data.sessions.length && ( @@ -220,18 +219,11 @@ export default function RecordingMemoryContext({

{s.title}

- {sourceDate(s.started_at).toLocaleTimeString("en-IN", { - timeZone: "Asia/Kolkata", - hour: "numeric", + {formatTime(s.started_at, { + hour: "2-digit", minute: "2-digit", })} - – - {sourceDate(s.ended_at).toLocaleTimeString("en-IN", { - timeZone: "Asia/Kolkata", - hour: "numeric", - minute: "2-digit", - })}{" "} - IST + –{formatTime(s.ended_at)}

{s.summary} @@ -423,7 +415,7 @@ export default function RecordingMemoryContext({

{session.total_sources > 0 && (busy || session.state === 'paused') &&

{session.completed_sources} of {session.total_sources} source groups complete · {({ account: 'Building the session account', combining: 'Combining source accounts', checking_claims: 'Independent account review', memory: 'Preparing note changes' } as Record)[session.stage || 'account']}

} - {busy && activityLabel(session) &&

{activityLabel(session)} · last activity {clock(session.investigation_activity!.updated_at, 'Asia/Kolkata')} IST

} + {busy && activityLabel(session) &&

{activityLabel(session)} · last activity {formatTime(session.investigation_activity!.updated_at)}

} {session.error && session.state !== 'generating' &&

{session.state === 'paused' ? (session.failure_kind === 'repeated_tool_call' ? 'Repeated identical tool calls stopped this investigation. Saved source reads and drafts remain inspectable. Restart begins a fresh attempt; no automatic retry is scheduled.' : 'The investigation reached its work limit. Restart to begin a new attempt with completed source groups retained; no automatic retry is scheduled. Earlier exchanges remain available below.') : session.state === 'failed' ? 'Preparation stopped before a reviewed draft was completed. Retry preparation, or inspect the details below.' : session.state === 'stale' ? 'This draft needs refreshing against the current sources before it can be approved.' : session.failure_kind === 'time_slice' ? 'Saved work will continue in the queue.' : session.error}

{session.state === 'failed' &&
Technical details
{session.error}
} @@ -152,7 +153,7 @@ function SessionRow({ session, day, timezone }: { session: MemorySession; day: s {(decide.error || generate.error || restart.error || correction.error) &&

{errorMessage(decide.error || generate.error || restart.error || correction.error)}

} {notice &&

{notice}

} {open &&
- {session.investigation_activity?.event &&
Investigation activity

{session.investigation_activity.tool_calls} tool calls · {session.investigation_activity.rounds} model rounds · Pi {session.investigation_activity.runtime_version}

{session.investigation_activity.checkpoint_saved ? 'Native session checkpoint saved' : 'Awaiting first complete checkpoint'}{session.investigation_activity.resumed ? ' · resumed saved work' : ''}

Last activity {clock(session.investigation_activity.updated_at, 'Asia/Kolkata')} IST

} + {session.investigation_activity?.event &&
Investigation activity

{session.investigation_activity.tool_calls} tool calls · {session.investigation_activity.rounds} model rounds · Pi {session.investigation_activity.runtime_version}

{session.investigation_activity.checkpoint_saved ? 'Native session checkpoint saved' : 'Awaiting first complete checkpoint'}{session.investigation_activity.resumed ? ' · resumed saved work' : ''}

Last activity {formatTime(session.investigation_activity.updated_at)}

} {proposal && reviewing && } {questions.map(question =>

{question}

)} {questions.length > 0 &&