Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ extras/asr-services/providers/*/finetune/

# k8s config
backends/charts/backend/env-configmap.yaml
k8s-manifests/secrets.yaml

extras/openmemory-mcp/data/*
.env.backup.*
Expand Down
10 changes: 6 additions & 4 deletions backend/webui/src/components/AutomationSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<AutomationSettings isAdmin />)
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' }))
Expand Down
6 changes: 4 additions & 2 deletions backend/webui/src/components/AutomationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -96,7 +98,7 @@ export default function AutomationSettings({ isAdmin }: { isAdmin: boolean }) {
Automation &amp; Schedules
</h3>
<p className="text-xs text-gray-500 dark:text-gray-400 mb-4">
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.
</p>

{error && (
Expand Down
7 changes: 4 additions & 3 deletions backend/webui/src/components/ChatRunViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions backend/webui/src/components/DateTime.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<time
dateTime={date.toISOString()}
title={formatDateTime(date, { dateStyle: 'full', timeStyle: 'long', timezone: options?.timezone })}
className={className}
>
{FORMATTERS[format](date, options)}
</time>
)
}
30 changes: 11 additions & 19 deletions backend/webui/src/components/RecordingMemoryContext.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 }[];
Expand Down Expand Up @@ -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<string>();
const [inspect, setInspect] = useState(false);
const query = useQuery({
queryKey: ["recording-context", recordingId, space],
queryKey: ["recording-context", recordingId, space, timezone],
queryFn: async () =>
(
await api.get<Context>(`/api/recordings/${recordingId}/context`, {
params: { timezone: "Asia/Kolkata", memory_space_id: space },
params: { timezone, memory_space_id: space },
})
).data,
refetchInterval: 5000,
Expand All @@ -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);
Expand Down Expand Up @@ -170,10 +171,8 @@ export default function RecordingMemoryContext({
{!data.event_date_known && (
<p className="text-sm text-gray-600 dark:text-gray-300">
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.
</p>
)}
{data.event_date_known && !data.sessions.length && (
Expand Down Expand Up @@ -220,18 +219,11 @@ export default function RecordingMemoryContext({
<div className="min-w-0">
<h3 className="break-words font-medium">{s.title}</h3>
<p className="mt-1 text-xs text-gray-600 dark:text-gray-300">
{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)}
</p>
<p className="mt-1 text-sm text-gray-600 dark:text-gray-300">
{s.summary}
Expand Down Expand Up @@ -423,7 +415,7 @@ export default function RecordingMemoryContext({
<CandidateChanges
proposal={proposal}
day="undated"
timezone="Asia/Kolkata"
timezone={timezone}
/>
<Button
size="sm"
Expand Down
15 changes: 4 additions & 11 deletions backend/webui/src/components/SourceResults.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Link } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";
import { api, ChatSourceRef } from "../services/api";
import { sourceDate } from "../utils/sourceTime";
import type { ReactNode } from "react";
import { formatDateTime, getDisplayTimezone } from '../utils/datetime'

export function Highlight({ text, terms }: { text: string; terms: string[] }) {
const matched = new Set(terms.map((t) => t.toLocaleLowerCase()));
Expand Down Expand Up @@ -57,14 +57,14 @@ export const hitRef = (hit: SourceHit): ChatSourceRef => ({
kind: hit.kind,
key: hit.key,
local_date: hit.owner_date,
timezone: hit.timezone || "Asia/Kolkata",
timezone: hit.timezone || getDisplayTimezone(),
});
export const refKey = (ref: ChatSourceRef) =>
[
ref.kind,
ref.key,
ref.local_date || "",
ref.timezone || "Asia/Kolkata",
ref.timezone || getDisplayTimezone(),
].join(":");

export function useSourceResults(
Expand Down Expand Up @@ -143,14 +143,7 @@ export function SourceResult({
: "Recording"}{" "}
·{" "}
{item.started_at
? sourceDate(item.started_at).toLocaleString("en-IN", {
timeZone: "Asia/Kolkata",
day: "numeric",
month: "short",
year: "numeric",
hour: "numeric",
minute: "2-digit",
}) + " IST"
? formatDateTime(item.started_at)
: "Date unknown"}
</p>
<h3 className="mt-1 break-words font-medium">
Expand Down
3 changes: 2 additions & 1 deletion backend/webui/src/components/VoiceLatencyReport.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useState } from 'react'
import { api } from '../services/api'
import { Alert, Button, Card } from './ui'
import { formatDateTime } from '../utils/datetime'

type Metric = { value_ms: number; quality: string; attempts?: number }
type TimingEvent = {
Expand Down Expand Up @@ -39,7 +40,7 @@ export function VoiceTimingCard({ report }: { report: VoiceReport }) {
const range = Math.max(1, eventEnd - eventStart)
return <article className="text-gray-900 dark:text-gray-100 border-t border-gray-200 dark:border-gray-700 py-4">
<div className="flex flex-wrap justify-between gap-2 text-sm">
<span className="font-medium">{report.client_id} · {new Date(report.started_at_ms).toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' })} IST</span>
<span className="font-medium">{report.client_id} · {formatDateTime(report.started_at_ms)}</span>
<span>{report.status} · {duration(total)} total</span>
</div>
<dl className="grid grid-cols-1 sm:grid-cols-3 gap-3 my-3">
Expand Down
3 changes: 2 additions & 1 deletion backend/webui/src/components/dataAudit/format.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sourceDate } from '../../utils/sourceTime'
import { PRECISE_DATE_TIME, formatDateTime } from '../../utils/datetime'

export function formatDuration(seconds: number): string {
if (!seconds || seconds <= 0) return '0s'
Expand All @@ -20,7 +21,7 @@ export function formatClock(seconds: number): string {

export function formatDate(iso: string | null): string {
if (!iso) return '—'
return sourceDate(iso).toLocaleString('en-IN', { timeZone: 'Asia/Kolkata', timeZoneName: 'short' })
return formatDateTime(sourceDate(iso), PRECISE_DATE_TIME)
}

// Processing-status chip for a Data Audit row. Returns null for the normal
Expand Down
5 changes: 3 additions & 2 deletions backend/webui/src/components/timeline/SessionMemoryBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChevronDown, Image, Monitor, Mic, Volume2, Check, Loader2 } from 'lucid
import { MemorySession, SessionSource, timelineApi } from '../../services/api'
import { Button } from '../ui'
import { CandidateChanges } from './ReviewDesk'
import { formatTime } from '../../utils/datetime'

const busyStates = ['queued', 'generating', 'checking', 'applying', 'regenerating']
const quietStates = ['excluded', 'deferred', 'no_changes', 'applied', 'rejected']
Expand Down Expand Up @@ -143,7 +144,7 @@ function SessionRow({ session, day, timezone }: { session: MemorySession; day: s
</div>
</div>
{session.total_sources > 0 && (busy || session.state === 'paused') && <div className="mb-3 pl-7"><p className="mb-1 text-xs text-gray-600 dark:text-gray-400">{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<string, string>)[session.stage || 'account']}</p><div role="progressbar" aria-label="Source groups complete" aria-valuemin={0} aria-valuemax={session.total_sources} aria-valuenow={session.completed_sources} className="h-1.5 overflow-hidden rounded bg-[var(--tape-line)]"><div className="h-full" style={{ backgroundColor: "var(--tape-focus)", width: `${Math.min(100, session.completed_sources / session.total_sources * 100)}%` }} /></div></div>}
{busy && activityLabel(session) && <p className="mb-3 pl-7 text-xs text-gray-600 dark:text-gray-400" role="status">{activityLabel(session)} · last activity {clock(session.investigation_activity!.updated_at, 'Asia/Kolkata')} IST</p>}
{busy && activityLabel(session) && <p className="mb-3 pl-7 text-xs text-gray-600 dark:text-gray-400" role="status">{activityLabel(session)} · last activity {formatTime(session.investigation_activity!.updated_at)}</p>}
{session.error && session.state !== 'generating' && <div className="mb-3 space-y-2 text-sm">
<p role={session.state === 'failed' ? 'alert' : 'status'} className={session.state === 'failed' ? 'text-red-700 dark:text-red-300' : session.state === 'paused' ? 'text-amber-800 dark:text-amber-300' : 'text-gray-600 dark:text-gray-300'}>{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}</p>
{session.state === 'failed' && <details><summary className="cursor-pointer text-xs text-[var(--tape-focus)]">Technical details</summary><pre className="mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-all rounded bg-[var(--tape-paper-raised)] p-2 text-xs">{session.error}</pre></details>}
Expand All @@ -152,7 +153,7 @@ function SessionRow({ session, day, timezone }: { session: MemorySession; day: s
{(decide.error || generate.error || restart.error || correction.error) && <p role="alert" className="mb-3 break-words text-sm text-red-700 dark:text-red-300">{errorMessage(decide.error || generate.error || restart.error || correction.error)}</p>}
{notice && <p role="status" className="mb-3 text-xs text-gray-600 dark:text-gray-300">{notice}</p>}
{open && <div className="mb-4 space-y-4 rounded-lg border border-[var(--tape-line)] bg-[var(--tape-paper-raised)] p-3 sm:ml-7 sm:p-4">
{session.investigation_activity?.event && <details className="text-xs text-gray-600 dark:text-gray-400"><summary className="cursor-pointer text-[var(--tape-focus)]">Investigation activity</summary><p className="mt-2">{session.investigation_activity.tool_calls} tool calls · {session.investigation_activity.rounds} model rounds · Pi {session.investigation_activity.runtime_version}</p><p>{session.investigation_activity.checkpoint_saved ? 'Native session checkpoint saved' : 'Awaiting first complete checkpoint'}{session.investigation_activity.resumed ? ' · resumed saved work' : ''}</p><p>Last activity {clock(session.investigation_activity.updated_at, 'Asia/Kolkata')} IST</p></details>}
{session.investigation_activity?.event && <details className="text-xs text-gray-600 dark:text-gray-400"><summary className="cursor-pointer text-[var(--tape-focus)]">Investigation activity</summary><p className="mt-2">{session.investigation_activity.tool_calls} tool calls · {session.investigation_activity.rounds} model rounds · Pi {session.investigation_activity.runtime_version}</p><p>{session.investigation_activity.checkpoint_saved ? 'Native session checkpoint saved' : 'Awaiting first complete checkpoint'}{session.investigation_activity.resumed ? ' · resumed saved work' : ''}</p><p>Last activity {formatTime(session.investigation_activity.updated_at)}</p></details>}
{proposal && reviewing && <CandidateChanges proposal={proposal} day={day} timezone={timezone} />}
{questions.map(question => <p key={question} className="rounded-md bg-amber-50 p-3 text-sm text-amber-950 dark:bg-amber-950/30 dark:text-amber-200">{question}</p>)}
{questions.length > 0 && <div className="space-y-2"><label className="block text-sm font-medium" htmlFor={`clarification-${session.session_key}`}>Add the missing context</label><textarea id={`clarification-${session.session_key}`} className="w-full rounded border border-[var(--tape-line)] bg-[var(--tape-paper)] p-2 text-sm" rows={2} maxLength={2000} value={clarification} onChange={event => setClarification(event.target.value)} placeholder="Your answer is retained as your own statement alongside the original sources." /><Button size="sm" variant="primary" disabled={saving || !clarification.trim()} onClick={() => decide.mutate({ action: 'clarify', keys: selected.size ? [...selected] : allKeys, clarification: clarification.trim() })}>Save clarification</Button></div>}
Expand Down
4 changes: 4 additions & 0 deletions backend/webui/src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createContext, useContext, useState, useEffect, ReactNode } from 'react'
import { authApi, browserSession, type CurrentUser } from '../services/api'
import { getStorageKey } from '../utils/storage'
import { setDisplayTimezone } from '../utils/datetime'
import { SESSION_CHANGED, savedToken, signedOut, logoutPending } from '../services/browserSession'

interface AuthContextType {
Expand Down Expand Up @@ -28,6 +29,9 @@ export function AuthProvider({ children }: { children: ReactNode }) {
// Check if user is admin
const isAdmin = user?.is_superuser || false

// Every displayed timestamp follows the user's saved zone (browser zone when unset).
useEffect(() => setDisplayTimezone(user?.timezone), [user?.timezone])

useEffect(() => {
const sync = () => {
setToken(savedToken())
Expand Down
Loading
Loading