Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 修复 iOS 标签排序与未持久化的左滑删除
ylliuuu66cc02f99f4c8b
diff --git a/apps/mobile/src/__tests__/taskTagsNative.test.tsx b/apps/mobile/src/__tests__/taskTagsNative.test.tsxindex fb8931c8cd..c1a7fb864e 100644--- a/apps/mobile/src/__tests__/taskTagsNative.test.tsx+++ b/apps/mobile/src/__tests__/taskTagsNative.test.tsx@@ -23,12 +23,17 @@ vi.mock('@/platform/chrome/nativeGlassButtonStyle.ios', () => ({useNativeGlassButtonStyle: () => [],}));vi.mock('@/session/ComposerNativeSection', () => ({- ComposerNativeSection: ({ children }: any) => <section>{children}</section>,+ ComposerNativeSection: ({ children, footer }: any) => (+ <section>+ {children}+ {footer}+ </section>+ ),}));vi.mock('@/session/ComposerNativeRow', () => ({- ComposerNativeRow: ({ title, onPress, onOptions, testID }: any) => (+ ComposerNativeRow: ({ title, onPress, onOptions, testID, disabled }: any) => (<div>- <button data-testid={testID} onClick={onPress}>+ <button data-testid={testID} disabled={disabled} onClick={onPress}>{title}</button>{onOptions ? (@@ -53,7 +58,9 @@ vi.mock('@expo/ui/swift-ui', () => {</button>),Circle: () => null,- Group: Box,+ Group: ({ children, modifiers }: any) => (+ <div data-modifiers={JSON.stringify(modifiers)}>{children}</div>+ ),HStack: Box,Image: () => null,List,@@ -76,6 +83,7 @@ vi.mock('@expo/ui/swift-ui/modifiers', () => ({'accessibilityLabel','buttonStyle','contentShape',+ 'deleteDisabled','disabled','font','foregroundStyle',@@ -89,6 +97,9 @@ vi.mock('@expo/ui/swift-ui/modifiers', () => ({'tint',].map((name) => [name, (value: unknown) => ({ [name]: value })]),),+ environment: (key: string, value: string) => ({+ environment: { key, value },+ }),shapes: { rectangle: () => ({}) },}));@@ -140,9 +151,7 @@ let node: HTMLDivElement;const render = (state: any) =>act(async () => root.render(<NativeTaskTagsExpanded state={state} />));const press = (testID: string) =>- act(async () =>- node.querySelector<HTMLButtonElement>(`[data-testid="${testID}"]`)!.click(),- );+ act(async () => node.querySelector<HTMLButtonElement>(`[data-testid="${testID}"]`)!.click());beforeEach(() => {(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;@@ -167,9 +176,13 @@ it('routes list drags, taps, edit and add through the shared state', async () =>const state = baseState();await render(state);act(() => h.onMove!([0], 3));+ expect(state.onMove).not.toHaveBeenCalled();+ await press('taskTags.reorder');+ act(() => h.onMove!([0], 3));expect(state.onMove).toHaveBeenLastCalledWith(0, 2);act(() => h.onMove!([2], 0));expect(state.onMove).toHaveBeenLastCalledWith(2, 0);+ await press('taskTags.reorder');await press('taskTags.tag.b');expect(state.onToggle).toHaveBeenCalledWith('b');await press('taskTags.tag.b.options');@@ -216,3 +229,62 @@ it('announces failures to VoiceOver once per message', async () => {await render(baseState({ message: 'taskTags.offline' }));expect(h.announce).toHaveBeenLastCalledWith('taskTags.offline');});++const modifiers = () =>+ Array.from(node.querySelectorAll('[data-modifiers]')).flatMap((element) =>+ JSON.parse(element.getAttribute('data-modifiers')!),+ );++it('disables native deletion in both modes and exposes edit mode only when sorting', async () => {+ const state = baseState();+ await render(state);+ expect(modifiers()).toContainEqual({+ environment: { key: 'editMode', value: 'inactive' },+ });+ expect(modifiers().filter((m: any) => m.deleteDisabled)).toHaveLength(3);+ expect(node.textContent).toContain('taskTags.reorderFooter');+ await press('taskTags.reorder');+ expect(modifiers()).toContainEqual({+ environment: { key: 'editMode', value: 'active' },+ });+ expect(modifiers().filter((m: any) => m.deleteDisabled)).toHaveLength(3);+ expect(modifiers().filter((m: any) => m.moveDisabled === false)).toHaveLength(3);+ expect(node.textContent).toContain('taskTags.reorderDone');+ expect(node.textContent).toContain('taskTags.reorderHint');+ expect(node.querySelector('[data-testid="taskTags.tag.a.options"]')).toBeNull();+ expect(node.querySelector('[data-testid="taskTags.add"]')).toBeNull();+ await press('taskTags.tag.a');+ expect(state.onToggle).not.toHaveBeenCalled();+ await press('taskTags.reorder');+ expect(modifiers()).toContainEqual({+ environment: { key: 'editMode', value: 'inactive' },+ });+ expect(node.querySelector('[data-testid="taskTags.tag.a.options"]')).not.toBeNull();+ expect(node.querySelector('[data-testid="taskTags.add"]')).not.toBeNull();+});++it('blocks moves while saving or offline, and restores sorting after the lock clears', async () => {+ const state = baseState();+ await render(state);+ await press('taskTags.reorder');+ await render({ ...state, disabled: true });+ expect(modifiers().filter((m: any) => m.moveDisabled === true)).toHaveLength(3);+ act(() => h.onMove!([0], 3));+ expect(state.onMove).not.toHaveBeenCalled();+ await render(state);+ act(() => h.onMove!([0], 3));+ expect(state.onMove).toHaveBeenCalledWith(0, 2);+});++it('resets sorting after leaving the list and keeps an exit when the catalog shrinks', async () => {+ const state = baseState();+ await render(state);+ await press('taskTags.reorder');+ await render({ ...state, tags: [state.tags[0]] });+ expect(node.textContent).toContain('taskTags.reorderDone');+ await render({ ...state, page: 'edit' });+ await render(state);+ expect(modifiers()).toContainEqual({+ environment: { key: 'editMode', value: 'inactive' },+ });+});diff --git a/apps/mobile/src/__tests__/taskTagsRecovery.test.tsx b/apps/mobile/src/__tests__/taskTagsRecovery.test.tsxindex 3b167aac7b..4733d57803 100644--- a/apps/mobile/src/__tests__/taskTagsRecovery.test.tsx+++ b/apps/mobile/src/__tests__/taskTagsRecovery.test.tsx@@ -508,3 +508,69 @@ it("offers retry only for failed reads, not for failed writes", async () => {expect(state.message).toBe("taskTags.failed");expect(state.canRetry).toBe(false);});++it("persists native reorder and confirmed deletion when the panel is reopened", async () => {+ const second = { ...tag, id: "second", name: "Home" };+ let catalog = [tag, second];+ h.invoke.mockImplementation(async (_device, _channel, [request]) => {+ if (request.action === "reorder") {+ catalog = request.tagIds.map((id: string) =>+ catalog.find((item) => item.id === id)!,+ );+ }+ if (request.action === "delete") {+ catalog = catalog.filter((item) => item.id !== request.tagId);+ }+ return {+ tags: catalog,+ sessions: [],+ ...(request.action === "previewDelete"+ ? {+ deletion: { tagId: tag.id, revision: tag.revision, count: 2 },+ }+ : {}),+ };+ });+ let state: any;+ const open = async (key: string) =>+ act(async () =>+ root.render(+ <TaskTagsPanel+ key={key}+ session={session}+ expanded+ onExpandedChange={onExpandedChange}+ renderExpanded={(value) => {+ state = value;+ return null;+ }}+ />,+ ),+ );+ await open("initial");+ await act(async () => state.onMove(0, 1));+ await open("reordered");+ expect(state.tags.map((item: any) => item.id)).toEqual(["second", "tag"]);+ await act(async () => state.onEdit("tag"));+ await act(async () => state.form.onDelete());+ expect(state.page).toBe("delete");+ expect(catalog).toHaveLength(2);+ expect(+ h.invoke.mock.calls.some((call) => call[2][0].action === "delete"),+ ).toBe(false);+ await act(async () => state.deletion.onConfirm());+ expect(h.invoke.mock.calls.at(-1)!.slice(0, 3)).toEqual([+ "host",+ "local-db:task-tags:execute",+ [+ {+ action: "delete",+ tagId: "tag",+ revision: tag.revision,+ expectedCount: 2,+ },+ ],+ ]);+ await open("deleted");+ expect(state.tags.map((item: any) => item.id)).toEqual(["second"]);+});diff --git a/apps/mobile/src/i18n/locales/en/taskTags.json b/apps/mobile/src/i18n/locales/en/taskTags.jsonindex 546d17565f..59635bce16 100644--- a/apps/mobile/src/i18n/locales/en/taskTags.json+++ b/apps/mobile/src/i18n/locales/en/taskTags.json@@ -34,7 +34,9 @@"editLabel": "Edit “{{name}}”","reorderLabel": "Reorder “{{name}}”","reorderHint": "Hold the handle and drag to reorder",- "reorderFooter": "Touch and hold, then drag to reorder.",+ "reorder": "Reorder Tags",+ "reorderDone": "Finish Reordering",+ "reorderFooter": "Tap “Reorder Tags”, then drag the handles to change the order.","pink": "Pink","coral": "Coral","teal": "Teal",diff --git a/apps/mobile/src/i18n/locales/ja/taskTags.json b/apps/mobile/src/i18n/locales/ja/taskTags.jsonindex 68f7e290fc..20d3bc4d68 100644--- a/apps/mobile/src/i18n/locales/ja/taskTags.json+++ b/apps/mobile/src/i18n/locales/ja/taskTags.json@@ -34,7 +34,9 @@"editLabel": "「{{name}}」を編集","reorderLabel": "「{{name}}」の順序を変更","reorderHint": "ハンドルを長押ししてドラッグで並べ替え",- "reorderFooter": "長押ししてドラッグすると並べ替えられます。",+ "reorder": "タグを並べ替え",+ "reorderDone": "並べ替えを完了",+ "reorderFooter": "「タグを並べ替え」をタップし、ハンドルをドラッグして順序を変更できます。","pink": "ピンク","coral": "コーラル","teal": "ティール",diff --git a/apps/mobile/src/i18n/locales/ko/taskTags.json b/apps/mobile/src/i18n/locales/ko/taskTags.jsonindex 53457944a4..17035bcb38 100644--- a/apps/mobile/src/i18n/locales/ko/taskTags.json+++ b/apps/mobile/src/i18n/locales/ko/taskTags.json@@ -34,7 +34,9 @@"editLabel": "“{{name}}” 편집","reorderLabel": "“{{name}}” 순서 변경","reorderHint": "손잡이를 길게 누르고 드래그하여 순서 변경",- "reorderFooter": "길게 누른 후 드래그하면 순서를 바꿀 수 있습니다.",+ "reorder": "태그 순서 변경",+ "reorderDone": "순서 변경 완료",+ "reorderFooter": "“태그 순서 변경”을 누른 후 손잡이를 드래그하여 순서를 바꿀 수 있습니다.","pink": "분홍색","coral": "산호색","teal": "청록색",diff --git a/apps/mobile/src/i18n/locales/zh-CN/taskTags.json b/apps/mobile/src/i18n/locales/zh-CN/taskTags.jsonindex 5972a1a7be..be8977d111 100644--- a/apps/mobile/src/i18n/locales/zh-CN/taskTags.json+++ b/apps/mobile/src/i18n/locales/zh-CN/taskTags.json@@ -34,7 +34,9 @@"editLabel": "编辑“{{name}}”","reorderLabel": "调整“{{name}}”的顺序","reorderHint": "长按手柄并拖动排序",- "reorderFooter": "长按拖动可调整顺序。",+ "reorder": "排序标签",+ "reorderDone": "完成排序",+ "reorderFooter": "点“排序标签”后拖动手柄调整顺序。","pink": "粉色","coral": "珊瑚色","teal": "青色",diff --git a/apps/mobile/src/i18n/locales/zh-TW/taskTags.json b/apps/mobile/src/i18n/locales/zh-TW/taskTags.jsonindex 7055e37d59..3415fdd442 100644--- a/apps/mobile/src/i18n/locales/zh-TW/taskTags.json+++ b/apps/mobile/src/i18n/locales/zh-TW/taskTags.json@@ -34,7 +34,9 @@"editLabel": "編輯「{{name}}」","reorderLabel": "調整「{{name}}」的順序","reorderHint": "長按把手並拖曳排序",- "reorderFooter": "長按並拖曳即可調整順序。",+ "reorder": "排序標籤",+ "reorderDone": "完成排序",+ "reorderFooter": "點「排序標籤」後拖曳控制柄調整順序。","pink": "粉紅色","coral": "珊瑚色","teal": "青色",diff --git a/apps/mobile/src/session/TaskTagsNative.ios.tsx b/apps/mobile/src/session/TaskTagsNative.ios.tsxindex fc1d1d0a88..4296192ab5 100644--- a/apps/mobile/src/session/TaskTagsNative.ios.tsx+++ b/apps/mobile/src/session/TaskTagsNative.ios.tsx@@ -1,4 +1,4 @@-import { useEffect } from 'react';+import { useEffect, useState } from 'react';import { AccessibilityInfo } from 'react-native';import { useTranslation } from 'react-i18next';import {@@ -21,7 +21,9 @@ import {accessibilityLabel,buttonStyle,contentShape,+ deleteDisabled,disabled,+ environment,font,foregroundStyle,frame,@@ -247,6 +249,10 @@ function TagForm({ state }: { state: TaskTagsExpandedState }) {/** SwiftUI rendering of the expanded tag pages: list, add / edit, delete confirmation. */export function NativeTaskTagsExpanded({ state }: { state: TaskTagsExpandedState }) {const { t } = useTranslation();+ const [sorting, setSorting] = useState(false);+ useEffect(() => {+ if (state.page !== 'list') setSorting(false);+ }, [state.page]);// The failure text arrives asynchronously and focus does not move to it, so a footer// alone is silent in VoiceOver; the React Native panel exposed it as an alert.useEffect(() => {@@ -270,42 +276,64 @@ export function NativeTaskTagsExpanded({ state }: { state: TaskTagsExpandedStateif (state.page === 'add' || state.page === 'edit') return <TagForm state={state} />;return (<>+ {!state.loading && (sorting || state.tags.length > 1) ? (+ <Section>+ <ComposerNativeRow+ title={t(sorting ? 'taskTags.reorderDone' : 'taskTags.reorder')}+ disabled={state.disabled}+ onPress={() => setSorting((value) => !value)}+ testID="taskTags.reorder"+ />+ </Section>+ ) : null}{state.loading ? (<Section><ProgressView /></Section>) : state.tags.length ? (- <Section footer={<Note text={t('taskTags.reorderFooter')} />}>- <List.ForEach- onMove={(sources, destination) => {- const from = sources[0];- if (from === undefined) return;- state.onMove(from, taskTagMoveTarget(from, destination));- }}+ <Group modifiers={[environment('editMode', sorting ? 'active' : 'inactive')]}>+ <Section+ footer={+ state.tags.length > 1 ? (+ <Note text={t(sorting ? 'taskTags.reorderHint' : 'taskTags.reorderFooter')} />+ ) : undefined+ }>- {state.tags.map((tag) => (- <Group key={tag.id} modifiers={[moveDisabled(state.disabled)]}>- <ComposerNativeRow- leading={<NativeTagSwatch {...tag} selected={false} size={TAG_SWATCH.row} />}- title={tag.name}- selected={tag.selected}- disabled={state.disabled}- onPress={() => state.onToggle(tag.id)}- onOptions={() => state.onEdit(tag.id)}- optionsIcon={<Image size={iconSize.lg} systemName="pencil" />}- optionsLabel={t('taskTags.editLabel', { name: tag.name })}- testID={`taskTags.tag.${tag.id}`}- />- </Group>- ))}- </List.ForEach>- </Section>+ <List.ForEach+ onMove={(sources, destination) => {+ if (!sorting || state.disabled) return;+ const from = sources[0];+ if (from === undefined) return;+ state.onMove(from, taskTagMoveTarget(from, destination));+ }}+ >+ {state.tags.map((tag) => (+ <Group+ key={tag.id}+ modifiers={[deleteDisabled(true), moveDisabled(state.disabled || !sorting)]}+ >+ <ComposerNativeRow+ leading={<NativeTagSwatch {...tag} selected={false} size={TAG_SWATCH.row} />}+ title={tag.name}+ selected={tag.selected}+ disabled={state.disabled || sorting}+ onPress={() => state.onToggle(tag.id)}+ onOptions={sorting ? undefined : () => state.onEdit(tag.id)}+ optionsIcon={<Image size={iconSize.lg} systemName="pencil" />}+ optionsLabel={t('taskTags.editLabel', { name: tag.name })}+ testID={`taskTags.tag.${tag.id}`}+ />+ </Group>+ ))}+ </List.ForEach>+ </Section>+ </Group>) : !state.message ? (<Section><Note text={t('taskTags.empty')} /></Section>) : null}- {state.canAdd ? (+ {state.canAdd && !sorting ? (<Section><ComposerNativeRowleading={<Image size={iconSize.lg} systemName="plus" />}diff --git a/docs/product-rules/task-tags.md b/docs/product-rules/task-tags.mdindex 3db7d6c28d..f89e556c78 100644--- a/docs/product-rules/task-tags.md+++ b/docs/product-rules/task-tags.md@@ -2,7 +2,7 @@当前实现沿用任务列表单栏结构,不增加标签筛选导航。任务标签不是可选显示项:「任务信息」子菜单不提供「标签」复选项,有标签的任务始终在标题后紧跟色球,没有标签时不占位。桌面侧栏文字版、列表版与置顶卡片版,聊天标题栏,以及手机任务列表与任务标题栏一致;标题过长时标题截断,色球保持可见,卡片版两行标题时色球对齐首行。多标签色球重叠显示,每个色球悬停显示对应的本地化标签名称。鼠标悬停任务或操作按钮浮出时色球仍在原位,右侧任务信息照旧让位。旧版本保存的「标签」显示选择不再生效,其他任务信息选择与顺序保持不变;「任务信息」默认只勾选时间。任务状态标识保持原语义。-任务菜单在常规操作与归档/删除之间显示排序靠前的标签。最多七个标签,同行最后一个圆形「…」进入完整编辑器。桌面菜单悬停色球时放大色球、上方与气泡均提示添加或移除标签;选中状态用球内勾选标记,悬停已选球显示叉号,未选中的悬停球显示加号。统一标签面板可增删当前任务的标签、创建标签、改名、换色和删除标签,不再拆分「标签」与「标签设置」。桌面拖动行排序,点击色球或名称勾选,双击名称或点击悬停编辑按钮修改名称和颜色;手机长按手柄后标签行跟随手指移动,其余行让位,松手吸附后保存排序;支持边缘自动滚动与系统减少动态效果设置。点击名称选择,点击常显编辑按钮编辑。键盘可在排序手柄上使用上下箭头,手机提供辅助功能增减操作。标签目录最多 256 项,单任务最多 32 个标签;颜色为红、橙、黄、绿、蓝、紫、灰、粉、珊瑚、青、靛蓝、白共十二色。名称最长 80 字符,持久名称去除首尾空白后忽略大小写判重。预置名称的界面翻译不占用自定义名称;自定义标签保持独立身份,不按翻译后的显示名合并或拒绝。旧无颜色标签按白色显示,旧请求仍被接受并在保存时归一白色。白色球用细边框和固定深色勾。桌面与手机列表最多展示十二行,并随窗口可用高度收缩;列表溢出时滚动条常显,标题与添加入口留在滚动区域外。手机任务列表中的色球仅展示,不弹出名称菜单;任务标题栏色球可打开任务详情。详情和任务菜单的标题居中,下方完整显示当前标签的色球与名称;任务详情的标签管理在独立弹窗中打开,关闭即完成选择,无额外完成按钮。快捷标签支持长按查看名称,末尾「…」与色球同尺寸。任务色球外圈跟随行背景及选中状态;鼠标悬停任务时外圈保持原样,不因半透明悬停底色消失。默认只显示列表,点击添加或编辑后在同一面板切换为名称与两行六列色板,取消不写入,保存后返回列表;不显示双击编辑提示。+任务菜单在常规操作与归档/删除之间显示排序靠前的标签。最多七个标签,同行最后一个圆形「…」进入完整编辑器。桌面菜单悬停色球时放大色球、上方与气泡均提示添加或移除标签;选中状态用球内勾选标记,悬停已选球显示叉号,未选中的悬停球显示加号。统一标签面板可增删当前任务的标签、创建标签、改名、换色和删除标签,不再拆分「标签」与「标签设置」。桌面拖动行排序,点击色球或名称勾选,双击名称或点击悬停编辑按钮修改名称和颜色;iOS 先点「排序标签」显示系统排序手柄,拖动后保存,点「完成排序」返回选择;排序期间不切换标签或编辑,且不提供系统左滑删除,删除统一从编辑页进入二次确认。其他手机端长按手柄后标签行跟随手指移动,其余行让位,松手吸附后保存排序;支持边缘自动滚动与系统减少动态效果设置。点击名称选择,点击常显编辑按钮编辑。键盘可在排序手柄上使用上下箭头,手机提供辅助功能增减操作。标签目录最多 256 项,单任务最多 32 个标签;颜色为红、橙、黄、绿、蓝、紫、灰、粉、珊瑚、青、靛蓝、白共十二色。名称最长 80 字符,持久名称去除首尾空白后忽略大小写判重。预置名称的界面翻译不占用自定义名称;自定义标签保持独立身份,不按翻译后的显示名合并或拒绝。旧无颜色标签按白色显示,旧请求仍被接受并在保存时归一白色。白色球用细边框和固定深色勾。桌面与手机列表最多展示十二行,并随窗口可用高度收缩;列表溢出时滚动条常显,标题与添加入口留在滚动区域外。手机任务列表中的色球仅展示,不弹出名称菜单;任务标题栏色球可打开任务详情。详情和任务菜单的标题居中,下方完整显示当前标签的色球与名称;任务详情的标签管理在独立弹窗中打开,关闭即完成选择,无额外完成按钮。快捷标签支持长按查看名称,末尾「…」与色球同尺寸。任务色球外圈跟随行背景及选中状态;鼠标悬停任务时外圈保持原样,不因半透明悬停底色消失。默认只显示列表,点击添加或编辑后在同一面板切换为名称与两行六列色板,取消不写入,保存后返回列表;不显示双击编辑提示。首次获得标签功能的账号预置十二个标签:前六个为「红/橙/黄/绿/蓝/紫」颜色标签,后六个为「重要/待跟进/工作/生活/灵感/资料」,后六个分别使用珊瑚/粉/靛蓝/青/白/灰,与前六种默认色红/橙/黄/绿/蓝/紫不重复。默认名称随界面语言显示,用户改名后显示自定义名称。预置项与普通标签一样可改名、换色、排序和删除,不自动关联任务;已有标签目录保持不变,用户删掉的标签不会在重启后补回。显式补入预置项沿用创建接口的 `presetId`,仅接受已知预置 ID 及其标准名称和颜色,追加到目录末尾;ID 已存在则拒绝覆盖。预置名称覆盖简体中文、繁体中文、英语、日语、韩语,桌面和手机按各自界面语言显示同一标签。