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
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ export interface IChatReferenceListItem extends IChatContentReference {
excluded?: boolean;
}

export interface IChatListDividerItem {
kind: 'divider';
label: string;
menuId?: MenuId;
menuArg?: unknown;
scopedInstantiationService?: IInstantiationService;
}

export type IChatCollapsibleListItem = IChatReferenceListItem | IChatWarningMessage | IChatListDividerItem;
export type IChatCollapsibleListItem = IChatReferenceListItem | IChatWarningMessage;

export class ChatCollapsibleListContentPart extends ChatCollapsibleContentPart {

Expand Down Expand Up @@ -218,7 +210,7 @@ export class CollapsibleListPool extends Disposable {
'ChatListRenderer',
container,
new CollapsibleListDelegate(),
[this.instantiationService.createInstance(CollapsibleListRenderer, resourceLabels, this.menuId), this.instantiationService.createInstance(DividerRenderer)],
[this.instantiationService.createInstance(CollapsibleListRenderer, resourceLabels, this.menuId)],
{
...this.listOptions,
alwaysConsumeMouseWheel: false,
Expand All @@ -227,9 +219,6 @@ export class CollapsibleListPool extends Disposable {
if (element.kind === 'warning') {
return element.content.value;
}
if (element.kind === 'divider') {
return element.label;
}
const reference = element.reference;
if (typeof reference === 'string') {
return reference;
Expand Down Expand Up @@ -294,9 +283,6 @@ class CollapsibleListDelegate implements IListVirtualDelegate<IChatCollapsibleLi
}

getTemplateId(element: IChatCollapsibleListItem): string {
if (element.kind === 'divider') {
return DividerRenderer.TEMPLATE_ID;
}
return CollapsibleListRenderer.TEMPLATE_ID;
}
}
Expand Down Expand Up @@ -367,11 +353,6 @@ class CollapsibleListRenderer implements IListRenderer<IChatCollapsibleListItem,
return;
}

if (data.kind === 'divider') {
// Dividers are handled by DividerRenderer
return;
}

const reference = data.reference;
const icon = this.getReferenceIcon(data);
templateData.label.element.style.display = 'flex';
Expand Down Expand Up @@ -466,54 +447,6 @@ class CollapsibleListRenderer implements IListRenderer<IChatCollapsibleListItem,
}
}

interface IDividerTemplate {
readonly container: HTMLElement;
readonly label: HTMLElement;
readonly line: HTMLElement;
readonly toolbarContainer: HTMLElement;
readonly templateDisposables: DisposableStore;
readonly elementDisposables: DisposableStore;
toolbar: MenuWorkbenchToolBar | undefined;
}

class DividerRenderer implements IListRenderer<IChatListDividerItem, IDividerTemplate> {
static TEMPLATE_ID = 'chatListDividerRenderer';
readonly templateId: string = DividerRenderer.TEMPLATE_ID;

constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
) { }

renderTemplate(container: HTMLElement): IDividerTemplate {
const templateDisposables = new DisposableStore();
const elementDisposables = templateDisposables.add(new DisposableStore());
container.classList.add('chat-list-divider');
const label = dom.append(container, dom.$('span.chat-list-divider-label'));
const line = dom.append(container, dom.$('div.chat-list-divider-line'));
const toolbarContainer = dom.append(container, dom.$('.chat-list-divider-toolbar'));

return { container, label, line, toolbarContainer, templateDisposables, elementDisposables, toolbar: undefined };
}

renderElement(data: IChatListDividerItem, index: number, templateData: IDividerTemplate): void {
templateData.label.textContent = data.label;

// Clear element-specific disposables from previous render
templateData.elementDisposables.clear();
templateData.toolbar = undefined;
dom.clearNode(templateData.toolbarContainer);

if (data.menuId) {
const instantiationService = data.scopedInstantiationService || this.instantiationService;
templateData.toolbar = templateData.elementDisposables.add(instantiationService.createInstance(MenuWorkbenchToolBar, templateData.toolbarContainer, data.menuId, { menuOptions: { arg: data.menuArg } }));
}
}

disposeTemplate(templateData: IDividerTemplate): void {
templateData.templateDisposables.dispose();
}
}

function getResourceLabelForGithubUri(uri: URI): IResourceLabelProps {
const repoPath = uri.path.split('/').slice(1, 3).join('/');
const filePath = uri.path.split('/').slice(5);
Expand Down Expand Up @@ -558,7 +491,7 @@ function getLineRangeFromGithubUri(uri: URI): IRange | undefined {
}

function getResourceForElement(element: IChatCollapsibleListItem): URI | null {
if (element.kind === 'warning' || element.kind === 'divider') {
if (element.kind === 'warning') {
return null;
}
const { reference } = element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2374,19 +2374,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}))
);

const shouldRender = derived(reader => {
const sessionFilesLength = sessionFiles.read(reader).length;
const editSessionEntriesLength = editSessionEntries.read(reader).length;

const sessionResource = chatEditingSession?.chatSessionResource ?? this._widget?.viewModel?.model.sessionResource;
if (sessionResource && getChatSessionType(sessionResource) === localChatSessionType) {
return sessionFilesLength > 0 || editSessionEntriesLength > 0;
}

// For background sessions, only render the
// working set when there are session files
return sessionFilesLength > 0;
});
const shouldRender = derived(reader =>
editSessionEntries.read(reader).length > 0 || sessionFiles.read(reader).length > 0);

this._renderingChatEdits.value = autorun(reader => {
if (this.options.renderWorkingSet && shouldRender.read(reader)) {
Expand Down Expand Up @@ -2594,21 +2583,10 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
const editEntries = editSessionEntries.read(reader);
const sessionFileEntries = sessionEntries.read(reader) ?? [];

// Combine entries with an optional divider
const allEntries: IChatCollapsibleListItem[] = [...editEntries];
if (sessionFileEntries.length > 0) {
if (editEntries.length > 0) {
// Add divider between edit session entries and session file entries
allEntries.push({
kind: 'divider',
label: localize('chatEditingSession.allChanges', 'Worktree Changes'),
menuId: MenuId.ChatEditingSessionChangesToolbar,
menuArg: sessionResource,
scopedInstantiationService,
});
}
allEntries.push(...sessionFileEntries);
}
// Combine edit session entries with session file changes. At the moment, we
// we can combine these two arrays since local chat sessions use edit session
// entries, while background chat sessions use session file changes.
const allEntries = editEntries.concat(sessionFileEntries);

const maxItemsShown = 6;
const itemsShown = Math.min(allEntries.length, maxItemsShown);
Expand Down
35 changes: 0 additions & 35 deletions src/vs/workbench/contrib/chat/browser/widget/media/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -2108,41 +2108,6 @@ have to be updated for changes to the rules above, or to support more deeply nes
display: none;
}

.interactive-session .chat-list-divider {
display: flex;
align-items: center;
padding: 2px 3px;
font-size: 11px;
color: var(--vscode-descriptionForeground);
gap: 8px;
pointer-events: none;
user-select: none;
}

.interactive-session .monaco-list .monaco-list-row:has(.chat-list-divider) {
background-color: transparent !important;
cursor: default;
}

.interactive-session .chat-list-divider .chat-list-divider-label {
text-transform: uppercase;
letter-spacing: 0.04em;
flex-shrink: 0;
}

.interactive-session .chat-list-divider .chat-list-divider-line {
flex: 1;
height: 1px;
background-color: var(--vscode-editorWidget-border, var(--vscode-contrastBorder));
opacity: 0.5;
}

.interactive-session .chat-list-divider .chat-list-divider-toolbar {
display: flex;
align-items: center;
pointer-events: auto;
}

.interactive-session .chat-summary-list .monaco-list .monaco-list-row {
border-radius: 4px;
}
Expand Down
Loading