fix(frontend): reset left panel metadata on notebook switch - #950
fix(frontend): reset left panel metadata on notebook switch#950Hariharanpugazh wants to merge 3 commits into
Conversation
When switching between notebooks, the left panel kept rendering the previous notebook's experiment, pipeline name, and description while the async loading RPCs (getKfpUiHost, getNamespace, getExperiments) were still pending. The metadata state was only updated after those awaits resolved, so stale values were visible during the gap. Reset the panel to fresh defaults synchronously at the start of every notebook switch (before any await) and surface the existing experiment 'Loading...' state via gettingExperiments. Also guard the async load against completing after the user has switched again, so a late-resolving load cannot clobber the now-active notebook's metadata. Fixes kubeflow#644 Signed-off-by: Hariharanpugazh <hariharanpugazh@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
ada333
left a comment
There was a problem hiding this comment.
hi @Hariharanpugazh I could not replicate the bug that is described in this PR - could you please share a video, or detailed instructions?
|
Hi @ada333, thanks for taking a look! Here are detailed steps to reproduce. SetupCreate two notebooks in the same Jupyter server, each with different Kale metadata:
Make sure Kale is enabled and the left panel is open. Steps
Expected: Panel clears to defaults (experiment shows Actual (before this fix): During the async load window the panel keeps showing the previous notebook's values ( Why it can be hard to hitIt's a race in I'll follow up with a short screen recording if these steps don't reproduce it on your end. |
The previous fix reset panel state on switch, but two deeper problems remained that caused metadata to leak between notebooks and the panel to hang when KFP was unreachable. Root cause of the leak: the persistence effect wrote metadata to tracker.currentWidget, which is resolved when the effect runs (after paint), not when the edit was made. Switching tabs before the effect flushed wrote one notebook's metadata into another. The effect now targets the notebook the metadata was loaded from (loadedNotebookRef), so edits always save to the notebook they belong to. Also: guard the metadata load so the loader's own setMetadata calls are not written back to the file (isLoadingRef), wrap the load in try/finally so the loading flag can never stay stuck, and stop backend RPC failures (unreachable KFP) from aborting the metadata load or freezing the panel. Fixes kubeflow#644 Signed-off-by: Hariharanpugazh <hariharanpugazh@gmail.com>
|
Thanks for taking a look, @ada333. The original symptom is timing-sensitive, which is likely why it didn't reproduce for you on a fast KFP backend the stale-metadata window is very small. While reproducing it locally I found a deeper and more serious variant of the same underlying issue: metadata could leak between notebooks. Root cause: the metadata-persistence effect wrote to Fix: persist to the notebook the metadata was actually loaded from (tracked via a
I've pushed these changes to this PR. Repro for the original stale-metadata symptom:
Expected: panel resets/loads B's values. Before the fix: it kept showing A's values during that window, and rapid switching could persist A's metadata onto B. To widen the window for a reliable repro, throttle the network in DevTools or add a temporary delay before |
Extract the persistence decision into a pure resolveMetadataPersistence() helper (no runtime JupyterLab imports, so it is unit-testable in isolation) and add regression tests for kubeflow#644. The key assertion guards the leak fixed in the previous commit: a metadata change is written to the notebook it was loaded from, never to the currently active tab. Also covers skipping while the loader is populating state, when metadata is unchanged, and when the owning notebook is missing or disposed. Signed-off-by: Hariharanpugazh <hariharanpugazh@gmail.com>
What this does
Fixes stale metadata in the Kale left panel when switching between notebooks.
Problem
When switching from one notebook to another, the left panel kept showing the
previous notebook's experiment, pipeline name, and description. The
notebook-load sequence in
useNotebookLoader.loadNotebookPanel()awaits severalbackend RPCs (
getKfpUiHost,getNamespace,getExperiments) before it callssetMetadata, and it never cleared state first. During that async window thepanel rendered stale values from the notebook we just left.
Fix
notebook switch, before any
await, via a newresetForNotebookSwitch()inuseNotebookMetadata. This also setsgettingExperiments, so the experimentfield shows its existing "Loading..." state during the load instead of stale text.
isStale()check after each await: if the userswitches notebooks again while a load is in flight, the late-resolving load
bails out instead of clobbering the now-active notebook's metadata.
loadNotebookPanelso it resets on thenon-backend path too.
Reset uses a fresh default metadata object rather than the shared
DefaultState.metadatareference, so it stays compatible with theDefaultStatefreezing proposed in #868 (#643).Testing
jlpm eslint:check— cleanprettier --check— cleantsc --noEmit— cleanjest— passingManually verified by opening two notebooks with different metadata and switching
between them: the panel now resets/loads instead of showing the previous
notebook's values.
Related
DefaultStateso the two changes shouldn't conflict.