Summary
Switching to a different ClioDeck project while the editor has unsaved changes silently discards those changes — no save prompt, no warning, no save attempt at all. This is the same class of bug already fixed once at the chapter-switch level (the fix-bascule-fichier history) but reintroduced one level up, at the project-switch level.
Found while auditing the ClioDeck wiki against the actual code (pass 16, editor & export cluster, project-switch-mid-operation angle).
Current behavior (verified against code)
- Switching chapters or documents within a project is safe:
src/renderer/src/stores/editorStore.ts's loadFile() explicitly checks isDirty and awaits saveFile() before proceeding, refusing to open the next file if the save fails.
- Switching to a different project entirely goes through a completely separate code path:
src/renderer/src/stores/projectStore.ts's loadProject() (lines 90+) calls window.electron.project.load(projectPath) immediately, with no check of isDirty and no call to saveFile() anywhere in the function.
- All three renderer call sites of
loadProject() (src/renderer/src/components/Project/ProjectPanel.tsx:94,119,318 — opening a project via dialog, opening a path directly, and opening a recent project from the list) go through this same unguarded path.
- The main-process
project:load IPC handler (src/main/ipc/handlers/project-handlers.ts:102) also has no isDirty/save-related logic.
Impact
A user with unsaved edits in the currently open document/chapter who opens a different project (including via the "recent projects" list, a common quick-switch action) loses those edits with zero warning. This is a real, user-facing data-loss bug in a very commonly used action.
Suggested fix
Apply the same guard loadFile() already uses at the chapter level to loadProject(): check useEditorStore.getState().isDirty before proceeding, and await a save (or prompt the user) before opening the new project, refusing to proceed if the save fails — mirroring the existing, working chapter-switch guard.
Evidence trail
src/renderer/src/stores/editorStore.ts — loadFile(), the existing (correct) chapter-switch guard, for comparison.
src/renderer/src/stores/projectStore.ts:90-114 — loadProject(), no such guard.
src/renderer/src/components/Project/ProjectPanel.tsx:94,119,318 — all three call sites.
src/main/ipc/handlers/project-handlers.ts:102 — project:load handler, no save-related logic.
- Wiki page corrected in the same pass:
1.16-The-Editor.md.
Summary
Switching to a different ClioDeck project while the editor has unsaved changes silently discards those changes — no save prompt, no warning, no save attempt at all. This is the same class of bug already fixed once at the chapter-switch level (the
fix-bascule-fichierhistory) but reintroduced one level up, at the project-switch level.Found while auditing the ClioDeck wiki against the actual code (pass 16, editor & export cluster, project-switch-mid-operation angle).
Current behavior (verified against code)
src/renderer/src/stores/editorStore.ts'sloadFile()explicitly checksisDirtyand awaitssaveFile()before proceeding, refusing to open the next file if the save fails.src/renderer/src/stores/projectStore.ts'sloadProject()(lines 90+) callswindow.electron.project.load(projectPath)immediately, with no check ofisDirtyand no call tosaveFile()anywhere in the function.loadProject()(src/renderer/src/components/Project/ProjectPanel.tsx:94,119,318— opening a project via dialog, opening a path directly, and opening a recent project from the list) go through this same unguarded path.project:loadIPC handler (src/main/ipc/handlers/project-handlers.ts:102) also has noisDirty/save-related logic.Impact
A user with unsaved edits in the currently open document/chapter who opens a different project (including via the "recent projects" list, a common quick-switch action) loses those edits with zero warning. This is a real, user-facing data-loss bug in a very commonly used action.
Suggested fix
Apply the same guard
loadFile()already uses at the chapter level toloadProject(): checkuseEditorStore.getState().isDirtybefore proceeding, and await a save (or prompt the user) before opening the new project, refusing to proceed if the save fails — mirroring the existing, working chapter-switch guard.Evidence trail
src/renderer/src/stores/editorStore.ts—loadFile(), the existing (correct) chapter-switch guard, for comparison.src/renderer/src/stores/projectStore.ts:90-114—loadProject(), no such guard.src/renderer/src/components/Project/ProjectPanel.tsx:94,119,318— all three call sites.src/main/ipc/handlers/project-handlers.ts:102—project:loadhandler, no save-related logic.1.16-The-Editor.md.