@yemi33/minions 0.1.2152 → 0.1.2153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/js/refresh.js +44 -11
- package/dashboard/js/render-kb.js +12 -7
- package/dashboard.js +27 -0
- package/package.json +1 -1
package/dashboard/js/refresh.js
CHANGED
|
@@ -214,6 +214,30 @@ function _changed(key, value, version) {
|
|
|
214
214
|
return true;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
// Conditional JSON fetch for the heavy per-page endpoints (browser-OOM fix).
|
|
218
|
+
// /api/knowledge (~4.5MB) and /api/work-items (~4.2MB) were re-fetched AND
|
|
219
|
+
// re-parsed on every 4s refresh tick — ~11MB of allocation churn per tick that
|
|
220
|
+
// OOM-crashed the tab during active foreground use. These endpoints emit an
|
|
221
|
+
// input-mtime ETag server-side (serveFreshJson + handleKnowledgeList), so send
|
|
222
|
+
// If-None-Match off the last-seen ETag and resolve { notModified:true } on a
|
|
223
|
+
// 304. Callers skip the parse + render entirely and keep their last-rendered
|
|
224
|
+
// state, so an idle dashboard drops from ~11MB/tick to ~0. Routes through
|
|
225
|
+
// safeFetch (like the /api/status poll it mirrors) for the 15s abort timeout +
|
|
226
|
+
// X-Minions-Dashboard-* tab/visibility correlation headers. Per-URL ETag cache;
|
|
227
|
+
// a non-304 error rejects so each call site's existing .catch arm still fires.
|
|
228
|
+
var _condFetchEtags = {};
|
|
229
|
+
function _condFetchJson(url) {
|
|
230
|
+
var headers = {};
|
|
231
|
+
if (_condFetchEtags[url]) headers['If-None-Match'] = _condFetchEtags[url];
|
|
232
|
+
return safeFetch(url, { headers }).then(function (r) {
|
|
233
|
+
if (r.status === 304) return { notModified: true, data: null };
|
|
234
|
+
if (!r.ok) return Promise.reject(new Error('HTTP ' + r.status));
|
|
235
|
+
var etag = r.headers && r.headers.get ? r.headers.get('etag') : null;
|
|
236
|
+
if (etag) _condFetchEtags[url] = etag;
|
|
237
|
+
return r.json().then(function (data) { return { notModified: false, data: data }; });
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
217
241
|
function _formatCcPowerLabel(autoMode) {
|
|
218
242
|
var runtime = autoMode && autoMode.ccCli ? String(autoMode.ccCli) : 'claude';
|
|
219
243
|
var runtimeLabel = runtime.charAt(0).toUpperCase() + runtime.slice(1);
|
|
@@ -518,7 +542,11 @@ function _processStatusUpdate(data, opts) {
|
|
|
518
542
|
window._lastRequestedSeq = window._lastRequestedSeq || {};
|
|
519
543
|
window._lastRequestedSeq.prd = seq;
|
|
520
544
|
Promise.all([
|
|
521
|
-
fetch(
|
|
545
|
+
// Conditional fetch (browser-OOM fix): flatten to null on a 304 or error,
|
|
546
|
+
// which the cached status/progress fallback below already handles. The
|
|
547
|
+
// .catch keeps a prd failure from rejecting the whole Promise.all and
|
|
548
|
+
// starving the verify-guides slice (matches the old `r.ok ? … : null`).
|
|
549
|
+
_condFetchJson('/api/prd').then(function (resp) { return resp.notModified ? null : resp.data; }).catch(function () { return null; }),
|
|
522
550
|
fetch('/api/verify-guides').then(function (r) { return r.ok ? r.json() : null; }),
|
|
523
551
|
])
|
|
524
552
|
.then(function (results) {
|
|
@@ -616,10 +644,12 @@ function _processStatusUpdate(data, opts) {
|
|
|
616
644
|
const seq = (window._refreshSeq = (window._refreshSeq || 0) + 1);
|
|
617
645
|
window._lastRequestedSeq = window._lastRequestedSeq || {};
|
|
618
646
|
window._lastRequestedSeq.prs = seq;
|
|
619
|
-
|
|
620
|
-
.then(function (
|
|
621
|
-
.then(function (fresh) {
|
|
647
|
+
_condFetchJson('/api/pull-requests')
|
|
648
|
+
.then(function (resp) {
|
|
622
649
|
if (seq < (window._lastRequestedSeq.prs || 0)) return;
|
|
650
|
+
// 304 → PR list unchanged; keep last-rendered state + cross-slice sigs.
|
|
651
|
+
if (resp.notModified) return;
|
|
652
|
+
const fresh = resp.data;
|
|
623
653
|
const list = Array.isArray(fresh) ? fresh : (window._lastPullRequests || []);
|
|
624
654
|
const wasFirstNonEmpty = !Array.isArray(window._lastPullRequests);
|
|
625
655
|
window._lastPullRequests = list;
|
|
@@ -695,11 +725,12 @@ function _processStatusUpdate(data, opts) {
|
|
|
695
725
|
const seq = (window._refreshSeq = (window._refreshSeq || 0) + 1);
|
|
696
726
|
window._lastRequestedSeq = window._lastRequestedSeq || {};
|
|
697
727
|
window._lastRequestedSeq.dispatch = seq;
|
|
698
|
-
|
|
699
|
-
.then(function (
|
|
700
|
-
.then(function (fresh) {
|
|
728
|
+
_condFetchJson('/api/dispatch')
|
|
729
|
+
.then(function (resp) {
|
|
701
730
|
if (seq < (window._lastRequestedSeq.dispatch || 0)) return;
|
|
702
|
-
|
|
731
|
+
// 304 → dispatch queue unchanged; keep last-rendered panes + scroll.
|
|
732
|
+
if (resp.notModified) return;
|
|
733
|
+
const d = resp.data || window._lastDispatch;
|
|
703
734
|
if (d) window._lastDispatch = d;
|
|
704
735
|
_safeRender('dispatch', function() { renderDispatch(d, dispatchOpts); });
|
|
705
736
|
// Dispatch is the third cross-slice edge: derivePlanStatus reads
|
|
@@ -785,10 +816,12 @@ function _processStatusUpdate(data, opts) {
|
|
|
785
816
|
const seq = (window._refreshSeq = (window._refreshSeq || 0) + 1);
|
|
786
817
|
window._lastRequestedSeq = window._lastRequestedSeq || {};
|
|
787
818
|
window._lastRequestedSeq.workItems = seq;
|
|
788
|
-
|
|
789
|
-
.then(function (
|
|
790
|
-
.then(function (fresh) {
|
|
819
|
+
_condFetchJson('/api/work-items')
|
|
820
|
+
.then(function (resp) {
|
|
791
821
|
if (seq < (window._lastRequestedSeq.workItems || 0)) return;
|
|
822
|
+
// 304 → list unchanged; keep the last-rendered rows + DOM untouched.
|
|
823
|
+
if (resp.notModified) return;
|
|
824
|
+
const fresh = resp.data;
|
|
792
825
|
const list = Array.isArray(fresh) ? fresh : (window._lastWorkItems || []);
|
|
793
826
|
window._lastWorkItems = list;
|
|
794
827
|
_safeRender('workItems', function() { renderWorkItems(list); });
|
|
@@ -32,13 +32,18 @@ function _formatSweepElapsed(startedAt) {
|
|
|
32
32
|
|
|
33
33
|
async function refreshKnowledgeBase() {
|
|
34
34
|
try {
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
_kbData
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
// Conditional fetch (browser-OOM fix): /api/knowledge is ~4.5MB and was
|
|
36
|
+
// re-fetched + re-parsed every 4s tick, the single biggest contributor to
|
|
37
|
+
// the heap churn that crashed the tab. On a 304 the payload is unchanged,
|
|
38
|
+
// so _kbData (which cross-slice readers like command-center.js depend on)
|
|
39
|
+
// is already current — skip the parse and the render entirely.
|
|
40
|
+
const resp = await _condFetchJson('/api/knowledge');
|
|
41
|
+
if (resp.notModified) return;
|
|
42
|
+
_kbData = resp.data;
|
|
43
|
+
// Second-level guard: an mtime-only ETag bust (e.g. a sweep touched a file)
|
|
44
|
+
// can arrive with byte-identical content — skip the full kb-list/kb-tabs
|
|
45
|
+
// rewrite when the payload matches last tick. Dedicated cache key
|
|
46
|
+
// 'kbPayload' avoids colliding with any other tracked slice (S1).
|
|
42
47
|
if (typeof _changed !== 'function' || _changed('kbPayload', _kbData)) {
|
|
43
48
|
renderKnowledgeBase();
|
|
44
49
|
}
|
package/dashboard.js
CHANGED
|
@@ -6425,6 +6425,33 @@ const server = http.createServer(async (req, res) => {
|
|
|
6425
6425
|
|
|
6426
6426
|
async function handleKnowledgeList(req, res) {
|
|
6427
6427
|
const entries = await getKnowledgeBaseEntries();
|
|
6428
|
+
// Content ETag (browser-OOM fix). /api/knowledge is ~4.5MB and the dashboard
|
|
6429
|
+
// polls it every 4s per foregrounded tab; without a 304 path the browser
|
|
6430
|
+
// re-downloaded + re-parsed the whole payload every tick, churning enough
|
|
6431
|
+
// heap to OOM-crash the tab. Derive the signature from the already-cached
|
|
6432
|
+
// entry metadata (count + per-file mtime/size) instead of stat-walking the
|
|
6433
|
+
// knowledge tree — that tree is ~9k files and the walk measured ~185ms,
|
|
6434
|
+
// which would block the event loop on every poll. getKnowledgeBaseEntries
|
|
6435
|
+
// is O(1) on a cache hit (30s TTL + explicit invalidation on KB writes and
|
|
6436
|
+
// sweeps), so this adds ~nothing on the hot path. Two small stats fold in
|
|
6437
|
+
// the sweep-badge files so the in-flight indicator still busts the tag.
|
|
6438
|
+
let h = 2166136261;
|
|
6439
|
+
for (const e of entries) {
|
|
6440
|
+
h = Math.imul(h ^ ((e.size || 0) >>> 0), 16777619);
|
|
6441
|
+
h = Math.imul(h ^ Math.floor(e.sortTs || 0), 16777619);
|
|
6442
|
+
}
|
|
6443
|
+
const sweepMtime = _maxInputMtimeMs([
|
|
6444
|
+
path.join(ENGINE_DIR, 'kb-swept.json'),
|
|
6445
|
+
path.join(ENGINE_DIR, 'kb-sweep-state.json'),
|
|
6446
|
+
]);
|
|
6447
|
+
const kbEtag = '"knowledge-' + entries.length + '-' + (h >>> 0).toString(36) + '-' + sweepMtime + '"';
|
|
6448
|
+
res.setHeader('ETag', kbEtag);
|
|
6449
|
+
res.setHeader('Cache-Control', 'private, max-age=0, must-revalidate');
|
|
6450
|
+
if (req && req.headers && req.headers['if-none-match'] === kbEtag) {
|
|
6451
|
+
res.statusCode = 304;
|
|
6452
|
+
res.end();
|
|
6453
|
+
return;
|
|
6454
|
+
}
|
|
6428
6455
|
const result = {};
|
|
6429
6456
|
for (const cat of shared.KB_CATEGORIES) result[cat] = [];
|
|
6430
6457
|
for (const e of entries) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yemi33/minions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2153",
|
|
4
4
|
"description": "Multi-agent AI dev team that runs from ~/.minions/ — five autonomous agents share a single engine, dashboard, and knowledge base",
|
|
5
5
|
"bin": {
|
|
6
6
|
"minions": "bin/minions.js"
|