@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "pluginId": "official.companion",
3
- "version": "0.1.0-alpha.25",
3
+ "version": "0.1.0-alpha.26",
4
4
  "contractVersion": "0.1.0",
5
5
  "name": "猫猫球",
6
6
  "icon": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clowder-ai/companion",
3
- "version": "0.1.0-alpha.25",
3
+ "version": "0.1.0-alpha.26",
4
4
  "description": "The desktop voice body for your Clowder companion",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/plugin.yaml CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "pluginId": "official.companion",
3
- "version": "0.1.0-alpha.25",
3
+ "version": "0.1.0-alpha.26",
4
4
  "contractVersion": "0.1.0",
5
5
  "name": "猫猫球",
6
6
  "icon": {
@@ -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.loading = false;
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
- if (this.loading) return;
120
- this.loading = true;
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 { this.loading = false; }
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