Skip to content

Preview a distrobox.ini before assembling it - #215

Open
kacperpaczos wants to merge 3 commits into
Dvlv:masterfrom
kacperpaczos:feat/assemble-ini-preview
Open

Preview a distrobox.ini before assembling it#215
kacperpaczos wants to merge 3 commits into
Dvlv:masterfrom
kacperpaczos:feat/assemble-ini-preview

Conversation

@kacperpaczos

@kacperpaczos kacperpaczos commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes #214

Puts a confirmation step in front of Assemble: pick an .ini and, instead of running it immediately, BoxBuddy parses it and shows what it will create — one row per box, Apply or Cancel. The last of the assemble items on the Needs External Help list.

assemble .ini preview

The design point worth reviewing: it shows every key the file sets, not a curated subset. An assemble file can mount host paths, run as root, or fire an init_hook that fetches and runs a script — so a preview that folded unknown keys into "+N more" (which is what this started as) would give false assurance about what Apply actually does. The parser is deliberately generic for that reason: each section comes back as its name plus its key/value pairs in file order, the row is titled name (image) and lists the rest verbatim, and the subtitle wraps so a long hook command or volume list is fully readable rather than ellipsized to a teaser.

Testing

  • parse_assemble_ini is a plain string→sections function with 6 unit tests: single and multiple sections with keys in order, unknown keys kept verbatim, comments and junk skipped, keys before any header ignored, empty input.
  • Fidelity check: I wrote a two-section .ini, ran the real distrobox assemble create on it, and confirmed it produced exactly the boxes the parser reports (names and images) — then removed them. So the preview reflects what distrobox will actually do, not a separate interpretation.
  • The dialog in the screenshot is the real show_assemble_preview_dialog rendering that same file. The one thing I couldn't drive here is the file chooser that precedes it — it's portal-backed and doesn't open under my headless test setup — so the picker → preview handoff is worth a click-through before merging.

BoxBuddy Contributor and others added 2 commits August 22, 2026 20:24
Adds an IniBoxSection struct plus a small parse_assemble_ini helper that
turns distrobox.ini-style files into a Vec<IniBoxSection>. Recognised
keys (image, additional_packages, home, init, nvidia) are surfaced as
typed fields; anything else is preserved verbatim in extra_keys so the
user sees what is being passed to 'distrobox assemble create'.

When the user picks a .ini file from the Assemble button, the parser
runs first. If sections were found, show_assemble_preview_dialog lists
them in a scrollable MessageDialog with one ActionRow per box, so the
user can sanity-check before applying. Apply continues into the
existing assemble_new_distrobox flow; Cancel closes the dialog and
aborts. An empty file or unreadable path falls back to the old
no-preview flow so the user is never blocked.

Resolves 'Parse assemble .ini files and show confirmation pop-up with
details' from the Roadmap.

The parser is intentionally minimal - no regex crate, no multiline
support. distrobox.ini is a flat INI with key=value per line, which
the simple state machine in parse_assemble_ini covers in full.
…rser

The preview dialog listed each box's known fields and folded everything
else into '+N more'. That is the one thing a confirmation dialog must not
do: a distrobox.ini can mount a host path, run as root, or fire an
init_hook that fetches and runs a script, and none of it was on screen -
so Apply meant approving things you could not see. Every key the file
sets is now shown verbatim, with the subtitle wrapping so a long hook
command or volume list is readable in full rather than ellipsized.

parse_assemble_ini, the pure core, gains unit tests: single and multiple
sections, unknown keys kept verbatim, comments and junk skipped, the
truthy/falsy spellings of init/nvidia, and keys before any header ignored.
The parser returned a struct with five named fields plus a list of
"everything else", and the dialog then flattened all of it back into
text. Returning each section as its name and its key/value pairs, in
file order, shows the same information with less machinery: no struct,
no per-key special cases, no boolean spelling table.
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.

Preview a distrobox.ini before assembling it (Roadmap: Needs External Help)

1 participant