Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

Events created in day view disappear temporarily during DB save, then reappear. Week view already handles this with optimistic rendering.

Changes

The issue was that optimistic event operations only updated getWeekEventsSlice. Day view reads from getDayEventsSlice, so optimistic events weren't visible.

Updated saga.util.ts:

  • insertOptimisticEvent: Insert into both week and day slices
  • replaceOptimisticId: Replace IDs in both slices

Updated event.sagas.ts:

  • deleteEvent: Delete from both slices
  • convertCalendarToSomedayEvent: Restore to both slices on error
// Before
yield put(getWeekEventsSlice.actions.insert(event._id!));

// After
yield put(getWeekEventsSlice.actions.insert(event._id!));
yield put(getDayEventsSlice.actions.insert(event._id!));

Day and week views use independent slices and selectors, so events must be added to both for visibility in either view.

Original prompt

This section details on the original issue you should resolve

<issue_title>Optimistically render events from day view</issue_title>
<issue_description>### Priority

Medium (nice to have)

Feature Description

When a user creates a new event from the day view, the event should always appear on the screen immediately. Currenly, the event preview appears, but then it disappears temporarily as the event is being saved to the DB and returned. Instead, we should optimistically render the event to ensure a smoother UX.

Use Case

No response

Additional Context

This optimistic rendering pattern is already present in the week view. Follow that same pattern.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Implement optimistic rendering for day view events Add optimistic rendering for day view event creation Dec 29, 2025
Copilot AI requested a review from tyler-dane December 29, 2025 21:41
- Introduced comprehensive tests for the event saga to validate optimistic rendering behavior.
- Ensured that events are correctly added to the state with optimistic IDs during creation.
- Verified that events remain in the state during API calls and transition from optimistic to real IDs upon successful API responses.
- Included checks for maintaining event presence in week and day event lists throughout the creation process.
- Updated tests to utilize Schema_Event for event parsing during optimistic rendering.
- Refactored event creation logic in tests to improve clarity and maintainability.
- Ensured consistent handling of optimistic IDs and real IDs throughout the event lifecycle.
@tyler-dane tyler-dane requested a review from Copilot December 29, 2025 23:55
@tyler-dane tyler-dane marked this pull request as ready for review December 29, 2025 23:55
@cursor
Copy link

cursor bot commented Dec 29, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 3.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds optimistic rendering support for event creation in the day view, addressing a UX issue where newly created events temporarily disappeared during the database save operation. The implementation follows the existing pattern already used in the week view.

Key Changes:

  • Updated saga utilities to insert and replace optimistic events in both week and day slices
  • Modified event sagas to delete from and restore to both slices during error handling
  • Added comprehensive test coverage for the optimistic rendering behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/web/src/ducks/events/sagas/saga.util.ts Extended insertOptimisticEvent and replaceOptimisticId to update both week and day slices for calendar events
packages/web/src/ducks/events/sagas/event.sagas.ts Updated deleteEvent and convertCalendarToSomedayEvent error handling to maintain consistency across both slices
packages/web/src/ducks/events/sagas/event.sagas.test.ts Added comprehensive integration tests verifying optimistic event creation, ID replacement, and persistence throughout the lifecycle

The changes are well-structured, consistent, and properly tested. The implementation correctly handles the independent nature of day and week slices by ensuring all optimistic operations update both slices for calendar events (non-someday events).

- Updated tests to include checks for optimistic events in `DraggableTimedAgendaEvent`, ensuring correct rendering and behavior.
- Added logic to prevent opening event previews and forms for optimistic events in `useOpenAgendaEventPreview` and `useOpenEventForm`.
- Refactored event utility functions to streamline optimistic event checks across components.
- Introduced `getEventCursorStyle` utility function to determine cursor styles based on dragging and optimistic event states.
- Updated `StyledEvent` component to utilize the new cursor style utility for improved cursor handling during event interactions.
- Refactored `DraggableAllDayAgendaEvent` and `DraggableTimedAgendaEvent` components to apply the cursor styles dynamically based on event states.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

@tyler-dane tyler-dane changed the title Add optimistic rendering for day view event creation feat(web): add optimistic rendering for day view event creation Dec 30, 2025
…ment

- Added `getEventCursorClass` function to determine cursor classes based on dragging and optimistic event states.
- Updated `DraggableAllDayAgendaEvent` and `DraggableTimedAgendaEvent` components to utilize the new cursor class utility for improved cursor handling during event interactions.
@tyler-dane tyler-dane merged commit 86d6c53 into main Dec 30, 2025
5 checks passed
@tyler-dane tyler-dane deleted the copilot/optimistically-render-events-day-view branch December 30, 2025 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimistically render events from day view

2 participants