Skip to content

Feature/restore#84

Merged
mcgivrer merged 6 commits into
developfrom
feature/restore
May 18, 2026
Merged

Feature/restore#84
mcgivrer merged 6 commits into
developfrom
feature/restore

Conversation

@jib63
Copy link
Copy Markdown
Collaborator

@jib63 jib63 commented May 18, 2026

Restore workspace when reopen

jib63 and others added 4 commits May 18, 2026 20:49
Persist and restore complete workspace state across sessions and hard kills:

- Window geometry (x, y, width, height, maximized, fullscreen) saved to
  config via debounced property listeners — survives SIGKILL because state
  is written on every change, not only at shutdown
- Active tab per project stored in [active_file] section of .marknote
- ProjectSessionService: new SessionData record (openFiles + activeFile);
  loadSession() returns SessionData instead of List<File>
- Auto-restore on startup via handleStartupRestore(): when
  restoreWorkspaceOnStart=true (default), the last project + session are
  reopened automatically without a confirmation dialog
- ShutdownHook registered for SIGTERM / unexpected JVM exit
- geometryDebouncer shut down cleanly in Application.stop()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In reading mode the window is fullscreen and panels are rearranged.
Persisting that state (fullscreen=true, resized dimensions) would cause
the workspace to restore into a broken fullscreen layout on next launch.

All six geometry listeners (x, y, width, height, maximized, fullscreen)
now guard on !readingModeActive so only the pre-reading-mode geometry is
kept in config.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Show an elegant semi-transparent overlay during startup workspace
restoration so the user gets visual feedback while files are loaded.

- WorkspaceRestoreOverlay: StackPane with 50% dark backdrop, centered
  card (white/rounded/drop-shadow), app logo, title label,
  determinate ProgressBar and per-file status label
- Scene root changed to StackPane(root, overlay) so the overlay can
  cover the full window without disrupting existing layout
- openSessionFilesSequentially(): opens session files one-by-one via
  Platform.runLater chain so the FX thread can repaint the progress
  bar between each file; hides overlay once all files are open
- setupProjectDirectory() extracted from openProjectDirectory() to
  allow the restore path to call setup + sequential open separately
- i18n keys restore.overlay.title / restore.overlay.file added to all
  6 language files (fr, en, de, es, it, default)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace StackPane with AnchorPane as scene root so the overlay is
  pinned to all 4 edges and always covers the full window
- Replace programmatic setBackground() with a Rectangle child whose
  width/height are bound to the overlay, making it immune to CSS theme overrides
- Fix geometry debouncer bug: all 4 listeners (x, y, width, height) now
  share a single saveGeometry Runnable so a resize cannot cause one
  property to silently overwrite the others mid-debounce
- Apply macOS fullscreen restoration via showingProperty listener
  instead of bare Platform.runLater (fires too early before stage show)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mcgivrer
Copy link
Copy Markdown
Owner

Je tombe sur un bug que je ne comprends pas:

Quoi que je fasse, le projet se rouvre ET la question "Dois-je rouvrir le précédent projet" apparait :

image

Pourtant dans le code:

  1. A l'ouverture (j'ai un peu refactoré pour la lecture)

MarNote.java:436

        // Afficher le splash screen ; la fenêtre principale et la logique de
        // démarrage s'exécutent une fois le splash fermé.
        if (config.isShowSplashScreen()) {
            SplashScreen splash = new SplashScreen(messages, config.getCurrentTheme());
            splash.setOnClosed(() -> {
                startWorking(stage);
            });
            splash.show();
        } else {
            startWorking(stage);
        }
    }

    private void startWorking(Stage stage) {
        stage.show();
        handleStartupRestore();
        // Rouvrir le dernier projet si l'option est activée
        handleReopenLastProject();
        checkForUpdatesOnStartup();
    }
  1. Et le processing du "handleStartupRestore"

MarkNote.java:1436

    /**
     * Point d'entrée unique pour la logique de démarrage (après splash éventuel).
     * Si restoreWorkspaceOnStart est actif, le dernier workspace est restauré
     * automatiquement avec un overlay de progression. Sinon, le comportement
     * historique (dialogue de confirmation) est conservé.
     */
    private void handleStartupRestore() {
        if (config.isRestoreWorkspaceOnStart() && !config.getRecentDirs().isEmpty()) {
            File lastDir = new File(config.getRecentDirs().getFirst());
            if (lastDir.exists() && lastDir.isDirectory()) {
                restoreOverlay.show();
                setupProjectDirectory(lastDir);
                ProjectSessionService.SessionData session = projectSessionService.loadSession(lastDir);
                openSessionFilesSequentially(session.openFiles(), 0, session.activeFile());
                return;
            }
        }
        // Comportement historique : dialogue de confirmation ou onglet de bienvenue
        handleReopenLastProject();
        if (config.isShowWelcomePage()) {
            showWelcomeTab();
        }
        if (config.isOpenDocOnStart() && !config.isShowWelcomePage()) {
            addNewDocument();
        }
    }

@mcgivrer
Copy link
Copy Markdown
Owner

La taille des panels n'est plus sauvegardée.

@jib63
Copy link
Copy Markdown
Collaborator Author

jib63 commented May 18, 2026

Je reprendrais la feature. Il y a visiblement quelque chose que j’ai loupé

@jib63 jib63 marked this pull request as draft May 18, 2026 21:07
@mcgivrer mcgivrer marked this pull request as ready for review May 18, 2026 21:16
@mcgivrer mcgivrer merged commit e86eba9 into develop May 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants