From 29148aaa0ae6d2b86c4995e69f8461e410a2b3ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:57:27 +0000 Subject: [PATCH 1/2] Initial plan From 2f20b2a1e3068c30182756d9aa900068ba309a15 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 20:01:47 +0000 Subject: [PATCH 2/2] Use deterministic filename for browser temp HTML files to prevent accumulation Co-authored-by: slosar <1197186+slosar@users.noreply.github.com> --- bor/tabs/message.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/bor/tabs/message.py b/bor/tabs/message.py index 8908b4e..7742d43 100644 --- a/bor/tabs/message.py +++ b/bor/tabs/message.py @@ -6,6 +6,7 @@ from __future__ import annotations +import hashlib import html import re import subprocess @@ -907,16 +908,21 @@ def action_view_in_browser(self) -> None: try: config = get_config() tmp_dir_str = config.html.browser_tmp_dir - tmp_dir = Path(tmp_dir_str).expanduser() if tmp_dir_str else None - if tmp_dir is not None: - tmp_dir.mkdir(parents=True, exist_ok=True) - tmp = tempfile.NamedTemporaryFile( - suffix=".html", prefix="bor_msg_", delete=False, - mode="w", encoding="utf-8", dir=tmp_dir, + tmp_dir = ( + Path(tmp_dir_str).expanduser() + if tmp_dir_str + else Path(tempfile.gettempdir()) ) - tmp.write(full_html) - tmp.close() - webbrowser.open(Path(tmp.name).as_uri()) + tmp_dir.mkdir(parents=True, exist_ok=True) + + # Use a deterministic filename based on the message identifier so + # that re-opening the same message reuses the file instead of + # accumulating many bor_msg_*.html files. + key = msg.msgid or (str(msg.docid) if msg.docid else full_html) + file_hash = hashlib.sha256(key.encode()).hexdigest()[:16] + tmp_path = tmp_dir / f"bor_msg_{file_hash}.html" + tmp_path.write_text(full_html, encoding="utf-8") + webbrowser.open(tmp_path.as_uri()) self.notify("Message opened in browser") except Exception as e: self.notify(f"Could not open browser: {e}")