@yemi33/minions 0.1.1929 → 0.1.1930

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.
@@ -182,24 +182,45 @@ async function _ccDashboardHealth() {
182
182
  // Triggered by the CC "Restart Minions" recovery button when a stale dashboard
183
183
  // connection is killing CC streams with "Failed to fetch". Spawns the same
184
184
  // `minions restart` flow as the CLI command (kills + respawns engine AND
185
- // dashboard). The browser auto-reloads via refresh.js when it sees the new
186
- // dashboardStartedAt; if the POST itself fails (dashboard truly unreachable),
187
- // fall back to a plain location.reload() so behavior is never worse than before.
185
+ // dashboard). Then polls /api/health until the new dashboard is online before
186
+ // reloading fixed timers either fired too early (reload hits dead port) or
187
+ // fired after the fetch threw (dashboard killed mid-response 500ms reload
188
+ // to nothing).
188
189
  async function ccRestartMinions(btn) {
189
190
  if (btn) { try { btn.disabled = true; btn.textContent = 'Restarting...'; } catch {} }
191
+ // Fire and forget the POST. We do NOT await it — the dashboard often kills
192
+ // its own process before the response is flushed, so the fetch throws even
193
+ // though the restart child is happily running. Whatever the POST does, the
194
+ // next step (wait-for-healthy) is the truth.
190
195
  try {
191
- var res = await fetch('/api/dashboard/restart', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
192
- if (!res.ok) throw new Error('HTTP ' + res.status);
193
- if (btn) { try { btn.textContent = 'Restarting Minions page will reload...'; } catch {} }
194
- // The dashboard process is about to be killed. refresh.js's status poll
195
- // will detect the new dashboardStartedAt and call location.reload() once
196
- // the new dashboard is online; this fallback handles the case where the
197
- // poll hasn't fired (e.g., user closed the browser tab and reopened).
198
- setTimeout(function() { try { location.reload(); } catch {} }, 8000);
199
- } catch (e) {
200
- if (btn) { try { btn.textContent = 'Restart failed — reloading...'; } catch {} }
201
- setTimeout(function() { try { location.reload(); } catch {} }, 500);
196
+ fetch('/api/dashboard/restart', { method: 'POST', headers: { 'Content-Type': 'application/json' } })
197
+ .catch(function() { /* dashboard process likely killed mid-response — expected */ });
198
+ } catch { /* network layer threw before fetch even queued also expected */ }
199
+ if (btn) { try { btn.textContent = 'Restarting Minions — waiting for new dashboard...'; } catch {} }
200
+ var startedAt = Date.now();
201
+ var DEADLINE_MS = 60000;
202
+ var INTERVAL_MS = 500;
203
+ function pollHealth() {
204
+ fetch('/api/health', { cache: 'no-store' }).then(function(res) {
205
+ if (res && res.ok) {
206
+ if (btn) { try { btn.textContent = 'Dashboard online — reloading...'; } catch {} }
207
+ try { location.reload(); } catch {}
208
+ return;
209
+ }
210
+ throw new Error('not ok');
211
+ }).catch(function() {
212
+ if (Date.now() - startedAt > DEADLINE_MS) {
213
+ if (btn) { try { btn.textContent = 'Restart timed out — reloading...'; } catch {} }
214
+ try { location.reload(); } catch {}
215
+ return;
216
+ }
217
+ setTimeout(pollHealth, INTERVAL_MS);
218
+ });
202
219
  }
220
+ // Don't poll immediately — give the restart child a moment to actually kill
221
+ // the old dashboard. If we polled at t=0 we'd hit the OLD (dying) dashboard
222
+ // and prematurely reload before the new one is up.
223
+ setTimeout(pollHealth, 2000);
203
224
  }
204
225
 
205
226
  function _ccIsReconnectableStreamError(err) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "runtime": "copilot",
3
3
  "models": null,
4
- "cachedAt": "2026-05-14T02:50:03.274Z"
4
+ "cachedAt": "2026-05-14T02:53:42.873Z"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.1929",
3
+ "version": "0.1.1930",
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"