This repository was archived by the owner on May 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathchatSessionMetadataStore.ts
More file actions
92 lines (82 loc) · 4.04 KB
/
chatSessionMetadataStore.ts
File metadata and controls
92 lines (82 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type * as vscode from 'vscode';
import type { Uri } from 'vscode';
import { createServiceIdentifier } from '../../../util/common/services';
import { ChatSessionWorktreeProperties } from './chatSessionWorktreeService';
import type { IWorkspaceInfo } from './workspaceInfo';
export interface WorkspaceFolderEntry {
readonly folderPath: string;
readonly repositoryPath?: string;
readonly timestamp: number;
}
/**
* Serializable subset of ChatRequestModeInstructions (excludes toolReferences).
*/
export interface StoredModeInstructions {
readonly uri?: string;
readonly name: string;
readonly content: string;
readonly metadata?: Record<string, boolean | string | number>;
readonly isBuiltin?: boolean;
}
export interface RequestDetails {
/** VS Code request ID — always available, serves as primary key. */
readonly vscodeRequestId: string;
/** Copilot SDK request ID — may not be available until the request completes. */
copilotRequestId?: string;
/**
* Map of tool call id to VS Code edit id, used to correlate edits to the tool call that created them.
*/
toolIdEditMap: { [copilotToolId: string]: string };
/**
* @deprecated This field is deprecated in favor of modeInstructions.
* Agent used for this request.
* */
agentId?: string;
/** Mode instructions for this request (excluding toolReferences). */
modeInstructions?: StoredModeInstructions;
/** Checkpoint reference for this request. */
checkpointRef?: string;
}
export interface ChatSessionMetadataFile {
worktreeProperties?: ChatSessionWorktreeProperties;
workspaceFolder?: WorkspaceFolderEntry;
additionalWorkspaces?: {
worktreeProperties?: ChatSessionWorktreeProperties;
workspaceFolder?: WorkspaceFolderEntry;
}[];
/**
* Whether the session metadata has been written to the Copilot CLI session state directory.
*/
writtenToDisc?: boolean;
/** The first user message sent in the session, used as the session label. */
firstUserMessage?: string;
/** Custom title set by the user or generated for the session. */
customTitle?: string;
}
export const IChatSessionMetadataStore = createServiceIdentifier<IChatSessionMetadataStore>('IChatSessionMetadataStore');
export interface IChatSessionMetadataStore {
readonly _serviceBrand: undefined;
getMetadataFileUri(sessionId: string): vscode.Uri;
deleteSessionMetadata(sessionId: string): Promise<void>;
storeWorktreeInfo(sessionId: string, properties: ChatSessionWorktreeProperties): Promise<void>;
storeWorkspaceFolderInfo(sessionId: string, entry: WorkspaceFolderEntry): Promise<void>;
getSessionIdForWorktree(folder: vscode.Uri): Promise<string | undefined>;
getSessionIdForWorkspaceFolder(folder: vscode.Uri): Promise<string[]>;
getWorktreeProperties(sessionId: string): Promise<ChatSessionWorktreeProperties | undefined>;
getWorktreeProperties(folder: Uri): Promise<ChatSessionWorktreeProperties | undefined>;
getSessionWorkspaceFolder(sessionId: string): Promise<vscode.Uri | undefined>;
getSessionWorkspaceFolderEntry(sessionId: string): Promise<WorkspaceFolderEntry | undefined>;
getAdditionalWorkspaces(sessionId: string): Promise<IWorkspaceInfo[]>;
setAdditionalWorkspaces(sessionId: string, workspaces: IWorkspaceInfo[]): Promise<void>;
getSessionFirstUserMessage(sessionId: string): Promise<string | undefined>;
setSessionFirstUserMessage(sessionId: string, message: string): Promise<void>;
getCustomTitle(sessionId: string): Promise<string | undefined>;
setCustomTitle(sessionId: string, title: string): Promise<void>;
getRequestDetails(sessionId: string): Promise<RequestDetails[]>;
updateRequestDetails(sessionId: string, details: (Partial<RequestDetails> & { vscodeRequestId: string })[]): Promise<void>;
getSessionAgent(sessionId: string): Promise<string | undefined>;
}