fix(usage): prevent usage script config from leaking between providers

Add key prop to UsageScriptModal to ensure component remounts when
switching between different providers. This fixes issue #569 where
configuring usage query for one provider would incorrectly apply
the same configuration to all providers.

The root cause was that useState initialization only runs on first
mount, and due to useLastValidValue hook keeping the modal rendered
during close animation, the component might not fully unmount when
switching providers rapidly.

Closes #569
This commit is contained in:
Jason
2026-01-10 11:05:18 +08:00
parent 83db457b10
commit 95ed6d6903
2 changed files with 2 additions and 1 deletions

2
src-tauri/Cargo.lock generated
View File

@@ -701,7 +701,7 @@ dependencies = [
[[package]]
name = "cc-switch"
version = "3.9.0"
version = "3.9.1"
dependencies = [
"anyhow",
"async-stream",

View File

@@ -806,6 +806,7 @@ function App() {
{effectiveUsageProvider && (
<UsageScriptModal
key={effectiveUsageProvider.id}
provider={effectiveUsageProvider}
appId={activeApp}
isOpen={Boolean(usageProvider)}