Repository navigation
Conversation
`folio chooser` is an xdg-desktop-portal backend for org.freedesktop.impl.portal.FileChooser. Each OpenFile, SaveFile or SaveFiles call opens an ordinary Folio window, with its views, sidebar and keys, plus a bar along the bottom (ChooserBar.qml) for the name to save under, the app's filters, Cancel and the button that answers. A ChooserDialog holds the request and its one reply: answered, cancelled, closed by the caller's Request.Close, or gone with its window, the call is answered exactly once. The portal starts the backend when it starts itself and waits for it, so the chooser makes no call to the portal before it owns its name: it runs with Qt's generic platform theme, since Omarchy's reads the portal's settings while the application is constructed, and it exports its object before claiming the name, because the portal asks for its properties straight away. D-Bus starts it again on demand, so it quits a minute after its last dialog, through a QEventLoopLocker so that file work begun in a dialog still finishes. Any process on the session bus can call it. Every option is checked against its D-Bus signature before it is read, and a malformed call gets an InvalidArgs error. Names the app supplies are bare names: a suggested name is cut to its last part, and a SaveFiles list holding anything else is refused. Only the user, typing in the name field, can give a path. Request objects live only under the portal's request path, and only the caller can close one. Filters are FolderModel's: a list of patterns applied in the background listing, a MIME type when it has a slash (with inheritance and image/*), otherwise a case-insensitive glob for the name. Folders always show, and choosing a folder lists only folders. The portal documentation calls globs case-sensitive; a filter for *.png that hides CAT.PNG would only get in the way. In a chooser window, opening a file emits Backend::chosen instead of starting an app, and Ctrl+N does nothing, because a plain window in the chooser's process would outlive its linger. With no chooser, every window behaves as before: `chooser` is null in the root context and the filter is empty. Choices (an app's extra combo boxes) are ignored, as are parent_window and modal; the README says so. The tests send options over a real peer-to-peer D-Bus connection, so compound values arrive still marshalled, as they do from the portal, and the test build now carries the resources so a whole chooser window can be driven from the keyboard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Arriving in a folder puts the cursor on its first item, and the selection falls back to the item under the cursor, so a folder picker answered Choose with the first subfolder rather than the folder the user was looking at. The cursor is always on some folder, so one folder under it says nothing: the answer is the folder shown, and Return goes into a folder as it does everywhere else. Several folders picked at once can only be deliberate, so with multiple they're still the answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SaveFiles answers with the names the app chose, in the folder picked. Where a folder there already had one of those names, the bar asked whether to replace it and then handed the app the folder's path, which no app can write a file to. A file can't replace a folder, and the app's names aren't the user's to change here, so the bar says which folder is in the way and waits for another folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in Replace A name in the save field went through the path bar's reading of a typed path, which trims, so " report.txt" was answered as "report.txt": a different file, written without asking, or the wrong one offered for replacing. A bare name is now kept exactly; only something with a slash or a leading ~ is read as a path. A filtered search stopped at its thousand matches before the filter left any out, so a tree full of matching text files could hide every picture an image filter asked for. The filter now applies as matches are found, and only what fits counts. The bar's name field and Replace prompt weren't counted as typing, so the window's Tab shortcut stayed on beside the prompt's own and Qt, finding two, ran neither: Tab did nothing in the prompt. The bar now says when it has the keys. Co-Authored-By: Codex XHigh <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A folder's name typed to save under goes into that folder, but through the path bar's reading, which trims: " sp " went into "sp" beside it, or said there was no such folder. A bare name now means the folder of exactly that name here, the same reading the answer gives a file's name, and only a path goes the path bar's way. Co-Authored-By: Codex XHigh <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The latest changes appear safe to merge. SummaryThis PR adds Folio-backed Open and Save dialogs through xdg-desktop-portal.
Reviews (5) · Last reviewed commit: "Open a chooser's filters with Ctrl+F" · Reviewed by Greptile |
The details pane's button read "Open with Image Viewer" in a chooser, though there it picks the file, and its "Opens with" menu would change the user's default app from inside another app's dialog. The bar already holds the button that answers, so a chooser's details show neither. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Screenshots of the chooser at 0a35cf7, on a fresh Omarchy VM (Qt 6.12, xdg-desktop-portal 1.22.1), each dialog asked for through the real portal the way an app asks for one. Without a window rule the dialog tiles; Open, with the app's Images filter: the text file in Pictures isn't listed, and the bar names the three files the button will answer with. Save As, starting in the name with the part before the extension selected, and the app's Text filter listing only Replace, before a save writes over a file that's there. Choose a Folder: the bar says the answer is 🤖 Generated by Opus 5.5 in Claude Code. |
…wers The bar along the bottom now holds only the name to save under, Cancel and the button that answers, 12 pixels from the window's edges, as the path bar's buttons are from the top. The sidebar drops the shortcuts button in a chooser, since a dialog isn't where Files' keys are learned. The app's filters move behind a funnel beside the view and sort buttons, a menu like theirs, shown only when the app offers more than one: with a single filter there's nothing to choose. A second click on the funnel or the sort button now closes its menu rather than opening it again. A chooser window asks for 875×600, the size Omarchy gives every floating window and so GTK's dialogs. The README gives the rule that floats folio-chooser the same way, and shows both dialogs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…logs Tab went round the sidebar, the files and the details, never the bar, so once the save name was left for the files there was no key back to it. The bar is now the last stop: the name when saving, the answer otherwise. The name field holds the window's Tab back while it types, so it moves on itself. Ctrl+Return answered the app whatever else was asking: with a rename up in an Open dialog, it closed the window with the rename unfinished. The bar now waits while one of the pane's dialogs or the shortcuts is up, its buttons too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The funnel, like the view and sort buttons beside it, takes no Tab, so moving the filters there left them to the mouse; before, Tab from the save name reached them. Ctrl+F opens the menu, from the name field too, and the arrows and Return pick a filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Put a typed path away before Ctrl+F opens a chooser's filters With a path being typed (Ctrl+L), Ctrl+F opened the filters, and the path field, losing its focus to the menu, stopped editing and handed the keyboard back to the files. The menu stayed up while the arrows moved through the files and Escape cancelled the dialog. Ctrl+F now puts the path away first, then opens the menu, which keeps the keyboard. Found by Codex at xhigh, reviewing #132. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Put away a path typed in either pane before a bar's menu opens The filters live in the left pane's bar, so with the window split and a path being typed in the right pane, Ctrl+F only looked at the left bar, and the right path field, losing its focus to the menu, handed the keyboard back to the files from under it. A click on the funnel, or on the sort button while its own pane typed a path, did the same. Both menus now open through one helper that puts away a path being typed in the pane keys go to, and in the bar's own pane, first. Found by Greptile on #134. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>




Other apps' Open and Save dialogs come from
xdg-desktop-portal-gtk, so picking a file in a browser or an editor drops you into a GTK window that looks and works nothing like Files. This makesfolio chooseranxdg-desktop-portalFileChooser backend, so those dialogs are a Folio window: the same views, sidebar, previews and keys, with a bar along the bottom for the name to save under, Cancel and the answer. Closes #40.What this owes #75, and why it's a clean room
Gavin Nugent's #75 came first, answering the question they asked in #40, and it proved the idea: a Folio window can be every app's Open and Save dialog through the real portal, for GTK, Qt, Chromium and Firefox alike. Reviewing it is also where two facts this branch is built on were found: xdg-desktop-portal starts every backend it's configured with as it starts and waits for each, so Omarchy's Qt theme plugin stalled the portal for 25 seconds at every login; and a folder picker can't take the item under Folio's cursor as the answer, a trap Greptile found on #75 and this branch walked into again independently.
We wanted the simplest version of this we could get, and that couldn't come from #75 itself. Paring a contributor's deliberate design down inside their own pull request would have meant rewriting their work under their name, and starting from their code would have made this a derivative of it published under the bot's. So it was written clean-room: a behaviour-only spec, drawn from the portal's interface definitions, Folio's
mainand those two facts, went to an agent that never saw #75's code, branch or review. Where the two look alike, it's because they solve the same problem in the same codebase. The result is 842 lines of code against #75's 981, with 523 lines of tests against 422: smaller, not dramatically, because most of the size is what the portal contract asks for. Having both to compare is part of the point.How it works
src/chooser.{h,cpp}holds three small pieces.ChooserRequestreads and type-checks a call's options and works out the answer for each mode.ChooserDialogis one request: the window'schooserand theorg.freedesktop.impl.portal.Requestobject at the call's handle, replying exactly once however the window goes.Chooseris theorg.freedesktop.impl.portal.FileChooseradaptor, which owns the bus name and quits the process a minute after its last dialog.src/ChooserBar.qmlis the bar, loaded byMain.qmlonly in a chooser window. The app's filters, when it offers more than one, are a menu under a funnel in the path bar, beside the view and sort buttons. Ordinary windows get a nullchooserand behave as before.FolderModelgains afilter: name globs and MIME types (with inheritance andimage/*), told from the type Folio already reads off the name, never the contents. A search counts only what fits toward its limit.share/gainsfolio.portal, the D-Bus service file and a hiddenfolio-chooser.desktop; chooser windows have the app idfolio-chooserand open at 875×600, the size Omarchy gives every floating window and so GTK's dialogs. Omarchy should float them as it doesxdg-desktop-portal-gtk's, witho.window("folio-chooser", { tag = "+floating-window" })indefault/hypr/apps/system.lua; the README gives the same line for~/.config/hypr/hyprland.lua. Nothing changes untilportals.confnamesfolio(the README has the three lines). The omarchy-pkgs PKGBUILD would install the three files, sincemainhas no install rules.Behaviour worth knowing
~makes it a path. A file that's there asks before it's replaced. SaveFiles saves the app's names into the folder shown, and refuses with a notice where a folder already has one of those names, since no file can replace a folder..or..is cut or refused. Malformed options get anInvalidArgserror and the service stays up. Only the caller that opened a request can close it.folio chooserstarts on Qt'sgenericplatform theme. xdg-desktop-portal activates every backendportals.confnames as it starts, and waits for each to take its bus name; Omarchy's theme plugin,qtengine, asks the portal for its settings while the application is built, so the two would wait on each other until a 25-second timeout, at every login, holding up every app waiting on any portal. Folio sets its own font, style and colours, so the chooser looks the same.Left out on purpose
parent_windowandmodaltoo: dialogs float on their own rather than attaching to the window that asked. The README says so.*.jpglistsPHOTO.JPG. The portal spec says globs are case-sensitive; this was a deliberate choice, and it's yours to overrule.Checked
On a disposable Omarchy VM (Qt 6.12, xdg-desktop-portal 1.22.1), with this build installed as the FileChooser: the portal starts in 104 to 134 ms, and these calls through the real portal frontend, as an app makes them, each came back right: a save with a filter, a save over an existing file through Replace, a cancelled open, SaveFiles with a folder in the way (refused) and without (both names), a name with a trailing space (kept), a folder pick in a folder with subfolders (the folder shown), and Escape in the name field.
Reviewed by Codex at xhigh: the whole branch once, then each fix after it. It found the save-name trimming, the search limit, Tab in the Replace prompt and a spaced folder name in the save field, all fixed here with tests that fail without the fix. The screenshots above are from a throwaway home folder, with the dialogs floated by that rule's size.
🤖 Generated by Opus 5.5 in Claude Code. Reviewed by Codex XHigh.