Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/chatSessions/common.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
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 { Schemas } from '../../../../../base/common/network.js';
7
import { EditorInput } from '../../../../common/editor/editorInput.js';
8
import { IChatSessionItem, IChatSessionItemProvider } from '../../common/chatSessionsService.js';
9
import { ChatSessionUri } from '../../common/chatUri.js';
10
import { ChatEditorInput } from '../chatEditorInput.js';
11
12
export type ChatSessionItemWithProvider = IChatSessionItem & {
13
readonly provider: IChatSessionItemProvider;
14
relativeTime?: string;
15
relativeTimeFullWord?: string;
16
hideRelativeTime?: boolean;
17
timing?: {
18
startTime: number;
19
};
20
};
21
22
export function isChatSession(editor?: EditorInput): boolean {
23
if (!(editor instanceof ChatEditorInput)) {
24
return false;
25
}
26
27
if (editor.resource?.scheme !== 'vscode-chat-editor' && editor.resource?.scheme !== 'vscode-chat-session') {
28
return false;
29
}
30
31
if (editor.options.ignoreInView) {
32
return false;
33
}
34
35
return true;
36
}
37
38
/**
39
* Returns chat session type from a URI, or 'local' if not specified or cannot be determined.
40
*/
41
export function getChatSessionType(editor: ChatEditorInput): string {
42
if (!editor.resource) {
43
return 'local';
44
}
45
46
const { scheme, query } = editor.resource;
47
48
if (scheme === Schemas.vscodeChatSession) {
49
const parsed = ChatSessionUri.parse(editor.resource);
50
if (parsed) {
51
return parsed.chatSessionType;
52
}
53
}
54
55
const sessionTypeFromQuery = new URLSearchParams(query).get('chatSessionType');
56
if (sessionTypeFromQuery) {
57
return sessionTypeFromQuery;
58
}
59
60
// Default to 'local' for vscode-chat-editor scheme or when type cannot be determined
61
return 'local';
62
}
63
64