Skip to content

Commit 49a2e5b

Browse files
fix: sessionStorage-backed state so stop/agent cards survive navigation
- Events and running state persisted in sessionStorage - Survives page navigation without losing running indicator - Dual-write to context + sessionStorage for cross-component sync
1 parent 2a001f3 commit 49a2e5b

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎cmd/slmcode/ui/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
99
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
1010
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='6' fill='%237c3aed'/><text x='16' y='22' font-family='system-ui' font-weight='700' font-size='18' fill='white' text-anchor='middle'>SL</text></svg>" />
11-
<script type="module" crossorigin src="/assets/index-Del_mAJI.js"></script>
11+
<script type="module" crossorigin src="/assets/index-C4d-EQhs.js"></script>
1212
<link rel="stylesheet" crossorigin href="/assets/index-DLElLyRL.css">
1313
</head>
1414
<body class="antialiased">

‎web/src/components/Live/LiveView.tsx‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,24 @@ type PhaseState = 'pending' | 'active' | 'completed';
9292

9393
export default function LiveView() {
9494
const ctx = useContext(AppContext);
95-
const events = ctx?.liveEvents || [];
96-
const setEvents = ctx?.setLiveEvents || (() => {});
97-
const running = ctx?.liveRunning || false;
98-
const setRunning = ctx?.setLiveRunning || (() => {});
95+
// Use sessionStorage-backed state so it survives page navigation
96+
const [localEvents, setLocalEvents] = useState<RunEvent[]>(() => {
97+
try { return JSON.parse(sessionStorage.getItem('slmcode:events') || '[]'); } catch { return []; }
98+
});
99+
const [localRunning, setLocalRunning] = useState(() => sessionStorage.getItem('slmcode:running') === 'true');
100+
const events = ctx?.liveEvents?.length ? ctx.liveEvents : localEvents;
101+
const setEvents = (v: RunEvent[] | ((p: RunEvent[]) => RunEvent[])) => {
102+
const next = typeof v === 'function' ? v(localEvents) : v;
103+
setLocalEvents(next);
104+
ctx?.setLiveEvents?.(next);
105+
try { sessionStorage.setItem('slmcode:events', JSON.stringify(next.slice(-200))); } catch {}
106+
};
107+
const running = ctx?.liveRunning || localRunning;
108+
const setRunning = (v: boolean) => {
109+
setLocalRunning(v);
110+
ctx?.setLiveRunning?.(v);
111+
sessionStorage.setItem('slmcode:running', String(v));
112+
};
99113
const result = ctx?.liveResult || null;
100114
const setResult = ctx?.setLiveResult || (() => {});
101115
const [query, setQuery] = useState('');

0 commit comments

Comments
 (0)