Skip to content

delete button#112

Merged
MarcSkovMadsen merged 1 commit into
mainfrom
enhancement/delete-button
Jan 20, 2026
Merged

delete button#112
MarcSkovMadsen merged 1 commit into
mainfrom
enhancement/delete-button

Conversation

@MarcSkovMadsen

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 20, 2026 04:55
@MarcSkovMadsen MarcSkovMadsen merged commit 0e91f3a into main Jan 20, 2026
7 of 13 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a delete button feature to the visualization feed page, allowing users to remove visualizations from both the database and the cached views. The UI is enhanced with a tabbed interface that separates the View and Code display.

Changes:

  • Added on_delete function to handle deletion of visualizations from database and cache
  • Introduced a delete button with danger styling for each visualization
  • Enhanced UI with tabs separating View (iframe) and Code (CodeEditor) display
  • Adjusted iframe height from 200px to 300px to accommodate the new tabbed layout

Comment on lines +25 to +33
def on_delete(snippet_id):
"""Handle deletion of a visualization."""
# Delete from database
get_db().delete_snippet(snippet_id)
# Remove from cache
if snippet_id in pn.state.cache["views"]:
del pn.state.cache["views"][snippet_id]
# Refresh feed
update_chat()

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

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

The on_delete function does not handle potential errors from the database deletion operation. If get_db().delete_snippet() fails or raises an exception, the cache could be left in an inconsistent state (the cache entry might be deleted while the database record remains). Consider wrapping the deletion logic in a try-except block and only clearing the cache if the database deletion succeeds. The delete_snippet method returns a bool indicating success, which should be checked before modifying the cache.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +33
def on_delete(snippet_id):
"""Handle deletion of a visualization."""
# Delete from database
get_db().delete_snippet(snippet_id)
# Remove from cache
if snippet_id in pn.state.cache["views"]:
del pn.state.cache["views"][snippet_id]
# Refresh feed
update_chat()

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

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

There is a potential race condition between the on_delete function and the update_chat periodic callback (which runs every 1 second per line 125). When a snippet is deleted, update_chat() is called to refresh the feed. However, the periodic callback could also be executing simultaneously, potentially attempting to recreate the deleted view from the database before the deletion completes or while cache is being modified. Consider adding synchronization or checking if snippets exist in the database before caching their views.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +33
def on_delete(snippet_id):
"""Handle deletion of a visualization."""
# Delete from database
get_db().delete_snippet(snippet_id)
# Remove from cache
if snippet_id in pn.state.cache["views"]:
del pn.state.cache["views"][snippet_id]
# Refresh feed
update_chat()

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

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

The new delete functionality (on_delete function and delete button) lacks test coverage. While there are tests for the underlying database.delete_snippet method, there are no tests verifying the feed_page delete behavior, including cache invalidation and feed refresh logic. Consider adding tests that verify: 1) successful deletion removes items from both database and cache, 2) the feed is properly refreshed after deletion, and 3) error cases are handled gracefully.

Copilot uses AI. Check for mistakes.
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.

2 participants