Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix(plan-canvas): guard localStorage so blocked site data can't disable canvas controls (#2703)

Brianff2280a3186d
diff --git a/scripts/lib/plan-canvas/ui.js b/scripts/lib/plan-canvas/ui.js
index a9815aa69..df1f05626 100644
--- a/scripts/lib/plan-canvas/ui.js
+++ b/scripts/lib/plan-canvas/ui.js
@@ -215,11 +215,22 @@ function canvasClientJs() {
else document.documentElement.removeAttribute('data-theme');
$('themeBtn').textContent = t === 'light' ? '\\u263E dark' : '\\u2600 light';
}
- let theme = localStorage.getItem(themeKey) || 'dark';
+ // Storage access throws outright when the browser blocks site data for this
+ // origin (loopback is a common trigger). Unguarded, that killed the whole
+ // client IIFE here, before the send button and Enter handlers bound below:
+ // every control rendered and stayed inert. sessionStorage is already guarded
+ // above and below; match it. See affaan-m/ECC#2702.
+ function readTheme() {
+ try { return localStorage.getItem(themeKey); } catch { return null; }
+ }
+ function writeTheme(v) {
+ try { localStorage.setItem(themeKey, v); } catch { /* site data blocked */ }
+ }
+ let theme = readTheme() || 'dark';
applyTheme(theme);
$('themeBtn').addEventListener('click', () => {
theme = theme === 'light' ? 'dark' : 'light';
- localStorage.setItem(themeKey, theme);
+ writeTheme(theme);
applyTheme(theme);
});