agentHostRenameCommand.ts ×3

Frontier kind: Code frontier

unlabeled · c_e23bd81b8b9e

520 tests · 14091 LOC · 56 files · introduces 0 tests · 50 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges50 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1335 ranges14091 lines · 56 files · Browse complete extent
All tests (intent)
520 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 50 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostRenameCommand.ts 50 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostRenameCommand.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { CancellationToken } from '../../../base/common/cancellation.js';
7 > import { localize } from '../../../nls.js';
8 > import type { URI } from '../common/state/protocol/common/state.js';
9 > import { CompletionItem, CompletionItemKind, CompletionsParams } from '../common/state/protocol/commands.js';
10 > import { MessageAttachmentKind } from '../common/state/protocol/state.js';
11 > import { toCommandCompletionAttachmentMeta } from '../common/meta/agentCompletionAttachmentMeta.js';
12 > import { CompletionTriggerCharacter, IAgentHostCompletionItemProvider } from './agentHostCompletions.js';
13 > import { extractLeadingSlashToken, matchesSlashCompletion } from './agentHostSlashCompletion.js';
14 >
15 > /** The generic, agent-agnostic `/rename` slash command name. */
16 > export const RENAME_SLASH_COMMAND = 'rename';
17 >
18 > /**
19 > * Parses a leading `/rename [title]` command at the very start of `prompt`.
20 > *
21 > * Mirrors `parseLeadingSlashCommand` (the Copilot CLI slash parser): the
22 > * command must be `/rename`, followed either by end-of-input or at least one
23 > * whitespace character. `/renamed`, `/rename-foo`, or a leading-space
24 > * `/rename` all return `undefined`. Match is case-sensitive.
25 > *
26 > * Returns the trimmed new title (possibly an empty string when no title is
27 > * supplied) when the prompt is a rename command, or `undefined` when it is not.
28 > * Callers MUST distinguish "not a rename command" (`undefined`) from "rename
29 > * with empty title" (`''`).
30 > */
31 > export function parseRenameCommand(prompt: string): string | undefined {
32 const match = /^\/rename(?:$|\s+([\s\S]*))/.exec(prompt);
33 if (!match) {
36 return (match[1] ?? '').trim();
37 }
39 > /**
40 > * Generic completion provider that contributes the `/rename` slash command
41 > * for every agent-host session type. Unlike agent-specific slash commands
42 > * (e.g. Copilot's `/compact`), `/rename` is not forwarded to any agent SDK;
43 > * it is intercepted in the agent-host send path and redirected to a
44 > * `SessionTitleChanged` action (see the rename handling in `AgentSideEffects`).
45 > *
46 > * The completion is only offered for sessions that already have history —
47 > * renaming a session before the first turn has no meaningful target.
48 > */
49 > export class AgentHostRenameCompletionProvider implements IAgentHostCompletionItemProvider {
50 > readonly kinds: ReadonlySet<CompletionItemKind> = new Set([CompletionItemKind.UserMessage]);
51 > readonly triggerCharacters = [CompletionTriggerCharacter.Slash] as const;
52 >
53 > constructor(private readonly _hasHistory: (session: URI) => boolean) { }
54 >
55 > async provideCompletionItems(params: CompletionsParams, _token: CancellationToken): Promise<readonly CompletionItem[]> {
56 const leading = extractLeadingSlashToken(params.text, params.offset);
57 if (!leading) {