Skip to content

Conversation

@redeck1
Copy link

@redeck1 redeck1 commented Jan 12, 2026

Fixed autosave and quick tab switching. The note id might not match the id in the url

@vercel
Copy link

vercel bot commented Jan 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
codex-ui Ready Ready Preview, Comment Jan 13, 2026 8:42pm

Copy link

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 fixes race conditions that occur when users quickly switch between notes, which could result in data from one note being saved to or displayed for another note. The fix involves capturing note IDs before async operations and validating that the current note ID hasn't changed after async operations complete.

Changes:

  • Added race condition checks in the load() function to prevent setting note data if the current ID changed during the async fetch
  • Captured note ID before save operations to ensure content is saved to the correct note even if the user switches notes during the save
  • Updated the noteTitle watcher to use note ID instead of route path for better consistency

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

Comment on lines 409 to 420
watch(noteTitle, (currentNoteTitle) => {
if (route.name == 'note') {
patchOpenedPageByUrl(
route.path,
{
title: currentNoteTitle,
url: route.path,
});
if (route.name == 'note' && currentId.value !== null) {
/**
* URL may have changed, use note id
*/
const noteUrl = `/note/${currentId.value}`;

patchOpenedPageByUrl(noteUrl, {
title: currentNoteTitle,
url: noteUrl,
});
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The noteTitle watcher has a potential race condition. While currentId.value is checked, it's not captured at the time the watcher is triggered. If currentId changes between when noteTitle is recalculated and when this watcher callback runs, the title from one note could be used to update the opened page for a different note. Consider capturing currentId.value at the start of the watcher callback, similar to how savedNoteId is captured in the save function.

Copilot uses AI. Check for mistakes.
title: currentNoteTitle,
url: route.path,
});
if (route.name == 'note' && currentId.value !== null) {
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

Use strict equality (===) instead of loose equality (==) for consistency with the rest of the codebase and to avoid potential type coercion issues.

Suggested change
if (route.name == 'note' && currentId.value !== null) {
if (route.name === 'note' && currentId.value !== null) {

Copilot uses AI. Check for mistakes.
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