mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 10:37:38 +01:00
agent sessions - focus chat if session opened from stacked view (#289120)
This commit is contained in:
@@ -29,7 +29,7 @@ import { IStyleOverride } from '../../../../../platform/theme/browser/defaultSty
|
||||
import { IAgentSessionsControl } from './agentSessions.js';
|
||||
import { HoverPosition } from '../../../../../base/browser/ui/hover/hoverWidget.js';
|
||||
import { URI } from '../../../../../base/common/uri.js';
|
||||
import { openSession } from './agentSessionsOpener.js';
|
||||
import { ISessionOpenOptions, openSession } from './agentSessionsOpener.js';
|
||||
import { IEditorService } from '../../../../services/editor/common/editorService.js';
|
||||
import { ChatEditorInput } from '../widgetHosts/editor/chatEditorInput.js';
|
||||
import { IMouseEvent } from '../../../../../base/browser/mouseEvent.js';
|
||||
@@ -43,6 +43,7 @@ export interface IAgentSessionsControlOptions extends IAgentSessionsSorterOption
|
||||
getHoverPosition(): HoverPosition;
|
||||
trackActiveEditorSession(): boolean;
|
||||
|
||||
overrideSessionOpenOptions?(openEvent: IOpenEvent<AgentSessionListItem | undefined>): ISessionOpenOptions;
|
||||
notifySessionOpened?(resource: URI, widget: IChatWidget): void;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,8 @@ export class AgentSessionsControl extends Disposable implements IAgentSessionsCo
|
||||
source: this.options.source
|
||||
});
|
||||
|
||||
const widget = await this.instantiationService.invokeFunction(openSession, element, e);
|
||||
const options = this.options.overrideSessionOpenOptions?.(e) ?? e;
|
||||
const widget = await this.instantiationService.invokeFunction(openSession, element, options);
|
||||
if (widget) {
|
||||
this.options.notifySessionOpened?.(element.resource, widget);
|
||||
}
|
||||
|
||||
@@ -408,6 +408,12 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
|
||||
trackActiveEditorSession: () => {
|
||||
return !this._widget || this._widget.isEmpty(); // only track and reveal if chat widget is empty
|
||||
},
|
||||
overrideSessionOpenOptions: openEvent => {
|
||||
if (this.sessionsViewerOrientation === AgentSessionsViewerOrientation.Stacked && !openEvent.sideBySide) {
|
||||
return { ...openEvent, editorOptions: { ...openEvent.editorOptions, preserveFocus: false /* focus the chat widget when opening from stacked sessions viewer since this closes the stacked viewer */ } };
|
||||
}
|
||||
return openEvent;
|
||||
},
|
||||
overrideCompare(sessionA: IAgentSession, sessionB: IAgentSession): number | undefined {
|
||||
|
||||
// When limited where only few sessions show, sort unread sessions to the top
|
||||
|
||||
Reference in New Issue
Block a user