Add lazy page creation from [[links]] and Quick Switcher#23
Merged
Conversation
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 on lines
+68
to
+72
| date: dummy_date, | ||
| uid: new_uid, | ||
| title: title_owned, | ||
| blocks: vec![], | ||
| }; |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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