-
Notifications
You must be signed in to change notification settings - Fork 4
updates-99: stuck-stop fix, calendar prefetch, chart polish #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ import { | |
| useCreateEvent, | ||
| useUpdateEvent, | ||
| useDeleteEvent, | ||
| prefetchEvents, | ||
| } from "@/hooks/use-events"; | ||
| import { useOverlayPeople } from "@/hooks/use-overlay-people"; | ||
| import { useGoogleAuthStatus } from "@/hooks/use-google-auth"; | ||
|
|
@@ -142,6 +143,51 @@ export default function CalendarView() { | |
| } = useEvents(from, to, overlayEmails); | ||
| const rawEvents = Array.isArray(rawEventsData) ? rawEventsData : []; | ||
|
|
||
| // Warm the adjacent ranges so j/k (and the chevron buttons) feel instant. | ||
| // Borrowed from the mail template's background-warm pattern — fire-and-forget | ||
| // prefetch that lets React Query dedupe and reuse the response when the user | ||
| // actually navigates. Only runs once the current range has loaded so we | ||
| // don't fight the primary fetch for bandwidth. | ||
| useEffect(() => { | ||
| if (isLoading) return; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Prefetch concurrency: adjacent ranges fetch while primary range is loadingThe guard React with 👍 or 👎 to help me improve. |
||
| const ranges = (() => { | ||
| switch (viewMode) { | ||
| case "month": { | ||
| const next = addMonths(selectedDate, 1); | ||
| const prev = subMonths(selectedDate, 1); | ||
| return [next, prev].map((d) => ({ | ||
| from: startOfWeek(startOfMonth(d)).toISOString(), | ||
| to: endOfWeek(endOfMonth(d)).toISOString(), | ||
| })); | ||
| } | ||
| case "week": { | ||
| // Two weeks forward so rapid `j j` stays instant, plus one back. | ||
| const next = addWeeks(selectedDate, 1); | ||
| const next2 = addWeeks(selectedDate, 2); | ||
| const prev = subWeeks(selectedDate, 1); | ||
| return [next, next2, prev].map((d) => ({ | ||
| from: startOfWeek(d).toISOString(), | ||
| to: endOfWeek(d).toISOString(), | ||
| })); | ||
| } | ||
| case "day": { | ||
| const next = addDays(selectedDate, 1); | ||
| const prev = subDays(selectedDate, 1); | ||
| return [next, prev].map((d) => { | ||
| const start = new Date(d); | ||
| start.setHours(0, 0, 0, 0); | ||
| const end = new Date(d); | ||
| end.setHours(23, 59, 59, 999); | ||
| return { from: start.toISOString(), to: end.toISOString() }; | ||
| }); | ||
| } | ||
| } | ||
| })(); | ||
| for (const range of ranges) { | ||
| void prefetchEvents(queryClient, range.from, range.to, overlayEmails); | ||
| } | ||
| }, [isLoading, viewMode, selectedDate, overlayEmails, queryClient]); | ||
|
|
||
| // Show skeleton only when loading with no cached data (new date range). | ||
| // Tab refocus keeps cached data visible and refetches in background. | ||
| const eventsLoading = isLoading; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 forceStopped now gates submission state, risking race with server run persistence
The new
isRunning = !forceStopped && (...)makes submissions possible immediately after Stop, but the previous run may still be aborting on the server. If the user submits quickly, the server could persist the old run's partial output before the new user message is saved to the database, causing loss or out-of-order history on reconnect.React with 👍 or 👎 to help me improve.