Skip to content

Commit 2f2bc05

Browse files
authored
Don't log when not actually persisting sessions (microsoft#187214)
1 parent 31f1832 commit 2f2bc05

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/vs/workbench/contrib/chat/common/chatServiceImpl.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ export class ChatService extends Disposable implements IChatService {
152152
if (sessionData) {
153153
this._persistedSessions = this.deserializeChats(sessionData);
154154
const countsForLog = Object.keys(this._persistedSessions).length;
155-
this.trace('constructor', `Restored ${countsForLog} persisted sessions`);
155+
if (countsForLog > 0) {
156+
this.trace('constructor', `Restored ${countsForLog} persisted sessions`);
157+
}
156158
} else {
157159
this._persistedSessions = {};
158-
this.trace('constructor', 'No persisted sessions');
159160
}
160161

161162
this._transferred = this.getTransferredSession();
@@ -176,10 +177,16 @@ export class ChatService extends Disposable implements IChatService {
176177
.filter(session => session.requests.length));
177178
allSessions.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
178179
allSessions = allSessions.slice(0, maxPersistedSessions);
179-
this.trace('onWillSaveState', `Persisting ${allSessions.length} sessions`);
180+
if (allSessions.length) {
181+
this.trace('onWillSaveState', `Persisting ${allSessions.length} sessions`);
182+
}
180183

181184
const serialized = JSON.stringify(allSessions);
182-
this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
185+
186+
if (allSessions.length) {
187+
this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
188+
}
189+
183190
this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
184191
}
185192

0 commit comments

Comments
 (0)