@tano.page/workbench 0.14.0 → 0.16.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 (248) hide show
  1. package/package.json +50 -16
  2. package/src/App.vue +82 -752
  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/agent-identities.ts +1 -97
  17. package/src/assistant/agent-task-context.ts +1 -54
  18. package/src/assistant/attachments.ts +1 -1
  19. package/src/assistant/completion.ts +1 -61
  20. package/src/assistant/components/AssistantChangeList.vue +98 -21
  21. package/src/assistant/components/AssistantPanel.vue +425 -8
  22. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  23. package/src/assistant/connection-actions.ts +237 -0
  24. package/src/assistant/document-mentions.ts +1 -33
  25. package/src/assistant/engine.ts +1 -532
  26. package/src/assistant/execution.ts +6 -33
  27. package/src/assistant/files.ts +5 -13
  28. package/src/assistant/hash.ts +1 -4
  29. package/src/assistant/inbox.ts +1 -148
  30. package/src/assistant/language.ts +10 -37
  31. package/src/assistant/mention-autocomplete.ts +69 -0
  32. package/src/assistant/plugin-bridge-builder.ts +146 -0
  33. package/src/assistant/prompts.ts +1 -58
  34. package/src/assistant/proposal-actions.ts +336 -0
  35. package/src/assistant/results.ts +20 -86
  36. package/src/assistant/store.ts +167 -327
  37. package/src/assistant/structures.ts +1 -155
  38. package/src/assistant/tasks.ts +8 -96
  39. package/src/assistant/tool-rules.ts +1 -7
  40. package/src/assistant/workspace-bridge.ts +1 -1
  41. package/src/composables/use-document-actions.ts +38 -20
  42. package/src/composables/use-file-tree-controller.ts +7 -12
  43. package/src/composables/use-workbench-help.ts +177 -0
  44. package/src/composables/use-workbench-history.ts +2 -4
  45. package/src/composables/use-workbench-lifecycle.ts +249 -0
  46. package/src/composables/use-workbench-modals.ts +6 -1
  47. package/src/composables/use-workbench-outline.ts +0 -5
  48. package/src/composables/use-workbench-settings.ts +185 -0
  49. package/src/composables/use-workbench-shortcuts.ts +40 -1021
  50. package/src/composables/use-workbench-views.ts +325 -0
  51. package/src/data-tables/data-tables.ts +1 -2
  52. package/src/documents/components/DocumentActionMenu.vue +279 -0
  53. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  54. package/src/documents/components/DocumentInspector.vue +168 -0
  55. package/src/documents/components/DocumentPane.vue +482 -0
  56. package/src/documents/description-merge.ts +1 -9
  57. package/src/features.ts +1 -0
  58. package/src/files/components/FileMetadataPanel.vue +49 -15
  59. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  60. package/src/fonts/Inter-Latin.woff2 +0 -0
  61. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  62. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  63. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  64. package/src/help/help-milestones.ts +3 -5
  65. package/src/i18n/locale-catalogs.ts +7 -6
  66. package/src/i18n/locale-registry.ts +8 -6
  67. package/src/i18n/locales/de-DE.json +371 -3
  68. package/src/i18n/locales/en-US.json +371 -2
  69. package/src/i18n/locales/es-ES.json +371 -3
  70. package/src/i18n/locales/ja-JP.json +370 -2
  71. package/src/i18n/locales/zh-TW.json +370 -2
  72. package/src/mail/components/MailAccountDialog.vue +450 -0
  73. package/src/mail/components/MailComposerDialog.vue +326 -0
  74. package/src/mail/components/MailProviderIcon.vue +30 -0
  75. package/src/mail/components/MailWorkspaceView.vue +821 -0
  76. package/src/mail/components/SidebarMail.vue +134 -0
  77. package/src/mail/mail-avatar.ts +17 -0
  78. package/src/mail/mail-bridge.ts +68 -0
  79. package/src/mail/mail-calendar.ts +208 -0
  80. package/src/mail/mail-markdown.ts +195 -0
  81. package/src/mail/types.ts +226 -0
  82. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  83. package/src/objects/content-references.ts +6 -56
  84. package/src/objects/wiki-links.ts +1 -48
  85. package/src/objects/workspace-objects.ts +3 -4
  86. package/src/plan-sync/types.ts +6 -3
  87. package/src/plans/calendar-interaction.ts +194 -0
  88. package/src/plans/calendar.ts +65 -9
  89. package/src/plans/components/CalendarAgendaView.vue +165 -0
  90. package/src/plans/components/CalendarDayPopover.vue +172 -39
  91. package/src/plans/components/CalendarFilterBar.vue +128 -0
  92. package/src/plans/components/CalendarMonthView.vue +224 -0
  93. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  94. package/src/plans/components/CalendarTimelineView.vue +517 -0
  95. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  96. package/src/plans/components/CalendarView.vue +264 -748
  97. package/src/plans/components/CalendarYearView.vue +138 -0
  98. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  99. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  100. package/src/plans/components/PlanDateField.vue +6 -4
  101. package/src/plans/components/PlanDetailPanel.vue +227 -32
  102. package/src/plans/components/PlanEventList.vue +16 -4
  103. package/src/plans/components/SidebarPlan.vue +22 -15
  104. package/src/plans/components/TaskRepeatControls.vue +169 -30
  105. package/src/plans/components/calendar-shared.css +192 -0
  106. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  107. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  108. package/src/plans/local-reminders.ts +149 -0
  109. package/src/plans/personal-plans.ts +10 -1
  110. package/src/plans/plan-date.ts +8 -1
  111. package/src/plans/plan-migration.ts +95 -0
  112. package/src/plans/recurrence.ts +95 -0
  113. package/src/plans/task-repeat.ts +8 -8
  114. package/src/plans/timeline-layout.ts +92 -0
  115. package/src/plugins/assistant-bridge.ts +520 -0
  116. package/src/plugins/attachment-reader.ts +3 -1
  117. package/src/plugins/cache-storage.ts +42 -2
  118. package/src/plugins/components/PluginAutomations.vue +3 -3
  119. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  120. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  121. package/src/plugins/components/PluginConnections.vue +1 -1
  122. package/src/plugins/components/PluginCustomView.vue +2 -2
  123. package/src/plugins/components/PluginDetailPage.vue +136 -57
  124. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  125. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  126. package/src/plugins/components/PluginExplorer.vue +21 -25
  127. package/src/plugins/components/PluginImportDialog.vue +410 -0
  128. package/src/plugins/components/PluginInstaller.vue +273 -288
  129. package/src/plugins/components/PluginListItem.vue +3 -0
  130. package/src/plugins/components/PluginMaintenance.vue +37 -34
  131. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  132. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  133. package/src/plugins/components/PluginSettingsForm.vue +112 -0
  134. package/src/plugins/components/PluginStatusBar.vue +161 -0
  135. package/src/plugins/components/PluginSurface.vue +18 -6
  136. package/src/plugins/components/PluginUiDialog.vue +452 -0
  137. package/src/plugins/components/PluginsTabPage.vue +61 -0
  138. package/src/plugins/components/plugin-center.css +5 -0
  139. package/src/plugins/data.ts +9 -86
  140. package/src/plugins/editor-plugin-adapters.ts +169 -0
  141. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  142. package/src/plugins/excalidraw/manifest.json +12 -1
  143. package/src/plugins/host.ts +662 -43
  144. package/src/plugins/native.ts +2 -10
  145. package/src/plugins/overlay-mapping.ts +125 -0
  146. package/src/plugins/packages.ts +73 -1
  147. package/src/plugins/plugin-data.ts +2 -3
  148. package/src/plugins/plugin-permissions.ts +57 -0
  149. package/src/plugins/plugin-rpc-router.ts +558 -0
  150. package/src/plugins/plugin-sdk.ts +1 -94
  151. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  152. package/src/plugins/policy.ts +53 -3
  153. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  154. package/src/plugins/presentation-preview/manifest.json +2 -1
  155. package/src/plugins/queries.ts +1 -73
  156. package/src/plugins/sandbox.ts +15 -1
  157. package/src/plugins/use-plugin-actions.ts +67 -20
  158. package/src/plugins/user-plugins.ts +254 -0
  159. package/src/plugins/view-header.ts +2 -7
  160. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  161. package/src/plugins/word-preview/manifest.json +13 -1
  162. package/src/plugins/workbench.ts +175 -2
  163. package/src/plugins/worker.js +105 -8
  164. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  165. package/src/plugins/workspace-plugins.ts +212 -21
  166. package/src/runtime.ts +103 -4
  167. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  168. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  169. package/src/settings/components/SettingsPanel.vue +8 -3
  170. package/src/settings/components/WorkbenchSettings.vue +20 -7
  171. package/src/settings/components/settings-context.ts +1 -1
  172. package/src/settings/components/settings-search.ts +2 -3
  173. package/src/settings/settings-tab.ts +1 -0
  174. package/src/shell/command-palette.ts +3 -3
  175. package/src/shell/components/EditorToolbar.vue +8 -9
  176. package/src/shell/components/EditorTools.vue +1 -5
  177. package/src/shell/components/PaneTopbar.vue +393 -0
  178. package/src/shell/components/SelectionToolbar.vue +0 -2
  179. package/src/shell/components/SidebarNavigation.vue +22 -2
  180. package/src/shell/components/WorkbenchContextMenus.vue +58 -34
  181. package/src/shell/components/WorkbenchModals.vue +47 -62
  182. package/src/shell/components/WorkbenchPanes.vue +371 -1342
  183. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  184. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  185. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  186. package/src/shell/pane-registry.ts +69 -0
  187. package/src/shell/use-surface-dismissal.ts +219 -0
  188. package/src/shell/use-workbench-commands.ts +599 -0
  189. package/src/shell/use-workbench-keybindings.ts +337 -0
  190. package/src/shell/use-workbench.ts +531 -1153
  191. package/src/shell/workbench-async-components.ts +14 -5
  192. package/src/shell/workbench-context.ts +30 -3
  193. package/src/stores/mail.ts +414 -0
  194. package/src/stores/plan-sync.ts +2 -1
  195. package/src/stores/plans.ts +2 -9
  196. package/src/stores/workspace-document-io.ts +807 -0
  197. package/src/stores/workspace-file-ops.ts +1 -1
  198. package/src/stores/workspace-knowledge.ts +2 -114
  199. package/src/stores/workspace-lifecycle.ts +459 -0
  200. package/src/stores/workspace-plugins-state.ts +254 -259
  201. package/src/stores/workspace-session.ts +287 -0
  202. package/src/stores/workspace-tabs-layout.ts +6 -44
  203. package/src/stores/workspace-types.ts +50 -0
  204. package/src/stores/workspace.ts +184 -1363
  205. package/src/styles/agent-diff-modals.css +0 -7
  206. package/src/styles/dark-theme.css +3 -3
  207. package/src/styles/inspector.css +0 -59
  208. package/src/styles/layout-themes.css +346 -0
  209. package/src/styles/mail.css +1568 -0
  210. package/src/styles/mobile.css +2 -2
  211. package/src/styles/recent-and-media.css +0 -17
  212. package/src/styles/theme-contract.css +3 -3
  213. package/src/styles/workbench-shell.css +110 -17
  214. package/src/styles/workspace-states.css +9 -33
  215. package/src/styles.css +0 -1
  216. package/src/tabs/components/DesktopTabs.vue +19 -14
  217. package/src/tabs/components/NewTabPicker.vue +10 -4
  218. package/src/tabs/tab-label.ts +0 -1
  219. package/src/windows/AuxiliaryWindows.vue +2 -2
  220. package/src/windows/use-window-event-bridge.ts +152 -0
  221. package/src/workspace/components/TemplateLibrary.vue +1 -1
  222. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  223. package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
  224. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  225. package/src/workspace/workspace-comments.ts +11 -151
  226. package/src/workspace/workspace-welcome.ts +1 -1
  227. package/src/assistant/locales/de-DE.json +0 -126
  228. package/src/assistant/locales/en-US.json +0 -126
  229. package/src/assistant/locales/es-ES.json +0 -126
  230. package/src/assistant/locales/ja-JP.json +0 -126
  231. package/src/assistant/locales/zh-CN.json +0 -126
  232. package/src/assistant/locales/zh-TW.json +0 -126
  233. package/src/assistant/task-prompts.json +0 -39
  234. package/src/documents/components/FormulaMenu.vue +0 -50
  235. package/src/files/components/FileDatabasePage.vue +0 -152
  236. package/src/files/components/FolderHomeIcon.vue +0 -12
  237. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  238. package/src/objects/components/ObjectPanel.vue +0 -554
  239. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  240. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  241. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  242. package/src/styles/object-panel.css +0 -163
  243. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  244. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  245. package/src/workspace/welcome-slogans.ts +0 -11
  246. package/src/workspace/workspace-git.ts +0 -35
  247. package/src/workspace/workspace-sync.ts +0 -46
  248. package/src/workspace/workspace-views.ts +0 -48
@@ -43,7 +43,12 @@ export const AssistantPanel = defineAsyncComponent(
43
43
  export const DiffDialog = defineAsyncComponent(() => import('../documents/components/DiffDialog.vue'));
44
44
  export const MobileRecycle = defineAsyncComponent(() => import('./components/MobileRecycle.vue'));
45
45
  export const SettingsPanel = defineAsyncComponent(() => import('../settings/components/SettingsPanel.vue'));
46
- export const ObjectPanel = defineAsyncComponent(() => import('../objects/components/ObjectPanel.vue'));
46
+ export const ObjectDetailModal = defineAsyncComponent(
47
+ () => import('../objects/components/ObjectDetailModal.vue'),
48
+ );
49
+ export const PlanArchiveDialog = defineAsyncComponent(
50
+ () => import('../plans/components/PlanArchiveDialog.vue'),
51
+ );
47
52
  export const PlanDetailPanel = defineAsyncComponent(
48
53
  () => import('../plans/components/PlanDetailPanel.vue'),
49
54
  );
@@ -58,14 +63,18 @@ export const CalendarView = loadingComponent(
58
63
  () => import('../plans/components/CalendarView.vue'),
59
64
  'document',
60
65
  );
66
+ export const MailWorkspaceView = loadingComponent(
67
+ () => import('../mail/components/MailWorkspaceView.vue'),
68
+ 'document',
69
+ );
70
+ export const SidebarMail = loadingComponent(
71
+ () => import('../mail/components/SidebarMail.vue'),
72
+ 'tree',
73
+ );
61
74
  export const DataTablePage = loadingComponent(
62
75
  () => import('../data-tables/components/DataTablePage.vue'),
63
76
  'spreadsheet',
64
77
  );
65
- export const WorkspaceViewTab = loadingComponent(
66
- () => import('./components/WorkspaceViewTab.vue'),
67
- 'document',
68
- );
69
78
  export const PluginInstaller = defineAsyncComponent(
70
79
  () => import('../plugins/components/PluginInstaller.vue'),
71
80
  );
@@ -1,5 +1,32 @@
1
- import type { InjectionKey, ShallowUnwrapRef } from 'vue';
1
+ import { provide, proxyRefs, shallowReactive, type InjectionKey, type ShallowUnwrapRef } from 'vue';
2
2
  import type { useWorkbench } from './use-workbench';
3
3
 
4
- export type WorkbenchContext = ShallowUnwrapRef<ReturnType<typeof useWorkbench>>;
5
- export const workbenchContextKey: InjectionKey<WorkbenchContext> = Symbol('tano-workbench');
4
+ type WorkbenchBundle = ReturnType<typeof useWorkbench>;
5
+
6
+ export type WorkbenchPrefsContext = ShallowUnwrapRef<WorkbenchBundle['prefs']>;
7
+ export type WorkbenchShellContext = ShallowUnwrapRef<WorkbenchBundle['shell']>;
8
+ export type WorkbenchDocumentsContext = ShallowUnwrapRef<WorkbenchBundle['documents']>;
9
+ export type WorkbenchTreeMenusContext = ShallowUnwrapRef<WorkbenchBundle['treeMenus']>;
10
+ export type WorkbenchModalsContext = ShallowUnwrapRef<WorkbenchBundle['modals']>;
11
+
12
+ export const workbenchPrefsKey: InjectionKey<WorkbenchPrefsContext> = Symbol('tano-workbench-prefs');
13
+ export const workbenchShellKey: InjectionKey<WorkbenchShellContext> = Symbol('tano-workbench-shell');
14
+ export const workbenchDocumentsKey: InjectionKey<WorkbenchDocumentsContext> = Symbol('tano-workbench-documents');
15
+ export const workbenchTreeMenusKey: InjectionKey<WorkbenchTreeMenusContext> = Symbol('tano-workbench-tree-menus');
16
+ export const workbenchModalsKey: InjectionKey<WorkbenchModalsContext> = Symbol('tano-workbench-modals');
17
+
18
+ export function provideWorkbenchContexts(bundle: WorkbenchBundle) {
19
+ const prefs = shallowReactive(proxyRefs(bundle.prefs));
20
+ const shell = shallowReactive(proxyRefs(bundle.shell));
21
+ const documents = shallowReactive(proxyRefs(bundle.documents));
22
+ const treeMenus = shallowReactive(proxyRefs(bundle.treeMenus));
23
+ const modals = shallowReactive(proxyRefs(bundle.modals));
24
+
25
+ provide(workbenchPrefsKey, prefs);
26
+ provide(workbenchShellKey, shell);
27
+ provide(workbenchDocumentsKey, documents);
28
+ provide(workbenchTreeMenusKey, treeMenus);
29
+ provide(workbenchModalsKey, modals);
30
+
31
+ return { prefs, shell, documents, treeMenus, modals };
32
+ }
@@ -0,0 +1,414 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import { computed, ref } from 'vue';
3
+ import { defineStore } from 'pinia';
4
+ import { isFeatureEnabled } from '../features';
5
+ import { useWorkbenchRuntime } from '../runtime';
6
+ import { mailBridge } from '../mail/mail-bridge';
7
+ import type {
8
+ MailAccount,
9
+ MailAccountInput,
10
+ MailCacheStats,
11
+ MailComposeSeed,
12
+ MailCredentials,
13
+ MailDraft,
14
+ MailFilter,
15
+ MailFolder,
16
+ MailMessageDetail,
17
+ MailMessageSummary,
18
+ MailPreset,
19
+ MailSendRequest,
20
+ } from '../mail/types';
21
+
22
+ export const useMailStore = defineStore('mail', () => {
23
+ const runtime = useWorkbenchRuntime();
24
+ const available = computed(
25
+ () => isFeatureEnabled('desktopMailClient') && runtime.native && !runtime.mobile,
26
+ );
27
+
28
+ const presets = ref<MailPreset[]>([]);
29
+ const accounts = ref<MailAccount[]>([]);
30
+ const folders = ref<MailFolder[]>([]);
31
+ const messages = ref<MailMessageSummary[]>([]);
32
+ const drafts = ref<MailDraft[]>([]);
33
+ const cacheStats = ref<MailCacheStats | null>(null);
34
+
35
+ const selectedFolderId = ref('');
36
+ const selectedMessageId = ref('');
37
+ const currentDetail = ref<MailMessageDetail | null>(null);
38
+
39
+ const filter = ref<MailFilter>('all');
40
+ const searchQuery = ref('');
41
+ const loading = ref(false);
42
+ const loadingMessage = ref(false);
43
+ const syncingAccountId = ref('');
44
+ const error = ref('');
45
+ const initialized = ref(false);
46
+
47
+ const accountDialogOpen = ref(false);
48
+ /** Provider preset to preselect the next time the account dialog opens. */
49
+ const accountDialogPreset = ref('');
50
+ const composerOpen = ref(false);
51
+ const composeSeed = ref<MailComposeSeed | null>(null);
52
+
53
+ const totalUnread = computed(() =>
54
+ folders.value
55
+ .filter((folder) => folder.specialUse === 'inbox')
56
+ .reduce((sum, folder) => sum + folder.unreadCount, 0),
57
+ );
58
+
59
+ const selectedFolder = computed(() =>
60
+ folders.value.find((folder) => folder.id === selectedFolderId.value),
61
+ );
62
+
63
+ const foldersByAccount = computed(() => {
64
+ const map = new Map<string, MailFolder[]>();
65
+ for (const account of accounts.value) map.set(account.id, []);
66
+ for (const folder of folders.value) {
67
+ const list = map.get(folder.accountId);
68
+ if (list) list.push(folder);
69
+ }
70
+ return map;
71
+ });
72
+
73
+ async function init() {
74
+ if (!available.value) return;
75
+ if (initialized.value) return;
76
+ loading.value = true;
77
+ error.value = '';
78
+ try {
79
+ const [presetList, accountList, folderList, draftList, stats] = await Promise.all([
80
+ mailBridge.presetsList(),
81
+ mailBridge.accountsList(),
82
+ mailBridge.foldersList(),
83
+ mailBridge.draftsList(),
84
+ mailBridge.cacheStats(),
85
+ ]);
86
+ presets.value = presetList;
87
+ accounts.value = accountList;
88
+ folders.value = folderList;
89
+ drafts.value = draftList;
90
+ cacheStats.value = stats;
91
+ initialized.value = true;
92
+
93
+ if (!selectedFolderId.value && folderList.length) {
94
+ const firstInbox = folderList.find((f) => f.specialUse === 'inbox') ?? folderList[0]!;
95
+ await selectFolder(firstInbox.id);
96
+ }
97
+ } catch (err) {
98
+ error.value = err instanceof Error ? err.message : String(err);
99
+ } finally {
100
+ loading.value = false;
101
+ }
102
+ }
103
+
104
+ async function refreshAccounts() {
105
+ if (!available.value) return;
106
+ accounts.value = await mailBridge.accountsList();
107
+ folders.value = await mailBridge.foldersList();
108
+ cacheStats.value = await mailBridge.cacheStats();
109
+ }
110
+
111
+ async function testAccount(input: MailAccountInput, credentials: MailCredentials) {
112
+ if (!available.value) throw new Error('仅桌面端支持原生邮箱连接');
113
+ return mailBridge.accountTest(input, credentials);
114
+ }
115
+
116
+ async function saveAccount(input: MailAccountInput, credentials?: MailCredentials) {
117
+ if (!available.value) throw new Error('仅桌面端支持原生邮箱连接');
118
+ const saved = await mailBridge.accountSave(input, credentials);
119
+ await refreshAccounts();
120
+ return saved;
121
+ }
122
+
123
+ async function removeAccount(accountId: string) {
124
+ if (!available.value) return;
125
+ await mailBridge.accountRemove(accountId);
126
+ if (selectedFolder.value?.accountId === accountId) {
127
+ selectedFolderId.value = '';
128
+ selectedMessageId.value = '';
129
+ currentDetail.value = null;
130
+ messages.value = [];
131
+ }
132
+ await refreshAccounts();
133
+ if (!selectedFolderId.value && folders.value.length) {
134
+ const next = folders.value.find((f) => f.specialUse === 'inbox') ?? folders.value[0]!;
135
+ await selectFolder(next.id);
136
+ }
137
+ }
138
+
139
+ async function syncAccount(accountId: string) {
140
+ if (!available.value || syncingAccountId.value) return;
141
+ syncingAccountId.value = accountId;
142
+ error.value = '';
143
+ try {
144
+ await mailBridge.syncAccount(accountId);
145
+ folders.value = await mailBridge.foldersList();
146
+ if (selectedFolderId.value) {
147
+ await reloadMessages();
148
+ } else {
149
+ const inbox =
150
+ folders.value.find((f) => f.accountId === accountId && f.specialUse === 'inbox') ??
151
+ folders.value.find((f) => f.accountId === accountId);
152
+ if (inbox) await selectFolder(inbox.id);
153
+ }
154
+ cacheStats.value = await mailBridge.cacheStats();
155
+ } catch (err) {
156
+ error.value = err instanceof Error ? err.message : String(err);
157
+ throw err;
158
+ } finally {
159
+ syncingAccountId.value = '';
160
+ }
161
+ }
162
+
163
+ async function syncSelectedFolder() {
164
+ if (!available.value || !selectedFolderId.value || syncingAccountId.value) return;
165
+ const folder = selectedFolder.value;
166
+ if (!folder) return;
167
+ syncingAccountId.value = folder.accountId;
168
+ error.value = '';
169
+ try {
170
+ await mailBridge.syncFolder(folder.id);
171
+ folders.value = await mailBridge.foldersList();
172
+ await reloadMessages();
173
+ cacheStats.value = await mailBridge.cacheStats();
174
+ } catch (err) {
175
+ error.value = err instanceof Error ? err.message : String(err);
176
+ throw err;
177
+ } finally {
178
+ syncingAccountId.value = '';
179
+ }
180
+ }
181
+
182
+ async function selectFolder(folderId: string) {
183
+ if (!available.value) return;
184
+ selectedFolderId.value = folderId;
185
+ searchQuery.value = '';
186
+ await reloadMessages();
187
+ if (messages.value.length && !messages.value.some((m) => m.id === selectedMessageId.value)) {
188
+ await selectMessage(messages.value[0]!.id);
189
+ } else if (!messages.value.length) {
190
+ selectedMessageId.value = '';
191
+ currentDetail.value = null;
192
+ }
193
+ }
194
+
195
+ async function reloadMessages() {
196
+ if (!available.value) return;
197
+ if (searchQuery.value.trim()) {
198
+ messages.value = await mailBridge.messagesSearch(
199
+ searchQuery.value.trim(),
200
+ selectedFolder.value?.accountId,
201
+ );
202
+ return;
203
+ }
204
+ if (!selectedFolderId.value) {
205
+ messages.value = [];
206
+ return;
207
+ }
208
+ messages.value = await mailBridge.messagesList(selectedFolderId.value, {
209
+ limit: 80,
210
+ offset: 0,
211
+ filter: filter.value,
212
+ });
213
+ }
214
+
215
+ async function setFilter(next: MailFilter) {
216
+ filter.value = next;
217
+ await reloadMessages();
218
+ }
219
+
220
+ async function search(query: string) {
221
+ searchQuery.value = query;
222
+ await reloadMessages();
223
+ }
224
+
225
+ async function selectMessage(messageId: string, forceRefresh = false) {
226
+ if (!available.value) return;
227
+ selectedMessageId.value = messageId;
228
+ loadingMessage.value = true;
229
+ error.value = '';
230
+ try {
231
+ const detail = await mailBridge.messageGet(messageId, forceRefresh);
232
+ if (selectedMessageId.value !== messageId) return;
233
+ currentDetail.value = detail;
234
+ if (!detail.summary.seen) {
235
+ const updated = await mailBridge.updateFlags(messageId, { seen: true });
236
+ if (selectedMessageId.value === messageId) currentDetail.value = updated;
237
+ syncSummaryInList(updated.summary);
238
+ folders.value = await mailBridge.foldersList();
239
+ } else {
240
+ syncSummaryInList(detail.summary);
241
+ }
242
+ cacheStats.value = await mailBridge.cacheStats();
243
+ } catch (err) {
244
+ error.value = err instanceof Error ? err.message : String(err);
245
+ } finally {
246
+ loadingMessage.value = false;
247
+ }
248
+ }
249
+
250
+ function syncSummaryInList(summary: MailMessageSummary) {
251
+ messages.value = messages.value.map((item) => (item.id === summary.id ? summary : item));
252
+ }
253
+
254
+ async function toggleSeen(messageId: string, nextSeen: boolean) {
255
+ if (!available.value) return;
256
+ const updated = await mailBridge.updateFlags(messageId, { seen: nextSeen });
257
+ syncSummaryInList(updated.summary);
258
+ if (currentDetail.value?.summary.id === messageId) currentDetail.value = updated;
259
+ folders.value = await mailBridge.foldersList();
260
+ }
261
+
262
+ async function toggleFlagged(messageId: string, nextFlagged: boolean) {
263
+ if (!available.value) return;
264
+ const updated = await mailBridge.updateFlags(messageId, { flagged: nextFlagged });
265
+ syncSummaryInList(updated.summary);
266
+ if (currentDetail.value?.summary.id === messageId) currentDetail.value = updated;
267
+ }
268
+
269
+ async function moveToSpecialFolder(messageId: string, specialUse: 'trash' | 'archive') {
270
+ if (!available.value) return;
271
+ const summary = messages.value.find((m) => m.id === messageId) ?? currentDetail.value?.summary;
272
+ if (!summary) return;
273
+ const target = folders.value.find(
274
+ (f) => f.accountId === summary.accountId && f.specialUse === specialUse,
275
+ );
276
+ if (!target) {
277
+ throw new Error(specialUse === 'trash' ? '该邮箱未提供废纸篓文件夹' : '该邮箱未提供归档文件夹');
278
+ }
279
+ await mailBridge.moveMessage(messageId, target.id);
280
+ messages.value = messages.value.filter((m) => m.id !== messageId);
281
+ if (selectedMessageId.value === messageId) {
282
+ selectedMessageId.value = '';
283
+ currentDetail.value = null;
284
+ }
285
+ folders.value = await mailBridge.foldersList();
286
+ }
287
+
288
+ async function markInviteState(
289
+ inviteId: string,
290
+ importedObjectId?: string | null,
291
+ rsvpStatus?: string | null,
292
+ ) {
293
+ if (!available.value) return;
294
+ await mailBridge.updateInvite(inviteId, importedObjectId, rsvpStatus);
295
+ if (currentDetail.value) {
296
+ currentDetail.value = {
297
+ ...currentDetail.value,
298
+ invites: currentDetail.value.invites.map((inv) =>
299
+ inv.id === inviteId
300
+ ? {
301
+ ...inv,
302
+ importedObjectId: importedObjectId ?? inv.importedObjectId,
303
+ rsvpStatus: rsvpStatus ?? inv.rsvpStatus,
304
+ }
305
+ : inv,
306
+ ),
307
+ };
308
+ }
309
+ }
310
+
311
+ async function downloadAttachment(attachmentId: string) {
312
+ if (!available.value) throw new Error('仅桌面端支持下载邮件附件');
313
+ const result = await mailBridge.downloadAttachment(attachmentId);
314
+ if (currentDetail.value) {
315
+ currentDetail.value = {
316
+ ...currentDetail.value,
317
+ attachments: currentDetail.value.attachments.map((att) =>
318
+ att.id === attachmentId ? { ...att, downloaded: true } : att,
319
+ ),
320
+ };
321
+ }
322
+ cacheStats.value = await mailBridge.cacheStats();
323
+ return result;
324
+ }
325
+
326
+ async function sendMail(request: MailSendRequest) {
327
+ if (!available.value) throw new Error('仅桌面端支持原生发信');
328
+ return mailBridge.sendMail(request);
329
+ }
330
+
331
+ async function clearCache() {
332
+ if (!available.value) return;
333
+ cacheStats.value = await mailBridge.cacheClear();
334
+ currentDetail.value = null;
335
+ selectedMessageId.value = '';
336
+ }
337
+
338
+ async function saveDraft(draft: MailDraft) {
339
+ if (!available.value) return;
340
+ const saved = await mailBridge.draftSave(draft);
341
+ drafts.value = [saved, ...drafts.value.filter((d) => d.id !== saved.id)];
342
+ return saved;
343
+ }
344
+
345
+ async function deleteDraft(draftId: string) {
346
+ if (!available.value) return;
347
+ await mailBridge.draftDelete(draftId);
348
+ drafts.value = drafts.value.filter((d) => d.id !== draftId);
349
+ }
350
+
351
+ function openComposer(seed: MailComposeSeed = {}) {
352
+ if (!available.value) return;
353
+ composeSeed.value = {
354
+ accountId: seed.accountId ?? selectedFolder.value?.accountId ?? accounts.value[0]?.id,
355
+ ...seed,
356
+ };
357
+ composerOpen.value = true;
358
+ }
359
+
360
+ function closeComposer() {
361
+ composerOpen.value = false;
362
+ composeSeed.value = null;
363
+ }
364
+
365
+ return {
366
+ available,
367
+ presets,
368
+ accounts,
369
+ folders,
370
+ foldersByAccount,
371
+ messages,
372
+ drafts,
373
+ cacheStats,
374
+ selectedFolderId,
375
+ selectedFolder,
376
+ selectedMessageId,
377
+ currentDetail,
378
+ filter,
379
+ searchQuery,
380
+ loading,
381
+ loadingMessage,
382
+ syncingAccountId,
383
+ error,
384
+ initialized,
385
+ totalUnread,
386
+ accountDialogOpen,
387
+ accountDialogPreset,
388
+ composerOpen,
389
+ composeSeed,
390
+ init,
391
+ refreshAccounts,
392
+ testAccount,
393
+ saveAccount,
394
+ removeAccount,
395
+ syncAccount,
396
+ syncSelectedFolder,
397
+ selectFolder,
398
+ reloadMessages,
399
+ setFilter,
400
+ search,
401
+ selectMessage,
402
+ toggleSeen,
403
+ toggleFlagged,
404
+ moveToSpecialFolder,
405
+ markInviteState,
406
+ downloadAttachment,
407
+ sendMail,
408
+ clearCache,
409
+ saveDraft,
410
+ deleteDraft,
411
+ openComposer,
412
+ closeComposer,
413
+ };
414
+ });
@@ -1,6 +1,7 @@
1
1
  import { computed, onScopeDispose, ref } from 'vue';
2
2
  import { defineStore } from 'pinia';
3
3
  import { nativeInvoke as invoke } from '../platform/native-bridge';
4
+ import { isPlanObject } from '@tano/protocol';
4
5
  import type { WorkspaceObject } from '@tano/protocol';
5
6
  import { useWorkbenchRuntime } from '../runtime';
6
7
  import { useWorkspaceStore } from './workspace';
@@ -64,7 +65,7 @@ export const usePlanSyncStore = defineStore('plan-sync', () => {
64
65
  return { type: 'event', name: value.name, description: value.description, archived: value.archived, properties: { ...itemProperties(value, kind), ...extra } };
65
66
  }
66
67
  function port(connection: Connection): LocalSyncPort {
67
- const list = async () => (await records(connection.scope, connection.workspaceId)).filter(r => ['event', 'task'].includes(r.object.type) && (connection.kind === 'todo' ? isCheckableEvent(r) : !isCheckableEvent(r)));
68
+ const list = async () => (await records(connection.scope, connection.workspaceId)).filter(r => isPlanObject(r.object) && (connection.kind === 'todo' ? isCheckableEvent(r) : !isCheckableEvent(r)));
68
69
  return {
69
70
  list,
70
71
  create: (value, remoteId, readOnly) => plans.create(draft(value, connection.kind, { syncConnection: connection.id, syncRemoteId: remoteId, syncReadOnly: readOnly }), connection.scope, connection.workspaceId),
@@ -56,6 +56,7 @@ export const usePlanStore = defineStore('plans', () => {
56
56
  const personalWritable = computed(
57
57
  () => !!personalId.value && !loadError.value && !errors.value.length,
58
58
  );
59
+ const workspaceId = computed(() => workspace.workspace?.id);
59
60
  const workspaceWritable = computed(
60
61
  () =>
61
62
  !!workspace.workspace &&
@@ -152,14 +153,6 @@ export const usePlanStore = defineStore('plans', () => {
152
153
  if (!id) throw new Error('工作区已关闭');
153
154
  return workspace.updateObject(record, value, id);
154
155
  }
155
- const panel = computed(() => ({
156
- id: personalId.value,
157
- records: personal.value,
158
- errors: [...errors.value, ...(loadError.value ? [loadError.value] : [])],
159
- writable: personalWritable.value,
160
- createObject: createPersonal,
161
- updateObject: updatePersonal,
162
- }));
163
156
  const onFocus = () => {
164
157
  if (!requiresDesktopRestart.value) void refreshPersonal();
165
158
  };
@@ -189,9 +182,9 @@ export const usePlanStore = defineStore('plans', () => {
189
182
  records,
190
183
  recordsFor,
191
184
  defaultScope,
185
+ workspaceId,
192
186
  personalWritable,
193
187
  workspaceWritable,
194
- panel,
195
188
  refreshPersonal,
196
189
  canEdit,
197
190
  create,