-
Notifications
You must be signed in to change notification settings - Fork 484
frontend: Live-sync editor with server updates and add merge option #4269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
frontend: Live-sync editor with server updates and add merge option #4269
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kahirokunn The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
8b191b6 to
22b5e83
Compare
409c38b to
dabe9e5
Compare
dabe9e5 to
6dfc8cd
Compare
|
@joaquimrocha The code has a bit too many lines, but I think this is the ideal editor from a user experience perspective. What do you think? My idea is that if the server-side YAML changes, it will eventually cause an optimistic lock error. Therefore, I think it would be a better experience to reflect the server-side YAML to some extent automatically in the editor. |
6dfc8cd to
4b11025
Compare
|
I think this is likely too complex for us to have it in time for this week's release, but let's try for the next one (and review it as soon as we can). |
|
I think the source code might have even more room for improvement, but I believe the PR and the video effectively convey what we're aiming to achieve. Please let me join in on this challenge together! 💪 |
|
fiy there's also a somewhat related PR that we should make sure it'll work nicely together #4098 |
vyncent-t
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will throw in a copilot review for improvement suggestions, otherwise looks interesting!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements live-sync functionality for the resource YAML editor, enabling the editor to automatically update when the underlying Kubernetes resource changes on the server. When users haven't made edits, the editor auto-updates. When users have modified the content, a warning banner appears with options to reload from server or perform a 3-way merge.
Key changes:
- Added live server update tracking with automatic editor synchronization when not dirty
- Implemented a 3-way merge algorithm with conflict detection for resolving concurrent edits
- Added visual highlighting to show externally-changed lines in both Monaco and simple editors
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/components/common/Resource/EditorDialog.tsx | Core implementation of live-sync, merge logic, warning banner, and highlighting functionality |
| frontend/src/components/common/Resource/EditButton.tsx | Updated to pass full KubeObject instead of editable object to enable live updates |
| frontend/src/components/common/Resource/SimpleEditor.tsx | Converted to forwardRef to support ref access for highlighting in simple editor mode |
| frontend/src/lib/k8s/KubeObject.ts | Added KUBE_OBJECT_BRAND symbol for cross-bundle instance detection |
| frontend/src/components/resourceMap/KubeObjectGlance/NodeGlance.tsx | Updated to use brand checking instead of instanceof for KubeObject detection |
| frontend/src/plugin/snapshots/pluginLib.snapshot | Updated snapshot to reflect SimpleEditor's forwardRef change |
| frontend/src/i18n/locales/*/translation.json | Added translation strings for merge conflict messages and UI actions (with some locales pending translation) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4b11025 to
2bb4918
Compare
711e6f6 to
1b481c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 17 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4cabcfb to
abe285e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 29 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
681ed25 to
47760f8
Compare
Signed-off-by: kahirokunn <[email protected]>
Signed-off-by: kahirokunn <[email protected]>
47760f8 to
21bea75
Compare
|
Hi @vyncent-t, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Summary
This PR improves the resource YAML editor behavior when the underlying resource changes on the server. If the user hasn’t typed anything yet, the editor auto-updates to the latest YAML. If the user has started editing, the editor won’t overwrite changes and instead shows an accessible warning with actions to reload or merge changes.
Related Issue
Fixes #XXXX
Changes
EditButton/EditorDialogso the editor follows live server updates when not dirty.Steps to Test
Screenshots
Notes for the Reviewer
status,metadata.managedFields, andmetadata.resourceVersionto reduce noisy conflicts.