Skip to content

[Bug]: Clicking wiki link to non-existent note shows error instead of creating the note #419

@corkang

Description

@corkang

What happened?

According to the documentation, "If the note doesn't exist yet, Lokus will create it when you click the link." However, when clicking a wiki link that points to a non-existent note, Lokus displays an error message instead of creating the note:

ERROR: Failed to load file: No such file or directory (os error 2)

The editor becomes unresponsive and cannot be edited after this error appears.
Expected behavior: Clicking a link to a non-existent note should automatically create an empty note with that name.

Version

0.1.0 (latest)

Operating System

macOS

Steps to reproduce

  1. Open any note in Lokus
  2. Type [[NewNoteThatDoesNotExist]] and press Enter or select to create the wiki link
  3. Click on the created wiki link
  4. Error message appears: "Failed to load file: No such file or directory (os error 2)"
  5. The note is not created and the editor shows an error state

Relevant log output

Failed to load file: No such file or directory (os error 2)

Additional context

Two issues contribute to this bug:

  1. In src/editor/components/Editor.jsx, when clicking a wiki link to a non-existent file, the click handler doesn't construct a proper absolute file path. It passes an unresolved relative path to the workspace.

  2. In src/views/Workspace.jsx, when invoke("read_file_content") fails with a "file not found" error, the code only displays an error message. There's no logic to auto-create the file as documented.

The fix should:

  • Construct a proper absolute path for non-existent files (in the same folder as the current note)
  • Auto-create the .md file when a "No such file" error occurs

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    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