/** * Choosing a repository folder. * * Wrapped so the rest of the app never imports the dialog plugin directly — * which also means the tests can stand in for it in one place. */ import { open } from "@tauri-apps/plugin-dialog"; /** * Ask for a repository folder. * * Resolves to `undefined` when the dialog is dismissed, which is an ordinary * outcome rather than an error. Any folder inside a repository will do: the * Rust side searches upwards the way git does. */ export async function chooseRepositoryFolder(): Promise { const chosen = await open({ directory: true, multiple: false, title: "Open repository", }); // The plugin returns null on dismissal, and an array only when `multiple` // is set — which it is not. return typeof chosen === "string" ? chosen : undefined; }