diff --git a/CHANGELOG.md b/CHANGELOG.md index d27fe81..bd22dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and - Failed and stopped Ask AI answers save their final status before notifying clients, so reloading an ended stream cannot leave the answer busy. - Audio pipeline progress keeps updating after temporary network failures, and interrupted Ask AI answers reconnect without duplicating text. - Transcript searches refresh after re-transcription, and browser transcription progress and notifications follow the interface language. - - Recordings with multiple transcript sources show every source in the transcript switcher, with the preferred source first. The detail API includes all transcripts while keeping the singular `transcription` field for existing clients. - Library text search matches every transcript source available for a recording, including older sources, without duplicate results. - +- The Dashboard marks Plaud setup as skipped in local-only mode instead of incorrectly showing it as completed. +- Saved playback, date/time and sync-on-return preferences take effect immediately without navigating away from Settings. +- Auto-play next starts the next recording in the current library order and stops at the end. Recording dates now follow the selected relative, absolute or ISO format across library rows, detail and player views. +- Returning to the app tab syncs a connected Plaud account when enabled, with a one-minute throttle to avoid repeated syncs during rapid tab switches. - A failure to open or lock the Mac app's instance-lock file now shows a startup error instead of silently exiting as if another copy were running. - Launch at Login keeps its tray check mark in sync after an interface-language change rebuilds the menu. - Changing the Mac app's locale through desktop preferences no longer hangs while rebuilding the tray menu. diff --git a/contract-tests/tests/settings-behavior-ui.spec.ts b/contract-tests/tests/settings-behavior-ui.spec.ts new file mode 100644 index 0000000..1d2578f --- /dev/null +++ b/contract-tests/tests/settings-behavior-ui.spec.ts @@ -0,0 +1,224 @@ +import { type APIRequestContext, type Browser, expect, type Page, type Route, test } from "@playwright/test"; +import { baseURL, clientHeaders, newUserContext, uploadRecording } from "../helpers/api"; + +test.use({ viewport: { width: 1280, height: 800 } }); + +async function account(browser: Browser, patch: Record = {}) { + const api = await newUserContext("settings-behavior"); + expect((await api.put("/api/settings/user", { data: { + onboardingCompleted: true, autoSyncEnabled: false, syncOnMount: false, + syncOnVisibilityChange: false, ...patch, + } })).ok()).toBeTruthy(); + const context = await browser.newContext({ baseURL, locale: "en-US", extraHTTPHeaders: clientHeaders(), storageState: await api.storageState() }); + await context.addInitScript(() => { + const original = window.fetch.bind(window); + (window as unknown as { syncRequests: number }).syncRequests = 0; + window.fetch = (input, init) => { + if (String(input).endsWith("/api/plaud/sync") && init?.method === "POST") { + (window as unknown as { syncRequests: number }).syncRequests++; + } + return original(input, init); + }; + }); + const page = await context.newPage(); + return { api, page, close: async () => { await context.close(); await api.dispose(); } }; +} + +async function recording(api: APIRequestContext, title: string): Promise { + const id = await uploadRecording(api); + expect((await api.patch(`/api/recordings/${id}`, { data: { filename: title } })).ok()).toBeTruthy(); + return id; +} + +async function visibility(page: Page, state: "hidden" | "visible"): Promise { + return page.evaluate((value) => { + Object.defineProperty(document, "visibilityState", { configurable: true, value }); + document.dispatchEvent(new Event("visibilitychange")); + return (window as unknown as { syncRequests: number }).syncRequests; + }, state); +} + +const syncResult = { success: true, newRecordings: 0, updatedRecordings: 0, errors: [], needsReconnect: false }; + +test("auto-play follows filtered name order, plays next, and stops at the last or excluded recording", async ({ browser }) => { + const user = await account(browser, { autoPlayNext: true, recordingListSortOrder: "name" }); + const { page, api } = user; + try { + const bravo = await recording(api, "Queue Bravo"); + const alpha = await recording(api, "Queue Alpha"); + await recording(api, "Excluded"); + await page.goto("/recordings?q=Queue"); + const rows = page.getByTestId("recording-row"); + await expect(rows).toHaveCount(2); + await expect(rows.first()).toContainText("Queue Alpha"); + await rows.first().locator("button").first().click(); + await expect(page.getByTestId("player-play")).toBeEnabled(); + await page.getByTestId("player-play").click(); + await expect.poll(() => page.locator("audio").evaluate((el: HTMLAudioElement) => el.paused)).toBe(false); + await page.locator("audio").evaluate((el: HTMLAudioElement) => { el.pause(); el.dispatchEvent(new Event("ended")); }); + await expect(page.locator("audio")).toHaveAttribute("src", `/api/recordings/${bravo}/audio`); + await expect(rows.filter({ hasText: "Queue Bravo" }).locator("button").first()).toHaveAttribute("aria-current", "true"); + await expect.poll(() => page.locator("audio").evaluate((el: HTMLAudioElement) => el.paused)).toBe(false); + const last = await page.locator("audio").evaluate((el: HTMLAudioElement) => { + el.pause(); el.dispatchEvent(new Event("ended")); return el.getAttribute("src"); + }); + expect(last).toBe(`/api/recordings/${bravo}/audio`); + await rows.filter({ hasText: "Queue Alpha" }).locator("button").first().click(); + await page.getByTestId("player-play").click(); + await page.locator("audio").evaluate((el: HTMLAudioElement) => el.pause()); + await page.getByTestId("recording-search").fill("Queue Bravo"); + await expect(rows).toHaveCount(1); + const excluded = await page.locator("audio").evaluate((el: HTMLAudioElement) => { el.dispatchEvent(new Event("ended")); return el.getAttribute("src"); }); + expect(excluded).toBe(`/api/recordings/${alpha}/audio`); + } finally { await user.close(); } +}); + +test("disabled auto-play and an empty library never advance", async ({ browser }) => { + const user = await account(browser, { autoPlayNext: false, recordingListSortOrder: "name" }); + const { api, page } = user; + try { + await page.goto("/recordings"); + await expect(page.getByTestId("recording-row")).toHaveCount(0); + await page.locator("audio").evaluate((el: HTMLAudioElement) => el.dispatchEvent(new Event("ended"))); + await expect(page.locator("audio")).not.toHaveAttribute("src"); + const id = await recording(api, "First"); + await recording(api, "Second"); + await page.reload(); + const row = page.getByTestId("recording-row").filter({ hasText: "First" }); + await row.locator("button").first().click(); + await expect(page.getByTestId("player-play")).toBeEnabled(); + await page.getByTestId("player-play").click(); + const src = await page.locator("audio").evaluate((el: HTMLAudioElement) => { el.pause(); el.dispatchEvent(new Event("ended")); return el.getAttribute("src"); }); + expect(src).toBe(`/api/recordings/${id}/audio`); + } finally { await user.close(); } +}); + +for (const format of ["relative", "absolute", "iso"] as const) { + test(`${format} dates agree across library, detail and player`, async ({ browser }) => { + const user = await account(browser, { dateTimeFormat: format }); + const { page, api } = user; + try { + const id = await recording(api, "Date preference"); + const start = new Date(Date.now() - 5 * 60_000).toISOString(); + await page.route("**/api/recordings", async (route) => { + const response = await route.fetch(); + const body = await response.json(); + body.recordings = body.recordings.map((r: Record) => ({ ...r, startTime: start })); + await route.fulfill({ response, json: body }); + }); + await page.route(`**/api/recordings/${id}`, async (route) => { + const response = await route.fetch(); + const body = await response.json(); + body.recording.startTime = start; + await route.fulfill({ response, json: body }); + }); + await page.goto("/recordings"); + const expected = format === "iso" ? start : format === "relative" ? "5 minutes ago" : await page.evaluate((value) => new Date(value).toLocaleString("en-US"), start); + const row = page.getByTestId("recording-row"); + await expect(row).toContainText(expected); + await expect(row.locator("button").first()).toHaveAccessibleName(new RegExp(expected.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))); + await row.locator("button").first().click(); + await expect(page.getByTestId("player").locator("time")).toContainText(expected); + await page.getByRole("tab", { name: "Details", exact: true }).click(); + await expect(page.getByTestId("details-card")).toContainText(expected); + } finally { await user.close(); } + }); +} + +test("visibility sync observes saved toggles immediately, respects lock/throttle, and ignores a failed save", async ({ browser }) => { + const user = await account(browser); + const { page } = user; + let held: Route | undefined; + let hold = true; + let failSave = false; + try { + await page.clock.install(); + await page.route("**/api/plaud/connection", (route) => route.fulfill({ json: { connected: true } })); + await page.route("**/api/plaud/sync", async (route) => { + if (hold) { held = route; return; } + await route.fulfill({ json: syncResult }); + }); + await page.route("**/api/settings/user", async (route) => { + if (failSave && route.request().method() === "PUT") { + failSave = false; + await route.fulfill({ status: 500, json: { error: "Save rejected" } }); + } else await route.continue(); + }); + await page.goto("/settings/sync"); + const toggle = page.getByRole("switch", { name: "Sync on tab visibility", exact: true }); + await expect(toggle).not.toBeChecked(); + expect(await visibility(page, "visible")).toBe(0); + await toggle.click(); + await expect(toggle).toBeChecked(); + await expect(toggle).toBeEnabled(); + expect(await visibility(page, "hidden")).toBe(0); + expect(await visibility(page, "visible")).toBe(1); + await expect.poll(() => Boolean(held)).toBe(true); + await page.clock.fastForward(60_001); + expect(await visibility(page, "visible")).toBe(1); + await toggle.click(); + await expect(toggle).not.toBeChecked(); + await expect(toggle).toBeEnabled(); + const finished = page.waitForResponse("**/api/plaud/sync"); + await held!.fulfill({ json: syncResult }); + await (await finished).finished(); + hold = false; + expect(await visibility(page, "visible")).toBe(1); + await toggle.click(); + await expect(toggle).toBeChecked(); + await expect(toggle).toBeEnabled(); + const synced = page.waitForResponse("**/api/plaud/sync"); + expect(await visibility(page, "visible")).toBe(2); + await (await synced).finished(); + expect(await visibility(page, "visible")).toBe(2); + failSave = true; + await toggle.click(); + await expect(page.getByText("Failed to save settings. Changes reverted.", { exact: true })).toBeVisible(); + await expect(toggle).toBeChecked(); + await expect(toggle).toBeEnabled(); + await page.clock.fastForward(60_001); + expect(await visibility(page, "visible")).toBe(3); + await expect(page).toHaveURL(/\/settings\/sync$/); + } finally { await user.close(); } +}); + +for (const gate of ["local-only", "disconnected"] as const) { + test(`visibility sync stays off when ${gate}`, async ({ browser }) => { + const user = await account(browser, { syncOnVisibilityChange: true, plaudEnabled: gate !== "local-only" }); + try { + await user.page.route("**/api/plaud/connection", (route) => route.fulfill({ json: { connected: gate !== "disconnected" } })); + await user.page.goto("/dashboard"); + await expect(user.page.getByRole("heading", { level: 1, name: "Dashboard" })).toBeVisible(); + expect(await visibility(user.page, "visible")).toBe(0); + } finally { await user.close(); } + }); +} + +test("an in-flight shell settings response cannot revert a newer saved visibility preference", async ({ browser }) => { + const user = await account(browser); + const { page } = user; + let stale: { route: Route; body: string } | undefined; + try { + await page.route("**/api/plaud/connection", (route) => route.fulfill({ json: { connected: true } })); + await page.route("**/api/plaud/sync", (route) => route.fulfill({ json: syncResult })); + await page.goto("/settings/playback"); + await expect(page.getByRole("switch", { name: "Auto-play next recording", exact: true })).toBeEnabled(); + await page.route("**/api/settings/user", async (route) => { + if (route.request().method() === "GET") { + const response = await route.fetch(); + stale = { route, body: await response.text() }; + } else await route.continue(); + }); + await page.getByTestId("settings-nav").getByRole("link", { name: "Sync settings", exact: true }).click(); + const toggle = page.getByRole("switch", { name: "Sync on tab visibility", exact: true }); + await expect(toggle).toBeEnabled(); + await expect.poll(() => Boolean(stale)).toBe(true); + await toggle.click(); + await expect(toggle).toBeChecked(); + await expect(toggle).toBeEnabled(); + const response = page.waitForResponse("**/api/settings/user"); + await stale!.route.fulfill({ contentType: "application/json", body: stale!.body }); + await (await response).finished(); + expect(await visibility(page, "visible")).toBe(1); + } finally { await user.close(); } +}); diff --git a/contract-tests/tests/ui-app.spec.ts b/contract-tests/tests/ui-app.spec.ts index 3a31e84..8d0c5cb 100644 --- a/contract-tests/tests/ui-app.spec.ts +++ b/contract-tests/tests/ui-app.spec.ts @@ -247,6 +247,25 @@ test.describe("shell: account menu", () => { }); test.describe("dashboard", () => { + test("local-only mode marks Plaud setup as skipped rather than completed", async ({ browser }) => { + const { api, page, close } = await freshPage(browser); + try { + expect((await api.put("/api/settings/user", { data: { plaudEnabled: false } })).status()).toBe(200); + await page.goto("/dashboard"); + const setup = page.getByRole("region", { name: "Set up" }); + const skipped = setup.getByRole("status", { name: "Connect Plaud — skipped in local-only mode", exact: true }); + await expect(skipped).toBeVisible(); + await expect(skipped).toHaveText("Connect Plaud — skipped in local-only mode"); + await expect(skipped.locator(".text-success")).toHaveCount(0); + await expect(skipped.getByText("Done", { exact: true })).toHaveCount(0); + await expect(setup.getByRole("link", { name: /Connect Plaud/ })).toHaveCount(0); + await expect(setup.getByRole("link", { name: "Add an AI provider" })).toBeVisible(); + expect(await (await api.get("/api/plaud/connection")).json()).toMatchObject({ connected: false }); + } finally { + await close(); + } + }); + test("a new account sees the empty state and the set up list", async ({ browser }) => { const { page, close } = await freshPage(browser); try { diff --git a/spec/plaud.md b/spec/plaud.md index b23c1fb..eb13e2d 100644 --- a/spec/plaud.md +++ b/spec/plaud.md @@ -485,10 +485,11 @@ The web app's shell calls `POST /api/plaud/sync` while a page is open and the co | sync on mount | on | One quiet sync when the app shell loads. Off when `syncOnMount` is `false`. | | interval | 5 minutes | Sync at this interval. The settings offer 1, 2, 5, 10, 15 and 30 minutes. The value is never less than 1 minute. Ticks are skipped while the page is hidden. | | enabled | on | Off when `autoSyncEnabled` is `false`. | +| sync on return | on | On `visibilitychange` to `visible`, sync quietly when `syncOnVisibilityChange` is not `false`, Plaud is enabled and connected without a reconnect requirement. At most one visibility-triggered sync per minute; events during an existing sync are skipped. This setting is independent of interval sync. | Quiet syncs show no toast on success or failure. A sync is not started while another sync from the same page is running. -The interval and on/off are saved as user settings: `syncInterval` (milliseconds), `autoSyncEnabled`, `syncOnMount`, `syncOnVisibilityChange`, `syncNotifications`. The client does not act on `syncOnVisibilityChange`; it is stored only. Browser storage is not used for these settings. +The interval and on/off are saved as user settings: `syncInterval` (milliseconds), `autoSyncEnabled`, `syncOnMount`, `syncOnVisibilityChange`, `syncNotifications`. Browser storage is not used for these settings. The visibility listener is removed when the shell unmounts or the setting or connection no longer permits sync. The worker skips users synced in the last 4 minutes, so a recent browser sync also keeps the worker from running for that user. diff --git a/spec/ui-app.md b/spec/ui-app.md index 7a70528..6fcc506 100644 --- a/spec/ui-app.md +++ b/spec/ui-app.md @@ -153,7 +153,7 @@ When the account has no recordings, the page shows, after the header: - An empty state with the title "No recordings yet". In default mode, the description is "Sync from your Plaud account, or upload an audio file to start your library.". In local-only mode (`plaudEnabled: false`), the description is "Upload audio files or place them into your local storage folder to start your library.". - Buttons: `overview-upload`, "Upload audio" (opens the file picker), and, when `plaudEnabled` is true, `overview-sync`, "Sync now" (or "Syncing…" while busy). - A link "Add an AI provider" to `/settings/providers`, shown only when the account has no AI provider. -- The Set up section (3.6), where Plaud setup is treated as completed when local-only mode is active. +- The Set up section (3.7), where Plaud setup is skipped when local-only mode is active. ### 3.3 Library present @@ -192,7 +192,8 @@ A region named "At a glance" with three tiles. Each tile is a link, shows its la - A section labelled "Set up" with two rows, in this order: "Connect Plaud" (to `/settings/plaud-account`) and "Add an AI provider" (to `/settings/providers`). - A row that is not done is a link. A done row shows a check, the text "Done" for screen readers, and no link. -- The whole section is hidden once Plaud is connected and at least one AI provider exists. +- In local-only mode the Plaud row instead shows "Connect Plaud — skipped in local-only mode", a neutral circle and no link or "Done" label. Its accessible status name matches the visible translated text. +- The whole section is hidden once Plaud is connected or skipped and at least one AI provider exists. ### 3.8 Data @@ -201,6 +202,8 @@ A region named "At a glance" with three tiles. Each tile is a link, shows its la ## 4. Settings +Successful preference saves notify the mounted shell immediately, without navigation or a reload. Auto-play, recording date formatting and visibility sync use the saved values; failed saves do not change the shell. A shell settings request already in flight cannot overwrite a newer successful save. + ### 4.1 Structure - `/settings` has no content of its own. It goes to one section, in this order: @@ -324,6 +327,7 @@ Each section page has a visually hidden level 1 heading "Settings", and its own ### 4.10 Display (`display`) - "Date/time format" (`date-time-format`): "Relative", "Absolute", "ISO". Saves `dateTimeFormat`. + Library row dates (including accessible names), recording detail dates and the player's recorded range share one formatter: Relative uses the interface locale's relative time, Absolute uses the locale's date and time, and ISO uses UTC ISO 8601. Invalid dates render empty; an unset or unknown format falls back to Relative. - "Recording list sort order" (`sort-order`): "Newest first", "Oldest first", "By name". Saves `recordingListSortOrder`. - "Items per page" (`items-per-page`): a whole number from 10 to 100. Values outside the range are ignored and nothing is saved. Saves `itemsPerPage`. - "Theme" (`theme`): "Light", "Dark", "System". Applies at once and is saved (section 6). diff --git a/spec/ui-library.md b/spec/ui-library.md index 038b83c..a90c46d 100644 --- a/spec/ui-library.md +++ b/spec/ui-library.md @@ -334,6 +334,7 @@ The player card has `data-testid="player"`. It contains: - Starting values come from the user's defaults: playback speed, volume (default 75), and auto-play next (when a recording ends, the next row in the list is selected if there is one). + With `autoPlayNext` enabled while the library is open, ending audio selects and plays the next recording in the current filtered and sorted list, including rows beyond the loaded page. The last row stops without wrapping; an ended recording outside that list does not advance. Turning the setting off or leaving the library removes the end listener. - Download menu (the download icon in the header on the library preview; hidden on the detail page, where the actions menu does this): "Download MP3" and "Download original" (`download-original`). "Download MP3" saves the converted file; "Download original" diff --git a/web/src/components/player/player-card.tsx b/web/src/components/player/player-card.tsx index 28022bc..b14d323 100644 --- a/web/src/components/player/player-card.tsx +++ b/web/src/components/player/player-card.tsx @@ -6,8 +6,9 @@ import { Card } from "@/components/ui/card"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { api } from "@/lib/api"; import { downloadRecordings } from "@/lib/downloads"; -import { formatBytes, formatClock } from "@/lib/format"; -import { intlLocale, useI18n } from "@/lib/i18n"; +import { formatBytes, formatClock, formatRecordingDate } from "@/lib/format"; +import { useI18n } from "@/lib/i18n"; +import { useShellData } from "@/components/shell/shell-data"; import { cn } from "@/lib/cn"; import { RECORDINGS_CHANGED } from "@/lib/recordings"; import { PLAYBACK_RATES, usePlayer } from "./player-context"; @@ -68,18 +69,18 @@ export function PlayerCard({ recording, onChanged, sectionRef, className, showHe ); } -/** "Oct 16, 2026 · 11:02 PM–11:02 PM", the start and end of the recording. */ -function recordedRange(startIso: string, durationMs: number): string { +/** The recording's start and end in the preferred date/time format. */ +function recordedRange(startIso: string, durationMs: number, dateTimeFormat: unknown): string { const start = new Date(startIso); const end = new Date(start.getTime() + durationMs); - const date = new Intl.DateTimeFormat(intlLocale(), { month: "short", day: "numeric", year: "numeric" }).format(start); - const time = new Intl.DateTimeFormat(intlLocale(), { hour: "numeric", minute: "2-digit" }); - return `${date} · ${time.format(start)}–${time.format(end)}`; + if (!Number.isFinite(start.getTime()) || !Number.isFinite(end.getTime())) return ""; + return `${formatRecordingDate(start, dateTimeFormat)}–${formatRecordingDate(end, dateTimeFormat)}`; } /** Title, recorded range, length and size, with the audio download on the right. */ function PlayerHeader({ recording }: { recording: PlayerCardRecording }) { const { t } = useI18n(); + const { settings } = useShellData(); const { id, filename, duration, startTime, filesize } = recording; const facts: string[] = [formatClock(duration / 1000)]; if (filesize) facts.push(formatBytes(filesize)); @@ -90,7 +91,7 @@ function PlayerHeader({ recording }: { recording: PlayerCardRecording }) {

{startTime ? ( - {t("library.player.recorded")} + {t("library.player.recorded")} ) : null} {facts.map((fact) => ( diff --git a/web/src/components/recording/details-card.tsx b/web/src/components/recording/details-card.tsx index 941d4f8..5b4b041 100644 --- a/web/src/components/recording/details-card.tsx +++ b/web/src/components/recording/details-card.tsx @@ -1,15 +1,17 @@ import { type ReactNode, useState } from "react"; import { ChevronUp } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { formatBytes, formatClock } from "@/lib/format"; +import { formatBytes, formatClock, formatRecordingDate } from "@/lib/format"; +import { useShellData } from "@/components/shell/shell-data"; import type { Recording } from "@/lib/recordings"; -import { intlLocale, t, useI18n } from "@/lib/i18n"; +import { t, useI18n } from "@/lib/i18n"; /** Read-only facts about the recording file */ export function DetailsCard({ recording }: { recording: Recording }) { const { t } = useI18n(); const [expanded, setExpanded] = useState(true); - const date = new Date(recording.startTime).toLocaleDateString(intlLocale()); + const { settings } = useShellData(); + const date = formatRecordingDate(recording.startTime, settings?.dateTimeFormat); const rows: [string, ReactNode][] = [ [t("recording.details.duration"), formatClock(recording.duration / 1000)], [t("recording.details.fileSize"), fileSize(recording)], diff --git a/web/src/components/recording/recording-header.tsx b/web/src/components/recording/recording-header.tsx index 8fea3cc..7fd0cdd 100644 --- a/web/src/components/recording/recording-header.tsx +++ b/web/src/components/recording/recording-header.tsx @@ -13,7 +13,8 @@ import { } from "@/components/ui/dropdown-menu"; import { errorMessage } from "@/lib/api"; import { downloadRecordings } from "@/lib/downloads"; -import { formatClock, formatDateTime } from "@/lib/format"; +import { formatClock, formatRecordingDate } from "@/lib/format"; +import { useShellData } from "@/components/shell/shell-data"; import { cn } from "@/lib/cn"; import { deleteRecording, type Recording, renameRecording, setStarred, sourceOf } from "@/lib/recordings"; import { buildSrt, buildTranscriptJson, buildVtt, downloadText, safeFileName } from "./exports"; @@ -90,8 +91,9 @@ export function RecordingHeader({ variant, recording, transcript, busy, onTransc const Heading = variant === "page" ? "h1" : "h2"; const hasTimeline = Boolean(transcript?.timeline?.length); + const { settings } = useShellData(); const meta = [ - formatDateTime(recording.startTime), + formatRecordingDate(recording.startTime, settings?.dateTimeFormat), formatClock(recording.duration / 1000), sourceOf(recording) === "upload" ? t("dashboard.sourceUpload") : t("dashboard.sourcePlaud"), ]; diff --git a/web/src/components/recordings/library-model.ts b/web/src/components/recordings/library-model.ts index 9a18f90..2ee073a 100644 --- a/web/src/components/recordings/library-model.ts +++ b/web/src/components/recordings/library-model.ts @@ -1,5 +1,5 @@ import { recordingStage, RECORDING_STAGE_LABELS, type RecordingStage } from "@/components/recording/pipeline-labels"; -import { formatDate, formatDuration, formatTime } from "@/lib/format"; +import { formatDate, formatDuration, formatRecordingDate } from "@/lib/format"; import { sourceOf, type Recording } from "@/lib/recordings"; import { t, tn, type MessageKey } from "@/lib/i18n"; @@ -187,25 +187,10 @@ export function statusOf(r: Recording): RowStatus { return { stage, label: t(RECORDING_STAGE_LABELS[stage]) }; } -/** Relative time in the row's meta line, for example "less than a minute ago" or "12 minutes ago". */ -export function formatAgo(value: string, now: number = Date.now()): string { - const time = Date.parse(value); - if (Number.isNaN(time)) return ""; - const seconds = Math.max(0, (now - time) / 1000); - if (seconds < 60) return t("library.lessThanMinute"); - const minutes = Math.floor(seconds / 60); - if (minutes < 60) return tn("library.minutesAgo", minutes); - const hours = Math.floor(minutes / 60); - if (hours < 24) return tn("library.hoursAgo", hours); - const days = Math.floor(hours / 24); - if (days < 30) return tn("library.daysAgo", days); - return formatDate(value, { dateStyle: "medium" }); -} - /** The row's full accessible name: name, starred, date, duration, source and status. */ -export function rowLabel(r: Recording): string { +export function rowLabel(r: Recording, dateTimeFormat?: unknown): string { const status = statusOf(r); - const when = `${formatDate(r.startTime, { month: "short", day: "numeric", year: "numeric" })}, ${formatTime(r.startTime)}`; + const when = formatRecordingDate(r.startTime, dateTimeFormat); return [r.filename, r.starredAt ? t("library.starred") : null, `${formatClipDuration(r.duration)}`, when, sourceLabel(r), status.label] .filter(Boolean) .join(", "); diff --git a/web/src/components/recordings/recording-row.tsx b/web/src/components/recordings/recording-row.tsx index 0e2b94e..df69eb7 100644 --- a/web/src/components/recordings/recording-row.tsx +++ b/web/src/components/recordings/recording-row.tsx @@ -6,9 +6,10 @@ import { RecordingStatusBadge } from "@/components/ui/status-badge"; import { recordingStage } from "@/components/recording/pipeline-labels"; import { cn } from "@/lib/cn"; import { downloadRecordings } from "@/lib/downloads"; -import { formatClock } from "@/lib/format"; +import { formatClock, formatRecordingDate } from "@/lib/format"; +import { useShellData } from "@/components/shell/shell-data"; import type { Recording } from "@/lib/recordings"; -import { formatAgo, rowLabel, sourceLabel } from "./library-model"; +import { rowLabel, sourceLabel } from "./library-model"; import { useI18n } from "@/lib/i18n"; export interface RowActions { @@ -40,7 +41,8 @@ export interface RecordingRowProps { */ export function RecordingRow({ recording: r, selected, selectMode, checked, compact, transcribing, onActivate, actions }: RecordingRowProps) { const stage = recordingStage(r); - const ago = formatAgo(r.startTime); + const { settings } = useShellData(); + const ago = formatRecordingDate(r.startTime, settings?.dateTimeFormat); const meta = ago ? `${ago} · ${sourceLabel(r)}` : sourceLabel(r); const onSelected = selected && !selectMode; @@ -48,7 +50,7 @@ export function RecordingRow({ recording: r, selected, selectMode, checked, comp

) : ( <> - 0} /> + 0} /> )} @@ -257,23 +257,28 @@ function RowStatus({ recording }: { recording: Recording }) { return ; } -function SetUp({ plaudDone, providerDone }: { plaudDone: boolean; providerDone: boolean }) { - if (plaudDone && providerDone) return null; +function SetUp({ plaudDone, plaudSkipped, providerDone }: { plaudDone: boolean; plaudSkipped: boolean; providerDone: boolean }) { + if ((plaudDone || plaudSkipped) && providerDone) return null; return (

{t("dashboard.setUp")}

    - +
); } -function SetUpRow({ done, title, to }: { done: boolean; title: string; to: string }): ReactNode { - const body = done ? ( +function SetUpRow({ done, skipped = false, title, to }: { done: boolean; skipped?: boolean; title: string; to: string }): ReactNode { + const body = skipped ? ( + <> +