Skip to content

Commit 09ec2df

Browse files
Focus console pane when changing foreground session (#7730)
Addresses #7522 Updated the command palette actions that cause the foreground session to change. This includes the duplicate session, create session, and select session actions. The focus is moved to the console before the new session is ready for a snappier experience. https://github.com/user-attachments/assets/d636a3f3-a616-4791-9a92-edbe1c7b8e0b ### Release Notes #### New Features - N/A #### Bug Fixes - Focus console pane when foreground session changes via the interpreter command palette actions ### QA Notes @:win @:sessions @:web
1 parent 66b0aac commit 09ec2df

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/vs/workbench/contrib/languageRuntime/browser/languageRuntimeActions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,13 +825,16 @@ export function registerLanguageRuntimeActions() {
825825

826826
registerLanguageRuntimeAction(LANGUAGE_RUNTIME_OPEN_ACTIVE_SESSIONS_ID, 'Session Selector', async accessor => {
827827
// Access services.
828+
const commandService = accessor.get(ICommandService);
828829
const runtimeSessionService = accessor.get(IRuntimeSessionService);
829830

830831
// Prompt the user to select a runtime to use.
831832
const newActiveSession = await selectLanguageRuntimeSession(accessor, { allowStartSession: true });
832833

833834
// If the user selected a specific session, set it as the active session if it still exists
834835
if (newActiveSession) {
836+
// Drive focus into the Positron console.
837+
commandService.executeCommand('workbench.panel.positronConsole.focus');
835838
runtimeSessionService.foregroundSession = newActiveSession;
836839
}
837840
});
@@ -874,6 +877,9 @@ export function registerLanguageRuntimeActions() {
874877
return;
875878
}
876879

880+
// Drive focus into the Positron console.
881+
commandService.executeCommand('workbench.panel.positronConsole.focus');
882+
877883
// Duplicate the current session with the `startNewRuntimeSession` method.
878884
await runtimeSessionService.startNewRuntimeSession(
879885
currentSession.runtimeMetadata.runtimeId,
@@ -910,13 +916,17 @@ export function registerLanguageRuntimeActions() {
910916

911917
async run(accessor: ServicesAccessor) {
912918
// Access services.
919+
const commandService = accessor.get(ICommandService);
913920
const runtimeSessionService = accessor.get(IRuntimeSessionService);
914921

915922
// Prompt the user to select a runtime to start
916923
const selectedRuntime = await selectNewLanguageRuntime(accessor);
917924

918925
// If the user selected a runtime, set it as the active runtime
919926
if (selectedRuntime?.runtimeId) {
927+
// Drive focus into the Positron console.
928+
commandService.executeCommand('workbench.panel.positronConsole.focus');
929+
920930
return await runtimeSessionService.startNewRuntimeSession(
921931
selectedRuntime.runtimeId,
922932
selectedRuntime.runtimeName,

src/vs/workbench/services/runtimeSession/common/runtimeSession.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,9 +1657,9 @@ export class RuntimeSessionService extends Disposable implements IRuntimeSession
16571657
// Save the new active session info.
16581658
const activeSession = new ActiveRuntimeSession(
16591659
session,
1660-
manager,
1660+
manager,
16611661
this._commandService,
1662-
this._logService,
1662+
this._logService,
16631663
this._openerService,
16641664
this._configurationService,
16651665
);
@@ -1669,8 +1669,8 @@ export class RuntimeSessionService extends Disposable implements IRuntimeSession
16691669
this._onDidReceiveRuntimeEventEmitter.fire(evt);
16701670
}));
16711671

1672-
// Forwad UI client to interested services once it's available
1673-
activeSession.register(activeSession.onUiClientStarted(uiClient => {
1672+
// Forward UI client to interested services once it's available
1673+
activeSession.register(activeSession.onUiClientStarted(uiClient => {
16741674
this._onDidStartUiClientEmitter.fire({ sessionId: session.sessionId, uiClient });
16751675
}));
16761676

0 commit comments

Comments
 (0)