Skip to content

Bug: Crash when adding notes to unregistered assets & external resources deselect on save #461

Description

@Sumit-ai-dev

Prerequisites

  • Are you running the latest version?
  • Did you check other issues/PRs to see if this has already been reported or requested?

Current Behavior

Right now, there are two issues when adding notes to assets:

  1. If you try to add a note to a new file that hasn't been scanned or indexed into project.assets yet (or if project.assets is null/empty), the app immediately crashes with TypeError: assetsCopy.push is not a function.
  2. When you add or edit a note on an external resource (URL, external file, or folder), the note saves to disk, but the right-hand details pane abruptly closes because the resource gets deselected. You have to click it again in the tree to see your saved note.

Expected Behavior

  • Adding a note to any asset—whether it's already indexed or brand-new—should save cleanly without crashing.
  • Saving a note on an external resource should keep the item selected and leave the details pane open.

Possible Solution

I dug into the code and traced the root causes:

  • In Project.js, assetsCopy is a tree node object containing a children array, not an array itself. Calling .push() on it directly throws a type error. Pushing into assetsCopy.children and delegating to upsertNoteHandler should prevent the crash and ensure the note gets full metadata (UUID, author, timestamps).
  • In app/services/project.js, loadAndMergeProjectUpdates doesn't handle unregistered asset nodes when NOTE_ADDED fires, and _updateNote/_deleteNote lack null guards for missing entities. We can dynamically create the node with the right type (file, folder, URL) and attach it to the parent directory or root.
  • In Assets.js, the useEffect hook syncing the selected asset only searches project.assets. Because external resources live in project.externalAssets, the lookup returns null and resets the selection. Using AssetUtil.isExternalAsset() to check project.externalAssets should keep the item selected after saving.

I think this would be a clean way to address both issues so that local files and external resources handle note creation, editing, and deletion smoothly.

I'd love your thoughts:

  • Does this sound like a solid fix to you?
  • If so, I'd be happy to open a PR and get this resolved!

Your Environment

  • Version used: 0.0.21 (Development branch)
  • Environment: macOS / Node.js

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions