From 4c7356544f514d177fd1910fe0ae6304ca6cc3b0 Mon Sep 17 00:00:00 2001 From: yoji export Date: Tue, 1 Dec 2026 00:38:37 +0000 Subject: [PATCH] Export yoji from 33baa16efd4c --- convex/agent.test.ts | 29 +++++++++++++++++++++++++- convex/agent.ts | 6 +++--- convex/agentSchema.ts | 2 ++ convex/integrations.test.ts | 2 +- package.json | 2 +- src/renderer/src/actions.tsx | 5 +++-- src/renderer/src/captainWindow.test.ts | 3 ++- src/renderer/src/drag.tsx | 8 +++---- src/renderer/src/editEvents.tsx | 6 +++--- src/renderer/src/layers/BlockPop.tsx | 4 ++-- src/shared/agent.test.ts | 4 +++- src/shared/agent.ts | 6 +++--- src/shared/agentClient.test.ts | 17 ++++++++++++++- src/shared/agentClient.ts | 1 + src/shared/i18n/locales/de/agents.ts | 1 + src/shared/i18n/locales/de/time.ts | 1 + src/shared/i18n/locales/en/agents.ts | 1 + src/shared/i18n/locales/en/time.ts | 1 + src/shared/i18n/locales/es/agents.ts | 1 + src/shared/i18n/locales/es/time.ts | 1 + src/shared/i18n/locales/fr/agents.ts | 1 + src/shared/i18n/locales/fr/time.ts | 1 + src/shared/i18n/locales/ja/agents.ts | 1 + src/shared/i18n/locales/ja/time.ts | 1 + src/shared/time.ts | 2 ++ src/shared/timeFormat.test.ts | 9 +++++++- 26 files changed, 92 insertions(+), 24 deletions(-) diff --git a/convex/agent.test.ts b/convex/agent.test.ts index c0b827a..1cd5757 100644 --- a/convex/agent.test.ts +++ b/convex/agent.test.ts @@ -189,7 +189,10 @@ describe('yoji Agent', () => { '{"reply": "YJ-1 is on Monday at 12."}', ); const { reply, messageId } = await ask(t, 'put orbit on monday at noon'); - expect(reply.cards[0]).toMatchObject({ state: 'applied', undoable: true, lines: [{ label: 'YJ-1', text: 'Time', to: 'Mon, Oct 26 12pm' }] }); + expect(reply.cards[0]).toMatchObject({ state: 'applied', undoable: true, lines: [{ label: 'YJ-1', text: 'Time', to: 'Mon, Oct 26 · 12pm' }] }); + expect(reply.cards[0].appliedAt).toBeUndefined(); + const { generate } = await import('./ai'); + expect(vi.mocked(generate).mock.calls.at(-1)![1].at(-1)!.content).toContain('Applied now, not a proposal: nothing waits for Apply'); const s = await snap(); const task = s.tasks.find((x) => x.num === 1)!; expect(task.day).toBeUndefined(); @@ -203,6 +206,30 @@ describe('yoji Agent', () => { vi.useRealTimers(); }); + it('proposes a time block, and once Apply is pressed the card reads Applied and the next turn knows it was applied', async () => { + vi.useFakeTimers(); + const { t, snap } = await setup(); + const { generate } = await import('./ai'); + replies.push( + '{"propose": true, "calls": [{"tool": "scheduleAt", "args": {"task": "YJ-1", "day": "2026-12-01", "time": "13:00", "duration": 120}}]}', + '{"reply": "I proposed a 2 hour block on Tue Dec 1 at 1pm. It waits for you to press Apply."}', + ); + const { reply, messageId, chatId } = await ask(t, 'block 2 hours for orbit on dec 1 at 1pm'); + expect(reply.cards[0]).toMatchObject({ state: 'proposed', lines: [{ label: 'YJ-1', text: 'Time', from: 'Tue, Oct 20', to: 'Tue, Dec 1 · 1pm' }] }); + expect(reply.cards[0].appliedAt).toBeUndefined(); + expect(vi.mocked(generate).mock.calls.at(-1)![1].at(-1)!.content).toContain('not applied'); + expect((await snap()).sessions).toHaveLength(0); + expect(await t.mutation(api.agent.applyCard, { messageId, cardId: reply.cards[0].id, skip: [] })).toEqual({ ok: true }); + const applied = (await t.query(api.agent.messages, { chatId })).find((m) => m._id === messageId)!.cards[0]; + expect(applied).toMatchObject({ state: 'applied', undoable: true, after: reply.cards[0].after, appliedAt: expect.any(Number), lines: [{ text: 'Time', to: 'Tue, Dec 1 · 1pm' }] }); + expect((await snap()).sessions).toEqual([expect.objectContaining({ day: '2026-12-01', start: 780, end: 900 })]); + await ask(t, 'thanks', chatId); + const past = vi.mocked(generate).mock.calls.at(-1)![1].find((m) => m.role === 'assistant')!.content; + expect(past).toContain('[proposal they applied with Apply]'); + expect(past).not.toContain('proposal waiting for Apply'); + vi.useRealTimers(); + }); + it('saves a playbook, and Undo removes it', async () => { vi.useFakeTimers(); const { t } = await setup(); diff --git a/convex/agent.ts b/convex/agent.ts index 9f3a62e..9424bff 100644 --- a/convex/agent.ts +++ b/convex/agent.ts @@ -226,7 +226,7 @@ export const applyCard = userMutation({ if (card.state !== 'proposed') throw new ConvexError('That proposal was already handled'); try { const done = await applyCalls(ctx, card.calls, skip, card.id); - await ctx.db.patch(m._id, { cards: withCard(m, i, card.after === undefined ? done : { ...done, after: card.after }) }); + await ctx.db.patch(m._id, { cards: withCard(m, i, { ...done, ...(card.after === undefined ? {} : { after: card.after }), appliedAt: Date.now() }) }); return { ok: true as const }; } catch (e) { if (!(e instanceof CallError)) throw e; @@ -535,7 +535,7 @@ function pastReply(m: Doc<'agentMessages'>): string { ? `[Slack message to ${c.draft.to}, ${c.state === 'sent' ? 'sent' : c.state === 'undone' ? 'sent, then deleted from Slack' : c.state === 'discarded' ? 'discarded, not sent' : 'waiting for Send, not sent'}]\n${c.draft.text.slice(0, 400)}` : c.draft ? `[${c.kind === 'reply' ? 'reply' : 'question'} drafted for ${c.draft.to}, not sent${c.state === 'discarded' ? ', discarded' : ''}]\n${c.draft.text.slice(0, 400)}` - : `[${c.state === 'proposed' ? 'proposal waiting for Apply' : c.state === 'applied' ? 'applied' : c.state}]\n${c.lines.map(lineText).join('\n')}`); + : `[${c.state === 'proposed' ? 'proposal waiting for Apply' : c.state === 'applied' ? (c.appliedAt ? 'proposal they applied with Apply' : 'applied') : c.state}]\n${c.lines.map(lineText).join('\n')}`); return [m.text || '(no reply)', ...cards].join('\n'); } @@ -820,7 +820,7 @@ export const run = internalAction({ } else { const done = await ctx.runMutation(internal.agent.commit, { messageId, calls: batch, cardId: `c${++cards}` }); world = await ctx.runQuery(internal.agent.world, { today: world.today }); - result = 'error' in done ? `Error: ${done.error}. Nothing was changed.` : `Applied (${callName(world.me)} sees it with Undo):\n${done.lines.map(lineText).join('\n')}`; + result = 'error' in done ? `Error: ${done.error}. Nothing was changed.` : `Applied now, not a proposal: nothing waits for Apply (${callName(world.me)} sees it with Undo):\n${done.lines.map(lineText).join('\n')}`; } } catch (e) { if (!(e instanceof CallError)) throw e; diff --git a/convex/agentSchema.ts b/convex/agentSchema.ts index df58763..829d726 100644 --- a/convex/agentSchema.ts +++ b/convex/agentSchema.ts @@ -66,6 +66,8 @@ export const agentCard = v.object({ error: v.optional(v.string()), /** How many of the reply's steps came before this card, so the apps list it where it happened among them. */ after: v.optional(v.number()), + /** When you pressed Apply on this proposal. A change the agent made straight away has none. */ + appliedAt: v.optional(v.number()), }); export const agentContext = v.object({ diff --git a/convex/integrations.test.ts b/convex/integrations.test.ts index 7808b47..6bbdc9f 100644 --- a/convex/integrations.test.ts +++ b/convex/integrations.test.ts @@ -845,7 +845,7 @@ describe('disconnect', () => { const ids = [await connection(t, 'google'), await connection(t, 'slack'), await connection(t, 'asana'), await connection(t, CANVAS)]; for (const id of ids) await t.mutation(api.integrations.disconnect, { id }); await settle(t); - expect(revoked).toEqual([['google', 'secret-refresh', null], ['slack', null, 'Bearer secret-access'], ['asana', 'secret-refresh', 'asana-secret']]); + expect(revoked.sort(([a], [b]) => a.localeCompare(b))).toEqual([['asana', 'secret-refresh', 'asana-secret'], ['google', 'secret-refresh', null], ['slack', null, 'Bearer secret-access']]); expect(await t.run((ctx) => ctx.db.query('connections').collect())).toEqual([]); }); }); diff --git a/package.json b/package.json index f458b3a..a8ebd52 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yoji", "productName": "yoji", - "version": "0.1.2", + "version": "0.1.3", "private": true, "description": "A desktop app for your tasks, calendar, inbox and AI agents, on a Convex backend you own.", "license": "Apache-2.0", diff --git a/src/renderer/src/actions.tsx b/src/renderer/src/actions.tsx index e82f68e..bb7748f 100644 --- a/src/renderer/src/actions.tsx +++ b/src/renderer/src/actions.tsx @@ -9,6 +9,7 @@ import { addDays, day0, dayLabel, + dayTime, dkey, dur, fromKey, @@ -377,7 +378,7 @@ export function pickMenu(kind: PickKind): Picker | undefined { // when const len = blockMode ? b!.end - b!.start : t!.length || 60; const apply = (day: string, time: number | null, L?: number | null) => { - const msg = to(time != null ? `${dayLabel(day)} ${tshort(time)}` : dayLabel(day)); + const msg = to(time != null ? dayTime(dayLabel(day), tshort(time)) : dayLabel(day)); if (blockMode) { const s = liveB(); if (!s) return; @@ -399,7 +400,7 @@ export function pickMenu(kind: PickKind): Picker | undefined { const day = p.day || todayKey(), L = blockMode ? len : p.length || len; out.push({ label: - p.time != null ? `${longDate(day)} · ${range(p.time, Math.min(1440, p.time + L))}` : longDate(day), + p.time != null ? dayTime(longDate(day), range(p.time, Math.min(1440, p.time + L))) : longDate(day), icon: I.enter, keys: ['↵'], run: () => apply(day, p.time, blockMode ? null : p.length), diff --git a/src/renderer/src/captainWindow.test.ts b/src/renderer/src/captainWindow.test.ts index 1c586b8..155ef6e 100644 --- a/src/renderer/src/captainWindow.test.ts +++ b/src/renderer/src/captainWindow.test.ts @@ -6,6 +6,7 @@ import { act, createElement } from 'react'; import { createRoot, type Root } from 'react-dom/client'; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import type { Captain, CaptainMessage, CaptainView } from '../../shared/captains'; +import { slow } from '../../../scripts/testTimeout'; import { WINDOW_MAX, WINDOW_OPEN } from './chatWindow'; const state = vi.hoisted(() => ({ view: null as CaptainView | null, earlier: [] as CaptainMessage[], more: true, loads: 0 })); @@ -100,7 +101,7 @@ describe('scrolling far up a long Captain chat', () => { expect(drawn()).toHaveLength(WINDOW_MAX); expect(state.loads).toBe(TOTAL / PAGE - 1); expect(host.querySelectorAll('.ag-doc > [data-msg]').length).toBeLessThanOrEqual(WINDOW_MAX); - }); + }, slow(15_000)); it('jumps back to the newest message from the top of the history', () => { show('back', TOTAL); diff --git a/src/renderer/src/drag.tsx b/src/renderer/src/drag.tsx index 921be12..17e8a8d 100644 --- a/src/renderer/src/drag.tsx +++ b/src/renderer/src/drag.tsx @@ -4,7 +4,7 @@ import type { MouseEvent as ReactMouseEvent, PointerEvent as ReactPointerEvent } from 'react'; import { snap15, snapEdge, snapMove } from '../../shared/calendar'; import { t as tr } from '../../shared/i18n'; -import { dayLabel, daysBetween, plusDays, range, trunc, tshort } from '../../shared/time'; +import { dayLabel, dayTime, daysBetween, plusDays, range, trunc, tshort } from '../../shared/time'; import { closeBlockPop, draftOpen, HOUR, newBlock, openBlockPop, touchDraft } from './actions'; import { act, getModel } from './data'; import { moveAllDay, moveEvent, moveEventDays } from './editEvents'; @@ -194,7 +194,7 @@ function onUp() { setUI({ sel: { kind: 'block', id: s._id } }); toast( <> - {trunc(m.sessionName(s), 26)} → {`${dayLabel(day)} ${range(s.start, s.end)}`} + {trunc(m.sessionName(s), 26)} → {dayTime(dayLabel(day), range(s.start, s.end))} , true, ); @@ -231,7 +231,7 @@ function onUp() { if (s) toast( <> - {trunc(getModel().sessionName(s), 26)} → {`${dayLabel(mv.day)} ${range(mv.start, mv.end)}`} + {trunc(getModel().sessionName(s), 26)} → {dayTime(dayLabel(mv.day), range(mv.start, mv.end))} , true, ); @@ -252,7 +252,7 @@ function onUp() { void act( { kind: 'schedule', id: task._id, day: g.day, time: g.start }, <> - {title} → {`${dayLabel(g.day)} ${tshort(g.start)}`} + {title} → {dayTime(dayLabel(g.day), tshort(g.start))} , ); else if (dd) diff --git a/src/renderer/src/editEvents.tsx b/src/renderer/src/editEvents.tsx index 8251506..c10692f 100644 --- a/src/renderer/src/editEvents.tsx +++ b/src/renderer/src/editEvents.tsx @@ -1,7 +1,7 @@ // Changes to Google Calendar events from yoji: shown at once as pending edits, sent to Google through // Convex, undoable from the toast or with ⌘Z, and put back with a short error if Google refuses. import type { ReactNode } from 'react'; -import { dayLabel, dkey, plusDays, range, shiftDays, trunc } from '../../shared/time'; +import { dayLabel, dayTime, dkey, plusDays, range, shiftDays, trunc } from '../../shared/time'; import { pushUndoStep } from './data'; import { atMinute, clearPending, eventLook, eventTitle, getIntegrationsSource, integrationError, NO_TITLE, revertPatch, setPending, type EventPatch, type ExternalEvent, type NewEvent } from './integrationsData'; import { toast } from './store'; @@ -43,7 +43,7 @@ export function updateEvent(e: ExternalEvent, patch: EventPatch, msg?: ReactNode export function moveEvent(e: ExternalEvent, day: string, start: number, end: number): void { updateEvent(e, { start: atMinute(day, start), end: atMinute(day, end) }, ( <> - {trunc(eventTitle(e.title), 26)} → {`${dayLabel(day)} ${range(start, end)}`} + {trunc(eventTitle(e.title), 26)} → {dayTime(dayLabel(day), range(start, end))} )); } @@ -64,7 +64,7 @@ export function moveEventDays(e: ExternalEvent, n: number): void { const min = (d: Date) => d.getHours() * 60 + d.getMinutes(); updateEvent(e, { start: start.getTime(), end: end.getTime() }, ( <> - {trunc(eventTitle(e.title), 26)} → {`${dayLabel(dkey(start))} ${range(min(start), min(end))}`} + {trunc(eventTitle(e.title), 26)} → {dayTime(dayLabel(dkey(start)), range(min(start), min(end)))} )); } diff --git a/src/renderer/src/layers/BlockPop.tsx b/src/renderer/src/layers/BlockPop.tsx index 1444c62..baad392 100644 --- a/src/renderer/src/layers/BlockPop.tsx +++ b/src/renderer/src/layers/BlockPop.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactElement } from 'react'; import { parseClock, planSubtaskOn, sessionSuggestions, suggestionNote, typedTask, type Suggestion } from '../../../shared/calendar'; import { parseLen } from '../../../shared/parse'; -import { dayLabel, dur, longDate, range, blockTime, trunc } from '../../../shared/time'; +import { dayLabel, dayTime, dur, longDate, range, blockTime, trunc } from '../../../shared/time'; import { idOf, PREFIX, STATUS_KEY, type Task } from '../../../shared/types'; import { useT } from '../../../shared/i18n/react'; import { Rich } from './SettingsLanguage'; @@ -196,7 +196,7 @@ export function BlockPop({ id, focus, layerKey }: { id: string; focus?: 'title' void act( { kind: 'moveSession', id, day, start, end }, <> - {trunc(getModel().sessionName(s), 26)} → {`${dayLabel(day)} ${range(start, end)}`} + {trunc(getModel().sessionName(s), 26)} → {dayTime(dayLabel(day), range(start, end))} , ); }; diff --git a/src/shared/agent.test.ts b/src/shared/agent.test.ts index 115c499..20cd834 100644 --- a/src/shared/agent.test.ts +++ b/src/shared/agent.test.ts @@ -118,7 +118,9 @@ describe('planCalls', () => { const p = planCalls(w, [{ tool: 'scheduleAt', args: { task: 'YJ-27', day: '2026-10-26', time: '12:00' } }]); expect(p.items[0]).toMatchObject({ op: { kind: 'schedule', id: 't27', day: '2026-10-26', time: 720 } }); expect(p.items[0]).not.toMatchObject({ op: { length: expect.anything() } }); - expect(p.lines[0]).toMatchObject({ text: 'Time', from: 'Tue, Oct 20', to: 'Mon, Oct 26 12pm' }); + expect(p.lines[0]).toMatchObject({ text: 'Time', from: 'Tue, Oct 20', to: 'Mon, Oct 26 · 12pm' }); + expect(planCalls(w, [{ tool: 'scheduleAt', args: { task: 'YJ-27', day: '2026-12-01', time: '13:00' } }]).lines[0]).toMatchObject({ text: 'Time', to: 'Tue, Dec 1 · 1pm' }); + expect(planCalls(w, [{ tool: 'scheduleAt', args: { task: 'YJ-31', day: '2026-12-01', time: '13:00' } }]).lines[0]).toMatchObject({ text: 'Time', from: expect.stringMatching(/^\w{3}, \w{3} \d+ · \d+(:\d\d)?[ap]m$/), to: 'Tue, Dec 1 · 1pm' }); expect(needsApproval(p, false)).toBe(false); const moved = planCalls(w, [{ tool: 'scheduleAt', args: { task: 'YJ-31', day: '2026-10-26', time: '2:00 PM', duration: 45 } }]); expect(moved.items[0]).toMatchObject({ op: { kind: 'schedule', id: 't31', day: '2026-10-26', time: 840, length: 45 } }); diff --git a/src/shared/agent.ts b/src/shared/agent.ts index 130eb78..389c268 100644 --- a/src/shared/agent.ts +++ b/src/shared/agent.ts @@ -5,7 +5,7 @@ import type { Op, TaskPatch } from './ops'; import { overlay } from './overlay'; import { callName } from './profile'; import { SEND_MAX } from './slackSend'; -import { addDays, dkey, fromKey, tshort, weekdayMonthDay, weekdayName } from './time'; +import { addDays, dayTime, dkey, fromKey, tshort, weekdayMonthDay, weekdayName } from './time'; import { promptLanguageLine, type Lang } from './i18n'; import { alwaysAsks, outbound, safeName, type SourceGuard } from './toolTrust'; import { PREFIX, SNAME, STATUSES, type ChecklistItem, type Status, type TaskFields, type TaskOwner } from './types'; @@ -655,8 +655,8 @@ export function planCalls(w: World, calls: AgentCall[], skip: string[] = []): Pl if (s && solo && s.day === a.day && s.start === time && s.end - s.start === duration) return; touch(t); plan.items.push({ kind: 'op', op: { kind: 'schedule', id: t._id, day: a.day, time, ...(a.duration !== undefined ? { length: duration } : {}) }, key }); - const was = s ? `${shortDate(s.day)} ${tshort(s.start)}` : before ? shortDate(before) : 'None'; - plan.lines.push(fieldLine(key, t, 'Time', was, `${shortDate(a.day)} ${tshort(time)}`)); + const was = s ? dayTime(shortDate(s.day), tshort(s.start)) : before ? shortDate(before) : 'None'; + plan.lines.push(fieldLine(key, t, 'Time', was, dayTime(shortDate(a.day), tshort(time)))); return; } if (tool === 'addSubtasks' || tool === 'setSubtasks') { diff --git a/src/shared/agentClient.test.ts b/src/shared/agentClient.test.ts index e1bfe2f..17bf436 100644 --- a/src/shared/agentClient.test.ts +++ b/src/shared/agentClient.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import type { ChangeLine } from './agent'; -import { cardBrief, FOLD_LINES, groupLines, toggleSkip, type AgentCard } from './agentClient'; +import { cardBrief, cardTitle, FOLD_LINES, groupLines, toggleSkip, type AgentCard } from './agentClient'; import { MARK_PETALS } from './agentMark'; const lines: ChangeLine[] = [ @@ -35,6 +35,21 @@ describe('groupLines', () => { }); }); +describe('cardTitle', () => { + const time = [{ key: '0', label: 'YJ-118', task: 't1', text: 'Time', from: 'Tue, Dec 1', to: 'Tue, Dec 1 · 1pm' }]; + const of = (state: string, more: object = {}) => cardTitle({ id: 'c', kind: 'edit', state, lines: time, ...more } as unknown as AgentCard); + + it('says Changed for a change the agent made straight away, and Proposed while it waits for Apply', () => { + expect(of('applied')).toBe('Changed'); + expect(of('proposed')).toBe('Proposed'); + }); + + it('says Applied once you pressed Apply, so a reply written while it waited still reads true', () => { + expect(of('applied', { appliedAt: 1 })).toBe('Applied'); + expect(of('undone', { appliedAt: 1 })).toBe('Undone'); + }); +}); + describe('cardBrief', () => { it('summarizes the card in one line', () => { expect(cardBrief(card)).toBe('3 tasks · 2 subtasks · 5 dates'); diff --git a/src/shared/agentClient.ts b/src/shared/agentClient.ts index e2f5f49..3a240e2 100644 --- a/src/shared/agentClient.ts +++ b/src/shared/agentClient.ts @@ -233,6 +233,7 @@ export function cardTitle(card: AgentCard): string { if (card.state === 'proposed') return t('agents.change.proposed'); if (card.state === 'discarded') return t('agents.change.discardedTitle'); if (card.state === 'undone') return t('agents.change.undone'); + if (card.appliedAt) return t('agents.change.appliedTitle'); return t(creates && creates === card.lines.filter((l) => !l.sub).length ? 'agents.change.created' : 'agents.change.changed'); } diff --git a/src/shared/i18n/locales/de/agents.ts b/src/shared/i18n/locales/de/agents.ts index 440050b..e254c78 100644 --- a/src/shared/i18n/locales/de/agents.ts +++ b/src/shared/i18n/locales/de/agents.ts @@ -358,6 +358,7 @@ export default { 'agents.change.discardedTitle': 'Verworfen', 'agents.change.created': 'Erstellt', 'agents.change.changed': 'Geändert', + 'agents.change.appliedTitle': 'Angewendet', 'agents.change.tasks': { one: '{count} Aufgabe', other: '{count} Aufgaben' }, 'agents.change.changes': { one: '{count} Änderung', other: '{count} Änderungen' }, 'agents.change.subtasks': { one: '{count} Unteraufgabe', other: '{count} Unteraufgaben' }, diff --git a/src/shared/i18n/locales/de/time.ts b/src/shared/i18n/locales/de/time.ts index 90f3c60..06b8e49 100644 --- a/src/shared/i18n/locales/de/time.ts +++ b/src/shared/i18n/locales/de/time.ts @@ -9,6 +9,7 @@ export default { 'time.yesterday': 'Gestern', 'time.at': 'um {time}', 'time.onAt': 'am {date} um {time}', + 'time.dayTime': '{date} · {time}', 'time.h': '{h} Std.', 'time.m': '{m} Min.', 'time.hm': '{h} Std. {m} Min.', diff --git a/src/shared/i18n/locales/en/agents.ts b/src/shared/i18n/locales/en/agents.ts index 098c975..ba6754f 100644 --- a/src/shared/i18n/locales/en/agents.ts +++ b/src/shared/i18n/locales/en/agents.ts @@ -356,6 +356,7 @@ export default { 'agents.change.discardedTitle': 'Discarded', 'agents.change.created': 'Created', 'agents.change.changed': 'Changed', + 'agents.change.appliedTitle': 'Applied', 'agents.change.tasks': { one: '{count} task', other: '{count} tasks' }, 'agents.change.changes': { one: '{count} change', other: '{count} changes' }, 'agents.change.subtasks': { one: '{count} subtask', other: '{count} subtasks' }, diff --git a/src/shared/i18n/locales/en/time.ts b/src/shared/i18n/locales/en/time.ts index 57f1da8..3b71b5d 100644 --- a/src/shared/i18n/locales/en/time.ts +++ b/src/shared/i18n/locales/en/time.ts @@ -5,6 +5,7 @@ export default { 'time.yesterday': 'Yesterday', 'time.at': 'at {time}', 'time.onAt': 'on {date} at {time}', + 'time.dayTime': '{date} · {time}', 'time.h': '{h}h', 'time.m': '{m}m', 'time.hm': '{h}h {m}m', diff --git a/src/shared/i18n/locales/es/agents.ts b/src/shared/i18n/locales/es/agents.ts index 913b223..4c75f8c 100644 --- a/src/shared/i18n/locales/es/agents.ts +++ b/src/shared/i18n/locales/es/agents.ts @@ -358,6 +358,7 @@ export default { 'agents.change.discardedTitle': 'Descartado', 'agents.change.created': 'Creado', 'agents.change.changed': 'Cambiado', + 'agents.change.appliedTitle': 'Aplicado', 'agents.change.tasks': { one: '{count} tarea', other: '{count} tareas' }, 'agents.change.changes': { one: '{count} cambio', other: '{count} cambios' }, 'agents.change.subtasks': { one: '{count} subtarea', other: '{count} subtareas' }, diff --git a/src/shared/i18n/locales/es/time.ts b/src/shared/i18n/locales/es/time.ts index 782696c..9407265 100644 --- a/src/shared/i18n/locales/es/time.ts +++ b/src/shared/i18n/locales/es/time.ts @@ -9,6 +9,7 @@ export default { 'time.yesterday': 'Ayer', 'time.at': 'a las {time}', 'time.onAt': 'el {date} a las {time}', + 'time.dayTime': '{date} · {time}', 'time.h': '{h} h', 'time.m': '{m} min', 'time.hm': '{h} h {m} min', diff --git a/src/shared/i18n/locales/fr/agents.ts b/src/shared/i18n/locales/fr/agents.ts index 4f9164d..0ba3ee8 100644 --- a/src/shared/i18n/locales/fr/agents.ts +++ b/src/shared/i18n/locales/fr/agents.ts @@ -358,6 +358,7 @@ export default { 'agents.change.discardedTitle': 'Ignoré', 'agents.change.created': 'Créé', 'agents.change.changed': 'Modifié', + 'agents.change.appliedTitle': 'Appliqué', 'agents.change.tasks': { one: '{count} tâche', other: '{count} tâches' }, 'agents.change.changes': { one: '{count} modification', other: '{count} modifications' }, 'agents.change.subtasks': { one: '{count} sous-tâche', other: '{count} sous-tâches' }, diff --git a/src/shared/i18n/locales/fr/time.ts b/src/shared/i18n/locales/fr/time.ts index ea9ed05..0d4f87f 100644 --- a/src/shared/i18n/locales/fr/time.ts +++ b/src/shared/i18n/locales/fr/time.ts @@ -10,6 +10,7 @@ export default { 'time.yesterday': 'Hier', 'time.at': 'à {time}', 'time.onAt': 'le {date} à {time}', + 'time.dayTime': '{date} · {time}', 'time.h': '{h} h', 'time.m': '{m} min', 'time.hm': '{h} h {m} min', diff --git a/src/shared/i18n/locales/ja/agents.ts b/src/shared/i18n/locales/ja/agents.ts index f894d22..28837f1 100644 --- a/src/shared/i18n/locales/ja/agents.ts +++ b/src/shared/i18n/locales/ja/agents.ts @@ -358,6 +358,7 @@ export default { 'agents.change.discardedTitle': '破棄済み', 'agents.change.created': '作成しました', 'agents.change.changed': '変更しました', + 'agents.change.appliedTitle': '適用しました', 'agents.change.tasks': { other: '{count} 件のタスク' }, 'agents.change.changes': { other: '{count} 件の変更' }, 'agents.change.subtasks': { other: '{count} 件のサブタスク' }, diff --git a/src/shared/i18n/locales/ja/time.ts b/src/shared/i18n/locales/ja/time.ts index 287ba9f..bca5bf3 100644 --- a/src/shared/i18n/locales/ja/time.ts +++ b/src/shared/i18n/locales/ja/time.ts @@ -9,6 +9,7 @@ export default { 'time.yesterday': '昨日', 'time.at': '{time}', 'time.onAt': '{date} {time}', + 'time.dayTime': '{date} · {time}', 'time.h': '{h}時間', 'time.m': '{m}分', 'time.hm': '{h}時間{m}分', diff --git a/src/shared/time.ts b/src/shared/time.ts index a42ec01..5fe69c0 100644 --- a/src/shared/time.ts +++ b/src/shared/time.ts @@ -101,6 +101,8 @@ export const whenAt = (ms: number, now = Date.now()): string => { const d = new Date(ms), time = hm(d.getHours() * 60 + d.getMinutes()); return dkey(d) === dkey(new Date(now)) ? t('time.at', { time }) : t('time.onAt', { date: monthDay(d), time }); }; +/** A day and a time of day kept apart, so "Tue, Dec 1" and "1pm" never run together as "Dec 11pm": "Tue, Dec 1 · 1pm". */ +export const dayTime = (date: string, time: string): string => t('time.dayTime', { date, time }); export const range = (s: number, e: number): string => hour24 ? `${clock(s)} – ${clock(e)}` : mer(s) === mer(e) ? t('time.withPeriod', { time: `${clock(s)} – ${clock(e)}`, period: mer(e) }) : `${hm(s)} – ${hm(e)}`; export const tshort = (m: number): string => { diff --git a/src/shared/timeFormat.test.ts b/src/shared/timeFormat.test.ts index 0b0c196..778514e 100644 --- a/src/shared/timeFormat.test.ts +++ b/src/shared/timeFormat.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, it } from 'vitest'; import { clockTime } from './chatTime'; -import { clock, hm, hourLabel, hourOpt, localeHour24, mer, range, setTimeFormat, blockTime, tshort, whenAt } from './time'; +import { clock, dayTime, hm, hourLabel, hourOpt, localeHour24, mer, range, setTimeFormat, blockTime, tshort, whenAt } from './time'; afterEach(() => setTimeFormat('12')); @@ -14,6 +14,13 @@ describe('time format', () => { expect(hourOpt()).toEqual({ hour12: true }); }); + it('keeps a day and its time apart, so Dec 1 at 1pm never reads as Dec 11pm', () => { + expect(dayTime('Tue, Dec 1', tshort(13 * 60))).toBe('Tue, Dec 1 · 1pm'); + expect(dayTime('Dec 1', range(13 * 60, 15 * 60))).toBe('Dec 1 · 1:00 – 3:00 PM'); + setTimeFormat('24'); + expect(dayTime('Tue, Dec 1', tshort(13 * 60))).toBe('Tue, Dec 1 · 13:00'); + }); + it('reads 24 hour times everywhere when set', () => { setTimeFormat('24'); expect([clock(13 * 60 + 5), mer(13 * 60), hm(9 * 60), hm(21 * 60 + 30, true), clock(0)]).toEqual(['13:05', '', '09:00', '21:30', '00:00']);