Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(TokenUsage): prevent animation when toggling between token and credit display (#10098)

Arvin Xuf20a9108ed86
diff --git a/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx b/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx
index b5231df5ae9..dc7453e88dc 100644
--- a/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx
+++ b/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx
@@ -217,6 +217,9 @@ const TokenDetail = memo<TokenDetailProps>(({ meta, model, provider }) => {
<Icon icon={isShowCredit ? BadgeCent : CoinsIcon} />
<AnimatedNumber
formatter={(value) => (formatShortenNumber(value) as string).toLowerCase?.()}
+ // Force remount when switching between token/credit to prevent unwanted animation
+ // See: https://github.com/lobehub/lobe-chat/pull/10098
+ key={isShowCredit ? 'credit' : 'token'}
value={totalCount}
/>
</Center>