@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
@@ -0,0 +1,249 @@
1
+ import { nextTick, onBeforeUnmount, onMounted, watch, type Ref } from 'vue';
2
+ import { storeToRefs } from 'pinia';
3
+ import type { useAgentInboxController } from '../assistant/agent-controller';
4
+ import { ASSISTANT_TAB_ID, openAssistantPage } from '../assistant/navigation';
5
+ import type { useAssistantStore, useInlineAssistantStore } from '../assistant/store';
6
+ import { tableFileId } from '../data-tables/data-tables';
7
+ import { t } from '../i18n/i18n';
8
+ import { LocalReminderScheduler } from '../plans/local-reminders';
9
+ import { expandRecurringPlans } from '../plans/recurrence';
10
+ import { nativeListen as listen } from '../platform/native-bridge';
11
+ import { mobile } from '../platform/platform';
12
+ import type { WorkbenchExtensions } from '../runtime';
13
+ import type { retainWorkbenchSession } from '../shell/workbench-session';
14
+ import type { usePlanStore } from '../stores/plans';
15
+ import type { useUpdatesStore } from '../stores/updates';
16
+ import type { useWorkspaceStore } from '../stores/workspace';
17
+ import type { WindowContext } from '../windows/context';
18
+ import type { useAuxiliaryWindows } from '../windows/manager';
19
+ import { native } from '../workspace/adapter';
20
+ import type { useDocumentActions } from './use-document-actions';
21
+ import type { useFileTreeController } from './use-file-tree-controller';
22
+ import type { useWorkbenchCalendar } from './use-workbench-calendar';
23
+ import type { useWorkbenchHistory } from './use-workbench-history';
24
+ import type { useWorkbenchModals } from './use-workbench-modals';
25
+ import type { useWorkbenchOutline } from './use-workbench-outline';
26
+
27
+ export interface WorkbenchLifecycleDeps {
28
+ props: {
29
+ initialWorkspace?: string;
30
+ resolveInitialWorkspace?: () => Promise<string | undefined>;
31
+ createWorkspace?: boolean;
32
+ };
33
+ emitReady: () => void;
34
+ mainWindow: WindowContext;
35
+ store: ReturnType<typeof useWorkspaceStore>;
36
+ assistant: ReturnType<typeof useAssistantStore>;
37
+ inlineRunner: ReturnType<typeof useInlineAssistantStore>;
38
+ agentInbox: ReturnType<typeof useAgentInboxController>;
39
+ plans: ReturnType<typeof usePlanStore>;
40
+ updates: ReturnType<typeof useUpdatesStore>;
41
+ editing: WorkbenchExtensions['editing'];
42
+ auxiliaryWindows: ReturnType<typeof useAuxiliaryWindows>;
43
+ workbenchSession: ReturnType<typeof retainWorkbenchSession>;
44
+ localNative: boolean;
45
+ startupPending: Ref<boolean>;
46
+ compactPanes: Ref<boolean>;
47
+ sidebar: Ref<boolean>;
48
+ navigationContext: Ref<'home' | 'workspace'>;
49
+ navigationModule: Ref<string>;
50
+ restoreNavigation: () => void;
51
+ homeModule: Ref<string>;
52
+ getPersonalPlanScope: () => ReturnType<typeof usePlanStore>['view'];
53
+ extensionViews: NonNullable<WorkbenchExtensions['views']>;
54
+ agentPanel: Ref<boolean>;
55
+ selectedDiff: Ref<unknown>;
56
+ recyclePanel: Ref<boolean>;
57
+ workspaceMenu: Ref<boolean>;
58
+ settingsPanel: Ref<boolean>;
59
+ historyPanel: Ref<boolean>;
60
+ menu: Ref<boolean>;
61
+ calendar: ReturnType<typeof useWorkbenchCalendar>;
62
+ docs: ReturnType<typeof useDocumentActions>;
63
+ tree: ReturnType<typeof useFileTreeController>;
64
+ outlineCtrl: ReturnType<typeof useWorkbenchOutline>;
65
+ modals: ReturnType<typeof useWorkbenchModals>;
66
+ history: ReturnType<typeof useWorkbenchHistory>;
67
+ }
68
+
69
+ export function useWorkbenchLifecycle(deps: WorkbenchLifecycleDeps) {
70
+ const {
71
+ props,
72
+ emitReady,
73
+ mainWindow,
74
+ store,
75
+ assistant,
76
+ inlineRunner,
77
+ agentInbox,
78
+ plans,
79
+ updates,
80
+ editing,
81
+ auxiliaryWindows,
82
+ workbenchSession,
83
+ localNative,
84
+ startupPending,
85
+ compactPanes,
86
+ sidebar,
87
+ navigationContext,
88
+ navigationModule,
89
+ restoreNavigation,
90
+ homeModule,
91
+ getPersonalPlanScope,
92
+ extensionViews,
93
+ agentPanel,
94
+ selectedDiff,
95
+ recyclePanel,
96
+ workspaceMenu,
97
+ settingsPanel,
98
+ historyPanel,
99
+ menu,
100
+ calendar,
101
+ docs,
102
+ tree,
103
+ outlineCtrl,
104
+ modals,
105
+ history,
106
+ } = deps;
107
+ const { activeId } = storeToRefs(store);
108
+
109
+ let unmounted = false;
110
+ let reminderTimer: ReturnType<typeof setInterval> | undefined;
111
+ let unlistenClose: (() => void) | undefined;
112
+ let unlistenWatchError: (() => void) | undefined;
113
+
114
+ const reminderScheduler = new LocalReminderScheduler({
115
+ onRemind: (item) => {
116
+ store.report(t('日程提醒:{0}', [item.record.object.name]));
117
+ },
118
+ });
119
+
120
+ function checkPlanReminders() {
121
+ if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return;
122
+ const now = new Date();
123
+ const windowStart = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
124
+ const windowEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 2);
125
+ const records = expandRecurringPlans(plans.recordsFor('all'), windowStart, windowEnd);
126
+ reminderScheduler.check(records, now.getTime());
127
+ }
128
+
129
+ watch(
130
+ () => store.workspace?.id,
131
+ (id, previous) => {
132
+ agentPanel.value = false;
133
+ selectedDiff.value = undefined;
134
+ recyclePanel.value = false;
135
+ if (navigationModule.value === 'workspace') {
136
+ if (previous) calendar.rememberCalendar(previous);
137
+ calendar.restoreCalendar(id);
138
+ }
139
+ calendar.calendarModeOpen.value = false;
140
+ workspaceMenu.value = false;
141
+ settingsPanel.value = false;
142
+ },
143
+ );
144
+
145
+ watch(activeId, (id) => {
146
+ calendar.calendarModeOpen.value = false;
147
+ if (id === ASSISTANT_TAB_ID && compactPanes.value) sidebar.value = false;
148
+ docs.closePageContextMenu();
149
+ const treeId = activeId.value.startsWith('table:')
150
+ ? tableFileId(activeId.value)
151
+ : activeId.value;
152
+ if (!tree.pendingTreeOpenIds.has(treeId) || !tree.selectedEntryIds.value.has(treeId))
153
+ tree.selectActiveFileInTree();
154
+ historyPanel.value = false;
155
+ menu.value = false;
156
+ outlineCtrl.resetOnActiveChange();
157
+ });
158
+
159
+ watch(
160
+ () => [store.activeId, assistant.loading, store.busy] as const,
161
+ ([id, loading, switching]) => {
162
+ if (id === ASSISTANT_TAB_ID && !loading && !switching) openAssistantPage(store, assistant);
163
+ },
164
+ );
165
+
166
+ watch(sidebar, (visible) => {
167
+ if (!visible) {
168
+ tree.closeFileContextMenu();
169
+ tree.closeDirectoryContextMenu();
170
+ outlineCtrl.closeOutlineContextMenu();
171
+ }
172
+ });
173
+
174
+ onMounted(async () => {
175
+ reminderTimer = setInterval(checkPlanReminders, 60_000);
176
+ if (history.webPageRouting) {
177
+ history.initializePageHistory();
178
+ window.addEventListener('popstate', history.handlePagePopState);
179
+ }
180
+ try {
181
+ await workbenchSession.initialize(async () => {
182
+ if (props.createWorkspace) await modals.createNewWorkspace();
183
+ else
184
+ await store.initialize(
185
+ history.initialPageRoute?.workspaceId ??
186
+ (props.resolveInitialWorkspace
187
+ ? await props.resolveInitialWorkspace()
188
+ : props.initialWorkspace),
189
+ );
190
+ });
191
+ } finally {
192
+ restoreNavigation();
193
+ if (
194
+ homeModule.value !== 'plan' &&
195
+ !extensionViews.some((view) => view.id === homeModule.value && view.sidebar)
196
+ )
197
+ homeModule.value = 'plan';
198
+ plans.view = navigationContext.value === 'home' ? getPersonalPlanScope() : 'workspace';
199
+ startupPending.value = false;
200
+ }
201
+ if (unmounted) return;
202
+ emitReady();
203
+ await nextTick();
204
+
205
+ await history.finishInitialPageRouting(props.createWorkspace);
206
+ if (native && !mobile) {
207
+ void updates.initialize();
208
+ }
209
+ if (native) {
210
+ if (localNative)
211
+ unlistenWatchError = await listen<string>('workspace-watch-error', (event) => {
212
+ store.enableWorkspacePolling();
213
+ store.report(t('文件监听遇到错误:{0}。目录仍会定期自动检查。', [event.payload]));
214
+ });
215
+ if (!mobile)
216
+ unlistenClose = await mainWindow.native!.onCloseRequested(async (event) => {
217
+ event.preventDefault();
218
+ if (updates.state.phase === 'installing') return;
219
+ try {
220
+ await editing.flush();
221
+ if (await store.flush()) {
222
+ await assistant.settle();
223
+ await inlineRunner.settle();
224
+ await agentInbox.settle();
225
+ if (!(await auxiliaryWindows.closeAll())) {
226
+ agentInbox.resume();
227
+ return;
228
+ }
229
+ await editing.suspendAll();
230
+ await mainWindow.native!.destroy();
231
+ } else store.report(t('还有未保存的内容,窗口已保留。请先保存或另存副本。'));
232
+ } catch (error) {
233
+ agentInbox.resume();
234
+ store.report(error);
235
+ }
236
+ });
237
+ }
238
+ });
239
+
240
+ onBeforeUnmount(() => {
241
+ unmounted = true;
242
+ clearInterval(reminderTimer);
243
+ document.documentElement.style.removeProperty('--sidebar-width');
244
+ workbenchSession.release();
245
+ window.removeEventListener('popstate', history.handlePagePopState);
246
+ unlistenClose?.();
247
+ unlistenWatchError?.();
248
+ });
249
+ }
@@ -266,7 +266,7 @@ export function useWorkbenchModals(deps: WorkbenchModalsDeps) {
266
266
  await removeDocuments(entries);
267
267
  }
268
268
 
269
- async function createNewEntry(kind: 'document' | 'folder', parent = '') {
269
+ async function createNewEntry(kind: 'document' | 'folder' | 'table', parent = '') {
270
270
  if (store.busy || workspace.value?.readOnly || updateLock.value) return;
271
271
  markInitialPageRouteSuperseded();
272
272
  menu.value = false;
@@ -279,6 +279,11 @@ export function useWorkbenchModals(deps: WorkbenchModalsDeps) {
279
279
  await store.createUntitledFolder(parent);
280
280
  return;
281
281
  }
282
+ if (kind === 'table') {
283
+ await store.createDataTable('blank', parent);
284
+ if (compactPanes.value) sidebar.value = false;
285
+ return;
286
+ }
282
287
  await store.createUntitledDocument(parent);
283
288
  if (compactPanes.value) sidebar.value = false;
284
289
  await nextTick();
@@ -37,7 +37,6 @@ export function useWorkbenchOutline(deps: WorkbenchOutlineDeps) {
37
37
  } = deps;
38
38
 
39
39
  const hoverOutline = window.matchMedia('(hover: hover)').matches;
40
- const panel = ref<'outline' | 'activity'>('outline');
41
40
  const showOutline = ref(readPreference('showOutline', true));
42
41
  const touchOutlineOpen = ref(false);
43
42
  watch(activeId, () => {
@@ -155,7 +154,6 @@ export function useWorkbenchOutline(deps: WorkbenchOutlineDeps) {
155
154
  function releaseOutlinePointerFocus(event: PointerEvent) {
156
155
  const { document } = activeWindow.value;
157
156
  if (
158
- panel.value !== 'outline' ||
159
157
  touchLayout.value ||
160
158
  !hoverOutline ||
161
159
  outlinePinned.value ||
@@ -180,7 +178,6 @@ export function useWorkbenchOutline(deps: WorkbenchOutlineDeps) {
180
178
 
181
179
  function openOutlineContextMenu(event: MouseEvent) {
182
180
  const { window: activeWin } = activeWindow.value;
183
- if (panel.value !== 'outline') return;
184
181
  event.preventDefault();
185
182
  closeOtherContextMenus();
186
183
  if (hoverOutline && !outlinePinned.value) toggleOutlinePin(event);
@@ -318,7 +315,6 @@ export function useWorkbenchOutline(deps: WorkbenchOutlineDeps) {
318
315
 
319
316
  function resetOnActiveChange() {
320
317
  closeOutlineContextMenu();
321
- panel.value = 'outline';
322
318
  outlineSearchOpen.value = false;
323
319
  outlineSearch.value = '';
324
320
  activeHeading.value = 0;
@@ -327,7 +323,6 @@ export function useWorkbenchOutline(deps: WorkbenchOutlineDeps) {
327
323
 
328
324
  return {
329
325
  hoverOutline,
330
- panel,
331
326
  showOutline,
332
327
  touchOutlineOpen,
333
328
  outlineOnLeft,
@@ -0,0 +1,185 @@
1
+ import { computed, ref, type Ref } from 'vue';
2
+ import { isMarkdown, isWorkspaceInternalPath, type WorkspaceAdapter } from '@tano/protocol';
3
+ import { version as appVersion } from '../../package.json';
4
+ import { t } from '../i18n/i18n';
5
+ import { mobile } from '../platform/platform';
6
+ import type { WorkbenchExtensions } from '../runtime';
7
+ import { readSettingsPage } from '../settings/settings-preference';
8
+ import { SETTINGS_TAB_ID } from '../settings/settings-tab';
9
+ import type { SettingsPageId } from '../settings/settings-window';
10
+ import type { useUpdatesStore } from '../stores/updates';
11
+ import type { useWorkspaceStore } from '../stores/workspace';
12
+ import type { WindowContext } from '../windows/context';
13
+ import type { useAuxiliaryWindows } from '../windows/manager';
14
+ import { native } from '../workspace/adapter';
15
+ import type { useWorkbenchModals } from './use-workbench-modals';
16
+ import type { useWorkbenchOutline } from './use-workbench-outline';
17
+ import type { useWorkbenchPreferences } from './use-workbench-preferences';
18
+
19
+ export interface WorkbenchSettingsDeps {
20
+ store: ReturnType<typeof useWorkspaceStore>;
21
+ updates: ReturnType<typeof useUpdatesStore>;
22
+ workspaceAdapter: WorkspaceAdapter;
23
+ extensions: WorkbenchExtensions;
24
+ auxiliaryWindows: ReturnType<typeof useAuxiliaryWindows>;
25
+ activeWindow: Ref<WindowContext>;
26
+ navigationContext: Ref<'home' | 'workspace'>;
27
+ compactPanes: Ref<boolean>;
28
+ sidebar: Ref<boolean>;
29
+ tabsEnabled: boolean;
30
+ menu: Ref<boolean>;
31
+ workspaceMenu: Ref<boolean>;
32
+ settingsPanel: Ref<boolean>;
33
+ agentPanel: Ref<boolean>;
34
+ recyclePanel: Ref<boolean>;
35
+ prefs: ReturnType<typeof useWorkbenchPreferences>;
36
+ outlineCtrl: ReturnType<typeof useWorkbenchOutline>;
37
+ modals: ReturnType<typeof useWorkbenchModals>;
38
+ }
39
+
40
+ export function useWorkbenchSettings(deps: WorkbenchSettingsDeps) {
41
+ const {
42
+ store,
43
+ updates,
44
+ workspaceAdapter,
45
+ extensions,
46
+ auxiliaryWindows,
47
+ activeWindow,
48
+ navigationContext,
49
+ compactPanes,
50
+ sidebar,
51
+ tabsEnabled,
52
+ menu,
53
+ workspaceMenu,
54
+ settingsPanel,
55
+ agentPanel,
56
+ recyclePanel,
57
+ prefs,
58
+ outlineCtrl,
59
+ modals,
60
+ } = deps;
61
+
62
+ const settingsPage = ref<SettingsPageId>(readSettingsPage());
63
+ const settingsWorkspace = computed(() =>
64
+ navigationContext.value === 'workspace' ? store.workspace : null,
65
+ );
66
+
67
+ function openSettingsTab(page: SettingsPageId) {
68
+ settingsPage.value = page;
69
+ store.openViewTab(SETTINGS_TAB_ID);
70
+ settingsPanel.value = false;
71
+ if (compactPanes.value) sidebar.value = false;
72
+ }
73
+
74
+ const openingSettingsWindow = ref(false);
75
+ async function openSettingsInNewWindow(page: SettingsPageId) {
76
+ if (!native || mobile || !tabsEnabled) return;
77
+ settingsPage.value = page;
78
+ if (openingSettingsWindow.value) return;
79
+ openingSettingsWindow.value = true;
80
+ settingsPanel.value = false;
81
+ try {
82
+ activeWindow.value = (
83
+ await auxiliaryWindows.open('settings', 'settings', t('设置') + ' — Tano / 同页')
84
+ ).context;
85
+ } catch (error) {
86
+ settingsPanel.value = true;
87
+ store.report(error);
88
+ } finally {
89
+ openingSettingsWindow.value = false;
90
+ }
91
+ }
92
+
93
+ function openSettings(page: SettingsPageId = readSettingsPage(settingsPage.value)) {
94
+ menu.value = false;
95
+ workspaceMenu.value = false;
96
+ settingsPage.value = page === 'preferences' ? 'appearance' : page;
97
+ const pane = store.panes.find((pane) => pane.tabs.includes(SETTINGS_TAB_ID));
98
+ if (pane) {
99
+ store.focusPane(pane.id);
100
+ openSettingsTab(settingsPage.value);
101
+ return;
102
+ }
103
+ settingsPanel.value = true;
104
+ }
105
+
106
+ function settingsAction(
107
+ action: 'open-folder' | 'switch-mode' | 'reveal' | 'agent' | 'history' | 'recycle' | 'sign-out',
108
+ ) {
109
+ if (!settingsWorkspace.value && ['reveal', 'agent', 'history', 'recycle'].includes(action))
110
+ return;
111
+ settingsPanel.value = false;
112
+ if (action === 'open-folder') void store.openWorkspace();
113
+ else if (action === 'reveal') void store.reveal();
114
+ else if (action === 'agent') agentPanel.value = true;
115
+ else if (action === 'history') extensions.showHistory?.();
116
+ else if (action === 'recycle') recyclePanel.value = true;
117
+ }
118
+
119
+ const settingsContext = computed(() => ({
120
+ pluginPages: settingsWorkspace.value ? store.pluginSettingsPages : [],
121
+ workspace: settingsWorkspace.value
122
+ ? {
123
+ id: settingsWorkspace.value.id,
124
+ name: settingsWorkspace.value.name,
125
+ path: settingsWorkspace.value.path,
126
+ readOnly: settingsWorkspace.value.readOnly,
127
+ canDelete: settingsWorkspace.value.canDelete,
128
+ canManageSettings: settingsWorkspace.value.canManageSettings,
129
+ }
130
+ : null,
131
+ activeFile:
132
+ settingsWorkspace.value && store.active
133
+ ? { id: store.active.id, path: store.active.path }
134
+ : null,
135
+ workspaceSettings: store.workspaceSettings,
136
+ workspacePages:
137
+ settingsWorkspace.value?.files
138
+ .filter(
139
+ (file) =>
140
+ file.kind === 'file' && isMarkdown(file.path) && !isWorkspaceInternalPath(file.path),
141
+ )
142
+ .map((file) => ({ id: file.id, path: file.path })) ?? [],
143
+ workspaceSettingsError: store.workspaceSettingsError,
144
+ workspaceSettingsSaving: store.workspaceSettingsSaving,
145
+ workspaceExporting: modals.workspaceExporting.value,
146
+ workspaceExportError: modals.workspaceExportError.value,
147
+ workspaceDeletionSupported: !!workspaceAdapter.deleteWorkspace,
148
+ workspaceDeleting: modals.workspaceDeleting.value || store.busy,
149
+ workspaceDeletionError: modals.workspaceDeletionError.value,
150
+ mode: store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local',
151
+ defaultSource: prefs.defaultSource.value,
152
+ theme: prefs.theme.value,
153
+ appearance: prefs.appearance.value,
154
+ visualFontChoice: prefs.visualFontChoice.value,
155
+ customFontName: prefs.customFontName.value,
156
+ splitFontSettings: prefs.splitFontSettings.value,
157
+ revealMarkdown: prefs.revealMarkdown.value,
158
+ toolbarMode: prefs.toolbarMode.value,
159
+ shortcuts: prefs.shortcuts.value,
160
+ showPageTitle: prefs.showPageTitle.value,
161
+ showDocumentProperties: prefs.showDocumentProperties.value,
162
+ showDocumentDiscussion: prefs.showDocumentDiscussion.value,
163
+ showOutline: outlineCtrl.showOutline.value,
164
+ outlineOnLeft: outlineCtrl.outlineOnLeft.value,
165
+ visualFontSize: prefs.visualFontSize.value,
166
+ sourceFontSize: prefs.sourceFontSize.value,
167
+ editorPreferences: prefs.editorPreferences.value,
168
+ historyEnabled: !!extensions.historyEnabled,
169
+ capabilities: store.capabilities,
170
+ capabilityError: store.capabilityError,
171
+ capabilitySaving: store.capabilitySaving,
172
+ version: updates.state.status?.currentVersion ?? appVersion,
173
+ updates: updates.state,
174
+ }));
175
+
176
+ return {
177
+ settingsPage,
178
+ openingSettingsWindow,
179
+ openSettingsTab,
180
+ openSettingsInNewWindow,
181
+ openSettings,
182
+ settingsAction,
183
+ settingsContext,
184
+ };
185
+ }