Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "Open session in editor/sidebar" useful even when there is no session to move #184463

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInp
import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane';
import { CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService';
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';

Expand Down Expand Up @@ -68,6 +69,11 @@ async function moveToSidebar(accessor: ServicesAccessor): Promise<void> {
const viewId = chatContribService.getViewIdForProvider(chatEditorInput.providerId);
const view = await viewsService.openView(viewId) as ChatViewPane;
view.loadSession(chatEditorInput.sessionId);
} else {
const chatService = accessor.get(IChatService);
const providerId = chatService.getProviderInfos()[0].id;
const viewId = chatContribService.getViewIdForProvider(providerId);
await viewsService.openView(viewId);
}
}

Expand All @@ -90,9 +96,12 @@ export function registerMoveActions() {
const widgetService = accessor.get(IChatWidgetService);
const viewService = accessor.get(IViewsService);
const editorService = accessor.get(IEditorService);
const chatService = accessor.get(IChatService);

const widget = widgetService.lastFocusedWidget;
if (!widget || !('viewId' in widget.viewContext)) {
const providerId = chatService.getProviderInfos()[0].id;
await editorService.openEditor({ resource: ChatEditorInput.getNewEditorUri(), options: <IChatEditorOptions>{ target: { providerId }, pinned: true } });
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/chat/common/chatServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class ChatService extends Disposable implements IChatService {
this.trace('onWillSaveState', `Persisting ${allSessions.length} sessions`);

const serialized = JSON.stringify(allSessions);
this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
}

Expand Down