diff --git a/packages/app/src/session/commands/use-session-commands.tsx b/packages/app/src/session/commands/use-session-commands.tsx index 2c67c986c73..88cfb0901dc 100644 --- a/packages/app/src/session/commands/use-session-commands.tsx +++ b/packages/app/src/session/commands/use-session-commands.tsx @@ -194,7 +194,7 @@ 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.new() if (terminal.all().length === 0) terminal.requestFocus() } diff --git a/packages/app/src/session/terminal/context.tsx b/packages/app/src/session/terminal/context.tsx index 3bd7aa97867..5938438fd66 100644 --- a/packages/app/src/session/terminal/context.tsx +++ b/packages/app/src/session/terminal/context.tsx @@ -244,9 +244,9 @@ function createWorkspaceTerminalSession( setStore("all", []) }) }, - new(options?: { focus?: boolean }) { + new() { const nextNumber = pickNextTerminalNumber() - const focusRequest = options?.focus ? requestFocus(undefined, true) : undefined + const focusRequest = requestFocus(undefined, true) const doCreate = async () => { return serverSDK.api.pty.create({ location, title: defaultTitle(nextNumber) }).then((result) => result.data) @@ -255,7 +255,7 @@ function createWorkspaceTerminalSession( .then((data) => { const id = data?.id if (!id) { - if (focusRequest !== undefined) cancelFocus(focusRequest) + cancelFocus(focusRequest) return } const newTerminal = { @@ -266,13 +266,13 @@ function createWorkspaceTerminalSession( batch(() => { setStore("all", store.all.length, newTerminal) setStore("active", id) - if (focusRequest !== undefined && ui.focus?.request === focusRequest) { + if (ui.focus?.request === focusRequest) { setUi("focus", { request: focusRequest, id, pending: false }) } }) }) .catch((error: unknown) => { - if (focusRequest !== undefined) cancelFocus(focusRequest) + cancelFocus(focusRequest) console.error("Failed to create terminal", error) }) }, @@ -440,7 +440,7 @@ export const { use: useTerminal, provider: TerminalProvider } = createSimpleCont ready: () => workspace().ready(), all: () => workspace().all(), active: () => workspace().active(), - new: (options?: { focus?: boolean }) => workspace().new(options), + new: () => workspace().new(), update: (pty: Partial & { id: string }) => workspace().update(pty), trim: (id: string) => workspace().trim(id), trimAll: () => workspace().trimAll(), diff --git a/packages/app/src/session/terminal/panel.tsx b/packages/app/src/session/terminal/panel.tsx index a265f3ee5e8..43d547fe9f9 100644 --- a/packages/app/src/session/terminal/panel.tsx +++ b/packages/app/src/session/terminal/panel.tsx @@ -330,7 +330,7 @@ export function TerminalPanel( } variant="ghost" - onClick={() => terminal.new({ focus: true })} + onClick={() => terminal.new()} aria-label={language.t("command.terminal.new")} />