From 9bd02d7ef713a62ef40eb1f15b7f66f3cb50c94b Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Wed, 19 Nov 2025 13:51:08 +0100 Subject: [PATCH] fix: Preserve 3D plot camera position and fix CSS loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two fixes for the vector visualization page: 1. **CSS Loading Fix**: Moved CSS from vector_viz.html fragment to user_info.html block. HTMX fragments don't process tags in , causing unstyled page. Now CSS loads correctly. 2. **Camera Preservation**: Modified renderPlot() to preserve camera position when toggling query point visibility. Previously, toggling the "Show Query Point" checkbox would reset zoom/rotation to default. Now reads existing camera settings from plot before updating. Related: nextcloud_mcp_server/auth/static/vector-viz.js:123-130 Related: nextcloud_mcp_server/auth/templates/user_info.html:12 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .dockerignore | 2 +- nextcloud_mcp_server/auth/static/vector-viz.js | 17 +++++++++++++---- .../auth/templates/user_info.html | 3 +++ .../auth/templates/vector_viz.html | 2 -- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index ca154cd..bd5793c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,4 +6,4 @@ !nextcloud_mcp_server/**/*.py !nextcloud_mcp_server/**/*.html -!nextcloud_mcp_server/auth/static/*.png +!nextcloud_mcp_server/auth/static/* diff --git a/nextcloud_mcp_server/auth/static/vector-viz.js b/nextcloud_mcp_server/auth/static/vector-viz.js index cd9f557..bf98a20 100644 --- a/nextcloud_mcp_server/auth/static/vector-viz.js +++ b/nextcloud_mcp_server/auth/static/vector-viz.js @@ -120,15 +120,22 @@ function vizApp() { } }; + // Preserve camera position if plot already exists + const plotDiv = document.getElementById('viz-plot'); + let cameraSettings = { eye: { x: 1.5, y: 1.5, z: 1.5 } }; // Default camera position + + if (plotDiv && plotDiv.layout && plotDiv.layout.scene && plotDiv.layout.scene.camera) { + // Plot exists and has been interacted with - preserve current camera + cameraSettings = plotDiv.layout.scene.camera; + } + const layout = { title: `Vector Space (PCA 3D) - ${results.length} results`, scene: { xaxis: { title: 'PC1' }, yaxis: { title: 'PC2' }, zaxis: { title: 'PC3' }, - camera: { - eye: { x: 1.5, y: 1.5, z: 1.5 } - } + camera: cameraSettings }, hovermode: 'closest', autosize: true, // Enable auto-sizing to fit container @@ -145,7 +152,9 @@ function vizApp() { displayModeBar: true }; - Plotly.newPlot('viz-plot', traces, layout, config); + // Use Plotly.react() instead of newPlot() to preserve camera position + // when toggling query point visibility + Plotly.react('viz-plot', traces, layout, config); }, getNextcloudUrl(result) { diff --git a/nextcloud_mcp_server/auth/templates/user_info.html b/nextcloud_mcp_server/auth/templates/user_info.html index 227114f..25f527b 100644 --- a/nextcloud_mcp_server/auth/templates/user_info.html +++ b/nextcloud_mcp_server/auth/templates/user_info.html @@ -11,6 +11,9 @@ + + + {% endblock %} {% block extra_styles %} diff --git a/nextcloud_mcp_server/auth/templates/vector_viz.html b/nextcloud_mcp_server/auth/templates/vector_viz.html index b68fe19..a052d9e 100644 --- a/nextcloud_mcp_server/auth/templates/vector_viz.html +++ b/nextcloud_mcp_server/auth/templates/vector_viz.html @@ -1,5 +1,3 @@ - -