Preview a distrobox.ini before assembling it - #215
Open
kacperpaczos wants to merge 3 commits into
Open
Conversation
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.
kacperpaczos
force-pushed
the
feat/assemble-ini-preview
branch
from
August 22, 2026 18:32
f2ff5e9 to
281c238
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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_iniis 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.distrobox assemble createon 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.show_assemble_preview_dialogrendering 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.