src/vs/platform/agentHost/node/agentHostRenameCommand.ts
82 LOC · 82 covered · 0 uncovered · 14 ranges · 1062 concepts · 10 introducers · 520 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
agentHostRenameCommand.ts ×3
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken } from '../../../base/common/cancellation.js';
import { localize } from '../../../nls.js';
import type { URI } from '../common/state/protocol/common/state.js';
import { CompletionItem, CompletionItemKind, CompletionsParams } from '../common/state/protocol/commands.js';
import { MessageAttachmentKind } from '../common/state/protocol/state.js';
import { toCommandCompletionAttachmentMeta } from '../common/meta/agentCompletionAttachmentMeta.js';
import { CompletionTriggerCharacter, IAgentHostCompletionItemProvider } from './agentHostCompletions.js';
import { extractLeadingSlashToken, matchesSlashCompletion } from './agentHostSlashCompletion.js';
/** The generic, agent-agnostic `/rename` slash command name. */
export const RENAME_SLASH_COMMAND = 'rename';
/**
* Parses a leading `/rename [title]` command at the very start of `prompt`.
*
* Mirrors `parseLeadingSlashCommand` (the Copilot CLI slash parser): the
* command must be `/rename`, followed either by end-of-input or at least one
* whitespace character. `/renamed`, `/rename-foo`, or a leading-space
* `/rename` all return `undefined`. Match is case-sensitive.
*
* Returns the trimmed new title (possibly an empty string when no title is
* supplied) when the prompt is a rename command, or `undefined` when it is not.
* Callers MUST distinguish "not a rename command" (`undefined`) from "rename
* with empty title" (`''`).
*/
export function parseRenameCommand(prompt: string): string | undefined {
if (!match) {
}
}
/**
* Generic completion provider that contributes the `/rename` slash command
* for every agent-host session type. Unlike agent-specific slash commands
* (e.g. Copilot's `/compact`), `/rename` is not forwarded to any agent SDK;
* it is intercepted in the agent-host send path and redirected to a
* `SessionTitleChanged` action (see the rename handling in `AgentSideEffects`).
*
* The completion is only offered for sessions that already have history —
* renaming a session before the first turn has no meaningful target.
*/
export class AgentHostRenameCompletionProvider implements IAgentHostCompletionItemProvider {
readonly kinds: ReadonlySet<CompletionItemKind> = new Set([CompletionItemKind.UserMessage]);
readonly triggerCharacters = [CompletionTriggerCharacter.Slash] as const;
constructor(private readonly _hasHistory: (session: URI) => boolean) { }
async provideCompletionItems(params: CompletionsParams, _token: CancellationToken): Promise<readonly CompletionItem[]> {
const leading = extractLeadingSlashToken(params.text, params.offset);
agentHostRenameCommand.ts ×2
if (!leading) {
}
}
const typed = leading.typed;
if (!matchesSlashCompletion(typed, RENAME_SLASH_COMMAND)) {
}
insertText: '/' + RENAME_SLASH_COMMAND + ' ',
rangeStart: leading.rangeStart,
rangeEnd: leading.rangeEnd,
attachment: {
type: MessageAttachmentKind.Simple,
label: '/' + RENAME_SLASH_COMMAND,
_meta: toCommandCompletionAttachmentMeta({
command: RENAME_SLASH_COMMAND,
description: localize('agentHostSlashCommand.rename.description', "Rename this chat"),
}),
},
}];