mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): harden cross-environment 2.33.0+ launcher coverage with zero-subprocess fast path and on-demand UAC
- Add pure Node.js [MS-SHLLINK] raw-byte fast probe (`probeWindowsShortcutsFast`) so steady-state startups and 15-minute background rechecks run in <20ms with zero subprocesses, zero COM calls, and zero recursive folder traversal into Desktop subdirectories or unrelated Start Menu vendor folders - Restrict Windows shortcut scanning to top-level Desktop / OneDrive Desktop / Taskbar / Startup `.lnk` files and `Programs\Antigravity*`, pre-filtering raw bytes before lazily instantiating `WScript.Shell` COM - Patch exact O(1) user-space `HKCU\Software\Classes` launch keys (`antigravity` protocol, `Applications\Antigravity.exe`, `AntigravitySourceFile`) via `.NET` `Registry.CurrentUser` with `--remote-debugging-port=0` placed before `-- "%1"`, resolve `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe` explicitly, and tolerate inaccessible folders without aborting - Support All-Users read-only public shortcuts (`readOnlyPaths`) and elevated old host processes via user-consented `-Verb RunAs` on 1-click relaunch while preserving WMI `Win32_Process.Create` when already elevated and de-elevating via `Shell.Application` when the original host ran unelevated (preserving Explorer drag-and-drop) - Generalize Linux `.desktop` `Exec=` patching for `env` prefixes and `Antigravity-*.AppImage`, add pure `node:fs` `/proc` executable discovery, gate launcher checks behind leader lease acquisition, and differentiate macOS / read-only shortcut notices honestly in `BridgeStatusNotice`
This commit is contained in:
+46
-25
@@ -1463,14 +1463,20 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.str.mountSidebar': '仅侧边栏',
|
||||
'settings.bridge.restartTitle': '已自动补齐启动参数,重启一次即可启用悬浮胶囊',
|
||||
'settings.bridge.ctxRestartTitle': '已自动补齐启动参数,重启一次即可激活上下文覆写',
|
||||
'settings.bridge.restartBody': '已自动为桌面 / 开始菜单 / 任务栏快捷方式及自启项写入 --remote-debugging-port=0(后续每次正常打开均 100% 全自动挂载)。点击下方按钮即可退出托盘后台并立即生效。',
|
||||
'settings.bridge.restartBody': '已自动为快捷方式、自启项及协议关联写入 --remote-debugging-port=0(后续通过常规快捷方式打开均自动生效)。点击下方按钮即可退出后台进程并立即生效。',
|
||||
'settings.bridge.readOnlyTitle': '公共桌面快捷方式受权限保护,授权重启即可生效',
|
||||
'settings.bridge.ctxReadOnlyTitle': '公共桌面快捷方式受权限保护,授权重启即可激活上下文覆写',
|
||||
'settings.bridge.readOnlyBody': '个人启动项已配好,但公共桌面或开始菜单快捷方式需管理员权限修改。点击下方按钮并在系统弹窗中确认授权,即可一次性修补公共图标并带参重开(后续日常打开均自动生效)。',
|
||||
'settings.bridge.macTitle': '当前会话未开启调试端口,一键重开即可启用挂载',
|
||||
'settings.bridge.ctxMacTitle': '当前会话未开启调试端口,一键重开即可激活上下文覆写',
|
||||
'settings.bridge.noPortTitle': '未检测到本地调试端口,主窗口挂载暂未生效',
|
||||
'settings.bridge.unreachableTitle': '本地调试端口未就绪,主窗口挂载暂未生效',
|
||||
'settings.bridge.ctxTitle': '未连通本地调试通道,上下文窗口覆写暂未注入',
|
||||
'settings.bridge.guideWin': 'Antigravity 2.33.0+ 默认不再开启调试端口。点击「立即重启并启用挂载」即可自动补齐快捷方式参数、退出托盘后台并带参重启生效。',
|
||||
'settings.bridge.guideMac': 'Antigravity 2.33.0+ 默认不再开启调试端口。点击「立即重启并启用挂载」即可一键带参重开客户端生效,也可复制参数通过 open -a "Antigravity" --args --remote-debugging-port=0 启动。',
|
||||
'settings.bridge.guideMac': '受 macOS 应用签名限制,从 Dock 直接冷启动默认不带调试端口参数。点击下方按钮即可一键带参重开恢复(日常仅关窗不完全退出 Cmd+Q 则持续有效)。',
|
||||
'settings.bridge.guideLinux': 'Antigravity 2.33.0+ 默认不再开启调试端口。点击「立即重启并启用挂载」即可自动写入 .desktop 启动器并重启生效。',
|
||||
'settings.bridge.relaunchBtn': '立即重启并启用挂载',
|
||||
'settings.bridge.relaunchAuthBtn': '授权修补并立即重启',
|
||||
'settings.bridge.relaunchingBtn': '正在重启客户端...',
|
||||
'settings.bridge.relaunchFailed': '自动重启失败,请从托盘退出后重试',
|
||||
'settings.bridge.dismissAria': '暂时关闭提示',
|
||||
@@ -2093,14 +2099,20 @@ const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.str.mountSidebar': 'Sidebar Only',
|
||||
'settings.bridge.restartTitle': 'Launch Flag Auto-Configured — Restart Once to Activate',
|
||||
'settings.bridge.ctxRestartTitle': 'Launch Flag Auto-Configured — Restart Once for Context Override',
|
||||
'settings.bridge.restartBody': 'Automatically added --remote-debugging-port=0 to your shortcuts and startup entries (future launches mount 100% automatically). Click below to close tray processes and relaunch now.',
|
||||
'settings.bridge.restartBody': 'Automatically added --remote-debugging-port=0 to your shortcuts, startup entries, and protocol handlers (subsequent shortcut launches mount automatically). Click below to close background processes and relaunch now.',
|
||||
'settings.bridge.readOnlyTitle': 'Public Shortcut Protected — Authorize & Relaunch to Activate',
|
||||
'settings.bridge.ctxReadOnlyTitle': 'Public Shortcut Protected — Authorize & Relaunch for Context Override',
|
||||
'settings.bridge.readOnlyBody': 'Personal launch entries are configured, but public shortcuts require administrator permission. Click below and approve the system prompt to patch public shortcuts once and relaunch.',
|
||||
'settings.bridge.macTitle': 'Debug Port Inactive — One-Click Relaunch to Enable Mount',
|
||||
'settings.bridge.ctxMacTitle': 'Debug Port Inactive — One-Click Relaunch for Context Override',
|
||||
'settings.bridge.noPortTitle': 'Local Debug Port Missing — Window Mount Inactive',
|
||||
'settings.bridge.unreachableTitle': 'Local Debug Port Not Ready — Window Mount Inactive',
|
||||
'settings.bridge.ctxTitle': 'Local Debug Port Inactive — Context Override Pending',
|
||||
'settings.bridge.guideWin': 'Antigravity 2.33.0+ no longer opens a debug port by default. Click "Relaunch & Enable Mount" to auto-configure shortcuts, close tray background processes, and relaunch.',
|
||||
'settings.bridge.guideMac': 'Antigravity 2.33.0+ no longer opens a debug port by default. Click "Relaunch & Enable Mount" to relaunch with the flag in one click, or run open -a "Antigravity" --args --remote-debugging-port=0.',
|
||||
'settings.bridge.guideMac': 'Due to macOS app code signing, cold launches from Dock omit the debug port flag. Click below to relaunch with the flag in one click (stays active until you fully Quit via Cmd+Q).',
|
||||
'settings.bridge.guideLinux': 'Antigravity 2.33.0+ no longer opens a debug port by default. Click "Relaunch & Enable Mount" to update your .desktop launcher and relaunch.',
|
||||
'settings.bridge.relaunchBtn': 'Relaunch & Enable Mount',
|
||||
'settings.bridge.relaunchAuthBtn': 'Authorize & Relaunch',
|
||||
'settings.bridge.relaunchingBtn': 'Relaunching Host...',
|
||||
'settings.bridge.relaunchFailed': 'Auto-relaunch failed — quit from tray and retry',
|
||||
'settings.bridge.dismissAria': 'Dismiss notice for now',
|
||||
@@ -14257,6 +14269,7 @@ const BridgeStatusNotice = defineComponent({
|
||||
|
||||
function syncActionButtons() {
|
||||
const canRelaunch = lastPayload.windowBridge?.canRelaunch !== false;
|
||||
const needsAuth = Boolean(lastPayload.windowBridge?.hasReadOnlyShortcuts);
|
||||
patchAttr(relaunchBtnEl, 'hidden', !canRelaunch);
|
||||
patchAttr(relaunchBtnEl, 'disabled', relaunchState === 'relaunching');
|
||||
patchText(
|
||||
@@ -14265,7 +14278,9 @@ const BridgeStatusNotice = defineComponent({
|
||||
? t('settings.bridge.relaunchingBtn')
|
||||
: relaunchState === 'failed'
|
||||
? t('settings.bridge.relaunchFailed')
|
||||
: t('settings.bridge.relaunchBtn')
|
||||
: needsAuth
|
||||
? t('settings.bridge.relaunchAuthBtn')
|
||||
: t('settings.bridge.relaunchBtn')
|
||||
);
|
||||
|
||||
patchSvgIcon(copyBtnIconEl, copied ? 'check' : 'copy');
|
||||
@@ -14298,38 +14313,44 @@ const BridgeStatusNotice = defineComponent({
|
||||
patchAttr(rootEl, 'hidden', !shouldShow);
|
||||
if (!shouldShow) return;
|
||||
|
||||
const plat = String(lastPayload.hostPlatform || '').trim().toLowerCase();
|
||||
const hasReadOnlyShortcuts = Boolean(wb?.hasReadOnlyShortcuts);
|
||||
const isMacDesktop = plat === 'darwin' && !wb?.argvConfigured;
|
||||
const isAutoConfigured = Boolean(
|
||||
wb?.launcherConfigured || wb?.argvUpdatedThisBoot || wb?.argvConfigured
|
||||
);
|
||||
const useRestartTheme = !hasReadOnlyShortcuts && (isAutoConfigured || isMacDesktop);
|
||||
|
||||
patchClasses(rootEl, {
|
||||
'is-restart': isAutoConfigured,
|
||||
'is-warn': !isAutoConfigured,
|
||||
'is-restart': useRestartTheme,
|
||||
'is-warn': !useRestartTheme,
|
||||
});
|
||||
patchSvgIcon(headIconEl, isAutoConfigured ? 'refresh' : 'warning');
|
||||
patchSvgIcon(headIconEl, useRestartTheme ? 'refresh' : 'warning');
|
||||
|
||||
let titleText = '';
|
||||
if (isAutoConfigured) {
|
||||
let bodyText = '';
|
||||
if (hasReadOnlyShortcuts) {
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxReadOnlyTitle')
|
||||
: t('settings.bridge.readOnlyTitle');
|
||||
bodyText = t('settings.bridge.readOnlyBody');
|
||||
} else if (isMacDesktop) {
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxMacTitle')
|
||||
: t('settings.bridge.macTitle');
|
||||
bodyText = t('settings.bridge.guideMac');
|
||||
} else 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') {
|
||||
titleText = t('settings.bridge.unreachableTitle');
|
||||
} else {
|
||||
titleText = t('settings.bridge.noPortTitle');
|
||||
}
|
||||
|
||||
const plat = String(lastPayload.hostPlatform || '').trim().toLowerCase();
|
||||
let bodyText = '';
|
||||
if (isAutoConfigured) {
|
||||
bodyText = t('settings.bridge.restartBody');
|
||||
} else if (plat === 'darwin') {
|
||||
bodyText = t('settings.bridge.guideMac');
|
||||
} else if (plat === 'linux') {
|
||||
bodyText = t('settings.bridge.guideLinux');
|
||||
} else {
|
||||
bodyText = t('settings.bridge.guideWin');
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxTitle')
|
||||
: state === 'cdp_unreachable'
|
||||
? t('settings.bridge.unreachableTitle')
|
||||
: t('settings.bridge.noPortTitle');
|
||||
bodyText = plat === 'linux' ? t('settings.bridge.guideLinux') : t('settings.bridge.guideWin');
|
||||
}
|
||||
|
||||
patchText(titleEl, titleText);
|
||||
|
||||
@@ -460,9 +460,12 @@ export async function executeAccountCredentialAction(data) {
|
||||
|
||||
export async function executeBridgeRelaunchAction() {
|
||||
ensureIdeRemoteDebuggingArgv({ enabled: true });
|
||||
await ensureDesktopLaunchEntriesConfigured({ enabled: true }).catch(() => {});
|
||||
const launchConfig = await ensureDesktopLaunchEntriesConfigured({ enabled: true }).catch(
|
||||
() => null
|
||||
);
|
||||
const result = await triggerDesktopHostRelaunch({
|
||||
stalePortFiles: resolveDevToolsPortCandidates(),
|
||||
readOnlyShortcutPaths: launchConfig?.readOnlyPaths || [],
|
||||
});
|
||||
return {
|
||||
status: result.ok ? 200 : Number(result.status || 500),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -714,6 +714,7 @@ export function createWindowBridgeController(options) {
|
||||
onVersionDrift = null,
|
||||
leaseFilePath = '',
|
||||
autoConfigureIdeArgv = options?.env === undefined && options?.homeDir === undefined,
|
||||
launcherRecheckIntervalMs = 15 * 60 * 1000,
|
||||
launcherExecFileFn = null,
|
||||
launcherFsOps = null,
|
||||
allowDesktopLauncherInTest = false,
|
||||
@@ -743,21 +744,23 @@ export function createWindowBridgeController(options) {
|
||||
let hadInjectedTargets = false;
|
||||
let hadInjectedChatFrames = false;
|
||||
let cdpFallbackActive = false;
|
||||
let ideArgvProvisioned = false;
|
||||
let lastLauncherProvisionAtMs = 0;
|
||||
let hostLauncherPromise = null;
|
||||
let argvUpdatedThisBoot = false;
|
||||
let argvConfigured = false;
|
||||
let launcherConfigured = false;
|
||||
let hasReadOnlyShortcuts = false;
|
||||
const hostExecInfo = resolveDesktopHostExecutable({
|
||||
env,
|
||||
platform,
|
||||
homeDir,
|
||||
existsFn: existsHostFn,
|
||||
});
|
||||
// Windows / macOS 支持从运行中宿主进程动态反查任意盘符路径,因此桌面端环境下即使自定义安装路径不在默认盘符也可一键重拉
|
||||
// Windows / macOS / Linux 均支持从运行中宿主进程动态反查路径(含自定义盘符与 AppImage),自定义安装路径亦可一键重拉
|
||||
const canRelaunch = Boolean(
|
||||
hostExecInfo.found ||
|
||||
((platform === 'win32' || platform === 'darwin') && options?.existsHostFn === undefined)
|
||||
((platform === 'win32' || platform === 'darwin' || platform === 'linux') &&
|
||||
options?.existsHostFn === undefined)
|
||||
);
|
||||
let lastPersistedLeaseSig = '';
|
||||
let lastBridgeStatus = {
|
||||
@@ -768,6 +771,7 @@ export function createWindowBridgeController(options) {
|
||||
argvUpdatedThisBoot: false,
|
||||
argvConfigured: false,
|
||||
launcherConfigured: false,
|
||||
hasReadOnlyShortcuts: false,
|
||||
canRelaunch,
|
||||
updatedAtMs: 0,
|
||||
};
|
||||
@@ -1209,11 +1213,12 @@ export function createWindowBridgeController(options) {
|
||||
argvUpdatedThisBoot: Boolean(argvUpdatedThisBoot),
|
||||
argvConfigured: Boolean(argvConfigured || launcherConfigured),
|
||||
launcherConfigured: Boolean(launcherConfigured || argvConfigured),
|
||||
hasReadOnlyShortcuts: Boolean(hasReadOnlyShortcuts),
|
||||
canRelaunch: Boolean(canRelaunch),
|
||||
updatedAtMs: Date.now(),
|
||||
};
|
||||
if (leasedBySelf && leaseFilePath) {
|
||||
const sig = `${nextState}:${lastBridgeStatus.aliveCount}:${lastBridgeStatus.targets}:${lastBridgeStatus.argvUpdatedThisBoot ? 1 : 0}:${lastBridgeStatus.launcherConfigured ? 1 : 0}:${lastBridgeStatus.canRelaunch ? 1 : 0}`;
|
||||
const sig = `${nextState}:${lastBridgeStatus.aliveCount}:${lastBridgeStatus.targets}:${lastBridgeStatus.argvUpdatedThisBoot ? 1 : 0}:${lastBridgeStatus.launcherConfigured ? 1 : 0}:${lastBridgeStatus.hasReadOnlyShortcuts ? 1 : 0}:${lastBridgeStatus.canRelaunch ? 1 : 0}`;
|
||||
if (sig !== lastPersistedLeaseSig) {
|
||||
lastPersistedLeaseSig = sig;
|
||||
saveJson(leaseFilePath, {
|
||||
@@ -1227,6 +1232,7 @@ export function createWindowBridgeController(options) {
|
||||
argvUpdatedThisBoot: lastBridgeStatus.argvUpdatedThisBoot,
|
||||
argvConfigured: lastBridgeStatus.argvConfigured,
|
||||
launcherConfigured: lastBridgeStatus.launcherConfigured,
|
||||
hasReadOnlyShortcuts: lastBridgeStatus.hasReadOnlyShortcuts,
|
||||
canRelaunch: lastBridgeStatus.canRelaunch,
|
||||
updatedAtMs: Date.now(),
|
||||
});
|
||||
@@ -1234,13 +1240,13 @@ export function createWindowBridgeController(options) {
|
||||
}
|
||||
}
|
||||
|
||||
function provisionHostLaunchersOnce() {
|
||||
if (ideArgvProvisioned) return Promise.resolve();
|
||||
function provisionHostLaunchersOnce({ fastCheckIfActive = false } = {}) {
|
||||
if (hostLauncherPromise) return hostLauncherPromise;
|
||||
hostLauncherPromise = (async () => {
|
||||
const ideRes = ensureIdeRemoteDebuggingArgv({ env, homeDir, enabled: true });
|
||||
const desktopRes = await ensureDesktopLaunchEntriesConfigured({
|
||||
enabled: true,
|
||||
fastCheckIfActive,
|
||||
env,
|
||||
platform,
|
||||
homeDir,
|
||||
@@ -1254,10 +1260,13 @@ export function createWindowBridgeController(options) {
|
||||
if (ideRes.updated || ideRes.alreadyConfigured) {
|
||||
argvConfigured = true;
|
||||
}
|
||||
if (desktopRes.updated || desktopRes.alreadyConfigured || desktopRes.configured) {
|
||||
launcherConfigured = true;
|
||||
launcherConfigured = Boolean(
|
||||
desktopRes.updated || desktopRes.alreadyConfigured || desktopRes.configured
|
||||
);
|
||||
if (!desktopRes.fastPath) {
|
||||
hasReadOnlyShortcuts = Boolean(desktopRes.hasReadOnlyShortcuts);
|
||||
}
|
||||
ideArgvProvisioned = true;
|
||||
lastLauncherProvisionAtMs = Date.now();
|
||||
})().finally(() => {
|
||||
hostLauncherPromise = null;
|
||||
});
|
||||
@@ -1280,10 +1289,6 @@ export function createWindowBridgeController(options) {
|
||||
const enabled = Boolean(curSettings.enableWindowOverlay !== false && mountMode !== 'sidebar');
|
||||
const contextWindows = curSettings.modelContextWindows || {};
|
||||
const hasContextWindows = Object.keys(contextWindows).length > 0;
|
||||
const provPending =
|
||||
(enabled || hasContextWindows) && autoConfigureIdeArgv && !ideArgvProvisioned
|
||||
? provisionHostLaunchersOnce()
|
||||
: hostLauncherPromise;
|
||||
|
||||
let leasedBySelf = false;
|
||||
let currentLease = null;
|
||||
@@ -1311,6 +1316,7 @@ export function createWindowBridgeController(options) {
|
||||
argvUpdatedThisBoot: Boolean(lease?.argvUpdatedThisBoot || argvUpdatedThisBoot),
|
||||
argvConfigured: mergedConfigured,
|
||||
launcherConfigured: mergedConfigured,
|
||||
hasReadOnlyShortcuts: Boolean(lease?.hasReadOnlyShortcuts || hasReadOnlyShortcuts),
|
||||
canRelaunch: Boolean(lease?.canRelaunch ?? canRelaunch),
|
||||
updatedAtMs: Date.now(),
|
||||
};
|
||||
@@ -1330,13 +1336,24 @@ export function createWindowBridgeController(options) {
|
||||
argvUpdatedThisBoot: Boolean(argvUpdatedThisBoot),
|
||||
argvConfigured: Boolean(argvConfigured || launcherConfigured),
|
||||
launcherConfigured: Boolean(launcherConfigured || argvConfigured),
|
||||
hasReadOnlyShortcuts: Boolean(hasReadOnlyShortcuts),
|
||||
canRelaunch: Boolean(canRelaunch),
|
||||
updatedAtMs: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
const shouldCheckLaunchers =
|
||||
(enabled || hasContextWindows) &&
|
||||
autoConfigureIdeArgv &&
|
||||
(lastLauncherProvisionAtMs === 0 ||
|
||||
Date.now() - lastLauncherProvisionAtMs >= launcherRecheckIntervalMs);
|
||||
const isInitialLauncherPass = lastLauncherProvisionAtMs === 0;
|
||||
|
||||
const cdpPorts = findActiveDevToolsPorts();
|
||||
if (!cdpPorts.length) {
|
||||
const provPending = shouldCheckLaunchers
|
||||
? provisionHostLaunchersOnce({ fastCheckIfActive: !isInitialLauncherPass })
|
||||
: hostLauncherPromise;
|
||||
if (provPending) {
|
||||
await provPending.catch(() => {});
|
||||
}
|
||||
@@ -1351,6 +1368,9 @@ export function createWindowBridgeController(options) {
|
||||
|
||||
const { reachableCount, targets } = await collectAllMainWindowTargets(cdpPorts);
|
||||
if (reachableCount === 0) {
|
||||
const provPending = shouldCheckLaunchers
|
||||
? provisionHostLaunchersOnce({ fastCheckIfActive: !isInitialLauncherPass })
|
||||
: hostLauncherPromise;
|
||||
if (provPending) {
|
||||
await provPending.catch(() => {});
|
||||
}
|
||||
@@ -1362,6 +1382,11 @@ export function createWindowBridgeController(options) {
|
||||
});
|
||||
return { ok: false, enabled, reason: 'cdp_unreachable', injected: 0 };
|
||||
}
|
||||
|
||||
if (shouldCheckLaunchers) {
|
||||
// 调试端口已正常连通时走纯 Node.js 零子进程快检(<2ms),仅在发现未配参快捷方式时才拉起 PowerShell
|
||||
void provisionHostLaunchersOnce({ fastCheckIfActive: true }).catch(() => {});
|
||||
}
|
||||
if (!targets.length) {
|
||||
updateBridgeStatus(enabled ? 'no_targets' : 'disabled', {
|
||||
enabled,
|
||||
@@ -1842,6 +1867,8 @@ export function createWindowBridgeController(options) {
|
||||
const hasCtx = Object.keys(cur.modelContextWindows || {}).length > 0;
|
||||
if (!hasCtx && autoConfigureIdeArgv) {
|
||||
launcherConfigured = false;
|
||||
hasReadOnlyShortcuts = false;
|
||||
lastLauncherProvisionAtMs = 0;
|
||||
void ensureDesktopLaunchEntriesConfigured({
|
||||
enabled: false,
|
||||
env,
|
||||
@@ -1853,7 +1880,7 @@ export function createWindowBridgeController(options) {
|
||||
}).catch(() => {});
|
||||
}
|
||||
} else {
|
||||
ideArgvProvisioned = false;
|
||||
lastLauncherProvisionAtMs = 0;
|
||||
hadInjectedChatFrames = true;
|
||||
}
|
||||
return syncAllWindows({ forceReinject: false }).catch(() => ({ ok: false }));
|
||||
@@ -1865,9 +1892,11 @@ export function createWindowBridgeController(options) {
|
||||
const overlayOn = Boolean(cur.enableWindowOverlay !== false && mountMode !== 'sidebar');
|
||||
const hasCtx = Object.keys(cur.modelContextWindows || {}).length > 0;
|
||||
if (hasCtx) {
|
||||
ideArgvProvisioned = false;
|
||||
lastLauncherProvisionAtMs = 0;
|
||||
} else if (!overlayOn && autoConfigureIdeArgv) {
|
||||
launcherConfigured = false;
|
||||
hasReadOnlyShortcuts = false;
|
||||
lastLauncherProvisionAtMs = 0;
|
||||
void ensureDesktopLaunchEntriesConfigured({
|
||||
enabled: false,
|
||||
env,
|
||||
@@ -1908,6 +1937,7 @@ export function getDefaultWindowBridgeStatus() {
|
||||
argvUpdatedThisBoot: false,
|
||||
argvConfigured: false,
|
||||
launcherConfigured: false,
|
||||
hasReadOnlyShortcuts: false,
|
||||
canRelaunch: false,
|
||||
updatedAtMs: 0,
|
||||
};
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>用量监控</title>
|
||||
<link rel="stylesheet" href="/styles.css?v=1795006728154">
|
||||
<link rel="stylesheet" href="/styles.css?v=1795018723250">
|
||||
<script src="/preload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app-root"></div>
|
||||
<script src="/app.js?v=1795006728154"></script>
|
||||
<script src="/app.js?v=1795018723250"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -186,6 +186,7 @@ export const BridgeStatusNotice = defineComponent({
|
||||
|
||||
function syncActionButtons() {
|
||||
const canRelaunch = lastPayload.windowBridge?.canRelaunch !== false;
|
||||
const needsAuth = Boolean(lastPayload.windowBridge?.hasReadOnlyShortcuts);
|
||||
patchAttr(relaunchBtnEl, 'hidden', !canRelaunch);
|
||||
patchAttr(relaunchBtnEl, 'disabled', relaunchState === 'relaunching');
|
||||
patchText(
|
||||
@@ -194,7 +195,9 @@ export const BridgeStatusNotice = defineComponent({
|
||||
? t('settings.bridge.relaunchingBtn')
|
||||
: relaunchState === 'failed'
|
||||
? t('settings.bridge.relaunchFailed')
|
||||
: t('settings.bridge.relaunchBtn')
|
||||
: needsAuth
|
||||
? t('settings.bridge.relaunchAuthBtn')
|
||||
: t('settings.bridge.relaunchBtn')
|
||||
);
|
||||
|
||||
patchSvgIcon(copyBtnIconEl, copied ? 'check' : 'copy');
|
||||
@@ -227,38 +230,44 @@ export const BridgeStatusNotice = defineComponent({
|
||||
patchAttr(rootEl, 'hidden', !shouldShow);
|
||||
if (!shouldShow) return;
|
||||
|
||||
const plat = String(lastPayload.hostPlatform || '').trim().toLowerCase();
|
||||
const hasReadOnlyShortcuts = Boolean(wb?.hasReadOnlyShortcuts);
|
||||
const isMacDesktop = plat === 'darwin' && !wb?.argvConfigured;
|
||||
const isAutoConfigured = Boolean(
|
||||
wb?.launcherConfigured || wb?.argvUpdatedThisBoot || wb?.argvConfigured
|
||||
);
|
||||
const useRestartTheme = !hasReadOnlyShortcuts && (isAutoConfigured || isMacDesktop);
|
||||
|
||||
patchClasses(rootEl, {
|
||||
'is-restart': isAutoConfigured,
|
||||
'is-warn': !isAutoConfigured,
|
||||
'is-restart': useRestartTheme,
|
||||
'is-warn': !useRestartTheme,
|
||||
});
|
||||
patchSvgIcon(headIconEl, isAutoConfigured ? 'refresh' : 'warning');
|
||||
patchSvgIcon(headIconEl, useRestartTheme ? 'refresh' : 'warning');
|
||||
|
||||
let titleText = '';
|
||||
if (isAutoConfigured) {
|
||||
let bodyText = '';
|
||||
if (hasReadOnlyShortcuts) {
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxReadOnlyTitle')
|
||||
: t('settings.bridge.readOnlyTitle');
|
||||
bodyText = t('settings.bridge.readOnlyBody');
|
||||
} else if (isMacDesktop) {
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxMacTitle')
|
||||
: t('settings.bridge.macTitle');
|
||||
bodyText = t('settings.bridge.guideMac');
|
||||
} else 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') {
|
||||
titleText = t('settings.bridge.unreachableTitle');
|
||||
} else {
|
||||
titleText = t('settings.bridge.noPortTitle');
|
||||
}
|
||||
|
||||
const plat = String(lastPayload.hostPlatform || '').trim().toLowerCase();
|
||||
let bodyText = '';
|
||||
if (isAutoConfigured) {
|
||||
bodyText = t('settings.bridge.restartBody');
|
||||
} else if (plat === 'darwin') {
|
||||
bodyText = t('settings.bridge.guideMac');
|
||||
} else if (plat === 'linux') {
|
||||
bodyText = t('settings.bridge.guideLinux');
|
||||
} else {
|
||||
bodyText = t('settings.bridge.guideWin');
|
||||
titleText = contextMode
|
||||
? t('settings.bridge.ctxTitle')
|
||||
: state === 'cdp_unreachable'
|
||||
? t('settings.bridge.unreachableTitle')
|
||||
: t('settings.bridge.noPortTitle');
|
||||
bodyText = plat === 'linux' ? t('settings.bridge.guideLinux') : t('settings.bridge.guideWin');
|
||||
}
|
||||
|
||||
patchText(titleEl, titleText);
|
||||
|
||||
@@ -437,14 +437,20 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.str.mountSidebar': 'Sidebar Only',
|
||||
'settings.bridge.restartTitle': 'Launch Flag Auto-Configured — Restart Once to Activate',
|
||||
'settings.bridge.ctxRestartTitle': 'Launch Flag Auto-Configured — Restart Once for Context Override',
|
||||
'settings.bridge.restartBody': 'Automatically added --remote-debugging-port=0 to your shortcuts and startup entries (future launches mount 100% automatically). Click below to close tray processes and relaunch now.',
|
||||
'settings.bridge.restartBody': 'Automatically added --remote-debugging-port=0 to your shortcuts, startup entries, and protocol handlers (subsequent shortcut launches mount automatically). Click below to close background processes and relaunch now.',
|
||||
'settings.bridge.readOnlyTitle': 'Public Shortcut Protected — Authorize & Relaunch to Activate',
|
||||
'settings.bridge.ctxReadOnlyTitle': 'Public Shortcut Protected — Authorize & Relaunch for Context Override',
|
||||
'settings.bridge.readOnlyBody': 'Personal launch entries are configured, but public shortcuts require administrator permission. Click below and approve the system prompt to patch public shortcuts once and relaunch.',
|
||||
'settings.bridge.macTitle': 'Debug Port Inactive — One-Click Relaunch to Enable Mount',
|
||||
'settings.bridge.ctxMacTitle': 'Debug Port Inactive — One-Click Relaunch for Context Override',
|
||||
'settings.bridge.noPortTitle': 'Local Debug Port Missing — Window Mount Inactive',
|
||||
'settings.bridge.unreachableTitle': 'Local Debug Port Not Ready — Window Mount Inactive',
|
||||
'settings.bridge.ctxTitle': 'Local Debug Port Inactive — Context Override Pending',
|
||||
'settings.bridge.guideWin': 'Antigravity 2.33.0+ no longer opens a debug port by default. Click "Relaunch & Enable Mount" to auto-configure shortcuts, close tray background processes, and relaunch.',
|
||||
'settings.bridge.guideMac': 'Antigravity 2.33.0+ no longer opens a debug port by default. Click "Relaunch & Enable Mount" to relaunch with the flag in one click, or run open -a "Antigravity" --args --remote-debugging-port=0.',
|
||||
'settings.bridge.guideMac': 'Due to macOS app code signing, cold launches from Dock omit the debug port flag. Click below to relaunch with the flag in one click (stays active until you fully Quit via Cmd+Q).',
|
||||
'settings.bridge.guideLinux': 'Antigravity 2.33.0+ no longer opens a debug port by default. Click "Relaunch & Enable Mount" to update your .desktop launcher and relaunch.',
|
||||
'settings.bridge.relaunchBtn': 'Relaunch & Enable Mount',
|
||||
'settings.bridge.relaunchAuthBtn': 'Authorize & Relaunch',
|
||||
'settings.bridge.relaunchingBtn': 'Relaunching Host...',
|
||||
'settings.bridge.relaunchFailed': 'Auto-relaunch failed — quit from tray and retry',
|
||||
'settings.bridge.dismissAria': 'Dismiss notice for now',
|
||||
|
||||
@@ -437,14 +437,20 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.str.mountSidebar': '仅侧边栏',
|
||||
'settings.bridge.restartTitle': '已自动补齐启动参数,重启一次即可启用悬浮胶囊',
|
||||
'settings.bridge.ctxRestartTitle': '已自动补齐启动参数,重启一次即可激活上下文覆写',
|
||||
'settings.bridge.restartBody': '已自动为桌面 / 开始菜单 / 任务栏快捷方式及自启项写入 --remote-debugging-port=0(后续每次正常打开均 100% 全自动挂载)。点击下方按钮即可退出托盘后台并立即生效。',
|
||||
'settings.bridge.restartBody': '已自动为快捷方式、自启项及协议关联写入 --remote-debugging-port=0(后续通过常规快捷方式打开均自动生效)。点击下方按钮即可退出后台进程并立即生效。',
|
||||
'settings.bridge.readOnlyTitle': '公共桌面快捷方式受权限保护,授权重启即可生效',
|
||||
'settings.bridge.ctxReadOnlyTitle': '公共桌面快捷方式受权限保护,授权重启即可激活上下文覆写',
|
||||
'settings.bridge.readOnlyBody': '个人启动项已配好,但公共桌面或开始菜单快捷方式需管理员权限修改。点击下方按钮并在系统弹窗中确认授权,即可一次性修补公共图标并带参重开(后续日常打开均自动生效)。',
|
||||
'settings.bridge.macTitle': '当前会话未开启调试端口,一键重开即可启用挂载',
|
||||
'settings.bridge.ctxMacTitle': '当前会话未开启调试端口,一键重开即可激活上下文覆写',
|
||||
'settings.bridge.noPortTitle': '未检测到本地调试端口,主窗口挂载暂未生效',
|
||||
'settings.bridge.unreachableTitle': '本地调试端口未就绪,主窗口挂载暂未生效',
|
||||
'settings.bridge.ctxTitle': '未连通本地调试通道,上下文窗口覆写暂未注入',
|
||||
'settings.bridge.guideWin': 'Antigravity 2.33.0+ 默认不再开启调试端口。点击「立即重启并启用挂载」即可自动补齐快捷方式参数、退出托盘后台并带参重启生效。',
|
||||
'settings.bridge.guideMac': 'Antigravity 2.33.0+ 默认不再开启调试端口。点击「立即重启并启用挂载」即可一键带参重开客户端生效,也可复制参数通过 open -a "Antigravity" --args --remote-debugging-port=0 启动。',
|
||||
'settings.bridge.guideMac': '受 macOS 应用签名限制,从 Dock 直接冷启动默认不带调试端口参数。点击下方按钮即可一键带参重开恢复(日常仅关窗不完全退出 Cmd+Q 则持续有效)。',
|
||||
'settings.bridge.guideLinux': 'Antigravity 2.33.0+ 默认不再开启调试端口。点击「立即重启并启用挂载」即可自动写入 .desktop 启动器并重启生效。',
|
||||
'settings.bridge.relaunchBtn': '立即重启并启用挂载',
|
||||
'settings.bridge.relaunchAuthBtn': '授权修补并立即重启',
|
||||
'settings.bridge.relaunchingBtn': '正在重启客户端...',
|
||||
'settings.bridge.relaunchFailed': '自动重启失败,请从托盘退出后重试',
|
||||
'settings.bridge.dismissAria': '暂时关闭提示',
|
||||
|
||||
@@ -25,9 +25,13 @@ import {
|
||||
buildWindowsRelaunchInnerScript,
|
||||
ensureDesktopLaunchEntriesConfigured,
|
||||
ensureRemoteDebugFlagInArgs,
|
||||
inspectWindowsLnkBuffer,
|
||||
patchLinuxDesktopEntryText,
|
||||
patchWindowsRunRegistryCommand,
|
||||
patchWindowsShellOpenCommand,
|
||||
probeWindowsShortcutsFast,
|
||||
resolveDesktopHostExecutable,
|
||||
resolveWindowsPowerShellExecutable,
|
||||
triggerDesktopHostRelaunch,
|
||||
} from '../backend/desktop-launcher-config.mjs';
|
||||
import {
|
||||
@@ -4909,6 +4913,107 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
);
|
||||
assert.equal(winRunIdeIgnored.matched, false);
|
||||
|
||||
// System32 PowerShell resolution & HKCU\Software\Classes shell\open\command patching
|
||||
assert.equal(
|
||||
resolveWindowsPowerShellExecutable(
|
||||
{ SystemRoot: 'D:\\WinSys' },
|
||||
(p) => p === 'D:\\WinSys\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
|
||||
),
|
||||
'D:\\WinSys\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
|
||||
);
|
||||
assert.equal(
|
||||
resolveWindowsPowerShellExecutable({ SystemRoot: 'D:\\Missing' }, () => false),
|
||||
'powershell.exe'
|
||||
);
|
||||
|
||||
const shellOpenPatched = patchWindowsShellOpenCommand(
|
||||
'"C:\\Users\\Dev\\AppData\\Local\\Programs\\Antigravity\\Antigravity.exe" -- "%1"',
|
||||
{ enabled: true }
|
||||
);
|
||||
assert.equal(shellOpenPatched.matched, true);
|
||||
assert.equal(shellOpenPatched.changed, true);
|
||||
assert.equal(
|
||||
shellOpenPatched.value,
|
||||
'"C:\\Users\\Dev\\AppData\\Local\\Programs\\Antigravity\\Antigravity.exe" --remote-debugging-port=0 -- "%1"',
|
||||
'Inserts flag before -- "%1" so Chromium parses it as a switch'
|
||||
);
|
||||
const shellOpenRollback = patchWindowsShellOpenCommand(shellOpenPatched.value, { enabled: false });
|
||||
assert.equal(shellOpenRollback.changed, true);
|
||||
assert.equal(
|
||||
shellOpenRollback.value,
|
||||
'"C:\\Users\\Dev\\AppData\\Local\\Programs\\Antigravity\\Antigravity.exe" -- "%1"'
|
||||
);
|
||||
assert.equal(
|
||||
patchWindowsShellOpenCommand(
|
||||
'"C:\\Users\\Dev\\AppData\\Local\\Programs\\Antigravity IDE\\Antigravity IDE.exe" "--open-url" "--" "%1"',
|
||||
{ enabled: true }
|
||||
).matched,
|
||||
false
|
||||
);
|
||||
|
||||
// Zero-subprocess binary .lnk inspection & non-recursive folder boundary verification
|
||||
const makeFakeLnkBuf = (targetPath, argsStr = '') =>
|
||||
Buffer.concat([
|
||||
Buffer.alloc(76, 0x4c),
|
||||
Buffer.from(`${targetPath}\0${argsStr}\0`, 'utf16le'),
|
||||
]);
|
||||
assert.deepEqual(
|
||||
inspectWindowsLnkBuffer(
|
||||
makeFakeLnkBuf('C:\\App\\Antigravity.exe', '--remote-debugging-port=0')
|
||||
),
|
||||
{ matched: true, hasDebugPort: true }
|
||||
);
|
||||
assert.deepEqual(
|
||||
inspectWindowsLnkBuffer(makeFakeLnkBuf('C:\\App\\Antigravity IDE.exe', '')),
|
||||
{ matched: false, hasDebugPort: false }
|
||||
);
|
||||
|
||||
const visitedDirs = [];
|
||||
const fakeDesktopDir = 'C:\\Users\\Dev\\Desktop';
|
||||
const fakeProgramsDir = 'C:\\Users\\Dev\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs';
|
||||
const fakeAgySubDir = `${fakeProgramsDir}\\Antigravity`;
|
||||
const fastProbeRes = probeWindowsShortcutsFast({
|
||||
env: {
|
||||
USERPROFILE: 'C:\\Users\\Dev',
|
||||
APPDATA: 'C:\\Users\\Dev\\AppData\\Roaming',
|
||||
PUBLIC: 'C:\\Users\\Public',
|
||||
ProgramData: 'C:\\ProgramData',
|
||||
},
|
||||
homeDir: 'C:\\Users\\Dev',
|
||||
fsOps: {
|
||||
readdirFn: (dir) => {
|
||||
visitedDirs.push(dir);
|
||||
if (dir === fakeDesktopDir) {
|
||||
return [
|
||||
{ name: 'Antigravity.lnk', isFile: () => true, isDirectory: () => false },
|
||||
{ name: 'huge-repo-with-node_modules', isFile: () => false, isDirectory: () => true },
|
||||
];
|
||||
}
|
||||
if (dir === fakeProgramsDir) {
|
||||
return [
|
||||
{ name: 'Visual Studio 2022', isFile: () => false, isDirectory: () => true },
|
||||
{ name: 'Antigravity', isFile: () => false, isDirectory: () => true },
|
||||
];
|
||||
}
|
||||
if (dir === fakeAgySubDir) {
|
||||
return [{ name: 'Antigravity IDE.lnk', isFile: () => true, isDirectory: () => false }];
|
||||
}
|
||||
return [];
|
||||
},
|
||||
statFn: () => ({ size: 512 }),
|
||||
readFn: (p) =>
|
||||
p.endsWith('Antigravity IDE.lnk')
|
||||
? makeFakeLnkBuf('C:\\App\\Antigravity IDE.exe', '')
|
||||
: makeFakeLnkBuf('C:\\App\\Antigravity.exe', '--remote-debugging-port=0'),
|
||||
},
|
||||
});
|
||||
assert.equal(fastProbeRes.allConfigured, true);
|
||||
assert.equal(
|
||||
visitedDirs.some((d) => d.includes('huge-repo') || d.includes('Visual Studio')),
|
||||
false,
|
||||
'Never recurses into Desktop subfolders or unrelated Start Menu vendor folders'
|
||||
);
|
||||
|
||||
const linuxDesktopRaw = [
|
||||
'[Desktop Entry]',
|
||||
'Name=Antigravity',
|
||||
@@ -4924,6 +5029,43 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
assert.equal(linuxReverted.changed, true);
|
||||
assert.equal(linuxReverted.text, linuxDesktopRaw);
|
||||
|
||||
const linuxAppImageRaw = [
|
||||
'[Desktop Entry]',
|
||||
'Name=Antigravity',
|
||||
'Exec=env DESKTOPINTEGRATION=false "/home/alice/Apps/Antigravity-2.33.0-x86_64.AppImage" %U',
|
||||
'Type=Application',
|
||||
'',
|
||||
].join('\n');
|
||||
const linuxAppImagePatched = patchLinuxDesktopEntryText(linuxAppImageRaw, { enabled: true });
|
||||
assert.equal(linuxAppImagePatched.matched, true);
|
||||
assert.equal(linuxAppImagePatched.changed, true);
|
||||
assert.match(
|
||||
linuxAppImagePatched.text,
|
||||
/Exec=env DESKTOPINTEGRATION=false "\/home\/alice\/Apps\/Antigravity-2\.33\.0-x86_64\.AppImage" --remote-debugging-port=0 %U/
|
||||
);
|
||||
assert.equal(
|
||||
patchLinuxDesktopEntryText(linuxAppImagePatched.text, { enabled: false }).text,
|
||||
linuxAppImageRaw
|
||||
);
|
||||
assert.equal(
|
||||
patchLinuxDesktopEntryText('Exec=env FOO=1 /opt/antigravity-ide/antigravity-ide %F', {
|
||||
enabled: true,
|
||||
}).matched,
|
||||
false
|
||||
);
|
||||
|
||||
const resolvedLinuxAppImage = resolveDesktopHostExecutable({
|
||||
env: {
|
||||
APPIMAGE: '/home/alice/Apps/Antigravity-2.33.0.AppImage',
|
||||
ANTIGRAVITY_AGENTAPI_EXE: '/tmp/.mount_Antigr123/resources/bin/language_server_linux_x64',
|
||||
},
|
||||
platform: 'linux',
|
||||
homeDir: '/home/alice',
|
||||
existsFn: (p) => p === '/home/alice/Apps/Antigravity-2.33.0.AppImage',
|
||||
});
|
||||
assert.equal(resolvedLinuxAppImage.found, true);
|
||||
assert.equal(resolvedLinuxAppImage.executablePath, '/home/alice/Apps/Antigravity-2.33.0.AppImage');
|
||||
|
||||
// 3. Host executable resolution from ANTIGRAVITY_AGENTAPI_EXE & clean relaunch env sanitization
|
||||
const resolvedWinHost = resolveDesktopHostExecutable({
|
||||
env: {
|
||||
@@ -5038,8 +5180,9 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
/--remote-debugging-port=0 %U/
|
||||
);
|
||||
|
||||
// Verify Windows shortcut auto-provisioning + stale port (`cdp_unreachable`) status reporting + clean rollback on disable
|
||||
// Verify Windows shortcut auto-provisioning + read-only public shortcut tracking + periodic recheck + clean rollback
|
||||
const winPsCalls = [];
|
||||
let simulateReadOnlyPublicDesktop = false;
|
||||
const mockWinExec = async (file, args, opts) => {
|
||||
winPsCalls.push({ file, args, env: opts?.env });
|
||||
const enabledFlag = opts?.env?.AGY_LAUNCH_ENABLED === '1';
|
||||
@@ -5051,6 +5194,10 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
configuredPaths: enabledFlag
|
||||
? ['C:\\Users\\Admin\\Desktop\\Antigravity.lnk', 'C:\\TaskBar\\Antigravity.lnk']
|
||||
: [],
|
||||
readOnlyPaths:
|
||||
enabledFlag && simulateReadOnlyPublicDesktop
|
||||
? ['C:\\Users\\Public\\Desktop\\Antigravity.lnk']
|
||||
: [],
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5069,6 +5216,7 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
homeDir,
|
||||
leaseFilePath: leaseFile,
|
||||
autoConfigureIdeArgv: true,
|
||||
launcherRecheckIntervalMs: 25,
|
||||
launcherExecFileFn: mockWinExec,
|
||||
allowDesktopLauncherInTest: true,
|
||||
});
|
||||
@@ -5079,10 +5227,18 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
assert.equal(stWin.state, 'cdp_unreachable');
|
||||
assert.equal(stWin.argvUpdatedThisBoot, true);
|
||||
assert.equal(stWin.launcherConfigured, true);
|
||||
assert.equal(stWin.hasReadOnlyShortcuts, false);
|
||||
assert.equal(stWin.canRelaunch, true);
|
||||
assert.equal(winPsCalls.length, 1);
|
||||
assert.equal(winPsCalls[0].env.AGY_LAUNCH_ENABLED, '1');
|
||||
|
||||
// Periodic re-check after cooldown detects NSIS installer-wiped or read-only public shortcuts
|
||||
simulateReadOnlyPublicDesktop = true;
|
||||
await new Promise((r) => setTimeout(r, 35));
|
||||
await ctrlWin.syncAllWindows();
|
||||
assert.equal(winPsCalls.length, 2, 'Re-provisions automatically once cooldown interval elapses');
|
||||
assert.equal(ctrlWin.getBridgeStatus().hasReadOnlyShortcuts, true);
|
||||
|
||||
// Disabling overlay (Sidebar Only) cleanly triggers shortcut flag rollback
|
||||
currentMountSettings = {
|
||||
windowMountMode: 'sidebar',
|
||||
@@ -5091,8 +5247,9 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
};
|
||||
await ctrlWin.notifySettingChanged(false);
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
assert.equal(winPsCalls.length, 2);
|
||||
assert.equal(winPsCalls[1].env.AGY_LAUNCH_ENABLED, '0');
|
||||
assert.equal(winPsCalls.length, 3);
|
||||
assert.equal(winPsCalls[2].env.AGY_LAUNCH_ENABLED, '0');
|
||||
assert.equal(ctrlWin.getBridgeStatus().hasReadOnlyShortcuts, false);
|
||||
await ctrlWin.stop();
|
||||
|
||||
// Verify Windows out-of-job Shell.Application relaunch payload (.ps1 file with UTF-8 BOM) & macOS open -a relaunch
|
||||
@@ -5159,10 +5316,35 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
assert.equal(macSpawnArgs.env.AGY_RELAUNCH_APP, '/Applications/Antigravity.app');
|
||||
assert.match(macSpawnArgs.args[1], /open -a "\$AGY_RELAUNCH_APP" --args --remote-debugging-port=0/);
|
||||
|
||||
// Explicit ANTIGRAVITY_DEVTOOLS_PORT fallback still works seamlessly
|
||||
const innerScriptCheck = buildWindowsRelaunchInnerScript(fakeExe, [stalePortFile], 'desktop');
|
||||
// Verify Linux /proc dynamic AppImage discovery & multi-comm pkill handling
|
||||
let linuxSpawnArgs = null;
|
||||
const relaunchLinuxRes = await triggerDesktopHostRelaunch({
|
||||
env: { PATH: '/usr/bin:/bin' },
|
||||
platform: 'linux',
|
||||
homeDir: '/home/alice',
|
||||
stalePortFiles: ['/home/alice/.config/Antigravity/DevToolsActivePort'],
|
||||
allowInTest: true,
|
||||
existsFn: () => false,
|
||||
execFileFn: async () => '/home/alice/Apps/Antigravity-2.33.0.AppImage\n',
|
||||
spawnFn: async (file, args, opts) => {
|
||||
linuxSpawnArgs = { file, args, env: opts?.env };
|
||||
return { pid: 5678 };
|
||||
},
|
||||
});
|
||||
assert.equal(relaunchLinuxRes.ok, true);
|
||||
assert.equal(linuxSpawnArgs.env.AGY_RELAUNCH_EXE, '/home/alice/Apps/Antigravity-2.33.0.AppImage');
|
||||
assert.match(linuxSpawnArgs.args[1], /for pn in "\$AGY_PROC_NAME" antigravity Antigravity/);
|
||||
|
||||
// Explicit ANTIGRAVITY_DEVTOOLS_PORT fallback & UAC read-only shortcut + de-elevation script generation
|
||||
const innerScriptCheck = buildWindowsRelaunchInnerScript(fakeExe, [stalePortFile], 'desktop', {
|
||||
readOnlyShortcutPaths: ['C:\\Users\\Public\\Desktop\\Antigravity.lnk'],
|
||||
psExePath: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
|
||||
});
|
||||
assert.match(innerScriptCheck, /CloseMainWindow/);
|
||||
assert.match(innerScriptCheck, /Stop-Process/);
|
||||
assert.match(innerScriptCheck, /-Verb RunAs/);
|
||||
assert.match(innerScriptCheck, /C:\\Users\\Public\\Desktop\\Antigravity\.lnk/);
|
||||
assert.match(innerScriptCheck, /\$isSelfElevated -and -not \$wasHostElevated/);
|
||||
} finally {
|
||||
fs.rmSync(simTmp, { recursive: true, force: true });
|
||||
}
|
||||
@@ -5251,7 +5433,23 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
);
|
||||
assert.match(strTab.refs.mountBridgeNotice.refs.relaunchBtnEl.textContent, /正在重启客户端/);
|
||||
|
||||
// macOS unconfigured state -> `.is-warn` with 1-click relaunch + copy button
|
||||
// All-Users read-only Public Desktop shortcut -> `.is-warn` + UAC authorization button copy
|
||||
strTab.refs.renderSettings(
|
||||
{ windowMountMode: 'dual', enableWindowOverlay: true },
|
||||
{
|
||||
state: 'no_devtools_port',
|
||||
argvUpdatedThisBoot: true,
|
||||
argvConfigured: true,
|
||||
launcherConfigured: true,
|
||||
hasReadOnlyShortcuts: true,
|
||||
canRelaunch: true,
|
||||
},
|
||||
'win32'
|
||||
);
|
||||
assert.equal(noticeEl.classList.contains('is-warn'), true);
|
||||
assert.match(noticeEl.textContent, /公共桌面快捷方式受权限保护/);
|
||||
|
||||
// macOS Desktop -> honest code-signing notice with `.is-restart` + 1-click relaunch + copy button
|
||||
strTab.refs.renderSettings(
|
||||
{ windowMountMode: 'dual', enableWindowOverlay: true },
|
||||
{
|
||||
@@ -5259,12 +5457,13 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
argvUpdatedThisBoot: false,
|
||||
argvConfigured: false,
|
||||
launcherConfigured: false,
|
||||
hasReadOnlyShortcuts: false,
|
||||
canRelaunch: true,
|
||||
},
|
||||
'darwin'
|
||||
);
|
||||
assert.equal(noticeEl.classList.contains('is-warn'), true);
|
||||
assert.match(noticeEl.textContent, /open -a "Antigravity" --args --remote-debugging-port=0/);
|
||||
assert.equal(noticeEl.classList.contains('is-restart'), true);
|
||||
assert.match(noticeEl.textContent, /macOS 应用签名限制/);
|
||||
|
||||
strTab.refs.mountBridgeNotice.refs.copyBtnEl.dispatchEvent({ type: 'click' });
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
@@ -5275,10 +5474,16 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
const globalBanner = BridgeStatusNotice({ dismissible: true });
|
||||
globalBanner.refs.update({
|
||||
visible: true,
|
||||
windowBridge: { state: 'no_devtools_port', launcherConfigured: true, canRelaunch: true },
|
||||
windowBridge: {
|
||||
state: 'no_devtools_port',
|
||||
launcherConfigured: true,
|
||||
hasReadOnlyShortcuts: true,
|
||||
canRelaunch: true,
|
||||
},
|
||||
hostPlatform: 'win32',
|
||||
});
|
||||
assert.equal(globalBanner.el.hasAttribute('hidden'), false);
|
||||
assert.match(globalBanner.refs.relaunchBtnEl.textContent, /授权修补并立即重启/);
|
||||
globalBanner.refs.dismissBtnEl.dispatchEvent({ type: 'click' });
|
||||
assert.equal(globalBanner.el.hasAttribute('hidden'), true);
|
||||
globalBanner.refs.update({
|
||||
@@ -5293,10 +5498,21 @@ test('Issue #26: Antigravity Desktop 2.33.0+ automatic shortcut/launcher provisi
|
||||
});
|
||||
assert.equal(globalBanner.el.hasAttribute('hidden'), false, 'Re-armed after active cycle');
|
||||
|
||||
// English localization check
|
||||
// English localization check across macOS & read-only shortcut states
|
||||
setI18nLanguage('en-US');
|
||||
strTab.refs.refreshLabels();
|
||||
assert.match(noticeEl.textContent, /Local Debug Port Missing/);
|
||||
assert.match(noticeEl.textContent, /Due to macOS app code signing/);
|
||||
globalBanner.refs.update({
|
||||
visible: true,
|
||||
windowBridge: {
|
||||
state: 'no_devtools_port',
|
||||
launcherConfigured: true,
|
||||
hasReadOnlyShortcuts: true,
|
||||
canRelaunch: true,
|
||||
},
|
||||
hostPlatform: 'win32',
|
||||
});
|
||||
assert.match(globalBanner.refs.relaunchBtnEl.textContent, /Authorize & Relaunch/);
|
||||
|
||||
// Switching to Sidebar Only hides notice immediately
|
||||
strTab.refs.renderSettings(
|
||||
|
||||
Reference in New Issue
Block a user