Skip to content

Commit

Permalink
Rebase against the upstream cdfd702
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: cdfd702
  • Loading branch information
Eclipse Che Sync committed Jan 9, 2025
2 parents 8f89921 + cdfd702 commit 58dc03c
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 55 deletions.
2 changes: 1 addition & 1 deletion code/extensions/git/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
]
},
"view.workbench.scm.empty": {
"message": "In order to use Git features, you can open a folder containing a Git repository or clone from a URL.\n[Open Folder](command:vscode.openFolder)\n[Clone Repository](command:git.clone)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"message": "In order to use Git features, you can open a folder containing a Git repository or clone from a URL.\n[Open Folder](command:vscode.openFolder)\n[Clone Repository](command:git.cloneRecursive)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"comment": [
"{Locked='](command:vscode.openFolder'}",
"Do not translate the 'command:*' part inside of the '(..)'. It is an internal command syntax for VS Code",
Expand Down
32 changes: 22 additions & 10 deletions code/extensions/git/src/historyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
readonly onDidChangeHistoryItemRefs: Event<SourceControlHistoryItemRefsChangeEvent> = this._onDidChangeHistoryItemRefs.event;

private _HEAD: Branch | undefined;
private historyItemRefs: SourceControlHistoryItemRef[] = [];
private _historyItemRefs: SourceControlHistoryItemRef[] = [];

private historyItemDecorations = new Map<string, FileDecoration>();

Expand All @@ -112,6 +112,14 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
return;
}

// Refs (alphabetically)
const historyItemRefs = this.repository.refs
.map(ref => toSourceControlHistoryItemRef(this.repository, ref))
.sort((a, b) => a.id.localeCompare(b.id));

const delta = deltaHistoryItemRefs(this._historyItemRefs, historyItemRefs);
this._historyItemRefs = historyItemRefs;

let historyItemRefId = '';
let historyItemRefName = '';

Expand All @@ -130,8 +138,9 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
icon: new ThemeIcon('cloud')
} : undefined;

// Base - compute only if the branch has changed
// Base
if (this._HEAD?.name !== this.repository.HEAD.name) {
// Compute base if the branch has changed
const mergeBase = await this.resolveHEADMergeBase();

this._currentHistoryItemBaseRef = mergeBase &&
Expand All @@ -142,6 +151,17 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
revision: mergeBase.commit,
icon: new ThemeIcon('cloud')
} : undefined;
} else {
// Update base revision if it has changed
const mergeBaseModified = delta.modified
.find(ref => ref.id === this._currentHistoryItemBaseRef?.id);

if (this._currentHistoryItemBaseRef && mergeBaseModified) {
this._currentHistoryItemBaseRef = {
...this._currentHistoryItemBaseRef,
revision: mergeBaseModified.revision
};
}
}
} else {
// Detached commit
Expand Down Expand Up @@ -178,18 +198,10 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
this.logger.trace(`[GitHistoryProvider][onDidRunWriteOperation] currentHistoryItemRemoteRef: ${JSON.stringify(this._currentHistoryItemRemoteRef)}`);
this.logger.trace(`[GitHistoryProvider][onDidRunWriteOperation] currentHistoryItemBaseRef: ${JSON.stringify(this._currentHistoryItemBaseRef)}`);

// Refs (alphabetically)
const historyItemRefs = this.repository.refs
.map(ref => toSourceControlHistoryItemRef(this.repository, ref))
.sort((a, b) => a.id.localeCompare(b.id));

// Auto-fetch
const silent = result.operation.kind === OperationKind.Fetch && result.operation.showProgress === false;
const delta = deltaHistoryItemRefs(this.historyItemRefs, historyItemRefs);
this._onDidChangeHistoryItemRefs.fire({ ...delta, silent });

this.historyItemRefs = historyItemRefs;

const deltaLog = {
added: delta.added.map(ref => ref.id),
modified: delta.modified.map(ref => ref.id),
Expand Down
6 changes: 6 additions & 0 deletions code/src/vs/editor/common/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,12 @@ export interface IInlineEdit {

export interface IInlineEditContext {
triggerKind: InlineEditTriggerKind;

/**
* @experimental
* @internal
*/
requestUuid?: string;
}

export enum InlineEditTriggerKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class InlineEditsAdapter extends Disposable {
const inlineEdits = await Promise.all(allInlineEditProvider.map(async provider => {
const result = await provider.provideInlineEdit(model, {
triggerKind: InlineEditTriggerKind.Automatic,
requestUuid: context.requestUuid
}, token);
if (!result) { return undefined; }
return { result, provider };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
version: this.productService.version,
date: this.productService.date
}
});
}, false);

if (extension) {
result.push(extension);
Expand Down Expand Up @@ -990,7 +990,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
if (hasAllVersions) {
const extensions: IGalleryExtension[] = [];
for (const rawGalleryExtension of rawGalleryExtensions) {
const extension = await this.toGalleryExtensionWithCriteria(rawGalleryExtension, criteria, context);
const extension = await this.toGalleryExtensionWithCriteria(rawGalleryExtension, criteria, true, context);
if (extension) {
extensions.push(extension);
}
Expand Down Expand Up @@ -1019,7 +1019,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
continue;
}
}
const extension = await this.toGalleryExtensionWithCriteria(rawGalleryExtension, criteria, context);
const extension = await this.toGalleryExtensionWithCriteria(rawGalleryExtension, criteria, false, context);
if (!extension
/** Need all versions if the extension is a pre-release version but
* - the query is to look for a release version or
Expand Down Expand Up @@ -1060,7 +1060,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
return { extensions: result.sort((a, b) => a[0] - b[0]).map(([, extension]) => extension), total };
}

private async toGalleryExtensionWithCriteria(rawGalleryExtension: IRawGalleryExtension, criteria: IExtensionCriteria, queryContext?: IStringDictionary<any>): Promise<IGalleryExtension | null> {
private async toGalleryExtensionWithCriteria(rawGalleryExtension: IRawGalleryExtension, criteria: IExtensionCriteria, hasAllVersions: boolean, queryContext?: IStringDictionary<any>): Promise<IGalleryExtension | null> {

const extensionIdentifier = { id: getGalleryExtensionId(rawGalleryExtension.publisher.publisherName, rawGalleryExtension.extensionName), uuid: rawGalleryExtension.extensionId };
const version = criteria.versions?.find(extensionIdentifierWithVersion => areSameExtensions(extensionIdentifierWithVersion, extensionIdentifier))?.version;
Expand All @@ -1082,7 +1082,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
extensionIdentifier.id,
rawGalleryExtensionVersion,
rawGalleryExtension.publisher.displayName,
includePreRelease ? 'any' : 'release',
includePreRelease ? (hasAllVersions ? 'any' : 'prerelease') : 'release',
criteria.compatible,
allTargetPlatforms,
criteria.targetPlatform,
Expand Down
3 changes: 2 additions & 1 deletion code/src/vs/workbench/api/common/extHostLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,8 @@ class InlineEditAdapter {
async provideInlineEdits(uri: URI, context: languages.IInlineEditContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineEdit | undefined> {
const doc = this._documents.getDocument(uri);
const result = await this._provider.provideInlineEdit(doc, {
triggerKind: this.languageTriggerKindToVSCodeTriggerKind[context.triggerKind]
triggerKind: this.languageTriggerKindToVSCodeTriggerKind[context.triggerKind],
requestUuid: context.requestUuid,
}, token);

if (!result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export class ChatEditingService extends Disposable implements IChatEditingServic
this._applyingChatEditsFailedContextKey.set(false);
this._register(decorationsService.registerDecorationsProvider(_instantiationService.createInstance(ChatDecorationsProvider, this._currentSessionObs)));
this._register(multiDiffSourceResolverService.registerResolver(_instantiationService.createInstance(ChatEditingMultiDiffSourceResolver, this._currentSessionObs)));
textModelService.registerTextModelContentProvider(ChatEditingTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingTextModelContentProvider, this._currentSessionObs));
textModelService.registerTextModelContentProvider(ChatEditingSnapshotTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingSnapshotTextModelContentProvider, this._currentSessionObs));
this._register(textModelService.registerTextModelContentProvider(ChatEditingTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingTextModelContentProvider, this._currentSessionObs)));
this._register(textModelService.registerTextModelContentProvider(ChatEditingSnapshotTextModelContentProvider.scheme, _instantiationService.createInstance(ChatEditingSnapshotTextModelContentProvider, this._currentSessionObs)));
this._register(bindContextKey(decidedChatEditingResourceContextKey, contextKeyService, (reader) => {
const currentSession = this._currentSessionObs.read(reader);
if (!currentSession) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
return linearHistory.slice(linearHistoryIndex).map(s => s.requestId).filter((r): r is string => !!r);
});

private readonly _onDidChange = new Emitter<ChatEditingSessionChangeType>();
private readonly _onDidChange = this._register(new Emitter<ChatEditingSessionChangeType>());
get onDidChange() {
this._assertNotDisposed();
return this._onDidChange.event;
Expand Down Expand Up @@ -517,6 +517,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
super.dispose();
this._state.set(ChatEditingSessionState.Disposed, undefined);
this._onDidDispose.fire();
this._onDidDispose.dispose();
}

getVirtualModel(documentId: string): ITextModel | null {
Expand Down
10 changes: 2 additions & 8 deletions code/src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
// Re-render once content references are loaded
(isResponseVM(element) ? `_${element.contentReferences.length}` : '') +
// Re-render if element becomes hidden due to undo/redo
`_${element.isHidden ? '1' : '0'}` +
`_${element.shouldBeRemovedOnSend ? '1' : '0'}` +
// Rerender request if we got new content references in the response
// since this may change how we render the corresponding attachments in the request
(isRequestVM(element) && element.contentReferences ? `_${element.contentReferences?.length}` : '');
Expand Down Expand Up @@ -1002,13 +1002,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
`${query.prefix} ${editorValue}`;
const isUserQuery = !query || 'prefix' in query;

const requests = this.viewModel.model.getRequests();
for (let i = requests.length - 1; i >= 0; i -= 1) {
const request = requests[i];
if (request.isHidden) {
this.chatService.removeRequest(this.viewModel.sessionId, request.id);
}
}


let attachedContext = this.inputPart.getAttachedAndImplicitContext(this.viewModel.sessionId);
let workingSet: URI[] | undefined;
Expand Down
33 changes: 19 additions & 14 deletions code/src/vs/workbench/contrib/chat/common/chatModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface IChatRequestModel {
readonly workingSet?: URI[];
readonly isCompleteAddedRequest: boolean;
readonly response?: IChatResponseModel;
isHidden: boolean;
shouldBeRemovedOnSend: boolean;
}

export interface IChatTextEditGroupState {
Expand Down Expand Up @@ -207,7 +207,7 @@ export interface IChatResponseModel {
readonly response: IResponse;
readonly isComplete: boolean;
readonly isCanceled: boolean;
readonly isHidden: boolean;
readonly shouldBeRemovedOnSend: boolean;
readonly isCompleteAddedRequest: boolean;
/** A stale response is one that has been persisted and rehydrated, so e.g. Commands that have their arguments stored in the EH are gone. */
readonly isStale: boolean;
Expand All @@ -230,7 +230,7 @@ export class ChatRequestModel implements IChatRequestModel {
return this._session;
}

public isHidden: boolean = false;
public shouldBeRemovedOnSend: boolean = false;

public get username(): string {
return this.session.requesterUsername;
Expand Down Expand Up @@ -506,16 +506,16 @@ export class ChatResponseModel extends Disposable implements IChatResponseModel
return this._session;
}

public get isHidden() {
return this._isHidden;
public get shouldBeRemovedOnSend() {
return this._shouldBeRemovedOnSend;
}

public get isComplete(): boolean {
return this._isComplete;
}

public set isHidden(hidden: boolean) {
this._isHidden = hidden;
public set shouldBeRemovedOnSend(hidden: boolean) {
this._shouldBeRemovedOnSend = hidden;
this._onDidChange.fire();
}

Expand Down Expand Up @@ -605,7 +605,7 @@ export class ChatResponseModel extends Disposable implements IChatResponseModel
private _result?: IChatAgentResult,
followups?: ReadonlyArray<IChatFollowup>,
public readonly isCompleteAddedRequest = false,
private _isHidden: boolean = false,
private _shouldBeRemovedOnSend: boolean = false,
restoredId?: string
) {
super();
Expand Down Expand Up @@ -733,6 +733,8 @@ export interface ISerializableChatRequestData {
/** Is really like "prompt data". This is the message in the format in which the agent gets it + variable values. */
variableData: IChatRequestVariableData;
response: ReadonlyArray<IMarkdownString | IChatResponseProgressFileTreeData | IChatContentInlineReference | IChatAgentMarkdownContentWithVulnerability> | undefined;

/**Old, persisted name for shouldBeRemovedOnSend */
isHidden: boolean;
responseId?: string;
agent?: ISerializableChatAgentData;
Expand Down Expand Up @@ -1084,7 +1086,7 @@ export class ChatModel extends Disposable implements IChatModel {
// Old messages don't have variableData, or have it in the wrong (non-array) shape
const variableData: IChatRequestVariableData = this.reviveVariableData(raw.variableData);
const request = new ChatRequestModel(this, parsedRequest, variableData, raw.timestamp ?? -1, undefined, undefined, undefined, undefined, raw.workingSet?.map((uri) => URI.revive(uri)), undefined, raw.requestId);
request.isHidden = !!raw.isHidden;
request.shouldBeRemovedOnSend = !!raw.isHidden;
if (raw.response || raw.result || (raw as any).responseErrorDetails) {
const agent = (raw.agent && 'metadata' in raw.agent) ? // Check for the new format, ignore entries in the old format
reviveSerializedAgent(raw.agent) : undefined;
Expand All @@ -1094,7 +1096,7 @@ export class ChatModel extends Disposable implements IChatModel {
// eslint-disable-next-line local/code-no-dangerous-type-assertions
{ errorDetails: raw.responseErrorDetails } as IChatAgentResult : raw.result;
request.response = new ChatResponseModel(raw.response ?? [new MarkdownString(raw.response)], this, agent, raw.slashCommand, request.id, true, raw.isCanceled, raw.vote, raw.voteDownReason, result, raw.followups, undefined, undefined, raw.responseId);
request.response.isHidden = !!raw.isHidden;
request.response.shouldBeRemovedOnSend = !!raw.isHidden;
if (raw.usedContext) { // @ulugbekna: if this's a new vscode sessions, doc versions are incorrect anyway?
request.response.applyReference(revive(raw.usedContext));
}
Expand Down Expand Up @@ -1193,11 +1195,14 @@ export class ChatModel extends Disposable implements IChatModel {
}

disableRequests(requestIds: ReadonlyArray<string>) {

const toHide = new Set(requestIds);

this._requests.forEach((request) => {
const isHidden = requestIds.includes(request.id);
request.isHidden = isHidden;
const shouldBeRemovedOnSend = toHide.has(request.id);
request.shouldBeRemovedOnSend = shouldBeRemovedOnSend;
if (request.response) {
request.response.isHidden = isHidden;
request.response.shouldBeRemovedOnSend = shouldBeRemovedOnSend;
}
});

Expand Down Expand Up @@ -1364,7 +1369,7 @@ export class ChatModel extends Disposable implements IChatModel {
})
: undefined,
responseId: r.response?.id,
isHidden: r.isHidden,
isHidden: r.shouldBeRemovedOnSend,
result: r.response?.result,
followups: r.response?.followups,
isCanceled: r.response?.isCanceled,
Expand Down
8 changes: 8 additions & 0 deletions code/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ export class ChatService extends Disposable implements IChatService {
return;
}

const requests = model.getRequests();
for (let i = requests.length - 1; i >= 0; i -= 1) {
const request = requests[i];
if (request.shouldBeRemovedOnSend) {
this.removeRequest(sessionId, request.id);
}
}

const location = options?.location ?? model.initialLocation;
const attempt = options?.attempt ?? 0;
const defaultAgent = this.chatAgentService.getDefaultAgent(location)!;
Expand Down
Loading

0 comments on commit 58dc03c

Please sign in to comment.