clementine-agent 1.18.146 → 1.18.147
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/dist/cli/dashboard.js +22 -0
- package/dist/cli/index.js +33 -2
- package/package.json +1 -1
package/dist/cli/dashboard.js
CHANGED
|
@@ -1754,6 +1754,28 @@ export async function cmdDashboard(opts) {
|
|
|
1754
1754
|
}
|
|
1755
1755
|
catch { /* ignore */ }
|
|
1756
1756
|
};
|
|
1757
|
+
// 1.18.147 — Auto-open the dashboard URL in the user's default
|
|
1758
|
+
// browser once the child has had a chance to bind + write the
|
|
1759
|
+
// token file. Direct `clementine dashboard` invocations now match
|
|
1760
|
+
// the restart/update flow so the user never has to copy-paste a
|
|
1761
|
+
// token by hand. Honors NO_BROWSER=1 for headless / CI runs.
|
|
1762
|
+
if (process.env.NO_BROWSER !== '1') {
|
|
1763
|
+
setTimeout(() => {
|
|
1764
|
+
try {
|
|
1765
|
+
const tokenPath = path.join(BASE_DIR, '.dashboard-token');
|
|
1766
|
+
const token = existsSync(tokenPath) ? readFileSync(tokenPath, 'utf-8').trim() : '';
|
|
1767
|
+
if (!token)
|
|
1768
|
+
return;
|
|
1769
|
+
const url = `http://localhost:${childPort}/?token=${token}`;
|
|
1770
|
+
const platform = process.platform;
|
|
1771
|
+
const cmd = platform === 'darwin' ? 'open'
|
|
1772
|
+
: platform === 'win32' ? 'start'
|
|
1773
|
+
: 'xdg-open';
|
|
1774
|
+
spawn(cmd, [url], { detached: true, stdio: 'ignore' }).unref();
|
|
1775
|
+
}
|
|
1776
|
+
catch { /* best effort */ }
|
|
1777
|
+
}, 1500);
|
|
1778
|
+
}
|
|
1757
1779
|
// Forward signals to child
|
|
1758
1780
|
process.on('SIGINT', () => { child.kill('SIGINT'); cleanup(); process.exit(0); });
|
|
1759
1781
|
process.on('SIGTERM', () => { child.kill('SIGTERM'); cleanup(); process.exit(0); });
|
package/dist/cli/index.js
CHANGED
|
@@ -472,7 +472,32 @@ function cmdStop() {
|
|
|
472
472
|
* the user's old browser tab (which would silently 401 on the stale
|
|
473
473
|
* token) doesn't waste their time.
|
|
474
474
|
*/
|
|
475
|
-
|
|
475
|
+
/**
|
|
476
|
+
* 1.18.147 — Open the dashboard URL in the user's default browser.
|
|
477
|
+
*
|
|
478
|
+
* Invoked after the dashboard child binds. Best-effort cross-platform:
|
|
479
|
+
* macOS uses `open`, Windows uses `start`, Linux falls back to
|
|
480
|
+
* `xdg-open`. Failures are swallowed (no native browser, headless
|
|
481
|
+
* SSH session, etc.) — the printed URL is still the source of truth
|
|
482
|
+
* the user can copy by hand.
|
|
483
|
+
*
|
|
484
|
+
* Honors NO_BROWSER=1 env var so CI / scripted runs don't get a
|
|
485
|
+
* spurious browser tab.
|
|
486
|
+
*/
|
|
487
|
+
function openInBrowser(url) {
|
|
488
|
+
if (process.env.NO_BROWSER === '1')
|
|
489
|
+
return;
|
|
490
|
+
const platform = process.platform;
|
|
491
|
+
const cmd = platform === 'darwin' ? 'open'
|
|
492
|
+
: platform === 'win32' ? 'start'
|
|
493
|
+
: 'xdg-open';
|
|
494
|
+
try {
|
|
495
|
+
const { spawn: spawnProc } = require('node:child_process');
|
|
496
|
+
spawnProc(cmd, [url], { detached: true, stdio: 'ignore' }).unref();
|
|
497
|
+
}
|
|
498
|
+
catch { /* no browser available; URL was already printed */ }
|
|
499
|
+
}
|
|
500
|
+
async function relaunchDashboardDetached(opts = {}) {
|
|
476
501
|
try {
|
|
477
502
|
const { spawn: spawnProc } = await import('node:child_process');
|
|
478
503
|
const child = spawnProc('node', [path.join(PACKAGE_ROOT, 'dist/cli/index.js'), 'dashboard'], { detached: true, stdio: 'ignore' });
|
|
@@ -489,7 +514,13 @@ async function relaunchDashboardDetached() {
|
|
|
489
514
|
}
|
|
490
515
|
catch { /* token may not be ready yet */ }
|
|
491
516
|
if (token) {
|
|
492
|
-
|
|
517
|
+
const url = `http://localhost:3030/?token=${token}`;
|
|
518
|
+
console.log(` Dashboard relaunched: ${url}`);
|
|
519
|
+
// 1.18.147 — auto-open the browser by default. Restart/update
|
|
520
|
+
// already imply user wants the dashboard back; making them copy a
|
|
521
|
+
// URL was a UX papercut.
|
|
522
|
+
if (opts.open !== false)
|
|
523
|
+
openInBrowser(url);
|
|
493
524
|
}
|
|
494
525
|
else {
|
|
495
526
|
console.log(' Dashboard relaunched (token not ready — check `clementine status`).');
|