Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust max input part height for compact chat widget, keep input height separate when compute minHeight #213139

Merged
merged 1 commit into from
May 21, 2024
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
7 changes: 5 additions & 2 deletions src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
private readonly _onDidChangeVisibility = this._register(new Emitter<boolean>());
private readonly _contextResourceLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this._onDidChangeVisibility.event });

private readonly inputEditorMaxHeight: number;
private inputEditorHeight = 0;
private container!: HTMLElement;

Expand Down Expand Up @@ -150,6 +151,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
) {
super();

this.inputEditorMaxHeight = this.options.renderStyle === 'compact' ? INPUT_EDITOR_MAX_HEIGHT / 3 : INPUT_EDITOR_MAX_HEIGHT;

this.inputEditorHasText = CONTEXT_CHAT_INPUT_HAS_TEXT.bindTo(contextKeyService);
this.chatCursorAtTop = CONTEXT_CHAT_INPUT_CURSOR_AT_TOP.bindTo(contextKeyService);
this.inputEditorHasFocus = CONTEXT_CHAT_INPUT_HAS_FOCUS.bindTo(contextKeyService);
Expand Down Expand Up @@ -326,7 +329,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
this._inputEditor = this._register(scopedInstantiationService.createInstance(CodeEditorWidget, this._inputEditorElement, options, editorOptions));

this._register(this._inputEditor.onDidChangeModelContent(() => {
const currentHeight = Math.min(this._inputEditor.getContentHeight(), INPUT_EDITOR_MAX_HEIGHT);
const currentHeight = Math.min(this._inputEditor.getContentHeight(), this.inputEditorMaxHeight);
if (currentHeight !== this.inputEditorHeight) {
this.inputEditorHeight = currentHeight;
this._onDidChangeHeight.fire();
Expand Down Expand Up @@ -509,7 +512,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
return {
inputEditorBorder: 2,
followupsHeight: this.followupsContainer.offsetHeight,
inputPartEditorHeight: Math.min(this._inputEditor.getContentHeight(), INPUT_EDITOR_MAX_HEIGHT),
inputPartEditorHeight: Math.min(this._inputEditor.getContentHeight(), this.inputEditorMaxHeight),
inputPartHorizontalPadding: this.options.renderStyle === 'compact' ? 8 : 40,
inputPartVerticalPadding: this.options.renderStyle === 'compact' ? 12 : 24,
implicitContextHeight: this.attachedContextContainer.offsetHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,17 @@ export class InlineChatWidget {
// The chat widget is variable height and supports scrolling. It should be
// at least "maxWidgetHeight" high and at most the content height.

let maxWidgetHeight = 100;
let maxWidgetOutputHeight = 100;
for (const item of this._chatWidget.viewModel?.getItems() ?? []) {
if (isResponseVM(item) && item.response.value.some(r => r.kind === 'textEditGroup' && !r.state?.applied)) {
maxWidgetHeight = 270;
maxWidgetOutputHeight = 270;
break;
}
}

let value = this.contentHeight;
value -= this._chatWidget.contentHeight;
value += Math.min(maxWidgetHeight, this._chatWidget.contentHeight);
value += Math.min(this._chatWidget.input.contentHeight + maxWidgetOutputHeight, this._chatWidget.contentHeight);
return value;
}

Expand Down
Loading