Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { IViewDescriptorService } from '../../../../workbench/common/views.js';
import { IViewPaneOptions, ViewPane } from '../../../../workbench/browser/parts/views/viewPane.js';
import { NewChatInputWidget } from './newChatInput.js';
import { IChatRequestVariableEntry } from '../../../../workbench/contrib/chat/common/attachments/chatVariableEntries.js';
import { ANY_AGENT_HOST_PROVIDER_RE } from '../../../common/agentHostSessionsProvider.js';

// #region --- New Chat In Session Widget ---

Expand Down Expand Up @@ -65,6 +66,10 @@ class NewChatInSessionWidget extends Disposable {
loading,
minEditorHeight: 64,
placeholder: localize('newChatInSessionPlaceholder', 'Ask a follow-up question or start a new topic within this session...'),
shouldExpandPromptSlashCommand: () => {
const providerId = this.sessionsManagementService.activeSession.get()?.providerId;
return !providerId || !ANY_AGENT_HOST_PROVIDER_RE.test(providerId);
},
}));
}

Expand Down
18 changes: 14 additions & 4 deletions src/vs/sessions/contrib/chat/browser/newChatInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ export class NewChatInputWidget extends Disposable implements IHistoryNavigation
loading: IObservable<boolean>;
minEditorHeight?: number;
placeholder?: string;
/**
* If provided and returns `false`, prompt/skill slash commands are sent
* verbatim instead of being expanded into a CLI-friendly markdown
* reference. Agent host sessions support slash commands natively, so
* the expansion should be skipped for them.
*/
shouldExpandPromptSlashCommand?: () => boolean;
},
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IModelService private readonly modelService: IModelService,
Expand Down Expand Up @@ -500,10 +507,13 @@ export class NewChatInputWidget extends Disposable implements IHistoryNavigation
return;
}

// Expand prompt/skill slash commands into a CLI-friendly reference
const expanded = this._slashCommandHandler?.tryExpandPromptSlashCommand(query);
if (expanded) {
query = expanded;
// Expand prompt/skill slash commands into a CLI-friendly reference,
// unless the target session natively supports slash commands.
if (this.options.shouldExpandPromptSlashCommand?.() ?? true) {
const expanded = this._slashCommandHandler?.tryExpandPromptSlashCommand(query);
if (expanded) {
query = expanded;
}
}

const attachedContext = this._contextAttachments.attachments.length > 0
Expand Down
8 changes: 8 additions & 0 deletions src/vs/sessions/contrib/chat/browser/newChatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { WorkspacePicker, IWorkspaceSelection } from './sessionWorkspacePicker.j
import { ScopedWorkspacePicker } from './scopedWorkspacePicker.js';
import { NewChatInputWidget } from './newChatInput.js';
import { IChatRequestVariableEntry } from '../../../../workbench/contrib/chat/common/attachments/chatVariableEntries.js';
import { ANY_AGENT_HOST_PROVIDER_RE } from '../../../common/agentHostSessionsProvider.js';

// #region --- New Chat Widget ---

Expand Down Expand Up @@ -71,6 +72,13 @@ class NewChatWidget extends Disposable {
sendRequest: async (text: string, attachedContext?: IChatRequestVariableEntry[]) => this._send(text, attachedContext),
canSendRequest,
loading,
shouldExpandPromptSlashCommand: () => {
// Mirror what `_send()` does: it sends to the current active
// session, which can lag behind the workspace picker selection
// while trust approval or session-type discovery is in flight.
const providerId = this.sessionsManagementService.activeSession.get()?.providerId;
return !providerId || !ANY_AGENT_HOST_PROVIDER_RE.test(providerId);
},
}));

this._register(this._workspacePicker.onDidSelectWorkspace(async workspace => {
Expand Down
Loading