fix: review

This commit is contained in:
lin onetwo 2025-11-20 23:32:48 +08:00
parent df0b9e2ec2
commit 614f5e2093
9 changed files with 35 additions and 14 deletions

View file

@ -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],

View file

@ -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.",

View file

@ -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.",

View file

@ -171,6 +171,10 @@
"LastVisitState": "最後に訪れたページ",
"MainWorkspacePath": "メインワークスペースのパス",
"MiscOptions": "その他のオプション",
"MoveWorkspace": "モバイルワークスペース...",
"MoveWorkspaceFailed": "モバイルワークスペースの移動に失敗しました",
"MoveWorkspaceFailedMessage": "ワークスペースの移動に失敗しました",
"MoveWorkspaceTooltip": "ワークスペースフォルダを新しい場所に移動します。移動前にナレッジベースが自動的に停止され、ファイルロックの問題を回避します。",
"Name": "ワークスペース名",
"NameDescription": "ワークスペースの名前。サイドバーに表示され、ワークスペース内のGitリポジトリの実際のフォルダ名と異なる場合があります",
"NoRevert": "注意!この操作は元に戻せません。",

View file

@ -171,6 +171,10 @@
"LastVisitState": "Последняя посещенная страница",
"MainWorkspacePath": "Основной путь рабочей области",
"MiscOptions": "Разные настройки",
"MoveWorkspace": "Переместить рабочую область...",
"MoveWorkspaceFailed": "Не удалось переместить рабочую область",
"MoveWorkspaceFailedMessage": "Не удалось переместить рабочую область",
"MoveWorkspaceTooltip": "Переместить папку рабочей области в новое место. Перед перемещением база знаний будет автоматически остановлена, чтобы избежать проблем с блокировкой файлов.",
"Name": "Имя рабочего пространства",
"NameDescription": "Имя рабочего пространства, которое будет отображаться на боковой панели, может отличаться от фактического имени папки репозитория Git в рабочем пространстве",
"NoRevert": "Внимание! Эта операция не может быть отменена.",

View file

@ -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": "检查更新失败(网络错误)",

View file

@ -171,6 +171,10 @@
"LastVisitState": "上次訪問的頁面",
"MainWorkspacePath": "主工作區路徑",
"MiscOptions": "雜項設置",
"MoveWorkspace": "移動工作區...",
"MoveWorkspaceFailed": "移動工作區失敗",
"MoveWorkspaceFailedMessage": "移動工作區失敗",
"MoveWorkspaceTooltip": "將工作區資料夾移動到新位置。移動前會自動停止知識庫以避免檔案鎖定問題。",
"Name": "工作區名",
"NameDescription": "工作區的名字將顯示在側邊欄上可以與工作區Git倉庫的實際文件夾名不同",
"NoRevert": "注意!這個操作無法撤銷!",

View file

@ -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<IWorkspaceViewService>(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 });

View file

@ -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 }),
});
}
}
}}