Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,28 @@ export class DragAndDropObserver extends Disposable {
}
}

/**
* A wrapper around ResizeObserver that is disposable.
*/
export class DisposableResizeObserver extends Disposable {

private readonly observer: ResizeObserver;

constructor(callback: ResizeObserverCallback) {
super();
this.observer = new ResizeObserver(callback);
this._register(toDisposable(() => this.observer.disconnect()));
}

observe(target: Element, options?: ResizeObserverOptions): void {
this.observer.observe(target, options);
}

unobserve(target: Element): void {
this.observer.unobserve(target);
}
}

type HTMLElementAttributeKeys<T> = Partial<{ [K in keyof T]: T[K] extends Function ? never : T[K] extends object ? HTMLElementAttributeKeys<T[K]> : T[K] }>;
type ElementAttributes<T> = HTMLElementAttributeKeys<T> & Record<string, any>;
type RemoveHTMLElement<T> = T extends HTMLElement ? never : T;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3126,8 +3126,8 @@ export namespace ChatResponsePart {
export namespace ChatAgentRequest {
export function to(request: IChatAgentRequest, location2: vscode.ChatRequestEditorData | vscode.ChatRequestNotebookData | undefined, model: vscode.LanguageModelChat, diagnostics: readonly [vscode.Uri, readonly vscode.Diagnostic[]][], tools: Map<string, boolean>, extension: IRelaxedExtensionDescription, logService: ILogService): vscode.ChatRequest {

const toolReferences: typeof request.variables.variables = [];
const variableReferences: typeof request.variables.variables = [];
const toolReferences: IChatRequestVariableEntry[] = [];
const variableReferences: IChatRequestVariableEntry[] = [];
for (const v of request.variables.variables) {
if (v.kind === 'tool') {
toolReferences.push(v);
Expand Down
26 changes: 17 additions & 9 deletions src/vs/workbench/common/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ export function getVisbileViewContextKey(viewId: string): string { return `view.
//#region < --- Resources --- >

abstract class AbstractResourceContextKey {

// NOTE: DO NOT CHANGE THE DEFAULT VALUE TO ANYTHING BUT
// UNDEFINED! IT IS IMPORTANT THAT DEFAULTS ARE INHERITED
// FROM THE PARENT CONTEXT AND ONLY UNDEFINED DOES THIS

static readonly Scheme = new RawContextKey<string>('resourceScheme', undefined, { type: 'string', description: localize('resourceScheme', "The scheme of the resource") });
static readonly Filename = new RawContextKey<string>('resourceFilename', undefined, { type: 'string', description: localize('resourceFilename', "The file name of the resource") });
static readonly Dirname = new RawContextKey<string>('resourceDirname', undefined, { type: 'string', description: localize('resourceDirname', "The folder name the resource is contained in") });
Expand All @@ -186,8 +191,6 @@ abstract class AbstractResourceContextKey {
static readonly HasResource = new RawContextKey<boolean>('resourceSet', undefined, { type: 'boolean', description: localize('resourceSet', "Whether a resource is present or not") });
static readonly IsFileSystemResource = new RawContextKey<boolean>('isFileSystemResource', undefined, { type: 'boolean', description: localize('isFileSystemResource', "Whether the resource is backed by a file system provider") });

protected readonly _disposables = new DisposableStore();

protected _value: URI | undefined;
protected readonly _resourceKey: IContextKey<string | null>;
protected readonly _schemeKey: IContextKey<string | null>;
Expand Down Expand Up @@ -216,10 +219,6 @@ abstract class AbstractResourceContextKey {
this._isFileSystemResource = AbstractResourceContextKey.IsFileSystemResource.bindTo(this._contextKeyService);
}

dispose(): void {
this._disposables.dispose();
}

protected _setLangId(): void {
const value = this.get();
if (!value) {
Expand Down Expand Up @@ -277,6 +276,9 @@ abstract class AbstractResourceContextKey {
}

export class ResourceContextKey extends AbstractResourceContextKey {

private readonly _disposables = new DisposableStore();

constructor(
@IContextKeyService contextKeyService: IContextKeyService,
@IFileService fileService: IFileService,
Expand All @@ -299,12 +301,18 @@ export class ResourceContextKey extends AbstractResourceContextKey {
}
}));
}
}

export class StaticResourceContextKey extends AbstractResourceContextKey {
// No event listeners
dispose(): void {
this._disposables.dispose();
}
}

/**
* This is a version of ResourceContextKey that is not disposable and has no listeners for model change events.
* It will configure itself for the state/presence of a model only when created and not update.
*/
export class StaticResourceContextKey extends AbstractResourceContextKey { }


//#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class InlineAnchorWidget extends Disposable {
}
}

const resourceContextKey = this._register(new StaticResourceContextKey(contextKeyService, fileService, languageService, modelService));
const resourceContextKey = new StaticResourceContextKey(contextKeyService, fileService, languageService, modelService);
resourceContextKey.set(location.uri);
this._chatResourceContext.set(location.uri.toString());

Expand Down
21 changes: 11 additions & 10 deletions src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
}

get contentHeight(): number {
return this.input.contentHeight + this.tree.contentHeight + this.chatSuggestNextWidget.height;
return this.input.inputPartHeight.get() + this.tree.contentHeight + this.chatSuggestNextWidget.height;
}

get attachmentModel(): ChatAttachmentModel {
Expand Down Expand Up @@ -1921,7 +1921,9 @@ export class ChatWidget extends Disposable implements IChatWidget {
},
});
}));
this._register(this.input.onDidChangeHeight(() => {
this._register(autorun(reader => {
this.input.inputPartHeight.read(reader);

const editedRequest = this.renderer.getTemplateDataForRequestId(this.viewModel?.editing?.id);
if (isRequestVM(editedRequest?.currentElement) && this.viewModel?.editing) {
this.renderer.updateItemHeightOnRender(editedRequest?.currentElement, editedRequest);
Expand Down Expand Up @@ -2422,14 +2424,13 @@ export class ChatWidget extends Disposable implements IChatWidget {
const heightUpdated = this.bodyDimension && this.bodyDimension.height !== height;
this.bodyDimension = new dom.Dimension(width, height);

const layoutHeight = this._dynamicMessageLayoutData?.enabled ? this._dynamicMessageLayoutData.maxHeight : height;
if (this.viewModel?.editing) {
this.inlineInputPart?.layout(layoutHeight, width);
this.inlineInputPart?.layout(width);
}

this.inputPart.layout(layoutHeight, width);
this.inputPart.layout(width);

const inputHeight = this.inputPart.inputPartHeight;
const inputHeight = this.inputPart.inputPartHeight.get();
const chatSuggestNextWidgetHeight = this.chatSuggestNextWidget.height;
const lastElementVisible = this.tree.scrollTop + this.tree.renderHeight >= this.tree.scrollHeight - 2;
const lastItem = this.viewModel?.getItems().at(-1);
Expand Down Expand Up @@ -2487,8 +2488,8 @@ export class ChatWidget extends Disposable implements IChatWidget {

const possibleMaxHeight = (this._dynamicMessageLayoutData?.maxHeight ?? maxHeight);
const width = this.bodyDimension?.width ?? this.container.offsetWidth;
this.input.layout(possibleMaxHeight, width);
const inputPartHeight = this.input.inputPartHeight;
this.input.layout(width);
const inputPartHeight = this.input.inputPartHeight.get();
const chatSuggestNextWidgetHeight = this.chatSuggestNextWidget.height;
const newHeight = Math.min(renderHeight + diff, possibleMaxHeight - inputPartHeight - chatSuggestNextWidgetHeight);
this.layout(newHeight + inputPartHeight + chatSuggestNextWidgetHeight, width);
Expand Down Expand Up @@ -2532,8 +2533,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
}

const width = this.bodyDimension?.width ?? this.container.offsetWidth;
this.input.layout(this._dynamicMessageLayoutData.maxHeight, width);
const inputHeight = this.input.inputPartHeight;
this.input.layout(width);
const inputHeight = this.input.inputPartHeight.get();
const chatSuggestNextWidgetHeight = this.chatSuggestNextWidget.height;

const totalMessages = this.viewModel.getItems();
Expand Down
Loading
Loading