Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix(app): pluralize proactive counts and date rows that aren't today
  • Loading branch information
zakiego committed Nov 24, 2026
commit fd97561078641bd4022814853c60daf006880176
6 changes: 6 additions & 0 deletions apps/app/src/components/agent-proactive.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,9 @@ test("saves run in order, and two failures go back to what the server last confi
await waitFor(() => expect(screen.getByRole("switch", { name: "Skip groups" }).getAttribute("aria-checked")).toBe("true"))
expect(screen.getByRole("switch", { name: "Tell me when an event changes" }).getAttribute("aria-checked")).toBe("true")
})

test("counts read right at one", async () => {
api.getProactiveFn.mockResolvedValue(view({ enabled: true, chatId: "chat_web", ticksToday: 1, sentToday: 1 }))
render(<AgentProactive agentId="agt_palui" />)
expect(await screen.findByText("1 check · 1 sent")).toBeTruthy()
})
15 changes: 9 additions & 6 deletions apps/app/src/components/agent-proactive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
type ProactiveView,
} from "@/lib/api/proactive"
import { clockTime, errorMessage } from "@/lib/format"
import { useT } from "@/lib/i18n"
import { useCount, useT } from "@/lib/i18n"
import type { Key } from "@/lib/i18n/en"

type T = ReturnType<typeof useT>
Expand All @@ -57,6 +57,8 @@ function merged(cfg: ProactiveConfig, patch: ProactivePatch): ProactiveConfig {
return out as ProactiveConfig
}

const sameDay = (ms: number) => new Date(ms).toDateString() === new Date().toDateString()
const shortDay = (ms: number) => new Date(ms).toLocaleDateString(undefined, { day: "numeric", month: "short" })
const shownAt = (n: ProactiveNudge) => (n.status === "scheduled" && n.wakeAt ? n.wakeAt : (n.sentAt ?? n.updatedAt))
const byTime = (list: ProactiveNudge[]) => [...list].sort((a, b) => shownAt(b) - shownAt(a))

Expand All @@ -82,6 +84,7 @@ const STATUS: Record<NudgeStatus, { tone: StatusTone; key: Key }> = {

export function AgentProactive({ agentId }: { agentId: string }) {
const t = useT()
const count = useCount()
const [view, setView] = React.useState<ProactiveView | null>(null)
const [error, setError] = React.useState<string | null>(null)
const [checking, setChecking] = React.useState(false)
Expand Down Expand Up @@ -342,10 +345,7 @@ export function AgentProactive({ agentId }: { agentId: string }) {
title={t("proactive.activity")}
action={
<span className="text-sm text-muted-foreground tabular-nums">
{t("proactive.activityCounts", {
checks: view.ticksToday.toLocaleString(),
sent: view.sentToday.toLocaleString(),
})}
{count(view.ticksToday, "proactive.checksOne", "proactive.checksMany")} · {count(view.sentToday, "proactive.sentOne", "proactive.sentMany")}
</span>
}
>
Expand Down Expand Up @@ -671,7 +671,10 @@ function ActivityRow({ n, t, important, onImportant }: { n: ProactiveNudge; t: T
const isSummary = n.kind === "sum_morning" || n.kind === "sum_evening"
return (
<li className="flex min-w-0 items-start gap-3 py-2.5 first:pt-0 last:pb-0">
<span className="w-[8.5ch] shrink-0 pt-0.5 font-mono text-caption text-muted-foreground tabular-nums">{clockTime(at)}</span>
<span className="flex w-[8.5ch] shrink-0 flex-col pt-0.5 font-mono text-caption text-muted-foreground tabular-nums">
{clockTime(at)}
{!sameDay(at) && <span>{shortDay(at)}</span>}
</span>
<Icon aria-hidden={true} className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span dir="auto" className="min-w-0 text-sm [overflow-wrap:anywhere]">
Expand Down
5 changes: 4 additions & 1 deletion apps/app/src/lib/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@ export const en = {
"proactive.mutes": "Muted",
"proactive.unmute": "Unmute",
"proactive.activity": "Today",
"proactive.activityCounts": "{checks} checks · {sent} sent",
"proactive.checksOne": "{n} check",
"proactive.checksMany": "{n} checks",
"proactive.sentOne": "{n} sent",
"proactive.sentMany": "{n} sent",
"proactive.activityNone": "Nothing yet.",
"proactive.escalated": "reminded again",
"proactive.markImportant": "Mark {name} important",
Expand Down
5 changes: 4 additions & 1 deletion apps/app/src/lib/i18n/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,10 @@ export const id: Record<Key, string> = {
"proactive.mutes": "Di-mute",
"proactive.unmute": "Buka lagi",
"proactive.activity": "Hari ini",
"proactive.activityCounts": "{checks} cek · {sent} dikirim",
"proactive.checksOne": "{n} cek",
"proactive.checksMany": "{n} cek",
"proactive.sentOne": "{n} dikirim",
"proactive.sentMany": "{n} dikirim",
"proactive.activityNone": "Belum ada.",
"proactive.escalated": "diingetin lagi",
"proactive.markImportant": "Tandai {name} penting",
Expand Down