Path: blob/main/src/vs/workbench/contrib/chat/browser/chatSessions/common.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Schemas } from '../../../../../base/common/network.js';6import { EditorInput } from '../../../../common/editor/editorInput.js';7import { IChatSessionItem, IChatSessionItemProvider } from '../../common/chatSessionsService.js';8import { ChatSessionUri } from '../../common/chatUri.js';9import { ChatEditorInput } from '../chatEditorInput.js';1011export type ChatSessionItemWithProvider = IChatSessionItem & {12readonly provider: IChatSessionItemProvider;13relativeTime?: string;14relativeTimeFullWord?: string;15hideRelativeTime?: boolean;16timing?: {17startTime: number;18};19};2021export function isChatSession(editor?: EditorInput): boolean {22if (!(editor instanceof ChatEditorInput)) {23return false;24}2526if (editor.resource?.scheme !== 'vscode-chat-editor' && editor.resource?.scheme !== 'vscode-chat-session') {27return false;28}2930if (editor.options.ignoreInView) {31return false;32}3334return true;35}3637/**38* Returns chat session type from a URI, or 'local' if not specified or cannot be determined.39*/40export function getChatSessionType(editor: ChatEditorInput): string {41if (!editor.resource) {42return 'local';43}4445const { scheme, query } = editor.resource;4647if (scheme === Schemas.vscodeChatSession) {48const parsed = ChatSessionUri.parse(editor.resource);49if (parsed) {50return parsed.chatSessionType;51}52}5354const sessionTypeFromQuery = new URLSearchParams(query).get('chatSessionType');55if (sessionTypeFromQuery) {56return sessionTypeFromQuery;57}5859// Default to 'local' for vscode-chat-editor scheme or when type cannot be determined60return 'local';61}626364