WIP: Smart create call #184
No reviewers
Labels
No labels
bug
dependencies
docker
documentation
duplicate
enhancement
good first issue
help wanted
invalid
javascript
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: andras/vault-link#184
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "asch/smart-create"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request overview
This PR updates the project's toolchain (Node.js 25, Rust 1.92), refactors the document creation workflow to support merging with existing files, and improves error handling and WebSocket reliability. The changes also include code organization improvements by consolidating error classes into a dedicated package and replacing eclint with Prettier for formatting.
Key Changes:
force_mergeparameter for document creation to enable merging with existing files at the same pathReviewed changes
Copilot reviewed 61 out of 78 changed files in this pull request and generated 5 comments.
Show a summary per file
merge_with_stored_versionfunctiondocument_idfield and addsforce_mergeparameter toCreateDocumentVersionget_latest_non_deleted_document_by_pathand improves loggingdocumentIdfromDocumentRecordtoDocumentMetadataand removeshasInitialSyncCompletedtrackinghandleMaybeMergingResponsehelper and removes fake document creationforce_mergeparameter instead ofdocument_idComments suppressed due to low confidence (1)
sync-server/src/server/update_document.rs:1
contentHashappears to be a reassignment that shadows the parameter, but it's not used after this point in the function. The reassignment should either update the metadata being saved (lines 520-528) or be removed if unnecessary.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -23,3 +21,1 @@"tsx": "^4.20.6","typescript": "5.8.3","webpack": "^5.99.9","tsx": "^4.21.0",The packages
commanderandwatcherare listed underdevDependenciesbut should be independenciessince they're required at runtime for the CLI tool to function. devDependencies are only for build-time and testing tools.@ -21,2 +34,3 @@"update": "ncu -u -ws""lint": "eslint --fix sync-client obsidian-plugin test-client deterministic-tests local-client-cli && prettier --write \"**/*.ts\"","update": "ncu -u"},The prettier configuration override for
*.mdfiles uses 2-space indentation, but the command in update-api-types.sh and other scripts formats all files including markdown. This could cause inconsistent formatting in code blocks within markdown files that contain other languages. Consider excluding code blocks from this rule or being more specific about which markdown content gets 2-space indentation.@ -231,7 +305,18 @@ export class WebSocketManager {}};There's a potential race condition: if the connection opens just as the timeout fires, both the
onopenhandler (line 193) and the timeout callback could attempt to clearconnectionTimeoutId. While this particular case is harmless, it's better to clear the timeout inside the callback before callingclose()to avoid the race. Movethis.connectionTimeoutId = undefined;after the close() call or remove it from the callback entirely since it will be cleared in the onclose handler.When
oldPathis undefined butresponse.relativePath != originalRelativePathis true (meaning the server changed the path), usingoriginalRelativePathas themovedFromvalue is incorrect. The file wasn't actually moved fromoriginalRelativePathlocally - this was a server-side path change. Consider handling this case separately or using the document's actual previous path from metadata.The log message is misleading because it's placed inside the loop iteration where a candidate path is found to be taken, but it says 'Finding first available path' which suggests it's starting the search. Consider moving this log to line 12 before the loop starts, or rewording it to 'Candidate path
{candidate}is already taken, trying next path'.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.