-
Notifications
You must be signed in to change notification settings - Fork 51
feat(web): add optimistic rendering for day view event creation #1395
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
feat(web): add optimistic rendering for day view event creation #1395
Conversation
Co-authored-by: tyler-dane <[email protected]>
- 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.
|
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. |
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.
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.
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.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
…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.
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 fromgetDayEventsSlice, so optimistic events weren't visible.Updated
saga.util.ts:insertOptimisticEvent: Insert into both week and day slicesreplaceOptimisticId: Replace IDs in both slicesUpdated
event.sagas.ts:deleteEvent: Delete from both slicesconvertCalendarToSomedayEvent: Restore to both slices on errorDay and week views use independent slices and selectors, so events must be added to both for visibility in either view.
Original prompt
💡 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.