mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
fix(panel): auto-provision Desktop shortcuts and add out-of-job 1-click host relaunch for 2.33.0+
- Add cross-platform desktop launcher manager (backend/desktop-launcher-config.mjs): automatically appends --remote-debugging-port=0 to user Desktop (including OneDrive), Start Menu, Taskbar pinned, and Startup Antigravity.lnk shortcuts plus existing HKCU Run entries on Windows and XDG .desktop launchers on Linux, with clean rollback when switching back to Sidebar Only mode - Remove ineffective Desktop argv.json provisioning (Electron Desktop 2.33.0 does not read argv.json) while retaining ~/.antigravity-ide/argv.json for Antigravity IDE - Add POST /api/bridge/relaunch (with hot-reload POST /api/settings fallback) using Shell.Application (-Sta + UTF-8 BOM .ps1) on Windows to break out of the host Job Object, exit tray instances, clean up stale DevToolsActivePort files, sanitize host environment variables, and relaunch with --remote-debugging-port=0 (plus open -a / nohup support on macOS and Linux, and live running-process path discovery across drives) - Surface dismissible BridgeStatusNotice banner directly at the top of App.js alongside Settings tabs so users can activate topbar/composer mounting in one click Closes #26
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @fileoverview Shared CDP / Window Bridge diagnostic notice card (`BridgeStatusNotice.js`).
|
||||
* Surfaces actionable restart or `--remote-debugging-port=0` guidance when Antigravity 2.33.0+
|
||||
* runs without an active `DevToolsActivePort` (`no_devtools_port` / `cdp_unreachable`).
|
||||
* @fileoverview Shared CDP / Window Bridge diagnostic & one-click relaunch card (`BridgeStatusNotice.js`).
|
||||
* Surfaces automatic shortcut provisioning status and a one-click host relaunch button when
|
||||
* Antigravity 2.33.0+ runs without an active `DevToolsActivePort` (`no_devtools_port` / `cdp_unreachable`).
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
@@ -9,6 +9,7 @@ import { h, patchAttr, patchClasses, patchText } from '../../core/domPatch.js';
|
||||
import { isWindowOverlayMode } from '../../core/httpClient.js';
|
||||
import { createSvgIcon, patchSvgIcon } from '../../icons/SvgIcon.js';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { triggerBridgeHostRelaunch } from '../../store/telemetryStore.js';
|
||||
|
||||
const LAUNCH_FLAG_TEXT = '--remote-debugging-port=0';
|
||||
|
||||
@@ -41,19 +42,99 @@ export const BridgeStatusNotice = defineComponent({
|
||||
name: 'BridgeStatusNotice',
|
||||
setup({ props, onCleanup }) {
|
||||
const contextMode = Boolean(props?.contextMode);
|
||||
const dismissible = Boolean(props?.dismissible);
|
||||
let lastPayload = {
|
||||
visible: false,
|
||||
windowBridge: null,
|
||||
hostPlatform: 'win32',
|
||||
};
|
||||
let dismissed = false;
|
||||
let copied = false;
|
||||
let copiedTimer = null;
|
||||
let relaunchState = 'idle'; // 'idle' | 'relaunching' | 'failed'
|
||||
let relaunchResetTimer = null;
|
||||
let destroyed = false;
|
||||
|
||||
const headIconEl = createSvgIcon('warning', { size: 13, className: 'settings-bridge-icon' });
|
||||
const titleEl = h('strong', { className: 'settings-bridge-title', text: '' });
|
||||
const bodyEl = h('p', { className: 'settings-bridge-desc', text: '' });
|
||||
|
||||
const dismissBtnEl = dismissible
|
||||
? h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'btn-ghost-sm settings-bridge-dismiss-btn',
|
||||
'aria-label': t('settings.bridge.dismissAria'),
|
||||
title: t('settings.bridge.dismissAria'),
|
||||
onClick: () => {
|
||||
dismissed = true;
|
||||
render();
|
||||
props?.onDismiss?.();
|
||||
},
|
||||
},
|
||||
[createSvgIcon('close', { size: 11 })]
|
||||
)
|
||||
: null;
|
||||
|
||||
const relaunchBtnIconEl = createSvgIcon('refresh', { size: 11 });
|
||||
const relaunchBtnTextEl = h('span', {
|
||||
className: 'settings-bridge-relaunch-text',
|
||||
text: t('settings.bridge.relaunchBtn'),
|
||||
});
|
||||
const relaunchBtnEl = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'settings-bridge-relaunch-btn',
|
||||
onClick: async () => {
|
||||
if (relaunchState === 'relaunching' || destroyed) return;
|
||||
relaunchState = 'relaunching';
|
||||
if (relaunchResetTimer) {
|
||||
clearTimeout(relaunchResetTimer);
|
||||
relaunchResetTimer = null;
|
||||
}
|
||||
syncActionButtons();
|
||||
try {
|
||||
const res = await triggerBridgeHostRelaunch();
|
||||
if (destroyed) return;
|
||||
if (!res || res.ok === false) {
|
||||
relaunchState = 'failed';
|
||||
syncActionButtons();
|
||||
relaunchResetTimer = setTimeout(() => {
|
||||
relaunchResetTimer = null;
|
||||
if (destroyed) return;
|
||||
relaunchState = 'idle';
|
||||
syncActionButtons();
|
||||
}, 3500);
|
||||
relaunchResetTimer?.unref?.();
|
||||
return;
|
||||
}
|
||||
// Reset button if host is still open after 9s (e.g. cancelled close prompt)
|
||||
relaunchResetTimer = setTimeout(() => {
|
||||
relaunchResetTimer = null;
|
||||
if (destroyed) return;
|
||||
relaunchState = 'idle';
|
||||
syncActionButtons();
|
||||
}, 9000);
|
||||
relaunchResetTimer?.unref?.();
|
||||
} catch {
|
||||
if (destroyed) return;
|
||||
relaunchState = 'failed';
|
||||
syncActionButtons();
|
||||
relaunchResetTimer = setTimeout(() => {
|
||||
relaunchResetTimer = null;
|
||||
if (destroyed) return;
|
||||
relaunchState = 'idle';
|
||||
syncActionButtons();
|
||||
}, 3500);
|
||||
relaunchResetTimer?.unref?.();
|
||||
}
|
||||
},
|
||||
},
|
||||
[relaunchBtnIconEl, relaunchBtnTextEl]
|
||||
);
|
||||
|
||||
const copyBtnIconEl = createSvgIcon('copy', { size: 11 });
|
||||
const copyBtnTextEl = h('span', {
|
||||
className: 'settings-bridge-copy-text',
|
||||
@@ -69,12 +150,12 @@ export const BridgeStatusNotice = defineComponent({
|
||||
if (destroyed) return;
|
||||
copied = true;
|
||||
if (copiedTimer) clearTimeout(copiedTimer);
|
||||
syncCopyBtn();
|
||||
syncActionButtons();
|
||||
copiedTimer = setTimeout(() => {
|
||||
copiedTimer = null;
|
||||
if (destroyed) return;
|
||||
copied = false;
|
||||
syncCopyBtn();
|
||||
syncActionButtons();
|
||||
}, 1800);
|
||||
copiedTimer?.unref?.();
|
||||
},
|
||||
@@ -82,6 +163,17 @@ export const BridgeStatusNotice = defineComponent({
|
||||
[copyBtnIconEl, copyBtnTextEl]
|
||||
);
|
||||
|
||||
const headLeftEl = h('div', { className: 'settings-bridge-head-main' }, [headIconEl, titleEl]);
|
||||
const headRowEl = h(
|
||||
'div',
|
||||
{ className: 'settings-bridge-head' },
|
||||
dismissBtnEl ? [headLeftEl, dismissBtnEl] : [headLeftEl]
|
||||
);
|
||||
const actionsRowEl = h('div', { className: 'settings-bridge-actions' }, [
|
||||
relaunchBtnEl,
|
||||
copyBtnEl,
|
||||
]);
|
||||
|
||||
const rootEl = h(
|
||||
'div',
|
||||
{
|
||||
@@ -89,14 +181,22 @@ export const BridgeStatusNotice = defineComponent({
|
||||
role: 'status',
|
||||
hidden: true,
|
||||
},
|
||||
[
|
||||
h('div', { className: 'settings-bridge-head' }, [headIconEl, titleEl]),
|
||||
bodyEl,
|
||||
copyBtnEl,
|
||||
]
|
||||
[headRowEl, bodyEl, actionsRowEl]
|
||||
);
|
||||
|
||||
function syncCopyBtn() {
|
||||
function syncActionButtons() {
|
||||
const canRelaunch = lastPayload.windowBridge?.canRelaunch !== false;
|
||||
patchAttr(relaunchBtnEl, 'hidden', !canRelaunch);
|
||||
patchAttr(relaunchBtnEl, 'disabled', relaunchState === 'relaunching');
|
||||
patchText(
|
||||
relaunchBtnTextEl,
|
||||
relaunchState === 'relaunching'
|
||||
? t('settings.bridge.relaunchingBtn')
|
||||
: relaunchState === 'failed'
|
||||
? t('settings.bridge.relaunchFailed')
|
||||
: t('settings.bridge.relaunchBtn')
|
||||
);
|
||||
|
||||
patchSvgIcon(copyBtnIconEl, copied ? 'check' : 'copy');
|
||||
patchText(
|
||||
copyBtnTextEl,
|
||||
@@ -104,12 +204,22 @@ export const BridgeStatusNotice = defineComponent({
|
||||
? t('settings.bridge.copiedBtn')
|
||||
: t('settings.bridge.copyFlagBtn', { cmd: LAUNCH_FLAG_TEXT })
|
||||
);
|
||||
|
||||
if (dismissBtnEl) {
|
||||
const aria = t('settings.bridge.dismissAria');
|
||||
patchAttr(dismissBtnEl, 'aria-label', aria);
|
||||
patchAttr(dismissBtnEl, 'title', aria);
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
const wb = lastPayload.windowBridge;
|
||||
const state = String(wb?.state || '').trim();
|
||||
if (state === 'active') {
|
||||
dismissed = false;
|
||||
}
|
||||
const shouldShow =
|
||||
!dismissed &&
|
||||
Boolean(lastPayload.visible) &&
|
||||
!isWindowOverlayMode() &&
|
||||
(state === 'no_devtools_port' || state === 'cdp_unreachable');
|
||||
@@ -117,16 +227,20 @@ export const BridgeStatusNotice = defineComponent({
|
||||
patchAttr(rootEl, 'hidden', !shouldShow);
|
||||
if (!shouldShow) return;
|
||||
|
||||
const isRestartPending = state === 'no_devtools_port' && Boolean(wb?.argvUpdatedThisBoot);
|
||||
const isAutoConfigured = Boolean(
|
||||
wb?.launcherConfigured || wb?.argvUpdatedThisBoot || wb?.argvConfigured
|
||||
);
|
||||
patchClasses(rootEl, {
|
||||
'is-restart': isRestartPending,
|
||||
'is-warn': !isRestartPending,
|
||||
'is-restart': isAutoConfigured,
|
||||
'is-warn': !isAutoConfigured,
|
||||
});
|
||||
patchSvgIcon(headIconEl, isRestartPending ? 'refresh' : 'warning');
|
||||
patchSvgIcon(headIconEl, isAutoConfigured ? 'refresh' : 'warning');
|
||||
|
||||
let titleText = '';
|
||||
if (isRestartPending) {
|
||||
titleText = t('settings.bridge.restartTitle');
|
||||
if (isAutoConfigured) {
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxRestartTitle')
|
||||
: t('settings.bridge.restartTitle');
|
||||
} else if (contextMode) {
|
||||
titleText = t('settings.bridge.ctxTitle');
|
||||
} else if (state === 'cdp_unreachable') {
|
||||
@@ -137,7 +251,7 @@ export const BridgeStatusNotice = defineComponent({
|
||||
|
||||
const plat = String(lastPayload.hostPlatform || '').trim().toLowerCase();
|
||||
let bodyText = '';
|
||||
if (isRestartPending) {
|
||||
if (isAutoConfigured) {
|
||||
bodyText = t('settings.bridge.restartBody');
|
||||
} else if (plat === 'darwin') {
|
||||
bodyText = t('settings.bridge.guideMac');
|
||||
@@ -149,7 +263,7 @@ export const BridgeStatusNotice = defineComponent({
|
||||
|
||||
patchText(titleEl, titleText);
|
||||
patchText(bodyEl, bodyText);
|
||||
syncCopyBtn();
|
||||
syncActionButtons();
|
||||
}
|
||||
|
||||
function update(next = {}) {
|
||||
@@ -166,6 +280,10 @@ export const BridgeStatusNotice = defineComponent({
|
||||
clearTimeout(copiedTimer);
|
||||
copiedTimer = null;
|
||||
}
|
||||
if (relaunchResetTimer) {
|
||||
clearTimeout(relaunchResetTimer);
|
||||
relaunchResetTimer = null;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -173,7 +291,9 @@ export const BridgeStatusNotice = defineComponent({
|
||||
refs: {
|
||||
update,
|
||||
refreshLabels: render,
|
||||
relaunchBtnEl,
|
||||
copyBtnEl,
|
||||
dismissBtnEl,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user