fix(cli): enhance backend to send the partial application#150
fix(cli): enhance backend to send the partial application#150davemooreuws merged 1 commit intomainfrom
Conversation
Allows the frontend to preserve existing fields when errors occur during application YAML parsing or validation.
📝 WalkthroughWalkthroughWell ackchyually… the changes modify error handling in the file synchronization logic. The Pre-merge checks✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cli/internal/devserver/filesync.go (1)
213-214: Well ackchyually… file watching stops on any error, breaking auto-reload.The
fileErrorvariable captures errors from the debounced handler, then Line 253 returns it, exitingwatchFileentirely. If a YAML parse error occurs, file watching stops permanently. When the user fixes the error, the devserver won't detect the change.Remove the error return to keep watching:
- var fileError error = nil debounced, cancel = lo.NewDebounce(fs.debounce, func() { application, contents, err := fs.getApplicationFileContents() if err != nil { // Update contents so sync can be handled after validation errors clear fs.lastSyncContents = contents - fileError = err - validationErrors, validationErr := validateApplicationSchema(contents) if validationErr != nil { return } // Send partial application data first so frontend has existing fields to merge with if application != nil { fs.broadcast(Message[any]{ Type: "syncMessage", Payload: *application, }) } fs.broadcast(Message[any]{ Type: "syncError", Payload: validationErrors, }) return } if bytes.Equal(fs.lastSyncContents, contents) { return } fs.broadcast(Message[any]{ Type: "syncMessage", Payload: *application, }) }) debounced() - if fileError != nil { - return fileError - } } }Also applies to: 252-254
♻️ Duplicate comments (1)
cli/internal/devserver/filesync.go (1)
223-225: Well ackchyually… same silent failure here too.Identical to Line 100-102: if validation error computation fails, the debounced function returns without notifying clients.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cli/internal/devserver/filesync.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cli/internal/devserver/filesync.go (1)
cli/internal/devserver/devserver.go (1)
Message(16-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build (macos-latest, arm64)
🔇 Additional comments (4)
cli/internal/devserver/filesync.go (4)
51-59: LGTM! Partial application preservation enables better UX.The changes correctly return the partial application alongside errors, allowing the frontend to preserve existing fields during validation failures. The error message on Line 58 is generic but sufficient since detailed validation errors are computed separately in
validateApplicationSchema.
78-94: LGTM! Clean validation error computation.The helper function correctly aggregates schema validation errors and application spec errors into a single slice.
105-110: LGTM! Partial application sent before errors enables frontend field preservation.The nil check and ordering are correct for the intended UX flow.
228-233: LGTM! Consistent with OnConnect pattern.Correctly sends partial application before validation errors, maintaining the intended sequence for frontend reconciliation.
|
🎉 This PR is included in version 0.6.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Allows the frontend to preserve existing fields when errors occur during application YAML parsing or validation.
This is to accomodate a new screen which prompts you to pick a platform when none is configured e.g. when you use suga init.