fix: address review feedback and code scanning alerts

This commit is contained in:
Cita
2026-03-22 23:41:45 +08:00
parent 32d7037629
commit 5d78658af9
38 changed files with 929 additions and 344 deletions
+33 -5
View File
@@ -228,11 +228,39 @@ async function executeAccountTokenSync(row: AccountWithSiteRow): Promise<SyncExe
if (!row.accounts.accessToken) {
if (row.accounts.apiToken) {
await convergeAccountMutation({
accountId,
preferredApiToken: row.accounts.apiToken,
defaultTokenSource: 'legacy',
});
try {
const convergence = await convergeAccountMutation({
accountId,
preferredApiToken: row.accounts.apiToken,
defaultTokenSource: 'legacy',
rebuildRoutes: true,
});
if (convergence.defaultTokenId != null) {
return {
...base,
status: 'synced',
reason: 'legacy_default_token_restored',
message: 'restored local default token from legacy api token',
synced: true,
created: 0,
updated: 0,
total: 0,
defaultTokenId: convergence.defaultTokenId,
};
}
} catch (error: any) {
return {
...base,
status: 'failed',
reason: 'sync_error',
message: error?.message || 'sync failed',
synced: false,
created: 0,
updated: 0,
total: 0,
defaultTokenId: null,
};
}
}
return {
...base,
@@ -242,12 +242,12 @@ function detectProtocolClientApp(input: {
};
case 'codex': {
const clientApp = detectCodexOfficialClientAppViaProfile(input.headers);
return (clientApp
return clientApp
? {
...clientApp,
clientConfidence: 'exact' as const,
}
: null) || {
: {
clientAppId: 'codex',
clientAppName: 'Codex',
clientConfidence: 'heuristic',