From 92dbf0baa5cdf703bfb48e44f7845b6adb0c601a Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 22 Nov 2026 14:03:13 +0800 Subject: [PATCH] fix(terminal): separate session choices from window actions (#5138) Open the predefined session chooser directly on the installed shells and SSH. The plus button opens the default shell. Split commands live in the terminal tool window's Options menu, with Settings at the bottom of the session chooser. On the Windows fixture the chooser went from nine actions to six and from 267 px to 153 px in height. --- e2e/terminalSessionTabsLayout.spec.ts | 29 +++++++++++++++++++++++--- src/features/terminal/TerminalView.tsx | 18 ++++++++-------- src/features/terminal/index.ts | 7 +++++++ src/platform/locales/text/es.json | 1 - src/platform/locales/text/fr.json | 1 - src/platform/locales/text/ko.json | 1 - src/platform/locales/text/pl.json | 1 - src/platform/locales/text/pt.json | 1 - src/platform/locales/text/tr.json | 1 - src/platform/locales/text/zh-TW.json | 1 - src/platform/locales/text/zh.json | 1 - 11 files changed, 42 insertions(+), 20 deletions(-) diff --git a/e2e/terminalSessionTabsLayout.spec.ts b/e2e/terminalSessionTabsLayout.spec.ts index 25cbd5a59..45eda4c4f 100644 --- a/e2e/terminalSessionTabsLayout.spec.ts +++ b/e2e/terminalSessionTabsLayout.spec.ts @@ -58,8 +58,8 @@ test("a narrow terminal panel keeps the selected tab's close button in view", as await expect(selected).toHaveAttribute("data-tooltip", new RegExp(longName)); await expect(terminal.getByRole("button", { name: "Show Hidden Tabs" })).toBeHidden(); await expect(terminal.getByRole("button", { name: "New Tab", exact: true })).toBeVisible(); - await terminal.getByRole("button", { name: "More Terminal Options" }).click(); - await expect(page.getByRole("menuitem", { name: /^New Terminal Tab/ })).toBeVisible(); + await terminal.getByRole("button", { name: "New Predefined Session" }).click(); + await expect(page.getByRole("menuitem", { name: "zsh", exact: true })).toBeVisible(); await page.keyboard.press("Escape"); await strip.getByRole("button", { name: "Close Tab", exact: true }).click(); await expect(terminal).toBeHidden(); @@ -82,9 +82,32 @@ test("terminal split tabs fit when sessions overflow and switch through the menu await page.getByRole("menuitem", { name: "Local (2)", exact: true }).click(); await expect(strip.getByRole("tab", { name: "Local (2)", selected: true })).toBeVisible(); await expectSelectedTabToFit(strip); - await expect(header.getByRole("button", { name: "More Terminal Options" })).toBeVisible(); + await expect(header.getByRole("button", { name: "New Predefined Session" })).toBeVisible(); await hidden.click(); await page.getByRole("menuitem", { name: longName, exact: true }).click(); await expect(strip.getByRole("tab", { name: longName, selected: true })).toBeVisible(); await expectSelectedTabToFit(strip); }); + +test("the terminal session chooser lists shells first and window options own the split commands", async ({ + workbench: page, +}) => { + const terminal = await openTerminal(page, 520); + const chooser = terminal.getByRole("button", { name: "New Predefined Session", exact: true }); + await expect(chooser).toBeVisible(); + await chooser.press("Space"); + const sessions = page.getByRole("menu", { name: "New Predefined Session", exact: true }); + await expect(sessions.getByRole("menuitem")).toHaveText(["zsh", "SSH Session…", /^Settings/]); + await page.keyboard.press("Home"); + await expect(sessions.getByRole("menuitem", { name: "zsh", exact: true })).toBeFocused(); + await page.keyboard.press("Enter"); + await expect(sessions).toBeHidden(); + await expect(terminal.getByRole("tab", { name: "zsh", selected: true })).toBeVisible(); + + await terminal.getByRole("button", { name: "Options", exact: true }).click(); + const options = page.getByRole("menu", { name: "Terminal options", exact: true }); + await expect(options.getByRole("menuitem", { name: /^Split Down/ })).toBeVisible(); + await expect(options.getByRole("menuitem", { name: /^Settings/ })).toBeVisible(); + await options.getByRole("menuitem", { name: /^Split Right/ }).click(); + await expect(terminal.getByRole("tablist", { name: "Terminal sessions" })).toHaveCount(2); +}); diff --git a/src/features/terminal/TerminalView.tsx b/src/features/terminal/TerminalView.tsx index 810ec36e7..3c458b898 100644 --- a/src/features/terminal/TerminalView.tsx +++ b/src/features/terminal/TerminalView.tsx @@ -427,16 +427,10 @@ function GroupTabs({ group }: { group: string }) { }; const renameTarget = renaming && tabs.find((t) => t.id === renaming.id); - const moreItems: MenuItem[] = [ - { kind: "action", action: "terminal.new" }, - { kind: "separator" }, - { kind: "header", label: "New Predefined Session" }, + const sessionItems: MenuItem[] = [ ...shellItems(shells), { kind: "action", action: "ssh.startSession", label: "SSH Session…" }, { kind: "separator" }, - { kind: "action", action: "terminal.splitRight" }, - { kind: "action", action: "terminal.splitDown" }, - { kind: "separator" }, { kind: "action", action: "file.settings", arg: "tools.terminal", label: "Settings", icon: "settings" }, ]; @@ -488,7 +482,7 @@ function GroupTabs({ group }: { group: string }) { ref={menuRef} icon="toolbar-expand" size="small" - title="More Terminal Options" + title="New Predefined Session" aria-haspopup="menu" aria-expanded={menuOpen} onClick={() => { @@ -499,7 +493,13 @@ function GroupTabs({ group }: { group: string }) { setMenuOpen((v) => !v); }} /> - setMenuOpen(false)} /> + setMenuOpen(false)} + /> } /> diff --git a/src/features/terminal/index.ts b/src/features/terminal/index.ts index 6d45fecc2..720dd24fd 100644 --- a/src/features/terminal/index.ts +++ b/src/features/terminal/index.ts @@ -124,6 +124,13 @@ export function activate(): () => void { order: 10, component: lazyComponent(() => loadTerminalRuntime().then((rt) => rt.TerminalView)), headerContent: lazyComponent(() => loadTerminalRuntime().then((rt) => rt.TerminalTabs)), + plainTitle: true, + headerMenu: [ + { kind: "action", action: "terminal.splitRight" }, + { kind: "action", action: "terminal.splitDown" }, + { kind: "separator" }, + { kind: "action", action: "file.settings", arg: "tools.terminal", label: "Settings", icon: "settings" }, + ], }), // Terminal sessions moved to the editor (#2202): saved with the editor session, kept alive while hidden. registerEditorKind({ diff --git a/src/platform/locales/text/es.json b/src/platform/locales/text/es.json index b8e1d41c1..a29027392 100644 --- a/src/platform/locales/text/es.json +++ b/src/platform/locales/text/es.json @@ -1241,7 +1241,6 @@ "More Filters": "Más filtros", "More Actions": "Más acciones", "More Run/Debug": "Más de Ejecutar/Depurar", - "More Terminal Options": "Más opciones de terminal", "More Tool Windows": "Más ventanas de herramientas", "Most recently opened tab": "Pestaña abierta más recientemente", "Mouse Control": "Control del mouse", diff --git a/src/platform/locales/text/fr.json b/src/platform/locales/text/fr.json index 5e33b6a90..6741d67f3 100644 --- a/src/platform/locales/text/fr.json +++ b/src/platform/locales/text/fr.json @@ -1176,7 +1176,6 @@ "More Filters": "Plus de filtres", "More Actions": "Plus d'actions", "More Run/Debug": "Plus d'options d'exécution/débogage", - "More Terminal Options": "Plus d'options du terminal", "More Tool Windows": "Plus de fenêtres d'outils", "Most recently opened tab": "Dernier onglet ouvert", "Mouse Control": "Contrôle à la souris", diff --git a/src/platform/locales/text/ko.json b/src/platform/locales/text/ko.json index d3366271e..7b4d8e4fe 100644 --- a/src/platform/locales/text/ko.json +++ b/src/platform/locales/text/ko.json @@ -1277,7 +1277,6 @@ "More Filters": "필터 더 보기", "More Actions": "액션 더보기", "More Run/Debug": "그 외 실행/디버그", - "More Terminal Options": "기타 터미널 옵션", "More Tool Windows": "도구 창 더보기", "Most recently opened tab": "가장 최근에 연 탭", "Mouse Control": "마우스 컨트롤", diff --git a/src/platform/locales/text/pl.json b/src/platform/locales/text/pl.json index b3f1b3528..30d8a0fbf 100644 --- a/src/platform/locales/text/pl.json +++ b/src/platform/locales/text/pl.json @@ -1231,7 +1231,6 @@ "More Filters": "Więcej filtrów", "More Actions": "Więcej akcji", "More Run/Debug": "Więcej opcji Uruchom/Debuguj", - "More Terminal Options": "Więcej opcji terminala", "More Tool Windows": "Więcej okien narzędziowych", "Most recently opened tab": "Ostatnio otwarta karta", "Mouse Control": "Sterowanie myszą", diff --git a/src/platform/locales/text/pt.json b/src/platform/locales/text/pt.json index 308b90e25..add720d3e 100644 --- a/src/platform/locales/text/pt.json +++ b/src/platform/locales/text/pt.json @@ -1231,7 +1231,6 @@ "More Filters": "Mais filtros", "More Actions": "Mais ações", "More Run/Debug": "Mais opções de Executar/Depurar", - "More Terminal Options": "Mais opções do terminal", "More Tool Windows": "Mais janelas de ferramentas", "Most recently opened tab": "Aba aberta mais recentemente", "Mouse Control": "Controle do mouse", diff --git a/src/platform/locales/text/tr.json b/src/platform/locales/text/tr.json index d84967033..617a1411f 100644 --- a/src/platform/locales/text/tr.json +++ b/src/platform/locales/text/tr.json @@ -4021,7 +4021,6 @@ "More Filters": "Diğer Filtreler", "More Actions": "Diğer Eylemler", "More Run/Debug": "Diğer Çalıştır/Hata Ayıkla Seçenekleri", - "More Terminal Options": "Diğer Terminal Seçenekleri", "More Tool Windows": "Diğer Araç Pencereleri", "Most recently opened tab": "En son açılan sekme", "Mouse Control": "Fare Kontrolü", diff --git a/src/platform/locales/text/zh-TW.json b/src/platform/locales/text/zh-TW.json index f7aa8e8a1..65073ea6d 100644 --- a/src/platform/locales/text/zh-TW.json +++ b/src/platform/locales/text/zh-TW.json @@ -1908,7 +1908,6 @@ "More Filters": "更多篩選", "More Actions": "更多操作", "More Run/Debug": "更多執行/偵錯", - "More Terminal Options": "更多終端機選項", "More Tool Windows": "更多工具視窗", "Most recently opened tab": "最近開啟的分頁", "Mouse Control": "滑鼠控制", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 6490fa689..f7d5c5019 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -1962,7 +1962,6 @@ "More Filters": "更多筛选", "More Actions": "更多操作", "More Run/Debug": "更多运行/调试", - "More Terminal Options": "更多终端选项", "More Tool Windows": "更多工具窗口", "Most recently opened tab": "最近打开的标签页", "Mouse Control": "鼠标控制",