jlcodes99/cockpit-tools · error

common.shared.instances.unsupported.title

common.shared.instances.unsupported.title

Error message

暂不支持当前系统

What it means

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.

Source

Thrown at src/pages/FloatingCardWindow.tsx:1264

    const timerId = window.setInterval(() => {
      void refreshDisplayedAccount({ silent: true });
    }, 60_000);

    return () => {
      window.clearInterval(timerId);
    };
  }, [refreshDisplayedAccount, viewedAccount]);

  const handleSwitch = useCallback(async () => {
    if (!viewedAccount || switchingAccountId || isCurrentViewed) return;
    setSwitchingAccountId(viewedAccount.id);
    setErrorText(null);
    try {
      if (instanceContext) {
        const instanceStore = resolveInstanceStoreApi(selectedPlatform);
        if (!instanceStore) {
          throw new Error(t('common.shared.instances.unsupported.title', '暂不支持当前系统'));
        }
        const instances = await instanceStore.refreshInstances();
        const targetInstance = findInstanceById(instances, instanceContext.instanceId);
        const wasRunning = targetInstance?.running === true;
        if (
          selectedPlatform === 'grok' &&
          instanceContext.instanceId !== DEFAULT_INSTANCE_ID &&
          wasRunning
        ) {
          throw new Error(
            t(
              'floatingCard.errors.stopInstanceBeforeSwitch',
              '请先停止实例再切换账号',
            ),
          );
        }
        await instanceStore.updateInstance({
          instanceId: instanceContext.instanceId,

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Switch accounts from a page/flow that does not require per-instance management for this platform.
  2. Add or register an instance-store implementation for the current platform (resolveInstanceStoreApi returning null means none exists).
  3. Verify selectedPlatform is the expected value; a mis-detected platform may fall into the unsupported branch.
  4. Hide or disable the switch-account action for unsupported platform/platform combinations.

Example fix

// before
const instanceStore = resolveInstanceStoreApi(selectedPlatform);
if (!instanceStore) throw new Error(t('common.shared.instances.unsupported.title', '暂不支持当前系统'));
// after (caller-side guard)
if (resolveInstanceStoreApi(selectedPlatform)) {
  await switchAccount(viewedAccount.id);
} else {
  showToast(t('common.shared.instances.unsupported.title'));
}
Defensive patterns

Strategy: fallback

Validate before calling

const store = resolveInstanceStoreApi(selectedPlatform);
if (!store) {
  showToast(t('common.shared.instances.unsupported.title'));
  return; // fall back to a non-instance flow
}

Type guard

const hasInstanceStore = (p: Platform): p is SupportedPlatform =>
  resolveInstanceStoreApi(p) != null;

Try / catch

try {
  await switchAccount(viewedAccount.id);
} catch (e) {
  if (e.message.includes('unsupported')) {
    showToast(t('common.shared.instances.unsupported.title'));
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/0dbbce90956cea00. Report an issue: GitHub.