@tano.page/workbench 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/package.json +21 -8
  2. package/src/App.vue +76 -17
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/components/AssistantChangeList.vue +98 -21
  17. package/src/assistant/components/AssistantPanel.vue +424 -7
  18. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  19. package/src/assistant/engine.ts +56 -3
  20. package/src/assistant/files.ts +5 -13
  21. package/src/assistant/inbox.ts +1 -148
  22. package/src/assistant/locales/de-DE.json +4 -1
  23. package/src/assistant/locales/en-US.json +4 -1
  24. package/src/assistant/locales/es-ES.json +4 -1
  25. package/src/assistant/locales/ja-JP.json +4 -1
  26. package/src/assistant/locales/zh-CN.json +4 -1
  27. package/src/assistant/locales/zh-TW.json +4 -1
  28. package/src/assistant/mention-autocomplete.ts +69 -0
  29. package/src/assistant/prompts.ts +7 -0
  30. package/src/assistant/results.ts +20 -86
  31. package/src/assistant/store.ts +319 -12
  32. package/src/assistant/structures.ts +7 -5
  33. package/src/assistant/tasks.ts +3 -5
  34. package/src/assistant/workspace-bridge.ts +1 -1
  35. package/src/composables/use-document-actions.ts +38 -20
  36. package/src/composables/use-file-tree-controller.ts +7 -12
  37. package/src/composables/use-workbench-history.ts +2 -4
  38. package/src/composables/use-workbench-modals.ts +6 -1
  39. package/src/composables/use-workbench-outline.ts +0 -5
  40. package/src/composables/use-workbench-shortcuts.ts +26 -22
  41. package/src/data-tables/data-tables.ts +1 -2
  42. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  43. package/src/features.ts +1 -0
  44. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  45. package/src/fonts/Inter-Latin.woff2 +0 -0
  46. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  47. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  48. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  49. package/src/help/help-milestones.ts +3 -5
  50. package/src/i18n/locales/de-DE.json +349 -3
  51. package/src/i18n/locales/en-US.json +349 -2
  52. package/src/i18n/locales/es-ES.json +349 -3
  53. package/src/i18n/locales/ja-JP.json +348 -2
  54. package/src/i18n/locales/zh-TW.json +348 -2
  55. package/src/mail/components/MailAccountDialog.vue +449 -0
  56. package/src/mail/components/MailComposerDialog.vue +325 -0
  57. package/src/mail/components/MailProviderIcon.vue +30 -0
  58. package/src/mail/components/MailWorkspaceView.vue +820 -0
  59. package/src/mail/components/SidebarMail.vue +133 -0
  60. package/src/mail/mail-avatar.ts +17 -0
  61. package/src/mail/mail-bridge.ts +68 -0
  62. package/src/mail/mail-calendar.ts +208 -0
  63. package/src/mail/mail-markdown.ts +195 -0
  64. package/src/mail/types.ts +226 -0
  65. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  66. package/src/objects/workspace-objects.ts +1 -1
  67. package/src/plan-sync/types.ts +6 -3
  68. package/src/plans/calendar-interaction.ts +194 -0
  69. package/src/plans/calendar.ts +63 -7
  70. package/src/plans/components/CalendarDayPopover.vue +172 -39
  71. package/src/plans/components/CalendarView.vue +1736 -276
  72. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  73. package/src/plans/components/PlanDateField.vue +6 -4
  74. package/src/plans/components/PlanDetailPanel.vue +227 -32
  75. package/src/plans/components/PlanEventList.vue +16 -4
  76. package/src/plans/components/SidebarPlan.vue +22 -15
  77. package/src/plans/components/TaskRepeatControls.vue +169 -30
  78. package/src/plans/local-reminders.ts +149 -0
  79. package/src/plans/personal-plans.ts +10 -1
  80. package/src/plans/plan-date.ts +8 -1
  81. package/src/plans/plan-migration.ts +95 -0
  82. package/src/plans/recurrence.ts +95 -0
  83. package/src/plans/task-repeat.ts +8 -8
  84. package/src/plans/timeline-layout.ts +92 -0
  85. package/src/plugins/assistant-bridge.ts +520 -0
  86. package/src/plugins/attachment-reader.ts +3 -1
  87. package/src/plugins/cache-storage.ts +42 -2
  88. package/src/plugins/components/PluginAutomations.vue +3 -3
  89. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  90. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  91. package/src/plugins/components/PluginConnections.vue +1 -1
  92. package/src/plugins/components/PluginCustomView.vue +2 -2
  93. package/src/plugins/components/PluginDetailPage.vue +129 -54
  94. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  95. package/src/plugins/components/PluginExplorer.vue +15 -21
  96. package/src/plugins/components/PluginImportDialog.vue +410 -0
  97. package/src/plugins/components/PluginInstaller.vue +39 -145
  98. package/src/plugins/components/PluginListItem.vue +3 -0
  99. package/src/plugins/components/PluginMaintenance.vue +21 -6
  100. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  101. package/src/plugins/components/PluginSettingsForm.vue +111 -0
  102. package/src/plugins/components/PluginStatusBar.vue +161 -0
  103. package/src/plugins/components/PluginSurface.vue +18 -6
  104. package/src/plugins/components/PluginUiDialog.vue +452 -0
  105. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  106. package/src/plugins/excalidraw/manifest.json +12 -1
  107. package/src/plugins/host.ts +662 -43
  108. package/src/plugins/native.ts +2 -10
  109. package/src/plugins/overlay-mapping.ts +125 -0
  110. package/src/plugins/packages.ts +73 -1
  111. package/src/plugins/plugin-permissions.ts +57 -0
  112. package/src/plugins/plugin-sdk.ts +174 -8
  113. package/src/plugins/policy.ts +53 -3
  114. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  115. package/src/plugins/presentation-preview/manifest.json +2 -1
  116. package/src/plugins/queries.ts +3 -1
  117. package/src/plugins/sandbox.ts +15 -1
  118. package/src/plugins/use-plugin-actions.ts +67 -20
  119. package/src/plugins/user-plugins.ts +254 -0
  120. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  121. package/src/plugins/word-preview/manifest.json +13 -1
  122. package/src/plugins/workbench.ts +175 -2
  123. package/src/plugins/worker.js +105 -8
  124. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  125. package/src/plugins/workspace-plugins.ts +212 -21
  126. package/src/runtime.ts +101 -3
  127. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  128. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  129. package/src/settings/components/settings-search.ts +2 -3
  130. package/src/shell/components/SidebarNavigation.vue +22 -2
  131. package/src/shell/components/WorkbenchContextMenus.vue +21 -8
  132. package/src/shell/components/WorkbenchModals.vue +27 -46
  133. package/src/shell/components/WorkbenchPanes.vue +267 -84
  134. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  135. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  136. package/src/shell/use-workbench.ts +116 -145
  137. package/src/shell/workbench-async-components.ts +14 -5
  138. package/src/stores/mail.ts +414 -0
  139. package/src/stores/plan-sync.ts +2 -1
  140. package/src/stores/plans.ts +2 -9
  141. package/src/stores/workspace-knowledge.ts +1 -113
  142. package/src/stores/workspace-plugins-state.ts +537 -14
  143. package/src/stores/workspace-tabs-layout.ts +5 -43
  144. package/src/stores/workspace.ts +69 -66
  145. package/src/styles/agent-diff-modals.css +0 -7
  146. package/src/styles/dark-theme.css +3 -3
  147. package/src/styles/inspector.css +0 -59
  148. package/src/styles/layout-themes.css +346 -0
  149. package/src/styles/mail.css +1568 -0
  150. package/src/styles/mobile.css +2 -2
  151. package/src/styles/recent-and-media.css +0 -17
  152. package/src/styles/theme-contract.css +3 -3
  153. package/src/styles/workbench-shell.css +110 -17
  154. package/src/styles/workspace-states.css +9 -33
  155. package/src/styles.css +1 -1
  156. package/src/tabs/components/DesktopTabs.vue +0 -3
  157. package/src/tabs/components/NewTabPicker.vue +10 -4
  158. package/src/tabs/tab-label.ts +0 -1
  159. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  160. package/src/workspace/components/WorkspaceIconPicker.vue +28 -6
  161. package/src/workspace/workspace-comments.ts +11 -151
  162. package/src/workspace/workspace-welcome.ts +1 -1
  163. package/src/documents/components/FormulaMenu.vue +0 -50
  164. package/src/files/components/FileDatabasePage.vue +0 -152
  165. package/src/files/components/FolderHomeIcon.vue +0 -12
  166. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  167. package/src/objects/components/ObjectPanel.vue +0 -554
  168. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  169. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  170. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  171. package/src/styles/object-panel.css +0 -163
  172. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  173. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  174. package/src/workspace/welcome-slogans.ts +0 -11
  175. package/src/workspace/workspace-git.ts +0 -35
  176. package/src/workspace/workspace-sync.ts +0 -46
  177. package/src/workspace/workspace-views.ts +0 -48
@@ -1,56 +1,195 @@
1
1
  <script setup lang="ts">
2
2
  import { t } from '../../i18n/i18n';
3
- import { computed, ref } from 'vue';
3
+ import { computed, ref, useId } from 'vue';
4
4
  import { CalendarPlus, Repeat2 } from 'lucide-vue-next';
5
- import { parseTaskRepeat } from '@tano/protocol';
6
- import type { WorkspaceObject } from '@tano/protocol';
5
+ import { isActionableTask, isPlanCompleted, parseTaskRepeat, validEventDate, validEventTime } from '@tano/protocol';
6
+ import type { TaskRepeatMode, WorkspaceObject } from '@tano/protocol';
7
7
  import type { ObjectRecord } from '../../objects/workspace-objects';
8
8
  import type { RepeatPreview } from '../task-repeat';
9
+ import { localDayKey } from '../calendar';
9
10
  import { useWorkspaceStore } from '../../stores/workspace';
10
- const props = defineProps<{ object: WorkspaceObject; record: ObjectRecord; disabled: boolean; dirty: boolean; workspaceId: string }>();
11
+
12
+ const props = defineProps<{
13
+ object: WorkspaceObject;
14
+ record: ObjectRecord;
15
+ disabled: boolean;
16
+ dirty: boolean;
17
+ workspaceId?: string;
18
+ personal?: boolean;
19
+ }>();
11
20
  const emit = defineEmits<{ change: [value: unknown]; openRecord: [record: ObjectRecord] }>();
12
- const store = useWorkspaceStore(), preview = ref<RepeatPreview | null>(), busy = ref(false), error = ref('');
21
+ const store = useWorkspaceStore();
22
+ const preview = ref<RepeatPreview | null>();
23
+ const busy = ref(false);
24
+ const error = ref('');
25
+ const frequencyId = useId();
26
+
27
+ const checkable = computed(() => isActionableTask(props.object));
28
+ const supportsAfterComplete = computed(() => checkable.value && !props.personal && !!props.workspaceId);
13
29
  const rule = computed(() => {
14
30
  const value = props.object.properties.repeatSourceId
15
- ? store.objects.find(record => record.object.id === props.object.properties.repeatSourceId)?.object.properties.repeat
31
+ ? store.objects.find((record) => record.object.id === props.object.properties.repeatSourceId)?.object.properties.repeat
16
32
  : props.object.properties.repeat;
17
33
  return value === undefined ? null : parseTaskRepeat(value);
18
34
  });
19
- const anchor = computed(() => String(props.object.properties.date ?? props.object.properties.due ?? ''));
35
+ const effectiveMode = computed<TaskRepeatMode>(() =>
36
+ rule.value?.mode ?? (supportsAfterComplete.value ? 'after_complete' : 'schedule'),
37
+ );
38
+ const anchor = computed(() => {
39
+ const p = props.object.properties;
40
+ if (validEventDate(p.date)) return p.date;
41
+ if (validEventTime(p.start)) return localDayKey(new Date(p.start));
42
+ if (validEventDate(p.due)) return p.due;
43
+ return '';
44
+ });
45
+
20
46
  function update(key: string, value: unknown) {
21
- preview.value = undefined; error.value = '';
22
- if (key === 'frequency' && !value) { emit('change', undefined); return; }
23
- try { emit('change', parseTaskRepeat({ version: 1, frequency: 'weekly', interval: 1, anchor: anchor.value, ...rule.value, [key]: value })); }
24
- catch (reason) { error.value = String(reason); }
47
+ preview.value = undefined;
48
+ error.value = '';
49
+ if (key === 'frequency' && !value) {
50
+ emit('change', undefined);
51
+ return;
52
+ }
53
+ try {
54
+ const baseMode: TaskRepeatMode | undefined = supportsAfterComplete.value
55
+ ? rule.value?.mode
56
+ : 'schedule';
57
+ const nextRaw: Record<string, unknown> = {
58
+ version: 1,
59
+ frequency: 'weekly',
60
+ interval: 1,
61
+ anchor: anchor.value,
62
+ ...(baseMode ? { mode: baseMode } : {}),
63
+ ...rule.value,
64
+ [key]: value,
65
+ };
66
+ if (nextRaw.until === undefined) delete nextRaw.until;
67
+ if (nextRaw.mode === undefined) delete nextRaw.mode;
68
+ emit('change', parseTaskRepeat(nextRaw));
69
+ } catch (reason) {
70
+ error.value = String(reason);
71
+ }
25
72
  }
73
+
26
74
  async function prepare() {
27
- busy.value = true; error.value = '';
28
- try { preview.value = await store.repeatPreview(props.record, props.workspaceId); if (!preview.value) error.value = t('重复规则已结束'); }
29
- catch (reason) { error.value = String(reason); }
30
- finally { busy.value = false; }
75
+ if (!props.workspaceId) return;
76
+ busy.value = true;
77
+ error.value = '';
78
+ try {
79
+ preview.value = await store.repeatPreview(props.record, props.workspaceId);
80
+ if (!preview.value) error.value = t('重复规则已结束');
81
+ } catch (reason) {
82
+ error.value = String(reason);
83
+ } finally {
84
+ busy.value = false;
85
+ }
31
86
  }
87
+
32
88
  async function create() {
33
- if (!preview.value) return;
34
- busy.value = true; error.value = '';
35
- try { emit('openRecord', await store.createRepeat(preview.value, props.workspaceId)); }
36
- catch (reason) { error.value = String(reason); }
37
- finally { busy.value = false; }
89
+ if (!preview.value || !props.workspaceId) return;
90
+ busy.value = true;
91
+ error.value = '';
92
+ try {
93
+ emit('openRecord', await store.createRepeat(preview.value, props.workspaceId));
94
+ } catch (reason) {
95
+ error.value = String(reason);
96
+ } finally {
97
+ busy.value = false;
98
+ }
38
99
  }
39
- const people = computed(() => preview.value?.relations.filter(row => row.type === 'assigned').map(row => store.objects.find(item => item.object.id === row.source.id)?.object.name ?? t('不可用')).join('、') || t('未分配'));
100
+
101
+ const people = computed(
102
+ () =>
103
+ preview.value?.relations
104
+ .filter((row) => row.type === 'assigned')
105
+ .map((row) => store.objects.find((item) => item.object.id === row.source.id)?.object.name ?? t('不可用'))
106
+ .join('、') || t('未分配'),
107
+ );
40
108
  </script>
109
+
41
110
  <template>
42
111
  <section class="task-repeat" :aria-label="t('重复任务')">
43
- <label><Repeat2 :size="14" />{{ t('重复') }}<select :value="rule?.frequency ?? ''" :disabled="disabled || busy || !!object.properties.repeatSourceId" @change="update('frequency', ($event.target as HTMLSelectElement).value)"><option value="">{{ t('不重复') }}</option><option value="daily">{{ t('每天') }}</option><option value="weekly">{{ t('每周') }}</option><option value="monthly">{{ t('每月') }}</option></select></label>
44
- <template v-if="rule"><label>{{ t('间隔') }}<input type="number" min="1" max="99" :value="rule.interval" :disabled="disabled || busy || !!object.properties.repeatSourceId" @change="update('interval', Number(($event.target as HTMLInputElement).value))" /></label><label>{{ t('结束日期') }}<input type="date" :value="rule.until ?? ''" :disabled="disabled || busy || !!object.properties.repeatSourceId" @change="update('until', ($event.target as HTMLInputElement).value || undefined)" /></label><button type="button" :disabled="disabled || dirty || busy || object.properties.completed !== true" @click="prepare"><CalendarPlus :size="14" />{{ t('预览下一次') }}</button></template>
45
- <div v-if="preview" class="repeat-preview"><strong>{{ preview.object.name }}</strong><span>{{ t('下一次:') }}{{ preview.object.properties.date ?? preview.object.properties.due }}</span><span>{{ t('负责人:') }}{{ people }}</span><span>{{ t('关联:') }}{{ preview.relations.length }} {{ t('项') }}</span><div><button type="button" :disabled="disabled || dirty || busy" @click="create">{{ t('确认创建下一次') }}</button><button type="button" :disabled="busy" @click="preview = undefined">{{ t('取消') }}</button></div></div>
112
+ <label class="task-repeat-label" :for="frequencyId"><Repeat2 :size="15" />{{ t('重复') }}</label>
113
+ <div class="task-repeat-body">
114
+ <select
115
+ :id="frequencyId"
116
+ :class="{ 'is-empty': !rule }"
117
+ :value="rule?.frequency ?? ''"
118
+ :disabled="disabled || busy || !!object.properties.repeatSourceId"
119
+ @change="update('frequency', ($event.target as HTMLSelectElement).value)"
120
+ >
121
+ <option value="">{{ t('不重复') }}</option>
122
+ <option value="daily">{{ t('每天') }}</option>
123
+ <option value="weekly">{{ t('每周') }}</option>
124
+ <option value="monthly">{{ t('每月') }}</option>
125
+ </select>
126
+ <template v-if="rule">
127
+ <label v-if="supportsAfterComplete">
128
+ {{ t('重复模式') }}
129
+ <select
130
+ :value="effectiveMode"
131
+ :disabled="disabled || busy || !!object.properties.repeatSourceId"
132
+ @change="update('mode', ($event.target as HTMLSelectElement).value)"
133
+ >
134
+ <option value="after_complete">{{ t('完成后生成下一次') }}</option>
135
+ <option value="schedule">{{ t('按日程规律重复') }}</option>
136
+ </select>
137
+ </label>
138
+ <label>
139
+ {{ t('间隔') }}
140
+ <input
141
+ type="number"
142
+ min="1"
143
+ max="99"
144
+ :value="rule.interval"
145
+ :disabled="disabled || busy || !!object.properties.repeatSourceId"
146
+ @change="update('interval', Number(($event.target as HTMLInputElement).value))"
147
+ />
148
+ </label>
149
+ <label>
150
+ {{ t('结束日期') }}
151
+ <input
152
+ type="date"
153
+ :value="rule.until ?? ''"
154
+ :disabled="disabled || busy || !!object.properties.repeatSourceId"
155
+ @change="update('until', ($event.target as HTMLInputElement).value || undefined)"
156
+ />
157
+ </label>
158
+ <button
159
+ v-if="supportsAfterComplete && effectiveMode === 'after_complete'"
160
+ type="button"
161
+ :disabled="disabled || dirty || busy || !isPlanCompleted(object)"
162
+ @click="prepare"
163
+ >
164
+ <CalendarPlus :size="14" />{{ t('预览下一次') }}
165
+ </button>
166
+ </template>
167
+ <div v-if="preview" class="repeat-preview">
168
+ <strong>{{ preview.object.name }}</strong>
169
+ <span>{{ t('下一次:') }}{{ preview.object.properties.date ?? preview.object.properties.due }}</span>
170
+ <span>{{ t('负责人:') }}{{ people }}</span>
171
+ <span>{{ t('关联:') }}{{ preview.relations.length }} {{ t('项') }}</span>
172
+ <div>
173
+ <button type="button" :disabled="disabled || dirty || busy" @click="create">{{ t('确认创建下一次') }}</button>
174
+ <button type="button" :disabled="busy" @click="preview = undefined">{{ t('取消') }}</button>
175
+ </div>
176
+ </div>
46
177
  <p v-if="error" role="alert">{{ error }}</p>
178
+ </div>
47
179
  </section>
48
180
  </template>
181
+
49
182
  <style scoped>
50
- .task-repeat { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 18px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; font-size: 12px; }
51
- label { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
52
- select, input { min-height: 30px; max-width: 150px; min-width: 0; border: 1px solid var(--line); border-radius: 5px; padding: 4px 7px; background: var(--paper); color: var(--text); font: inherit; }
53
- input[type=number] { width: 56px; } button { display: inline-flex; gap: 5px; align-items: center; font: inherit; color: var(--green); }
54
- .repeat-preview { display: grid; gap: 8px; flex-basis: 100%; padding: 12px 0; border-top: 1px solid var(--line); }
55
- .repeat-preview > div { display: flex; gap: 16px; } p { margin: 0; color: var(--danger); flex-basis: 100%; overflow-wrap: anywhere; }
183
+ /* Laid out as one row of the detail panel's property list: label column + controls. */
184
+ .task-repeat { display: grid; grid-template-columns: var(--plan-row-label, 104px) minmax(0, 1fr); column-gap: 12px; align-items: start; font-size: 13px; }
185
+ .task-repeat-label { display: flex; align-items: center; gap: 8px; min-height: 32px; color: var(--muted); }
186
+ .task-repeat-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
187
+ .task-repeat-body > label { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; }
188
+ input[type=number] { width: 64px; }
189
+ button { display: inline-flex; gap: 5px; align-items: center; min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12px; color: var(--text-secondary); }
190
+ button:hover:not(:disabled) { border-color: var(--control-border); background: var(--hover); color: var(--text); }
191
+ .repeat-preview { display: grid; gap: 6px; flex-basis: 100%; padding: 10px 12px; border-radius: 8px; background: var(--surface); font-size: 12px; }
192
+ .repeat-preview > div { display: flex; gap: 8px; margin-top: 4px; }
193
+ p { margin: 0; color: var(--danger); flex-basis: 100%; font-size: 12px; overflow-wrap: anywhere; }
194
+ @media (max-width: 420px) { .task-repeat { grid-template-columns: minmax(0, 1fr); } }
56
195
  </style>
@@ -0,0 +1,149 @@
1
+ import { validEventDate, validEventTime } from '@tano/protocol';
2
+ import type { ObjectRecord } from '../objects/workspace-objects';
3
+ import { isEventCompleted } from './calendar';
4
+ import { planKey } from './personal-plans';
5
+
6
+ export const REMINDER_STORAGE_KEY = 'tano.plan-reminders.fired.v1';
7
+ export const REMINDER_PRESETS = [0, 10, 30, 60, 1440] as const;
8
+ const DEFAULT_GRACE_MS = 5 * 60_000;
9
+ const RETENTION_MS = 30 * 86_400_000;
10
+
11
+ export interface PendingReminder {
12
+ key: string;
13
+ record: ObjectRecord;
14
+ offsetMinutes: number;
15
+ fireAt: number;
16
+ anchorMs: number;
17
+ }
18
+
19
+ export function extractReminders(properties: Record<string, unknown>): number[] {
20
+ if (!Array.isArray(properties.reminders)) return [];
21
+ return [...new Set(
22
+ properties.reminders.filter(
23
+ (item): item is number => typeof item === 'number' && Number.isInteger(item) && item >= 0 && item <= 43200,
24
+ ),
25
+ )].sort((a, b) => a - b);
26
+ }
27
+
28
+ export function reminderAnchorMs(record: ObjectRecord): number | null {
29
+ const p = record.object.properties;
30
+ if (validEventTime(p.start)) {
31
+ if (p.allDay === true) {
32
+ const d = new Date(p.start);
33
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 9, 0, 0).getTime();
34
+ }
35
+ return Date.parse(p.start);
36
+ }
37
+ if (validEventDate(p.date)) {
38
+ return new Date(`${p.date}T09:00:00`).getTime();
39
+ }
40
+ if (validEventDate(p.due)) {
41
+ return new Date(`${p.due}T09:00:00`).getTime();
42
+ }
43
+ return null;
44
+ }
45
+
46
+ export function computePendingReminders(
47
+ records: readonly ObjectRecord[],
48
+ nowMs: number,
49
+ firedKeys: ReadonlySet<string>,
50
+ graceWindowMs = DEFAULT_GRACE_MS,
51
+ ): PendingReminder[] {
52
+ const due: PendingReminder[] = [];
53
+ for (const record of records) {
54
+ if (record.object.archived || isEventCompleted(record)) continue;
55
+ const offsets = extractReminders(record.object.properties);
56
+ if (!offsets.length) continue;
57
+ const anchorMs = reminderAnchorMs(record);
58
+ if (anchorMs === null) continue;
59
+ const baseKey = planKey(record);
60
+ for (const offsetMinutes of offsets) {
61
+ const fireAt = anchorMs - offsetMinutes * 60_000;
62
+ if (fireAt > nowMs || nowMs - fireAt > graceWindowMs) continue;
63
+ const key = `${baseKey}:${anchorMs}:${offsetMinutes}`;
64
+ if (firedKeys.has(key)) continue;
65
+ due.push({ key, record, offsetMinutes, fireAt, anchorMs });
66
+ }
67
+ }
68
+ return due.sort((a, b) => a.fireAt - b.fireAt);
69
+ }
70
+
71
+ export interface LocalReminderOptions {
72
+ storage?: Pick<Storage, 'getItem' | 'setItem'>;
73
+ onRemind?: (item: PendingReminder) => void;
74
+ notify?: (title: string, body: string) => void;
75
+ }
76
+
77
+ /**
78
+ * In-app/app-data local reminder tracker. Fired history stays in localStorage
79
+ * (application data) and never writes back to workspace files.
80
+ */
81
+ export class LocalReminderScheduler {
82
+ private fired = new Map<string, number>();
83
+ private storage?: Pick<Storage, 'getItem' | 'setItem'>;
84
+ private onRemind?: (item: PendingReminder) => void;
85
+ private notify?: (title: string, body: string) => void;
86
+
87
+ constructor(options: LocalReminderOptions = {}) {
88
+ this.storage = options.storage ?? (typeof localStorage !== 'undefined' ? localStorage : undefined);
89
+ this.onRemind = options.onRemind;
90
+ this.notify = options.notify;
91
+ this.load();
92
+ }
93
+
94
+ private load() {
95
+ if (!this.storage) return;
96
+ try {
97
+ const raw = this.storage.getItem(REMINDER_STORAGE_KEY);
98
+ if (!raw) return;
99
+ const parsed = JSON.parse(raw) as Record<string, number>;
100
+ if (parsed && typeof parsed === 'object') {
101
+ for (const [k, v] of Object.entries(parsed)) {
102
+ if (typeof v === 'number' && Number.isFinite(v)) this.fired.set(k, v);
103
+ }
104
+ }
105
+ } catch {
106
+ /* ignore corrupt reminder cache */
107
+ }
108
+ }
109
+
110
+ private save(nowMs: number) {
111
+ for (const [key, firedAt] of this.fired) {
112
+ if (nowMs - firedAt > RETENTION_MS) this.fired.delete(key);
113
+ }
114
+ if (!this.storage) return;
115
+ try {
116
+ this.storage.setItem(REMINDER_STORAGE_KEY, JSON.stringify(Object.fromEntries(this.fired)));
117
+ } catch {
118
+ /* storage quota full — keep in-memory dedupe */
119
+ }
120
+ }
121
+
122
+ check(records: readonly ObjectRecord[], nowMs = Date.now()): PendingReminder[] {
123
+ const items = computePendingReminders(records, nowMs, new Set(this.fired.keys()));
124
+ if (!items.length) return [];
125
+ for (const item of items) {
126
+ this.fired.set(item.key, nowMs);
127
+ this.onRemind?.(item);
128
+ const body =
129
+ item.offsetMinutes === 0
130
+ ? '现在开始'
131
+ : item.offsetMinutes >= 1440
132
+ ? `提前 ${Math.round(item.offsetMinutes / 1440)} 天提醒`
133
+ : item.offsetMinutes >= 60
134
+ ? `提前 ${Math.round(item.offsetMinutes / 60)} 小时提醒`
135
+ : `提前 ${item.offsetMinutes} 分钟提醒`;
136
+ if (this.notify) {
137
+ this.notify(item.record.object.name, body);
138
+ } else if (typeof Notification !== 'undefined' && Notification.permission === 'granted') {
139
+ try {
140
+ new Notification(item.record.object.name, { body });
141
+ } catch {
142
+ /* ignore notification delivery failure */
143
+ }
144
+ }
145
+ }
146
+ this.save(nowMs);
147
+ return items;
148
+ }
149
+ }
@@ -6,10 +6,19 @@ import type { ObjectRecord, ObjectStorage } from '../objects/workspace-objects';
6
6
  import { t } from '../i18n/i18n';
7
7
 
8
8
  export const PERSONAL_PLANS_KEY = 'tano.personal-plans.v1';
9
- export const planKey = (record: ObjectRecord) =>
9
+ export const sourcePlanKey = (record: ObjectRecord) =>
10
10
  record.source?.scope === 'personal'
11
11
  ? `personal:${record.source.id}:${record.object.id}`
12
12
  : record.object.id;
13
+ export const planKey = (record: ObjectRecord) => {
14
+ const base = sourcePlanKey(record);
15
+ const occurrence =
16
+ record.object.properties.repeatVirtual === true &&
17
+ typeof record.object.properties.repeatOccurrence === 'string'
18
+ ? record.object.properties.repeatOccurrence
19
+ : '';
20
+ return occurrence ? `${base}@${occurrence}` : base;
21
+ };
13
22
  export const planSourceLabel = (record: ObjectRecord) =>
14
23
  record.source?.scope === 'personal' ? t('个人') : (record.source?.name ?? t('工作区'));
15
24
 
@@ -9,7 +9,13 @@ export interface PlanDateValue {
9
9
  end: string;
10
10
  }
11
11
  export function readPlanDate(properties: Record<string, unknown>): PlanDateValue {
12
- if (validEventDate(properties.date)) return { date: properties.date, time: '', end: '' };
12
+ if (validEventDate(properties.date)) {
13
+ return {
14
+ date: properties.date,
15
+ time: '',
16
+ end: validEventDate(properties.endDate) ? properties.endDate : '',
17
+ };
18
+ }
13
19
  if (validEventTime(properties.start)) {
14
20
  const start = localDateTime(new Date(properties.start));
15
21
  if (properties.allDay === true && validEventTime(properties.end)) {
@@ -29,6 +35,7 @@ export function readPlanDate(properties: Record<string, unknown>): PlanDateValue
29
35
  export function writePlanDate(properties: Record<string, unknown>, value: PlanDateValue) {
30
36
  const result = { ...properties };
31
37
  delete result.date;
38
+ delete result.endDate;
32
39
  delete result.start;
33
40
  delete result.end;
34
41
  delete result.allDay;
@@ -0,0 +1,95 @@
1
+ import { isActionableTask, isPlanCompleted, parseTaskRepeat } from '@tano/protocol';
2
+ import type { WorkspaceObject } from '@tano/protocol';
3
+ import type { ObjectRecord } from '../objects/workspace-objects';
4
+ import type { PlanScope } from '../stores/plans';
5
+
6
+ const STRIPPED_KEYS = [
7
+ 'syncConnection',
8
+ 'syncRemoteId',
9
+ 'syncReadOnly',
10
+ 'syncConflictCopy',
11
+ 'deliveryReview',
12
+ 'repeatSourceId',
13
+ 'repeatOccurrence',
14
+ 'repeatVirtual',
15
+ ] as const;
16
+
17
+ export interface PlanMigrationResult {
18
+ created: ObjectRecord;
19
+ archivedSource: boolean;
20
+ warning?: string;
21
+ }
22
+
23
+ export function prepareMigratedObject(
24
+ source: WorkspaceObject,
25
+ targetScope: PlanScope,
26
+ ): Pick<WorkspaceObject, 'type' | 'name' | 'description' | 'archived' | 'properties'> {
27
+ const properties: Record<string, unknown> = JSON.parse(JSON.stringify(source.properties));
28
+ for (const key of STRIPPED_KEYS) delete properties[key];
29
+
30
+ // Canonicalize legacy `task` -> `event` with `checkable: true` on migration.
31
+ const checkable = isActionableTask(source);
32
+ const completed = isPlanCompleted(source);
33
+ properties.checkable = checkable;
34
+ properties.completed = completed;
35
+
36
+ // Personal scope only runs calendar schedule recurrence, not workspace after_complete instances.
37
+ if (targetScope === 'personal' && properties.repeat !== undefined) {
38
+ try {
39
+ const rule = parseTaskRepeat(properties.repeat);
40
+ if (rule.mode !== 'schedule') {
41
+ properties.repeat = { ...rule, mode: 'schedule' };
42
+ }
43
+ } catch {
44
+ delete properties.repeat;
45
+ }
46
+ }
47
+
48
+ return {
49
+ type: 'event',
50
+ name: source.name,
51
+ description: source.description,
52
+ archived: false,
53
+ properties,
54
+ };
55
+ }
56
+
57
+ /**
58
+ * Moves a plan item between Personal and Workspace safely:
59
+ * 1. Create the cleaned copy in the destination scope.
60
+ * 2. Archive the original record only after creation succeeds.
61
+ * If archiving fails, the newly created copy is preserved and a warning is returned.
62
+ */
63
+ export async function movePlanBetweenScopes(
64
+ record: ObjectRecord,
65
+ targetScope: PlanScope,
66
+ ports: {
67
+ workspaceId?: string;
68
+ create: (
69
+ value: Pick<WorkspaceObject, 'type' | 'name' | 'description' | 'archived' | 'properties'>,
70
+ scope: PlanScope,
71
+ workspaceId?: string,
72
+ ) => Promise<ObjectRecord>;
73
+ archive: (source: ObjectRecord) => Promise<unknown>;
74
+ },
75
+ ): Promise<PlanMigrationResult> {
76
+ const currentScope: PlanScope = record.source?.scope === 'personal' ? 'personal' : 'workspace';
77
+ if (currentScope === targetScope) {
78
+ throw new Error('事项已在目标空间中');
79
+ }
80
+ if (targetScope === 'workspace' && !ports.workspaceId) {
81
+ throw new Error('请先打开目标工作区');
82
+ }
83
+ const payload = prepareMigratedObject(record.object, targetScope);
84
+ const created = await ports.create(payload, targetScope, ports.workspaceId);
85
+ try {
86
+ await ports.archive(record);
87
+ return { created, archivedSource: true };
88
+ } catch (reason) {
89
+ return {
90
+ created,
91
+ archivedSource: false,
92
+ warning: `已复制到目标空间,但原记录归档失败:${String(reason)}`,
93
+ };
94
+ }
95
+ }
@@ -0,0 +1,95 @@
1
+ import ICAL from 'ical.js';
2
+ import { parseTaskRepeat, validEventDate, validEventTime } from '@tano/protocol';
3
+ import type { ObjectRecord } from '../objects/workspace-objects';
4
+ import { localDayKey } from './calendar';
5
+ import { moveRecordToDay } from './calendar-interaction';
6
+
7
+ const MAX_OCCURRENCES_PER_SERIES = 400;
8
+
9
+ function baseDayKey(record: ObjectRecord): string | null {
10
+ const p = record.object.properties;
11
+ if (validEventDate(p.date)) return p.date;
12
+ if (validEventTime(p.start)) return localDayKey(new Date(p.start));
13
+ if (validEventDate(p.due)) return p.due;
14
+ return null;
15
+ }
16
+
17
+ export function isVirtualOccurrence(record: ObjectRecord): boolean {
18
+ return record.object.properties.repeatVirtual === true;
19
+ }
20
+
21
+ /**
22
+ * Expands `repeat.mode === 'schedule'` series within `[windowStart, windowEnd]`
23
+ * into lightweight virtual occurrence records without duplicating files on disk.
24
+ */
25
+ export function expandRecurringPlans(
26
+ records: readonly ObjectRecord[],
27
+ windowStart: Date,
28
+ windowEnd: Date,
29
+ ): ObjectRecord[] {
30
+ const startKey = localDayKey(windowStart);
31
+ const endKey = localDayKey(windowEnd);
32
+ if (endKey < startKey) return [...records];
33
+
34
+ const materializedOverrides = new Set<string>();
35
+ for (const record of records) {
36
+ const src = record.object.properties.repeatSourceId;
37
+ const occ = record.object.properties.repeatOccurrence;
38
+ if (typeof src === 'string' && validEventDate(occ)) {
39
+ materializedOverrides.add(`${record.source?.scope ?? 'workspace'}:${record.source?.id ?? ''}:${src}:${occ}`);
40
+ }
41
+ }
42
+
43
+ const expanded: ObjectRecord[] = [...records];
44
+
45
+ for (const record of records) {
46
+ if (record.object.archived) continue;
47
+ if (record.object.properties.repeat === undefined) continue;
48
+ if (record.object.properties.repeatSourceId !== undefined) continue;
49
+ let rule;
50
+ try {
51
+ rule = parseTaskRepeat(record.object.properties.repeat);
52
+ } catch {
53
+ continue;
54
+ }
55
+ if (rule.mode !== 'schedule') continue;
56
+
57
+ const originKey = baseDayKey(record);
58
+ const exdates = new Set(rule.exdates ?? []);
59
+ const frequency = { daily: 'DAILY', weekly: 'WEEKLY', monthly: 'MONTHLY' }[rule.frequency];
60
+ const recur = ICAL.Recur.fromString(`FREQ=${frequency};INTERVAL=${rule.interval}`);
61
+ const iterator = recur.iterator(ICAL.Time.fromDateString(rule.anchor));
62
+ const scopePrefix = `${record.source?.scope ?? 'workspace'}:${record.source?.id ?? ''}:${record.object.id}:`;
63
+
64
+ let produced = 0;
65
+ for (let step = 0; step < 20_000 && produced < MAX_OCCURRENCES_PER_SERIES; step++) {
66
+ const next = iterator.next();
67
+ if (!next) break;
68
+ const dateKey = next.toString();
69
+ if (rule.until && dateKey > rule.until) break;
70
+ if (dateKey > endKey) break;
71
+ if (dateKey < startKey) continue;
72
+ if (dateKey === originKey) continue;
73
+ if (exdates.has(dateKey)) continue;
74
+ if (materializedOverrides.has(`${scopePrefix}${dateKey}`)) continue;
75
+
76
+ const targetDate = new Date(`${dateKey}T00:00:00`);
77
+ const moved = moveRecordToDay(record.object, targetDate);
78
+ expanded.push({
79
+ ...record,
80
+ object: {
81
+ ...moved,
82
+ properties: {
83
+ ...moved.properties,
84
+ repeatSourceId: record.object.id,
85
+ repeatOccurrence: dateKey,
86
+ repeatVirtual: true,
87
+ },
88
+ },
89
+ });
90
+ produced++;
91
+ }
92
+ }
93
+
94
+ return expanded;
95
+ }
@@ -1,5 +1,5 @@
1
1
  import ICAL from 'ical.js';
2
- import { parseTaskRepeat, referenceKey, validateObjectProperties, validEventDate } from '@tano/protocol';
2
+ import { isPlanCompleted, parseTaskRepeat, referenceKey, validateObjectProperties, validEventDate, withPlanCompleted } from '@tano/protocol';
3
3
  import type { WorkspaceObject, WorkspaceRelation } from '@tano/protocol';
4
4
  import type { ObjectRecord } from '../objects/workspace-objects';
5
5
  import { assistantHash } from '../assistant/hash';
@@ -27,20 +27,20 @@ export async function previewTaskRepeat(record: ObjectRecord, relations: Workspa
27
27
  if (series.object.archived || series.object.properties.repeat === undefined) throw new Error('来源任务已停止重复或归档');
28
28
  const base: WorkspaceObject = { ...record.object, properties: { ...record.object.properties, repeat: series.object.properties.repeat } };
29
29
  validateObjectProperties(base.type, base.properties);
30
- if (base.archived || base.properties.syncReadOnly === true || base.properties.completed !== true) throw new Error('请先完成当前任务,再创建下一次');
30
+ if (base.archived || base.properties.syncReadOnly === true || !isPlanCompleted(base)) throw new Error('请先完成当前任务,再创建下一次');
31
31
  const date = nextRepeatDate(base);
32
32
  if (!date) return null;
33
33
  const sourceId = String(base.properties.repeatSourceId ?? base.id);
34
34
  const id = (await assistantHash(`tano-repeat:${sourceId}:${date}`)).slice(0, 6);
35
- const properties = { ...base.properties, completed: false, repeatSourceId: sourceId, repeatOccurrence: date };
36
- for (const key of ['syncConnection', 'syncRemoteId', 'syncReadOnly', 'syncConflictCopy', 'deliveryReview', 'start', 'end']) delete (properties as Record<string, unknown>)[key];
37
- if (base.properties.date) (properties as Record<string, unknown>).date = date;
38
- else (properties as Record<string, unknown>).due = date;
35
+ const reset = withPlanCompleted({ ...base, properties: { ...base.properties, deliveryReview: undefined } }, false);
36
+ const properties: Record<string, unknown> = { ...reset.properties, repeatSourceId: sourceId, repeatOccurrence: date };
37
+ for (const key of ['syncConnection', 'syncRemoteId', 'syncReadOnly', 'syncConflictCopy', 'deliveryReview', 'start', 'end']) delete properties[key];
38
+ if (base.properties.date) properties.date = date;
39
+ else properties.due = date;
39
40
  if (base.properties.date && base.properties.due) {
40
41
  const offset = Date.parse(`${base.properties.due}T00:00:00Z`) - Date.parse(`${base.properties.date}T00:00:00Z`);
41
- (properties as Record<string, unknown>).due = new Date(Date.parse(`${date}T00:00:00Z`) + offset).toISOString().slice(0, 10);
42
+ properties.due = new Date(Date.parse(`${date}T00:00:00Z`) + offset).toISOString().slice(0, 10);
42
43
  }
43
- if (base.type === 'task') (properties as Record<string, unknown>).status = 'todo';
44
44
  const object = { ...base, id, properties };
45
45
  validateObjectProperties(object.type, object.properties);
46
46
  const linked = repeatRelations(base, relations);