Skip to content

armgit / kwant

Public Imported from GitHub
0

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.

18d clock says day: a past time always says which day (#669)

Oleksandr Ivanchenkofa7aaf22c9ac
diff --git a/frontend/src/clock.ts b/frontend/src/clock.ts
index f1570c4c..95aae912 100644
--- a/frontend/src/clock.ts
+++ b/frontend/src/clock.ts
@@ -80,6 +80,18 @@ export function localClock(at: When, now: number = Date.now(), locale?: string):
return `${dateText(d, { locale, year: d.getFullYear() !== today.getFullYear() })}, ${time}`;
}
+/** A time inside a sentence that says "at": "at 9:40 AM" today, "on Nov 10 at 9:40 AM" on another day, and
+ * "on Nov 10, 2025 at 9:40 AM" in another year ("at 09:40" / "on 10 Nov at 09:40" in en-GB). Same day rule as
+ * `localClock`, with no "yesterday". Null for a missing or unreadable time. (Clock says day, roadmap 18d.) */
+export function atClock(at: When, now: number = Date.now(), locale?: string): string | null {
+ const d = toDate(at);
+ if (!d) return null;
+ const today = new Date(now);
+ const time = timeText(d, { locale })!;
+ if (sameDay(d, today)) return `at ${time}`;
+ return `on ${dateText(d, { locale, year: d.getFullYear() !== today.getFullYear() })} at ${time}`;
+}
+
/** A stored wall-clock "HH:MM" (a routine's `time`) the way this device writes it: "8:30 AM" in en-US,
* "08:30" in en-GB. Anything that isn't HH:MM comes back as it was. */
export function wallClock(hhmm: string, locale?: string): string {
diff --git a/frontend/src/components/DoneDetail.tsx b/frontend/src/components/DoneDetail.tsx
index aad57fc1..3db8877e 100644
--- a/frontend/src/components/DoneDetail.tsx
+++ b/frontend/src/components/DoneDetail.tsx
@@ -348,7 +348,9 @@ export const DoneItemView: React.FC<{
phone?: boolean;
onOpenChat?: () => void;
onEditRoutine?: (id: string) => void;
-}> = ({ item, d, place, hideTitle = false, phone = false, onOpenChat, onEditRoutine }) => {
+ /** The clock the meta line reads "today" from; the device's own when left out. */
+ now?: number;
+}> = ({ item, d, place, hideTitle = false, phone = false, onOpenChat, onEditRoutine, now }) => {
const uid = useId();
const title = doneTitle(item);
return (
@@ -360,7 +362,7 @@ export const DoneItemView: React.FC<{
{title}
</h2>
<p className="text-meta text-zinc-400 break-words" data-done-meta>
- {metaLine(item, d.routine, d.run)}
+ {metaLine(item, d.routine, d.run, now)}
</p>
</div>
</header>
diff --git a/frontend/src/components/GoalsStrip.tsx b/frontend/src/components/GoalsStrip.tsx
index 19e14466..1d593250 100644
--- a/frontend/src/components/GoalsStrip.tsx
+++ b/frontend/src/components/GoalsStrip.tsx
@@ -74,6 +74,7 @@ import {
withKind,
withMetric,
} from '../goals';
+import { atClock } from '../clock';
const focusRing = 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500';
const btn = `inline-flex items-center justify-center gap-1 min-h-[40px] sm:min-h-[28px] px-2.5 rounded-lg text-[11px] font-medium disabled:opacity-50 disabled:cursor-not-allowed ${focusRing}`;
@@ -369,8 +370,8 @@ export const DecisionCard: React.FC<{
/** What a goal says after the person chose Not now: not a request, so no amber and no counting (D1, D3). */
export const declinedText = (at: string | null, now: number): string => {
- const when = clockText(at, now);
- return `${when ? `You chose Not now at ${when}.` : 'Not now.'} The fix waits; it’s dropped if this recovers.`;
+ const when = atClock(at, now);
+ return `${when ? `You chose Not now ${when}.` : 'Not now.'} The fix waits; it’s dropped if this recovers.`;
};
/**
diff --git a/frontend/src/components/InboxNew.tsx b/frontend/src/components/InboxNew.tsx
index 981b7f8b..44c2f671 100644
--- a/frontend/src/components/InboxNew.tsx
+++ b/frontend/src/components/InboxNew.tsx
@@ -619,7 +619,9 @@ const ItemPane: React.FC<{
placeName?: (channelId: string | null) => string | null;
api?: DoneApi;
initial?: DoneDetailData;
-}> = ({ item, runItem, entry, onDone, onHeldResolved, onOpenItemChat, onOpenMessage, onEditRoutine, placeName, api, initial }) => {
+ /** The Inbox's clock, so the meta line says the day for an item from another day. */
+ now?: number;
+}> = ({ item, runItem, entry, onDone, onHeldResolved, onOpenItemChat, onOpenMessage, onEditRoutine, placeName, api, initial, now }) => {
const phone = usePhoneLayout();
const d = useDoneDetail(item, runItem, api ?? defaultDoneApi, initial);
const doneLayout = isDoneGroup(item.group) && (!isReview(item) || isRoutineItem(item));
@@ -635,7 +637,7 @@ const ItemPane: React.FC<{
const place = placeId ? (placeName?.(placeId) ?? null) : null;
const routineId = d.routine?.id;
const edit = onEditRoutine && routineId ? () => onEditRoutine(routineId) : undefined;
- if (!isReview(item)) return <DoneItemView item={item} d={d} place={place} phone={phone} onOpenChat={openChat} onEditRoutine={onEditRoutine} />;
+ if (!isReview(item)) return <DoneItemView item={item} d={d} place={place} phone={phone} now={now} onOpenChat={openChat} onEditRoutine={onEditRoutine} />;
return (
<ReviewItemView
item={item}
@@ -644,7 +646,7 @@ const ItemPane: React.FC<{
onHeldResolved={onHeldResolved}
done={{
title: doneTitle(item),
- meta: metaLine(item, d.routine, d.run),
+ meta: metaLine(item, d.routine, d.run, now),
chips: <DoneChipsAndCheck item={item} d={d} onAddCheck={edit} />,
body: <DoneSections item={item} d={d} place={place} onOpenChat={openChat} onEditRoutine={onEditRoutine} />,
changed: changedState(item, d.message),
@@ -1031,6 +1033,7 @@ export const InboxNew: React.FC<InboxNewProps> = ({
placeName={placeName}
api={doneApi}
initial={doneDetails?.[selItem.id]}
+ now={now}
/>
) : empty ? (
<div className="h-full grid place-items-center text-center" data-pane-empty>
diff --git a/frontend/src/components/ReviewItemView.tsx b/frontend/src/components/ReviewItemView.tsx
index f49af70e..8d63d4b2 100644
--- a/frontend/src/components/ReviewItemView.tsx
+++ b/frontend/src/components/ReviewItemView.tsx
@@ -65,6 +65,7 @@ import {
} from '../reviewItem';
export type { ReviewDone, ReviewEntry } from '../reviewItem';
+import { atClock } from '../clock';
/** The calls the view makes; tests and screenshots pass a fake. */
export interface ReviewItemApi {
@@ -738,7 +739,7 @@ const HeldBox: React.FC<{
denyRef?: React.Ref<HTMLButtonElement>;
onResolve: (d: 'allow_once' | 'deny') => void;
}> = ({ h, n, bot, st, phone, lock, denyRef, onResolve }) => {
- const at = clock(st.at);
+ const at = atClock(st.at ?? null);
const box =
st.state === 'allowed'
? 'border-teal-400/30 bg-teal-400/[0.05]'
@@ -749,10 +750,10 @@ const HeldBox: React.FC<{
st.state === 'allowed' ? (
<span className="text-ok">
<Check size={13} className="inline -mt-0.5 mr-1" aria-hidden="true" />
- You allowed this{at ? ` at ${at}` : ''}. It ran:
+ You allowed this{at ? ` ${at}` : ''}. It ran:
</span>
) : st.state === 'denied' ? (
- <span className="text-zinc-300">You denied this{at ? ` at ${at}` : ''}. It didn’t run.</span>
+ <span className="text-zinc-300">You denied this{at ? ` ${at}` : ''}. It didn’t run.</span>
) : st.state === 'expired' ? (
<span className="text-zinc-300">{st.ran || `This request expired. ${bot} will ask again if it still needs it.`}</span>
) : (
@@ -875,7 +876,7 @@ const SendBackForm: React.FC<{
const RoundBox: React.FC<{ item: ReviewItem }> = ({ item }) => {
const p = item.previous_round!;
- const at = clock(p.sent_back_at);
+ const at = atClock(p.sent_back_at ?? null);
const mine = [...item.criteria].reverse().find((c) => c.source === 'person_note' && c.round_added === item.round.n) ?? null;
const word = (s: InboxCriterion['status']) => (
<strong className={s === 'met' ? 'text-ok' : s === 'not_met' ? 'text-bad' : 'text-zinc-300'}>{CRITERION_WORD[s]}</strong>
@@ -885,7 +886,7 @@ const RoundBox: React.FC<{ item: ReviewItem }> = ({ item }) => {
<h3 className="flex items-center gap-1.5 text-body font-semibold text-zinc-100">
<RotateCcw size={14} aria-hidden="true" /> Round {item.round.n} · what changed since round {item.round.n - 1}
</h3>
- <p className="text-meta text-zinc-400">You sent it back{at ? ` at ${at}` : ''}:</p>
+ <p className="text-meta text-zinc-400">You sent it back{at ? ` ${at}` : ''}:</p>
<blockquote className="border-l-2 border-violet-400/60 bg-white/[0.03] px-3 py-2 text-body text-zinc-100 break-words whitespace-pre-wrap">{p.note}</blockquote>
<ul className="list-disc pl-5 space-y-0.5 text-meta text-zinc-300">
{mine && (
diff --git a/frontend/src/components/dev/TicketCard.tsx b/frontend/src/components/dev/TicketCard.tsx
index 587c2ebc..d5d5ab48 100644
--- a/frontend/src/components/dev/TicketCard.tsx
+++ b/frontend/src/components/dev/TicketCard.tsx
@@ -10,7 +10,7 @@ import { READ_LABEL, READ_STEPS, closedWhy, earnsMatches, onSite, openQuestions,
import { clock } from '../../dev/logic';
import { SiteOrigins, TicketBrief } from './TicketBrief';
import { TicketQuestions } from './TicketQuestions';
-import { dateText } from '../../clock';
+import { atClock, dateText, localClock } from '../../clock';
/** "Nov 5" / "5 Nov" in the viewer's zone and date order, or null. */
export const shortDay = (iso: string | null): string | null => dateText(iso);
@@ -380,8 +380,8 @@ export const TicketCard: React.FC<TicketCardProps> = (props) => {
: t.handed_over_by === 'assignee'
? 'Assigned it to someone else'
: 'It left the ticket search';
- const at = clock(t.taken_back_at);
- line = `${how}${at ? ` at ${at}` : ''}. Work paused; nothing was thrown away. It carries on if the ticket comes back.`;
+ const at = atClock(t.taken_back_at);
+ line = `${how}${at ? ` ${at}` : ''}. Work paused; nothing was thrown away. It carries on if the ticket comes back.`;
acts = (
<>
<Btn k={t.key} onClick={props.onCloseCard}>Close card</Btn>
@@ -562,7 +562,7 @@ export const TicketCard: React.FC<TicketCardProps> = (props) => {
/** Landed's footer (item 7): "#61 merged 11:20 · Brief · Built by Ann and Ben · reviewed by Cody". */
const LandedFoot: React.FC<{ w: ReturnType<typeof workView>; brief: React.ReactNode }> = ({ w, brief }) => {
- const at = clock(w.mergedAt);
+ const at = localClock(w.mergedAt);
const builders = w.builders.length ? w.builders : w.lead ? [w.lead] : [];
const bits: React.ReactNode[] = [];
if (w.pr)
diff --git a/frontend/src/components/dev/TicketQuestions.tsx b/frontend/src/components/dev/TicketQuestions.tsx
index d8c9b006..af47f5ef 100644
--- a/frontend/src/components/dev/TicketQuestions.tsx
+++ b/frontend/src/components/dev/TicketQuestions.tsx
@@ -7,6 +7,7 @@ import { Check, ExternalLink, HelpCircle, Loader2, MessageSquare } from 'lucide-
import type { AskPosted, AskPreview, Brief, BriefQuestion } from '../../dev/tickets';
import { mentionParts, openQuestions } from '../../dev/tickets';
import { clock } from '../../dev/logic';
+import { atClock } from '../../clock';
import { SourceChip, useSiteLink } from './TicketBrief';
export interface TicketQuestionsProps {
@@ -187,7 +188,7 @@ export const TicketQuestions: React.FC<TicketQuestionsProps> = ({ ticketKey, bri
const asked = qs.map((q) => q.asked_on_jira).find(Boolean) ?? null;
const askedTo = asked?.to ?? askTo;
const askedUrl = useSiteLink(asked?.comment_url ?? null);
- const askedAt = clock(asked?.at ?? null);
+ const askedAt = atClock(asked?.at ?? null);
const run = async (fn: () => Promise<void> | void) => {
setBusy(true);
@@ -231,7 +232,7 @@ export const TicketQuestions: React.FC<TicketQuestionsProps> = ({ ticketKey, bri
{lead}’s questions
</h4>
<span className="note" data-asked={asked ? 'yes' : undefined}>
- {asked ? `Asked ${askedTo ?? 'them'} on Jira${askedAt ? ` at ${askedAt}` : ''}. You can still answer here.` : 'At most 3. Each one blocks the build.'}
+ {asked ? `Asked ${askedTo ?? 'them'} on Jira${askedAt ? ` ${askedAt}` : ''}. You can still answer here.` : 'At most 3. Each one blocks the build.'}
</span>
</header>
<ol>
diff --git a/frontend/src/dev/prepush.ts b/frontend/src/dev/prepush.ts
index db8c1af9..e351539d 100644
--- a/frontend/src/dev/prepush.ts
+++ b/frontend/src/dev/prepush.ts
@@ -5,7 +5,7 @@
import { personFetch } from '../auth';
import { DevModeError } from '../devMode';
import { parseFreshEyes, type FreshEyes } from './freshEyes';
-import { timeText } from '../clock';
+import { atClock, localClock, timeText } from '../clock';
const isObj = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
const str = (v: unknown, max = 2000): string | null => (typeof v === 'string' && v.trim() !== '' ? v.slice(0, max) : null);
@@ -412,8 +412,8 @@ export function needsYouLead(c: PrepushCard, bot: string): string {
}
/** P2b's line around the branch, which the card renders as code (Mira Later 6). */
-export function clearedParts(c: PrepushCard): { before: string; branch: string; after: string } {
- const at = hhmm(c.updated_at);
+export function clearedParts(c: PrepushCard, now: number = Date.now()): { before: string; branch: string; after: string } {
+ const at = c.updated_at === null ? null : localClock(c.updated_at, now);
return { before: 'Cleared to push ', branch: c.branch, after: ` after ${plural(requiredPassed(c), 'check')} passed${at ? ` · ${at}` : ''}` };
}
@@ -423,9 +423,9 @@ export function clearedLine(c: PrepushCard): string {
}
// The override's first sentence on its own: what the person did, with no promise about the next push.
-export function overriddenHead(c: PrepushCard): string {
- const at = hhmm(c.override?.at ?? null);
- return `You let this push go${at ? ` at ${at}` : ''} with ${plural(openCount(c), 'finding')} open.`;
+export function overriddenHead(c: PrepushCard, now: number = Date.now()): string {
+ const at = atClock(c.override?.at ?? null, now);
+ return `You let this push go${at ? ` ${at}` : ''} with ${plural(openCount(c), 'finding')} open.`;
}
export function overriddenLine(c: PrepushCard, bot: string): string {
@@ -612,9 +612,9 @@ export const asksLine = (bot: string, a: PushApproval): string =>
a.reason ? `${bot}'s push still needs your OK. ${a.reason.charAt(0).toUpperCase()}${a.reason.slice(1)}. Pushes like this always ask, every time.` : `${bot}'s push still needs your OK. Pushes like this always ask, every time.`;
/** A follow-up card's own lead line, so the two cards read as one story. */
-export const afterRetryLine = (c: PrepushCard): string => {
- const at = hhmm(c.grant?.at ?? null);
- return `After you asked for a fix${at ? ` at ${at}` : ''}.`;
+export const afterRetryLine = (c: PrepushCard, now: number = Date.now()): string => {
+ const at = atClock(c.grant?.at ?? null, now);
+ return `After you asked for a fix${at ? ` ${at}` : ''}.`;
};
/**
diff --git a/frontend/src/doneAway.ts b/frontend/src/doneAway.ts
index 2c81071e..fcf41c7c 100644
--- a/frontend/src/doneAway.ts
+++ b/frontend/src/doneAway.ts
@@ -10,7 +10,7 @@ import { isReview } from './api/inbox';
import { type Routine, type RoutineRun, type Schedule, WEEKDAYS, monthDaysText } from './continuity';
import { parseMetaObject } from './questions';
import { relativeTime } from './away';
-import { dateText, secondsText, timeText, wallClock } from './clock';
+import { dateText, localClock, secondsText, timeText, wallClock } from './clock';
export const NEEDS_GROUPS: InboxGroup[] = ['waiting_on_you', 'failed_or_stuck'];
export const DONE_GROUPS: InboxGroup[] = ['to_review', 'finished'];
@@ -185,15 +185,17 @@ export function scheduleShort(s: Schedule | null | undefined): string {
* "Ben · routine, every Mon 09:00 · ran 22:51 because you pressed Run now". Without the routine it says what
* the item says ("Ben · finished 22:45"); without the run it leaves the why out rather than guess it.
*/
-export function metaLine(item: InboxItem, routine: Routine | null, run: RoutineRun | null): string {
+export function metaLine(item: InboxItem, routine: Routine | null, run: RoutineRun | null, now: number = Date.now()): string {
const bot = isTeamJob(item) ? ledLine(item) : item.kwant_name;
+ // Done items stay a week, so a time from another day says the day (18d): "finished Nov 10, 5:51 PM".
+ const day = (ts: string | null | undefined) => localClock(ts ?? null, now) ?? '';
if (!isRoutineItem(item)) {
- const at = hm(item.timestamp);
+ const at = day(item.timestamp);
return at ? `${bot} · finished ${at}` : bot;
}
const sched = routine ? scheduleShort(routine.schedule) : '';
const parts = [bot, sched ? `routine, ${sched}` : 'routine'];
- const ranAt = hm(run?.started_at ?? null) || hm(item.timestamp);
+ const ranAt = day(run?.started_at) || day(item.timestamp);
if (ranAt) parts.push(`ran ${ranAt}${triggerWords(run?.trigger ?? servedTrigger(item))}`);
return parts.join(' · ');
}
diff --git a/frontend/src/reviewItem.ts b/frontend/src/reviewItem.ts
index e21689fc..5248f23b 100644
--- a/frontend/src/reviewItem.ts
+++ b/frontend/src/reviewItem.ts
@@ -7,7 +7,7 @@ import type { CriterionStatus, InboxItem, ReviewItem, VerdictResult } from './ap
import { VERDICT_WORD } from './api/inbox';
import type { RestorePreview, RestoreResult } from './missions';
import { TIER_LABELS } from './flightSchool';
-import { localClock } from './clock';
+import { atClock, localClock } from './clock';
/** What the item view hands back when an action is done (Pixel's pane removes the item, opens the next). */
export interface ReviewDone {
@@ -63,10 +63,10 @@ export function confidenceText(v: ReviewItem['verdict']): string | null {
export function checkerMeta(i: Pick<ReviewItem, 'verdict' | 'risk'>): string | null {
const v = i.verdict;
if (!v.checker || v.result === 'none') return null;
- const at = clock(v.checked_at);
+ const at = atClock(v.checked_at ?? null);
const parts: string[] = [];
if (v.checker.tier_note === 'different_tier') parts.push(`Checked on a different tier of ${v.checker.engine} (no other engine set up)`);
- else parts.push(`Checked by fresh eyes on ${v.checker.engine}${at ? ` at ${at}` : ''}`);
+ else parts.push(`Checked by fresh eyes on ${v.checker.engine}${at ? ` ${at}` : ''}`);
if (isNum(v.steps_run) && isNum(v.steps_total) && v.steps_total > 0) {
if (v.steps_run === v.steps_total) parts.push(i.risk.level === 'high' ? `all ${v.steps_total} steps, because it’s high risk` : `all ${v.steps_total} steps`);
else parts.push(`${v.steps_run} of ${v.steps_total} steps`);
diff --git a/frontend/tests/goals.test.mjs b/frontend/tests/goals.test.mjs
index 5ef346e3..40ffcb99 100644
--- a/frontend/tests/goals.test.mjs
+++ b/frontend/tests/goals.test.mjs
@@ -625,6 +625,10 @@ test('D1/D3: Not now calls the route once, silently; the goal then reads Failing
assert.equal(b.goalDecision(server, [], NOW).kind, 'declined');
assert.equal(b.declinedText(minsAgo(0), NOW), 'You chose Not now at ' + new Date(NOW).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) + '. The fix waits; it’s dropped if this recovers.');
assert.match(b.declinedText(null, NOW), /^Not now\./);
+ // 18d: a Not now from another day says its day, "on Nov 1 at 9:40 AM", never "at Nov 1, 9:40 AM".
+ const day = new Date(NOW - 26 * 3600_000);
+ const want = `on ${day.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })} at ${day.toLocaleTimeString(undefined, { timeStyle: 'short' }).replace(/\u202f/g, ' ')}`;
+ assert.equal(b.declinedText(day.toISOString(), NOW), `You chose Not now ${want}. The fix waits; it’s dropped if this recovers.`);
});
test('D1: on a server without the route, Not now only hides it here; any other error undoes the hide and says so', async () => {
diff --git a/frontend/tests/inboxAway095.test.mjs b/frontend/tests/inboxAway095.test.mjs
index 100544a6..a5b2460f 100644
--- a/frontend/tests/inboxAway095.test.mjs
+++ b/frontend/tests/inboxAway095.test.mjs
@@ -69,13 +69,20 @@ test('sections: Needs you holds waiting and failed, Done holds to review and fin
test('meta line: what ran, when, and why; without the run it leaves the why out', () => {
const it = fx.AWAY_ROUTINE_REVIEW;
- assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, fx.AWAY_RUN), 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM because you pressed Run now');
- assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, { ...fx.AWAY_RUN, trigger: 'schedule' }), 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM on schedule');
- assert.equal(a.metaLine({ ...it, source: undefined }, null, null), 'Ben · routine · ran 10:51 PM');
+ const SAME_DAY = Date.parse('2026-11-11T23:30:00Z'); // the run's own day
+ assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, fx.AWAY_RUN, SAME_DAY), 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM because you pressed Run now');
+ assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, { ...fx.AWAY_RUN, trigger: 'schedule' }, SAME_DAY), 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM on schedule');
+ assert.equal(a.metaLine({ ...it, source: undefined }, null, null, SAME_DAY), 'Ben · routine · ran 10:51 PM');
// Part B's source.trigger, when the run isn't loaded; an app event says so (Needs B 5).
- assert.equal(a.metaLine(it, null, null), 'Ben · routine · ran 10:51 PM because you pressed Run now');
- assert.equal(a.metaLine({ ...it, source: { ...it.source, trigger: 'event' } }, null, null), 'Ben · routine · ran 10:51 PM on an app event');
- assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, { ...fx.AWAY_RUN, trigger: 'event' }), 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM on an app event');
+ assert.equal(a.metaLine(it, null, null, SAME_DAY), 'Ben · routine · ran 10:51 PM because you pressed Run now');
+ assert.equal(a.metaLine({ ...it, source: { ...it.source, trigger: 'event' } }, null, null, SAME_DAY), 'Ben · routine · ran 10:51 PM on an app event');
+ assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, { ...fx.AWAY_RUN, trigger: 'event' }, SAME_DAY), 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM on an app event');
+ // 18d: read the next day (the fixture's own now), the time says its day; another year adds the year.
+ const NEXT_DAY = Date.parse(fx.AWAY_INBOX.now);
+ assert.equal(a.metaLine(it, fx.AWAY_ROUTINE, fx.AWAY_RUN, NEXT_DAY), 'Ben · routine, every Mon 9:00 AM · ran Nov 11, 10:51 PM because you pressed Run now');
+ assert.equal(a.metaLine(fx.AWAY_HANDOFF, null, null, NEXT_DAY), 'Cody · finished Nov 11, 10:45 PM');
+ assert.equal(a.metaLine(fx.AWAY_HANDOFF, null, null, Date.parse('2027-01-04T09:00:00Z')), 'Cody · finished Nov 11, 2026, 10:45 PM');
+ assert.equal(a.metaLine({ ...fx.AWAY_HANDOFF, timestamp: 'nope' }, null, null, NEXT_DAY), 'Cody', 'a bad time drops the time');
assert.equal(a.scheduleShort({ type: 'daily', time: '08:30', tz: 'UTC' }), 'every day 8:30 AM');
assert.equal(a.scheduleShort({ type: 'interval', every_minutes: 120 }), 'every 2 h');
assert.equal(a.scheduleShort(null), '');
@@ -161,7 +168,7 @@ test('pane order: meta, chips, answer with Open in chat, What Ben did, Why, then
for (let i = 1; i < els.length; i++) {
assert.ok(els[i - 1].compareDocumentPosition(els[i]) & Node.DOCUMENT_POSITION_FOLLOWING, `${order[i - 1]} comes before ${order[i]}`);
}
- assert.equal(q('[data-done-meta]').textContent, 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM because you pressed Run now');
+ assert.equal(q('[data-done-meta]').textContent, 'Ben · routine, every Mon 9:00 AM · ran Nov 11, 10:51 PM because you pressed Run now');
assert.match(q('[data-chip="read-only"]').textContent, /Read only · changed nothing/);
assert.match(q('[data-chip="no-checks"]').textContent, /No checks set · Add one/);
// F2: a neutral chip, not amber; F1: the inline links stay compact and keep the 44 px tap area.
@@ -216,7 +223,7 @@ test('a team job opens in the pane: led-by meta, the lead’s answer, the team
const opened = [];
const { q, qa, root } = await mountInbox({ onOpenMessage: (t) => opened.push(t) });
await click(q('[data-option="tj-spring"]'));
- assert.equal(q('[data-done-meta]').textContent, 'Ann led Ben and Cody · finished 10:45 PM');
+ assert.equal(q('[data-done-meta]').textContent, 'Ann led Ben and Cody · finished Nov 11, 10:45 PM');
assert.equal(q('[data-done-answer] h3').textContent, 'Ann’s answer');
assert.match(q('[data-answer-text]').textContent, /^Done: Ben checked 2 shops/, 'the served excerpt, as text');
assert.equal(q('[data-done-trail] h3').textContent, 'What the team did');
@@ -251,7 +258,7 @@ test('F7: a finished hand-off with no review and no part B fields: summary answe
const chats = [];
const { q, root } = await mountInbox({ onOpen: (i) => chats.push(i.id) }, data);
await click(q('[data-option="d-spring"]'));
- assert.equal(q('[data-done-meta]').textContent, 'Cody · finished 10:45 PM');
+ assert.equal(q('[data-done-meta]').textContent, 'Cody · finished Nov 11, 10:45 PM');
assert.match(q('[data-answer-text]').textContent, /Drafted the sale email/);
assert.equal(q('[data-done-trail]'), null, 'no trail for a job the API has no steps for');
assert.equal(q('[data-redo]').textContent.trim(), 'Ask Cody to redo in chat');
@@ -280,7 +287,7 @@ test('the pane loads routine, run and message itself through the done api', asyn
await click(q('[data-option="r-prices"]'));
await settle(20);
assert.deepEqual(calls, ['routines', 'runs:rt-prices', 'message:m-prices']);
- assert.equal(q('[data-done-meta]').textContent, 'Ben · routine, every Mon 9:00 AM · ran 10:51 PM because you pressed Run now');
+ assert.equal(q('[data-done-meta]').textContent, 'Ben · routine, every Mon 9:00 AM · ran Nov 11, 10:51 PM because you pressed Run now');
assert.equal(q('[data-chip="read-only"]') !== null, true);
root.unmount();
});
diff --git a/frontend/tests/oneClock.test.mjs b/frontend/tests/oneClock.test.mjs
index ee6d235e..dc5634f6 100644
--- a/frontend/tests/oneClock.test.mjs
+++ b/frontend/tests/oneClock.test.mjs
@@ -45,6 +45,24 @@ for (const [name, run, want] of TABLE) {
test(`clock: ${name} in en-US and en-GB`, () => assert.deepEqual(run().map(n), want));
}
+// 18d (clock says day): a time inside an "at" sentence. Today: "at 8:15 PM"; another day: "on Nov 10 at 8:15 PM";
+// another year: "on Nov 10, 2025 at 8:15 PM". No "yesterday". Read at a fixed now on the Monday of AT.
+test('clock: atClock says the day when it is not today, in en-US and en-GB', () => {
+ const NOW = Date.parse('2026-11-16T22:00:00Z');
+ const at = (t, l) => n(m.atClock(t, NOW, l));
+ assert.deepEqual([at(AT, 'en-US'), at(AT, 'en-GB')], ['at 8:15 PM', 'at 20:15']);
+ assert.deepEqual([at(MORNING, 'en-US'), at(MORNING, 'en-GB')], ['at 8:30 AM', 'at 08:30']);
+ const OTHER = '2026-11-10T09:40:00Z';
+ assert.deepEqual([at(OTHER, 'en-US'), at(OTHER, 'en-GB')], ['on Nov 10 at 9:40 AM', 'on 10 Nov at 09:40']);
+ const YESTERDAY = '2026-11-15T23:59:00Z';
+ assert.deepEqual([at(YESTERDAY, 'en-US'), at(YESTERDAY, 'en-GB')], ['on Nov 15 at 11:59 PM', 'on 15 Nov at 23:59']);
+ const LAST_YEAR = '2025-11-10T09:40:00Z';
+ assert.deepEqual([at(LAST_YEAR, 'en-US'), at(LAST_YEAR, 'en-GB')], ['on Nov 10, 2025 at 9:40 AM', 'on 10 Nov 2025 at 09:40']);
+ for (const bad of [null, undefined, '', 'not a time']) assert.equal(m.atClock(bad, NOW, 'en-US'), null);
+ // The same day rule as localClock: the two agree on which times are today.
+ for (const t of [AT, MORNING, OTHER, YESTERDAY, LAST_YEAR]) assert.equal(m.atClock(t, NOW, 'en-US').startsWith('at '), m.localClock(t, NOW, 'en-US') === m.timeText(t, { locale: 'en-US' }));
+});
+
test('clock: missing or unreadable times give null; wallClock keeps what it cannot read', () => {
for (const f of [m.timeText, m.dateText, m.weekdayClock, m.dateClock]) {
assert.equal(f(null), null);
diff --git a/frontend/tests/prepush.test.mjs b/frontend/tests/prepush.test.mjs
index ea9ecab9..e10bb69a 100644
--- a/frontend/tests/prepush.test.mjs
+++ b/frontend/tests/prepush.test.mjs
@@ -2,6 +2,11 @@
// the Inbox "Needs you" item, the "Checked with fresh eyes" chip (R1–R3) and the semgrep tile.
// Data is shaped like Juno's card_json (ba2157a5); see src/dev/prepushFixtures.ts.
process.env.TZ = 'UTC';
+// 18d: a time from another day says its day ("on Nov 10 at 9:40 AM"). These fixtures are read late on their own
+// day, so the copy below stays time only; the clock still ticks. The other-day copy has its own test.
+const realNow = Date.now.bind(Date);
+const fixtureShift = realNow() - Date.parse('2026-11-09T23:00:00Z');
+Date.now = () => realNow() - fixtureShift;
import assert from 'node:assert/strict';
import test, { afterEach } from 'node:test';
diff --git a/frontend/tests/prepushGrant.test.mjs b/frontend/tests/prepushGrant.test.mjs
index 0b741567..4a6d2c6c 100644
--- a/frontend/tests/prepushGrant.test.mjs
+++ b/frontend/tests/prepushGrant.test.mjs
@@ -1,5 +1,10 @@
// 0.9.7 prepush-grant (Pixel): the card after retry/override, one Needs-you item per branch, superseded.
process.env.TZ = 'UTC';
+// 18d: a time from another day says its day ("on Nov 10 at 9:40 AM"). These fixtures are read late on their own
+// day, so the copy below stays time only; the clock still ticks. The other-day copy has its own test.
+const realNow = Date.now.bind(Date);
+const fixtureShift = realNow() - Date.parse('2026-11-09T23:00:00Z');
+Date.now = () => realNow() - fixtureShift;
import assert from 'node:assert/strict';
import test, { afterEach } from 'node:test';
@@ -453,3 +458,22 @@ test('round 3: in the thread, a "newer" link lands on the live card at the end o
const ss = host.querySelector('#prepush-pp_next [data-superseded-by]');
if (ss) { await click(ss); assert.ok(host.querySelector('#prepush-pp_live').classList.contains('kw-prepush-flash'), 'the Replaced card\'s own link too'); }
});
+
+// 18d (clock says day): the override and retry sentences say "on Nov 9 at 2:09 PM" when read on another day,
+// "at 2:09 PM" on the same day; P2b's tail carries the day too. Never "at Nov 9, 2:09 PM".
+test('18d: prepush sentences with "at" say the day when it was not today', () => {
+ const SAME = Date.UTC(2026, 10, 9, 23, 0);
+ const NEXT = Date.UTC(2026, 10, 10, 9, 0);
+ const NEXT_YEAR = Date.UTC(2027, 0, 4, 9, 0);
+ const over = m.parsePrepush(m.fx.PP_OVERRIDDEN);
+ assert.equal(m.overriddenHead(over, SAME), 'You let this push go at 2:09 PM with 1 finding open.');
+ assert.equal(m.overriddenHead(over, NEXT), 'You let this push go on Nov 9 at 2:09 PM with 1 finding open.');
+ assert.equal(m.overriddenHead(over, NEXT_YEAR), 'You let this push go on Nov 9, 2026 at 2:09 PM with 1 finding open.');
+ const next = m.parsePrepush(m.fx.PP_NEXT_CHECKING);
+ assert.equal(m.afterRetryLine(next, SAME), 'After you asked for a fix at 2:10 PM.');
+ assert.equal(m.afterRetryLine(next, NEXT), 'After you asked for a fix on Nov 9 at 2:10 PM.');
+ const clear = m.parsePrepush(m.fx.PP_CLEAR);
+ assert.equal(m.clearedParts(clear, SAME).after, ' after 5 checks passed · 2:02 PM');
+ assert.equal(m.clearedParts(clear, NEXT).after, ' after 5 checks passed · Nov 9, 2:02 PM');
+ assert.equal(m.overriddenHead({ ...over, override: null }, NEXT), 'You let this push go with 1 finding open.');
+});
diff --git a/frontend/tests/reviewItemView.test.mjs b/frontend/tests/reviewItemView.test.mjs
index 6e6ec9ac..51b6c9ca 100644
--- a/frontend/tests/reviewItemView.test.mjs
+++ b/frontend/tests/reviewItemView.test.mjs
@@ -439,3 +439,43 @@ test('copy has no emoji and no HTML from data', async () => {
assert.doesNotMatch(el.textContent, /\p{Extended_Pictographic}/u);
}
});
+
+// 18d (clock says day): a held action or a send-back from another day says the day, "on Nov 10 at 9:40 AM";
+// today it stays "at 9:40 AM". The day is the device's own, so the pattern allows any locale's short date.
+test('18d: "You allowed / denied / sent it back" say the day when it was not today', async () => {
+ const daysAgo = (d) => new Date(Date.now() - d * 86_400_000).toISOString();
+ const ON_DAY = String.raw`on (?:[A-Z][a-z]{2} \d{1,2}|\d{1,2} [A-Z][a-z]{2})(?:,? \d{4})? at \d{1,2}:\d{2}(?:\s?[AP]M)?`;
+ const allowed = { ...FX.heldAllowed, held_actions: FX.heldAllowed.held_actions.map((h) => ({ ...h, resolved_at: daysAgo(3) })) };
+ let r = await mount(allowed, fakeApi().api);
+ assert.match(r.q('[data-held]').textContent.replace(/\s+/g, ' '), new RegExp(`You allowed this ${ON_DAY}\\. It ran:`));
+ r.root?.unmount?.();
+ const denied = { ...FX.heldDenied, held_actions: FX.heldDenied.held_actions.map((h) => ({ ...h, resolved_at: daysAgo(2) })) };
+ r = await mount(denied, fakeApi().api);
+ assert.match(r.qa('[data-held]')[0].textContent.replace(/\s+/g, ' '), new RegExp(`You denied this ${ON_DAY}\\. It didn’t run\\.`));
+ assert.doesNotMatch(r.qa('[data-held]')[0].textContent, / at (?:[A-Z][a-z]{2} \d|\d{1,2} [A-Z][a-z]{2}),/, 'never "at Nov 10, 9:40 AM"');
+ const back = { ...FX.failRoundLimit, previous_round: { ...FX.failRoundLimit.previous_round, sent_back_at: daysAgo(4) } };
+ r = await mount(back, fakeApi().api);
+ assert.match(r.q('[data-round-box]').textContent.replace(/\s+/g, ' '), new RegExp(`You sent it back ${ON_DAY}:`));
+ // Today: the time alone, after "at".
+ const today = { ...FX.heldAllowed, held_actions: FX.heldAllowed.held_actions.map((h) => ({ ...h, resolved_at: new Date().toISOString() })) };
+ r = await mount(today, fakeApi().api);
+ assert.match(r.q('[data-held]').textContent.replace(/\s+/g, ' '), /You allowed this at \d{1,2}:\d{2}(?:\s?[AP]M)?\. It ran:/);
+});
+
+// 18d round 2 (Mira): the checker line says the day the same way, "Checked by fresh eyes on Codex on Nov 10 at
+// 9:55 AM" another day and "... at 9:55 AM" today; never "at Nov 10, 9:55 AM".
+test('18d: the checker line says the day when the check was not today', () => {
+ const t = new Date(); const at955 = (back) => new Date(t.getFullYear(), t.getMonth(), t.getDate() - back, 9, 55).toISOString();
+ const item = (checked_at) => ({ ...FX.heldAllowed, verdict: { ...FX.heldAllowed.verdict, result: 'pass', checker: { engine: 'Codex' }, checked_at } });
+ const before = m.checkerMeta(item(at955(5)));
+ assert.match(before, /^Checked by fresh eyes on Codex on (?:[A-Z][a-z]{2} \d{1,2}|\d{1,2} [A-Z][a-z]{2})(?:,? \d{4})? at (?:9:55\s?AM|09:55)/);
+ assert.doesNotMatch(before, / at (?:[A-Z][a-z]{2} \d|\d{1,2} [A-Z][a-z]{2}),/, 'never "at Nov 10, 9:55 AM"');
+ if (Intl.DateTimeFormat().resolvedOptions().locale === 'en-US') {
+ const d = new Date(at955(5));
+ const day = d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', ...(d.getFullYear() !== t.getFullYear() ? { year: 'numeric' } : {}) });
+ assert.ok(before.startsWith(`Checked by fresh eyes on Codex on ${day} at 9:55 AM`), before);
+ }
+ assert.match(m.checkerMeta(item(at955(0))), /^Checked by fresh eyes on Codex at (?:9:55\s?AM|09:55)(?: ·|$)/);
+ assert.equal(m.checkerMeta(item(null)).startsWith('Checked by fresh eyes on Codex'), true);
+ assert.doesNotMatch(m.checkerMeta(item(null)), / at | on Codex on /);
+});
diff --git a/frontend/tests/tickets.test.mjs b/frontend/tests/tickets.test.mjs
index 7cbc1d22..da2b567b 100644
--- a/frontend/tests/tickets.test.mjs
+++ b/frontend/tests/tickets.test.mjs
@@ -1,6 +1,11 @@
// 0.7.6 "Work from Jira" (Iris): the ticket card in every state, the brief, the questions with the
// Ask on Jira preview, Matches the ticket on the Review card, the parsers' fallbacks, and Off = no tab.
process.env.TZ = 'UTC';
+// 18d: a time from another day says its day ("on Nov 10 at 9:40 AM"). These fixtures are read late on their own
+// day, so the copy below stays time only; the clock still ticks. The other-day copy has its own test.
+const realNow = Date.now.bind(Date);
+const fixtureShift = realNow() - Date.parse('2026-11-07T23:00:00Z');
+Date.now = () => realNow() - fixtureShift;
import assert from 'node:assert/strict';
import test, { afterEach } from 'node:test';
@@ -673,3 +678,21 @@ test('D6: an engine_refused card shows the server’s sentence word for word, wi
const other = m.parseTicket(fx.ticket('failed', { error: { code: 'something_new', message: 'A sentence kwant wrote.' } }));
assert.match(html(m.TicketCard, { ...N, ticket: other }), /A sentence kwant wrote\./);
});
+
+// 18d (clock says day): read the next day, a ticket card's times say their day. "…at" sentences read
+// "on Nov 7 at 10:12 AM"; the landed footer reads "merged Nov 7, 11:20 AM".
+test('18d: ticket cards say the day when a time was not today', () => {
+ const now = Date.now;
+ Date.now = () => Date.parse('2026-11-08T09:00:00Z');
+ try {
+ const back = html(m.TicketCard, { ...N, ticket: T('taken_back'), onCloseCard: () => {} });
+ assert.match(back, / on Nov 7 at 10:12 AM\. Work paused; nothing was thrown away\./);
+ assert.doesNotMatch(back, / at Nov 7, /);
+ const landed = html(m.TicketCard, { ...N, ticket: T('landed'), brief: B(fx.BRIEF_ANSWERED) });
+ assert.match(landed, /merged Nov 7, 11:20 AM/);
+ const asked = html(m.TicketCard, { ...N, ticket: T('needs_answer'), brief: B(fx.BRIEF_ASKED), onAskPreview: async () => fx.ASK_PREVIEW });
+ assert.match(asked, /Asked Dana Park on Jira on Nov 7 at 10:04 AM\. You can still answer here\./);
+ } finally {
+ Date.now = now;
+ }
+});