From f3c615b6696250721d05d5212797f354592cb055 Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Mon, 24 Aug 2026 00:59:27 +0200 Subject: [PATCH] fix(files): give the file preview a working detach button The button next to the file preview's close icon was Copy Content, whose overlapping-pages glyph reads as a pop-out control - and for a PDF or any media/binary preview it was completely dead: those branches never fill filePreviewContent, so the click hit an empty-content guard and did nothing, with no feedback. There is now a real detach button that opens the previewed file in a browser tab (raw route for PDFs/images/media/text, the server-converted PDF preview for docx/pptx), severs window.opener by hand so a blocked pop-up stays detectable, closes the overlay on success (which also stops any playing media), and disarms on close so it can never open a stale file. The copy button now toasts 'Nothing to copy in this preview' instead of staying silent. Verified live with Playwright against an isolated instance: button visible and armed on a PDF preview, file-raw answers 200, clicking opens the URL and tears the overlay down, text previews keep a working copy buffer. Co-Authored-By: Claude Fable 5 --- src/web/public/index.html | 1 + src/web/public/panels-ui.js | 45 +++++++++ test/file-preview-detach.test.ts | 157 +++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+) create mode 100644 test/file-preview-detach.test.ts diff --git a/src/web/public/index.html b/src/web/public/index.html index a5a4250d..27bbd942 100644 --- a/src/web/public/index.html +++ b/src/web/public/index.html @@ -567,6 +567,7 @@
+
diff --git a/src/web/public/panels-ui.js b/src/web/public/panels-ui.js index 43286b4f..52a4c8ea 100644 --- a/src/web/public/panels-ui.js +++ b/src/web/public/panels-ui.js @@ -3313,6 +3313,11 @@ Object.assign(CodemanApp.prototype, { // Stop whatever the previous preview was playing. Overwriting innerHTML // only DETACHES a