{"record":{"id":"0dbbce90956cea00","repo":"jlcodes99/cockpit-tools","slug":"common-shared-instances-unsupported-title","errorCode":"common.shared.instances.unsupported.title","errorMessage":"暂不支持当前系统","messagePattern":"暂不支持当前系统","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pages/FloatingCardWindow.tsx","lineNumber":1264,"sourceCode":"\n    const timerId = window.setInterval(() => {\n      void refreshDisplayedAccount({ silent: true });\n    }, 60_000);\n\n    return () => {\n      window.clearInterval(timerId);\n    };\n  }, [refreshDisplayedAccount, viewedAccount]);\n\n  const handleSwitch = useCallback(async () => {\n    if (!viewedAccount || switchingAccountId || isCurrentViewed) return;\n    setSwitchingAccountId(viewedAccount.id);\n    setErrorText(null);\n    try {\n      if (instanceContext) {\n        const instanceStore = resolveInstanceStoreApi(selectedPlatform);\n        if (!instanceStore) {\n          throw new Error(t('common.shared.instances.unsupported.title', '暂不支持当前系统'));\n        }\n        const instances = await instanceStore.refreshInstances();\n        const targetInstance = findInstanceById(instances, instanceContext.instanceId);\n        const wasRunning = targetInstance?.running === true;\n        if (\n          selectedPlatform === 'grok' &&\n          instanceContext.instanceId !== DEFAULT_INSTANCE_ID &&\n          wasRunning\n        ) {\n          throw new Error(\n            t(\n              'floatingCard.errors.stopInstanceBeforeSwitch',\n              '请先停止实例再切换账号',\n            ),\n          );\n        }\n        await instanceStore.updateInstance({\n          instanceId: instanceContext.instanceId,","sourceCodeStart":1246,"sourceCodeEnd":1282,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/pages/FloatingCardWindow.tsx#L1246-L1282","documentation":"When switching accounts from the FloatingCardWindow, the code resolves a platform instance-store API via resolveInstanceStoreApi(selectedPlatform). If the platform has no instance store support, it throws an Error with the localized message 'common.shared.instances.unsupported.title' ('暂不支持当前系统' — current system not supported) and aborts the switch.","triggerScenarios":"Clicking switch-account in the floating card while selectedPlatform is a platform for which resolveInstanceStoreApi returns null/undefined (no instance-store backend registered for that OS/platform), with an instanceContext present.","commonSituations":"Using the floating card on an OS not supported by that platform's instance management; a platform added to the UI before its instance-store adapter exists; platform detection returning an unexpected value.","solutions":["Switch accounts from a page/flow that does not require per-instance management for this platform.","Add or register an instance-store implementation for the current platform (resolveInstanceStoreApi returning null means none exists).","Verify selectedPlatform is the expected value; a mis-detected platform may fall into the unsupported branch.","Hide or disable the switch-account action for unsupported platform/platform combinations."],"exampleFix":"// before\nconst instanceStore = resolveInstanceStoreApi(selectedPlatform);\nif (!instanceStore) throw new Error(t('common.shared.instances.unsupported.title', '暂不支持当前系统'));\n// after (caller-side guard)\nif (resolveInstanceStoreApi(selectedPlatform)) {\n  await switchAccount(viewedAccount.id);\n} else {\n  showToast(t('common.shared.instances.unsupported.title'));\n}","handlingStrategy":"fallback","validationCode":"const store = resolveInstanceStoreApi(selectedPlatform);\nif (!store) {\n  showToast(t('common.shared.instances.unsupported.title'));\n  return; // fall back to a non-instance flow\n}","typeGuard":"const hasInstanceStore = (p: Platform): p is SupportedPlatform =>\n  resolveInstanceStoreApi(p) != null;","tryCatchPattern":"try {\n  await switchAccount(viewedAccount.id);\n} catch (e) {\n  if (e.message.includes('unsupported')) {\n    showToast(t('common.shared.instances.unsupported.title'));\n    return;\n  }\n  throw e;\n}","preventionTips":["Hide instance-based actions for platforms without an instance store.","Keep resolveInstanceStoreApi coverage in sync with every platform added to the UI.","Verify platform detection on all supported operating systems."],"tags":["platform","unsupported","instances"],"backgroundTag":"unsupported-platform","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}