From 497f455da62647582c33315c02cd60aefcd11720 Mon Sep 17 00:00:00 2001 From: Christian Eriksson Date: Tue, 16 Jun 2026 15:35:51 +0200 Subject: [PATCH] fix(cookbook): open() no longer crashes when a task has a diagnosis (#4417) _showDiagnosis referenced an undefined `body` (left over from the refactor that moved the diagnosis text into the toolbar), throwing a ReferenceError whenever a failed task rendered fix buttons. Because open() wraps its render in try/finally with no catch, the throw escaped before the modal was un-hidden, so the whole Cookbook silently failed to open. - cookbook-diagnosis.js: append the fixes row to `diag` (the in-scope container) instead of the removed `body` element. - cookbook.js: guard the render passes in open() so one broken task card can't leave the entire panel stuck hidden. Fixes #4406 --- static/js/cookbook-diagnosis.js | 2 +- static/js/cookbook.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/static/js/cookbook-diagnosis.js b/static/js/cookbook-diagnosis.js index 5ac387178..933fbe621 100644 --- a/static/js/cookbook-diagnosis.js +++ b/static/js/cookbook-diagnosis.js @@ -757,7 +757,7 @@ export function _showDiagnosis(panel, diagnosis, sourceText) { }); row.appendChild(btn); } - body.appendChild(row); + diag.appendChild(row); } } diff --git a/static/js/cookbook.js b/static/js/cookbook.js index 81acc9e0d..fc05217c1 100644 --- a/static/js/cookbook.js +++ b/static/js/cookbook.js @@ -2462,10 +2462,13 @@ export async function open(opts) { // returned before hydration — and since close/reopen doesn't reset the page, // only a full reload recovered it. Re-rendering is cheap and the in-progress // Running tab is rendered separately just below. - _renderRecipes(); + // Guard the render passes: a single broken task card must not throw out of + // open() and leave the modal stuck hidden (it has no catch, so the panel + // would silently never appear). Show the window regardless; log and move on. + try { _renderRecipes(); } catch (e) { console.error('[cookbook] renderRecipes failed', e); } _rendered = true; _clearCookbookNotif(); - _renderRunningTab(); + try { _renderRunningTab(); } catch (e) { console.error('[cookbook] renderRunningTab failed', e); } // Self-heal: revive any download tasks whose tmux session is still alive // but were persisted as done/error (covers the "restarted server while a // big multi-shard download was in flight" case — the task survived in