lbjlaq/Antigravity-Manager · error · Error
Command [${cmd}] not supported in Web mode.
Error message
Command [${cmd}] not supported in Web mode. What it means
request() in src/utils/request.ts:184 throws this when running in a browser (no window.__TAURI_INTERNALS__/__TAURI__, detected at request.ts:2) and the command name is not a key of COMMAND_MAPPING. In Web mode every Tauri `invoke(cmd)` is translated to an HTTP call against a mapping entry (request.ts:5-166); an unmapped command has no HTTP route, so the adapter deliberately fails fast instead of guessing. It is a development/deployment-gap error: the backend Tauri command exists but nobody added its web-mode HTTP equivalent.
Source
Thrown at src/utils/request.ts:184
};
export async function request<T>(cmd: string, args?: any): Promise<T> {
// 1. Tauri 环境:直接使用 invoke ...
if (isTauri) {
try {
const { invoke } = await import('@tauri-apps/api/core');
return await invoke<T>(cmd, args);
} catch (error) {
console.error(`Tauri Invoke Error [${cmd}]:`, error);
throw error;
}
}
// 2. Web 环境:映射到 HTTP API
const mapping = COMMAND_MAPPING[cmd];
if (!mapping) {
console.error(`Command [${cmd}] is not yet mapped for Web mode. Failing.`);
throw new Error(`Command [${cmd}] not supported in Web mode.`);
}
let url = mapping.url;
// [FIX] 创建 args 副本,用于移除已使用的路径参数
let bodyArgs = args ? { ...args } : undefined;
// 通用路径参数处理:替换 :key 为 args[key]
if (args) {
Object.keys(args).forEach(key => {
const placeholder = `:${key}`;
if (url.includes(placeholder)) {
url = url.replace(placeholder, encodeURIComponent(String(args[key])));
// [FIX] 从 body 参数中移除已用于路径的参数
if (bodyArgs) {
delete bodyArgs[key];
}
}
});View on GitHub (pinned to a2e3c45423)
Solutions
- Add an entry to COMMAND_MAPPING in src/utils/request.ts pointing at the backend HTTP route, e.g. 'query_transit_info': { url: '/api/transit/query', method: 'POST' }, and implement that route in the web server.
- If the command genuinely cannot work in a browser (needs OS access), gate the UI: hide the feature in web mode instead of letting request() throw.
- Check for a command-name typo by diffing the invoke() call site against the COMMAND_MAPPING keys.
- As a last resort for the specific page, run the app in the Tauri desktop shell where the native invoke path (request.ts:170-178) is used.
Example fix
// before
const rawText = await request<string>('query_transit_info', { url, key });
// → Error: Command [query_transit_info] not supported in Web mode.
// after: src/utils/request.ts — add the mapping
const COMMAND_MAPPING = {
// ...
'query_transit_info': { url: '/api/transit/query', method: 'POST' },
}; Defensive patterns
Strategy: validation
Validate before calling
// request.ts — expose a support check
export const isTauriRuntime = () => !!(window as any).__TAURI_INTERNALS__ || !!(window as any).__TAURI__;
export function isCommandSupportedInWeb(cmd: string): boolean {
return Object.prototype.hasOwnProperty.call(COMMAND_MAPPING, cmd);
}
// caller — gate before invoking
if (!isTauriRuntime() && !isCommandSupportedInWeb('query_transit_info')) {
throw new Error('This feature requires the desktop app');
} Type guard
// request.ts export type WebCommand = keyof typeof COMMAND_MAPPING; export const isWebCommand = (cmd: string): cmd is WebCommand => cmd in COMMAND_MAPPING;
Try / catch
try {
return await request('query_transit_info', { url, key });
} catch (e) {
if (e instanceof Error && e.message.endsWith('not supported in Web mode.')) {
// deployment gap, not transient: disable the feature, do not retry
setFeatureUnavailable(true);
return null;
}
throw e;
} Prevention
- Treat COMMAND_MAPPING as the contract: any PR that adds an invoke('<new_cmd>') call must add the mapping entry (and HTTP route) in the same change.
- Type command names as a union of known commands (keyof typeof COMMAND_MAPPING in web-capable code) so unmapped names fail at compile time.
- Add a startup check comparing invoked command names against COMMAND_MAPPING keys in web builds to catch gaps before users do.
- Never rely on the browser build for OS-level commands; gate such UI behind isTauriRuntime().
When it happens
Trigger: Calling invoke('query_transit_info', ...) (used by src/pages/ApiKeyFun.tsx:129/151/180/188 — not present in COMMAND_MAPPING), or any newly added backend command, while the app is served as a plain website. Also triggered by typos in command names, e.g. invoke('get_proxy_stat') vs 'get_proxy_stats'.
Common situations: A feature is developed and tested in the Tauri desktop shell (where invoke works natively) and later deployed to the web build; a new Tauri command is wired into the frontend without a matching REST endpoint/mapping entry in the same change; renaming a Rust command without updating COMMAND_MAPPING keys.
Related errors
AI-assisted analysis of lbjlaq/Antigravity-Manager@a2e3c45423 (2026-08-16).
Data as JSON: /api/errors/68ae1430f679c39b.
Report an issue: GitHub.