Skip to content

Commit 6bfc5e1

Browse files
authored
Merge branch 'main' into merogge/stream
2 parents e14f190 + 4df44cf commit 6bfc5e1

39 files changed

+494
-152
lines changed

build/azure-pipelines/publish-types/update-types.js

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/azure-pipelines/publish-types/update-types.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@ try {
1414
.toString()
1515
.trim();
1616

17+
const [major, minor] = tag.split('.');
18+
const shorttag = `${major}.${minor}`;
19+
1720
const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vscode-dts/vscode.d.ts`;
18-
const outPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts');
19-
cp.execSync(`curl ${dtsUri} --output ${outPath}`);
21+
const outDtsPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts');
22+
cp.execSync(`curl ${dtsUri} --output ${outDtsPath}`);
23+
24+
updateDTSFile(outDtsPath, shorttag);
2025

21-
updateDTSFile(outPath, tag);
26+
const outPackageJsonPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/package.json');
27+
const packageJson = JSON.parse(fs.readFileSync(outPackageJsonPath, 'utf-8'));
28+
packageJson.version = shorttag + '.9999';
29+
fs.writeFileSync(outPackageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
2230

23-
console.log(`Done updating vscode.d.ts at ${outPath}`);
31+
console.log(`Done updating vscode.d.ts at ${outDtsPath} and package.json to version ${packageJson.version}`);
2432
} catch (err) {
2533
console.error(err);
2634
console.error('Failed to update types');
2735
process.exit(1);
2836
}
2937

30-
function updateDTSFile(outPath: string, tag: string) {
38+
function updateDTSFile(outPath: string, shorttag: string) {
3139
const oldContent = fs.readFileSync(outPath, 'utf-8');
32-
const newContent = getNewFileContent(oldContent, tag);
40+
const newContent = getNewFileContent(oldContent, shorttag);
3341

3442
fs.writeFileSync(outPath, newContent);
3543
}
@@ -46,21 +54,18 @@ function convertTabsToSpaces(str: string): string {
4654
return str.replace(/\t/gm, value => repeat(' ', value.length));
4755
}
4856

49-
function getNewFileContent(content: string, tag: string) {
57+
function getNewFileContent(content: string, shorttag: string) {
5058
const oldheader = [
5159
`/*---------------------------------------------------------------------------------------------`,
5260
` * Copyright (c) Microsoft Corporation. All rights reserved.`,
5361
` * Licensed under the MIT License. See License.txt in the project root for license information.`,
5462
` *--------------------------------------------------------------------------------------------*/`
5563
].join('\n');
5664

57-
return convertTabsToSpaces(getNewFileHeader(tag) + content.slice(oldheader.length));
65+
return convertTabsToSpaces(getNewFileHeader(shorttag) + content.slice(oldheader.length));
5866
}
5967

60-
function getNewFileHeader(tag: string) {
61-
const [major, minor] = tag.split('.');
62-
const shorttag = `${major}.${minor}`;
63-
68+
function getNewFileHeader(shorttag: string) {
6469
const header = [
6570
`// Type definitions for Visual Studio Code ${shorttag}`,
6671
`// Project: https://github.com/microsoft/vscode`,

extensions/git/src/repository.ts

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,42 +1801,48 @@ export class Repository implements Disposable {
18011801

18021802
async createWorktree(options?: { path?: string; commitish?: string; branch?: string }): Promise<string> {
18031803
const defaultWorktreeRoot = this.globalState.get<string>(`${Repository.WORKTREE_ROOT_STORAGE_KEY}:${this.root}`);
1804-
let { path: worktreePath, commitish, branch } = options || {};
1805-
let worktreeName: string | undefined;
1804+
const config = workspace.getConfiguration('git', Uri.file(this.root));
1805+
const branchPrefix = config.get<string>('branchPrefix', '');
18061806

18071807
return await this.run(Operation.Worktree, async () => {
1808-
// Generate branch name if not provided
1809-
if (branch === undefined) {
1810-
const config = workspace.getConfiguration('git', Uri.file(this.root));
1811-
const branchPrefix = config.get<string>('branchPrefix', '');
1808+
let worktreeName: string | undefined;
1809+
let { path: worktreePath, commitish, branch } = options || {};
18121810

1813-
let worktreeName = await this.getRandomBranchName();
1811+
if (branch === undefined) {
1812+
// Generate branch name if not provided
1813+
worktreeName = await this.getRandomBranchName();
18141814
if (!worktreeName) {
18151815
// Fallback to timestamp-based name if random generation fails
18161816
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
18171817
worktreeName = `worktree-${timestamp}`;
18181818
}
1819-
18201819
branch = `${branchPrefix}${worktreeName}`;
1820+
1821+
// Append worktree name to provided path
1822+
if (worktreePath !== undefined) {
1823+
worktreePath = path.join(worktreePath, worktreeName);
1824+
}
1825+
} else {
1826+
// Extract worktree name from branch
1827+
worktreeName = branch.startsWith(branchPrefix)
1828+
? branch.substring(branchPrefix.length).replace(/\//g, '-')
1829+
: branch.replace(/\//g, '-');
18211830
}
18221831

1823-
// Generate path if not provided
18241832
if (worktreePath === undefined) {
18251833
worktreePath = defaultWorktreeRoot
1826-
? path.join(defaultWorktreeRoot, worktreeName!)
1827-
: path.join(path.dirname(this.root), `${path.basename(this.root)}.worktrees`, worktreeName!);
1828-
1829-
// Ensure that the worktree path is unique
1830-
if (this.worktrees.some(worktree => pathEquals(path.normalize(worktree.path), path.normalize(worktreePath!)))) {
1831-
let counter = 1;
1832-
let uniqueWorktreePath = `${worktreePath}-${counter}`;
1833-
while (this.worktrees.some(wt => pathEquals(path.normalize(wt.path), path.normalize(uniqueWorktreePath)))) {
1834-
counter++;
1835-
uniqueWorktreePath = `${worktreePath}-${counter}`;
1836-
}
1834+
? path.join(defaultWorktreeRoot, worktreeName)
1835+
: path.join(path.dirname(this.root), `${path.basename(this.root)}.worktrees`, worktreeName);
1836+
}
18371837

1838-
worktreePath = uniqueWorktreePath;
1839-
}
1838+
// Ensure that the worktree path is unique
1839+
if (this.worktrees.some(worktree => pathEquals(path.normalize(worktree.path), path.normalize(worktreePath!)))) {
1840+
let counter = 0, uniqueWorktreePath: string;
1841+
do {
1842+
uniqueWorktreePath = `${worktreePath}-${++counter}`;
1843+
} while (this.worktrees.some(wt => pathEquals(path.normalize(wt.path), path.normalize(uniqueWorktreePath))));
1844+
1845+
worktreePath = uniqueWorktreePath;
18401846
}
18411847

18421848
// Create the worktree
@@ -3047,6 +3053,7 @@ export class Repository implements Disposable {
30473053
}
30483054

30493055
const dictionaries: string[][] = [];
3056+
const branchPrefix = config.get<string>('branchPrefix', '');
30503057
const branchWhitespaceChar = config.get<string>('branchWhitespaceChar', '-');
30513058
const branchRandomNameDictionary = config.get<string[]>('branchRandomName.dictionary', ['adjectives', 'animals']);
30523059

@@ -3075,7 +3082,7 @@ export class Repository implements Disposable {
30753082
});
30763083

30773084
// Check for local ref conflict
3078-
const refs = await this.getRefs({ pattern: `refs/heads/${randomName}` });
3085+
const refs = await this.getRefs({ pattern: `refs/heads/${branchPrefix}${randomName}` });
30793086
if (refs.length === 0) {
30803087
return randomName;
30813088
}

src/vs/base/browser/dompurify/dompurify.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,4 +1354,3 @@ function createDOMPurify() {
13541354
var purify = createDOMPurify();
13551355

13561356
export { purify as default };
1357-
//# sourceMappingURL=purify.es.mjs.map

src/vs/base/common/marked/marked.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2479,4 +2479,3 @@ const parser = _Parser.parse;
24792479
const lexer = _Lexer.lex;
24802480

24812481
export { _Hooks as Hooks, _Lexer as Lexer, Marked, _Parser as Parser, _Renderer as Renderer, _TextRenderer as TextRenderer, _Tokenizer as Tokenizer, _defaults as defaults, _getDefaults as getDefaults, lexer, marked, options, parse, parseInline, parser, setOptions, use, walkTokens };
2482-
//# sourceMappingURL=marked.esm.js.map

src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ export class InlineEditsView extends Disposable {
264264
} | undefined = undefined;
265265

266266
private _getLongDistanceHintState(model: ModelPerInlineEdit, reader: IReader): ILongDistanceHint | undefined {
267+
if (model.inlineEdit.inlineCompletion.identity.jumpedTo.read(reader)) {
268+
return undefined;
269+
}
267270
if (this._currentInlineEditCache?.inlineSuggestionIdentity !== model.inlineEdit.inlineCompletion.identity) {
268271
this._currentInlineEditCache = {
269272
inlineSuggestionIdentity: model.inlineEdit.inlineCompletion.identity,

src/vs/workbench/api/browser/mainThreadMcp.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ export class MainThreadMcp extends Disposable implements MainThreadMcpShape {
179179
this._servers.get(id)?.pushMessage(message);
180180
}
181181

182+
async $getTokenForProviderId(id: number, providerId: string, scopes: string[], options: IMcpAuthenticationOptions = {}): Promise<string | undefined> {
183+
const server = this._serverDefinitions.get(id);
184+
if (!server) {
185+
return undefined;
186+
}
187+
return this._getSessionForProvider(server, providerId, scopes, undefined, options.errorOnUserInteraction);
188+
}
189+
182190
async $getTokenFromServerMetadata(id: number, authDetails: IMcpAuthenticationDetails, { errorOnUserInteraction, forceNewRegistration }: IMcpAuthenticationOptions = {}): Promise<string | undefined> {
183191
const server = this._serverDefinitions.get(id);
184192
if (!server) {
@@ -202,7 +210,18 @@ export class MainThreadMcp extends Disposable implements MainThreadMcpShape {
202210
}
203211
providerId = provider.id;
204212
}
205-
const sessions = await this._authenticationService.getSessions(providerId, resolvedScopes, { authorizationServer: authorizationServer }, true);
213+
214+
return this._getSessionForProvider(server, providerId, resolvedScopes, authorizationServer, errorOnUserInteraction);
215+
}
216+
217+
private async _getSessionForProvider(
218+
server: McpServerDefinition,
219+
providerId: string,
220+
scopes: string[],
221+
authorizationServer?: URI,
222+
errorOnUserInteraction: boolean = false
223+
): Promise<string | undefined> {
224+
const sessions = await this._authenticationService.getSessions(providerId, scopes, { authorizationServer }, true);
206225
const accountNamePreference = this.authenticationMcpServersService.getAccountPreference(server.id, providerId);
207226
let matchingAccountPreferenceSession: AuthenticationSession | undefined;
208227
if (accountNamePreference) {
@@ -213,12 +232,12 @@ export class MainThreadMcp extends Disposable implements MainThreadMcpShape {
213232
if (sessions.length) {
214233
// If we have an existing session preference, use that. If not, we'll return any valid session at the end of this function.
215234
if (matchingAccountPreferenceSession && this.authenticationMCPServerAccessService.isAccessAllowed(providerId, matchingAccountPreferenceSession.account.label, server.id)) {
216-
this.authenticationMCPServerUsageService.addAccountUsage(providerId, matchingAccountPreferenceSession.account.label, resolvedScopes, server.id, server.label);
235+
this.authenticationMCPServerUsageService.addAccountUsage(providerId, matchingAccountPreferenceSession.account.label, scopes, server.id, server.label);
217236
return matchingAccountPreferenceSession.accessToken;
218237
}
219238
// If we only have one account for a single auth provider, lets just check if it's allowed and return it if it is.
220239
if (!provider.supportsMultipleAccounts && this.authenticationMCPServerAccessService.isAccessAllowed(providerId, sessions[0].account.label, server.id)) {
221-
this.authenticationMCPServerUsageService.addAccountUsage(providerId, sessions[0].account.label, resolvedScopes, server.id, server.label);
240+
this.authenticationMCPServerUsageService.addAccountUsage(providerId, sessions[0].account.label, scopes, server.id, server.label);
222241
return sessions[0].accessToken;
223242
}
224243
}
@@ -237,7 +256,7 @@ export class MainThreadMcp extends Disposable implements MainThreadMcpShape {
237256
throw new UserInteractionRequiredError('authentication');
238257
}
239258
session = provider.supportsMultipleAccounts
240-
? await this.authenticationMcpServersService.selectSession(providerId, server.id, server.label, resolvedScopes, sessions)
259+
? await this.authenticationMcpServersService.selectSession(providerId, server.id, server.label, scopes, sessions)
241260
: sessions[0];
242261
}
243262
else {
@@ -248,7 +267,7 @@ export class MainThreadMcp extends Disposable implements MainThreadMcpShape {
248267
do {
249268
session = await this._authenticationService.createSession(
250269
providerId,
251-
resolvedScopes,
270+
scopes,
252271
{
253272
activateImmediate: true,
254273
account: accountToCreate,
@@ -263,7 +282,7 @@ export class MainThreadMcp extends Disposable implements MainThreadMcpShape {
263282

264283
this.authenticationMCPServerAccessService.updateAllowedMcpServers(providerId, session.account.label, [{ id: server.id, name: server.label, allowed: true }]);
265284
this.authenticationMcpServersService.updateAccountPreference(server.id, providerId, session.account);
266-
this.authenticationMCPServerUsageService.addAccountUsage(providerId, session.account.label, resolvedScopes, server.id, server.label);
285+
this.authenticationMCPServerUsageService.addAccountUsage(providerId, session.account.label, scopes, server.id, server.label);
267286
return session.accessToken;
268287
}
269288

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,7 @@ export interface MainThreadMcpShape {
31253125
$upsertMcpCollection(collection: McpCollectionDefinition.FromExtHost, servers: McpServerDefinition.Serialized[]): void;
31263126
$deleteMcpCollection(collectionId: string): void;
31273127
$getTokenFromServerMetadata(id: number, authDetails: IMcpAuthenticationDetails, options?: IMcpAuthenticationOptions): Promise<string | undefined>;
3128+
$getTokenForProviderId(id: number, providerId: string, scopes: string[], options?: IMcpAuthenticationOptions): Promise<string | undefined>;
31283129
}
31293130

31303131
export interface MainThreadDataChannelsShape extends IDisposable {

src/vs/workbench/api/common/extHostMcp.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import product from '../../../platform/product/common/product.js';
2020
import { StorageScope } from '../../../platform/storage/common/storage.js';
2121
import { extensionPrefixedIdentifier, McpCollectionDefinition, McpConnectionState, McpServerDefinition, McpServerLaunch, McpServerStaticMetadata, McpServerStaticToolAvailability, McpServerTransportHTTP, McpServerTransportType, UserInteractionRequiredError } from '../../contrib/mcp/common/mcpTypes.js';
2222
import { MCP } from '../../contrib/mcp/common/modelContextProtocol.js';
23-
import { isProposedApiEnabled } from '../../services/extensions/common/extensions.js';
23+
import { checkProposedApiEnabled, isProposedApiEnabled } from '../../services/extensions/common/extensions.js';
2424
import { ExtHostMcpShape, IMcpAuthenticationDetails, IStartMcpOptions, MainContext, MainThreadMcpShape } from './extHost.protocol.js';
2525
import { IExtHostInitDataService } from './extHostInitDataService.js';
2626
import { IExtHostRpcService } from './extHostRpcService.js';
@@ -45,6 +45,10 @@ const serverDataValidation = vObj({
4545
availability: vNumber(),
4646
definition: vObjAny(),
4747
}))),
48+
})),
49+
authentication: vOptionalProp(vObj({
50+
providerId: vString(),
51+
scopes: vArray(vString()),
4852
}))
4953
});
5054

@@ -165,6 +169,9 @@ export class ExtHostMcpService extends Disposable implements IExtHostMpcService
165169
}
166170

167171
serverDataValidation.validateOrThrow(item);
172+
if ((item as vscode.McpHttpServerDefinition2).authentication) {
173+
checkProposedApiEnabled(extension, 'mcpToolDefinitions');
174+
}
168175

169176
let staticMetadata: McpServerStaticMetadata | undefined;
170177
const castAs2 = item as McpStdioServerDefinition | McpHttpServerDefinition;
@@ -710,6 +717,30 @@ export class McpHTTPHandle extends Disposable {
710717
this._log(LogLevel.Warning, `Error getting token from server metadata: ${String(e)}`);
711718
}
712719
}
720+
if (this._launch.authentication) {
721+
try {
722+
this._log(LogLevel.Debug, `Using provided authentication config: providerId=${this._launch.authentication.providerId}, scopes=${this._launch.authentication.scopes.join(', ')}`);
723+
const token = await this._proxy.$getTokenForProviderId(
724+
this._id,
725+
this._launch.authentication.providerId,
726+
this._launch.authentication.scopes,
727+
{
728+
errorOnUserInteraction: this._errorOnUserInteraction,
729+
forceNewRegistration
730+
}
731+
);
732+
if (token) {
733+
headers['Authorization'] = `Bearer ${token}`;
734+
this._log(LogLevel.Info, 'Successfully obtained token from provided authentication config');
735+
}
736+
} catch (e) {
737+
if (UserInteractionRequiredError.is(e)) {
738+
this._proxy.$onDidChangeState(this._id, { state: McpConnectionState.Kind.Stopped, reason: 'needs-user-interaction' });
739+
throw new CancellationError();
740+
}
741+
this._log(LogLevel.Warning, `Error getting token from provided authentication config: ${String(e)}`);
742+
}
743+
}
713744
return headers;
714745
}
715746

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,10 @@ export namespace McpServerDefinition {
38253825
type: McpServerTransportType.HTTP,
38263826
uri: item.uri,
38273827
headers: Object.entries(item.headers),
3828+
authentication: (item as vscode.McpHttpServerDefinition2).authentication ? {
3829+
providerId: (item as vscode.McpHttpServerDefinition2).authentication!.providerId,
3830+
scopes: (item as vscode.McpHttpServerDefinition2).authentication!.scopes
3831+
} : undefined,
38283832
}
38293833
: {
38303834
type: McpServerTransportType.Stdio,

0 commit comments

Comments
 (0)