@clawchatsai/connector 0.0.98 → 0.0.99

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/gateway.js +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.98",
3
+ "version": "0.0.99",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",
package/server/gateway.js CHANGED
@@ -168,6 +168,12 @@ export class GatewayClient {
168
168
  }
169
169
  if (state === 'aborted') {
170
170
  const parsed = parseSessionKey(sessionKey);
171
+ // Clear pending flag from DB so a stale pending:true doesn't survive page reloads
172
+ // and trigger phantom "thinking..." state on next visit to this thread.
173
+ if (parsed) {
174
+ const db = this.getDb(parsed.workspace);
175
+ if (db) this._clearPendingFlag(db, parsed.threadId);
176
+ }
171
177
  this.broadcastToBrowsers(rawData); // dual-emit
172
178
  if (parsed) {
173
179
  const activity = this._popActivityLogForSession(sessionKey);
@@ -184,6 +190,15 @@ export class GatewayClient {
184
190
  }
185
191
  }
186
192
 
193
+ // Removes metadata.pending flag from any pending assistant message for a thread.
194
+ // Called on abort and by _cleanupSilentPending — keeps the SQL in one place.
195
+ _clearPendingFlag(db, threadId) {
196
+ db.prepare(
197
+ "UPDATE messages SET metadata = json_remove(metadata, '$.pending') " +
198
+ "WHERE thread_id = ? AND role = 'assistant' AND json_extract(metadata, '$.pending') = 1"
199
+ ).run(threadId);
200
+ }
201
+
187
202
  _cleanupSilentPending(sessionKey) {
188
203
  const parsed = parseSessionKey(sessionKey);
189
204
  if (!parsed) return;