{"record":{"id":"b6fe1f20a59c25c4","repo":"libnyanpasu/clash-nyanpasu","slug":"script-mode-is-only-available-for-clash-premium","errorCode":null,"errorMessage":"Script mode is only available for Clash Premium","messagePattern":"Script mode is only available for Clash Premium","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/interface/src/ipc/use-proxy-mode.ts","lineNumber":55,"sourceCode":"\n    const currentMode = clashConfig.query.data?.mode?.toLowerCase()\n\n    if (\n      currentMode &&\n      Object.prototype.hasOwnProperty.call(modes, currentMode)\n    ) {\n      modes[currentMode as keyof typeof modes] = true\n    } else {\n      modes.rule = true\n    }\n\n    return modes\n  }, [clashConfig.query.data, clashCore.value])\n\n  const upsert = async (mode: ProxyMode) => {\n    // only clash premium support script mode\n    if (clashCore.value !== 'clash' && mode === 'script') {\n      throw new Error('Script mode is only available for Clash Premium')\n    }\n\n    await clashConfig.upsert.mutateAsync({ mode })\n  }\n\n  return {\n    value,\n    upsert,\n  }\n}\n","sourceCodeStart":37,"sourceCodeEnd":66,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/frontend/interface/src/ipc/use-proxy-mode.ts#L37-L66","documentation":"The proxy-mode upsert in use-proxy-mode.ts rejects 'script' mode unless the active clash core is 'clash' (Clash Premium). Script mode is a Premium-only feature, so any other core (mihomo, clash-rs, etc.) cannot process it and the client fails fast with this explicit error instead of sending an invalid config.","triggerScenarios":"Calling upsert('script') while clashCore.value is anything other than 'clash', e.g. after switching the core to mihomo or clash-rs and then selecting script mode in the UI or via the mutation.","commonSituations":"Users switch from Clash Premium to mihomo/clash-meta while a script mode was in use, or attempt to enable script mode on an open-source core that lacks the script engine.","solutions":["Switch the clash core to Clash Premium ('clash') before enabling script mode","Choose a non-script proxy mode (rule/global) compatible with the current core","Guard the UI so script mode is only selectable when the core is 'clash'"],"exampleFix":"// before\nawait upsert('script')\n// after\nif (clashCore.value === 'clash') {\n  await upsert('script')\n} else {\n  await upsert('rule')\n}","handlingStrategy":"validation","validationCode":"if (clashCore.value !== 'clash' && mode === 'script') {\n  throw new Error('Switch to Clash Premium to use script mode')\n}","typeGuard":"const canUseScriptMode = (core: string): core is 'clash' => core === 'clash'","tryCatchPattern":"try {\n  await upsert(mode)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Script mode')) {\n    showToast('Script mode requires Clash Premium')\n  }\n}","preventionTips":["Disable the script-mode option in the UI when the active core is not 'clash'","Check clashCore.value before any upsert call","Sync mode choice with core switches"],"tags":["proxy-mode","unsupported-feature","clash"],"backgroundTag":"unsupported-operation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}