From 844c2f3145768ad03e83088eb57844e4c6f32141 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 05:18:24 +0800 Subject: [PATCH 01/32] test(maven): wait for the background refresh of jdtls import roots (#5272) external_maven_link_persists_reloads_and_unlink_keeps_files failed on the macOS runner: setting languages.java.maven.linkedProjects refreshes the language server's import roots on a blocking task, and the test read them right after build_model returned. It now waits up to 5 s for them to change. --- crates/ide-host/tests/maven_external.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/ide-host/tests/maven_external.rs b/crates/ide-host/tests/maven_external.rs index ca28bdc46..a74dc7319 100644 --- a/crates/ide-host/tests/maven_external.rs +++ b/crates/ide-host/tests/maven_external.rs @@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() { assert_eq!(b.pom, canonical); assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling); assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]); - assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]); + assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]); let reloaded = ops::build::build_model(&host, "main").await.unwrap(); assert_eq!( @@ -63,13 +63,26 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() { let gone = ops::build::build_model(&host, "main").await.unwrap(); assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b")); assert!(host.project("main").unwrap().content_roots().is_empty()); - assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty()); + assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty()); assert_eq!(saved(), Vec::::new()); assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom); assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom); host.shutdown().await; } +/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in +/// the background. +async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec { + for _ in 0..200 { + let roots = host.project("main").unwrap().lsp.jdtls_import_roots(); + if ready(&roots) { + return roots; + } + tokio::time::sleep(std::time::Duration::from_millis(25)).await; + } + host.project("main").unwrap().lsp.jdtls_import_roots() +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() { let temp = tempfile::tempdir().unwrap(); From 5d6c76cdda832af2e6bd8d6aa76178876b99cc1d Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 09:11:47 +0800 Subject: [PATCH 02/32] fix(keymap): make shortcut recording and conflicts easier to read (#5220) The shortcut recorder puts the action name and its category in the dialog body and uses a full-width first field. The optional second stroke stays beside its checkbox. Conflicting actions use two-line rows that keep the action name, category and binding readable in a narrow window. --- e2e/shortcutRecorderLayout.spec.ts | 44 ++++++++++ .../settings/keymap/Keymap.module.css | 80 ++++++++++++------ .../settings/keymap/RecordShortcutDialog.tsx | 81 +++++++++++-------- src/platform/locales/text/en.json | 2 + src/platform/locales/text/es.json | 3 +- src/platform/locales/text/fr.json | 3 +- src/platform/locales/text/ko.json | 3 +- src/platform/locales/text/pl.json | 3 +- src/platform/locales/text/pt.json | 3 +- src/platform/locales/text/tr.json | 3 +- src/platform/locales/text/zh-TW.json | 3 +- src/platform/locales/text/zh.json | 3 +- 12 files changed, 164 insertions(+), 67 deletions(-) create mode 100644 e2e/shortcutRecorderLayout.spec.ts diff --git a/e2e/shortcutRecorderLayout.spec.ts b/e2e/shortcutRecorderLayout.spec.ts new file mode 100644 index 000000000..aaaffafd8 --- /dev/null +++ b/e2e/shortcutRecorderLayout.spec.ts @@ -0,0 +1,44 @@ +import { expect, test } from "./fixtures"; + +test("shortcut assignment fits the first stroke and conflict names in a narrow window", async ({ workbench: page }) => { + await page.setViewportSize({ width: 336, height: 540 }); + await page.keyboard.press("Meta+,"); + const settings = page.getByRole("dialog", { name: "Settings", exact: true }); + await settings.getByRole("treeitem", { name: "Keymap", exact: true }).click(); + await settings.getByRole("textbox", { name: "Search actions" }).fill("Find Action"); + const action = settings.getByRole("treeitem", { name: /Find Action/ }); + await action.click(); + await settings.getByRole("button", { name: "Add Keyboard Shortcut", exact: true }).click(); + + const dialog = page.getByRole("dialog", { name: "Keyboard Shortcut: Find Action…", exact: true }); + const first = dialog.getByRole("textbox", { name: "First stroke" }); + const body = dialog.locator("[data-dialog-body]"); + const titleBar = dialog.locator("[data-dialog-titlebar]"); + await expect(first).toBeFocused(); + await expect(titleBar).toHaveText("Keyboard Shortcut"); + await expect(body.getByText("Find Action…", { exact: true })).toBeVisible(); + const firstBounds = (await first.boundingBox())!; + const bodyBounds = (await body.boundingBox())!; + expect(firstBounds.width).toBeGreaterThan(bodyBounds.width - 32); + const conflicts = dialog.getByRole("list", { name: "Conflicts:" }); + await expect(conflicts).toHaveCount(0); + + await first.press("Meta+Alt+L"); + await expect(conflicts).toBeVisible(); + await expect(conflicts.getByRole("listitem").filter({ hasText: "Reformat Code" }).first()).toBeVisible(); + expect(await conflicts.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + expect( + await conflicts + .getByRole("listitem") + .evaluateAll((rows) => rows.every((row) => row.scrollHeight <= row.clientHeight)), + ).toBe(true); + expect(await body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + + const ok = dialog.getByRole("button", { name: "OK", exact: true }); + await ok.click(); + const confirmation = page.getByRole("dialog", { name: "Warning", exact: true }); + await expect(confirmation.getByRole("list").getByText("Reformat Code", { exact: true })).toHaveCount(2); + await confirmation.getByRole("button", { name: "Leave", exact: true }).click(); + await expect(dialog).toBeHidden(); + await expect(action.locator("kbd").filter({ hasText: "⌥⌘L" })).toHaveCount(1); +}); diff --git a/src/features/settings/keymap/Keymap.module.css b/src/features/settings/keymap/Keymap.module.css index 35621de48..b6c53156d 100644 --- a/src/features/settings/keymap/Keymap.module.css +++ b/src/features/settings/keymap/Keymap.module.css @@ -30,9 +30,6 @@ .presetSelect { flex: 1; } -.spacer { - flex: 1; -} .modifiedNote { color: var(--fg-subtle); font-size: var(--fs-small); @@ -195,53 +192,88 @@ .recordLabel { color: var(--fg); } +.shortcutBody { + display: flex; + flex-direction: column; + gap: var(--space-2); + padding: var(--space-2) var(--space-3) 0; + font-size: var(--fs-ui); + overflow-wrap: anywhere; +} +.actionSummary { + display: grid; + gap: var(--space-0-5); +} +.actionName { + color: var(--fg-strong); + font-weight: 600; +} +.shortcutField { + flex: 0 0 auto; + background: var(--bg-field); +} +.shortcutField > span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.secondStroke { + display: flex; + align-items: center; + gap: var(--space-2); +} +.secondStroke > label { + max-width: 55%; +} +.secondStroke .shortcutField { + flex: 1; +} .recordHint { color: var(--fg-subtle); font-size: var(--fs-small); } -.conflicts { - min-height: 72px; - padding: 6px 8px; - border-radius: var(--radius-small); - box-shadow: inset 0 0 0 1px var(--border); -} -.noConflicts { - color: var(--fg-subtle); +.shortcutStatus { + display: grid; + gap: var(--space-1); } .conflictTitle { display: flex; align-items: center; gap: var(--space-1-5); color: var(--fg-emphasis); + font-weight: 600; } .conflictIcon { + flex: none; color: var(--warning); + --icon-color: currentColor; } .conflictList { list-style: none; - margin: 6px 0 0; - padding: 0 0 0 20px; - max-height: 120px; - overflow: auto; + margin: 0; + padding: 0; + max-height: 132px; + overflow-y: auto; } .conflictList li { - display: flex; - min-width: 0; - align-items: center; + display: grid; + grid-template-columns: minmax(0, 1fr) fit-content(42%); + align-items: start; gap: var(--space-2); - height: var(--h-row); + padding-block: var(--space-1); } .conflictAction { color: var(--fg); + overflow-wrap: anywhere; } -.conflictCategory { +.actionPath { color: var(--fg-subtle); font-size: var(--fs-small); } - -.conflictsLabel { - color: var(--fg); - padding-top: 4px; +.conflictBinding { + text-align: end; + white-space: normal; + overflow-wrap: anywhere; } .nameError { color: var(--danger); diff --git a/src/features/settings/keymap/RecordShortcutDialog.tsx b/src/features/settings/keymap/RecordShortcutDialog.tsx index c9a1b4dc8..7f715b5dd 100644 --- a/src/features/settings/keymap/RecordShortcutDialog.tsx +++ b/src/features/settings/keymap/RecordShortcutDialog.tsx @@ -20,7 +20,7 @@ import { findConflicts, resolveBindings, type Conflict, type KeymapDraft } from import { groupPath } from "./groups"; import { StrokeRecorder } from "./StrokeRecorder"; import styles from "./Keymap.module.css"; -import { tx } from "@/platform/i18n"; +import { useTx } from "@/platform/i18n"; import { usePlatform } from "@/platform/platformInfo"; export interface RecordShortcutDialogProps { @@ -39,6 +39,8 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi const [second, setSecond] = useState(""); const [useSecond, setUseSecond] = useState(false); const os = usePlatform((s) => s.os); + const tx = useTx(); + const actionName = tx(action.title); const rectangularSelection = action.id === "editor.createRectangularSelectionOnMouseDrag"; const allowsSecond = !isPageSwipe(first) && !parseDoubleModifier(first); @@ -76,14 +78,23 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi void ok() }, { label: "Cancel", role: "cancel" }, ]} > -
+
+
+
{actionName}
+
+ {groupPath(action) + .map((part) => tx(part)) + .join(" › ")} +
+
{mouse ? ( ) : ( @@ -102,31 +113,23 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi On Linux, middle-button rectangular selection conflicts with primary selection paste.
)} -
- Conflicts: -
-
+
{already && ( - + The action already has this shortcut )} {!already && binding && conflicts.length === 0 && ( - + No conflicts )} - {!binding && ( - - Press a shortcut - - )} {conflicts.length > 0 && ( <>
- is already assigned to: + is already assigned to:
@@ -139,21 +142,26 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi } function ConflictList({ conflicts }: { conflicts: readonly Conflict[] }) { + const tx = useTx(); return ( -
    +
      {conflicts.map((c) => (
    • - {c.title} - - ({groupPath({ id: c.actionId, category: c.category }).join(" | ")}) - - - {c.kind === "prefix" && ( - - chord prefix +
      +
      {tx(c.title)}
      + + {groupPath({ id: c.actionId, category: c.category }) + .map((part) => tx(part)) + .join(" › ")} + {c.kind === "prefix" && ( + <> + {" "} + · chord prefix + + )} - )} - +
      +
    • ))}
    @@ -171,23 +179,26 @@ interface KeyStrokesProps { } function KeyStrokes({ first, second, useSecond, allowsSecond, setFirst, setSecond, setUseSecond }: KeyStrokesProps) { + const tx = useTx(); return ( <> -
    - - First stroke: - - -
    -
    + +
    diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index f2e25dd94..ca44332ec 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -2497,6 +2497,8 @@ "e.g. /api/": "e.g. /api/", "Part of a request URL": "Part of a request URL", "Mouse": "Mouse", + "Keyboard Shortcut": "Keyboard Shortcut", + "Mouse Shortcut": "Mouse Shortcut", "Keyboard": "Keyboard", "Form": "Form", "Page": "Page", diff --git a/src/platform/locales/text/es.json b/src/platform/locales/text/es.json index 5ba16adb8..20dfec059 100644 --- a/src/platform/locales/text/es.json +++ b/src/platform/locales/text/es.json @@ -890,7 +890,6 @@ "Find…": "Buscar…", "First letter only": "Solo la primera letra", "First stroke": "Primera combinación de teclas", - "First stroke:": "Primera combinación de teclas:", "Fix the highlighted fields": "Corrige los campos resaltados", "Flame Graph": "Gráfico de llamas", "Flame graph": "Gráfico de llamas", @@ -4088,6 +4087,7 @@ "based on {parent}": "basado en {parent}", "Delete keymap '{name}'?": "¿Eliminar el mapa de teclado '{name}'?", "Remove {shortcut}": "Quitar {shortcut}", + "Keyboard Shortcut": "Atajo de teclado", "Keyboard Shortcut: {action}": "Atajo de teclado: {action}", "Remove content root {path}": "Quitar raíz de contenido {path}", "Unmark {folder}": "Desmarcar {folder}", @@ -4827,6 +4827,7 @@ "Add Mouse Shortcut": "Agregar atajo de ratón", "Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Haga clic aquí manteniendo presionado Ctrl, Alt o Command, o use el botón central o un botón lateral del ratón", "Mouse shortcut": "Atajo de ratón", + "Mouse Shortcut": "Atajo de ratón", "Mouse Shortcut: {action}": "Atajo de ratón: {action}", "Accept Left Side": "Aceptar lado izquierdo", "Accept Right Side": "Aceptar lado derecho", diff --git a/src/platform/locales/text/fr.json b/src/platform/locales/text/fr.json index 983a4baa0..3aef6b3eb 100644 --- a/src/platform/locales/text/fr.json +++ b/src/platform/locales/text/fr.json @@ -827,7 +827,6 @@ "Find…": "Rechercher…", "First letter only": "Première lettre uniquement", "First stroke": "Première touche", - "First stroke:": "Première touche :", "Fix the highlighted fields": "Corrigez les champs mis en évidence", "Flame Graph": "Flame graph", "Flame graph": "Flame graph", @@ -3952,6 +3951,7 @@ "based on {parent}": "basé sur {parent}", "Delete keymap '{name}'?": "Supprimer les raccourcis clavier '{name}' ?", "Remove {shortcut}": "Retirer {shortcut}", + "Keyboard Shortcut": "Raccourci clavier", "Keyboard Shortcut: {action}": "Raccourci clavier : {action}", "Remove content root {path}": "Retirer la racine de contenu {path}", "Unmark {folder}": "Démarquer {folder}", @@ -4682,6 +4682,7 @@ "Add Mouse Shortcut": "Ajouter un raccourci souris", "Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Cliquez ici en maintenant Ctrl, Alt ou Commande, ou utilisez le bouton central ou un bouton latéral de la souris", "Mouse shortcut": "Raccourci souris", + "Mouse Shortcut": "Raccourci souris", "Mouse Shortcut: {action}": "Raccourci souris : {action}", "Accept Left Side": "Accepter le côté gauche", "Accept Right Side": "Accepter le côté droit", diff --git a/src/platform/locales/text/ko.json b/src/platform/locales/text/ko.json index 3a3b0757c..1be07f421 100644 --- a/src/platform/locales/text/ko.json +++ b/src/platform/locales/text/ko.json @@ -926,7 +926,6 @@ "Find…": "찾기…", "First letter only": "첫 글자만", "First stroke": "첫 번째 키 입력", - "First stroke:": "첫 번째 키 입력:", "Fix the highlighted fields": "강조 표시된 필드를 수정하세요", "Flame Graph": "플레임 그래프", "Flame graph": "플레임 그래프", @@ -4149,6 +4148,7 @@ "based on {parent}": "{parent} 기반", "Delete keymap '{name}'?": "키맵 '{name}'을(를) 삭제하시겠습니까?", "Remove {shortcut}": "{shortcut} 제거", + "Keyboard Shortcut": "키보드 단축키", "Keyboard Shortcut: {action}": "키보드 단축키: {action}", "Remove content root {path}": "콘텐츠 루트 {path} 제거", "Unmark {folder}": "{folder} 표시 해제", @@ -4899,6 +4899,7 @@ "Add Mouse Shortcut": "마우스 단축키 추가", "Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Ctrl, Alt 또는 Command를 누른 채 여기를 클릭하거나 마우스 가운데 버튼 또는 측면 버튼을 사용하세요", "Mouse shortcut": "마우스 단축키", + "Mouse Shortcut": "마우스 단축키", "Mouse Shortcut: {action}": "마우스 단축키: {action}", "Accept Left Side": "왼쪽 수락", "Accept Right Side": "오른쪽 수락", diff --git a/src/platform/locales/text/pl.json b/src/platform/locales/text/pl.json index 941bd223e..2d2970712 100644 --- a/src/platform/locales/text/pl.json +++ b/src/platform/locales/text/pl.json @@ -882,7 +882,6 @@ "Find…": "Znajdź…", "First letter only": "Tylko pierwsza litera", "First stroke": "Naciśnięcie pierwsze", - "First stroke:": "Naciśnięcie pierwsze:", "Fix the highlighted fields": "Popraw podświetlone pola", "Flame Graph": "Wykres płomieniowy (Flame Graph)", "Flame graph": "Wykres płomieniowy", @@ -4044,6 +4043,7 @@ "based on {parent}": "na podstawie {parent}", "Delete keymap '{name}'?": "Usunąć mapę klawiszy '{name}'?", "Remove {shortcut}": "Usuń {shortcut}", + "Keyboard Shortcut": "Skrót klawiszowy", "Keyboard Shortcut: {action}": "Skrót klawiszowy: {action}", "Remove content root {path}": "Usuń katalog główny zawartości {path}", "Unmark {folder}": "Odznacz {folder}", @@ -4778,6 +4778,7 @@ "Add Mouse Shortcut": "Dodaj skrót myszy", "Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Kliknij tutaj przytrzymując Ctrl, Alt lub Command albo użyj środkowego lub bocznego przycisku myszy", "Mouse shortcut": "Skrót myszy", + "Mouse Shortcut": "Skrót myszy", "Mouse Shortcut: {action}": "Skrót myszy: {action}", "Accept Left Side": "Zaakceptuj lewą stronę", "Accept Right Side": "Zaakceptuj prawą stronę", diff --git a/src/platform/locales/text/pt.json b/src/platform/locales/text/pt.json index 46ffc452a..0a2c73b76 100644 --- a/src/platform/locales/text/pt.json +++ b/src/platform/locales/text/pt.json @@ -882,7 +882,6 @@ "Find…": "Localizar…", "First letter only": "Apenas primeira letra", "First stroke": "Primeiro toque", - "First stroke:": "Primeiro toque:", "Fix the highlighted fields": "Corrija os campos destacados", "Flame Graph": "Flame Graph", "Flame graph": "Flame graph", @@ -4054,6 +4053,7 @@ "based on {parent}": "com base em {parent}", "Delete keymap '{name}'?": "Excluir o mapa de teclas '{name}'?", "Remove {shortcut}": "Remover {shortcut}", + "Keyboard Shortcut": "Atalho do teclado", "Keyboard Shortcut: {action}": "Atalho do teclado: {action}", "Remove content root {path}": "Remover raiz de conteúdo {path}", "Unmark {folder}": "Desmarcar {folder}", @@ -4793,6 +4793,7 @@ "Add Mouse Shortcut": "Adicionar atalho de mouse", "Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Clique aqui mantendo Ctrl, Alt ou Command pressionado, ou use o botão do meio ou um botão lateral do mouse", "Mouse shortcut": "Atalho de mouse", + "Mouse Shortcut": "Atalho de mouse", "Mouse Shortcut: {action}": "Atalho de mouse: {action}", "Accept Left Side": "Aceitar lado esquerdo", "Accept Right Side": "Aceitar lado direito", diff --git a/src/platform/locales/text/tr.json b/src/platform/locales/text/tr.json index eb1a168d6..9d2bf18d7 100644 --- a/src/platform/locales/text/tr.json +++ b/src/platform/locales/text/tr.json @@ -3676,7 +3676,6 @@ "Find…": "Bul…", "First letter only": "Yalnızca ilk harf", "First stroke": "İlk tuş birleşimi", - "First stroke:": "İlk tuş birleşimi:", "Fix the highlighted fields": "Vurgulanan alanları düzeltin", "Flame Graph": "Alev Grafiği", "Flame graph": "Alev grafiği", @@ -6777,6 +6776,7 @@ "based on {parent}": "{parent} temel alınarak", "Delete keymap '{name}'?": "'{name}' tuş eşlemi silinsin mi?", "Remove {shortcut}": "{shortcut} kaldır", + "Keyboard Shortcut": "Klavye Kısayolu", "Keyboard Shortcut: {action}": "Klavye Kısayolu: {action}", "Remove content root {path}": "{path} içerik kökünü kaldır", "Unmark {folder}": "{folder} işaretini kaldır", @@ -7501,6 +7501,7 @@ "Sort by Modification Time": "Değiştirilme Zamanına Göre Sırala", "Add Mouse Shortcut": "Fare Kısayolu Ekle", "Mouse shortcut": "Fare kısayolu", + "Mouse Shortcut": "Fare Kısayolu", "Mouse Shortcut: {action}": "Fare Kısayolu: {action}", "Accept Left Side": "Sol Tarafı Kabul Et", "Accept Right Side": "Sağ Tarafı Kabul Et", diff --git a/src/platform/locales/text/zh-TW.json b/src/platform/locales/text/zh-TW.json index 9dbf13753..af0376ef5 100644 --- a/src/platform/locales/text/zh-TW.json +++ b/src/platform/locales/text/zh-TW.json @@ -1550,7 +1550,6 @@ "Find…": "查詢…", "First letter only": "僅首字母", "First stroke": "第一次擊鍵", - "First stroke:": "第一次擊鍵:", "Fix the highlighted fields": "請修復醒目提示的欄位", "Flame Graph": "火焰圖", "Flame graph": "火焰圖", @@ -5033,6 +5032,7 @@ "based on {parent}": "基於 {parent}", "Delete keymap '{name}'?": "是否刪除按鍵對映 '{name}'?", "Remove {shortcut}": "移除 {shortcut}", + "Keyboard Shortcut": "鍵盤快速鍵", "Keyboard Shortcut: {action}": "鍵盤快速鍵:{action}", "Remove content root {path}": "移除內容根 {path}", "Unmark {folder}": "取消標記 {folder}", @@ -5812,6 +5812,7 @@ "Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "按住 Ctrl、Alt 或 Command 在此點選,或使用滑鼠中鍵或側鍵", "Click here with Ctrl, Alt or Command held, or use the middle mouse button": "按住 Ctrl、Alt 或 Command 在此點選,或使用滑鼠中鍵", "Mouse shortcut": "滑鼠快速鍵", + "Mouse Shortcut": "滑鼠快速鍵", "Mouse Shortcut: {action}": "滑鼠快速鍵:{action}", "Accept Left Side": "接受左側", "Accept Right Side": "接受右側", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 0d2dbf6da..803d01ed9 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -1917,7 +1917,6 @@ "Find…": "查找…", "First letter only": "仅首字母", "First stroke": "第一次击键", - "First stroke:": "第一次击键:", "Fix the highlighted fields": "请修复高亮显示的字段", "Flame Graph": "火焰图", "Flame graph": "火焰图", @@ -5483,6 +5482,8 @@ "based on {parent}": "基于 {parent}", "Delete keymap '{name}'?": "是否删除按键映射 '{name}'?", "Remove {shortcut}": "移除 {shortcut}", + "Keyboard Shortcut": "键盘快捷键", + "Mouse Shortcut": "鼠标快捷键", "Keyboard Shortcut: {action}": "键盘快捷键:{action}", "Remove content root {path}": "移除内容根 {path}", "Unmark {folder}": "取消标记 {folder}", From 29fcec6ab8112bee1075b3fc2bba20b875645b46 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 09:11:56 +0800 Subject: [PATCH 03/32] fix(debugger): keep gutter breakpoint controls in view (#5221) The gutter breakpoint popup puts the file and line in a fixed header and keeps the action buttons visible while the fields scroll. The popup gives the condition and hit-count fields more room. Long filenames shorten in the header while the line number stays visible. The same popup layout covers method breakpoints and field watchpoints. --- e2e/breakpointPopoverLayout.spec.ts | 52 +++++ src/features/debugger/ui/Overlays.module.css | 69 ++++-- src/features/debugger/ui/Overlays.tsx | 213 ++++++++++--------- 3 files changed, 221 insertions(+), 113 deletions(-) create mode 100644 e2e/breakpointPopoverLayout.spec.ts diff --git a/e2e/breakpointPopoverLayout.spec.ts b/e2e/breakpointPopoverLayout.spec.ts new file mode 100644 index 000000000..f272cc252 --- /dev/null +++ b/e2e/breakpointPopoverLayout.spec.ts @@ -0,0 +1,52 @@ +import type { EditorView } from "@codemirror/view"; +import { expect, stubDesktop, test } from "./fixtures"; + +test("gutter breakpoint keeps its location and buttons visible while editing in a short window", async ({ + workbench: page, +}) => { + await page.setViewportSize({ width: 410, height: 340 }); + await stubDesktop(page); + const name = "RecalculateInternationalPaymentsAcrossMultipleRegionalSettlementCyclesAndVerifyReceiptTotals.ts"; + const path = `/dev/acme-api/${name}`; + await page.evaluate(async (path) => { + const contributionsModule = "/src/workbench/contributions.ts"; + const { editorService } = await import(/* @vite-ignore */ contributionsModule); + await editorService().openFile(path); + }, path); + await page.locator(".cm-content").evaluate(async (editor, path) => { + const view = (editor as HTMLElement & { cmTile: { view: EditorView } }).cmTile.view; + const insert = Array.from({ length: 14 }, (_, i) => `const amount${i + 1} = ${i * 10};`).join("\n"); + view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert } }); + const breakpointsModule = "/src/features/debugger/breakpoints/store.ts"; + const { addBreakpoint } = await import(/* @vite-ignore */ breakpointsModule); + window.__ipc.handlers.debug_set_breakpoints = () => []; + addBreakpoint(path, 7, { condition: "amount8 > 50", hitCondition: ">= 3", logMessage: "amount: {amount8}" }); + }, path); + const marker = page.locator(".cm-lineNumbers .cm-gutterElement").filter({ hasText: /^8$/ }); + const open = () => marker.click({ button: "right" }); + await open(); + + const popup = page.getByRole("dialog", { name: "Breakpoint properties" }); + const done = popup.getByRole("button", { name: "Done", exact: true }); + const condition = popup.getByLabel("Condition", { exact: true }); + await expect(condition).toBeFocused(); + await expect(done).toBeInViewport({ ratio: 1 }); + const location = popup.getByTitle(`${path}:8`, { exact: true }); + await expect(location.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 }); + await expect(popup.getByText("Condition", { exact: true })).toHaveCSS("font-size", "13px"); + + await condition.fill("amount8 > 60"); + const log = popup.getByRole("textbox", { name: "Evaluate and log", exact: true }); + await log.fill("paid: {amount8}"); + await expect(location).toBeInViewport({ ratio: 1 }); + await expect(done).toBeInViewport({ ratio: 1 }); + await done.click(); + await expect(popup).toBeHidden(); + + await open(); + await expect(condition).toHaveValue("amount8 > 60"); + await expect(log).toHaveValue("paid: {amount8}"); + await popup.getByRole("button", { name: /^More/ }).click(); + const dialog = page.getByRole("dialog", { name: "Breakpoints", exact: true }); + await expect(dialog.getByLabel("Condition", { exact: true })).toHaveValue("amount8 > 60"); +}); diff --git a/src/features/debugger/ui/Overlays.module.css b/src/features/debugger/ui/Overlays.module.css index b288a515a..0b9f7b8c4 100644 --- a/src/features/debugger/ui/Overlays.module.css +++ b/src/features/debugger/ui/Overlays.module.css @@ -1,7 +1,3 @@ -.spacer { - flex: 1; -} - .empty { padding: 16px; color: var(--fg-faint); @@ -21,12 +17,53 @@ } /* breakpoint popover */ -.bpEditor { - width: 340px; - padding: 10px 12px; +.bpPopover { + display: flex; + flex-direction: column; + width: 400px; + overflow: hidden; + font-size: var(--fs-ui); +} + +.bpPopoverTitle, +.bpFooter { + flex: none; + display: flex; + align-items: center; + gap: var(--space-2); + padding: var(--space-2) var(--space-3); +} + +.bpPopoverTitle { + color: var(--fg-strong); + font-weight: 600; + white-space: nowrap; +} + +.bpPopoverTitle > svg { + flex: none; +} + +.bpPopoverTitle .bpFile { + font-family: var(--font-ui); +} + +.bpPopoverFields { display: flex; flex-direction: column; gap: var(--space-2); + min-height: 0; + padding: var(--space-1) var(--space-3) var(--space-2); + overflow: auto; + overscroll-behavior: contain; +} + +.bpPopoverFields > * { + flex: none; +} + +.bpPopoverFields .label { + font-size: var(--fs-ui); } .bpActions { @@ -86,21 +123,27 @@ } .bpFooter { - display: flex; - align-items: center; - gap: var(--space-1-5); - margin-top: 2px; + flex-wrap: wrap; + border-block-start: 1px solid var(--border-popup); } -.link { +.bpFooterButtons { + display: flex; + flex-wrap: wrap; + gap: var(--space-1); + margin-inline-start: auto; +} + +.bpMore { display: inline-flex; + flex-wrap: wrap; align-items: center; gap: var(--space-1-5); color: var(--accent); font-size: var(--fs-ui); cursor: pointer; } -.link:hover { +.bpMore:hover { color: var(--accent-hover); } diff --git a/src/features/debugger/ui/Overlays.tsx b/src/features/debugger/ui/Overlays.tsx index ced8b8e45..70f6ac4ac 100644 --- a/src/features/debugger/ui/Overlays.tsx +++ b/src/features/debugger/ui/Overlays.tsx @@ -10,6 +10,7 @@ import { type CSSProperties, type KeyboardEvent, type MutableRefObject, + type ReactNode, } from "react"; import { basename, relativePath, useProject } from "@/platform/project"; import { executeAction, getAction } from "@/platform/actions"; @@ -137,6 +138,62 @@ function BreakpointPopover() { return ; } +function BreakpointPropertiesPopup({ + at, + title, + onClose, + onRemove, + children, +}: { + at: { x: number; y: number }; + title: ReactNode; + onClose: () => void; + onRemove: () => void; + children: ReactNode; +}) { + return ( + +
    {title}
    +
    {children}
    +
    + +
    + + +
    +
    +
    + ); +} + function BreakpointEditor({ path, bp, @@ -155,49 +212,25 @@ function BreakpointEditor({ }; return ( - -
    -
    + removeBreakpoint(path, bp.id)} + title={ + <> - - {basename(path)}:{bp.line + 1} - -
    - -
    - -
    - - -
    -
    - + + + } + > + + ); } @@ -365,66 +398,46 @@ function SpecialEditor({ bp, at }: { bp: SpecialBreakpoint; at: { x: number; y: closeBreakpointPopover(); }; return ( - -
    -
    + removeSpecial(bp.id)} + title={ + <> - {specialTitle(bp)} -
    - updateSpecial(bp.id, { enabled })} label="Enabled" /> - - -
    - -
    - - -
    -
    - + + } + > + updateSpecial(bp.id, { enabled })} label="Enabled" /> + + + ); } From 6aeb733f20bb4be332481dfe1832d440a778f310 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 09:12:05 +0800 Subject: [PATCH 04/32] fix(run): make test report export paths easier to edit (#5223) The test results export dialog puts HTML and XML on separate rows and gives the file name and folder separate fields. The file name is selected on open, so it can be replaced without retyping the directory. Pasting a full path and choosing a destination with Browse still work. --- e2e/run.spec.ts | 51 +++++++++ .../run/ExportTestResultsDialog.test.tsx | 54 ++++++--- src/features/run/ExportTestResultsDialog.tsx | 108 ++++++++++++------ src/features/run/Run.module.css | 40 ++++++- src/features/run/TestTreeView.test.tsx | 3 +- 5 files changed, 198 insertions(+), 58 deletions(-) diff --git a/e2e/run.spec.ts b/e2e/run.spec.ts index 0861c7b95..4ce9d8aec 100644 --- a/e2e/run.spec.ts +++ b/e2e/run.spec.ts @@ -581,3 +581,54 @@ test("CMake builds the selected target in Build before starting only the applica await expect(run.getByRole("tab", { name: "hello [Release, release]" })).toBeVisible(); await expect(run.getByText("COMPILER_OUTPUT", { exact: true })).toHaveCount(0); }); + +test("test report export separates the format and destination in a narrow window", async ({ workbench: page }) => { + await page.setViewportSize({ width: 410, height: 500 }); + await stubRun( + page, + [ + { + kind: "stdout", + text: '{"Package":"example.com/checkout","Action":"pass","Test":"TestReceipt","Elapsed":0.1}\n', + }, + ], + 0, + { id: "go:report-tests", name: "Checkout tests", kind: "go", command: "go", args: ["test", "-json"], isTest: true }, + ); + await page.evaluate(() => { + window.__ipc.handlers.fs_entry_kind = () => { + throw { kind: "NotFound", message: "Not found" }; + }; + window.__ipc.handlers.fs_create_file_bytes = () => null; + }); + + await page.keyboard.press("Control+r"); + const results = page.getByRole("toolbar", { name: "Test results" }); + await results.getByRole("button", { name: "More Actions" }).click(); + const exportItem = page.getByRole("menuitem", { name: "Export Test Results…" }); + await expect(exportItem).toBeEnabled(); + await exportItem.click(); + + const dialog = page.getByRole("dialog", { name: "Export Test Results" }); + const html = dialog.getByRole("radio", { name: "HTML", exact: true }); + const xml = dialog.getByRole("radio", { name: "XML", exact: true }); + await expect(html).toBeVisible(); + expect((await xml.boundingBox())!.y).toBeGreaterThan((await html.boundingBox())!.y); + const file = dialog.getByLabel("File name", { exact: true }); + const folder = dialog.getByLabel("Folder", { exact: true }); + const browse = dialog.getByRole("button", { name: "Browse…" }); + await expect(file).toBeFocused(); + await expect(file).toHaveValue("Test Results - Checkout tests.html"); + await expect(folder).toHaveValue("/dev/acme-api"); + await expect(browse).toBeInViewport({ ratio: 1 }); + expect((await folder.boundingBox())!.width).toBeGreaterThan(180); + await file.fill("receipts.html"); + await folder.fill("reports"); + await xml.check(); + await expect(file).toHaveValue("receipts.xml"); + await expect(dialog.getByRole("checkbox", { name: "Open exported file in browser" })).toBeDisabled(); + await dialog.getByRole("button", { name: "OK", exact: true }).click(); + await expect(dialog).toBeHidden(); + const [write] = await ipcCalls(page, "fs_create_file_bytes"); + expect(write).toMatchObject({ path: "/dev/acme-api/reports/receipts.xml" }); +}); diff --git a/src/features/run/ExportTestResultsDialog.test.tsx b/src/features/run/ExportTestResultsDialog.test.tsx index 5b6c65ced..1d60c9175 100644 --- a/src/features/run/ExportTestResultsDialog.test.tsx +++ b/src/features/run/ExportTestResultsDialog.test.tsx @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { commands } from "@/platform/ipc"; -import { ExportTestResultsDialog, defaultExportPath, loadExportOptions } from "./ExportTestResultsDialog"; +import { ExportTestResultsDialog, defaultExportName, loadExportOptions } from "./ExportTestResultsDialog"; import { TestResults } from "./testing"; const actions = vi.hoisted(() => ({ executeAction: vi.fn(async () => {}) })); @@ -56,13 +56,15 @@ function open(onClose = vi.fn()) { return onClose; } -const file = () => screen.getByLabelText("Output file"); +const file = () => screen.getByLabelText("File name"); +const folder = () => screen.getByLabelText("Folder"); const press = (name: string) => fireEvent.click(screen.getByRole("button", { name })); describe("ExportTestResultsDialog", () => { - it("writes an HTML report to the project folder under IDEA's name and opens it in the browser", async () => { + it("writes an HTML report to the project folder and opens it in the browser", async () => { const onClose = open(); - expect(file()).toHaveValue("/work/app/Test Results - go test _calc.html"); + expect(file()).toHaveValue("Test Results - go test _calc.html"); + expect(folder()).toHaveValue("/work/app/"); expect(screen.getByRole("radio", { name: "HTML" })).toBeChecked(); press("OK"); await waitFor(() => expect(onClose).toHaveBeenCalled()); @@ -92,7 +94,7 @@ describe("ExportTestResultsDialog", () => { it("switches the extension with the format, keeps XML out of the browser, and remembers the choice", async () => { const onClose = open(); fireEvent.click(screen.getByRole("radio", { name: "XML" })); - expect(file()).toHaveValue("/work/app/Test Results - go test _calc.xml"); + expect(file()).toHaveValue("Test Results - go test _calc.xml"); // Only an HTML report opens in the browser. expect(screen.getByRole("checkbox", { name: "Open exported file in browser" })).toBeDisabled(); press("OK"); @@ -143,18 +145,36 @@ describe("ExportTestResultsDialog", () => { }); it("doesn't ask again for a file the save dialog already confirmed", async () => { - onDisk["/tmp/picked.html"] = "file"; - dialog.save.mockResolvedValueOnce("/tmp/picked.html"); + const path = "C:\\reports\\picked.html"; + onDisk[path] = "file"; + dialog.save.mockResolvedValueOnce(path); const onClose = open(); press("Browse…"); - await waitFor(() => expect(file()).toHaveValue("/tmp/picked.html")); + await waitFor(() => expect(file()).toHaveValue("picked.html")); + expect(folder()).toHaveValue("C:\\reports\\"); expect(dialog.save).toHaveBeenCalledWith( - expect.objectContaining({ filters: [{ name: "HTML", extensions: ["html"] }] }), + expect.objectContaining({ + defaultPath: "/work/app/Test Results - go test _calc.html", + filters: [{ name: "HTML", extensions: ["html"] }], + }), ); press("OK"); await waitFor(() => expect(onClose).toHaveBeenCalled()); expect(messages.confirm).not.toHaveBeenCalled(); - expect(written.map((w) => w.path)).toEqual(["/tmp/picked.html"]); + expect(written.map((w) => w.path)).toEqual([path]); + }); + + it("confirms again when the destination changes after using the save dialog", async () => { + dialog.save.mockResolvedValueOnce("/tmp/picked.html"); + onDisk["/work/app/reports/picked.html"] = "file"; + messages.confirm.mockResolvedValueOnce(false); + open(); + press("Browse…"); + await waitFor(() => expect(file()).toHaveValue("picked.html")); + fireEvent.change(folder(), { target: { value: "reports" } }); + press("OK"); + await waitFor(() => expect(messages.confirm).toHaveBeenCalledOnce()); + expect(written).toHaveLength(0); }); it("reports a directory or a failed write and stays open", async () => { @@ -187,15 +207,11 @@ describe("ExportTestResultsDialog", () => { }); }); -describe("defaultExportPath", () => { +describe("defaultExportName", () => { it("replaces characters file systems refuse in the configuration's name", () => { - expect(defaultExportPath("C:\\proj\\", 'a/b\\c:d*e?f"gi|j', "xml")).toBe( - "C:\\proj/Test Results - a_b_c_d_e_f_g_h_i_j.xml", - ); - expect(defaultExportPath("/p", "go test ./...", "html")).toBe("/p/Test Results - go test.html"); - expect(defaultExportPath("/p", "Tests in 'com.acme.Cart'", "html")).toBe( - "/p/Test Results - Tests in 'com_acme_Cart'.html", - ); - expect(defaultExportPath("/p", "...", "html")).toBe("/p/Test Results - Tests.html"); + expect(defaultExportName('a/b\\c:d*e?f"gi|j', "xml")).toBe("Test Results - a_b_c_d_e_f_g_h_i_j.xml"); + expect(defaultExportName("go test ./...", "html")).toBe("Test Results - go test.html"); + expect(defaultExportName("Tests in 'com.acme.Cart'", "html")).toBe("Test Results - Tests in 'com_acme_Cart'.html"); + expect(defaultExportName("...", "html")).toBe("Test Results - Tests.html"); }); }); diff --git a/src/features/run/ExportTestResultsDialog.tsx b/src/features/run/ExportTestResultsDialog.tsx index 34dab76cc..c3db1d907 100644 --- a/src/features/run/ExportTestResultsDialog.tsx +++ b/src/features/run/ExportTestResultsDialog.tsx @@ -2,7 +2,7 @@ * IDEA's Export Test Results dialog: HTML or XML, the output file, and whether to * open an HTML report in the browser once it is written. */ -import { useState } from "react"; +import { useId, useState } from "react"; import { executeAction } from "@/platform/actions"; import { tx } from "@/platform/i18n"; import { call, commands } from "@/platform/ipc"; @@ -38,13 +38,35 @@ function saveExportOptions(o: ExportOptions) { } } -/** - * IDEA's default name, `Test Results - .html`. Like IDEA's `PathUtil.suggestFileName`, runs of - * dots and characters file systems refuse become one `_` (`go test ./...` gives `go test`). - */ -export function defaultExportPath(dir: string, name: string, format: TestExportFormat): string { +/** Runs of dots and characters file systems refuse become one `_`. */ +export function defaultExportName(name: string, format: TestExportFormat): string { const safe = name.replace(/[/\\:*?"<>|.]+/g, "_").replace(/^[\s_]+|[\s_]+$/g, ""); - return `${dir.replace(/[\\/]+$/, "")}/Test Results - ${safe || "Tests"}.${format}`; + return `Test Results - ${safe || "Tests"}.${format}`; +} + +interface Destination { + folder: string; + fileName: string; + /** The native picker already asked before replacing this exact path. */ + pickedPath?: string; +} + +function destinationFromPicker(path: string): Destination { + const slash = path.lastIndexOf("/"); + const posix = path.startsWith("/") && !path.startsWith("//"); + const end = (posix ? slash : Math.max(slash, path.lastIndexOf("\\"))) + 1; + return { folder: path.slice(0, end), fileName: path.slice(end), pickedPath: path }; +} + +function resolveDestination({ folder, fileName, pickedPath }: Destination, cwd: string): string { + if (pickedPath) return pickedPath; + const file = fileName.trim(); + if (!file || isAbsolutePath(file)) return file; + const dir = folder.trim(); + const posix = dir.startsWith("/") && !dir.startsWith("//"); + const base = dir.replace(posix ? /\/+$/ : /[\\/]+$/, ""); + const path = dir ? `${base}/${file}` : file; + return isAbsolutePath(path) ? path : `${cwd.replace(/[\\/]+$/, "")}/${path}`; } async function exists(path: string): Promise<"file" | "dir" | null> { @@ -111,44 +133,47 @@ export function ExportTestResultsDialog({ cwd: string; onClose: () => void; }) { + const fileNameId = useId(); + const folderId = useId(); const [options, setOptions] = useState(loadExportOptions); - const [path, setPath] = useState(() => defaultExportPath(cwd, name, options.format)); - // The save dialog already asked before replacing this file. - const [picked, setPicked] = useState(null); + const [destination, setDestination] = useState(() => ({ + folder: cwd, + fileName: defaultExportName(name, options.format), + })); const [busy, setBusy] = useState(false); const html = options.format === "html"; + const { folder, fileName, pickedPath } = destination; + const target = resolveDestination(destination, cwd); const update = (next: Partial) => { const merged = { ...options, ...next }; setOptions(merged); saveExportOptions(merged); // The file follows the format's extension, as in the Export Data dialog. - if (next.format) setPath((p) => p.replace(/\.(html|xml)$/i, `.${next.format}`)); + if (next.format) { + const nextName = fileName.replace(/\.(html|xml)$/i, `.${next.format}`); + if (nextName !== fileName) setDestination({ folder, fileName: nextName }); + } }; const browse = async () => { try { const { save } = await import("@/platform/dialog"); const chosen = await save({ - defaultPath: path, + defaultPath: target || folder || cwd, filters: [{ name: html ? "HTML" : "XML", extensions: [options.format] }], }); - if (chosen) { - setPath(chosen); - setPicked(chosen); - } + if (chosen) setDestination(destinationFromPicker(chosen)); } catch { // No dialog (tests): keep typing the path. } }; const run = async () => { - const raw = path.trim(); - if (!raw) return; - const target = isAbsolutePath(raw) ? raw : `${cwd.replace(/[\\/]+$/, "")}/${raw}`; + if (!target) return; setBusy(true); const text = exportTestResults(options.format, results, { name, cwd, date: new Date() }); - const ok = await writeTestReport(target, text, picked === raw); + const ok = await writeTestReport(target, text, pickedPath !== undefined); setBusy(false); if (!ok) return; onClose(); @@ -167,29 +192,46 @@ export function ExportTestResultsDialog({ open title="Export Test Results" onClose={onClose} - width={520} + width={500} buttons={[ - { label: "OK", role: "default", disabled: busy || !path.trim(), onClick: () => void run() }, + { label: "OK", role: "default", disabled: busy || !target, onClick: () => void run() }, { label: "Cancel", role: "cancel" }, ]} > -
    -
    - +
    +
    + Export format: - + update({ format: "html" })} /> update({ format: "xml" })} /> -
    -
From c61ddbff3d4e037720c583eb8838e5b8d41bf779 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 09:13:30 +0800 Subject: [PATCH 14/32] fix(vcs): make Git Log commit choices easier to scan (#5250) The Git Log commit chooser now gives its results the full dialog width and sizes the list to the number of candidates. Previously the list could be clipped inside a fixed-height area. Each row separates the subject from the hash, author and timestamp. The search field keeps keyboard focus while the arrow keys move the selection. --- e2e/gitLogCommitChooser.spec.ts | 104 ++++++++++++++++++++++ src/features/vcs/CommitChooser.module.css | 65 ++++++++++++++ src/features/vcs/CommitChooser.tsx | 81 ++++++++++++++--- 3 files changed, 239 insertions(+), 11 deletions(-) create mode 100644 e2e/gitLogCommitChooser.spec.ts create mode 100644 src/features/vcs/CommitChooser.module.css diff --git a/e2e/gitLogCommitChooser.spec.ts b/e2e/gitLogCommitChooser.spec.ts new file mode 100644 index 000000000..c531a5205 --- /dev/null +++ b/e2e/gitLogCommitChooser.spec.ts @@ -0,0 +1,104 @@ +import { expect, stubDesktop, test } from "./fixtures"; + +const rootSubject = "Start warehouse reporting"; +const mergeSubject = "Merge reporting changes"; +const firstSubject = "Align regional settlement totals with the warehouse ledger before monthly reconciliation closes"; +const secondSubject = "Keep archived settlement adjustments in the regional audit trail after the ledger is rebuilt"; + +test("Git Log commit choices fit their rows and navigate by keyboard after filtering", async ({ workbench: page }) => { + await page.setViewportSize({ width: 1040, height: 700 }); + await stubDesktop(page); + await page.evaluate( + async ({ mergeSubject, firstSubject, secondSubject, rootSubject }) => { + const root = "/dev/acme-api"; + const changes = [ + [mergeSubject, "Merge Author", [1, 2]], + [firstSubject, "Priya Kapoor", [3]], + [secondSubject, "Morgan Olsen", [3]], + [rootSubject, "Initial Author", []], + ] as const; + const id = (i: number) => String(i + 1).repeat(40); + const commits = changes.map(([summary, author, parents], i) => ({ + id: id(i), + shortId: id(i).slice(0, 8), + parents: parents.map(id), + refs: i === 0 ? ["HEAD", "main"] : [], + author, + email: "author@example.com", + timeMs: Date.UTC(2026, 10, 15 - i, 10 + i, 30), + summary, + message: summary, + })); + const handlers = window.__ipc.handlers; + handlers.vcs_log = ({ query }) => { + const { skip, limit, range } = query as { skip: number; limit: number; range?: string }; + return range ? [] : commits.slice(skip, limit ? skip + limit : undefined); + }; + handlers.vcs_log_refs = () => ({}); + handlers.vcs_log_users = () => []; + handlers.vcs_branches = () => []; + handlers.vcs_branch_info = () => ({ head: "main", headCommit: id(0), ahead: 0, behind: 0 }); + handlers.vcs_config_get = () => null; + handlers.vcs_commit_files = () => []; + handlers.vcs_log_details_batch = ({ revisions }) => + (revisions as string[]).map(() => ({ message: "", containingBranches: [], signature: "N" })); + const vcsModule = "/src/features/vcs/store.ts"; + const contextModule = "/src/platform/context.ts"; + const actionsModule = "/src/platform/actions.ts"; + const { useVcs } = await import(/* @vite-ignore */ vcsModule); + const { setContext } = await import(/* @vite-ignore */ contextModule); + const { executeAction } = await import(/* @vite-ignore */ actionsModule); + useVcs.setState({ available: true, root, repo: root, roots: [root], branchesLoaded: true }); + setContext("vcsAvailable", true); + await executeAction("vcs.showLog"); + }, + { mergeSubject, firstSubject, secondSubject, rootSubject }, + ); + + const log = page.getByRole("listbox", { name: "Commits", exact: true }); + const merge = log.getByRole("option", { name: new RegExp(mergeSubject) }); + await merge.click(); + await log.press("ArrowRight"); + const chooser = page.getByRole("dialog", { name: "Select Parent Commit", exact: true }); + const options = chooser.getByRole("option"); + const filter = chooser.getByRole("combobox", { name: "Search commits" }); + await expect(filter).toBeFocused(); + await expect(options).toHaveCount(2); + const before = (await chooser.boundingBox())!; + expect(before.height).toBeLessThan(200); + const first = options.filter({ hasText: firstSubject }); + const subject = first.getByText(firstSubject, { exact: true }); + const author = first.getByText("Priya Kapoor", { exact: true }); + const hash = first.getByText("22222222", { exact: true }); + await expect(subject).toHaveCSS("font-size", "13px"); + await expect(author).toHaveCSS("font-size", "12px"); + expect((await subject.boundingBox())!.y).toBeLessThan((await hash.boundingBox())!.y); + await expect(subject.locator("..")).toHaveAttribute("title", /Priya Kapoor/); + + await page.setViewportSize({ width: 440, height: 520 }); + const narrow = (await chooser.boundingBox())!; + expect(narrow.x + narrow.width).toBeLessThanOrEqual(440); + expect(await chooser.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeLessThanOrEqual(1); + await filter.fill("No such change"); + await expect(chooser.getByText("No commits", { exact: true })).toBeVisible(); + await filter.press("Enter"); + await expect(chooser).toBeVisible(); + await filter.fill("Morgan Olsen"); + await expect(options).toHaveCount(1); + await expect(options.first()).toContainText(secondSubject); + await filter.fill(""); + await expect(options).toHaveCount(2); + await filter.press("ArrowDown"); + await expect(options.filter({ hasText: secondSubject })).toHaveAttribute("aria-selected", "true"); + await filter.press("Enter"); + await expect(chooser).toBeHidden(); + await expect(log.getByRole("option", { name: new RegExp(secondSubject) })).toHaveAttribute("aria-selected", "true"); + + await log.getByRole("option", { name: new RegExp(rootSubject) }).click(); + await log.press("ArrowLeft"); + const children = page.getByRole("dialog", { name: "Select Child Commit", exact: true }); + await expect(children.getByRole("option")).toHaveCount(2); + await children.getByRole("option", { name: new RegExp(firstSubject) }).click(); + await expect(children).toBeHidden(); + await expect(log.getByRole("option", { name: new RegExp(firstSubject) })).toHaveAttribute("aria-selected", "true"); +}); diff --git a/src/features/vcs/CommitChooser.module.css b/src/features/vcs/CommitChooser.module.css new file mode 100644 index 000000000..4817177ce --- /dev/null +++ b/src/features/vcs/CommitChooser.module.css @@ -0,0 +1,65 @@ +.search { + display: flex; + padding: var(--space-2) var(--space-3); +} + +.search > * { + flex: 1; + min-width: 0; +} + +.results { + display: flex; + flex-direction: column; + max-height: max(84px, calc(100vh - 144px)); + margin-bottom: var(--space-2); +} + +.list { + flex: 1; +} + +.choice { + display: flex; + flex-direction: column; + width: 100%; + min-width: 0; +} + +.choice > span { + pointer-events: none; +} + +.subject, +.author, +.date { + overflow: hidden; + text-overflow: ellipsis; +} + +.subject { + font-size: var(--fs-ui); +} + +.metadata { + display: flex; + gap: var(--space-2); + align-items: baseline; + color: var(--fg-muted); + font-size: var(--fs-small); +} + +.hash { + flex: none; + font-family: var(--font-mono); +} + +.author { + flex: 1; + min-width: 0; +} + +.date { + flex: none; + max-width: 50%; +} diff --git a/src/features/vcs/CommitChooser.tsx b/src/features/vcs/CommitChooser.tsx index a7eaf894c..550a10244 100644 --- a/src/features/vcs/CommitChooser.tsx +++ b/src/features/vcs/CommitChooser.tsx @@ -1,9 +1,14 @@ -import { useState } from "react"; +import { useId, useState, type KeyboardEvent } from "react"; import type { Commit } from "@/bindings"; -import { Dialog, List, SearchField } from "@/ui"; +import { tx } from "@/platform/i18n"; +import { Dialog, List, SearchField, T, listNavigate } from "@/ui"; import { openDialog } from "./dialogs"; +import { formatTime } from "./model"; import { commitKey } from "./multiRoot"; -import { useRowHeight } from "@/ui/density"; +import styles from "./CommitChooser.module.css"; + +const ROW_HEIGHT = 42; +const VISIBLE_ROWS = 8; export function chooseLogCommit(commits: Commit[], title: string): Promise { return new Promise((resolve) => { @@ -29,22 +34,76 @@ function CommitChooser({ title: string; onDone: (commit: Commit | null) => void; }) { - const rowHeight = useRowHeight(26); + const listId = useId(); const [query, setQuery] = useState(""); - const shown = commits.filter((c) => - `${c.id} ${c.summary} ${c.author}`.toLocaleLowerCase().includes(query.toLocaleLowerCase()), + const [active, setActive] = useState(0); + const filter = query.toLocaleLowerCase(); + const shown = commits.filter((commit) => + `${commit.id} ${commit.summary} ${commit.author}`.toLocaleLowerCase().includes(filter), ); + const selected = Math.min(active, shown.length - 1); + const onKeyDown = (event: KeyboardEvent) => { + if (event.nativeEvent.isComposing) return; + if (event.key === "Enter") { + event.preventDefault(); + if (shown[selected]) onDone(shown[selected]); + } else if (event.key === "ArrowDown" || event.key === "ArrowUp") { + const next = listNavigate(event.key, { items: shown, active: selected, wrap: true }); + if (next === null) return; + event.preventDefault(); + setActive(next); + } + }; + return ( onDone(null)} width={520}> - -
+
+ = 0 ? `${listId}-${selected}` : undefined} + value={query} + onChange={(value) => { + setQuery(value); + setActive(0); + }} + onKeyDown={onKeyDown} + placeholder="Search commits" + aria-label="Search commits" + /> +
+
`${c.shortId} ${c.summary} — ${c.author}`} + activeIndex={selected} + onActiveChange={setActive} onActivate={onDone} - rowHeight={rowHeight} - aria-label={title} + focusable={false} + rowHeight={ROW_HEIGHT} + aria-label={tx(title)} + empty={No commits} + className={styles.list} + renderItem={(commit) => { + const date = formatTime(commit.timeMs); + return ( + + {commit.summary} + + {commit.shortId} + {commit.author} + {date && {date}} + + + ); + }} />
From d7a05eea211b2ec43d6a80039ad2618caf8359a4 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 09:13:37 +0800 Subject: [PATCH 15/32] fix(vcs): align commit author and date fields (#5252) Commit Options gives the author and date fields a shared label column when there is room. A narrow options pane puts the labels above the controls and moves the clear button below the date when needed. In the 650 px desktop window, the author input grew from 104 px to 157 px, and the date input grew from 133 px to 157 px. The native date control can still clip part of the time display at that width. --- e2e/commit.spec.ts | 60 +++++++++++++++++++++++++ src/features/vcs/CommitAuthorFields.tsx | 14 +++--- src/features/vcs/CommitView.module.css | 32 +++++++------ 3 files changed, 86 insertions(+), 20 deletions(-) diff --git a/e2e/commit.spec.ts b/e2e/commit.spec.ts index ca6c3859b..6420942f4 100644 --- a/e2e/commit.spec.ts +++ b/e2e/commit.spec.ts @@ -85,6 +85,66 @@ test("⌘K commits the checked changes with the typed message", async ({ workben await expect(changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden(); }); +test("commit options align author fields and keep the date editable in a narrow dialog", async ({ + workbench: page, +}) => { + await stubRepository(page); + await page.setViewportSize({ width: 1040, height: 700 }); + await page.keyboard.press("Meta+k"); + const panel = page.getByRole("region", { name: "Commit", exact: true }); + await panel.getByRole("button", { name: "Commit Options", exact: true }).click(); + const popup = page.getByRole("dialog", { name: "Commit Options", exact: true }); + const author = popup.getByRole("textbox", { name: "Author", exact: true }); + const date = popup.getByLabel("Author date", { exact: true }); + const clear = popup.getByRole("button", { name: "Clear author date", exact: true }); + const name = "Regional Ledger Review "; + const time = "2024-06-04T13:20:21"; + await author.fill(name); + await date.fill(time); + const authorBox = (await author.boundingBox())!; + const dateBox = (await date.boundingBox())!; + const dateLabel = (await popup.getByText("Author date", { exact: true }).boundingBox())!; + const clearBox = (await clear.boundingBox())!; + expect(authorBox.x).toBeCloseTo(dateBox.x, 0); + expect(dateLabel.y).toBeGreaterThanOrEqual(dateBox.y); + expect(dateLabel.y).toBeLessThan(dateBox.y + dateBox.height); + expect(clearBox.x + clearBox.width).toBeCloseTo(authorBox.x + authorBox.width, 0); + await expect(clear).toBeInViewport({ ratio: 1 }); + + await page.keyboard.press("Escape"); + await expect(popup).toBeHidden(); + await page.evaluate(async () => { + const projectModule = "/src/platform/project.ts"; + const { useProject } = await import(/* @vite-ignore */ projectModule); + const { settings } = useProject.getState(); + useProject.setState({ + settings: { ...settings, vcs: { ...settings?.vcs, commit: { ...settings?.vcs?.commit, nonModal: false } } }, + }); + }); + await page.setViewportSize({ width: 650, height: 650 }); + await page.keyboard.press("Meta+k"); + const dialog = page.getByRole("dialog", { name: "Commit Changes", exact: true }); + const options = dialog.getByRole("group", { name: "Commit Options", exact: true }); + const compactAuthor = options.getByRole("textbox", { name: "Author", exact: true }); + const compactDate = options.getByLabel("Author date", { exact: true }); + const compactClear = options.getByRole("button", { name: "Clear author date", exact: true }); + await expect(compactAuthor).toHaveValue(name); + await expect(compactDate).toHaveValue(time); + const labelBox = (await options.getByText("Author:", { exact: true }).boundingBox())!; + const inputBox = (await compactAuthor.boundingBox())!; + expect(inputBox.x).toBeCloseTo(labelBox.x, 0); + expect(inputBox.y).toBeGreaterThanOrEqual(labelBox.y + labelBox.height); + const box = (await compactDate.boundingBox())!; + const buttonBox = (await compactClear.boundingBox())!; + expect(box.width).toBeCloseTo(inputBox.width, 0); + expect(buttonBox.y).toBeGreaterThanOrEqual(box.y + box.height); + expect(await options.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeLessThanOrEqual(1); + await compactClear.click(); + await expect(compactDate).toHaveValue(""); + await expect(compactClear).toBeHidden(); + await expect(compactAuthor).toHaveValue(name); +}); + test("the Commit window gives its message preferred focus", async ({ workbench: page }) => { await stubRepository(page); const stripe = page.locator('[data-stripe-button="commit"]'); diff --git a/src/features/vcs/CommitAuthorFields.tsx b/src/features/vcs/CommitAuthorFields.tsx index ec915a482..50722fcaa 100644 --- a/src/features/vcs/CommitAuthorFields.tsx +++ b/src/features/vcs/CommitAuthorFields.tsx @@ -33,15 +33,17 @@ export function CommitAuthorFields({ focusAuthor?: boolean; onChange: (update: Partial) => void; }) { + const authorId = useId(); const authorDateId = useId(); const date = authorDate ? new Date(authorDate) : null; return ( - <> -