mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
feat(app): redesign the open project folder picker (#64241)
This commit is contained in:
committed by
GitHub
Unverified
parent
93abead744
commit
96a6c43b34
@@ -28,7 +28,8 @@ test("Tab and Enter while suggestions load act on the typed folder, not the prev
|
||||
const input = picker.getByRole("combobox")
|
||||
|
||||
await input.fill("alp")
|
||||
await expect(picker.getByRole("option")).toHaveText(["C:\\OpenCode\\Picker\\alpha/"])
|
||||
await expect(picker.getByRole("option")).toHaveCount(1)
|
||||
await expect(picker.getByRole("option")).toHaveAttribute("data-directory-path", "C:/OpenCode/Picker/alpha")
|
||||
|
||||
const search = await holdRoute(page, /\/api\/fs\/find\?(.*&)?query=beta(&|$)/)
|
||||
await input.fill("beta")
|
||||
@@ -40,7 +41,7 @@ test("Tab and Enter while suggestions load act on the typed folder, not the prev
|
||||
|
||||
await input.press("Enter")
|
||||
await expect(input).toHaveValue("C:\\OpenCode\\Picker\\beta\\")
|
||||
await expect(picker.locator(".directory-picker-selection-text")).toHaveText("C:\\…\\Picker\\beta")
|
||||
await expect(picker.getByRole("treeitem", { name: "beta", exact: true })).toHaveAttribute("aria-selected", "true")
|
||||
search.release()
|
||||
})
|
||||
|
||||
@@ -103,3 +104,30 @@ test("the folder picker's tree scrolls with the mouse wheel inside the modal", a
|
||||
await page.mouse.wheel(0, 300)
|
||||
await expect.poll(scrollTop).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test("Escape closes suggestions, then drops a typed path, before it closes the picker", async ({ page }) => {
|
||||
const picker = await openPicker(page, {
|
||||
fileList: (path) =>
|
||||
path === directory ? ["alpha", "beta"].map((name) => fileNode(directory, name, "directory")) : [],
|
||||
findFiles: (input) => ["alpha", "beta"].filter((name) => input.query.length >= 3 && name.startsWith(input.query)),
|
||||
})
|
||||
|
||||
const input = picker.getByRole("combobox")
|
||||
|
||||
await picker.getByRole("treeitem", { name: "beta", exact: true }).click()
|
||||
await expect(input).toHaveValue("C:\\OpenCode\\Picker\\beta\\")
|
||||
|
||||
await input.fill("alp")
|
||||
await expect(picker.getByRole("option")).toHaveCount(1)
|
||||
await input.press("Escape")
|
||||
await expect(picker.getByRole("option")).toHaveCount(0)
|
||||
await expect(input).toHaveValue("alp")
|
||||
|
||||
await input.press("Escape")
|
||||
await expect(picker).toBeVisible()
|
||||
await expect(input).toHaveValue("C:\\OpenCode\\Picker\\beta\\")
|
||||
await expect(picker.getByRole("treeitem", { name: "beta", exact: true })).toHaveAttribute("aria-selected", "true")
|
||||
|
||||
await input.press("Escape")
|
||||
await expect(picker).toBeHidden()
|
||||
})
|
||||
|
||||
@@ -84,13 +84,15 @@ test("creates a session in a new project and selects its model", async ({ page }
|
||||
return url.pathname === "/api/fs/list" && url.searchParams.get("path") === "C:/OpenCode"
|
||||
})
|
||||
|
||||
await picker.getByRole("button", { name: "Parent", exact: true }).click()
|
||||
await picker
|
||||
.getByRole("navigation", { name: "Folder path", exact: true })
|
||||
.getByRole("button", { name: "OpenCode", exact: true })
|
||||
.click()
|
||||
expect(new URL((await listing).url()).searchParams.get("location[directory]")).toBe(directory)
|
||||
const directoryItem = picker.getByRole("treeitem", { name: "NewProject", exact: true })
|
||||
await expect(directoryItem).toBeVisible()
|
||||
await directoryItem.click()
|
||||
await expect(directoryItem).toHaveAttribute("aria-selected", "true")
|
||||
await expect(picker.getByText("C:\\OpenCode\\NewProject", { exact: true })).toBeVisible()
|
||||
const selectFolder = picker.getByRole("button", { name: "Select folder", exact: true })
|
||||
await expect(selectFolder).toBeEnabled()
|
||||
await selectFolder.click()
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "አዲስ ቅርንጫፍ ለመፍጠር መልዕክት የለም",
|
||||
"dialog.directory.action.selectFile": "ፋይል ምረጥ",
|
||||
"dialog.directory.action.selectFolder": "አቃፊን ምረጥ",
|
||||
"dialog.directory.root": "ሥር",
|
||||
"dialog.directory.parent": "ወላጅ",
|
||||
"dialog.directory.readError": "ይህን አቃፊ ማንበብ አልተቻለም",
|
||||
"dialog.server.add.title": "አገልጋይ አክል",
|
||||
"dialog.server.add.url": "የአገልጋይ አድራሻ",
|
||||
|
||||
@@ -233,8 +233,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "لا توجد رسائل للتفرع منها",
|
||||
"dialog.directory.action.selectFile": "اختيار ملف",
|
||||
"dialog.directory.action.selectFolder": "اختيار مجلد",
|
||||
"dialog.directory.root": "الجذر",
|
||||
"dialog.directory.parent": "المجلد الأصل",
|
||||
"dialog.directory.readError": "تعذرت قراءة هذا المجلد",
|
||||
"dialog.server.add.title": "إضافة خادم",
|
||||
"dialog.server.add.url": "عنوان URL للخادم",
|
||||
|
||||
@@ -222,8 +222,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Yeni sessiyaya ayırmaq üçün mesaj yoxdur",
|
||||
"dialog.directory.action.selectFile": "Fayl seçin",
|
||||
"dialog.directory.action.selectFolder": "Qovluğu seçin",
|
||||
"dialog.directory.root": "Kök",
|
||||
"dialog.directory.parent": "Üst qovluq",
|
||||
"dialog.directory.readError": "Bu qovluğu oxumaq mümkün deyil",
|
||||
"dialog.server.add.title": "Server əlavə et",
|
||||
"dialog.server.add.url": "Server ünvanı",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Няма съобщения за разклонение",
|
||||
"dialog.directory.action.selectFile": "Изберете файл",
|
||||
"dialog.directory.action.selectFolder": "Изберете папка",
|
||||
"dialog.directory.root": "корен",
|
||||
"dialog.directory.parent": "Родител",
|
||||
"dialog.directory.readError": "Тази папка не може да се прочете",
|
||||
"dialog.server.add.title": "Добавете сървър",
|
||||
"dialog.server.add.url": "Адрес на сървъра",
|
||||
|
||||
@@ -225,8 +225,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "থেকে কাঁটাচামচ কোন বার্তা",
|
||||
"dialog.directory.action.selectFile": "ফাইল নির্বাচন করুন",
|
||||
"dialog.directory.action.selectFolder": "ফোল্ডার নির্বাচন করুন",
|
||||
"dialog.directory.root": "রুট",
|
||||
"dialog.directory.parent": "অভিভাবক",
|
||||
"dialog.directory.readError": "এই ফোল্ডারটি পড়তে অক্ষম৷",
|
||||
"dialog.server.add.title": "সার্ভার যোগ করুন",
|
||||
"dialog.server.add.url": "সার্ভার ঠিকানা",
|
||||
|
||||
@@ -438,8 +438,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nenhuma mensagem para bifurcar",
|
||||
"dialog.directory.action.selectFile": "Selecionar arquivo",
|
||||
"dialog.directory.action.selectFolder": "Selecionar pasta",
|
||||
"dialog.directory.root": "Raiz",
|
||||
"dialog.directory.parent": "Pasta superior",
|
||||
"dialog.directory.readError": "Não foi possível ler esta pasta",
|
||||
"dialog.server.add.title": "Adicionar um servidor",
|
||||
"dialog.server.add.url": "Endereço do servidor",
|
||||
|
||||
@@ -243,8 +243,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Odaberi datoteku",
|
||||
"dialog.directory.action.selectFolder": "Odaberi fasciklu",
|
||||
"dialog.directory.root": "Korijen",
|
||||
"dialog.directory.parent": "Nadređena fascikla",
|
||||
"dialog.directory.readError": "Nije moguće pročitati ovu fasciklu",
|
||||
|
||||
"dialog.server.add.title": "Dodaj server",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "No hi ha missatges per bifurcar",
|
||||
"dialog.directory.action.selectFile": "Seleccioneu el fitxer",
|
||||
"dialog.directory.action.selectFolder": "Seleccioneu la carpeta",
|
||||
"dialog.directory.root": "Arrel",
|
||||
"dialog.directory.parent": "Pare",
|
||||
"dialog.directory.readError": "No es pot llegir aquesta carpeta",
|
||||
"dialog.server.add.title": "Afegeix servidor",
|
||||
"dialog.server.add.url": "Adreça del servidor",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Žádné zprávy k rozvětvení",
|
||||
"dialog.directory.action.selectFile": "Vyberte soubor",
|
||||
"dialog.directory.action.selectFolder": "Vyberte složku",
|
||||
"dialog.directory.root": "Kořen",
|
||||
"dialog.directory.parent": "Rodič",
|
||||
"dialog.directory.readError": "Tuto složku nelze přečíst",
|
||||
"dialog.server.add.title": "Přidat server",
|
||||
"dialog.server.add.url": "Adresa serveru",
|
||||
|
||||
@@ -373,8 +373,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Vælg fil",
|
||||
"dialog.directory.action.selectFolder": "Vælg mappe",
|
||||
"dialog.directory.root": "Rod",
|
||||
"dialog.directory.parent": "Overordnet",
|
||||
"dialog.directory.readError": "Denne mappe kan ikke læses",
|
||||
|
||||
"dialog.server.add.title": "Tilføj en server",
|
||||
|
||||
@@ -371,8 +371,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Keine Nachrichten zum Abzweigen vorhanden",
|
||||
"dialog.directory.action.selectFile": "Datei auswählen",
|
||||
"dialog.directory.action.selectFolder": "Ordner auswählen",
|
||||
"dialog.directory.root": "Stammverzeichnis",
|
||||
"dialog.directory.parent": "Übergeordnet",
|
||||
"dialog.directory.readError": "Dieser Ordner kann nicht gelesen werden",
|
||||
"dialog.server.add.title": "Server hinzufügen",
|
||||
"dialog.server.add.url": "Serveradresse",
|
||||
|
||||
@@ -224,8 +224,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "ފޯކް ކުރާނެ މެސެޖެއް ނެތެވެ",
|
||||
"dialog.directory.action.selectFile": "ފައިލް ހޮވާށެވެ",
|
||||
"dialog.directory.action.selectFolder": "ފޯލްޑަރ ހޮވާށެވެ",
|
||||
"dialog.directory.root": "މޫ",
|
||||
"dialog.directory.parent": "ބެލެނިވެރިޔާއެވެ",
|
||||
"dialog.directory.readError": "މި ފޯލްޑަރ ކިޔަން ނުކުޅެދިއްޖެއެވެ",
|
||||
"dialog.server.add.title": "ސަރވަރ އިތުރުކުރުން",
|
||||
"dialog.server.add.url": "ސަރވަރ އެޑްރެސް",
|
||||
|
||||
@@ -232,8 +232,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "ལས་ཕོརཀ་འབད་ནི་ལུ་འཕྲིན་དོན་མེད།",
|
||||
"dialog.directory.action.selectFile": "ཡིག་སྣོད་སེལ་འཐུ་འབད།",
|
||||
"dialog.directory.action.selectFolder": "སྣོད་འཛིན་སེལ་འཐུ་འབད།",
|
||||
"dialog.directory.root": "ར༌ཏོག",
|
||||
"dialog.directory.parent": "ཕ་མ།",
|
||||
"dialog.directory.readError": "སྣོད་འཛིན་འདི་ལྷག་མི་ཚུགས།",
|
||||
"dialog.server.add.title": "སར་བར་ཁ་སྐོང་འབད།",
|
||||
"dialog.server.add.url": "སར་བར་ཁ་བྱང་།",
|
||||
|
||||
@@ -222,8 +222,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Δεν υπάρχουν μηνύματα για διακλάδωση",
|
||||
"dialog.directory.action.selectFile": "Επιλογή αρχείου",
|
||||
"dialog.directory.action.selectFolder": "Επιλογή φακέλου",
|
||||
"dialog.directory.root": "Ρίζα",
|
||||
"dialog.directory.parent": "Γονικός",
|
||||
"dialog.directory.readError": "Δεν είναι δυνατή η ανάγνωση αυτού του φακέλου",
|
||||
"dialog.server.add.title": "Προσθήκη διακομιστή",
|
||||
"dialog.server.add.url": "Διεύθυνση διακομιστή",
|
||||
|
||||
@@ -416,12 +416,12 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Select file",
|
||||
"dialog.directory.action.selectFolder": "Select folder",
|
||||
"dialog.directory.search.placeholder": "Search projects or enter ~/path…",
|
||||
"dialog.directory.breadcrumbs": "Folder path",
|
||||
"dialog.directory.search.placeholder": "Search folders or enter ~/path…",
|
||||
"dialog.directory.recent": "Recent",
|
||||
"dialog.directory.moreProjects": "More projects",
|
||||
"dialog.directory.recentProject": "{{name}} ({{path}})",
|
||||
"dialog.directory.gitRepo": "git repo",
|
||||
"dialog.directory.root": "Root",
|
||||
"dialog.directory.parent": "Parent",
|
||||
"dialog.directory.readError": "Unable to read this folder",
|
||||
|
||||
"dialog.server.add.title": "Add server",
|
||||
|
||||
@@ -459,8 +459,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Seleccionar archivo",
|
||||
"dialog.directory.action.selectFolder": "Seleccionar carpeta",
|
||||
"dialog.directory.root": "Raíz",
|
||||
"dialog.directory.parent": "Carpeta superior",
|
||||
"dialog.directory.readError": "No se puede leer esta carpeta",
|
||||
|
||||
"dialog.server.add.title": "Añadir un servidor",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Ühtegi sõnumit pole",
|
||||
"dialog.directory.action.selectFile": "Valige fail",
|
||||
"dialog.directory.action.selectFolder": "Valige kaust",
|
||||
"dialog.directory.root": "Juur",
|
||||
"dialog.directory.parent": "Lapsevanem",
|
||||
"dialog.directory.readError": "Seda kausta ei saa lugeda",
|
||||
"dialog.server.add.title": "Lisa server",
|
||||
"dialog.server.add.url": "Serveri aadress",
|
||||
|
||||
@@ -230,8 +230,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "هیچ پیامی برای فورک وجود ندارد",
|
||||
"dialog.directory.action.selectFile": "فایل را انتخاب کنید",
|
||||
"dialog.directory.action.selectFolder": "پوشه را انتخاب کنید",
|
||||
"dialog.directory.root": "ریشه",
|
||||
"dialog.directory.parent": "پدر و مادر",
|
||||
"dialog.directory.readError": "خواندن این پوشه ممکن نیست",
|
||||
"dialog.server.add.title": "سرور اضافه کنید",
|
||||
"dialog.server.add.url": "آدرس سرور",
|
||||
|
||||
@@ -354,8 +354,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Ei viestejä, joista voisi haarauttaa",
|
||||
"dialog.directory.action.selectFile": "Valitse tiedosto",
|
||||
"dialog.directory.action.selectFolder": "Valitse kansio",
|
||||
"dialog.directory.root": "Juuri",
|
||||
"dialog.directory.parent": "Ylätaso",
|
||||
"dialog.directory.readError": "Tätä kansiota ei voi lukea",
|
||||
"dialog.server.add.title": "Lisää palvelin",
|
||||
"dialog.server.add.url": "Palvelimen osoite",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Eingi boð at greina frá",
|
||||
"dialog.directory.action.selectFile": "Vel fílu",
|
||||
"dialog.directory.action.selectFolder": "Vel mappu",
|
||||
"dialog.directory.root": "Rót",
|
||||
"dialog.directory.parent": "Foreldur",
|
||||
"dialog.directory.readError": "Tað ber ikki til at lesa hesa mappuna",
|
||||
"dialog.server.add.title": "Legg ambætara til",
|
||||
"dialog.server.add.url": "Ambætaraadressa",
|
||||
|
||||
@@ -442,8 +442,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Aucun message à partir duquel bifurquer",
|
||||
"dialog.directory.action.selectFile": "Sélectionner le fichier",
|
||||
"dialog.directory.action.selectFolder": "Sélectionner le dossier",
|
||||
"dialog.directory.root": "Racine",
|
||||
"dialog.directory.parent": "Parent",
|
||||
"dialog.directory.readError": "Impossible de lire ce dossier",
|
||||
"dialog.server.add.title": "Ajouter un serveur",
|
||||
"dialog.server.add.url": "URL du serveur",
|
||||
|
||||
@@ -229,8 +229,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "אין הודעות שמהן אפשר ליצור הפעלה",
|
||||
"dialog.directory.action.selectFile": "בחר קובץ",
|
||||
"dialog.directory.action.selectFolder": "בחר תיקייה",
|
||||
"dialog.directory.root": "שורש",
|
||||
"dialog.directory.parent": "תיקיית אב",
|
||||
"dialog.directory.readError": "לא ניתן לקרוא את התיקייה הזו",
|
||||
"dialog.server.add.title": "הוסף שרת",
|
||||
"dialog.server.add.url": "כתובת שרת",
|
||||
|
||||
@@ -226,8 +226,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "फ़ोर्क करने के लिए कोई संदेश नहीं",
|
||||
"dialog.directory.action.selectFile": "फ़ाइल का चयन करें",
|
||||
"dialog.directory.action.selectFolder": "फ़ोल्डर चुनें",
|
||||
"dialog.directory.root": "रूट",
|
||||
"dialog.directory.parent": "पैरेंट",
|
||||
"dialog.directory.readError": "इस फ़ोल्डर को पढ़ने में असमर्थ",
|
||||
"dialog.server.add.title": "सर्वर जोड़ें",
|
||||
"dialog.server.add.url": "सर्वर पता",
|
||||
|
||||
@@ -233,8 +233,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nema poruka za račvanje",
|
||||
"dialog.directory.action.selectFile": "Odaberite datoteku",
|
||||
"dialog.directory.action.selectFolder": "Odaberite mapu",
|
||||
"dialog.directory.root": "Korijen",
|
||||
"dialog.directory.parent": "Roditelj",
|
||||
"dialog.directory.readError": "Nije moguće pročitati ovu mapu",
|
||||
"dialog.server.add.title": "Dodaj poslužitelj",
|
||||
"dialog.server.add.url": "Adresa poslužitelja",
|
||||
|
||||
@@ -233,8 +233,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nincsenek üzenetek, ahonnan elágazhatna",
|
||||
"dialog.directory.action.selectFile": "Válassza ki a fájlt",
|
||||
"dialog.directory.action.selectFolder": "Válasszon mappát",
|
||||
"dialog.directory.root": "Gyökér",
|
||||
"dialog.directory.parent": "Szülő",
|
||||
"dialog.directory.readError": "Ez a mappa nem olvasható",
|
||||
"dialog.server.add.title": "Szerver hozzáadása",
|
||||
"dialog.server.add.url": "Szerver címe",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Չկան պատառաքաղված հաղորդագրություններ",
|
||||
"dialog.directory.action.selectFile": "Ընտրել ֆայլը",
|
||||
"dialog.directory.action.selectFolder": "Ընտրել թղթապանակ",
|
||||
"dialog.directory.root": "Արմատ",
|
||||
"dialog.directory.parent": "Ծնող",
|
||||
"dialog.directory.readError": "Անհնար է կարդալ այս թղթապանակը",
|
||||
"dialog.server.add.title": "Ավելացնել սերվեր",
|
||||
"dialog.server.add.url": "Սերվերի հասցեն",
|
||||
|
||||
@@ -252,8 +252,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Pilih berkas",
|
||||
"dialog.directory.action.selectFolder": "Pilih folder",
|
||||
"dialog.directory.root": "Akar",
|
||||
"dialog.directory.parent": "Induk",
|
||||
"dialog.directory.readError": "Tidak dapat membaca folder ini",
|
||||
|
||||
"dialog.server.add.title": "Tambah server",
|
||||
|
||||
@@ -233,8 +233,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Engin skilaboð til að punga frá",
|
||||
"dialog.directory.action.selectFile": "Veldu skrá",
|
||||
"dialog.directory.action.selectFolder": "Veldu möppu",
|
||||
"dialog.directory.root": "Rót",
|
||||
"dialog.directory.parent": "Foreldri",
|
||||
"dialog.directory.readError": "Get ekki lesið þessa möppu",
|
||||
"dialog.server.add.title": "Bæta við netþjóni",
|
||||
"dialog.server.add.url": "Heimilisfang netþjóns",
|
||||
|
||||
@@ -375,8 +375,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nessun messaggio da cui effettuare il fork",
|
||||
"dialog.directory.action.selectFile": "Seleziona file",
|
||||
"dialog.directory.action.selectFolder": "Seleziona la cartella",
|
||||
"dialog.directory.root": "Radice",
|
||||
"dialog.directory.parent": "Cartella superiore",
|
||||
"dialog.directory.readError": "Impossibile leggere questa cartella",
|
||||
"dialog.server.add.title": "Aggiungi server",
|
||||
"dialog.server.add.url": "Indirizzo del server",
|
||||
|
||||
@@ -231,8 +231,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "フォーク元のメッセージがありません",
|
||||
"dialog.directory.action.selectFile": "ファイルを選択",
|
||||
"dialog.directory.action.selectFolder": "フォルダを選択",
|
||||
"dialog.directory.root": "ルート",
|
||||
"dialog.directory.parent": "親フォルダ",
|
||||
"dialog.directory.readError": "このフォルダを読み取れません",
|
||||
"dialog.server.add.title": "サーバーを追加",
|
||||
"dialog.server.add.url": "サーバーURL",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "განშტოებისთვის შეტყობინებები არ არის",
|
||||
"dialog.directory.action.selectFile": "აირჩიეთ ფაილი",
|
||||
"dialog.directory.action.selectFolder": "აირჩიე საქაღალდე",
|
||||
"dialog.directory.root": "ძირეული",
|
||||
"dialog.directory.parent": "მშობელი",
|
||||
"dialog.directory.readError": "ამ საქაღალდის წაკითხვა შეუძლებელია",
|
||||
"dialog.server.add.title": "სერვერის დამატება",
|
||||
"dialog.server.add.url": "სერვერის მისამართი",
|
||||
|
||||
@@ -227,8 +227,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "គ្មានសារដែលត្រូវបំបែកពី",
|
||||
"dialog.directory.action.selectFile": "ជ្រើសរើសឯកសារ",
|
||||
"dialog.directory.action.selectFolder": "ជ្រើសរើសថត",
|
||||
"dialog.directory.root": "ឫស",
|
||||
"dialog.directory.parent": "មាតាបិតា",
|
||||
"dialog.directory.readError": "មិនអាចអានថតឯកសារនេះបានទេ។",
|
||||
"dialog.server.add.title": "បន្ថែមម៉ាស៊ីនមេ",
|
||||
"dialog.server.add.url": "អាសយដ្ឋានម៉ាស៊ីនមេ",
|
||||
|
||||
@@ -155,8 +155,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "분기할 메시지 없음",
|
||||
"dialog.directory.action.selectFile": "파일 선택",
|
||||
"dialog.directory.action.selectFolder": "폴더 선택",
|
||||
"dialog.directory.root": "루트",
|
||||
"dialog.directory.parent": "상위 폴더",
|
||||
"dialog.directory.readError": "이 폴더를 읽을 수 없습니다",
|
||||
"dialog.server.add.title": "서버 추가",
|
||||
"dialog.server.add.url": "서버 URL",
|
||||
|
||||
@@ -227,8 +227,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "ບໍ່ມີຂໍ້ຄວາມທີ່ຈະແຍກອອກຈາກ",
|
||||
"dialog.directory.action.selectFile": "ເລືອກໄຟລ໌",
|
||||
"dialog.directory.action.selectFolder": "ເລືອກໂຟນເດີ",
|
||||
"dialog.directory.root": "ຮາກ",
|
||||
"dialog.directory.parent": "ພໍ່ແມ່",
|
||||
"dialog.directory.readError": "ບໍ່ສາມາດອ່ານໂຟນເດີນີ້ໄດ້",
|
||||
"dialog.server.add.title": "ເພີ່ມເຊີບເວີ",
|
||||
"dialog.server.add.url": "ທີ່ຢູ່ເຊີບເວີ",
|
||||
|
||||
@@ -233,8 +233,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nėra pranešimų, iš kurių būtų galima išsišakoti",
|
||||
"dialog.directory.action.selectFile": "Pasirinkite failą",
|
||||
"dialog.directory.action.selectFolder": "Pasirinkite aplanką",
|
||||
"dialog.directory.root": "Šaknis",
|
||||
"dialog.directory.parent": "Tėvas",
|
||||
"dialog.directory.readError": "Nepavyko perskaityti šio aplanko",
|
||||
"dialog.server.add.title": "Pridėti serverį",
|
||||
"dialog.server.add.url": "Serverio adresas",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nav ziņu, no kurām atzarot",
|
||||
"dialog.directory.action.selectFile": "Izvēlieties failu",
|
||||
"dialog.directory.action.selectFolder": "Izvēlieties mapi",
|
||||
"dialog.directory.root": "Sakne",
|
||||
"dialog.directory.parent": "Vecāks",
|
||||
"dialog.directory.readError": "Neizdevās nolasīt šo mapi",
|
||||
"dialog.server.add.title": "Pievienot serveri",
|
||||
"dialog.server.add.url": "Servera adrese",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Нема пораки од кои може да се префрлите",
|
||||
"dialog.directory.action.selectFile": "Изберете датотека",
|
||||
"dialog.directory.action.selectFolder": "Изберете папка",
|
||||
"dialog.directory.root": "Корен",
|
||||
"dialog.directory.parent": "Родител",
|
||||
"dialog.directory.readError": "Не може да се прочита оваа папка",
|
||||
"dialog.server.add.title": "Додај сервер",
|
||||
"dialog.server.add.url": "Адреса на серверот",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Салаалах зурвас алга",
|
||||
"dialog.directory.action.selectFile": "Файл сонгоно уу",
|
||||
"dialog.directory.action.selectFolder": "Фолдер сонгоно уу",
|
||||
"dialog.directory.root": "Үндэс",
|
||||
"dialog.directory.parent": "Эцэг эх",
|
||||
"dialog.directory.readError": "Энэ фолдерыг унших боломжгүй байна",
|
||||
"dialog.server.add.title": "Сервер нэмэх",
|
||||
"dialog.server.add.url": "Серверийн хаяг",
|
||||
|
||||
@@ -228,8 +228,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Tiada mesej untuk dicabang",
|
||||
"dialog.directory.action.selectFile": "Pilih fail",
|
||||
"dialog.directory.action.selectFolder": "Pilih folder",
|
||||
"dialog.directory.root": "Akar",
|
||||
"dialog.directory.parent": "Induk",
|
||||
"dialog.directory.readError": "Tidak dapat membaca folder ini",
|
||||
"dialog.server.add.title": "Tambah pelayan",
|
||||
"dialog.server.add.url": "Alamat pelayan",
|
||||
|
||||
@@ -228,8 +228,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "လမ်းခွဲရန် မက်ဆေ့ချ်များ မရှိပါ။",
|
||||
"dialog.directory.action.selectFile": "ဖိုင်ကို ရွေးပါ။",
|
||||
"dialog.directory.action.selectFolder": "ဖိုင်တွဲကို ရွေးပါ။",
|
||||
"dialog.directory.root": "အမြစ်",
|
||||
"dialog.directory.parent": "မိဘ",
|
||||
"dialog.directory.readError": "ဤဖိုင်တွဲကို ဖတ်၍မရပါ။",
|
||||
"dialog.server.add.title": "ဆာဗာထည့်ပါ။",
|
||||
"dialog.server.add.url": "ဆာဗာလိပ်စာ",
|
||||
|
||||
@@ -225,8 +225,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "बाट फोर्क गर्न कुनै सन्देश छैन",
|
||||
"dialog.directory.action.selectFile": "फाइल चयन गर्नुहोस्",
|
||||
"dialog.directory.action.selectFolder": "फोल्डर चयन गर्नुहोस्",
|
||||
"dialog.directory.root": "रूट",
|
||||
"dialog.directory.parent": "अभिभावक",
|
||||
"dialog.directory.readError": "यो फोल्डर पढ्न असमर्थ",
|
||||
"dialog.server.add.title": "सर्भर थप्नुहोस्",
|
||||
"dialog.server.add.url": "सर्भर ठेगाना",
|
||||
|
||||
@@ -426,8 +426,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Geen berichten om van af te splitsen",
|
||||
"dialog.directory.action.selectFile": "Selecteer bestand",
|
||||
"dialog.directory.action.selectFolder": "Selecteer map",
|
||||
"dialog.directory.root": "Hoofdmap",
|
||||
"dialog.directory.parent": "Bovenliggende map",
|
||||
"dialog.directory.readError": "Kan deze map niet lezen",
|
||||
"dialog.server.add.title": "Server toevoegen",
|
||||
"dialog.server.add.url": "Serveradres",
|
||||
|
||||
@@ -433,8 +433,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Velg fil",
|
||||
"dialog.directory.action.selectFolder": "Velg mappe",
|
||||
"dialog.directory.root": "Rot",
|
||||
"dialog.directory.parent": "Overordnet",
|
||||
"dialog.directory.readError": "Kan ikke lese denne mappen",
|
||||
|
||||
"dialog.server.add.title": "Legg til en server",
|
||||
|
||||
@@ -227,8 +227,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "فورک کرن لئی کوئی پیغام نئیں",
|
||||
"dialog.directory.action.selectFile": "فائل چنو",
|
||||
"dialog.directory.action.selectFolder": "فولڈر چنو",
|
||||
"dialog.directory.root": "Root",
|
||||
"dialog.directory.parent": "اُتلا فولڈر",
|
||||
"dialog.directory.readError": "اس فولڈر نوں پڑھن توں قاصر",
|
||||
"dialog.server.add.title": "سرور شامل کرو",
|
||||
"dialog.server.add.url": "سرور دا پتہ",
|
||||
|
||||
@@ -224,8 +224,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Brak wiadomości do rozwidlenia",
|
||||
"dialog.directory.action.selectFile": "Wybierz plik",
|
||||
"dialog.directory.action.selectFolder": "Wybierz folder",
|
||||
"dialog.directory.root": "Katalog główny",
|
||||
"dialog.directory.parent": "Folder nadrzędny",
|
||||
"dialog.directory.readError": "Nie można odczytać tego folderu",
|
||||
"dialog.server.add.title": "Dodaj serwer",
|
||||
"dialog.server.add.url": "Adres URL serwera",
|
||||
|
||||
@@ -220,8 +220,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Niciun mesaj de bifurcat",
|
||||
"dialog.directory.action.selectFile": "Selectează fișier",
|
||||
"dialog.directory.action.selectFolder": "Selectează folder",
|
||||
"dialog.directory.root": "Rădăcină",
|
||||
"dialog.directory.parent": "Părinte",
|
||||
"dialog.directory.readError": "Nu se poate citi acest folder",
|
||||
"dialog.server.add.title": "Adaugă server",
|
||||
"dialog.server.add.url": "Adresă server",
|
||||
|
||||
@@ -242,8 +242,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Выбрать файл",
|
||||
"dialog.directory.action.selectFolder": "Выбрать папку",
|
||||
"dialog.directory.root": "Корень",
|
||||
"dialog.directory.parent": "Родительская папка",
|
||||
"dialog.directory.readError": "Не удалось прочитать эту папку",
|
||||
|
||||
"dialog.server.add.title": "Добавить сервер",
|
||||
|
||||
@@ -224,8 +224,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "ෆෝක් කිරීමට පණිවිඩ නැත",
|
||||
"dialog.directory.action.selectFile": "ගොනුව තෝරන්න",
|
||||
"dialog.directory.action.selectFolder": "ෆෝල්ඩරය තෝරන්න",
|
||||
"dialog.directory.root": "මූල",
|
||||
"dialog.directory.parent": "දෙමාපිය",
|
||||
"dialog.directory.readError": "මෙම ෆෝල්ඩරය කියවීමට නොහැක",
|
||||
"dialog.server.add.title": "සේවාදායකය එක් කරන්න",
|
||||
"dialog.server.add.url": "සේවාදායක ලිපිනය",
|
||||
|
||||
@@ -246,8 +246,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Žiadne správy na vytvorenie vetvy",
|
||||
"dialog.directory.action.selectFile": "Vybrať súbor",
|
||||
"dialog.directory.action.selectFolder": "Vybrať priečinok",
|
||||
"dialog.directory.root": "Koreň",
|
||||
"dialog.directory.parent": "Nadradený",
|
||||
"dialog.directory.readError": "Nepodarilo sa načítať tento priečinok",
|
||||
"dialog.server.add.title": "Pridať server",
|
||||
"dialog.server.add.url": "Adresa servera",
|
||||
|
||||
@@ -246,8 +246,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Ni sporočil za odcepitev",
|
||||
"dialog.directory.action.selectFile": "Izberite datoteko",
|
||||
"dialog.directory.action.selectFolder": "Izberite mapo",
|
||||
"dialog.directory.root": "Koren",
|
||||
"dialog.directory.parent": "starš",
|
||||
"dialog.directory.readError": "Te mape ni mogoče prebrati",
|
||||
"dialog.server.add.title": "Dodaj strežnik",
|
||||
"dialog.server.add.url": "Naslov strežnika",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Nuk ka mesazhe për të marrë nga",
|
||||
"dialog.directory.action.selectFile": "Zgjidhni skedarin",
|
||||
"dialog.directory.action.selectFolder": "Zgjidhni dosjen",
|
||||
"dialog.directory.root": "Rrënja",
|
||||
"dialog.directory.parent": "Prindi",
|
||||
"dialog.directory.readError": "Nuk mund të lexohet kjo dosje",
|
||||
"dialog.server.add.title": "Shto server",
|
||||
"dialog.server.add.url": "Adresa e serverit",
|
||||
|
||||
@@ -234,8 +234,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Нема порука од којих треба да се рачвате",
|
||||
"dialog.directory.action.selectFile": "Изаберите датотеку",
|
||||
"dialog.directory.action.selectFolder": "Изаберите фасциклу",
|
||||
"dialog.directory.root": "Роот",
|
||||
"dialog.directory.parent": "Родитељ",
|
||||
"dialog.directory.readError": "Није могуће прочитати ову фасциклу",
|
||||
"dialog.server.add.title": "Додај сервер",
|
||||
"dialog.server.add.url": "Адреса сервера",
|
||||
|
||||
@@ -420,8 +420,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Inga meddelanden att förgrena från",
|
||||
"dialog.directory.action.selectFile": "Välj fil",
|
||||
"dialog.directory.action.selectFolder": "Välj mapp",
|
||||
"dialog.directory.root": "Rotmapp",
|
||||
"dialog.directory.parent": "Överordnad mapp",
|
||||
"dialog.directory.readError": "Det går inte att läsa den här mappen",
|
||||
"dialog.server.add.title": "Lägg till server",
|
||||
"dialog.server.add.url": "Serveradress",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Паёме барои сохтани шоха нест",
|
||||
"dialog.directory.action.selectFile": "Файлро интихоб кунед",
|
||||
"dialog.directory.action.selectFolder": "Папкаро интихоб кунед",
|
||||
"dialog.directory.root": "Реша",
|
||||
"dialog.directory.parent": "Падару модар",
|
||||
"dialog.directory.readError": "Ин ҷузвдонро хондан ғайриимкон аст",
|
||||
"dialog.server.add.title": "Илова кардани сервер",
|
||||
"dialog.server.add.url": "Суроғаи сервер",
|
||||
|
||||
@@ -250,8 +250,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "เลือกไฟล์",
|
||||
"dialog.directory.action.selectFolder": "เลือกโฟลเดอร์",
|
||||
"dialog.directory.root": "โฟลเดอร์ราก",
|
||||
"dialog.directory.parent": "โฟลเดอร์หลัก",
|
||||
"dialog.directory.readError": "ไม่สามารถอ่านโฟลเดอร์นี้ได้",
|
||||
|
||||
"dialog.server.add.title": "เพิ่มเซิร์ฟเวอร์",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Şahalandyrmaly habar ýok",
|
||||
"dialog.directory.action.selectFile": "Faýly saýlaň",
|
||||
"dialog.directory.action.selectFolder": "Papkany saýlaň",
|
||||
"dialog.directory.root": "Kök",
|
||||
"dialog.directory.parent": "Ene-ata",
|
||||
"dialog.directory.readError": "Bu bukjany okap bolmaýar",
|
||||
"dialog.server.add.title": "Serwer goşuň",
|
||||
"dialog.server.add.url": "Serwer salgysy",
|
||||
|
||||
@@ -255,8 +255,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Dosya seç",
|
||||
"dialog.directory.action.selectFolder": "Klasör seç",
|
||||
"dialog.directory.root": "Kök",
|
||||
"dialog.directory.parent": "Üst klasör",
|
||||
"dialog.directory.readError": "Bu klasör okunamıyor",
|
||||
|
||||
"dialog.server.add.title": "Sunucu ekle",
|
||||
|
||||
@@ -271,8 +271,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "Вибрати файл",
|
||||
"dialog.directory.action.selectFolder": "Вибрати папку",
|
||||
"dialog.directory.root": "Корінь",
|
||||
"dialog.directory.parent": "Батьківська папка",
|
||||
"dialog.directory.readError": "Не вдалося прочитати цю папку",
|
||||
|
||||
"dialog.server.add.title": "Додати сервер",
|
||||
|
||||
@@ -228,8 +228,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "کوئی پیغامات نہیں ہیں جن سے فورک کیا جائے۔",
|
||||
"dialog.directory.action.selectFile": "فائل منتخب کریں۔",
|
||||
"dialog.directory.action.selectFolder": "فولڈر منتخب کریں۔",
|
||||
"dialog.directory.root": "بنیادی فولڈر",
|
||||
"dialog.directory.parent": "بالائی فولڈر",
|
||||
"dialog.directory.readError": "یہ فولڈر پڑھا نہیں جا سکا",
|
||||
"dialog.server.add.title": "سرور شامل کریں۔",
|
||||
"dialog.server.add.url": "سرور کا پتہ",
|
||||
|
||||
@@ -221,8 +221,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Hech qanday xabar yo'q",
|
||||
"dialog.directory.action.selectFile": "Faylni tanlang",
|
||||
"dialog.directory.action.selectFolder": "Jildni tanlang",
|
||||
"dialog.directory.root": "Ildiz",
|
||||
"dialog.directory.parent": "Ota-ona",
|
||||
"dialog.directory.readError": "Bu jildni oʻqib boʻlmadi",
|
||||
"dialog.server.add.title": "Server qo'shish",
|
||||
"dialog.server.add.url": "Server manzili",
|
||||
|
||||
@@ -233,8 +233,6 @@ export const dict = {
|
||||
"dialog.fork.empty": "Không có tin nhắn nào để phân nhánh",
|
||||
"dialog.directory.action.selectFile": "Chọn tệp",
|
||||
"dialog.directory.action.selectFolder": "Chọn thư mục",
|
||||
"dialog.directory.root": "Gốc",
|
||||
"dialog.directory.parent": "Thư mục mẹ",
|
||||
"dialog.directory.readError": "Không thể đọc thư mục này",
|
||||
"dialog.server.add.title": "Thêm máy chủ",
|
||||
"dialog.server.add.url": "Địa chỉ máy chủ",
|
||||
|
||||
@@ -267,8 +267,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "选择文件",
|
||||
"dialog.directory.action.selectFolder": "选择文件夹",
|
||||
"dialog.directory.root": "根目录",
|
||||
"dialog.directory.parent": "上级目录",
|
||||
"dialog.directory.readError": "无法读取此文件夹",
|
||||
|
||||
"dialog.server.add.title": "添加服务器",
|
||||
|
||||
@@ -252,8 +252,6 @@ export const dict = {
|
||||
|
||||
"dialog.directory.action.selectFile": "選擇檔案",
|
||||
"dialog.directory.action.selectFolder": "選擇資料夾",
|
||||
"dialog.directory.root": "根目錄",
|
||||
"dialog.directory.parent": "上層目錄",
|
||||
"dialog.directory.readError": "無法讀取此資料夾",
|
||||
|
||||
"dialog.server.add.title": "新增伺服器",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import {
|
||||
createPickerComboboxState,
|
||||
ownsPickerEscape,
|
||||
pickerComboboxView,
|
||||
transitionPickerCombobox,
|
||||
type PickerComboboxContext,
|
||||
@@ -17,6 +18,7 @@ const context: PickerComboboxContext = {
|
||||
root: "/projects",
|
||||
fallback: "/home/luke",
|
||||
locationDirectory: "/projects",
|
||||
committed: "",
|
||||
}
|
||||
|
||||
const key = (name: string, options: { shiftKey?: boolean; composing?: boolean } = {}): PickerComboboxEvent => ({
|
||||
@@ -74,7 +76,6 @@ test("results of an earlier search never open the list for later input", () => {
|
||||
const late = run([{ type: "search.resolved", attempt: attempt(first.state), items: [directory("/x")] }], second.state)
|
||||
|
||||
expect(second.effects).toEqual([
|
||||
{ type: "selection.clear" },
|
||||
{ type: "search.start", attempt: attempt(first.state) + 1, query: "/projects/new", timeoutMs: 10_000 },
|
||||
])
|
||||
expect(late.state).toBe(second.state)
|
||||
@@ -121,18 +122,24 @@ test("arrow keys wrap through the list and reopen a closed list after a search",
|
||||
expect(pickerComboboxView(resolved.state).active).toBe(1)
|
||||
})
|
||||
|
||||
test("Escape closes an open list without reaching the dialog, and otherwise passes through", () => {
|
||||
test("Escape closes an open list, then drops the draft, without reaching the dialog, and otherwise passes through", () => {
|
||||
const state = opened("~/op", [directory("/home/luke/a")])
|
||||
const escaped = run([key("Escape")], state)
|
||||
const passed = run([key("Escape")], escaped.state)
|
||||
const reverted = run([key("Escape")], escaped.state)
|
||||
const passed = run([key("Escape")], reverted.state)
|
||||
|
||||
expect(escaped).toMatchObject({
|
||||
state: { status: "closed", input: "~/op" },
|
||||
preventDefault: true,
|
||||
stopPropagation: true,
|
||||
})
|
||||
expect(reverted).toMatchObject({
|
||||
state: { status: "closed", input: "" },
|
||||
preventDefault: true,
|
||||
stopPropagation: true,
|
||||
})
|
||||
expect(passed).toMatchObject({ preventDefault: false, stopPropagation: false })
|
||||
expect(passed.state).toBe(escaped.state)
|
||||
expect(passed.state).toBe(reverted.state)
|
||||
})
|
||||
|
||||
test("Shift+Tab and IME Enter pass through", () => {
|
||||
@@ -187,7 +194,7 @@ test("input typed before the location resolves searches once the location arrive
|
||||
const located = run([{ type: "context.changed" }], typed.state)
|
||||
|
||||
expect(typed.state).toMatchObject({ status: "open", input: "~/op", items: [] })
|
||||
expect(typed.effects).toEqual([{ type: "selection.clear" }])
|
||||
expect(typed.effects).toEqual([])
|
||||
expect(located.state).toMatchObject({ status: "loading", input: "~/op" })
|
||||
expect(located.effects).toEqual([
|
||||
{ type: "search.start", attempt: attempt(typed.state) + 1, query: "~/op", timeoutMs: 10_000 },
|
||||
@@ -221,5 +228,59 @@ test("input equal to the open root has nothing to suggest", () => {
|
||||
const typed = run([{ type: "input.changed", value: "/projects/" }])
|
||||
|
||||
expect(typed.state).toMatchObject({ status: "open", items: [] })
|
||||
expect(typed.effects).toEqual([{ type: "selection.clear" }])
|
||||
expect(typed.effects).toEqual([])
|
||||
})
|
||||
|
||||
const selected = { ...context, committed: "/projects/acme/" }
|
||||
|
||||
test("a draft never clears the selection, survives a selection that settles while typing, and Escape reverts it", () => {
|
||||
const synced = run([{ type: "synced" }], createPickerComboboxState(), selected)
|
||||
const edited = run([{ type: "input.changed", value: "/projects/ac" }], synced.state, selected)
|
||||
const cleared = run([{ type: "cleared" }], synced.state, selected)
|
||||
|
||||
expect(synced.state).toEqual({ status: "closed", attempt: 0, input: "/projects/acme/" })
|
||||
expect(edited.effects.map((effect) => effect.type)).toEqual(["search.start"])
|
||||
expect(cleared.effects).toEqual([])
|
||||
|
||||
for (const draft of [edited.state, cleared.state]) {
|
||||
const reverted = run([key("Escape")], draft, selected)
|
||||
|
||||
expect(reverted.state).toMatchObject({ status: "closed", input: "/projects/acme/" })
|
||||
expect(reverted.effects).toEqual(draft.status === "loading" ? [{ type: "search.cancel" }] : [])
|
||||
}
|
||||
|
||||
const moved = { ...selected, committed: "/projects/billing/" }
|
||||
|
||||
expect(run([{ type: "synced" }], edited.state, moved).state).toBe(edited.state)
|
||||
expect(run([{ type: "synced" }], cleared.state, moved).state).toMatchObject({ input: "/projects/billing/" })
|
||||
|
||||
expect(ownsPickerEscape(edited.state, selected.committed)).toBeTrue()
|
||||
expect(ownsPickerEscape(cleared.state, selected.committed)).toBeTrue()
|
||||
expect(ownsPickerEscape(synced.state, selected.committed)).toBeFalse()
|
||||
|
||||
const escaped = run([key("Escape")], synced.state, selected)
|
||||
|
||||
expect(escaped).toMatchObject({ preventDefault: false, stopPropagation: false })
|
||||
expect(escaped.state).toBe(synced.state)
|
||||
})
|
||||
|
||||
test("confirming submits the selection, or commits a draft first and submits once it is selected", () => {
|
||||
const synced = run([{ type: "synced" }], createPickerComboboxState(), selected).state
|
||||
const typed = run([{ type: "input.changed", value: "/projects/billing" }], synced, selected).state
|
||||
|
||||
const listed = run(
|
||||
[{ type: "search.resolved", attempt: attempt(typed), items: [directory("/projects/billing-service")] }],
|
||||
typed,
|
||||
selected,
|
||||
).state
|
||||
|
||||
expect(run([{ type: "submitted" }], synced, selected).effects).toEqual([{ type: "submit" }])
|
||||
expect(run([{ type: "submitted" }], createPickerComboboxState(), selected).effects).toEqual([{ type: "submit" }])
|
||||
expect(run([{ type: "submitted" }], typed, selected).effects).toEqual([
|
||||
{ type: "search.cancel" },
|
||||
{ type: "choose.directory", path: "/projects/billing", submit: true },
|
||||
])
|
||||
expect(run([{ type: "submitted" }], listed, selected).effects).toEqual([
|
||||
{ type: "choose.directory", path: "/projects/billing-service", submit: true },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -12,19 +12,24 @@ export const PICKER_SEARCH_TIMEOUT_MS = 10_000
|
||||
|
||||
export type PickerSuggestion = { readonly absolute: string; readonly type: "file" | "directory" }
|
||||
|
||||
/** What the input resolves and searches against. `fallback` is the base for relative input before a root opens. */
|
||||
/**
|
||||
* What the input resolves and searches against. `fallback` is the base for relative input before a root opens;
|
||||
* `committed` is the selection as the input shows it.
|
||||
*/
|
||||
export type PickerComboboxContext = {
|
||||
readonly policy: PickerPolicy
|
||||
readonly home: string
|
||||
readonly root: string
|
||||
readonly fallback: string
|
||||
readonly locationDirectory: string | undefined
|
||||
readonly committed: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The path input and its suggestion list. Only `open` holds items, and only for its `input`, so a key pressed while the
|
||||
* next search runs never acts on the previous query's results. `active` is null until the user steps or hovers;
|
||||
* `step` is an arrow key pressed while the search runs.
|
||||
* The path input and its suggestion list. The input shows the committed selection; typed input is a draft that only
|
||||
* changes the selection once committed (Enter, a suggestion, or `submitted`). Only `open` holds items, and only for
|
||||
* its `input`, so a key pressed while the next search runs never acts on the previous query's results. `active` is
|
||||
* null until the user steps or hovers; `step` is an arrow key pressed while the search runs.
|
||||
*/
|
||||
export type PickerComboboxState =
|
||||
| { readonly status: "closed"; readonly attempt: number; readonly input: string }
|
||||
@@ -45,6 +50,8 @@ export type PickerComboboxEvent =
|
||||
| { readonly type: "context.changed" }
|
||||
| { readonly type: "item.hovered"; readonly index: number }
|
||||
| { readonly type: "item.clicked"; readonly index: number }
|
||||
| { readonly type: "synced" }
|
||||
| { readonly type: "submitted" }
|
||||
| { readonly type: "key.down"; readonly key: string; readonly shiftKey: boolean; readonly composing: boolean }
|
||||
| { readonly type: "search.resolved"; readonly attempt: number; readonly items: readonly PickerSuggestion[] }
|
||||
| { readonly type: "search.failed"; readonly attempt: number }
|
||||
@@ -54,9 +61,9 @@ export type PickerComboboxEvent =
|
||||
export type PickerComboboxEffect =
|
||||
| { readonly type: "search.start"; readonly attempt: number; readonly query: string; readonly timeoutMs: number }
|
||||
| { readonly type: "search.cancel" }
|
||||
| { readonly type: "selection.clear" }
|
||||
| { readonly type: "choose.directory"; readonly path: string }
|
||||
| { readonly type: "choose.file"; readonly absolute: string }
|
||||
| { readonly type: "choose.directory"; readonly path: string; readonly submit?: true }
|
||||
| { readonly type: "choose.file"; readonly absolute: string; readonly submit?: true }
|
||||
| { readonly type: "submit" }
|
||||
|
||||
export type PickerComboboxTransition = {
|
||||
readonly state: PickerComboboxState
|
||||
@@ -86,11 +93,22 @@ export function transitionPickerCombobox(
|
||||
const input = cleanPickerInput(event.value)
|
||||
|
||||
// Trailing whitespace cleans to the same input; the running search or open list still matches it.
|
||||
if (input === state.input && (state.status !== "closed" || !input)) {
|
||||
return result(state, [{ type: "selection.clear" }])
|
||||
}
|
||||
if (input === state.input && (state.status !== "closed" || !input)) return unchanged(state)
|
||||
|
||||
return withInput(state, input, context, [{ type: "selection.clear" }])
|
||||
return withInput(state, input, context, [])
|
||||
}
|
||||
|
||||
// A selection that settles while the user types keeps the draft; picking in the tree closes the list first.
|
||||
if (event.type === "synced") {
|
||||
if (state.status !== "closed" || state.input === context.committed) return unchanged(state)
|
||||
|
||||
return result(close(state, context.committed))
|
||||
}
|
||||
|
||||
if (event.type === "submitted") {
|
||||
if (!state.input || state.input === context.committed) return result(state, [{ type: "submit" }])
|
||||
|
||||
return commit(state, context, true)
|
||||
}
|
||||
|
||||
if (event.type === "cleared") {
|
||||
@@ -168,6 +186,13 @@ export function pickerComboboxView(state: PickerComboboxState) {
|
||||
}
|
||||
}
|
||||
|
||||
// Escape closes an open list or drops a draft; only then does the input keep it from the dialog.
|
||||
export function ownsPickerEscape(state: PickerComboboxState, committed: string) {
|
||||
if (state.status === "disposed") return false
|
||||
|
||||
return (state.status === "open" && state.items.length > 0) || state.input !== committed
|
||||
}
|
||||
|
||||
function key(
|
||||
state: LiveCombobox,
|
||||
event: Extract<PickerComboboxEvent, { type: "key.down" }>,
|
||||
@@ -176,9 +201,13 @@ function key(
|
||||
const items = state.status === "open" ? state.items : []
|
||||
|
||||
if (event.key === "Escape") {
|
||||
if (state.status !== "open" || items.length === 0) return unchanged(state)
|
||||
if (state.status === "open" && items.length > 0) {
|
||||
return { ...result(close(state, state.input)), preventDefault: true, stopPropagation: true }
|
||||
}
|
||||
|
||||
return { ...result(close(state, state.input)), preventDefault: true, stopPropagation: true }
|
||||
if (state.input === context.committed) return unchanged(state)
|
||||
|
||||
return { ...result(close(state, context.committed), cancel(state)), preventDefault: true, stopPropagation: true }
|
||||
}
|
||||
|
||||
if (event.key === "Tab") {
|
||||
@@ -207,26 +236,32 @@ function key(
|
||||
}
|
||||
|
||||
if (event.key !== "Enter" || event.composing) return unchanged(state)
|
||||
const active = effectiveActiveIndex(state)
|
||||
|
||||
if (state.status === "open" && active >= 0) return handled(choose(state, state.items[active]!, context))
|
||||
const value = state.input ? resolve(state.input, context) : undefined
|
||||
|
||||
if (!value) return handled(unchanged(state))
|
||||
|
||||
return handled(
|
||||
result(close(state, displayInputDirectory(value, context.home)), [
|
||||
...cancel(state),
|
||||
{ type: "choose.directory", path: state.input },
|
||||
]),
|
||||
)
|
||||
return handled(commit(state, context, false))
|
||||
}
|
||||
|
||||
function choose(state: LiveCombobox, item: PickerSuggestion, context: PickerComboboxContext) {
|
||||
// Enter and a confirm with a draft both choose the highlighted suggestion, or else the typed path.
|
||||
function commit(state: LiveCombobox, context: PickerComboboxContext, submit: boolean) {
|
||||
const active = effectiveActiveIndex(state)
|
||||
|
||||
if (state.status === "open" && active >= 0) return choose(state, state.items[active]!, context, submit)
|
||||
const value = state.input ? resolve(state.input, context) : undefined
|
||||
|
||||
if (!value) return unchanged(state)
|
||||
|
||||
return result(close(state, displayInputDirectory(value, context.home)), [
|
||||
...cancel(state),
|
||||
chosenDirectory(state.input, submit),
|
||||
])
|
||||
}
|
||||
|
||||
function choose(state: LiveCombobox, item: PickerSuggestion, context: PickerComboboxContext, submit = false) {
|
||||
if (item.type === "file") {
|
||||
return result(close(state, displayPickerPath(item.absolute, state.input, context.home)), [
|
||||
...cancel(state),
|
||||
{ type: "choose.file", absolute: item.absolute },
|
||||
submit
|
||||
? { type: "choose.file", absolute: item.absolute, submit }
|
||||
: { type: "choose.file", absolute: item.absolute },
|
||||
])
|
||||
}
|
||||
|
||||
@@ -236,10 +271,14 @@ function choose(state: LiveCombobox, item: PickerSuggestion, context: PickerComb
|
||||
|
||||
return result(close(state, displayInputDirectory(value, context.home)), [
|
||||
...cancel(state),
|
||||
{ type: "choose.directory", path: item.absolute },
|
||||
chosenDirectory(item.absolute, submit),
|
||||
])
|
||||
}
|
||||
|
||||
function chosenDirectory(path: string, submit: boolean): PickerComboboxEffect {
|
||||
return submit ? { type: "choose.directory", path, submit } : { type: "choose.directory", path }
|
||||
}
|
||||
|
||||
function withInput(
|
||||
state: LiveCombobox,
|
||||
input: string,
|
||||
|
||||
@@ -2,21 +2,49 @@
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.directory-picker-subtitle {
|
||||
overflow: hidden;
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-tight);
|
||||
letter-spacing: 0.05px;
|
||||
text-overflow: ellipsis;
|
||||
/* Outranks the dialog's rule that grows the title, so the server chip sits beside it. */
|
||||
.directory-picker.directory-picker
|
||||
[data-slot="dialog-header"]
|
||||
.directory-picker-header
|
||||
> [data-slot="dialog-header-title"] {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
/* The 20px close button would add 2px below the 16px title row. */
|
||||
[data-component="dialog-v2"]
|
||||
[data-slot="dialog-container"]
|
||||
.directory-picker
|
||||
[data-slot="dialog-header"]
|
||||
[data-slot="dialog-close-button"] {
|
||||
margin-block: -2px;
|
||||
}
|
||||
|
||||
.directory-picker-server {
|
||||
display: inline-flex;
|
||||
min-width: 0;
|
||||
max-width: 240px;
|
||||
height: 16px;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: var(--line-height-compact);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-server [data-component="icon"] {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-muted);
|
||||
}
|
||||
|
||||
.directory-picker-body {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
@@ -31,7 +59,6 @@
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.directory-picker-input {
|
||||
@@ -40,72 +67,121 @@
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
|
||||
.directory-picker-actions {
|
||||
display: flex;
|
||||
.directory-picker-item-name {
|
||||
flex-shrink: 0;
|
||||
gap: 2px;
|
||||
max-width: 50%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-item-path {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--v2-text-text-faint);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-recent {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.directory-picker-recent-label {
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 13px;
|
||||
font-weight: 530;
|
||||
line-height: var(--line-height-compact);
|
||||
letter-spacing: -0.04px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.directory-picker-recent-list {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
margin-top: -4px;
|
||||
}
|
||||
|
||||
.directory-picker-recent-item {
|
||||
max-width: 240px;
|
||||
max-width: 160px;
|
||||
gap: 6px;
|
||||
padding-inline: 4px 8px;
|
||||
}
|
||||
|
||||
.directory-picker-recent-menu {
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.directory-picker-recent + .directory-picker-folder {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.directory-picker-folder {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex: 1 1 312px;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-base);
|
||||
}
|
||||
|
||||
.directory-picker-folder-header {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
height: 32px;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 4px 0 6px;
|
||||
border-bottom: 0.5px solid var(--v2-border-border-base);
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumbs {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb {
|
||||
min-width: 0;
|
||||
height: 22px;
|
||||
flex-shrink: 1;
|
||||
overflow: hidden;
|
||||
padding: 0 6px;
|
||||
border-radius: 4px;
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 22px;
|
||||
letter-spacing: -0.04px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb:hover {
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb[aria-current] {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb-separator {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-faint);
|
||||
}
|
||||
|
||||
.directory-picker-suggestions {
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
top: 34px;
|
||||
top: 36px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 4px;
|
||||
border: 1px solid var(--v2-border-border-base);
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-layer-02);
|
||||
box-shadow: var(--v2-elevation-overlay);
|
||||
}
|
||||
|
||||
.directory-picker-suggestions button {
|
||||
overflow: hidden;
|
||||
padding: 6px 8px;
|
||||
border-radius: 4px;
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 13px;
|
||||
line-height: var(--line-height-compact);
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
.directory-picker-suggestions-viewport {
|
||||
max-height: 232px;
|
||||
}
|
||||
|
||||
.directory-picker-suggestions button:hover,
|
||||
.directory-picker-suggestions button[data-active] {
|
||||
color: var(--v2-text-text-base);
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
.directory-picker-suggestions [data-component="menu-v2-item"] [data-component="icon"] {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-muted);
|
||||
}
|
||||
|
||||
.directory-picker-browser {
|
||||
@@ -116,10 +192,7 @@
|
||||
min-height: 0;
|
||||
flex: 1 1 280px;
|
||||
overflow: hidden;
|
||||
padding: 6px;
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-base);
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.directory-picker-tree {
|
||||
@@ -132,8 +205,8 @@
|
||||
--trees-bg-muted-override: transparent;
|
||||
--trees-selected-bg-override: var(--v2-overlay-simple-overlay-pressed);
|
||||
--trees-selected-fg-override: var(--v2-text-text-base);
|
||||
--trees-selected-focused-border-color-override: var(--v2-border-border-focus);
|
||||
--trees-focus-ring-color-override: var(--v2-border-border-focus);
|
||||
--trees-selected-focused-border-color-override: transparent;
|
||||
--trees-focus-ring-color-override: transparent;
|
||||
--trees-focus-ring-width-override: 1px;
|
||||
--trees-focus-ring-offset-override: -1px;
|
||||
--trees-border-color-override: var(--v2-border-border-base);
|
||||
@@ -141,7 +214,8 @@
|
||||
--trees-font-size-override: 13px;
|
||||
--trees-item-height: 24px;
|
||||
--trees-border-radius-override: 4px;
|
||||
--trees-padding-inline-override: 0px;
|
||||
/* Matches the 6px scrollbar gutter, which the tree takes out of the end padding. */
|
||||
--trees-padding-inline-override: 6px;
|
||||
--trees-item-margin-x-override: 0px;
|
||||
--trees-item-padding-x-override: 8px;
|
||||
--trees-item-row-gap-override: 6px;
|
||||
@@ -158,23 +232,3 @@
|
||||
line-height: var(--line-height-compact);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.directory-picker-selection {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
flex: 1 1 0%;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.directory-picker-selection-text {
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
color: var(--v2-text-text-faint);
|
||||
font-size: 13px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-compact);
|
||||
letter-spacing: -0.04px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@ import { FileTree } from "@pierre/trees"
|
||||
import { Dialog, DialogBody, DialogFooter, DialogHeader, DialogTitle } from "@opencode/ui/dialog"
|
||||
import { Button } from "@opencode/ui/button"
|
||||
import { Divider } from "@opencode/ui/divider"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
import { MenuScroll } from "@opencode/ui/menu-scroll"
|
||||
import {
|
||||
displayName,
|
||||
getProjectAvatarGenerated,
|
||||
getProjectAvatarSource,
|
||||
getProjectAvatarVariant,
|
||||
ProjectAvatar,
|
||||
@@ -26,10 +30,11 @@ import {
|
||||
pickerMode,
|
||||
createPriorityTaskQueue,
|
||||
createDirectorySearch,
|
||||
displayInputDirectory,
|
||||
displayPickerPath,
|
||||
shortenPickerRecentPath,
|
||||
pickerBreadcrumbs,
|
||||
pickerParent,
|
||||
pickerRoot,
|
||||
listPickerDirectory,
|
||||
pickerRelativePath,
|
||||
pickerAbsolutePath,
|
||||
@@ -45,6 +50,7 @@ import {
|
||||
} from "./tree-machine"
|
||||
import {
|
||||
createPickerComboboxState,
|
||||
ownsPickerEscape,
|
||||
pickerComboboxView,
|
||||
transitionPickerCombobox,
|
||||
type PickerComboboxEffect,
|
||||
@@ -152,23 +158,43 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
|
||||
return true
|
||||
})
|
||||
.slice(0, 5)
|
||||
.slice(0, 10)
|
||||
})
|
||||
|
||||
const search = createDirectorySearch({ sdk, home, location, base: () => treeView().root || start() })
|
||||
|
||||
const fullSelectionPath = createMemo(() => {
|
||||
const value = treeView().result
|
||||
const breadcrumbs = createMemo(() => {
|
||||
const root = treeView().root
|
||||
const crumbs = root ? pickerBreadcrumbs(root, home()) : []
|
||||
// Deep paths collapse the folders between / and ~ and the last two into an ellipsis that opens the one above them.
|
||||
const lead = crumbs[1]?.label === "~" ? 2 : 1
|
||||
|
||||
return value ? displayPickerPath(value, "", home()) : ""
|
||||
if (crumbs.length <= lead + 3) return crumbs
|
||||
|
||||
return [...crumbs.slice(0, lead), { label: "…", path: crumbs[crumbs.length - 3].path }, ...crumbs.slice(-2)]
|
||||
})
|
||||
|
||||
const shortSelectionPath = createMemo(() => {
|
||||
const value = treeView().result
|
||||
const committed = createMemo(() => {
|
||||
const selected = treeView().selected
|
||||
|
||||
return value ? shortenPickerRecentPath(value, home()) : ""
|
||||
if (!selected) return ""
|
||||
|
||||
return policy.action === "file" ? displayPickerPath(selected, "", home()) : displayInputDirectory(selected, home())
|
||||
})
|
||||
|
||||
function atSelection(input: HTMLInputElement) {
|
||||
if (!input.value) return true
|
||||
|
||||
const end = input.value.length
|
||||
|
||||
return input.value === committed() && input.selectionStart === end && input.selectionEnd === end
|
||||
}
|
||||
|
||||
function choose(directory: string) {
|
||||
dispatchCombobox({ type: "dismissed" })
|
||||
dispatchTree({ type: "directory.chosen", ...navigation(directory), fromInput: false })
|
||||
}
|
||||
|
||||
function navigation(path: string) {
|
||||
return { path, home: home(), fallback: start() || home(), located: Boolean(location()) }
|
||||
}
|
||||
@@ -195,6 +221,7 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
root: treeView().root,
|
||||
fallback: start() || home(),
|
||||
locationDirectory: location()?.directory,
|
||||
committed: committed(),
|
||||
})
|
||||
|
||||
if (next.state !== previous) setMachines((current) => ({ ...current, combobox: next.state }))
|
||||
@@ -309,6 +336,8 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
return
|
||||
}
|
||||
|
||||
if (effect.type === "submit") return resolve()
|
||||
|
||||
if (effect.type === "tree.focus-initial") {
|
||||
if (!tree?.getFocusedPath()) tree?.focusNearestPath(null)
|
||||
|
||||
@@ -343,13 +372,20 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
|
||||
if (effect.type === "search.cancel") return stopSearch()
|
||||
|
||||
if (effect.type === "selection.clear") return dispatchTree({ type: "selection.cleared" })
|
||||
if (effect.type === "submit") return resolve()
|
||||
|
||||
if (effect.type === "choose.directory") {
|
||||
return dispatchTree({ type: "directory.chosen", ...navigation(effect.path), fromInput: true })
|
||||
return dispatchTree({
|
||||
type: "directory.chosen",
|
||||
...navigation(effect.path),
|
||||
fromInput: true,
|
||||
submit: effect.submit,
|
||||
})
|
||||
}
|
||||
|
||||
dispatchTree({ type: "file.chosen", absolute: effect.absolute, home: home() })
|
||||
|
||||
if (effect.submit) resolve()
|
||||
}
|
||||
|
||||
function stopSearch() {
|
||||
@@ -457,7 +493,7 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
box-shadow: none !important;
|
||||
color: var(--v2-text-text-muted) !important;
|
||||
font-size: 13px !important;
|
||||
font-weight: 440 !important;
|
||||
font-weight: 500 !important;
|
||||
letter-spacing: -0.04px !important;
|
||||
}
|
||||
button[data-type="item"]:hover {
|
||||
@@ -477,12 +513,11 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
background:
|
||||
linear-gradient(0deg, var(--v2-overlay-simple-overlay-pressed), var(--v2-overlay-simple-overlay-pressed)),
|
||||
var(--v2-background-bg-base) !important;
|
||||
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base) !important;
|
||||
color: var(--v2-text-text-base) !important;
|
||||
font-weight: 530 !important;
|
||||
}
|
||||
button[data-type="item"]:focus-visible {
|
||||
outline: none !important;
|
||||
box-shadow: inset 0 0 0 1px var(--v2-border-border-focus) !important;
|
||||
}
|
||||
[data-item-type="folder"] > [data-item-section="icon"] {
|
||||
width: auto !important;
|
||||
@@ -519,16 +554,36 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
-webkit-mask-image: ${FOLDER_OPEN_MASK};
|
||||
mask-image: ${FOLDER_OPEN_MASK};
|
||||
}
|
||||
/* The tree renders rows in its shadow root, which only takes text decorations, so this repeats Badge's neutral compact style. */
|
||||
[data-item-section="decoration"] > span {
|
||||
box-sizing: border-box;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 16px;
|
||||
padding: 0 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--v2-background-bg-layer-03);
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
background: var(--v2-background-bg-layer-02);
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 530;
|
||||
line-height: 12px;
|
||||
line-height: 1;
|
||||
letter-spacing: 0.05px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
[data-item-section="spacing"] {
|
||||
padding-inline-start: 6.5px;
|
||||
}
|
||||
[data-item-section="spacing-item"] {
|
||||
border-left: none;
|
||||
margin-right: 0;
|
||||
border-inline-start: 1px solid color-mix(in srgb, var(--v2-border-border-muted) 50%, transparent);
|
||||
margin-inline-end: calc(var(--trees-level-gap) - 1px);
|
||||
transform: none;
|
||||
}
|
||||
/* The tree always reserves a lane for git change letters. */
|
||||
[data-item-section="git"] {
|
||||
display: none;
|
||||
}
|
||||
[data-file-tree-virtualized-scroll] {
|
||||
overscroll-behavior: contain;
|
||||
@@ -557,6 +612,8 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
if (path) dispatchTree({ type: "navigate", ...navigation(path) })
|
||||
})
|
||||
|
||||
createEffect(on(committed, () => dispatchCombobox({ type: "synced" }), { defer: true }))
|
||||
|
||||
// Suggestions search against the root and location, so a search started before either arrived runs again.
|
||||
createEffect(
|
||||
on([() => location()?.directory, treeRoot], () => dispatchCombobox({ type: "context.changed" }), {
|
||||
@@ -578,9 +635,10 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
<DialogTitle>{props.title ?? language.t("command.project.open")}</DialogTitle>
|
||||
<Show when={subtitle()}>
|
||||
{(value) => (
|
||||
<div class="directory-picker-subtitle" dir="ltr">
|
||||
{value()}
|
||||
</div>
|
||||
<span class="directory-picker-server" dir="ltr">
|
||||
<Icon name="server" size="small" />
|
||||
<span class="truncate">{value()}</span>
|
||||
</span>
|
||||
)}
|
||||
</Show>
|
||||
</div>
|
||||
@@ -597,6 +655,9 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
showClearButton={!!comboboxView().input}
|
||||
onClearClick={() => dispatchCombobox({ type: "cleared" })}
|
||||
class="directory-picker-input"
|
||||
data-owns-escape={ownsPickerEscape(machines().combobox, committed()) ? "" : undefined}
|
||||
appearance="large"
|
||||
leadingIcon={<Icon name="magnifying-glass" size="small" />}
|
||||
onInput={(event) => dispatchCombobox({ type: "input.changed", value: event.currentTarget.value })}
|
||||
role="combobox"
|
||||
aria-label={language.t("dialog.directory.search.placeholder")}
|
||||
@@ -605,6 +666,19 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
aria-controls="directory-picker-suggestions"
|
||||
aria-activedescendant={comboboxView().activeDescendant}
|
||||
onKeyDown={(event) => {
|
||||
// Goes up a level from the shown selection; a held key that just cleared the text must not keep climbing.
|
||||
if (
|
||||
event.key === "Backspace" &&
|
||||
!event.repeat &&
|
||||
!event.isComposing &&
|
||||
atSelection(event.currentTarget)
|
||||
) {
|
||||
event.preventDefault()
|
||||
const selected = treeView().selected
|
||||
|
||||
return selected ? choose(pickerParent(selected)) : navigate(pickerParent(treeView().root))
|
||||
}
|
||||
|
||||
const next = dispatchCombobox({
|
||||
type: "key.down",
|
||||
key: event.key,
|
||||
@@ -617,118 +691,162 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
||||
if (next.stopPropagation) event.stopPropagation()
|
||||
}}
|
||||
/>
|
||||
<div class="directory-picker-actions">
|
||||
<Button size="normal" variant="ghost" onClick={() => navigate(home() || treeView().root)}>
|
||||
~
|
||||
</Button>
|
||||
<Button
|
||||
size="normal"
|
||||
variant="ghost"
|
||||
onClick={() => navigate(pickerRoot(treeView().root) || treeView().root)}
|
||||
>
|
||||
{language.t("dialog.directory.root")}
|
||||
</Button>
|
||||
<Button
|
||||
size="normal"
|
||||
variant="ghost"
|
||||
onClick={() => navigate(pickerParent(treeView().selected || treeView().root))}
|
||||
>
|
||||
{language.t("dialog.directory.parent")}
|
||||
</Button>
|
||||
</div>
|
||||
<Show when={comboboxView().listboxOpen}>
|
||||
<div id="directory-picker-suggestions" role="listbox" class="directory-picker-suggestions">
|
||||
<For each={comboboxView().items}>
|
||||
{(suggestion, index) => (
|
||||
<button
|
||||
id={`directory-picker-suggestion-${index()}`}
|
||||
data-directory-path={suggestion.absolute}
|
||||
role="option"
|
||||
aria-selected={index() === comboboxView().active}
|
||||
data-active={index() === comboboxView().active ? "" : undefined}
|
||||
onPointerMove={() => dispatchCombobox({ type: "item.hovered", index: index() })}
|
||||
onClick={() => dispatchCombobox({ type: "item.clicked", index: index() })}
|
||||
>
|
||||
{displayPickerPath(suggestion.absolute, comboboxView().input, home())}
|
||||
{suggestion.type === "directory" ? "/" : ""}
|
||||
</button>
|
||||
)}
|
||||
</For>
|
||||
<div data-component="menu-v2-content" class="directory-picker-suggestions">
|
||||
<MenuScroll viewportClass="directory-picker-suggestions-viewport">
|
||||
<div id="directory-picker-suggestions" role="listbox">
|
||||
<For each={comboboxView().items}>
|
||||
{(suggestion, index) => (
|
||||
<div
|
||||
id={`directory-picker-suggestion-${index()}`}
|
||||
data-component="menu-v2-item"
|
||||
data-directory-path={suggestion.absolute}
|
||||
role="option"
|
||||
aria-selected={index() === comboboxView().active}
|
||||
data-highlighted={index() === comboboxView().active ? "" : undefined}
|
||||
onPointerMove={() => dispatchCombobox({ type: "item.hovered", index: index() })}
|
||||
onClick={() => dispatchCombobox({ type: "item.clicked", index: index() })}
|
||||
>
|
||||
<span data-slot="menu-v2-item-content">
|
||||
<Icon name={suggestion.type === "directory" ? "folder" : "open-file"} size="small" />
|
||||
<span class="directory-picker-item-name">
|
||||
{pickerBreadcrumbs(suggestion.absolute, home()).at(-1)?.label}
|
||||
</span>
|
||||
<bdi dir="ltr" class="directory-picker-item-path">
|
||||
{shortenPickerRecentPath(pickerParent(suggestion.absolute), home())}
|
||||
</bdi>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
</MenuScroll>
|
||||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
<Show when={recentProjects().length > 0}>
|
||||
<div class="directory-picker-recent">
|
||||
<div class="directory-picker-recent-label">{language.t("dialog.directory.recent")}</div>
|
||||
<div class="directory-picker-recent-list">
|
||||
<For each={recentProjects()}>
|
||||
{(project) => {
|
||||
const name = () => displayName(project)
|
||||
const fullPath = () => displayPickerPath(project.worktree, "", home())
|
||||
const shortPath = () => shortenPickerRecentPath(project.worktree, home())
|
||||
<div class="directory-picker-recent" aria-label={language.t("dialog.directory.recent")} role="group">
|
||||
<For each={recentProjects().slice(0, 3)}>
|
||||
{(project) => {
|
||||
const name = () => displayName(project)
|
||||
const shortPath = () => shortenPickerRecentPath(project.worktree, home())
|
||||
|
||||
return (
|
||||
<Tooltip placement="top" value={<bdi dir="ltr">{fullPath()}</bdi>}>
|
||||
<Button
|
||||
size="normal"
|
||||
variant="neutral"
|
||||
class="directory-picker-recent-item"
|
||||
aria-label={language.t("dialog.directory.recentProject", {
|
||||
name: name(),
|
||||
path: shortPath(),
|
||||
})}
|
||||
onClick={() => {
|
||||
dispatchCombobox({ type: "dismissed" })
|
||||
dispatchTree({ type: "directory.chosen", ...navigation(project.worktree), fromInput: false })
|
||||
}}
|
||||
>
|
||||
<ProjectAvatar
|
||||
class="shrink-0"
|
||||
aria-hidden="true"
|
||||
fallback={name()}
|
||||
src={getProjectAvatarSource(project.id, project.icon)}
|
||||
variant={getProjectAvatarVariant(project.icon?.color)}
|
||||
/>
|
||||
<span class="min-w-0 truncate">{name()}</span>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
</div>
|
||||
return (
|
||||
<Tooltip
|
||||
placement="top"
|
||||
value={<bdi dir="ltr">{displayPickerPath(project.worktree, "", home())}</bdi>}
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
variant="neutral"
|
||||
class="directory-picker-recent-item"
|
||||
aria-label={language.t("dialog.directory.recentProject", { name: name(), path: shortPath() })}
|
||||
onClick={() => choose(project.worktree)}
|
||||
>
|
||||
<ProjectAvatar
|
||||
class="shrink-0"
|
||||
aria-hidden="true"
|
||||
fallback={name()}
|
||||
src={getProjectAvatarSource(project.id, project.icon)}
|
||||
variant={getProjectAvatarVariant(project.icon?.color)}
|
||||
generated={getProjectAvatarGenerated(project)}
|
||||
/>
|
||||
<span class="min-w-0 truncate">{name()}</span>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
<Show when={recentProjects().length > 3}>
|
||||
<Menu gutter={4} modal={false} placement="bottom-start">
|
||||
<Menu.Trigger as={Button} size="small" variant="neutral">
|
||||
{language.t("dialog.directory.moreProjects")}
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content class="directory-picker-recent-menu">
|
||||
<For each={recentProjects().slice(3)}>
|
||||
{(project) => {
|
||||
const name = () => displayName(project)
|
||||
const shortPath = () => shortenPickerRecentPath(project.worktree, home())
|
||||
|
||||
return (
|
||||
<Menu.Item
|
||||
aria-label={language.t("dialog.directory.recentProject", {
|
||||
name: name(),
|
||||
path: shortPath(),
|
||||
})}
|
||||
onSelect={() => choose(project.worktree)}
|
||||
>
|
||||
<ProjectAvatar
|
||||
class="shrink-0"
|
||||
aria-hidden="true"
|
||||
fallback={name()}
|
||||
src={getProjectAvatarSource(project.id, project.icon)}
|
||||
variant={getProjectAvatarVariant(project.icon?.color)}
|
||||
generated={getProjectAvatarGenerated(project)}
|
||||
/>
|
||||
<span class="directory-picker-item-name">{name()}</span>
|
||||
<bdi dir="ltr" class="directory-picker-item-path">
|
||||
{shortPath()}
|
||||
</bdi>
|
||||
</Menu.Item>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
<div
|
||||
class="directory-picker-browser"
|
||||
ref={container}
|
||||
// The modal's scroll lock sees only the shadow host, not the tree's inner scroller. Stopping the event here
|
||||
// keeps the lock from cancelling it, and the passive listener leaves the scroller to the compositor.
|
||||
on:touchmove={(event) => event.stopPropagation()}
|
||||
on:wheel={{ handleEvent: (event: WheelEvent) => event.stopPropagation(), passive: true }}
|
||||
>
|
||||
<Show when={treeView().loading}>
|
||||
<div class="directory-picker-state">{language.t("common.loading")}</div>
|
||||
</Show>
|
||||
<Show when={treeView().error}>
|
||||
<div class="directory-picker-state">{language.t("dialog.directory.readError")}</div>
|
||||
</Show>
|
||||
<div class="directory-picker-folder">
|
||||
<div class="directory-picker-folder-header">
|
||||
<nav class="directory-picker-breadcrumbs" aria-label={language.t("dialog.directory.breadcrumbs")} dir="ltr">
|
||||
<For each={breadcrumbs()}>
|
||||
{(crumb, index) => (
|
||||
<>
|
||||
<Show when={index() > 0}>
|
||||
<Icon name="chevron-right" size="small" class="directory-picker-breadcrumb-separator" />
|
||||
</Show>
|
||||
<button
|
||||
type="button"
|
||||
class="directory-picker-breadcrumb"
|
||||
aria-current={index() === breadcrumbs().length - 1 ? "location" : undefined}
|
||||
onClick={() => navigate(crumb.path)}
|
||||
>
|
||||
{crumb.label}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</For>
|
||||
</nav>
|
||||
</div>
|
||||
<div
|
||||
class="directory-picker-browser"
|
||||
ref={container}
|
||||
// The modal's scroll lock sees only the shadow host, not the tree's inner scroller. Stopping the event here
|
||||
// keeps the lock from cancelling it, and the passive listener leaves the scroller to the compositor.
|
||||
on:touchmove={(event) => event.stopPropagation()}
|
||||
on:wheel={{ handleEvent: (event: WheelEvent) => event.stopPropagation(), passive: true }}
|
||||
>
|
||||
<Show when={treeView().loading}>
|
||||
<div class="directory-picker-state">{language.t("common.loading")}</div>
|
||||
</Show>
|
||||
<Show when={treeView().error}>
|
||||
<div class="directory-picker-state">{language.t("dialog.directory.readError")}</div>
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
</DialogBody>
|
||||
<DialogFooter>
|
||||
<Tooltip
|
||||
placement="top"
|
||||
disabled={!fullSelectionPath() || fullSelectionPath() === shortSelectionPath()}
|
||||
value={<bdi dir="ltr">{fullSelectionPath()}</bdi>}
|
||||
class="directory-picker-selection"
|
||||
>
|
||||
<span dir="ltr" class="directory-picker-selection-text">
|
||||
{shortSelectionPath()}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Button variant="neutral" onClick={() => dialog.close()}>
|
||||
{language.t("common.cancel")}
|
||||
</Button>
|
||||
<Button variant="contrast" disabled={!treeView().result} onClick={resolve}>
|
||||
<Button
|
||||
variant="contrast"
|
||||
disabled={!treeView().result && !comboboxView().input}
|
||||
onClick={() => dispatchCombobox({ type: "submitted" })}
|
||||
>
|
||||
{action[policy.action]}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
listPickerDirectory,
|
||||
displayPickerPath,
|
||||
shortenPickerRecentPath,
|
||||
pickerBreadcrumbs,
|
||||
pickerParent,
|
||||
pickerRoot,
|
||||
pickerAbsoluteInput,
|
||||
@@ -145,6 +146,41 @@ test.each([
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test.each([
|
||||
[
|
||||
"a folder under home",
|
||||
pickerBreadcrumbs("/home/luke/projects/acme", "/home/luke"),
|
||||
[
|
||||
{ label: "/", path: "/" },
|
||||
{ label: "~", path: "/home/luke" },
|
||||
{ label: "projects", path: "/home/luke/projects" },
|
||||
{ label: "acme", path: "/home/luke/projects/acme" },
|
||||
],
|
||||
],
|
||||
[
|
||||
"a folder outside home",
|
||||
pickerBreadcrumbs("/srv/infra/", "/home/luke"),
|
||||
[
|
||||
{ label: "/", path: "/" },
|
||||
{ label: "srv", path: "/srv" },
|
||||
{ label: "infra", path: "/srv/infra" },
|
||||
],
|
||||
],
|
||||
["the root", pickerBreadcrumbs("/", "/home/luke"), [{ label: "/", path: "/" }]],
|
||||
[
|
||||
"a Windows drive",
|
||||
pickerBreadcrumbs("C:/Users/luke/repo", "C:/Users/luke"),
|
||||
[
|
||||
{ label: "C:", path: "C:/" },
|
||||
{ label: "Users", path: "C:/Users" },
|
||||
{ label: "luke", path: "C:/Users/luke" },
|
||||
{ label: "repo", path: "C:/Users/luke/repo" },
|
||||
],
|
||||
],
|
||||
])("breadcrumbs for %s open each ancestor", (_name, actual, expected) => {
|
||||
expect(actual).toEqual(expected)
|
||||
})
|
||||
|
||||
test("resolves directory autocomplete from the browser root without changing location", async () => {
|
||||
const calls: unknown[] = []
|
||||
const location = { directory: "/repo", workspace: "workspace_1" }
|
||||
|
||||
@@ -401,6 +401,24 @@ export function shortenPickerRecentPath(path: string, home: string) {
|
||||
return display
|
||||
}
|
||||
|
||||
// The folders from the root down to `path`, with home shown as `~`.
|
||||
export function pickerBreadcrumbs(path: string, home: string) {
|
||||
const value = trimPickerPath(path)
|
||||
const root = pickerRoot(value)
|
||||
|
||||
if (!root) return []
|
||||
const tilde = pickerTilde(value, home)
|
||||
const base = tilde ? trimPickerPath(home) : root
|
||||
const names = value.slice(base.length).split("/").filter(Boolean)
|
||||
const first = [{ label: root === "/" ? "/" : trimPickerPath(root).replace(/\/$/, ""), path: root }]
|
||||
|
||||
return [
|
||||
...first,
|
||||
...(tilde && base !== root ? [{ label: "~", path: base }] : []),
|
||||
...names.map((label, index) => ({ label, path: joinPickerPath(base, names.slice(0, index + 1).join("/")) })),
|
||||
]
|
||||
}
|
||||
|
||||
export async function listPickerDirectory(
|
||||
sdk: ServerSDK,
|
||||
location: { directory: string; workspace?: string },
|
||||
|
||||
@@ -93,7 +93,7 @@ test("a newer choice wins over a reveal still waiting on its ancestors", () => {
|
||||
for (const newer of [
|
||||
choose(`${HOME}/fast-repo`),
|
||||
{ type: "tree.selected", path: "fast-repo/" } as const,
|
||||
{ type: "selection.cleared" } as const,
|
||||
{ type: "tree.selected", path: undefined } as const,
|
||||
]) {
|
||||
const chosen = run([newer], revealing.state)
|
||||
const settled = run([{ type: "dir.loaded", dir: "work", attempt: 2, nodes: [folder("slow")] }], chosen.state)
|
||||
@@ -254,3 +254,40 @@ test("disposing drops queued work and ignores later results", () => {
|
||||
expect(disposed.effects).toEqual([{ type: "queue.reset" }])
|
||||
expect(run([{ type: "dir.loaded", dir: "", attempt: 1, nodes: [] }], disposed.state).state).toBe(disposed.state)
|
||||
})
|
||||
|
||||
test("a confirmed choice submits once it is selected, and never when it fails or a newer choice wins", () => {
|
||||
const state = ready(HOME, [folder("work")])
|
||||
|
||||
const submit = (path: string): PickerTreeEvent => ({
|
||||
type: "directory.chosen",
|
||||
path,
|
||||
home: HOME,
|
||||
fallback: HOME,
|
||||
located: true,
|
||||
fromInput: true,
|
||||
submit: true,
|
||||
})
|
||||
|
||||
const inside = run([submit(`${HOME}/work/repo`)], state)
|
||||
const listed = run([{ type: "dir.loaded", dir: "work", attempt: 2, nodes: [folder("repo")] }], inside.state)
|
||||
const outside = run([submit("/srv/infra")], state)
|
||||
const root = outside.state.status === "loading" ? outside.state.attempt : -1
|
||||
const opened = run([{ type: "dir.loaded", dir: "", attempt: root, nodes: [] }], outside.state)
|
||||
const failed = run([{ type: "dir.failed", dir: "", attempt: root }], outside.state)
|
||||
|
||||
const superseded = run(
|
||||
[
|
||||
{ type: "tree.selected", path: undefined },
|
||||
{ type: "dir.loaded", dir: "work", attempt: 2, nodes: [folder("repo")] },
|
||||
],
|
||||
inside.state,
|
||||
)
|
||||
|
||||
expect(inside.effects).not.toContainEqual({ type: "submit" })
|
||||
expect(listed.effects).toContainEqual({ type: "submit" })
|
||||
expect(pickerTreeView(listed.state, policy).result).toBe(`${HOME}/work/repo`)
|
||||
expect(opened.effects.at(-1)).toEqual({ type: "submit" })
|
||||
expect(pickerTreeView(opened.state, policy).result).toBe("/srv/infra")
|
||||
expect(failed.effects).not.toContainEqual({ type: "submit" })
|
||||
expect(superseded.effects).not.toContainEqual({ type: "submit" })
|
||||
})
|
||||
|
||||
@@ -18,16 +18,20 @@ export type PickerDirState =
|
||||
| { readonly status: "ready" }
|
||||
| { readonly status: "failed" }
|
||||
|
||||
/** A chosen folder inside the root. Its ancestors list and expand in order from `index`, then it is selected. */
|
||||
/**
|
||||
* A chosen folder inside the root. Its ancestors list and expand in order from `index`, then it is selected, and
|
||||
* `submit` confirms it once selected.
|
||||
*/
|
||||
export type PickerReveal = {
|
||||
readonly target: string
|
||||
readonly relative: string
|
||||
readonly index: number
|
||||
readonly fromInput: boolean
|
||||
readonly submit: boolean
|
||||
}
|
||||
|
||||
/** The root to open, and the child of it to select once it lists. */
|
||||
export type PickerTarget = { readonly root: string; readonly selectChild?: string }
|
||||
/** The root to open, the child of it to select once it lists, and whether to confirm it then. */
|
||||
export type PickerTarget = { readonly root: string; readonly selectChild?: string; readonly submit?: boolean }
|
||||
|
||||
/**
|
||||
* The folder browser. `issued` numbers every location and listing request, so a result for an earlier root, reveal or
|
||||
@@ -49,6 +53,7 @@ export type PickerTreeState =
|
||||
readonly attempt: number
|
||||
readonly root: string
|
||||
readonly selectChild?: string
|
||||
readonly submit?: boolean
|
||||
readonly locationDirectory?: string
|
||||
}
|
||||
| {
|
||||
@@ -79,9 +84,8 @@ export type PickerTreeEvent =
|
||||
| { readonly type: "location.failed"; readonly attempt: number }
|
||||
| { readonly type: "location.timed-out"; readonly attempt: number }
|
||||
| ({ readonly type: "navigate" } & PickerNavigation)
|
||||
| ({ readonly type: "directory.chosen"; readonly fromInput: boolean } & PickerNavigation)
|
||||
| ({ readonly type: "directory.chosen"; readonly fromInput: boolean; readonly submit?: boolean } & PickerNavigation)
|
||||
| { readonly type: "file.chosen"; readonly absolute: string; readonly home: string }
|
||||
| { readonly type: "selection.cleared" }
|
||||
| { readonly type: "tree.selected"; readonly path: string | undefined }
|
||||
| { readonly type: "dir.expanded"; readonly dir: string }
|
||||
| {
|
||||
@@ -113,6 +117,7 @@ export type PickerTreeEffect =
|
||||
| { readonly type: "tree.clear-selection" }
|
||||
| { readonly type: "tree.focus-initial" }
|
||||
| { readonly type: "tree.refresh-decorations" }
|
||||
| { readonly type: "submit" }
|
||||
|
||||
export type PickerTreeTransition = { readonly state: PickerTreeState; readonly effects: readonly PickerTreeEffect[] }
|
||||
|
||||
@@ -172,8 +177,6 @@ export function transitionPickerTree(
|
||||
return select(state, event.path ? (policy.selection(state.root, event.path) ?? "") : "")
|
||||
}
|
||||
|
||||
if (event.type === "selection.cleared") return select(state, "")
|
||||
|
||||
return select(
|
||||
state,
|
||||
policy.selection(state.root, pickerFileSearchQuery(state.root, event.absolute, event.home)) ?? "",
|
||||
@@ -225,12 +228,18 @@ function choose(
|
||||
const relative = pickerRelativePath(state.root, value)
|
||||
|
||||
if (relative === "") {
|
||||
return { state: { ...state, selected: "", reveal: undefined }, effects: [{ type: "tree.clear-selection" }] }
|
||||
return {
|
||||
state: { ...state, selected: "", reveal: undefined },
|
||||
effects: [{ type: "tree.clear-selection" }, ...submitted(event.submit)],
|
||||
}
|
||||
}
|
||||
|
||||
if (relative) {
|
||||
return advanceReveal(
|
||||
{ ...state, reveal: { target: value, relative, index: 0, fromInput: event.fromInput } },
|
||||
{
|
||||
...state,
|
||||
reveal: { target: value, relative, index: 0, fromInput: event.fromInput, submit: event.submit ?? false },
|
||||
},
|
||||
[],
|
||||
policy,
|
||||
)
|
||||
@@ -240,10 +249,10 @@ function choose(
|
||||
const parent = pickerParent(value)
|
||||
|
||||
if (parent && getFilename(value) && parent !== value && parent === event.home) {
|
||||
return open(state, { root: parent, selectChild: value }, event.located)
|
||||
return open(state, { root: parent, selectChild: value, submit: event.submit }, event.located)
|
||||
}
|
||||
|
||||
return open(state, { root: value }, event.located)
|
||||
return open(state, { root: value, submit: event.submit }, event.located)
|
||||
}
|
||||
|
||||
// A new root drops every listing, queued preload and reveal of the previous one.
|
||||
@@ -268,6 +277,7 @@ function open(state: LiveTree, next: PickerTarget, located: boolean): PickerTree
|
||||
attempt,
|
||||
root: next.root,
|
||||
selectChild: next.selectChild,
|
||||
submit: next.submit,
|
||||
locationDirectory: state.locationDirectory,
|
||||
},
|
||||
effects: [{ type: "queue.reset" }, { type: "tree.reset" }, list(next.root, "", attempt, "user")],
|
||||
@@ -358,6 +368,7 @@ function openRoot(
|
||||
...listed.effects,
|
||||
entry ? { type: "tree.select", entry } : { type: "tree.focus-initial" },
|
||||
...children.map((name, index) => list(state.root, name, state.issued + index + 1, "background")),
|
||||
...submitted(state.submit),
|
||||
],
|
||||
}
|
||||
}
|
||||
@@ -420,9 +431,12 @@ function finishReveal(
|
||||
): PickerTreeTransition {
|
||||
const entry = `${reveal.relative}/`
|
||||
|
||||
if (!state.entries[entry]) return open({ ...state, reveal: undefined }, { root: reveal.target }, true)
|
||||
if (!state.entries[entry]) {
|
||||
return open({ ...state, reveal: undefined }, { root: reveal.target, submit: reveal.submit }, true)
|
||||
}
|
||||
|
||||
const selected = { ...state, reveal: undefined, selected: policy.selection(state.root, entry) ?? "" }
|
||||
const selecting = [...effects, { type: "tree.select" as const, entry }]
|
||||
const selecting = [...effects, { type: "tree.select" as const, entry }, ...submitted(reveal.submit)]
|
||||
|
||||
if (!reveal.fromInput) return { state: selected, effects: selecting }
|
||||
|
||||
@@ -483,6 +497,10 @@ function list(root: string, dir: string, attempt: number, priority: "user" | "ba
|
||||
return { type: "list", root, dir, attempt, priority, timeoutMs: PICKER_LOAD_TIMEOUT_MS }
|
||||
}
|
||||
|
||||
function submitted(submit: boolean | undefined): PickerTreeEffect[] {
|
||||
return submit ? [{ type: "submit" }] : []
|
||||
}
|
||||
|
||||
function unchanged(state: PickerTreeState): PickerTreeTransition {
|
||||
return { state, effects: [] }
|
||||
}
|
||||
|
||||
@@ -83,7 +83,9 @@
|
||||
linear-gradient(90deg, var(--v2-background-bg-button-neutral) 0%, var(--v2-background-bg-button-neutral) 100%);
|
||||
}
|
||||
|
||||
[data-component="button-v2"][data-variant="neutral"]:is(:active, [data-state="pressed"]):not(:disabled) {
|
||||
[data-component="button-v2"][data-variant="neutral"]:is(:active, [data-state="pressed"], [data-expanded]):not(
|
||||
:disabled
|
||||
) {
|
||||
background-image:
|
||||
linear-gradient(
|
||||
90deg,
|
||||
|
||||
Reference in New Issue
Block a user