Export and import the session tree #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Terminalko keeps everything in GSettings — there is no configuration file,
and the window is the only writer. The session tree lives at:
Folders and sessions are relocatable schema instances keyed by UUID. See
docs/spec/session-model.mdfor why membership and order live only in the folderlist keys, and
crates/terminalko-config/src/session.rsfor the model(
Store,Folder,Session,Layout,TidyReport).Schemas:
data/me.dusansimic.terminalko.{,folder.,session.}gschema.xml.Problem
dconf is not git-friendly and not portable between machines. A user who has built
up a set of sessions has no way to back them up, move them to another machine, or
keep them under version control.
docs/spec/session-model.mdalready promisesthis ("ship two explicit GUI actions: Export sessions… and Import
sessions…") and it does not exist.
Goal
Export the session tree to a single human-readable file, and import it back.
Suggested approach
Format. A GLib keyfile is the natural choice:
dconf dumpalready producesone,
glib::KeyFilereads and writes it, and it is diffable. Something like:Keeping it
dconf dump-compatible is worth it —dconf load /me/dusansimic/terminalko/ < filethen works as a fallback path, and users caninspect an export with tools they already have.
Where. Add to
terminalko-config(soterminalkoctlcould use it later),e.g.
Store::export_to_keyfile() -> glib::KeyFileandStore::import_from_keyfile(&KeyFile, ImportMode).Import needs a decision, not a default. Offer Replace (clear the tree
first) and Merge (keep what is there, giving imported folders and sessions
fresh UUIDs so an import cannot collide with or overwrite existing work).
The dialog must say which is which.
Validation. Imported data comes from a file a user may have edited:
type,restart,container-runtimeorescalationvalue mustfall back the way the model already does;
Store::tidy()so a truncated file cannot leave danglingreferences — it adopts orphans and drops references to sessions that do not
exist, and reports what it repaired.
UI. Two entries in the primary menu (
ui/window.blp) and two windowactions, using
gtk::FileDialog. Report the outcome as a toast or a messageincluding the counts, and what
tidy()had to repair.Acceptance criteria
colours, types, order, folder membership) on a fresh configuration.
assigns new UUIDs to what it adds.
never leaves the tree in a state that
tidy()still wants to repair.terminalko-configrunning headless withGSETTINGS_BACKEND=memory— see the existingwith_storehelper insession.rstests, which takes the process-wide lock and starts from an emptytree.
./build-aux/ci.shpasses;./build-aux/smoke.shstill passes.docs/spec/session-model.mdupdated to describe the format and the two importmodes.
Notes
terminalkoctlwrite configuration: the window isthe only writer, and that rule is what keeps the model consistent.
CONTRIBUTING.mdbefore looking at anyGPL-licensed terminal for reference.