← Commit history

battery: abort when profile discovery cannot enumerate the target (relay blip made it guess the wrong profile)

John Lauer ·deb12f3f18 ·2mo ago ·parent 5ff5b1f
1 file changed +10−2
tools/verb-battery.mjs+10−2
@@ -277,12 +277,20 @@ function metaCount() {  function discoverProfile() {   const r = call('nbrowser_profiles', {});-  const ps = (r && r.profiles) || [];+  // Discovery failing = the target is unreachable. ABORT here rather than fall back to a guessed+  // profile: the 12:18 relay blip made discovery "succeed" with the hardcoded laptop profile against+  // ROG, which would have graded a full run against the wrong identity.+  if (TARGET_LOST || !r || !Array.isArray(r.profiles)) {+    console.log(`⚠️  RUN ABORTED: could not enumerate profiles on '${TARGET}' (${TARGET_LOST || 'nbrowser_profiles gave no list'}) - not guessing a profile.`);+    process.exit(2);+  }+  const ps = r.profiles;   const live = ps.find((p) => p.live && p.browser === 'chrome') || ps.find((p) => p.live);   if (live) return live.profile;   const installed = ps.find((p) => p.extensionInstalled && p.browser === 'chrome') || ps.find((p) => p.extensionInstalled);   if (installed) { call('nbrowser_wake_profile', { profile: installed.profile }); return installed.profile; }-  return ps.length ? ps[0].profile : 'chrome:[email protected]';+  if (!ps.length) { console.log(`⚠️  RUN ABORTED: '${TARGET}' reports zero browser profiles.`); process.exit(2); }+  return ps[0].profile; }  if (import.meta.url === `file://${process.argv[1]}`) {