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。

test(mobile): verify current-task search through the layout consumer

Chris40f799eb55d2
diff --git a/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts b/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
index 01efa14188..c327908893 100644
--- a/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
@@ -166,7 +166,8 @@ describe('mobile session header desktop-first surface', () => {
expect(source).toContain('if (sessionListDrawerClosingRef.current || pendingDrawerNavigationRef.current) return;');
expect(source).toContain('sessionListDrawerClosingRef.current = true;\n pendingDrawerNavigationRef.current = action;');
expect(source).toContain('const closeSessionListDrawer = useCallback(() => {\n if (!sessionListDrawerOverlayMounted) return;\n if (sessionListDrawerClosingRef.current) return;\n sessionListDrawerClosingRef.current = true;');
- expect(source).toContain('if (targetSession.id === sessionId && !focusClientId) {\n closeSessionListDrawer();');
+ // Same-task selection versus search navigation is exercised through the actual
+ // layout callback in sideChatTaskBoundary.test.tsx, rather than a source literal.
expect(source).toContain('onClosed={handleSessionListDrawerClosed}');
expect(source).toContain('const action = pendingDrawerNavigationRef.current;\n sessionListDrawerClosingRef.current = false;\n setSessionListDrawerOverlayMounted(false);');
expect(source).toContain('pendingDrawerNavigationRef.current = null;\n action();');
diff --git a/apps/mobile/src/__tests__/sideChatTaskBoundary.test.tsx b/apps/mobile/src/__tests__/sideChatTaskBoundary.test.tsx
index e1cab3a53e..481b6ff5a8 100644
--- a/apps/mobile/src/__tests__/sideChatTaskBoundary.test.tsx
+++ b/apps/mobile/src/__tests__/sideChatTaskBoundary.test.tsx
@@ -224,6 +224,22 @@ describe('side chat task lifecycle', () => {
expect(state.replaceParams).toHaveBeenCalledWith({ deviceId: 'host', deviceName: 'host', sessionId: 'old', focusClientId: 'message' });
});
+ // #7105: a same-ID search hit must exit the companion resource skin, whereas
+ // selecting the already-open ordinary row is a no-op. Unit, actual layout consumer.
+ it.each([false, true])('handles the current task selected from search=%s', (search) => {
+ state.route = { deviceId: 'host', sessionId: 'child', resourceCollectionId: 'teammates', resourceKind: 'bot', resourceId: 'bot' };
+ act(() => root.render(<SessionTaskLayout>{() => <textarea />}</SessionTaskLayout>));
+ const target = {
+ session: { id: 'child', canonicalDeviceId: 'host' },
+ ...(search ? { searchLocallyCached: false } : {}),
+ } as unknown as RemoteSessionListItem;
+ act(() => state.sidebar!.onSelectSession!(target));
+ if (search) expect(state.replaceParams).toHaveBeenCalledExactlyOnceWith({
+ deviceId: 'host', deviceName: 'host', sessionId: 'child',
+ });
+ else expect(state.replaceParams).not.toHaveBeenCalled();
+ });
+
it('discards the outgoing attachment scope before sidebar navigation and preserves search focus', () => {
const order: string[] = [];
state.replaceParams.mockImplementation(() => order.push('navigate'));