jlcodes99/cockpit-tools · info

[Trae Accounts] Failed to load target current account:

Error message

[Trae Accounts] Failed to load target current account:

What it means

`loadTargetCurrentAccountId` fetches which Trae account is currently active on the target machine via `traeService.getTraeCurrentAccountId(platformId)`. On failure the warning is logged and the state is reset to null, so the UI treats the target as having no current account — potentially misleading if the failure was an error rather than 'none'.

Source

Thrown at src/pages/TraeAccountsPage.tsx:215

      const normalized = accountId?.trim() || null;
      setTargetCurrentAccountIdState(normalized);
      try {
        if (normalized) {
          localStorage.setItem(platformConfig.currentAccountIdKey, normalized);
        } else {
          localStorage.removeItem(platformConfig.currentAccountIdKey);
        }
      } catch {
        // ignore local cache failures
      }
    },
    [platformConfig.currentAccountIdKey],
  );
  const loadTargetCurrentAccountId = useCallback(async () => {
    try {
      setTargetCurrentAccountId(await traeService.getTraeCurrentAccountId(platformId));
    } catch (error) {
      console.warn('[Trae Accounts] Failed to load target current account:', error);
      setTargetCurrentAccountId(null);
    }
  }, [platformId, setTargetCurrentAccountId]);

  useEffect(() => {
    void loadTargetCurrentAccountId();
  }, [loadTargetCurrentAccountId, platformAccounts.length]);

  const pageStore = useMemo(
    () => ({
      accounts: platformAccounts,
      currentAccountId: targetCurrentAccountId,
      loading: store.loading,
      error: store.error,
      fetchAccounts: store.fetchAccounts,
      fetchCurrentAccountId: () => traeService.getTraeCurrentAccountId(platformId),
      deleteAccounts: store.deleteAccounts,
      refreshToken: store.refreshToken,

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Check the logged error to distinguish 'not installed/no account' from a real read failure.
  2. Verify `platformConfig.currentAccountIdKey` is defined for the active platformId before calling.
  3. Ensure Trae is installed and its config directory is readable at the expected path.
  4. Distinguish error-vs-empty in the UI instead of always falling back to null.
Defensive patterns

Strategy: fallback

Validate before calling

if (!platformConfig?.currentAccountIdKey) return; // platform not configured; skip load

Type guard

function isAccountId(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0;
}

Try / catch

try {
  const id = await traeService.getTraeCurrentAccountId(platformId);
  setTargetCurrentAccountId(isAccountId(id) ? id : null);
} catch (error) {
  console.warn('[Trae Accounts] Failed to load target current account:', error);
  setTargetCurrentAccountId(null);
}

Prevention

When it happens

Trigger: The service call rejects: Trae not installed on the target, its account storage unreadable, the platformId has no configured key (`platformConfig.currentAccountIdKey` missing/invalid), or a backend IPC error.

Common situations: Trae installed in a non-default location; account store format changed in a Trae update; wrong platformId passed in; target machine lacks the config file on fresh setups.

Related errors


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