diff --git a/packages/app/src/session/composer/controller.ts b/packages/app/src/session/composer/controller.ts index 3160b8ee3a20..8b6a460a1238 100644 --- a/packages/app/src/session/composer/controller.ts +++ b/packages/app/src/session/composer/controller.ts @@ -62,8 +62,14 @@ export function createSessionComposerController(input: { if (!editor?.isConnected || !region.showComposer() || region.child() || dialog.active) return const active = document.activeElement - // A control chosen while the session was loading owns focus now. - if (active && active !== document.body && active !== editor && !active.matches("[data-titlebar-tab-link]")) + // A control chosen while the session was loading owns focus now. The tab link that opened the session + // passes focus on, unless it sits in a dialog, such as the mobile tabs drawer reopened before the composer. + if ( + active && + active !== document.body && + active !== editor && + (!active.matches("[data-titlebar-tab-link]") || active.closest('[role="dialog"]')) + ) return editor.focus({ preventScroll: true }) setCursorPosition(editor, adapter.state.cursor() ?? promptLength(adapter.state.current()))