122
const models = Array.from(this._models.values())
123
.map(model => {
125
>
const owners = this._referenceOwners.get(key) ?? new Map();
126
>
const countsByOwner = new Map<string, number>();
127
>
for (const owner of owners.values()) {
128
countsByOwner.set(owner, (countsByOwner.get(owner) ?? 0) + 1);
129
}
131
>
const holders = Array.from(countsByOwner.entries())
132
>
.map(([holder, count]) => ({ holder, count }))
133
>
.sort((a, b) => b.count - a.count || a.holder.localeCompare(b.holder));
134
>
135
>
return {
136
>
sessionResource: model.sessionResource,
137
>
title: model.title,
138
>
createdBy: this._modelCreateOwners.get(key) ?? 'unknown',
139
>
initialLocation: model.initialLocation,
140
>
isImported: !!model.isImported,
141
>
willKeepAlive: model.willKeepAlive,
142
>
hasPendingEdits: !!model.editingSession?.entries.get().some(entry => entry.state.get() === ModifiedFileEntryState.Modified),
143
>
pendingDisposal: this._modelsToDispose.has(key),
144
>
referenceCount: owners.size,
145
>
holders,
146
>
} satisfies IChatModelReferenceDebugInfo;
147
})
148
.sort((a, b) => b.referenceCount - a.referenceCount || Number(b.hasPendingEdits) - Number(a.hasPendingEdits) || a.sessionResource.toString().localeCompare(b.sessionResource.toString()));