Skip to content

Commit 623c649

Browse files
committed
fix(desktop): address PR #173 review comments
- Surface write-through failure in persistMutation instead of silently swallowing the error, so callers can propagate it to the UI - Classify workspace migration collision and missing tracked-file errors as IPC_BAD_INPUT in snapshots-ipc for actionable client-side messages - Normalize workspace paths before comparison in FilesTabView to avoid false rebind prompts caused by trailing slashes or path-separator diffs Signed-off-by: roy1994 <dev.mancitrus@outlook.com>
1 parent 1cff6da commit 623c649

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

apps/desktop/src/main/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,14 @@ export function createRuntimeTextEditorFs({
231231
mkdirSync(path_module.dirname(destinationPath), { recursive: true });
232232
writeFileSync(destinationPath, content, 'utf8');
233233
} catch (err) {
234+
const message = err instanceof Error ? err.message : String(err);
234235
logger.error('runtime.fs.writeThrough.fail', {
235236
designId,
236237
filePath,
237238
workspacePath: design.workspacePath,
238-
message: err instanceof Error ? err.message : String(err),
239+
message,
239240
});
241+
throw new Error(`Workspace write-through failed for ${filePath}: ${message}`);
240242
}
241243
}
242244

apps/desktop/src/main/snapshots-ipc.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,14 @@ export function registerWorkspaceIpc(db: Database, getWin: () => BrowserWindow |
410410
} catch (err) {
411411
if (err instanceof CodesignError) throw err;
412412
if (err instanceof Error && err.message.includes('already bound')) {
413-
throw new CodesignError(err.message, 'IPC_CONFLICT');
413+
throw new CodesignError(err.message, 'IPC_CONFLICT', { cause: err });
414+
}
415+
if (
416+
err instanceof Error &&
417+
(err.message.includes('Workspace migration collision') ||
418+
err.message.includes('Tracked workspace file missing'))
419+
) {
420+
throw new CodesignError(err.message, 'IPC_BAD_INPUT', { cause: err });
414421
}
415422
throw new CodesignError('Workspace update failed', 'IPC_DB_ERROR', { cause: err });
416423
}

apps/desktop/src/renderer/src/components/FilesTabView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ function WorkspaceSection() {
5050
setPicking(true);
5151
const path = await window.codesign.snapshots.pickWorkspaceFolder();
5252
if (path && currentDesign && currentDesignId) {
53-
if (currentDesign.workspacePath && currentDesign.workspacePath !== path) {
53+
const normalizePath = (p: string) => p.replaceAll('\\', '/').replace(/\/+$/, '');
54+
if (
55+
currentDesign.workspacePath &&
56+
normalizePath(currentDesign.workspacePath) !== normalizePath(path)
57+
) {
5458
requestWorkspaceRebind(currentDesign, path);
5559
} else if (!currentDesign.workspacePath) {
5660
await window.codesign.snapshots.updateWorkspace(currentDesignId, path, false);

0 commit comments

Comments
 (0)