diff --git a/packages/app/e2e/regression/terminal-composer-focus.spec.ts b/packages/app/e2e/regression/terminal-composer-focus.spec.ts index b7013e8c81a..ca9263437b1 100644 --- a/packages/app/e2e/regression/terminal-composer-focus.spec.ts +++ b/packages/app/e2e/regression/terminal-composer-focus.spec.ts @@ -126,6 +126,8 @@ test("routes typing to the composer unless the open terminal is focused", async const composer = page.locator('[data-component="composer-editor"]') const terminal = page.locator('[data-component="terminal"]') + await composer.click() + await expect(composer).toBeFocused() await page.keyboard.press("Control+Backquote") await expect(terminal).toBeVisible() await expect.poll(() => terminal.evaluate((element) => element.contains(document.activeElement))).toBe(true) diff --git a/packages/app/src/session/commands/use-session-commands.tsx b/packages/app/src/session/commands/use-session-commands.tsx index a2ab6c83bcb..b066826e079 100644 --- a/packages/app/src/session/commands/use-session-commands.tsx +++ b/packages/app/src/session/commands/use-session-commands.tsx @@ -193,9 +193,9 @@ export const useSessionCommands = (actions: SessionCommandContext) => { } const openTerminal = () => { + actions.session.layout.view().terminal.open() if (terminal.all().length > 0) terminal.new({ focus: true }) if (terminal.all().length === 0) terminal.requestFocus() - actions.session.layout.view().terminal.open() } const closeTerminal = () => { @@ -361,8 +361,8 @@ export const useSessionCommands = (actions: SessionCommandContext) => { actions.session.layout.view().terminal.close() return } - terminal.requestFocus(terminal.active()) actions.session.layout.view().terminal.open() + terminal.requestFocus(terminal.active()) }, }), viewCommand({