* An editor could merge their working version straight into the main version of a project that
needs approval with "Combine versions" (POST /projects/{id}/combine), which needed `editor` only:
the review policy's whole promise, gone for anybody who can edit. The same route merged into
someone else's working version, the source of their open draft, and POST /projects/{id}/versions
could create that version in advance. `changes.assert_may_write_version` is the one rule for
both routes: the main version of a `review_required` project is moved by an approver or a
manager (D4: the approver role is the whole rule), someone else's `version/...` by a manager.
* "Resolve discrepancies" wrote around the write chokepoint: it published a draft that was already
rejected or withdrawn, wrote any path it was handed (files nobody reviewed, committed under
"Publish draft"), and committed an encrypted file's resolved text in plain text. It now needs an
open draft, writes only the files the draft changes, encrypts under the file's mode (a passphrase
file is refused, it cannot be encrypted without the passphrase), and the conflict picker shows
the decrypted text instead of ciphertext. `git add` gets `--` before the path.
DB-free regression tests in tests/test_review_gate.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 KiB
Galena — Functional Documentation
This document describes what Galena does and how people use it — its features, concepts, and
workflows — independent of the implementation. For setup/architecture see README.md;
for dependency licensing see CREDITS.md.
1. What Galena is
Galena is a self-hosted, git-backed cloud drive. To the person using it, it looks and behaves like an ordinary file-storage app — folders, uploads, a grid of documents, sharing, search. Underneath, every project's files live in a real git repository, so the product gives you full version history, side-by-side comparison, review-before-publish, authorship per line, and rollback — without requiring any knowledge of git. The interface is deliberately de-jargoned: you never see the words "commit", "branch", or "merge"; you see redactions, versions, and publish.
Who it's for: teams that want versioned, reviewable document storage they host themselves.
2. Key concepts & terminology
Galena renames git's concepts into plain language. The friendly term is what you see in the app.
| You see (friendly) | Means | Notes |
|---|---|---|
| Workspace | A top-level space for a team | The outermost container and a permission boundary. |
| Group / Folder | A container inside a workspace | Organises things; can carry its own access. |
| Project | A place where files live with full history | The only container that is a versioned repository. |
| Main version | The official, current copy everyone sees | The default line of a project. |
| Version | A separate working copy | Lets you make changes without touching the main version. |
| Redaction | One saved change | A point in history you can return to. |
| Draft | Proposed changes sent for review | Submitted from a working version, published by an approver. |
| Publish | Bring approved changes into the main version | |
| Combine versions | Merge one version's changes into another | (Not necessarily the main version.) |
| Resolve discrepancies | Decide what to keep when two edits overlap | The conflict-resolution screen. |
| Changes | A before-and-after comparison | Side-by-side / unified / inline, word-level highlights, with who-changed-it tooltips — works for documents (PDF, Word, e-books) too, not just text. |
| Authorship | Who wrote each line, and when | |
| Clone | Make your own separate copy of a project, with its history |
A built-in glossary is also available in the app under Account → About & help.
3. The access model (roles & permissions)
Access is granted to a person on any node (a workspace, group, folder, or project). A grant cascades downward: granting someone access on a workspace gives them that access on everything inside it. The effective access on any item is the highest grant they hold on that item or any of its ancestors.
Roles, from least to most powerful:
| Role | Can… |
|---|---|
| Viewer | Open and read items; download files; view history, changes, and authorship. |
| Editor | Everything a viewer can, plus: create/edit/upload/rename/move/copy/delete files, save redactions, submit drafts, and take part in review threads. |
| Approver | Everything an editor can, plus: approve & publish or request changes on a draft. |
| Manager | Everything an approver can, plus: manage members and roles on the item, rename/move/delete the node, and change project settings. |
Other rules:
- Instance administrators (a per-account flag) implicitly have manager-level access everywhere and can reach the Administration area.
- A node's owner (and your personal My files workspace) always has manager rights on it.
- No access → the item is hidden (you get a "not found", not a "forbidden", so its existence isn't leaked).
- You cannot approve your own draft — a different approver must review it.
- A viewer can read a review but not post in it; posting requires editor or higher.
The model is SSO/LDAP-ready: grants reference an abstract principal and passwords are optional at the schema level, so external identity providers can be added later.
4. The console at a glance
- Left sidebar — the file scopes: My files (your personal workspace), Favourites, Shared with me, Recent, an expandable Workspaces tree, a Storage usage indicator, and Settings. The Workspaces tree expands at every level — click the twisty next to any workspace, group, or folder to reveal what's inside it (projects are leaves, opened in the main area). The sidebar can be hidden; on narrow screens it becomes a drawer.
- Top bar — a sidebar toggle, a breadcrumb trail of where you are (each segment is clickable; it wraps to a second line for long paths), then the right-aligned actions: Dashboard, Drafts, Password generator, Text recognition (OCR), Administration (admins only), search, notifications (bell with an unread counter), theme, language, and your account menu.
- Main area — a grid/list of folders and files, or the current view (dashboard, a draft, history…).
The brand mark (a violet square with an asterisk) is the only place the brand colour appears; every other control is monochrome with outline icons.
Password generator (the key icon in the top bar) opens a built-in generator: choose a length
(4–64) and which character sets to include — uppercase, lowercase, numbers, symbols —
and get a fresh password with a strength estimate. Show/hide, Copy, and Regenerate are one
click each. It runs entirely in your browser using the platform's cryptographically secure random
source (crypto.getRandomValues, with rejection sampling so every character is equally likely) —
nothing is ever sent to the server or stored. The sign-in form also has a show/hide toggle on the
password field.
Text recognition (OCR) (the scan icon in the top bar) extracts text from a scanned image or
PDF. Drop a file (or browse), choose the language, and click Extract text; the result
appears in a box you can Copy or Download as .txt. Like the password generator, it runs
entirely in your browser — the document is never uploaded. The engine is Tesseract.js (the
Tesseract OCR engine compiled to WebAssembly, Apache-2.0), with 100+ languages; the chosen language
model downloads once on first use. It's strongest on clean printed text.
For tougher material (noisy scans, dense layout, handwriting), higher-accuracy server engines
(PaddleOCR / docTR) and cloud OCR are documented operator opt-ins (see OCR.md) — they're not in
the default in-browser tool because cloud OCR would send documents off the self-hosted box.
5. Workspaces, groups/folders, and projects
- Create anything from the New ▾ menu: a workspace (top level only), a group, a folder, a project, a document, or an upload.
- Projects are where versioned files live; creating one initialises its history automatically.
- Containers can be renamed, moved, and deleted (managers); deleting a container removes everything inside it.
- Drag and drop to move: drag a folder/group/project card onto another folder/group/workspace card to move it there; inside a project, drag a document onto a folder to move it within the project. (You need write access; dropping onto a project isn't allowed — projects hold files, not other items.)
- Turn a folder into a project (a folder/group's right-click menu → Turn into project): it becomes a versioned project (a git repository). Allowed only when the folder is empty — it can't contain a project (projects can't be nested) or any sub-folders. Move the contents out first if needed.
- A container's page header carries quick actions: Favourite (the star fills in when the item is one of your favourites, hollow when not — click to toggle), Share (managers), and Details (a panel listing type, path, access, policy, and encryption).
- Each card shows a status icon indicating access at a glance:
- plain — open / inherited access (nothing special needed);
- open padlock — access-controlled and you have access;
- closed padlock — you don't have access → offers Request access;
- people — shared with others;
- shield — the item is encrypted.
Drive views & sorting: switch between grid / compact / list, filter by name, and sort by name or size (ascending/descending). Your chosen view, sort field, and direction are remembered across sessions.
6. Working with files in a project
Inside a project you get the usual file-manager actions (via the New ▾ menu and a per-item right-click / kebab menu), subject to your role:
- Open (view) — clicking any document opens it read-only in the built-in ReaderJS viewer: PDF, DjVu, Word (DOC/DOCX), PowerPoint (PPTX), Excel (XLSX/XLS), OpenDocument (ODT/ODS/ODP), images, comic archives (CBZ/CBR), e-books (EPUB/MOBI), source code, and more — all in your browser, nothing uploaded. The viewer has a ✕ close button (and closes on Esc or by clicking the backdrop).
- Edit — editing is a separate action (the kebab menu's Edit, or the Edit button inside the viewer), shown for the formats Galena edits in-app: text/Markdown, DOCX/ODT, RTF, and legacy DOC. Other types (PDF, images, slides, sheets…) edit via Open on your computer (download → edit → drop the file back to save a new version).
- Download the file.
- Create a document or Upload files (there is a per-file size limit to protect the server).
- Rename, Move (to a new path within the project), and Copy a file.
- History and Authorship for the file.
- Encrypt / Re-encrypt the file.
- Delete the file.
Office documents (Word / OpenDocument)
You can edit DOCX and ODT files right in the browser: Galena opens the document's text in the normal editor and saves your changes back as a DOCX/ODT, recorded as a redaction like any other edit. This editing is simplified — it keeps headings, paragraphs, bold/italic, lists and basic tables, but drops images, footnotes, comments, custom styles and tracked changes on save, so a banner warns you and offers Download original to edit with full formatting in your own app.
RTF files also edit in the browser, through a built-in text-level editor: clicking an .rtf
opens its text in a full-screen editor and Save writes it back as clean RTF, recorded as a
redaction like any other edit. As with DOCX/ODT this is simplified — text and paragraphs are kept, but
fonts, colours, tables and images are dropped on save — so a note offers Download for full-fidelity
editing in your own app.
Older DOC files (the Word 97–2003 binary format) edit in the browser too — clicking a .doc
opens a full-screen text editor and Save writes a real .doc back, recorded as a redaction. Like
RTF this is text-level and simplified (text and paragraphs are kept; other formatting is dropped on
save), so a banner offers Download for full-fidelity editing. An older/protected .doc that can't
be read, and any office file protected by a passphrase, fall back to the Download → edit →
Upload edited version handoff, which replaces the file in place as a new redaction. That "edit
locally" handoff is also the way to make a fully-faithful change to a DOCX/ODT/RTF/DOC when the
simplified editor isn't enough.
Edit any file on your computer. Every file (including plain text/Markdown) has an Open on your computer action — in its right-click menu and on the editor's toolbar. It downloads a copy so you can open it in your own desktop app — Microsoft Word, LibreOffice Writer, FreeOffice TextMaker, etc. (a web page can't choose the application, so this hands the file to your operating system's default handler / "Open with"). When you've edited and saved it, drag the file straight from your computer onto the document — onto its card in the project, or onto the open editor — and Galena saves it as the new version (a redaction, or a draft where the project needs approval). Dropping onto a document highlights it; the existing in-app editor still works for quick edits. If you prefer a file picker to drag-and-drop, Upload new version… (in the right-click menu and the viewer's Edit ▾ dropdown) does the same thing — pick the edited file and it's saved in place as the new version.
A note on history for office files: because Word/OpenDocument files are compressed binaries, Changes (the side-by-side diff) and Authorship aren't available for them the way they are for text — the file still has full version history and rollback, but you compare versions by opening them, not line by line.
Every save, upload, move, copy, or delete is recorded as a redaction in the project's history.
7. Document previews — the ReaderJS viewer
Clicking a document opens the built-in ReaderJS viewer (a self-contained, same-origin viewer that runs entirely in your browser — nothing is uploaded). One viewer handles everything:
- PDF (thumbnails, zoom, print), DjVu (now built in — a permissive decoder, no plugin needed), Word (DOC/DOCX), PowerPoint (PPTX), Excel (XLSX/XLS), OpenDocument (ODT/ODS/ODP/ODG), images (PNG/JPG/GIF/WebP/AVIF/BMP/SVG/TIFF, with EXIF) — grid cards still show thumbnails,
- Markdown / plain text / source code (syntax-highlighted), CSV/TSV,
- comic-book archives (CBZ/CBR/CBT) and e-books (EPUB/MOBI/AZW3/FB2).
The viewer's own toolbar (zoom, page navigation, language switcher) sits inside it; Galena adds a Download and (for editable types) an Edit button, plus the corner ✕ close. Untrusted file bytes are still served safely (sandboxed) so nothing can run code in the app.
8. The editor
Opening a text or Markdown document loads a rich, document-style editor (bold/italic/underline, headings, bullet/numbered lists, tables, links, quotes) that fills the available width. If the editor can't load, it falls back to a plain text box so editing always works. The editor toolbar has:
- Save — saves your changes (routes through the normal save workflow below, so an edit becomes a redaction or a draft depending on the project's policy).
- Submit draft — shown only when the project needs approval, to send your working version for review.
- Print — renders the document to a clean, paginated page and opens your browser's print dialog (works whether the rich editor or the plain-text fallback is loaded).
The editor picks the right tool for the file:
- Markdown — write visually (Rich) or switch to Markdown for a raw editor with a live preview beside it and a markdown toolbar (bold, headings, lists, link, image).
- Code & config (JS, TS, JSON, YAML, CSS, HTML, SQL, shell, Python, C, …) — a code editor with line numbers and syntax highlighting that follows your light/dark theme.
- CSV/TSV — an editable table: type in cells, add or delete rows and columns.
- Anything else (PDF, spreadsheets, slides, images, …) — shown read-only with the Open on your computer → upload new version round-trip.
Across every editor: a word/character count, Find & replace (Ctrl/⌘-F), a fullscreen toggle, and an unsaved-changes warning before you navigate away or close the tab.
9. Saving, versions, and the review policy
Each project has a review policy:
- Save directly (
open) — your saves are recorded as redactions straight onto the main version. - Needs approval (
review_required) — your saves land on your own working version, and you submit a draft to bring them into the main version. Nothing reaches the main version until an approver publishes it.
Managers set the policy per project; admins set the default for new projects.
A version switcher sits in both the project header and the file editor (next to the actions). It shows the current version (Main version by default) and lets you switch to another version or create a new version from the one you're on — a separate working line where you can make changes without touching the main version, then bring them in with a draft or Combine versions. Creating or switching a version from the editor keeps the file you have open.
10. Drafts & review (the review conversation)
A draft is a request to bring a working version's redactions into the main version. Opening a draft shows a review conversation:
- Changed files — each links to its Changes (the diff) and, for participants, a Comment button.
- Comment threads — the review is organised as resolvable threads:
- Start a thread with a top-level comment (optionally anchored to a file).
- Reply within a thread (replies nest under the thread and inherit its file anchor).
- Resolve a thread to close it (it collapses) and Reopen it later; expand/collapse with Show/Hide.
- Actions are role-aware:
- An approver (who isn't the author) sees Approve & publish and Request changes (the latter opens a box for the reason, which is recorded in the thread).
- The author sees Withdraw and a note that they're waiting for an approver.
- When a draft is closed (published, sent back, or withdrawn) the conversation becomes read-only and a status banner explains the outcome.
- Approve & publish merges the draft into the main version. If the merge overlaps with other edits, you're taken to Resolve discrepancies instead.
Drafts are listed on the Drafts screen — those you authored plus open ones you can approve (the latter flagged "for you").
11. Resolve discrepancies (conflicts)
When publishing (or combining) would overlap with changes already made elsewhere, Galena detects the conflict and opens Resolve discrepancies: a per-file, side-by-side picker showing Main version, Your version, and an editable Result. You choose which side to keep (or write a combined result) and then publish. Plain-language throughout — "two people changed the same lines; choose what to keep."
12. Combine versions
From a project's History you can Combine versions — merge one version's changes into another (not necessarily the main version). You pick a source and a target version; a clean merge applies immediately, and an overlapping one reports the discrepancies.
Two targets are not an editor's to combine into: the main version of a project that needs approval (only an approver or a manager may; for everybody else the way in is a draft), and someone else's working version (it is the source of their draft; only a manager may). The same goes for creating someone else's working version in advance.
13. Clone
Clone makes an independent copy of a project — with its full history — as a new project. Useful for branching off a separate line of work that won't affect the original.
14. History & Changes
- History of a project is shown as an interactive version graph: a lane-packed timeline of every redaction across all versions, with branch/merge lines and version-tip badges (e.g. main version). Click any redaction to see its details and exactly which files it changed; each file links to its Changes.
- A single file's History is a clickable timeline of its redactions.
- Changes is the diff between two points, shown in the ReaderJS compare view: side-by-side (old on the left, new on the right) with a toggle to unified or inline, word-level highlights, and a tooltip on each changed line showing who changed it. It compares documents too (PDF, Word/DOCX, ODF, e-books), not just text. The breadcrumb shows the full path to the file.
- Authorship shows who wrote each line of a file and when (not available for binary or encrypted files).
15. Encryption
Files and folders can be optionally encrypted (they show a shield icon). Encryption is per-file envelope encryption with two modes:
- Server-managed — the server can decrypt for authorised users, so previews, search, and Changes keep working transparently.
- Passphrase (zero-knowledge) — protected by a passphrase that only the user knows; the server cannot decrypt without it (you're prompted for the passphrase to open the file, and lost passphrase = lost data).
In all cases the stored repository holds ciphertext — encryption keys are never kept in the repository. History and older versions remain decryptable because each stored version carries its own key material, so re-encrypting a file never breaks its past.
16. Permissions & sharing
From any item, managers open Share & permissions to:
- See direct grants on the item and inherited grants (and which ancestor they come from), plus the owner.
- Add a person by selecting them and a role (viewer/editor/approver/manager).
- Change or remove a grant.
If you land on something you can't access, you can Request access, which notifies the item's managers.
17. Notifications
A bell in the top bar shows an unread count and opens an in-app panel listing events with
relative timestamps and a Mark all read action. Events include: you're asked to review a draft,
you're mentioned (@name), your draft was published or sent back, a new review message,
a permission was granted, or someone requested access.
Delivery channels (per-user, under Notification settings): in-app (always on), opt-in browser push, and opt-in email. Push and email are only active if the server is configured for them.
18. Search
The top-bar search (also the Ctrl/⌘-K palette) searches across workspaces, groups, folders, and projects by name/path and inside file content, returning a short snippet for content matches. Results are scoped to what you're allowed to see. (Encrypted and binary file contents aren't searched.)
19. Dashboard
A workflow-tuned overview: stat cards (workspaces, active users, open drafts, storage used of quota), a 14-day activity chart (redactions vs drafts vs publishes, with day-of-month labels along the axis and a colour-keyed legend), a file-types donut (each slice labelled with its colour in the legend), a storage-by-workspace chart, an "Approvals waiting for you" queue with quick links, and a recent-activity feed — all scoped to what you can see (no global activity leakage). The charts use a three-colour Open Color palette (violet / teal / orange) so the series stay distinguishable in both light and dark themes.
20. Administration
Instance administrators get an Administration area to:
- Manage users — create users, edit name/admin flag, change passwords (which immediately ends that user's existing sessions), and deactivate accounts.
- Manage access — view and change a user's grants across nodes; create workspaces/groups.
- Git & instance settings — the default review policy for new projects, the commit author identity, and read-only info (storage backend, data directory, whether encryption is configured).
- Plugins — see installed plugins (name, version, license) and enable/disable each one.
- Backups — set up automatic backups and restore from them (see below).
20a. Backups
Administrators can protect the whole instance with backups (Administration → Backups). A backup is a single archive containing every file (all project repositories, with full history) and the entire database — users, permissions, drafts, settings, audit log, everything.
- Off by default. Turn on automatic backups and choose a schedule (hourly / daily / weekly) and how many of the newest backups to keep (older ones are pruned automatically). You can also Back up now at any time, regardless of the schedule.
- Where they're stored. Choose Local disk (under the server's data directory — the default,
needs nothing extra) or S3 / compatible object storage (AWS S3, MinIO, Cloudflare R2, …). S3
needs the optional
boto3dependency and AWS credentials configured on the server; the panel shows whether the chosen target is ready. - Restore everything with one click. Each stored backup has a Restore button. Restoring
asks for confirmation first (it's destructive), then replaces the current database and files
with the backup's contents and reloads the app. A few honest caveats, shown in the panel and worth
knowing:
- You may need to sign in again afterwards (sessions are part of the restored database).
- Restore assumes the same app version / database shape as when the backup was taken.
- Backups do not contain the encryption master key (it lives in the server environment), so server-encrypted files need the same key present after a restore to open.
- Backups created on a schedule and manual ones, plus every restore, are written to the audit log.
21. Plugins
Galena's core ships only permissively-licensed code. Capabilities that would require copyleft or niche code are delivered as optional, separately-licensed frontend plugins that an operator installs deliberately. The reference plugin is DjVu Viewer (inline DjVu preview). Plugins register their features with the console after sign-in; with a plugin absent, the related files degrade gracefully (e.g. DjVu files download). Admins toggle plugins from Administration → Plugins.
22. Account, sessions, theme & language
- Account menu — About & help, Settings, and Sign out.
- Sessions are server-side and can be revoked instantly (sign out, account deactivation, or a password change all end existing sessions). Login persists correctly whether you're on HTTPS or a plain-HTTP LAN host.
- Theme — light / dark / system (follows your OS), chosen with no flash on load.
- Language — full English / Polish localization, including the login screen; the interface auto-detects Polish browsers. (Some proper nouns and technical identifiers stay as-is by design.)
23. Typical end-to-end flow
- Sign in → open a Workspace (or your My files).
- Create a Project; set it to Needs approval if changes should be reviewed.
- Upload files or create a document and edit it; each save is a redaction.
- Submit a Draft for review.
- An approver opens the draft, reads the Changes, leaves comments in resolvable threads, then Approves & publishes (or Requests changes).
- If edits overlap, Resolve discrepancies, then publish.
- Anyone with access can browse History, compare Changes, and see Authorship — and roll back by reverting to an earlier redaction.
24. Glossary (quick reference)
- Workspace / Group / Folder — containers (top-level / nested).
- Project — a container whose files are versioned.
- Main version — the canonical, published copy.
- Version — a separate working line of changes.
- Redaction — one saved change.
- Draft — proposed changes awaiting approval.
- Publish — bring approved changes into the main version.
- Combine versions — merge one version into another.
- Resolve discrepancies — settle overlapping edits.
- Changes — a before/after comparison.
- Authorship — per-line "who and when".
- Clone — an independent copy of a project, with history.
- Viewer / Editor / Approver / Manager — the four access roles, least to most powerful.