Skip to content

Conversation

@chrishalcrow
Copy link
Member

@chrishalcrow chrishalcrow commented Nov 3, 2025

If the user has done some curation, and not saved the curation when they try to exit, this PR adds a dialog window.

In QT. Pretty easy. We keep a current_curation_saved in the controller. If it's false at exit, a window pops-up:

Screenshot 2025-11-03 at 09 57 59

In panel, we add a warning in CurationView if the curation is not saved.

Screenshot 2025-11-05 at 12 54 13

It's very difficult to add a listener to a browser tab closure.

@samuelgarcia
Copy link
Member

For panel is there a way to change the message ?

Comment on lines 423 to 432
# Add a listener which will warn the user when the browser tab is closed
js_code = """
<script>
window.addEventListener('beforeunload', function (e) {
e.preventDefault();
e.returnValue = '';
});
</script>
"""
on_close_prompt = pn.pane.HTML(js_code, width=0, height=0, margin=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this runs regardless of the curation being saved or not, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It runs if the user has made any modifications to the page. I don't exactly know what a modification is, but if you just look through units it doesn't activate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we can edit the code in pn.pane.HTML at any time, I think. So should be able to only have this listener on when it's needed... lemme try...

self.notify_unit_visibility_changed()

def _panel_on_manual_curation_updated(self):
import panel as pn
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alejoe91 I'm going mad. Can you think of a better way to check if there is already a warning message present?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, not sure we should use the warning, since it has a close button! We could just add a markdown pane in the refresh function so we have full control of it. What do you think?

@alejoe91
Copy link
Member

alejoe91 commented Nov 5, 2025

Great, just added a missing "notify" (when labeling within the table) and set save current curation to True if submitting to parent (which is a way of delegating the save)

@alejoe91 alejoe91 merged commit 2997ecb into SpikeInterface:main Nov 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants