chatUri.ts ×8

Frontier kind: Code frontier

unlabeled · c_23c6f92096a2

1107 tests · 7080 LOC · 35 files · introduces 0 tests · 49 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges49 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
863 ranges7080 lines · 35 files · Browse complete extent
All tests (intent)
1107 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: 49 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatUri.ts 49 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatUri.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 { encodeBase64, VSBuffer, decodeBase64 } from '../../../../../base/common/buffer.js';
7 > import { Schemas } from '../../../../../base/common/network.js';
8 > import { URI } from '../../../../../base/common/uri.js';
9 > import { localChatSessionType } from '../chatSessionsService.js';
10 >
11 > type ChatSessionIdentifier = {
12 > readonly chatSessionType: string;
13 > readonly sessionId: string;
14 > };
15 >
16 >
17 > export namespace LocalChatSessionUri {
18 >
19 > export const scheme = Schemas.vscodeLocalChatSession;
20 >
21 > export function forSession(sessionId: string): URI {
22 const encodedId = encodeBase64(VSBuffer.wrap(new TextEncoder().encode(sessionId)), false, true);
23 return URI.from({ scheme, authority: localChatSessionType, path: '/' + encodedId });
24 }
25 > chatUri.ts
26 > export function getNewSessionUri(): URI {
27 const handle = Math.floor(Math.random() * 1e9);
28 return forSession(`chat-${handle}`);
29 }
30 > chatUri.ts
31 > export function parseLocalSessionId(resource: URI): string | undefined {
32 const parsed = parse(resource);
33 return parsed?.chatSessionType === localChatSessionType ? parsed.sessionId : undefined;
34 }
35 > chatUri.ts
36 > export function isLocalSession(resource: URI): boolean {
37 return !!parseLocalSessionId(resource);
38 }
39 > chatUri.ts
40 > function parse(resource: URI): ChatSessionIdentifier | undefined {
41 if (resource.scheme !== scheme) {
42 return undefined;
56 return { chatSessionType, sessionId: new TextDecoder().decode(decodedSessionId.buffer) };
57 }
58 > } chatUri.ts
59 >
60 > /**
61 > * Converts a chat session resource URI to a string ID.
62 > *
63 > * This exists mainly for backwards compatibility with existing code that uses string IDs in telemetry and storage.
64 > */
65 > export function chatSessionResourceToId(resource: URI): string {
66 // If we have a local session, prefer using just the id part
67 const localId = LocalChatSessionUri.parseLocalSessionId(resource);
72 return resource.toString();
73 }
74 > chatUri.ts
75 > /**
76 > * Extracts the chat session type from a resource URI.
77 > *
78 > * @param resource - The chat session resource URI
79 > * @returns The session type string. Returns `localChatSessionType` for local sessions
80 > * (vscodeChatEditor and vscodeLocalChatSession schemes), or the scheme/authority
81 > * for contributed sessions.
82 > */
83 > export function getChatSessionType(resource: URI): string {
84 if (resource.scheme === Schemas.vscodeChatEditor) {
85 return localChatSessionType;
92 return resource.scheme;
93 }
94 > chatUri.ts
95 > export function isUntitledChatSession(resource: URI): boolean {
96 return resource.path.startsWith('/untitled-');
97 }