merge: preserve main lazy loading and scoped refresh with DSH
This commit is contained in:
commit
fb7a195186
113 files changed
+2675
-212
No files matched your search
@@ -374,7 +374,7 @@
|
||||
root.querySelector('.aw-usage').textContent = '调用额度暂不可用';
|
||||
}
|
||||
}
|
||||
function loadCurrent() {
|
||||
function loadCurrent(signal) {
|
||||
if (!currentId || !live()) return Promise.resolve();
|
||||
const id = currentId,
|
||||
at = revision,
|
||||
@@ -385,6 +385,8 @@
|
||||
if (!live() || currentId !== id || revision !== at) return;
|
||||
const next = await api(
|
||||
'/assistant/conversations/' + id + (deletedScope ? '?scope=deleted' : ''),
|
||||
undefined,
|
||||
{ signal, ownerCheck: () => live() && currentId === id && revision === at },
|
||||
);
|
||||
if (!live() || currentId !== id || revision !== at) return;
|
||||
conversation = next;
|
||||
@@ -778,6 +780,7 @@
|
||||
d.remove();
|
||||
});
|
||||
transcript.dispose();
|
||||
regionWatcher?.dispose();
|
||||
taskManager.dispose();
|
||||
panel.dispose();
|
||||
layout.dispose();
|
||||
@@ -785,6 +788,32 @@
|
||||
pendingActions.clear();
|
||||
input.value = '';
|
||||
}
|
||||
const regionWatcher = window.PageLifecycle?.regionPoll?.(
|
||||
'assistant',
|
||||
{ refresh: async () => false, onError: showError },
|
||||
1200,
|
||||
{ isActive: live, enabled: () => false },
|
||||
);
|
||||
if (regionWatcher)
|
||||
regionWatcher.refreshRegion = async () => {
|
||||
const next = await api('/assistant');
|
||||
if (!live()) return;
|
||||
panel.updateSettings(next.settings);
|
||||
data.usage = next.usage;
|
||||
root.querySelector('.aw-usage').textContent =
|
||||
'今日 ' + next.usage.calls + ' / ' + next.usage.limit;
|
||||
root.querySelector('.aw-connection').textContent =
|
||||
(next.settings.runtimeConfigured ?? !!next.settings.runtimePath)
|
||||
? '诊断已配置'
|
||||
: '待配置';
|
||||
await picker.refresh({ force: true });
|
||||
if (!live()) return;
|
||||
await window.PageLifecycle.validateRegion('assistant').catch(showError);
|
||||
await refreshList();
|
||||
await loadCurrent();
|
||||
await panel.refresh().catch(showError);
|
||||
if (live()) draw();
|
||||
};
|
||||
window.PageLifecycle?.onDispose(dispose);
|
||||
await Promise.all([
|
||||
refreshList(1),
|
||||
|
||||
Reference in new issue
Block a user