Skip to content

Commit d28da8f

Browse files
fix: skip dashboard re-render when data hasn't changed to preserve scroll state
1 parent 1b42e9a commit d28da8f

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-forge",
3-
"version": "0.4.17",
3+
"version": "0.4.18",
44
"type": "module",
55
"oc-plugin": [
66
"server",

‎src/dashboard/render.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,25 @@ export function renderDashboardHtml(): string {
162162
var lastData = null;
163163
var selectedProjectId = null;
164164
var selectedLoopName = null;
165+
var lastDataHash = '';
166+
167+
function dataHash(data) {
168+
return JSON.stringify(data, function(k, v) {
169+
if (k === 'generatedAt') return undefined;
170+
return v;
171+
});
172+
}
165173
166174
function load() {
167175
fetch('/api/data', { cache: 'no-store' })
168176
.then(function(r) { return r.json(); })
169-
.then(function(data) { render(data); })
177+
.then(function(data) {
178+
var hash = dataHash(data);
179+
if (hash !== lastDataHash) {
180+
lastDataHash = hash;
181+
render(data);
182+
}
183+
})
170184
.catch(function(err) {
171185
var mount = document.getElementById('forge-dashboard');
172186
if (mount) {

0 commit comments

Comments
 (0)