Skip to content

Add lazy page creation from [[links]] and Quick Switcher#23

Merged
avelino merged 1 commit into
mainfrom
avelino/issue-10
Mar 1, 2026
Merged

Add lazy page creation from [[links]] and Quick Switcher#23
avelino merged 1 commit into
mainfrom
avelino/issue-10

Conversation

@avelino

@avelino avelino commented Mar 1, 2026

Copy link
Copy Markdown
Owner

Navigating to a non-existent page showed an empty view but never created it in Roam. The Quick Switcher also had no way to create new pages.

When spawn_fetch_page gets an empty pull result, it now fires a create-page write before sending PageLoaded. The Quick Switcher appends a green "+ Create: X" entry when the query has no exact match, reusing the same navigation flow. New pages are added to the title cache so they appear in future searches. Version bumped to 0.2.0 for the new WriteAction::CreatePage API variant.

fixed: #10

Navigating to a non-existent page showed an empty view but never
created it in Roam. The Quick Switcher also had no way to create
new pages.

When spawn_fetch_page gets an empty pull result, it now fires a
create-page write before sending PageLoaded. The Quick Switcher
appends a green "+ Create: X" entry when the query has no exact
match, reusing the same navigation flow. New pages are added to
the title cache so they appear in future searches. Version bumped
to 0.2.0 for the new WriteAction::CreatePage API variant.

fixed: #10

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Comment thread src/app/tasks.rs
Comment on lines +68 to +72
date: dummy_date,
uid: new_uid,
title: title_owned,
blocks: vec![],
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The result of the client_clone.write(create_action) call is ignored. If the API call fails, the app proceeds as if the page was created, leading to a misleading UI state.
Severity: CRITICAL

Suggested Fix

Handle the Result of the client.write(create_action).await call. Instead of ignoring the result with let _ = ..., check for an Err variant. If an error occurs, send an AppMessage::ApiError message to notify the user, similar to the pattern used in the spawn_write function. Do not send AppMessage::PageLoaded on failure.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/app/tasks.rs#L68-L72

Potential issue: When creating a new page, the `Result` from the
`client_clone.write(create_action)` call is ignored. If this API call fails due to
network issues, an API error, or other problems, the application does not handle the
error. Instead, it unconditionally sends an `AppMessage::PageLoaded` message. This
misleads the user into believing the page was created successfully by displaying an
empty page. Subsequent edits or writes to this non-existent page will also fail
silently, potentially leading to user data loss without any notification.

Did we get this right? 👍 / 👎 to inform future reviews.

@avelino avelino merged commit 30fe9ca into main Mar 1, 2026
3 checks passed
@avelino avelino deleted the avelino/issue-10 branch March 1, 2026 11:56
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.

Create new pages from [[links]] or Quick Switcher

1 participant