lbjlaq/Antigravity-Manager · error · Error

Command [ ] not supported in Web mode.

Error message

Command [${cmd}] not supported in Web mode.

What it means

request() maps Tauri commands to HTTP endpoints when running in Web mode via COMMAND_MAPPING. If a command has no mapping entry, it throws this error because the backend capability simply has no web equivalent yet.

Solutions

  1. Add the command to COMMAND_MAPPING with its HTTP url/method in src/utils/request.ts
  2. Hide or disable the feature in web mode (capability check) so the unmapped command is never invoked
  3. Ensure the command name passed to request() matches the mapping key exactly (case/typos)

Example fix

// before
const COMMAND_MAPPING = {
  list_accounts: { url: '/api/accounts' }
};
// after
const COMMAND_MAPPING = {
  list_accounts: { url: '/api/accounts' },
  sync_opencode: { url: '/api/opencode/sync', method: 'POST' }
};
Defensive patterns

Strategy: fallback

Validate before calling

const supported = (cmd: string) => cmd in COMMAND_MAPPING;

Type guard

null

Try / catch

try { await request(cmd, args); } catch (e) { if (String(e.message).includes('not supported in Web mode')) { showToast(t('errors.webUnsupported')); return; } throw e; }

Prevention

When it happens

Trigger: Invoking a Tauri command (from useDebugConsole, handleBind, useProxyModels, handleSyncCli, handleSyncOpenCode) whose cmd key is absent from COMMAND_MAPPING while the app runs in web (browser) mode.

Common situations: A new Tauri command was added without adding its web HTTP mapping; user opens the web build and clicks a feature that only exists in the desktop app; typo in the command string.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.


AI-assisted analysis of lbjlaq/Antigravity-Manager@90a2b6b207 (2026-09-19). Data as JSON: /api/errors/68ae1430f679c39b. Report an issue: GitHub.

Appendix: source

Thrown at src/utils/request.ts:188

};

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 90a2b6b207)