Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 近况待办在 Android 可点击引用,读取失败可重试,电脑上下线即时更新
zqchrisff0044c9760d
diff --git a/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx b/apps/mobile/src/__tests__/androidMaterialMenu.test.tsxindex 753badf12b..2e9a98d1bc 100644--- a/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx+++ b/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx@@ -27,6 +27,7 @@ vi.mock("react-native", () => ({disabled={disabled}data-testid={testID}onClick={onPress ?? onLongPress}+ onContextMenu={onLongPress}>{children}</button>@@ -226,6 +227,26 @@ it("creates the host on demand and reuses it across dismiss/reopen without blockexpect(host?.parentElement?.getAttribute("data-pointer-events")).toBe("none");expect(container.textContent).toContain("One");});+// 伙伴近况的待办行:长按开菜单(删除),短按要把待办交给对话。触发器接管整块触摸,短按必须经 onPress 转发。+it("long-press mode opens on long press and forwards a tap to onPress", () => {+ const tap = vi.fn();+ act(() =>+ root.render(+ <AnchoredPullDownMenu longPress onPress={tap} actions={[{ id: "delete", title: "Delete", destructive: true }]} onAction={vi.fn()}>+ <span>Todo</span>+ </AnchoredPullDownMenu>,+ ),+ );+ click("Todo");+ expect(tap).toHaveBeenCalledOnce();+ expect(container.textContent).not.toContain("Delete");+ act(() => {+ Array.from(container.querySelectorAll("button")).find((b) => b.textContent === "Todo")!+ .dispatchEvent(new MouseEvent("contextmenu", { bubbles: true }));+ });+ expect(container.textContent).toContain("Delete");+ expect(tap).toHaveBeenCalledOnce();+});it("navigates a submenu, returns through its back row, dismisses and resets the path on reopen", () => {act(() =>root.render(diff --git a/apps/mobile/src/__tests__/companionGlance.test.tsx b/apps/mobile/src/__tests__/companionGlance.test.tsxindex cd7e59ad65..58a99dc5d7 100644--- a/apps/mobile/src/__tests__/companionGlance.test.tsx+++ b/apps/mobile/src/__tests__/companionGlance.test.tsx@@ -55,6 +55,19 @@ it('reads every page of open todos, not just the host first page of 25', async (expect(h.reads.filter(read => read.view === 'open').map(read => read.offset)).toEqual([0, 25]);});+it('keeps the newest completed todos past the 200 cap', async () => {+ h.items = Array.from({ length: 230 }, (_, index) => todo(`d${String(index).padStart(3, '0')}`, 'done'));+ let latest: ReturnType<typeof useCompanionGlanceTodos> | null = null;+ function Probe() { latest = useCompanionGlanceTodos({ deviceId: 'pc', deviceName: 'PC', botId: 'bot', enabled: true }); return null; }+ await act(async () => root.render(createElement(Probe)));+ await act(async () => { await Promise.resolve(); });+ const done = latest!.todos.done;+ expect(done).toHaveLength(200);+ expect(done[0].id).toBe('d229');+ expect(done.some(item => item.id === 'd029')).toBe(false);+ expect(latest!.todos.doneTotal).toBe(230);+});+it("lists only this teammate's finished deliverables, newest first, each opening its source task", () => {const outputs = companionGlanceOutputs({ok: true,diff --git a/apps/mobile/src/i18n/locales/en/devices.json b/apps/mobile/src/i18n/locales/en/devices.jsonindex ce4271e480..cf0ec771ed 100644--- a/apps/mobile/src/i18n/locales/en/devices.json+++ b/apps/mobile/src/i18n/locales/en/devices.json@@ -852,6 +852,7 @@"undo": "Undo","undoFailed": "Couldn't undo. Try again.","deleteFailed": "Couldn't delete. Try again.",+ "loadFailed": "Couldn't load todos","outputs": "Outputs","outputMeta": "{{time}} · {{task}}","source": {diff --git a/apps/mobile/src/i18n/locales/ja/devices.json b/apps/mobile/src/i18n/locales/ja/devices.jsonindex c180a9c030..b87d4c89e2 100644--- a/apps/mobile/src/i18n/locales/ja/devices.json+++ b/apps/mobile/src/i18n/locales/ja/devices.json@@ -852,6 +852,7 @@"undo": "元に戻す","undoFailed": "元に戻せませんでした。もう一度お試しください","deleteFailed": "削除できませんでした。もう一度お試しください",+ "loadFailed": "Todo を読み込めませんでした","outputs": "成果物","outputMeta": "{{time}} · {{task}}","source": {diff --git a/apps/mobile/src/i18n/locales/ko/devices.json b/apps/mobile/src/i18n/locales/ko/devices.jsonindex 06954bebbc..540ec823a9 100644--- a/apps/mobile/src/i18n/locales/ko/devices.json+++ b/apps/mobile/src/i18n/locales/ko/devices.json@@ -852,6 +852,7 @@"undo": "실행 취소","undoFailed": "실행 취소하지 못했습니다. 다시 시도하세요","deleteFailed": "삭제하지 못했습니다. 다시 시도하세요",+ "loadFailed": "할 일을 불러오지 못했습니다","outputs": "결과물","outputMeta": "{{time}} · {{task}}","source": {diff --git a/apps/mobile/src/i18n/locales/zh-CN/devices.json b/apps/mobile/src/i18n/locales/zh-CN/devices.jsonindex 1a290d964c..588f3e1b1a 100644--- a/apps/mobile/src/i18n/locales/zh-CN/devices.json+++ b/apps/mobile/src/i18n/locales/zh-CN/devices.json@@ -852,6 +852,7 @@"undo": "撤销","undoFailed": "没能撤销,请重试","deleteFailed": "没能删除,请重试",+ "loadFailed": "没能读取待办","outputs": "输出内容","outputMeta": "{{time}} · {{task}}","source": {diff --git a/apps/mobile/src/i18n/locales/zh-TW/devices.json b/apps/mobile/src/i18n/locales/zh-TW/devices.jsonindex 4c7883e64d..d230b03575 100644--- a/apps/mobile/src/i18n/locales/zh-TW/devices.json+++ b/apps/mobile/src/i18n/locales/zh-TW/devices.json@@ -852,6 +852,7 @@"undo": "復原","undoFailed": "無法復原,請重試","deleteFailed": "無法刪除,請重試",+ "loadFailed": "無法讀取待辦","outputs": "輸出內容","outputMeta": "{{time}} · {{task}}","source": {diff --git a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsxindex 86c699e912..af2fc6a8d3 100644--- a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx+++ b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx@@ -134,6 +134,7 @@ export function AnchoredPullDownMenu({children,longPress,onAction,+ onPress,style,testID,accessibilityLabel,@@ -173,7 +174,7 @@ export function AnchoredPullDownMenu({accessibilityValue={child.accessibilityValue}accessibilityRole="button"accessibilityState={{ ...child.accessibilityState, expanded: open }}- onPress={longPress ? undefined : show}+ onPress={longPress ? onPress : show}onLongPress={longPress ? show : undefined}testID={testID}>diff --git a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsxindex 6312787577..4434efd111 100644--- a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx+++ b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx@@ -95,6 +95,7 @@ export function AnchoredPullDownMenu({children,longPress = false,onAction,+ onPress,style,testID,}: {@@ -103,6 +104,8 @@ export function AnchoredPullDownMenu({children: ReactNode;longPress?: boolean;onAction(id: string): void;+ /** longPress 时的短按动作:触发器接管整块触摸,子元素自己的点按收不到,由这里转发。 */+ onPress?(): void;/** 触发器在父布局里的样式(如 flex: 1);外层替子元素占据父布局里的位置。 */style?: StyleProp<ViewStyle>;testID?: string;@@ -135,7 +138,7 @@ export function AnchoredPullDownMenu({accessibilityValue={child.accessibilityValue}collapsable={false}onLongPress={longPress ? show : undefined}- onPress={longPress ? undefined : show}+ onPress={longPress ? onPress : show}style={({ pressed }) => [style, pressed && styles.triggerPressed]}testID={testID}>diff --git a/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx b/apps/mobile/src/platform/chrome/NativePullDownMenu.tsxindex 7cc784bc27..55321c61a3 100644--- a/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx+++ b/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx@@ -112,6 +112,7 @@ export function NativePullDownMenu({disabled = false,longPress = false,onAction,+ onPress,style,testID,}: {@@ -123,6 +124,11 @@ export function NativePullDownMenu({disabled?: boolean;longPress?: boolean;onAction(id: string): void;+ /**+ * longPress 时的短按动作。Android 触发器接管整块触摸,子元素的点按收不到,必须经这里转发;+ * iOS 系统菜单只拦长按,短按仍交给子元素,这里不重复调用。+ */+ onPress?(): void;/*** 菜单外层在父布局里的样式。外层替代子元素成为父布局的直接子节点,子元素原本* 依赖父布局的样式(如 flex: 1 占满标题区)要同时交给这里。@@ -146,6 +152,7 @@ export function NativePullDownMenu({actions={actions}longPress={longPress}onAction={onAction}+ onPress={onPress}style={style}testID={testID}>diff --git a/apps/mobile/src/session/CompanionGlanceSheet.tsx b/apps/mobile/src/session/CompanionGlanceSheet.tsxindex 9d9c2445fa..5c096b50eb 100644--- a/apps/mobile/src/session/CompanionGlanceSheet.tsx+++ b/apps/mobile/src/session/CompanionGlanceSheet.tsx@@ -145,7 +145,8 @@ function Computers({ botId, deviceId, deviceName, online, cloudHome, onOpenCindyconst { colors } = useTheme();const styles = useThemedStyles(makeStyles);const { user, accountGeneration } = useAuth();- const { status, getPresenceAvailability } = useDeviceLink();+ // getPresenceAvailability is stable and reads live presence; presenceVersion is what changes.+ const { status, getPresenceAvailability, presenceVersion } = useDeviceLink();const [showOffline, setShowOffline] = useState(false);// Cindy runs a copy on each computer: the other copies come from the teammate list already read// on this phone (no extra discovery); other teammates only show the computer they run on.@@ -154,7 +155,7 @@ function Computers({ botId, deviceId, deviceName, online, cloudHome, onOpenCindyreturn readRemoteCollectionCache(`${user?.id ?? ''}:${accountGeneration}`, 'teammates').filter(row => row.item.ref.kind === 'bot' && row.item.ref.id === CINDY_BOT_ID && row.host.deviceId !== deviceId).map(row => ({ row, online: remoteResourceConnectionState(status, getPresenceAvailability(row.host.deviceId)) === true }));- }, [accountGeneration, botId, cloudHome, deviceId, getPresenceAvailability, status, user?.id]);+ }, [accountGeneration, botId, cloudHome, deviceId, getPresenceAvailability, presenceVersion, status, user?.id]);const onlineCopies = copies.filter(copy => copy.online);const offlineCopies = copies.filter(copy => !copy.online);const monitor = (state: 'here' | 'online' | 'offline') => <View>@@ -195,6 +196,14 @@ function Todos({ todos, online, onQuote }: { todos: GlanceTodoState; online: booconst [deleted, setDeleted] = useState<TeammateTodo | null>(null);const [error, setError] = useState<string | null>(null);const { open, done, doneTotal, openTotal } = todos.todos;+ // A failed first read is not "no todos": keep the section with a retry instead of hiding it.+ if (todos.failed && open.length === 0 && doneTotal === 0) return <Section label={t('devices.glance.todos')}>+ <Pressable accessibilityRole="button" onPress={() => void todos.refresh()} disabled={!online}+ style={({ pressed }) => [styles.row, pressed && styles.rowPressed]} testID="companion.glance.todo.retry">+ <Text numberOfLines={1} style={styles.undoNote}>{t('devices.glance.loadFailed')}</Text>+ <Text style={styles.undoAction}>{t('devices.resources.retry')}</Text>+ </Pressable>+ </Section>;if (open.length === 0 && doneTotal === 0 && !deleted) return null;const remove = async (todo: TeammateTodo) => {@@ -232,7 +241,7 @@ function Todos({ todos, online, onQuote }: { todos: GlanceTodoState; online: boo// 长按:系统上下文菜单(行浮起、背景模糊),只有「删除」。return <NativePullDownMenu key={todo.id} longPress disabled={!online} accessibilityLabel={todo.title}actions={[{ id: 'delete', title: t('devices.glance.delete'), destructive: true, image: 'trash' }]}- onAction={() => void remove(todo)}>{content}</NativePullDownMenu>;+ onAction={() => void remove(todo)} onPress={() => onQuote(todo)}>{content}</NativePullDownMenu>;};const rows: ReactNode[] = [];if (deleted) rows.push(<Pressable key="undo" accessibilityRole="button" onPress={() => void undo()}diff --git a/apps/mobile/src/session/useCompanionGlanceTodos.ts b/apps/mobile/src/session/useCompanionGlanceTodos.tsindex e000179bc1..f235be1b7a 100644--- a/apps/mobile/src/session/useCompanionGlanceTodos.ts+++ b/apps/mobile/src/session/useCompanionGlanceTodos.ts@@ -39,14 +39,18 @@ export function todosResourceRef(botId: string) {return { collectionId: 'teammates', kind: 'bot', id: `todos:${botId}` } as const;}-/** Reads every page of one view; the total read up front bounds the loop. */+/**+ * Reads every page of one view. Open todos keep the first 200 by due order; completed ones are+ * listed oldest first by the host, so past the cap the read starts from the tail to keep the newest.+ */async function readAll(readPage: (query: TodoListQuery) => Promise<Page>, view: 'open' | 'done'): Promise<Page> {const order = view === 'open' ? 'due' : 'created';const first = await readPage({ view, order, offset: 0, limit: PAGE });- const items = [...first.items];let total = first.total;- while (items.length < Math.min(total, MAX_ITEMS)) {- const page = await readPage({ view, order, offset: items.length, limit: PAGE });+ const start = view === 'done' ? Math.max(0, total - MAX_ITEMS) : 0;+ const items = start === 0 ? [...first.items] : [];+ while (start + items.length < total && items.length < MAX_ITEMS) {+ const page = await readPage({ view, order, offset: start + items.length, limit: PAGE });total = page.total;if (page.items.length === 0) break;items.push(...page.items);