Skip to content

Commit 64cadd4

Browse files
committed
docs: update session manager docs
1 parent 414c827 commit 64cadd4

6 files changed

Lines changed: 135 additions & 15 deletions

File tree

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,12 @@ For distro-specific package details, see [Installation](#installation). For keyb
224224
- Copy to clipboard or save to file
225225
- Uses `grim`, `slurp`, `wl-clipboard` (installed automatically by deb/rpm/AUR packages; fallback: xdg-desktop-portal)
226226

227-
### Session Persistence
228-
- Opt-in per board/monitor canvas + tool state restore
229-
- CLI overrides: `--resume-session` / `--no-resume-session`
227+
### Session Manager & Persistence
228+
- Session persistence is enabled by default for boards, undo/redo history, and tool state
229+
- Per-output default sessions, plus named session files with `--session-file`
230+
- Overlay Session panel: Open, Save As, Info, Clear, recent sessions, and Manager
231+
- Configurator Session tab: rename/reveal/forget catalog entries, plus duplicate/move/clear inactive session files
232+
- CLI overrides: `--resume-session`, `--no-resume-session`, `--session-info`, and `--clear-session`
230233
- Tray checkmark flips config on disk
231234

232235
### Toolbars & UI
@@ -788,7 +791,7 @@ ui_animation_fps = 30
788791
# named boards + backgrounds
789792
```
790793

791-
### Session Persistence
794+
### Session Manager & Persistence
792795

793796
Enable via configurator (<kbd>F11</kbd> → Session tab), CLI flags, or the tray checkmark (writes to config).
794797

@@ -798,15 +801,19 @@ wayscriber --no-resume-session # disable resume for this run
798801
wayscriber --session-info # inspect saved sessions
799802
wayscriber --clear-session # remove stored boards
800803
wayscriber --active --session-file ~/Documents/lecture-04.wayscriber-session
804+
wayscriber --freeze --session-file ~/Documents/lecture-04.wayscriber-session
801805
wayscriber --daemon --session-file ~/Documents/lecture-04.wayscriber-session
802806
wayscriber --daemon-toggle --session-file ~/Documents/meeting.wayscriber-session
803807
wayscriber --session-info --session-file ~/Documents/lecture-04.wayscriber-session
808+
wayscriber --clear-session --session-file ~/Documents/lecture-04.wayscriber-session
804809
```
805810

806811
Notes:
807812
- When `restore_tool_state` is enabled (default), the last-used tool settings (including arrow head placement) override config defaults on startup. Disable it in the Session tab or clear the session to force config values.
808-
- `--session-file` uses exactly the selected file, implies persistence for that overlay run, and does not create missing parent directories. A running daemon can launch a hidden overlay with a named target; if the overlay is already visible, hide it before switching to a different named session.
809-
- The configurator Session tab can manage recent named sessions: rename catalog labels, reveal files, and forget metadata. When no overlay/background service is active, it can duplicate a session by copying its primary file, move inactive session files, and clear saved data.
813+
- `--session-file` uses exactly the selected file, implies persistence for that overlay run, rejects directories/symlinks/special files, and does not create missing parent directories. A running daemon can launch a hidden overlay with a named target; if the overlay is already visible, hide it before switching to a different named session.
814+
- The overlay Session panel lives in the side toolbar's Settings drawer. It can open an existing named session, save the current overlay as another named session, show session info, clear the active session, reopen recent named sessions, and jump to the configurator. The Open/Save As dialogs use `zenity` or `kdialog`; Save As appends `.wayscriber-session` when no extension is supplied and asks before replacing existing session artifacts.
815+
- The configurator Session tab manages recent named sessions recorded when named-session targets are opened or saved from the CLI, daemon, or overlay. It can rename catalog labels, reveal files, and forget metadata without touching files. Duplicate, Move, and Clear are disabled while an overlay, manually started daemon, or background service is active.
816+
- See [Session manager examples](examples/session-manager.md) for complete CLI, overlay, and configurator workflows.
810817

811818
### Tablet/Stylus Support
812819

@@ -922,7 +929,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, project structure,
922929
- [x] Native Wayland layer-shell
923930
- [x] Daemon mode with system tray
924931
- [x] Multiple customizable boards/backgrounds
925-
- [x] Session persistence (with CLI override + tray config toggle)
932+
- [x] Session manager and persistence (named sessions, overlay actions, configurator catalog, CLI override, tray config toggle)
926933
- [x] Highlighter & eraser tools
927934
- [x] Additional shapes (filled shapes)
928935
- [x] Color picker

config.example.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,10 @@ storage = "auto"
686686

687687
# CLI note: --session-file PATH bypasses this storage directory for that run and
688688
# saves to exactly PATH, without creating missing parent directories.
689+
# The overlay Session panel can Open, Save As, inspect, clear, and reopen recent
690+
# named sessions. Save As appends .wayscriber-session when no extension is used.
691+
# The configurator Session tab can rename/reveal/forget catalog entries, and can
692+
# duplicate, move, or clear inactive session files when no overlay/daemon is running.
689693

690694
# Store separate sessions per monitor (set false to reuse one file per display)
691695
per_output = true

configurator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The window loads the current config, lets you tweak values across the tabbed sec
3232
- **Drawing, Arrow, Performance, UI, Board, Capture** – numeric fields with inline validation, toggles, and color editors (RGBA/RGB components).
3333
- **Default color** – toggle between named colors and custom RGB triples.
3434
- **Keybindings** – per-action comma-separated shortcut lists that map to `KeybindingsConfig`.
35-
- **Session** – persistence settings plus named-session catalog management: rename display labels, reveal files, forget metadata, and clear saved data when no overlay/background service is active.
35+
- **Session** – persistence settings plus named-session catalog management. Rename display labels, reveal files, and forget metadata without touching files. Duplicate, Move, and Clear are disabled while an overlay, manually started daemon, or background service is active.
3636
- Live dirty-state indicator plus status banner for success/error details.
3737

3838
## Building Releases

docs/CONFIG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,17 +892,29 @@ Use the CLI helpers for quick maintenance:
892892
- `wayscriber --daemon --session-file ~/Documents/lecture-04.wayscriber-session` starts a daemon whose overlay activations use that named session target.
893893
- `wayscriber --daemon-toggle --session-file ~/Documents/meeting.wayscriber-session` asks the running daemon to launch a hidden overlay with that named session target. If the overlay is already visible with a different target, hide it before switching.
894894
- `wayscriber --session-info --session-file <path>` and `wayscriber --clear-session --session-file <path>` inspect or remove only that named file and its sidecars.
895-
- The configurator Session tab also shows recent named sessions from the catalog. It can rename catalog display labels, reveal file locations, and forget catalog metadata without touching files. When no overlay/background service is active, it can duplicate a session by copying its primary file to a new target, move inactive session files and their non-lock sidecars to a new path, and clear saved data.
895+
896+
The overlay Session panel lives in the side toolbar's Settings drawer:
897+
898+
- `Open` loads an existing named session, saves dirty current data first when needed, and records the target in the recent catalog.
899+
- `Save As` writes the current overlay to another named session and switches the active target. It appends `.wayscriber-session` when no extension is supplied and asks before replacing existing session artifacts.
900+
- `Info` reports the active session file size, board shape counts, and history status.
901+
- `Clear` writes a durable empty session boundary for the active target.
902+
- Recent session rows reopen other named sessions. If a recent target is missing, Wayscriber removes that stale catalog entry after the failed open.
903+
- `Manager` opens the configurator. Overlay Open/Save As dialogs use `zenity` or `kdialog`.
904+
905+
The configurator Session tab also shows recent named sessions from the catalog, recorded when named-session targets are opened or saved from the CLI, daemon, or overlay. It can rename catalog display labels, reveal file locations, and forget catalog metadata without touching files. Duplicate, Move, and Clear are disabled while an overlay, manually started daemon, or background service is active.
896906

897907
Session overrides and recovery:
898908

899909
- CLI flags: `--resume-session` forces persistence on, `--no-resume-session` forces it off for the current run. The environment variable `WAYSCRIBER_RESUME_SESSION=1/0` does the same.
900-
- `--session-file` implies session persistence for that overlay run and conflicts with `--no-resume-session`. Named sessions use the exact selected file path; Wayscriber does not create missing parent directories or fall back to configured storage.
910+
- `--session-file` implies session persistence for that overlay run and conflicts with `--no-resume-session`. Named sessions use the exact selected file path; Wayscriber does not create missing parent directories or fall back to configured storage. Foreground/open targets reject directories, symlinks, and special files.
901911
- Size fallback: if visible drawings fit but persisted undo/redo history would exceed save or restore safety limits, autosave saves the drawings and warns once per run that history was trimmed or omitted.
902912
- Image paste guard: when a pasted image would push visible session data over `max_file_size_mb`, Wayscriber blocks the paste and points you to `[session] max_file_size_mb`; when only undo history is at risk, the paste is allowed with a warning.
903913
- Load safety: compressed session files are checked against an internal expanded-size cap while saving and loading. If an existing file expands beyond that cap, wayscriber refuses to load it, leaves the primary session file unchanged, and avoids overwriting it until session data changes.
904914
- Recovery: if a session file is corrupt or cannot be parsed/decompressed, wayscriber logs a warning, writes a `.bak` copy of the bad file, removes the corrupt file, and continues with defaults. Overrides above still apply after recovery.
905915

916+
For end-to-end CLI, overlay, and configurator flows, see [`examples/session-manager.md`](../examples/session-manager.md).
917+
906918
### `[keybindings]` - Custom Keybindings
907919

908920
Customize keyboard shortcuts for all actions. Each action can have multiple keybindings.

docs/codebase-overview.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This document explains how the application boots, how user input travels through
77
## 1. Execution Flow From `main.rs`
88

99
1. **CLI parsing (`src/main.rs`)**
10-
- Uses `clap` to parse `--daemon`, `--active`, `--mode`, and session management flags.
10+
- Uses the manual parser in `src/cli.rs` for `--daemon`, `--active`, `--mode`, named session, and session maintenance flags.
1111
- Verifies `WAYLAND_DISPLAY` when a Wayland session is required.
1212

1313
2. **Mode selection**
@@ -17,6 +17,7 @@ This document explains how the application boots, how user input travels through
1717

1818
3. **Shared subsystems automatically pulled in**
1919
- `config`: loads user settings, key bindings, and drawing defaults.
20+
- `session`: builds configured or named session targets, validates `--session-file`, loads saved state, and records named-session catalog entries.
2021

2122
---
2223

@@ -133,7 +134,25 @@ Notifications are sent via `notification::send_notification_async`, keeping all
133134

134135
---
135136

136-
## 7. Utility Modules
137+
## 7. Session Persistence and Named Session Manager
138+
139+
**Modules:**
140+
- `src/session/`: target options, primary-file validation, snapshot load/save, sidecars, clear/recovery markers, locks, catalog metadata, and inactive file operations.
141+
- `src/backend/wayland/session/`: runtime Open, Save As, and Clear transactions for the active overlay.
142+
- `src/backend/wayland/state/toolbar/events/session.rs`: overlay Session panel routing for Open, Save As, Info, Clear, recent sessions, and configurator launch.
143+
- `src/daemon/`: accepts daemon-toggle requests that carry an optional named session target.
144+
145+
**Flow:**
146+
1. CLI `--session-file` creates a named target instead of using configured storage. Named targets force persistence for that run, reject `--no-resume-session`, require an existing parent directory for foreground/open flows, and reject directories, symlinks, and special files.
147+
2. Backend startup builds `SessionOptions` from config plus any named target, then session loading restores boards/history/tool state before rendering begins.
148+
3. Runtime Open first saves dirty current data when needed, loads the candidate named session without mutating it, replaces board state only after a valid load, and records the open in the named-session catalog.
149+
4. Runtime Save As validates the target, prompts before replacing existing artifacts, writes the snapshot, switches the active target, and records the save in the catalog.
150+
5. Runtime Clear writes a durable empty-session boundary so older backup or recovery artifacts do not restore stale drawings.
151+
6. The configurator reads the same catalog for inactive-session management: rename/reveal/forget metadata, duplicate primary files, move non-lock sidecars, and clear saved data when daemon/overlay locks are absent.
152+
153+
---
154+
155+
## 8. Utility Modules
137156

138157
- **`src/draw/`**: Shape definitions, Cairo helpers, arrow geometry, fonts, and the `CanvasSet` abstraction (with undo/history per board mode).
139158
- **`src/ui.rs`**: Composes the status bar and help overlay using Cairo.
@@ -143,7 +162,7 @@ Notifications are sent via `notification::send_notification_async`, keeping all
143162

144163
---
145164

146-
## 8. Directory Map (excluding configurator)
165+
## 9. Directory Map (excluding configurator)
147166

148167
| Path | Role |
149168
|------|------|
@@ -155,19 +174,21 @@ Notifications are sent via `notification::send_notification_async`, keeping all
155174
| `src/ui.rs` | Status/help overlays. |
156175
| `src/capture/` | Screenshot pipeline (manager, dependencies, sources, clipboard/file helpers). |
157176
| `src/config/` | Config parsing, defaults, keybinding map. |
177+
| `src/session/` | Configured and named session persistence, snapshots, sidecars, locks, and catalog metadata. |
158178
| `src/notification.rs` | Desktop notifications for capture results. |
159179
| `src/util.rs` | Shared math/color utilities. |
160180
| `tests/` | CLI + rendering integration tests. |
161181

162182
---
163183

164-
## 9. Putting It Together
184+
## 10. Putting It Together
165185

166186
1. **Launch** via CLI → choose daemon vs active.
167187
2. **Daemon** provides lifecycle management, tray integration, and toggles the backend on demand.
168188
3. **Backend** sets up Wayland surfaces and loops, forwarding input to `InputState`.
169189
4. **InputState + draw/ui** update the overlay contents and request renders.
170190
5. **Capture** subsystem handles screenshot actions asynchronously and notifies the user.
171-
6. **Config** module ensures user preferences are honored everywhere.
191+
6. **Session** loads and saves configured or named session state, including runtime Open/Save As/Clear transactions.
192+
7. **Config** module ensures user preferences are honored everywhere.
172193

173194
Use this document to trace any feature: locate the entry point (CLI, tray, keybinding), follow it through the backend/input/capture stacks, and consult the relevant modules listed above for details.

examples/session-manager.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Session Manager Examples
2+
3+
These examples cover named sessions. Default persistence still works without a
4+
named file: start Wayscriber normally and it restores the configured session
5+
storage on the next run.
6+
7+
## Direct CLI Workflows
8+
9+
Use a named session file when you want one drawing set per meeting, lecture, or
10+
project:
11+
12+
```bash
13+
wayscriber --active --session-file ~/Documents/lecture-04.wayscriber-session
14+
wayscriber --freeze --session-file ~/Documents/lecture-04.wayscriber-session
15+
```
16+
17+
Named sessions can also be the target for daemon launches:
18+
19+
```bash
20+
wayscriber --daemon --session-file ~/Documents/default-work.wayscriber-session
21+
wayscriber --daemon-toggle --session-file ~/Documents/meeting.wayscriber-session
22+
```
23+
24+
Inspect or clear one named session without touching the configured default
25+
session:
26+
27+
```bash
28+
wayscriber --session-info --session-file ~/Documents/lecture-04.wayscriber-session
29+
wayscriber --clear-session --session-file ~/Documents/lecture-04.wayscriber-session
30+
```
31+
32+
`--session-file` uses the exact selected file, rejects directories, symlinks,
33+
and special files, and conflicts with `--no-resume-session`. Launch, Open, and
34+
Save As flows require an existing parent directory. `--session-info` and
35+
`--clear-session` can still report or clean up stale named-session paths when
36+
the parent directory is already gone.
37+
38+
## Overlay Workflow
39+
40+
Open Wayscriber with any persisted session target, then use the side toolbar's
41+
Settings drawer:
42+
43+
- `Open` loads an existing named session and records it in the recent catalog.
44+
- `Save As` writes the current overlay to another named session and switches the
45+
active target. It appends `.wayscriber-session` when no extension is supplied
46+
and asks before replacing existing session artifacts.
47+
- `Info` reports the active session file size, board shape counts, and history
48+
status.
49+
- `Clear` writes a durable empty session boundary for the active target.
50+
- Recent session rows reopen other named sessions.
51+
- `Manager` opens the configurator.
52+
53+
The overlay file picker uses `zenity` first and falls back to `kdialog`.
54+
55+
## Configurator Catalog Workflow
56+
57+
Run:
58+
59+
```bash
60+
wayscriber-configurator
61+
```
62+
63+
Open the Session tab and use the Saved Sessions section. It shows recent named
64+
sessions recorded when named-session targets are opened or saved from the CLI,
65+
daemon, or overlay.
66+
67+
- `Save Name` changes only the catalog display label.
68+
- `Reveal File` opens the session's parent folder.
69+
- `Forget` removes catalog metadata without deleting session files.
70+
- `Duplicate` copies the primary session file to a new named target.
71+
- `Move` moves an inactive session's primary file and non-lock sidecars.
72+
- `Clear Saved Data` removes saved data and sidecars for that catalog entry.
73+
74+
Duplicate, Move, and Clear are disabled while an overlay, manually started
75+
daemon, or background service is active. Stop the service or close the overlay
76+
before managing inactive session files from the configurator.

0 commit comments

Comments
 (0)