MCPcopy Create free account
hub / github.com/experdot/pointer / deleteWorkspace

Function deleteWorkspace

src/renderer/src/services/workspaceService.ts:199–226  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

197 * 注意:只从列表中移除,不删除文件
198 */
199export async function deleteWorkspace(workspaceId: string): Promise<void> {
200 const { workspace } = stores
201
202 const targetWorkspace = await workspace.getById(workspaceId)
203 if (!targetWorkspace) {
204 throw new Error(`Workspace not found: ${workspaceId}`)
205 }
206
207 // 不能删除默认工作区
208 if (targetWorkspace.type === 'default') {
209 throw new Error('Cannot delete default workspace')
210 }
211
212 // 如果删除的是当前工作区,切换到默认工作区
213 if (workspace.currentWorkspaceId === workspaceId) {
214 const defaultWs = workspace.workspaces.find((w) => w.type === 'default')
215 if (defaultWs) {
216 await switchWorkspace(defaultWs.id)
217 }
218 }
219
220 await workspace.delete(workspaceId)
221 const activeContext = persistence.database.getActiveContext()
222 if (!activeContext.accountId) {
223 throw new Error('No active account context')
224 }
225 await commitWorkspaceContext(activeContext.accountId, activeContext.workspacePath)
226}
227
228/**
229 * 获取当前工作区

Callers 1

handleDeleteWorkspaceFunction · 0.90

Calls 5

switchWorkspaceFunction · 0.85
commitWorkspaceContextFunction · 0.85
getActiveContextMethod · 0.80
getByIdMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected