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。

Merge upstream main into bot-observation-on-demand

zqchris62bb6913f1f7
diff --cc apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx
index 00d26de683,ceb75cfc98..c1a25e90d7
--- a/apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx
@@@ -58,30 -57,9 +60,30 @@@ import type { TabKindHostContext } fro
type Listener = (payload: { botIds?: string[] }) => void;
let listeners: Listener[] = [];
const glanceApi = vi.fn<(botId: string) => Promise<BotGlance>>();
- const localMaker = { getPendingInteractions: vi.fn(), resolveInteraction: vi.fn() };
+ const localMaker = { getPendingInteractions: vi.fn(), resolveInteraction: vi.fn(), allowBotWorkbenchPermission: vi.fn() };
const remoteInvoke = vi.fn();
+// Unit: inactive tabs stay mounted in the sidebar shell. Reading their glance used to
+// trigger remote IO while hidden; exercise the registered body and real data hook.
+it('reads remote state only while the workbench tab is visible', async () => {
+ glanceApi.mockResolvedValue(glance());
+ const Body = getTabKind('bot-workbench')!.TabBody;
+ const ctx: TabKindHostContext = {
+ tabId: 'workbench', sessionId: 'main', workdir: '', remoteHostId: null,
+ deviceLinkDeviceId: null, patchState: vi.fn(), onVisibilityChange: vi.fn(),
+ setCloseInterceptor: () => () => {},
+ };
+ const props = { state: { botId: 'bot-1' }, ctx };
+ const view = render(<Body {...props} active={false} shellVisible />);
+ expect(glanceApi).not.toHaveBeenCalled();
+ view.rerender(<Body {...props} active shellVisible={false} />);
+ expect(glanceApi).not.toHaveBeenCalled();
+ view.rerender(<Body {...props} active shellVisible />);
+ await waitFor(() => expect(glanceApi).toHaveBeenCalledWith('bot-1', true));
+ view.rerender(<Body {...props} active shellVisible={false} />);
+ expect(listeners).toHaveLength(0);
+});
+
function row(patch: Partial<GlanceRow>): GlanceRow {
return {
sessionId: 's1',