From 614f5e20931d778ad0f48893d6d66faaa67abd16 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Thu, 20 Nov 2025 23:32:48 +0800 Subject: [PATCH] fix: review --- features/stepDefinitions/application.ts | 8 ++++++-- localization/locales/en/translation.json | 4 +--- localization/locales/fr/translation.json | 4 ++++ localization/locales/ja/translation.json | 4 ++++ localization/locales/ru/translation.json | 4 ++++ localization/locales/zh-Hans/translation.json | 6 ++---- localization/locales/zh-Hant/translation.json | 4 ++++ src/services/wikiGitWorkspace/index.ts | 7 +++---- src/windows/EditWorkspace/index.tsx | 8 +++++++- 9 files changed, 35 insertions(+), 14 deletions(-) diff --git a/features/stepDefinitions/application.ts b/features/stepDefinitions/application.ts index 61c2ba5d..54e80267 100644 --- a/features/stepDefinitions/application.ts +++ b/features/stepDefinitions/application.ts @@ -338,10 +338,14 @@ When('I prepare to select directory in dialog {string}', async function(this: Ap throw new Error('Application is not launched'); } const targetPath = path.resolve(process.cwd(), directoryName); - // Setup dialog handler to intercept showOpenDialog calls in main process + // Setup one-time dialog handler that restores after use await this.app.evaluate(({ dialog }, targetDirectory: string) => { - // Override showOpenDialog to return the test directory + // Save original function with proper binding + const originalShowOpenDialog = dialog.showOpenDialog.bind(dialog); + // Override with one-time mock dialog.showOpenDialog = async () => { + // Restore original immediately after first call + dialog.showOpenDialog = originalShowOpenDialog; return { canceled: false, filePaths: [targetDirectory], diff --git a/localization/locales/en/translation.json b/localization/locales/en/translation.json index 9e5c4996..82594c85 100644 --- a/localization/locales/en/translation.json +++ b/localization/locales/en/translation.json @@ -172,11 +172,9 @@ "MainWorkspacePath": "Main Workspace Path", "MiscOptions": "Misc", "MoveWorkspace": "Move Workspace...", - "MoveWorkspaceTooltip": "Move workspace folder to a new location. The wiki will be stopped before moving to prevent file lock issues.", - "MoveWorkspaceSuccess": "Workspace Moved Successfully", - "MoveWorkspaceSuccessMessage": "Workspace {{name}} has been moved to {{newLocation}}. The edit window will close automatically.", "MoveWorkspaceFailed": "Failed to Move Workspace", "MoveWorkspaceFailedMessage": "Failed to move workspace", + "MoveWorkspaceTooltip": "Move workspace folder to a new location. The wiki will be stopped before moving to prevent file lock issues.", "Name": "Workspace Name", "NameDescription": "The name of the workspace, which will be displayed on the sidebar, can be different from the actual folder name of the Git repository in the workspace", "NoRevert": "Caution! This operation can't be reverted.", diff --git a/localization/locales/fr/translation.json b/localization/locales/fr/translation.json index 3fb42c30..f8498096 100644 --- a/localization/locales/fr/translation.json +++ b/localization/locales/fr/translation.json @@ -171,6 +171,10 @@ "LastVisitState": "Dernière page visitée", "MainWorkspacePath": "Chemin de l'espace de travail principal", "MiscOptions": "Divers", + "MoveWorkspace": "Espace de travail mobile...", + "MoveWorkspaceFailed": "Échec du déplacement de l'espace de travail", + "MoveWorkspaceFailedMessage": "Échec du déplacement de l'espace de travail", + "MoveWorkspaceTooltip": "Déplacer le dossier de l'espace de travail vers un nouvel emplacement. La base de connaissances sera automatiquement arrêtée avant le déplacement pour éviter les problèmes de verrouillage des fichiers.", "Name": "Nom de l'espace de travail", "NameDescription": "Le nom de l'espace de travail, qui sera affiché sur la barre latérale, peut être différent du nom réel du dossier du dépôt Git dans l'espace de travail", "NoRevert": "Attention ! Cette opération ne peut pas être annulée.", diff --git a/localization/locales/ja/translation.json b/localization/locales/ja/translation.json index c55da07f..2fc8954a 100644 --- a/localization/locales/ja/translation.json +++ b/localization/locales/ja/translation.json @@ -171,6 +171,10 @@ "LastVisitState": "最後に訪れたページ", "MainWorkspacePath": "メインワークスペースのパス", "MiscOptions": "その他のオプション", + "MoveWorkspace": "モバイルワークスペース...", + "MoveWorkspaceFailed": "モバイルワークスペースの移動に失敗しました", + "MoveWorkspaceFailedMessage": "ワークスペースの移動に失敗しました", + "MoveWorkspaceTooltip": "ワークスペースフォルダを新しい場所に移動します。移動前にナレッジベースが自動的に停止され、ファイルロックの問題を回避します。", "Name": "ワークスペース名", "NameDescription": "ワークスペースの名前。サイドバーに表示され、ワークスペース内のGitリポジトリの実際のフォルダ名と異なる場合があります", "NoRevert": "注意!この操作は元に戻せません。", diff --git a/localization/locales/ru/translation.json b/localization/locales/ru/translation.json index 996abe25..4b33cfa4 100644 --- a/localization/locales/ru/translation.json +++ b/localization/locales/ru/translation.json @@ -171,6 +171,10 @@ "LastVisitState": "Последняя посещенная страница", "MainWorkspacePath": "Основной путь рабочей области", "MiscOptions": "Разные настройки", + "MoveWorkspace": "Переместить рабочую область...", + "MoveWorkspaceFailed": "Не удалось переместить рабочую область", + "MoveWorkspaceFailedMessage": "Не удалось переместить рабочую область", + "MoveWorkspaceTooltip": "Переместить папку рабочей области в новое место. Перед перемещением база знаний будет автоматически остановлена, чтобы избежать проблем с блокировкой файлов.", "Name": "Имя рабочего пространства", "NameDescription": "Имя рабочего пространства, которое будет отображаться на боковой панели, может отличаться от фактического имени папки репозитория Git в рабочем пространстве", "NoRevert": "Внимание! Эта операция не может быть отменена.", diff --git a/localization/locales/zh-Hans/translation.json b/localization/locales/zh-Hans/translation.json index 4bbc8a09..420074ce 100644 --- a/localization/locales/zh-Hans/translation.json +++ b/localization/locales/zh-Hans/translation.json @@ -172,11 +172,9 @@ "MainWorkspacePath": "主工作区路径", "MiscOptions": "杂项设置", "MoveWorkspace": "移动工作区...", - "MoveWorkspaceTooltip": "将工作区文件夹移动到新位置。移动前会自动停止知识库以避免文件锁定问题。", - "MoveWorkspaceSuccess": "工作区移动成功", - "MoveWorkspaceSuccessMessage": "工作区 {{name}} 已移动到 {{newLocation}}。编辑窗口将自动关闭。", "MoveWorkspaceFailed": "移动工作区失败", "MoveWorkspaceFailedMessage": "移动工作区失败", + "MoveWorkspaceTooltip": "将工作区文件夹移动到新位置。移动前会自动停止知识库以避免文件锁定问题。", "Name": "工作区名", "NameDescription": "工作区的名字,将显示在侧边栏上,可以与工作区Git仓库的实际文件夹名不同", "NoRevert": "注意!这个操作无法撤销!", @@ -559,7 +557,7 @@ "UpdateAvailable": "有新版本!" }, "Unknown": "未知", - "Update": "", + "Update": "更新", "Updater": { "CheckUpdate": "检查更新", "CheckingFailed": "检查更新失败(网络错误)", diff --git a/localization/locales/zh-Hant/translation.json b/localization/locales/zh-Hant/translation.json index 29f39240..0da3cadf 100644 --- a/localization/locales/zh-Hant/translation.json +++ b/localization/locales/zh-Hant/translation.json @@ -171,6 +171,10 @@ "LastVisitState": "上次訪問的頁面", "MainWorkspacePath": "主工作區路徑", "MiscOptions": "雜項設置", + "MoveWorkspace": "移動工作區...", + "MoveWorkspaceFailed": "移動工作區失敗", + "MoveWorkspaceFailedMessage": "移動工作區失敗", + "MoveWorkspaceTooltip": "將工作區資料夾移動到新位置。移動前會自動停止知識庫以避免檔案鎖定問題。", "Name": "工作區名", "NameDescription": "工作區的名字,將顯示在側邊欄上,可以與工作區Git倉庫的實際文件夾名不同", "NoRevert": "注意!這個操作無法撤銷!", diff --git a/src/services/wikiGitWorkspace/index.ts b/src/services/wikiGitWorkspace/index.ts index 5234470f..ca73887f 100644 --- a/src/services/wikiGitWorkspace/index.ts +++ b/src/services/wikiGitWorkspace/index.ts @@ -297,15 +297,14 @@ export class WikiGitWorkspace implements IWikiGitWorkspaceService { wikiFolderLocation: newWikiFolderLocation, }); - await remove(wikiFolderLocation); - logger.info(`Successfully moved workspace to ${newWikiFolderLocation} [test-id-WORKSPACE_MOVED:${newWikiFolderLocation}]`); - // Restart the workspace view to load from new location const workspaceViewService = container.get(serviceIdentifier.WorkspaceView); await workspaceViewService.restartWorkspaceViewService(workspaceID); - logger.info(`Workspace view restarted after move [test-id-WORKSPACE_RESTARTED_AFTER_MOVE:${workspaceID}]`); + logger.debug(`Workspace view restarted after move [test-id-WORKSPACE_RESTARTED_AFTER_MOVE:${workspaceID}]`); + // Only delete old folder after successful restart to avoid inconsistent state + await remove(wikiFolderLocation); } catch (error_: unknown) { const error = error_ as Error; logger.error(`Failed to move workspace: ${error.message}`, { error }); diff --git a/src/windows/EditWorkspace/index.tsx b/src/windows/EditWorkspace/index.tsx index 729db544..da3655bd 100644 --- a/src/windows/EditWorkspace/index.tsx +++ b/src/windows/EditWorkspace/index.tsx @@ -285,7 +285,13 @@ export default function EditWorkspace(): React.JSX.Element { try { await window.service.wikiGitWorkspace.moveWorkspaceLocation(workspaceID, newLocation); } catch (error) { - console.error('Failed to move workspace:', error); + const errorMessage = (error as Error).message; + void window.service.native.log('error', `Failed to move workspace: ${errorMessage}`, { error, workspaceID, newLocation }); + // Show error notification + void window.service.notification.show({ + title: t('EditWorkspace.MoveWorkspaceFailed'), + body: t('EditWorkspace.MoveWorkspaceFailedMessage', { name: workspaceName, error: errorMessage }), + }); } } }}