@clowder-ai/companion 0.1.0-alpha.25 → 0.1.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/plugin.yaml +1 -1
- package/renderer/conversation-surface.mjs +16 -6
package/manifest.json
CHANGED
package/package.json
CHANGED
package/plugin.yaml
CHANGED
|
@@ -14,7 +14,8 @@ export class ConversationSurface {
|
|
|
14
14
|
onAccepted, retryLegacy, status });
|
|
15
15
|
this.scheduleInterval = (...args) => Reflect.apply(scheduleInterval, globalThis, args);
|
|
16
16
|
this.cancelInterval = (...args) => Reflect.apply(cancelInterval, globalThis, args);
|
|
17
|
-
this.
|
|
17
|
+
this.activePageRead = null;
|
|
18
|
+
this.pendingOlderRead = false;
|
|
18
19
|
this.bodyReads = new Set();
|
|
19
20
|
this.replyMode = 'idle';
|
|
20
21
|
this.controller = new ReplyLetterController({
|
|
@@ -116,8 +117,12 @@ export class ConversationSurface {
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
async readHistory({ before, older = false } = {}) {
|
|
119
|
-
|
|
120
|
-
this.
|
|
120
|
+
const readKind = older ? 'older' : 'latest';
|
|
121
|
+
if (this.activePageRead) {
|
|
122
|
+
if (readKind === 'older' && this.activePageRead === 'latest') this.pendingOlderRead = true;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.activePageRead = readKind;
|
|
121
126
|
try {
|
|
122
127
|
const page = await this.client.readConversationPage(before === undefined ? {} : { before });
|
|
123
128
|
this.history.loadPage(page, { older });
|
|
@@ -130,12 +135,17 @@ export class ConversationSurface {
|
|
|
130
135
|
this.controller.clearProtected('permission_required');
|
|
131
136
|
this.$('chat-connection-status').textContent = '聊天权限已撤销';
|
|
132
137
|
} else this.$('chat-connection-status').textContent = '聊天记录暂未更新 · 正在说的话仍会显示';
|
|
133
|
-
} finally {
|
|
138
|
+
} finally {
|
|
139
|
+
const readPendingOlder = readKind === 'latest' && this.pendingOlderRead;
|
|
140
|
+
if (readKind === 'latest') this.pendingOlderRead = false;
|
|
141
|
+
this.activePageRead = null;
|
|
142
|
+
if (readPendingOlder) void this.readOlderHistory();
|
|
143
|
+
}
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
async readOlderHistory() {
|
|
137
|
-
const { hasMoreOlder, olderCursor } = this.history.snapshot();
|
|
138
|
-
if (!hasMoreOlder || !olderCursor) return;
|
|
147
|
+
const { hasMoreOlder, olderCursor, pageStatus } = this.history.snapshot();
|
|
148
|
+
if (this.controller.mode !== 'history' || pageStatus !== 'available' || !hasMoreOlder || !olderCursor) return;
|
|
139
149
|
await this.readHistory({ before: olderCursor, older: true });
|
|
140
150
|
}
|
|
141
151
|
|