{"record":{"id":"68ae1430f679c39b","repo":"lbjlaq/Antigravity-Manager","slug":"command-cmd-not-supported-in-web-mode","errorCode":null,"errorMessage":"Command [${cmd}] not supported in Web mode.","messagePattern":"Command \\[(.+?)\\] not supported in Web mode\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/request.ts","lineNumber":188,"sourceCode":"};\n\nexport async function request<T>(cmd: string, args?: any): Promise<T> {\n  // 1. Tauri 环境：直接使用 invoke ...\n  if (isTauri) {\n    try {\n      const { invoke } = await import('@tauri-apps/api/core');\n      return await invoke<T>(cmd, args);\n    } catch (error) {\n      console.error(`Tauri Invoke Error [${cmd}]:`, error);\n      throw error;\n    }\n  }\n\n  // 2. Web 环境：映射到 HTTP API\n  const mapping = COMMAND_MAPPING[cmd];\n  if (!mapping) {\n    console.error(`Command [${cmd}] is not yet mapped for Web mode. Failing.`);\n    throw new Error(`Command [${cmd}] not supported in Web mode.`);\n  }\n\n  let url = mapping.url;\n  // [FIX] 创建 args 副本，用于移除已使用的路径参数\n  let bodyArgs = args ? { ...args } : undefined;\n\n  // 通用路径参数处理：替换 :key 为 args[key]\n  if (args) {\n    Object.keys(args).forEach(key => {\n      const placeholder = `:${key}`;\n      if (url.includes(placeholder)) {\n        url = url.replace(placeholder, encodeURIComponent(String(args[key])));\n        // [FIX] 从 body 参数中移除已用于路径的参数\n        if (bodyArgs) {\n          delete bodyArgs[key];\n        }\n      }\n    });","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/lbjlaq/Antigravity-Manager/blob/90a2b6b20797e2e593a83d0c54ab86037863fe70/src/utils/request.ts#L170-L206","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the command to COMMAND_MAPPING with its HTTP url/method in src/utils/request.ts","Hide or disable the feature in web mode (capability check) so the unmapped command is never invoked","Ensure the command name passed to request() matches the mapping key exactly (case/typos)"],"exampleFix":"// before\nconst COMMAND_MAPPING = {\n  list_accounts: { url: '/api/accounts' }\n};\n// after\nconst COMMAND_MAPPING = {\n  list_accounts: { url: '/api/accounts' },\n  sync_opencode: { url: '/api/opencode/sync', method: 'POST' }\n};","handlingStrategy":"fallback","validationCode":"const supported = (cmd: string) => cmd in COMMAND_MAPPING;","typeGuard":"null","tryCatchPattern":"try { await request(cmd, args); } catch (e) { if (String(e.message).includes('not supported in Web mode')) { showToast(t('errors.webUnsupported')); return; } throw e; }","preventionTips":["Keep a capability list and disable unmapped commands in web UI","Add a unit test iterating COMMAND_MAPPING vs all invoked command strings","Type command names with a union type so typos fail at compile time"],"tags":["web-mode","command-mapping","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"90a2b6b20797e2e593a83d0c54ab86037863fe70","analyzedAt":"2026-09-19T08:34:01.322Z","contentChangedAt":"2026-09-19T08:34:01.322Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}