Skip to content

Conversation

@djedi
Copy link
Owner

@djedi djedi commented Dec 12, 2025

Summary

  • Fixes race condition where saving a note triggered a spurious "Note updated elsewhere" warning
  • Moves markNoteUpdatedLocally() call to before the save API request so SSE events arriving during the save are properly ignored

Test plan

  • Save a note and verify no "Note updated elsewhere" warning appears
  • Open same note in two browsers, edit in one, verify the other still shows the warning appropriately

Move markNoteUpdatedLocally() call before the save API request
to fix a race condition where the SSE event could arrive before
the await returned, causing a spurious "Note updated elsewhere"
warning when saving your own notes.
Copilot AI review requested due to automatic review settings December 12, 2025 17:19
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 addresses a race condition where SSE (Server-Sent Events) notifications can arrive during the save API request, causing spurious "Note updated elsewhere" warnings in the UI. The fix moves the markNoteUpdatedLocally() call from after the await returns to before the API request is made, ensuring that SSE events arriving during the save operation are properly deduplicated.

Key Changes

  • Moves markNoteUpdatedLocally() to execute before the API call in both Note.vue and Day.vue
  • Day.vue adds additional logic to handle new notes that receive a uuid from the server
  • Maintains the 2-second deduplication window to prevent false SSE processing

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
client/src/views/Note.vue Moves SSE deduplication marker before save API call to prevent race condition
client/src/views/Day.vue Moves SSE deduplication marker before save API call and adds handling for newly-assigned uuids

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 136 to 137
try {
note.value = await NoteService.saveNote(updatedNote);
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

This implementation is incomplete compared to Day.vue. When saving a new note (without a uuid), the server will assign a uuid in the response. However, unlike Day.vue (lines 183-186), this code doesn't mark the newly assigned uuid as locally updated. This means SSE events for the newly created note could still trigger false warnings until the 2-second dedup window expires.

Consider adding the same logic as Day.vue after the save:

  • Check if res.uuid is different from the original note.value.uuid
  • If so, mark the new uuid as locally updated

Copilot uses AI. Check for mistakes.
@djedi djedi merged commit 9490d2b into master Dec 12, 2025
7 checks passed
@djedi djedi deleted the fix/SSE-notification-bug branch December 12, 2025 17:22
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.

2 participants