Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): allow token rate popover toggle close (#4786)

Dash5aa0b9bd113f
diff --git a/apps/desktop/src/renderer/__tests__/runningTokenRatePopover.test.tsx b/apps/desktop/src/renderer/__tests__/runningTokenRatePopover.test.tsx
index 9a1652e79d..c42a1bb270 100644
--- a/apps/desktop/src/renderer/__tests__/runningTokenRatePopover.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/runningTokenRatePopover.test.tsx
@@ -218,7 +218,7 @@ it('keeps the pinned card across turns while awaiting a fresh rate', async () =>
expect(nextLine?.match(/[ML]/g)).toHaveLength(3);
});
-it('keeps a clicked panel open through outside clicks, focus changes and repeated trigger clicks', async () => {
+it('keeps a clicked panel open through outside clicks and focus changes, and closes from the trigger', async () => {
const onPinnedChange = vi.fn();
render(
<>
@@ -254,10 +254,8 @@ it('keeps a clicked panel open through outside clicks, focus changes and repeate
expect(screen.getByRole('dialog')).toBe(dialog);
fireEvent.click(trigger);
fireEvent.pointerLeave(trigger);
- expect(screen.getByRole('dialog')).toBe(dialog);
- expect(screen.queryByRole('tooltip')).toBeNull();
- fireEvent.click(screen.getByRole('button', { name: 'titleBar.close' }));
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
+ expect(screen.queryByRole('tooltip')).toBeNull();
expect(onPinnedChange).toHaveBeenLastCalledWith(false);
});
diff --git a/apps/desktop/src/renderer/features/cc-agent/RunningTokenRatePopover.tsx b/apps/desktop/src/renderer/features/cc-agent/RunningTokenRatePopover.tsx
index 4c86872a57..a474a89f24 100644
--- a/apps/desktop/src/renderer/features/cc-agent/RunningTokenRatePopover.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/RunningTokenRatePopover.tsx
@@ -155,7 +155,7 @@ export function RunningTokenRatePopover({
<Popover
open={open}
onOpenChange={(next) => {
- if (next) setMode('pinned');
+ setMode(next ? 'pinned' : 'dismissed');
}}
>
<Tooltip.Provider>