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

voice - support any focused code editor (including notebooks) #202733

Merged
merged 1 commit into from
Jan 18, 2024
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 @@ -662,8 +662,8 @@ class ChatTokenDeleter extends Disposable {
const change = e.changes[0];

// If this was a simple delete, try to find out whether it was inside a token
if (!change.text) {
parser.parseChatRequest(this.widget.viewModel!.sessionId, previousInputValue).then(previousParsedValue => {
if (!change.text && this.widget.viewModel) {
parser.parseChatRequest(this.widget.viewModel.sessionId, previousInputValue).then(previousParsedValue => {
// For dynamic variables, this has to happen in ChatDynamicVariableModel with the other bookkeeping
const deletableTokens = previousParsedValue.parts.filter(p => p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart || p instanceof ChatRequestSlashCommandPart || p instanceof ChatRequestVariablePart);
deletableTokens.forEach(token => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST, MENU_INLINE_CHAT_INPUT } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { ActiveEditorContext } from 'vs/workbench/common/contextkeys';
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
Expand All @@ -46,6 +44,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment } from 'vs/workbench/services/statusbar/browser/statusbar';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';

const CONTEXT_VOICE_CHAT_GETTING_READY = new RawContextKey<boolean>('voiceChatGettingReady', false, { type: 'boolean', description: localize('voiceChatGettingReady', "True when getting ready for receiving voice input from the microphone for voice chat.") });
const CONTEXT_VOICE_CHAT_IN_PROGRESS = new RawContextKey<boolean>('voiceChatInProgress', false, { type: 'boolean', description: localize('voiceChatInProgress', "True when voice recording from microphone is in progress for voice chat.") });
Expand Down Expand Up @@ -84,7 +83,7 @@ class VoiceChatSessionControllerFactory {
const chatService = accessor.get(IChatService);
const viewsService = accessor.get(IViewsService);
const chatContributionService = accessor.get(IChatContributionService);
const editorService = accessor.get(IEditorService);
const codeEditorService = accessor.get(ICodeEditorService);
const quickChatService = accessor.get(IQuickChatService);
const layoutService = accessor.get(IWorkbenchLayoutService);

Expand Down Expand Up @@ -114,7 +113,7 @@ class VoiceChatSessionControllerFactory {
}

// Try with the inline chat
const activeCodeEditor = getCodeEditor(editorService.activeTextEditorControl);
const activeCodeEditor = codeEditorService.getFocusedCodeEditor();
if (activeCodeEditor) {
const inlineChat = InlineChatController.get(activeCodeEditor);
if (inlineChat?.hasFocus()) {
Expand All @@ -136,7 +135,7 @@ class VoiceChatSessionControllerFactory {

// Inline Chat
if (context === 'inline') {
const activeCodeEditor = getCodeEditor(editorService.activeTextEditorControl);
const activeCodeEditor = codeEditorService.getFocusedCodeEditor();
if (activeCodeEditor) {
const inlineChat = InlineChatController.get(activeCodeEditor);
if (inlineChat) {
Expand Down Expand Up @@ -772,7 +771,8 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
@IConfigurationService private readonly configurationService: IConfigurationService,
@ICommandService private readonly commandService: ICommandService,
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
@IInstantiationService instantiationService: IInstantiationService
@IInstantiationService instantiationService: IInstantiationService,
@ICodeEditorService private readonly codeEditorService: ICodeEditorService
) {
super();

Expand Down Expand Up @@ -879,7 +879,9 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
case KeywordActivationContribution.SETTINGS_VALUE.QUICK_CHAT:
return QuickVoiceChatAction.ID;
case KeywordActivationContribution.SETTINGS_VALUE.CHAT_IN_CONTEXT:
return StartVoiceChatAction.ID;
if (this.codeEditorService.getFocusedCodeEditor()) {
return InlineVoiceChatAction.ID;
}
default:
return VoiceChatInChatViewAction.ID;
}
Expand Down