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
22c: every date and time follows the one clock (#709)
Oleksandr Ivanchenko06941cc5aaef
diff --git a/frontend/src/clock.ts b/frontend/src/clock.tsindex d8856a20..80e49578 100644--- a/frontend/src/clock.ts+++ b/frontend/src/clock.ts@@ -78,6 +78,15 @@ export function dateClock(at: When, opts: ClockOpts & { year?: boolean } = {}):return `${dateText(d, opts)}, ${timeText(d, opts)}`;}+/** A record's date and time, always with the day (18d): "Nov 3, 8:15 PM" / "3 Nov, 20:15", and the year when it+ * isn't this year. For lists and tooltips that stamp when something happened (Import history, a verification's+ * time, a goal's check square). Null for a missing or unreadable time. (One clock everywhere, roadmap 22c.) */+export function stampClock(at: When, now: number = Date.now(), locale?: string): string | null {+ const d = toDate(at);+ if (!d) return null;+ return dateClock(d, { locale, year: d.getFullYear() !== new Date(now).getFullYear() });+}+/** "8:15 PM" when `at` is today, else the date too. Null for a missing or unreadable time. */export function localClock(at: When, now: number = Date.now(), locale?: string): string | null {const d = toDate(at);diff --git a/frontend/src/components/ImportDialog.tsx b/frontend/src/components/ImportDialog.tsxindex db4c5a16..0e85bdd3 100644--- a/frontend/src/components/ImportDialog.tsx+++ b/frontend/src/components/ImportDialog.tsx@@ -20,6 +20,7 @@ import {trapFocusTarget,} from '../imports';import { useEscapeLayer } from '../escape';+import { stampClock } from '../clock';import { pickProblem, uploadFor } from '../importZip';import {type FolderPlan,@@ -1005,7 +1006,7 @@ export const RecentImports: React.FC<{ records: ImportRecord[]; onUndo: (r: Impo<div className="flex-1 min-w-0"><p className="text-xs text-zinc-200 truncate">{names.length ? names.join(', ') : 'Skills only'}</p><p className="text-[11px] text-zinc-500">- {new Date(r.created_at).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })}+ {stampClock(r.created_at) ?? r.created_at}{r.status === 'undone' ? ' · undone' : ''}</p></div>diff --git a/frontend/src/components/JiraSettings.tsx b/frontend/src/components/JiraSettings.tsxindex addd9f38..f738b279 100644--- a/frontend/src/components/JiraSettings.tsx+++ b/frontend/src/components/JiraSettings.tsx@@ -223,8 +223,8 @@ export const JiraSettings: React.FC<{<TicketIcon size={14} className="text-[#b4a9ff]" aria-hidden="true" /> Work from Jira<span className={`kw-chip ${site.on ? 'kw-chip-ok' : ''}`}>{site.on ? 'On' : 'Paused'}</span></p>- <p className={`flex items-center gap-2 text-[11px] ${rejected ? 'text-rose-300' : 'text-zinc-400'}`} data-jira-status>- <span className={`w-1.5 h-1.5 rounded-full ${rejected ? 'bg-rose-400' : 'bg-teal-300'}`} aria-hidden="true" />+ <p className={`flex items-start gap-2 text-[11px] ${rejected ? 'text-rose-300' : 'text-zinc-400'}`} data-jira-status>+ <span className={`w-1.5 h-1.5 mt-[0.45em] shrink-0 rounded-full ${rejected ? 'bg-rose-400' : 'bg-teal-300'}`} aria-hidden="true" />{rejected ? `Jira stopped accepting the token ${atClock(rejected)}. Nothing new is picked up.` : `${site.polled_at ? `Checked ${hhmm(site.polled_at)} · ` : ''}${ticketSummary(jira.tickets)}`}</p><dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-xs">diff --git a/frontend/src/components/Signature.tsx b/frontend/src/components/Signature.tsxindex 8861dd83..0b52d6c2 100644--- a/frontend/src/components/Signature.tsx+++ b/frontend/src/components/Signature.tsx@@ -4,6 +4,7 @@ import type { HeartDot, HeartWord } from '../signature';import { heartbeatCount, heartbeatText, heartbeatWord } from '../signature';import { Sticker } from './Sticker';import { CheckBurst } from './CheckBurst';+import { stampClock } from '../clock';/*** "Verified · 3/3" (or "First verified") as Pixel's holo sticker, tilted −2° (S1) or −3° for the@@ -52,11 +53,8 @@ const WORD_TONE: Record<HeartWord, string> = {'Can’t check': 'text-muted',};-const when = (at?: string): string | undefined => {- if (!at) return undefined;- const d = new Date(at);- return Number.isNaN(d.getTime()) ? undefined : d.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });-};+/** A check square's tooltip time on the one clock (22c): "Nov 3, 8:15 PM" / "3 Nov, 20:15"; nothing when unreadable. */+export const beatWhen = (at?: string, now: number = Date.now(), locale?: string): string | undefined => stampClock(at, now, locale) ?? undefined;/*** The goal's last checks as 6×6 squares, oldest left, newest outlined (spec §3), then "5/7 ok" and a word.@@ -68,7 +66,7 @@ export const GoalHeartbeat: React.FC<{ dots: HeartDot[]; status: string; fixing?const phone = dots.slice(-5);const word = heartbeatWord(status, dots, fixing);const square = (d: HeartDot, i: number, newest: boolean, extra = '') => (- <span key={i} className={`kws-beat kws-beat-${d.tone} ${newest ? 'kws-beat-newest' : ''} ${extra}`} title={[d.label, when(d.at)].filter(Boolean).join(' · ')} data-dot={d.tone} />+ <span key={i} className={`kws-beat kws-beat-${d.tone} ${newest ? 'kws-beat-newest' : ''} ${extra}`} title={[d.label, beatWhen(d.at)].filter(Boolean).join(' · ')} data-dot={d.tone} />);const older = dots.length - phone.length;return (diff --git a/frontend/src/components/VirtualMachinePane.tsx b/frontend/src/components/VirtualMachinePane.tsxindex d6579dc5..4a0841c3 100644--- a/frontend/src/components/VirtualMachinePane.tsx+++ b/frontend/src/components/VirtualMachinePane.tsx@@ -37,6 +37,7 @@ import { POINT_COPY, footerText } from '../point';import { choosePage, noteTitle, pageTeam, pageTitleOf, shownPage, stepPage, trailTime, type ReplyPage } from '../browserPages';import { useBrowserPages } from '../useBrowserPages';import { BrowserPageStrip } from './BrowserPageStrip';+import { secondsText } from '../clock';const PHONE_QUERY = '(max-width: 639px)';/** 17b: the footer's pointing slot. It shrinks and truncates instead of spilling over the buttons, on one line. */@@ -1045,11 +1046,11 @@ export const VirtualMachinePane: React.FC<VirtualMachinePaneProps> = ({) : (terminalLogs.map((log, index) => (<div key={index} className="p-2 bg-zinc-900/60 border border-zinc-800/80 rounded-lg">- <div className="flex items-center justify-between text-sky-400 font-semibold text-[11px]">- <span>$ {log.command}</span>+ <div className="flex items-start justify-between gap-2 text-sky-400 font-semibold text-[11px]" data-terminal-row>+ <span className="min-w-0 break-words">$ {log.command}</span>{log.timestamp && (- <span className="text-[9px] text-zinc-500 font-normal">- {log.timestamp.includes('T') ? log.timestamp.split('T')[1].split('.')[0] : log.timestamp}+ <span className="shrink-0 whitespace-nowrap text-[9px] leading-4 text-zinc-500 font-normal" data-terminal-time>+ {terminalTime(log.timestamp)}</span>)}</div>@@ -1225,3 +1226,9 @@ export const VirtualMachinePane: React.FC<VirtualMachinePaneProps> = ({</>);};++/** A terminal log row's time on the device's own clock, with seconds ("4:05:12\u00a0PM" / "16:05:12"), not the+ * UTC slice of the ISO string. A timestamp that doesn't parse shows as it came. (One clock everywhere, 22c.) */+export function terminalTime(ts: string, locale?: string): string {+ return secondsText(ts, { locale }) ?? ts;+}diff --git a/frontend/src/components/dev/PrepushCard.tsx b/frontend/src/components/dev/PrepushCard.tsxindex 346e79a8..ed134a15 100644--- a/frontend/src/components/dev/PrepushCard.tsx+++ b/frontend/src/components/dev/PrepushCard.tsx@@ -374,7 +374,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({return (<span data-pushed>{/* Mira FIX 4: keyed on the grant, so it reads the same when the pressed card is out of view. */}- <span className="font-medium text-emerald-300">{pushedLine(used)}</span> · <code className="dv-sha dv-sha-wrap">{p.branch}</code>+ <span className="font-medium text-emerald-300">{pushedLine(used)}</span> · <code className="dv-sha dv-sha-whole" title={p.branch} data-pushed-branch>{p.branch}</code>{card.grant?.kind === 'override'? " · your Push anyway was the OK, so it didn't ask again.": " · your retry was the OK, so it didn't ask again."}diff --git a/frontend/src/components/results/Verification.tsx b/frontend/src/components/results/Verification.tsxindex c48ea789..9335d604 100644--- a/frontend/src/components/results/Verification.tsx+++ b/frontend/src/components/results/Verification.tsx@@ -2,6 +2,7 @@ import React from 'react';import { AlertTriangle, CircleDashed, Clock, XCircle, CheckCircle2 } from 'lucide-react';import { CheckStatus, VerificationBlock, VerificationCheck, inRange, isObj, isText, optText, parseCommon, uniqueIds } from '../../smartResults';import type { RendererProps } from './registry';+import { stampClock } from '../../clock';const STATUSES: CheckStatus[] = ['passed', 'failed', 'error', 'pending'];@@ -50,10 +51,10 @@ const STATUS_PILL: Record<CheckStatus, string> = {pending: 'border-zinc-600 bg-zinc-800/60 text-zinc-300',};-function formatWhen(s: string | null): string | null {+/** A check's time on the one clock (22c): "Nov 3, 8:15 PM" / "3 Nov, 20:15"; an unreadable time shows as it came. */+export function formatWhen(s: string | null, now: number = Date.now(), locale?: string): string | null {if (!s) return null;- const d = new Date(s);- return Number.isNaN(d.getTime()) ? s : d.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });+ return stampClock(s, now, locale) ?? s;}/** A task's outcome checks: the summary line, then each check with status, an expandable excerpt, and time. */diff --git a/frontend/src/styles/modern.css b/frontend/src/styles/modern.cssindex a7c8247f..674e799a 100644--- a/frontend/src/styles/modern.css+++ b/frontend/src/styles/modern.css@@ -916,6 +916,9 @@ a.kw-sticker:hover { transform: rotate(var(--kw-tilt)) scale(1.04); box-shadow:.dv-sha { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--kw-hairline); background: var(--dv-code-bg);font: 500 11px/1 'JetBrains Mono', monospace; color: var(--t3); white-space: nowrap; }button.dv-sha { cursor: copy; } button.dv-sha:hover { color: var(--accent); border-color: var(--kw-hairline-strong); }+/* The "Pushed · … · branch" meta line keeps the branch whole, cut with … and the full name in title (22c). */+.dv-sha.dv-sha-whole { display: inline-block; max-width: 100%; height: auto; padding: 1px 5px; line-height: 18px; vertical-align: bottom;+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }/* A branch inside a sentence wraps with the text (pre-push one-line cards, Mira ui-check-475 must-fix 1). */.dv-sha.dv-sha-wrap { display: inline; height: auto; white-space: normal; overflow-wrap: anywhere;padding: 1px 5px; line-height: 20px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }diff --git a/frontend/tests/jiraSetup.test.mjs b/frontend/tests/jiraSetup.test.mjsindex 0c0f4325..120badec 100644--- a/frontend/tests/jiraSetup.test.mjs+++ b/frontend/tests/jiraSetup.test.mjs@@ -579,6 +579,10 @@ test('19d: a rejected token says the day when it was not today; Checked stays aconst line = () => r.host.querySelector('[data-jira-status]').textContent;assert.equal(line(), `Jira stopped accepting the token ${m.atClock(rejected)}. Nothing new is picked up.`);assert.match(line(), /^Jira stopped accepting the token on .+ at \S+/, 'another day: "on <day> at <time>"');+ // 22c: when the line wraps, the dot sits beside line 1, not between the lines.+ const status = r.host.querySelector('[data-jira-status]');+ assert.ok(status.className.includes('items-start') && !status.className.includes('items-center'), status.className);+ assert.match(status.firstElementChild.className, /mt-\[0\.45em\] shrink-0/);r.unmount();m.jiraStore._reset();const polled = new Date(Date.now() - 3 * 86_400_000).toISOString();diff --git a/frontend/tests/timesOneClock.test.mjs b/frontend/tests/timesOneClock.test.mjsnew file mode 100644index 00000000..93a0b447--- /dev/null+++ b/frontend/tests/timesOneClock.test.mjs@@ -0,0 +1,98 @@+// Times: one clock everywhere (roadmap 22c, autonomy/times-one-clock-everywhere/brief.md). The last spots that+// built their own time strings now go through src/clock.ts: the bot computer's terminal log, Import history, a+// verification's time and a goal's check-square tooltip. The Pushed meta line keeps its branch whole. Each site is+// pinned in en-US (12 h) and en-GB (24 h) by passing the locale; the app passes none (the device's own).+import assert from 'node:assert/strict';+import test from 'node:test';+import { readFileSync } from 'node:fs';+import { JSDOM } from 'jsdom';+import { loadBundled } from './bundle.mjs';++process.env.TZ = 'Asia/Kolkata'; // a device that is not on UTC, so a UTC slice would show+const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/', pretendToBeVisual: true });+const g = globalThis;+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Element', 'Node', 'Event', 'CustomEvent', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'localStorage', 'sessionStorage']) {+ if (!(k in dom.window)) continue;+ Object.defineProperty(g, k, { value: dom.window[k], configurable: true, writable: true });+}+g.window.matchMedia ??= () => ({ matches: false, addEventListener() {}, removeEventListener() {} });++const m = await loadBundled(`+ export { stampClock, secondsText, dateClock } from './src/clock';+ export { terminalTime } from './src/components/VirtualMachinePane';+ export { RecentImports } from './src/components/ImportDialog';+ export { Verification, formatWhen } from './src/components/results/Verification';+ export { GoalHeartbeat, beatWhen } from './src/components/Signature';+ export { parsePrepush, storyOf } from './src/dev/prepush';+ export * as fx from './src/dev/prepushFixtures';+ export { PrepushCard } from './src/components/dev/PrepushCard';+ export { renderToStaticMarkup } from 'react-dom/server.browser';+ export { createElement } from 'react';+`);+const h = m.createElement;+const html = (C, props) => m.renderToStaticMarkup(h(C, props));++const AT = '2026-11-16T14:35:12.345Z'; // 8:05:12 PM in Kolkata; the old code showed "14:35:12" (UTC)+const NOW = Date.parse('2026-11-17T09:00:00Z');+const LAST_YEAR = '2025-03-04T14:35:00Z';++test('22c stampClock: always the day, the year only when not this year, in en-US and en-GB', () => {+ assert.deepEqual([m.stampClock(AT, NOW, 'en-US'), m.stampClock(AT, NOW, 'en-GB')], ['Nov 16, 8:05\u00a0PM', '16 Nov, 20:05']);+ assert.deepEqual([m.stampClock(AT, Date.parse(AT), 'en-US'), m.stampClock(AT, Date.parse(AT), 'en-GB')], ['Nov 16, 8:05\u00a0PM', '16 Nov, 20:05'], 'today keeps the day too');+ assert.deepEqual([m.stampClock(LAST_YEAR, NOW, 'en-US'), m.stampClock(LAST_YEAR, NOW, 'en-GB')], ['Mar 4, 2025, 8:05\u00a0PM', '4 Mar 2025, 20:05']);+ assert.equal(m.stampClock('nope', NOW), null);+ assert.equal(m.stampClock(null, NOW), null);+});++test('22c terminal log: the device clock with seconds, not the UTC slice of the ISO string', () => {+ assert.deepEqual([m.terminalTime(AT, 'en-US'), m.terminalTime(AT, 'en-GB')], ['8:05:12\u00a0PM', '20:05:12']);+ assert.notEqual(m.terminalTime(AT, 'en-GB'), '14:35:12', 'not UTC');+ assert.equal(m.terminalTime(AT), m.secondsText(AT), 'the app passes no locale: the device default');+ assert.equal(m.terminalTime('just now'), 'just now', 'an unreadable timestamp shows as it came');+ const src = readFileSync(new URL('../src/components/VirtualMachinePane.tsx', import.meta.url), 'utf8');+ assert.match(src, /className="shrink-0 whitespace-nowrap[^"]*" data-terminal-time/, 'the time never wraps or shrinks');+ assert.match(src, /className="min-w-0 break-words">\$ \{log\.command\}/, 'a long command wraps beside it');+ assert.doesNotMatch(src, /split\('T'\)\[1\]/);+});++test('22c Import history: the row reads the one clock, with " · undone" kept', () => {+ const rec = { id: 'imp_1', created_at: AT, status: 'undone', created: { kwants: [{ id: 'k', name: 'Inbox helper' }] } };+ const out = html(m.RecentImports, { records: [rec], onUndo: () => {}, busyId: null });+ assert.ok(out.includes(`${m.stampClock(AT)} · undone`), out);+ const bad = html(m.RecentImports, { records: [{ ...rec, created_at: 'soon', status: 'applied' }], onUndo: () => {}, busyId: null });+ assert.ok(bad.includes('soon'), 'an unreadable time shows as it came');+ assert.doesNotMatch(bad, /Invalid Date/);+});++test('22c Verification: a check time in en-US and en-GB; an unreadable one shows as it came', () => {+ assert.deepEqual([m.formatWhen(AT, NOW, 'en-US'), m.formatWhen(AT, NOW, 'en-GB')], ['Nov 16, 8:05\u00a0PM', '16 Nov, 20:05']);+ assert.equal(m.formatWhen('later', NOW), 'later');+ assert.equal(m.formatWhen(null, NOW), null);+ const block = {+ id: 'v1', kind: 'verification', summary: '1 of 1 passed', target: { title: 'Deploy' },+ checks: [{ id: 'c1', label: 'Site loads', status: 'passed', checked_at: AT }],+ };+ const out = html(m.Verification, { block });+ assert.ok(out.includes(m.stampClock(AT)), out);+});++test('22c goal check squares: the tooltip time in en-US and en-GB', () => {+ assert.deepEqual([m.beatWhen(AT, NOW, 'en-US'), m.beatWhen(AT, NOW, 'en-GB')], ['Nov 16, 8:05\u00a0PM', '16 Nov, 20:05']);+ assert.equal(m.beatWhen('nope', NOW), undefined);+ assert.equal(m.beatWhen(undefined, NOW), undefined);+ const out = html(m.GoalHeartbeat, { dots: [{ tone: 'ok', label: 'Passed', at: AT }], status: 'ok' });+ assert.ok(out.includes(`title="Passed · ${m.stampClock(AT)}"`), out);+});++test('22c Pushed meta line: the branch stays whole, cut with …, the full name in its title', () => {+ const c = m.parsePrepush(m.fx.PP_NEXT_PUSHED);+ const out = html(m.PrepushCard, { card: c, bot: 'Pixel' });+ const tag = /<code class="dv-sha dv-sha-whole" title="([^"]+)" data-pushed-branch="true">([^<]+)<\/code>/.exec(out);+ assert.ok(tag, out);+ assert.equal(tag[1], tag[2], 'title carries the full branch name');+ const css = readFileSync(new URL('../src/styles/modern.css', import.meta.url), 'utf8');+ assert.match(css, /\.dv-sha\.dv-sha-whole \{[^}]*white-space: nowrap;[^}]*overflow: hidden;[^}]*text-overflow: ellipsis;/);+ assert.match(css, /\.dv-sha\.dv-sha-whole \{[^}]*max-width: 100%/);+ const src = readFileSync(new URL('../src/components/dev/PrepushCard.tsx', import.meta.url), 'utf8');+ assert.equal((src.match(/dv-sha dv-sha-wrap/g) ?? []).length >= 1, true, 'the branch in the prose sentences still wraps');+});