From 358534efbf7635677a396667d24c71a7cd6a56a0 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sat, 4 Apr 2026 12:02:10 -0400 Subject: [PATCH] =?UTF-8?q?fix(events):=20audit=20pass=20=E2=80=94=207=20c?= =?UTF-8?q?orrectness=20fixes=20across=20the=20events=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend: - tools.py: apply UTC normalization to update_event datetime fields (matched create_event which already did this) - events.py service: allow end_dt/recurrence/project_id to be cleared via update_event by permitting None for nullable fields - events.py service: find_events_by_query now returns upcoming events first, falling back to past — prevents AI tools from mutating stale past events when a future match exists - events.py service: list_events now uses overlap logic (start <= to AND end >= from) so multi-day events spanning the query boundary are included; previously only start_dt was checked Frontend: - ToolCallCard: fire fable:calendar-changed on created/updated/deleted so CalendarView refetches without requiring a manual page refresh - KnowledgeView: replace raw apiGet('/api/events') with listEvents() client function; also fix today bar which was reading .events off a flat array (always empty) — now correctly receives EventEntry[] - HomeView: use full ISO strings for event date range instead of naive UTC-midnight strings; deduplicate inline date math via _dateRange() Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/components/ToolCallCard.vue | 11 ++++--- frontend/src/views/HomeView.vue | 12 +++---- frontend/src/views/KnowledgeView.vue | 10 +++--- src/fabledassistant/routes/events.py | 14 +++++--- src/fabledassistant/services/events.py | 42 +++++++++++++++++++----- src/fabledassistant/services/tools.py | 5 ++- 6 files changed, 63 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/ToolCallCard.vue b/frontend/src/components/ToolCallCard.vue index f1723c8..54c0fdb 100644 --- a/frontend/src/components/ToolCallCard.vue +++ b/frontend/src/components/ToolCallCard.vue @@ -270,8 +270,11 @@ async function openEventSlideOver(id: number | undefined) { } } -function closeEventSlideOver() { +function closeEventSlideOver(changed = false) { eventSlideOverOpen.value = false; + if (changed) { + document.dispatchEvent(new Event("fable:calendar-changed")); + } } @@ -522,9 +525,9 @@ function closeEventSlideOver() { :event="eventSlideOverEntry" initial-date="" @close="closeEventSlideOver" - @created="closeEventSlideOver" - @updated="closeEventSlideOver" - @deleted="closeEventSlideOver" + @created="() => closeEventSlideOver(true)" + @updated="() => closeEventSlideOver(true)" + @deleted="() => closeEventSlideOver(true)" /> diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index 789fb08..c940f8e 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -77,9 +77,11 @@ function _dateRange() { const today = new Date() const nextWeek = new Date(today) nextWeek.setDate(today.getDate() + 7) + // Use full ISO strings so the server sees the correct UTC equivalent of + // local midnight / end-of-day rather than a naive UTC-midnight guess. return { - todayStr: today.toISOString().slice(0, 10) + 'T00:00:00', - nextWeekStr: nextWeek.toISOString().slice(0, 10) + 'T23:59:59', + todayStr: today.toISOString(), + nextWeekStr: nextWeek.toISOString(), } } @@ -108,11 +110,7 @@ function _backgroundRefresh() { onMounted(async () => { // Phase 1: projects list + cross-project recent items + orphaned items + events — all parallel - const today = new Date(); - const todayStr = today.toISOString().slice(0, 10) + "T00:00:00"; - const nextWeek = new Date(today); - nextWeek.setDate(today.getDate() + 7); - const nextWeekStr = nextWeek.toISOString().slice(0, 10) + "T23:59:59"; + const { todayStr, nextWeekStr } = _dateRange(); const [projectsRes, recentRes, orphanTasksRes, orphanNotesRes, eventsRes] = await Promise.allSettled([ diff --git a/frontend/src/views/KnowledgeView.vue b/frontend/src/views/KnowledgeView.vue index bb3a2cf..ad87da6 100644 --- a/frontend/src/views/KnowledgeView.vue +++ b/frontend/src/views/KnowledgeView.vue @@ -1,7 +1,7 @@