Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { ChatViewId, IChatWidget, IChatWidgetService, showChatView, showCopilotV
import { IChatEditorOptions } from '../chatEditor.js';
import { ChatEditorInput, shouldShowClearEditingSessionConfirmation, showClearEditingSessionConfirmation } from '../chatEditorInput.js';
import { VIEWLET_ID } from '../chatSessions.js';
import { getChatSessionType } from '../chatSessions/common.js';
import { ChatViewPane } from '../chatViewPane.js';
import { convertBufferToScreenshotVariable } from '../contrib/screenshot.js';
import { clearChatEditor } from './chatClear.js';
Expand Down Expand Up @@ -975,7 +976,24 @@ export function registerChatActions() {

async run(accessor: ServicesAccessor) {
const editorService = accessor.get(IEditorService);
await editorService.openEditor({ resource: ChatEditorInput.getNewEditorUri(), options: { pinned: true } satisfies IChatEditorOptions });

// Try to get the current editor to inherit provider type
const activeEditor = editorService.activeEditor;
let chatSessionType: string | undefined;
if (activeEditor instanceof ChatEditorInput) {
const sessionType = getChatSessionType(activeEditor);
if (sessionType !== 'local') {
chatSessionType = sessionType;
}
}

await editorService.openEditor({
resource: ChatEditorInput.getNewEditorUri(),
options: {
pinned: true,
chatSessionType
} satisfies IChatEditorOptions
});
}
});

Expand All @@ -991,18 +1009,31 @@ export function registerChatActions() {
id: MenuId.ViewTitle,
group: 'submenu',
order: 1,
when: ContextKeyExpr.equals('view', `${VIEWLET_ID}.local`),
when: ContextKeyExpr.regex('view', new RegExp(`^${VIEWLET_ID.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.`)),
}
});
}

async run(accessor: ServicesAccessor) {
const editorService = accessor.get(IEditorService);
const contextKeyService = accessor.get(IContextKeyService);

// Get the provider type from the current view context
const currentView = contextKeyService.getContextKeyValue<string>('view');
let chatSessionType: string | undefined;
if (currentView && currentView.startsWith(`${VIEWLET_ID}.`)) {
const providerType = currentView.substring(`${VIEWLET_ID}.`.length);
if (providerType !== 'local') {
chatSessionType = providerType;
}
}

await editorService.openEditor({
resource: ChatEditorInput.getNewEditorUri(),
options: {
pinned: true,
auxiliary: { compact: false }
auxiliary: { compact: false },
chatSessionType
} satisfies IChatEditorOptions
}, AUX_WINDOW_GROUP);
}
Expand All @@ -1020,7 +1051,7 @@ export function registerChatActions() {
id: MenuId.ViewTitle,
group: 'submenu',
order: 1,
when: ContextKeyExpr.equals('view', `${VIEWLET_ID}.local`),
when: ContextKeyExpr.regex('view', new RegExp(`^${VIEWLET_ID.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.`)),
}
});
}
Expand Down Expand Up @@ -1056,22 +1087,39 @@ export function registerChatActions() {
id: MenuId.ViewTitle,
group: 'submenu',
order: 1,
when: ContextKeyExpr.equals('view', `${VIEWLET_ID}.local`),
when: ContextKeyExpr.regex('view', new RegExp(`^${VIEWLET_ID.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.`)),
}
});
}

async run(accessor: ServicesAccessor, ...args: any[]) {
const editorService = accessor.get(IEditorService);
const editorGroupService = accessor.get(IEditorGroupsService);
const contextKeyService = accessor.get(IContextKeyService);

// Get the provider type from the current view context
const currentView = contextKeyService.getContextKeyValue<string>('view');
let chatSessionType: string | undefined;
if (currentView && currentView.startsWith(`${VIEWLET_ID}.`)) {
const providerType = currentView.substring(`${VIEWLET_ID}.`.length);
if (providerType !== 'local') {
chatSessionType = providerType;
}
}

// Create a new editor group to the right
const newGroup = editorGroupService.addGroup(editorGroupService.activeGroup, GroupDirection.RIGHT);
editorGroupService.activateGroup(newGroup);

// Open a new chat editor in the new group
await editorService.openEditor(
{ resource: ChatEditorInput.getNewEditorUri(), options: { pinned: true } },
{
resource: ChatEditorInput.getNewEditorUri(),
options: {
pinned: true,
chatSessionType
}
},
newGroup.id
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1777,5 +1777,5 @@ MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
},
group: 'navigation',
order: 1,
when: ContextKeyExpr.equals('view', `${VIEWLET_ID}.local`),
when: ContextKeyExpr.regex('view', new RegExp(`^${VIEWLET_ID.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.`)),
});