Skip to content

Commit bc30b7b

Browse files
fix: isolate per-profile token cleanup on sign-out and assert state refresh
Wrap per-profile work in the zoo-gateway sign-out cleanup loop in its own try/catch so one corrupted profile or failed write no longer aborts cleanup of the remaining profiles. Also assert postStateToWebview runs on the handleZooCodeCallback persistence-failure path. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 42b3f0c commit bc30b7b

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,6 +3772,8 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
37723772
expect(mockOutputChannel.appendLine).toHaveBeenCalledWith(
37733773
expect.stringContaining("[handleZooCodeCallback] Failed to save zoo-gateway profile"),
37743774
)
3775+
// State must still be refreshed even when profile persistence fails.
3776+
expect(provider.postStateToWebview).toHaveBeenCalled()
37753777
})
37763778
})
37773779

src/core/webview/webviewMessageHandler.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,14 @@ export const webviewMessageHandler = async (
24572457
const currentApiConfigName = provider.contextProxy.getValues().currentApiConfigName
24582458

24592459
for (const entry of allProfiles) {
2460-
if (entry.apiProvider === "zoo-gateway") {
2460+
if (entry.apiProvider !== "zoo-gateway") {
2461+
continue
2462+
}
2463+
2464+
// Isolate per-profile failures: a corrupted profile or a failed write
2465+
// for one entry must not abort cleanup of the remaining profiles,
2466+
// otherwise sign-out would leave later profiles with a stale token.
2467+
try {
24612468
const profile = await provider.providerSettingsManager.getProfile({ name: entry.name })
24622469
const { zooSessionToken: _removed, ...cleanedProfile } = profile
24632470

@@ -2477,12 +2484,18 @@ export const webviewMessageHandler = async (
24772484
await provider.providerSettingsManager.saveConfig(entry.name, cleanedProfile)
24782485
provider.log(`[zooCodeSignOut] Cleared zooSessionToken from "${entry.name}" profile`)
24792486
}
2487+
} catch (profileError) {
2488+
// Log but continue to the next profile so one failure doesn't
2489+
// leave other profiles holding a stale token.
2490+
provider.log(
2491+
`[zooCodeSignOut] Failed to clear profile token for "${entry.name}": ${profileError instanceof Error ? profileError.message : String(profileError)}`,
2492+
)
24802493
}
24812494
}
24822495
} catch (profileError) {
2483-
// Log but don't fail the sign-out if profile cleanup fails
2496+
// listConfig itself failed — nothing to iterate.
24842497
provider.log(
2485-
`[zooCodeSignOut] Failed to clear profile token: ${profileError instanceof Error ? profileError.message : String(profileError)}`,
2498+
`[zooCodeSignOut] Failed to list profiles for token cleanup: ${profileError instanceof Error ? profileError.message : String(profileError)}`,
24862499
)
24872500
}
24882501

0 commit comments

Comments
 (0)