diff --git a/web/src/components/ui/toast.tsx b/web/src/components/ui/toast.tsx index 3d41450..fffa22d 100644 --- a/web/src/components/ui/toast.tsx +++ b/web/src/components/ui/toast.tsx @@ -17,9 +17,16 @@ interface ToastState { let nextId = 1 +// Error toasts no longer auto-dismiss (#85), so a burst of failures could grow +// the stack without bound and push older ones off-screen. Cap it: keep the most +// recent MAX_TOASTS and drop the oldest, so the newest — the one that just +// happened — is always visible. +const MAX_TOASTS = 4 + export const useToastStore = create((set) => ({ toasts: [], - push: (message, tone = 'info') => set((s) => ({ toasts: [...s.toasts, { id: nextId++, message, tone }] })), + push: (message, tone = 'info') => + set((s) => ({ toasts: [...s.toasts, { id: nextId++, message, tone }].slice(-MAX_TOASTS) })), dismiss: (id) => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })), })) @@ -32,21 +39,34 @@ export const toast = { // Param is `item`, not `toast`, so it doesn't shadow the module's `toast` export. function ToastItem({ item }: { item: Toast }) { const dismiss = useToastStore((s) => s.dismiss) + const isError = item.tone === 'error' useEffect(() => { + // Error toasts are the primary report that a mutation failed, so they do NOT + // auto-dismiss — a user who looked away at second 4 would otherwise lose the + // only notice, with nothing to retrieve (#85). Info toasts still time out. + if (isError) return const t = setTimeout(() => dismiss(item.id), 4000) return () => clearTimeout(t) - }, [item.id, dismiss]) + }, [item.id, dismiss, isError]) return (
- {item.message} + {item.message} +
) } diff --git a/web/src/editor/JournalPanel.tsx b/web/src/editor/JournalPanel.tsx index d37c193..fba7d63 100644 --- a/web/src/editor/JournalPanel.tsx +++ b/web/src/editor/JournalPanel.tsx @@ -16,6 +16,11 @@ import { import type { EditorObject } from './types' import { objectDisplayName } from './kinds' +// Shared styling for the small From/To date inputs, so the two stay in step and +// don't drift from each other. +const dateInputClass = + 'rounded-md border border-border bg-surface px-1.5 py-1 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent/40' + /** * The garden's journal: write an entry, read the season back. * @@ -42,7 +47,15 @@ export function JournalPanel({ scopeObjectId: number | null onScopeChange: (id: number | null) => void }) { - const filter = scopeObjectId != null ? { objectId: scopeObjectId } : {} + // Date-range narrowing (#85): the backend and JournalFilter already supported + // from/to; they just had no UI. Empty inputs don't filter. + const [from, setFrom] = useState('') + const [to, setTo] = useState('') + const filter = { + ...(scopeObjectId != null ? { objectId: scopeObjectId } : {}), + ...(from ? { from } : {}), + ...(to ? { to } : {}), + } const journal = useJournal(gardenId, filter) const entries = journal.data?.pages.flatMap((p) => p.entries) ?? [] const scopedObject = objects.find((o) => o.id === scopeObjectId) ?? null @@ -70,6 +83,41 @@ export function JournalPanel({ )} +
+ + + {(from || to) && ( + + )} +
+ {canEdit && ( +

{garden.name} diff --git a/web/src/pages/PublicGardenPage.tsx b/web/src/pages/PublicGardenPage.tsx index 19cd028..7900c00 100644 --- a/web/src/pages/PublicGardenPage.tsx +++ b/web/src/pages/PublicGardenPage.tsx @@ -53,7 +53,7 @@ export function PublicGardenPage() { } return ( -
+

{garden.name}