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(mobile): 默认收起 Orca 派活卡片 (#5082)

fmfsaisaicfbc2b4bac4b
diff --git a/apps/mobile/src/__tests__/orcaCardRetention.test.tsx b/apps/mobile/src/__tests__/orcaCardRetention.test.tsx
index f071a1bcad..db8182032d 100644
--- a/apps/mobile/src/__tests__/orcaCardRetention.test.tsx
+++ b/apps/mobile/src/__tests__/orcaCardRetention.test.tsx
@@ -29,8 +29,7 @@ const bindings = {
const Card = new Function(...Object.keys(bindings), `${compiled}; return OrcaCollabCard;`)(...Object.values(bindings));
describe('worker card reading state', () => {
- it.each(['report', 'dispatch'])('remembers %s toggles across remounts, independently per card/account', async (variant) => {
- const defaultExpanded = variant === 'dispatch';
+ it.each(['report', 'dispatch'])('starts %s collapsed and remembers toggles across remounts, independently per card/account', async (variant) => {
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
__test_internals.reset(); generation = 1;
const container = document.createElement('div');
@@ -39,17 +38,26 @@ describe('worker card reading state', () => {
card={{ variant, title: 'Worker', body: 'Long report' }} />));
try {
await show('pc/task/a');
- expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe(String(defaultExpanded));
+ expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe('false');
+ expect(container.textContent).not.toContain('Long report');
await act(async () => container.querySelector('button')!.click());
+ expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe('true');
+ expect(container.textContent).toContain('Long report');
await act(async () => root.render(null));
await show('pc/task/b');
- expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe(String(defaultExpanded));
+ expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe('false');
await act(async () => root.render(null));
await show('pc/task/a');
- expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe(String(!defaultExpanded));
- expect(container.textContent?.includes('Long report')).toBe(!defaultExpanded);
+ expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe('true');
+ expect(container.textContent).toContain('Long report');
generation = 2; await show('pc/task/a');
- expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe(String(defaultExpanded));
+ expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe('false');
+ generation = 1; await show('pc/task/a');
+ await act(async () => container.querySelector('button')!.click());
+ await act(async () => root.render(null));
+ await show('pc/task/a');
+ expect(container.querySelector('button')?.getAttribute('aria-expanded')).toBe('false');
+ expect(container.textContent).not.toContain('Long report');
} finally { await act(async () => root.unmount()); __test_internals.reset(); }
});
});
diff --git a/apps/mobile/src/__tests__/orcaCollab.test.ts b/apps/mobile/src/__tests__/orcaCollab.test.ts
index 47636c8411..f93a0439b7 100644
--- a/apps/mobile/src/__tests__/orcaCollab.test.ts
+++ b/apps/mobile/src/__tests__/orcaCollab.test.ts
@@ -270,7 +270,7 @@ describe('MessageRenderer wires the orca card', () => {
// F4:透传 screenWidth,使 CollabCardShell layout 随屏宽响应(与 SubagentCard 一致)。
expect(source).toContain('<OrcaCollabCard card={item.message.orcaCard} screenWidth={actions.screenWidth}');
expect(source).toContain('blockKey={JSON.stringify([actions.remoteDeviceId, item.key])}');
- expect(source).toContain("controlledExpanded={(card.variant === 'dispatch') !== toggled}");
+ expect(source).toContain('controlledExpanded={expanded}');
expect(source).toContain('onControlledToggle={toggleExpanded}');
expect(source).toContain('testID={`message.orcaCard.${card.variant}`}');
});
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 0836a2db27..6d8d2161ab 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -5165,14 +5165,14 @@ function MobileAutoResumeActionRow({
// Orca 协同卡片:Lead 派活(dispatch)/ worker 回报(report)。与 SubagentCard 共用 CollabCardShell
// chrome(同款 leadingIcon+title+可折叠 body),视觉一致;数据路径仍是 message.orcaCard,不碰 parentUuid。
-// worker 回报默认收起,Lead 派活保持默认展开;正文可选中(长按复制)。识别/文案抽取在 @/session/orcaCollab。
+// Lead 派活和 worker 回报均默认收起;正文可选中(长按复制)。识别/文案抽取在 @/session/orcaCollab。
function OrcaCollabCard({ card, screenWidth, blockKey }: {
card: OrcaCollabCardModel; screenWidth?: number; blockKey: string;
}) {
const { accountGeneration } = useAuth();
- // Remember deviations from each variant's default using the
+ // Remember manual expansions using the
// existing bounded block store, including across native route reconstruction.
- const [toggled, toggleExpanded] = useFoldableExpandedState(
+ const [expanded, toggleExpanded] = useFoldableExpandedState(
`orca-toggled-${JSON.stringify([accountGeneration, blockKey, card.variant])}`, false,
);
const { colors } = useTheme();
@@ -5193,7 +5193,7 @@ function OrcaCollabCard({ card, screenWidth, blockKey }: {
<CollabCardShell
leadingIcon={<Bot color={colors.textTertiary} size={iconSize.md} strokeWidth={iconStroke.regular} />}
title={card.title}
- controlledExpanded={(card.variant === 'dispatch') !== toggled}
+ controlledExpanded={expanded}
onControlledToggle={toggleExpanded}
screenWidth={screenWidth}
testID={`message.orcaCard.${card.variant}`}