@opencode-ai/client 0.0.0-dev-18598 → 0.0.0-dev-18606
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/dist/solid/data.d.ts +6 -1
- package/dist/solid/data.js +58 -11
- package/package.json +4 -4
package/dist/solid/data.d.ts
CHANGED
|
@@ -80,7 +80,12 @@ export declare function createData(config: CreateDataInput): {
|
|
|
80
80
|
sync(sessionID: string): Promise<void>;
|
|
81
81
|
more(sessionID: string): boolean;
|
|
82
82
|
loading(sessionID: string): boolean;
|
|
83
|
-
loadMore(sessionID: string
|
|
83
|
+
loadMore(sessionID: string, options?: {
|
|
84
|
+
all?: boolean;
|
|
85
|
+
signal?: AbortSignal;
|
|
86
|
+
/** Runs synchronously inside the store-publication batch. */
|
|
87
|
+
beforePublish?: () => void;
|
|
88
|
+
}): Promise<void>;
|
|
84
89
|
invalidate(sessionID: string): void;
|
|
85
90
|
};
|
|
86
91
|
permission: {
|
package/dist/solid/data.js
CHANGED
|
@@ -183,6 +183,7 @@ export function createData(config) {
|
|
|
183
183
|
// submission order. Each waits for the previous POST to settle, so one
|
|
184
184
|
// failure does not block the next.
|
|
185
185
|
const sending = new Map();
|
|
186
|
+
const messageLoads = new Map();
|
|
186
187
|
const compacting = new Map();
|
|
187
188
|
onCleanup(() => compacting.clear());
|
|
188
189
|
// Register `promise` under `key` until it settles. A later registration
|
|
@@ -1381,21 +1382,67 @@ export function createData(config) {
|
|
|
1381
1382
|
loading(sessionID) {
|
|
1382
1383
|
return store.session.messageLoading[sessionID] ?? false;
|
|
1383
1384
|
},
|
|
1384
|
-
async loadMore(sessionID) {
|
|
1385
|
+
async loadMore(sessionID, options) {
|
|
1386
|
+
const signal = options?.signal;
|
|
1387
|
+
if (signal?.aborted)
|
|
1388
|
+
return;
|
|
1389
|
+
while (messageLoads.has(sessionID)) {
|
|
1390
|
+
const published = await (() => {
|
|
1391
|
+
const pending = messageLoads.get(sessionID);
|
|
1392
|
+
if (!signal)
|
|
1393
|
+
return pending;
|
|
1394
|
+
const aborted = Promise.withResolvers();
|
|
1395
|
+
const cancel = () => aborted.resolve();
|
|
1396
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
1397
|
+
return Promise.race([pending, aborted.promise])
|
|
1398
|
+
.catch((error) => {
|
|
1399
|
+
if (!signal.aborted)
|
|
1400
|
+
throw error;
|
|
1401
|
+
})
|
|
1402
|
+
.finally(() => signal.removeEventListener("abort", cancel));
|
|
1403
|
+
})();
|
|
1404
|
+
if ((!options?.all && published) || signal?.aborted)
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1385
1407
|
const cursor = store.session.messageCursor[sessionID];
|
|
1386
|
-
if (!cursor ||
|
|
1408
|
+
if (!cursor || signal?.aborted)
|
|
1387
1409
|
return;
|
|
1388
1410
|
setStore("session", "messageLoading", sessionID, true);
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1411
|
+
const request = (async () => {
|
|
1412
|
+
const fetched = [];
|
|
1413
|
+
let next = cursor;
|
|
1414
|
+
do {
|
|
1415
|
+
const response = await api().message.list({
|
|
1416
|
+
sessionID,
|
|
1417
|
+
limit: options?.all ? 200 : messagePageLimit,
|
|
1418
|
+
cursor: next,
|
|
1419
|
+
}, { signal });
|
|
1420
|
+
if (signal?.aborted)
|
|
1421
|
+
return;
|
|
1422
|
+
fetched.push(...response.data);
|
|
1423
|
+
next = response.cursor.next ?? undefined;
|
|
1424
|
+
if (!options?.all)
|
|
1425
|
+
break;
|
|
1426
|
+
} while (next);
|
|
1427
|
+
// A jump through history publishes once, not once per page of offscreen messages.
|
|
1428
|
+
const existing = store.session.message[sessionID] ?? [];
|
|
1429
|
+
const ids = new Set(existing.map((item) => item.id));
|
|
1430
|
+
const messages = [...fetched.reverse().filter((item) => !ids.has(item.id)), ...existing];
|
|
1431
|
+
batch(() => {
|
|
1432
|
+
options?.beforePublish?.();
|
|
1433
|
+
messageIndex.set(sessionID, new Map(messages.map((item, position) => [item.id, position])));
|
|
1434
|
+
setStore("session", "message", sessionID, reconcile(messages));
|
|
1435
|
+
setStore("session", "messageCursor", sessionID, next);
|
|
1436
|
+
});
|
|
1437
|
+
return true;
|
|
1438
|
+
})()
|
|
1439
|
+
.catch((error) => {
|
|
1440
|
+
if (!signal?.aborted)
|
|
1441
|
+
throw error;
|
|
1442
|
+
})
|
|
1391
1443
|
.finally(() => setStore("session", "messageLoading", sessionID, false));
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
const ids = new Set(existing.map((item) => item.id));
|
|
1395
|
-
const messages = [...older.filter((item) => !ids.has(item.id)), ...existing];
|
|
1396
|
-
messageIndex.set(sessionID, new Map(messages.map((item, position) => [item.id, position])));
|
|
1397
|
-
setStore("session", "message", sessionID, reconcile(messages));
|
|
1398
|
-
setStore("session", "messageCursor", sessionID, response.cursor.next ?? undefined);
|
|
1444
|
+
track(messageLoads, sessionID, request);
|
|
1445
|
+
await request;
|
|
1399
1446
|
},
|
|
1400
1447
|
invalidate(sessionID) {
|
|
1401
1448
|
sync.invalidate(`session.message:${sessionID}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode-ai/client",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-18606",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"typecheck": "tsgo --noEmit"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@opencode-ai/schema": "0.0.0-dev-
|
|
61
|
-
"@opencode-ai/protocol": "0.0.0-dev-
|
|
60
|
+
"@opencode-ai/schema": "0.0.0-dev-18606",
|
|
61
|
+
"@opencode-ai/protocol": "0.0.0-dev-18606"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"effect": "4.0.0-rc.112",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@effect/platform-node": "4.0.0-rc.112",
|
|
77
|
-
"@opencode-ai/httpapi-codegen": "0.0.0-dev-
|
|
77
|
+
"@opencode-ai/httpapi-codegen": "0.0.0-dev-18606",
|
|
78
78
|
"@tsconfig/bun": "1.0.9",
|
|
79
79
|
"@types/bun": "1.3.13",
|
|
80
80
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|