Skip to content

Commit 2cadce3

Browse files
committed
Don't allow dragging chat session history node
Fixes microsoft#264667
1 parent 01afdfd commit 2cadce3

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/vs/workbench/contrib/chat/browser/chatSessions.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,15 @@ class LocalChatSessionsProvider extends Disposable implements IChatSessionItemPr
520520
});
521521

522522
// Add "Show history..." node at the end
523-
const historyNode: IChatSessionItem = {
524-
id: 'show-history',
525-
label: nls.localize('chat.sessions.showHistory', "History"),
526-
};
527-
528523
return [...sessions, historyNode];
529524
}
530525
}
531526

527+
const historyNode: IChatSessionItem = {
528+
id: 'show-history',
529+
label: nls.localize('chat.sessions.showHistory', "History"),
530+
};
531+
532532
// Chat sessions container
533533
class ChatSessionsViewPaneContainer extends ViewPaneContainer {
534534
private registeredViewDescriptors: Map<string, IViewDescriptor> = new Map();
@@ -762,7 +762,7 @@ class SessionsDataSource implements IAsyncDataSource<IChatSessionItemProvider, C
762762
}
763763

764764
// Check if this is the "Show history..." node
765-
if ('id' in element && element.id === 'show-history') {
765+
if ('id' in element && element.id === historyNode.id) {
766766
return true;
767767
}
768768

@@ -800,7 +800,7 @@ class SessionsDataSource implements IAsyncDataSource<IChatSessionItemProvider, C
800800
}
801801

802802
// Check if this is the "Show history..." node
803-
if ('id' in element && element.id === 'show-history') {
803+
if ('id' in element && element.id === historyNode.id) {
804804
return this.getHistoryItems();
805805
}
806806

@@ -1031,7 +1031,7 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
10311031
// Handle different icon types
10321032
let iconResource: URI | undefined;
10331033
let iconTheme: ThemeIcon | undefined;
1034-
if (!session.iconPath && session.id !== 'show-history') {
1034+
if (!session.iconPath && session.id !== historyNode.id) {
10351035
iconTheme = this.statusToIcon(session.status);
10361036
} else {
10371037
iconTheme = session.iconPath;
@@ -1488,6 +1488,9 @@ class SessionsViewPane extends ViewPane {
14881488
}
14891489
},
14901490
getDragURI: (element: ChatSessionItemWithProvider) => {
1491+
if (element.id === historyNode.id) {
1492+
return null;
1493+
}
14911494
return getResourceForElement(element).toString();
14921495
},
14931496
getDragLabel: (elements: ChatSessionItemWithProvider[]) => {
@@ -1523,7 +1526,7 @@ class SessionsViewPane extends ViewPane {
15231526

15241527
// Register context menu event for right-click actions
15251528
this._register(this.tree.onContextMenu((e) => {
1526-
if (e.element && e.element.id !== 'show-history') {
1529+
if (e.element && e.element.id !== historyNode.id) {
15271530
this.showContextMenu(e);
15281531
}
15291532
}));
@@ -1603,7 +1606,7 @@ class SessionsViewPane extends ViewPane {
16031606
}
16041607

16051608
try {
1606-
if (element.id === 'show-history') {
1609+
if (element.id === historyNode.id) {
16071610
// Don't try to open the "Show history..." node itself
16081611
return;
16091612
}

0 commit comments

Comments
 (0)