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
- Check the logged error to distinguish 'not installed/no account' from a real read failure.
- Verify `platformConfig.currentAccountIdKey` is defined for the active platformId before calling.
- Ensure Trae is installed and its config directory is readable at the expected path.
- 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
- Verify platformConfig.currentAccountIdKey exists for the platform before loading
- Distinguish real failures from 'no account' in the UI state
- Log the error details to detect Trae install/config format changes
- Re-run the load when the platformId changes (already done via useCallback deps)
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
- Trae OAuth start 响应缺少关键字段
- [WorkbuddyAutoCheckin] 从 Rust 端获取配置失败,使用本地缓存或默认值:
- [AntigravityInstalledVersionBadge] failed to load installed
- Tauri save failed, falling back to web download
- Codex 导入失败 {}: {}
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/3f97e650eb607474.
Report an issue: GitHub.