Skip to content

Commit 715d6f3

Browse files
authored
Enhance chat todo list widget scroll handling and state management (microsoft#262845)
1 parent 4a609b5 commit 715d6f3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatTodoListWidget.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class ChatTodoListWidget extends Disposable {
2424
private clearButtonContainer!: HTMLElement;
2525
private clearButton!: Button;
2626
private _currentSessionId: string | undefined;
27+
private _userHasScrolledManually: boolean = false;
2728

2829
constructor(
2930
@IChatTodoListService private readonly chatTodoListService: IChatTodoListService
@@ -84,6 +85,7 @@ export class ChatTodoListWidget extends Disposable {
8485

8586
this._register(dom.addDisposableListener(this.todoListContainer, 'scroll', () => {
8687
this.updateScrollShadow();
88+
this._userHasScrolledManually = true;
8789
}));
8890

8991
return container;
@@ -110,6 +112,11 @@ export class ChatTodoListWidget extends Disposable {
110112
return;
111113
}
112114

115+
if (this._currentSessionId !== sessionId) {
116+
this._userHasScrolledManually = false;
117+
this._userManuallyExpanded = false;
118+
}
119+
113120
const todoList = this.chatTodoListService.getTodos(sessionId);
114121
if (todoList.length > 0) {
115122
this.renderTodoList(todoList);
@@ -162,6 +169,12 @@ export class ChatTodoListWidget extends Disposable {
162169
this.updateTitleElement(titleElement, todoList);
163170
}
164171

172+
const allIncomplete = todoList.every(todo => todo.status === 'not-started');
173+
if (allIncomplete) {
174+
this._userHasScrolledManually = false;
175+
this._userManuallyExpanded = false;
176+
}
177+
165178
let lastActiveIndex = -1;
166179
let firstCompletedIndex = -1;
167180
let firstPendingAfterCompletedIndex = -1;
@@ -259,7 +272,7 @@ export class ChatTodoListWidget extends Disposable {
259272
}
260273

261274
private scrollToRelevantItem(lastActiveIndex: number, firstCompletedIndex: number, firstPendingAfterCompletedIndex: number, totalItems: number): void {
262-
if (totalItems <= 6) {
275+
if (totalItems <= 6 || this._userHasScrolledManually) {
263276
return;
264277
}
265278

0 commit comments

Comments
 (0)