@ateam-ai-mobile/core 0.1.27 → 0.1.29
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/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/store.ts +17 -9
package/dist/index.js
CHANGED
|
@@ -2107,9 +2107,19 @@ async function fetchTurnResult(jobId, jobSnap) {
|
|
|
2107
2107
|
const fallback = jobSnap.result?.message || jobSnap.state?.finalReply || (status === "error" ? "Something went wrong. Please try again." : "Done.");
|
|
2108
2108
|
updateJobProgress(jobId, { status, resultMessage: fallback });
|
|
2109
2109
|
}
|
|
2110
|
+
function isWaitingOnScreen(jobId) {
|
|
2111
|
+
return useChatStore.getState().messages.some((m) => {
|
|
2112
|
+
const p = m.jobProgress;
|
|
2113
|
+
return p?.jobId === jobId && p.status !== "done" && p.status !== "error" && p.status !== "paused";
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
function pollDelayMs(attempt) {
|
|
2117
|
+
return attempt < 120 ? 1500 : 5e3;
|
|
2118
|
+
}
|
|
2110
2119
|
async function pollJob(jobId, token) {
|
|
2111
2120
|
const { updateJobProgress } = useChatStore.getState();
|
|
2112
|
-
for (let i = 0;
|
|
2121
|
+
for (let i = 0; isWaitingOnScreen(jobId); i++) {
|
|
2122
|
+
if (i > 0) await new Promise((r) => setTimeout(r, pollDelayMs(i)));
|
|
2113
2123
|
try {
|
|
2114
2124
|
const res = await fetch(`${getCoreApiUrl()}/api/job/${jobId}/status`, {
|
|
2115
2125
|
headers: {
|
|
@@ -2133,12 +2143,7 @@ async function pollJob(jobId, token) {
|
|
|
2133
2143
|
}
|
|
2134
2144
|
} catch {
|
|
2135
2145
|
}
|
|
2136
|
-
await new Promise((r) => setTimeout(r, 1500));
|
|
2137
2146
|
}
|
|
2138
|
-
updateJobProgress(jobId, {
|
|
2139
|
-
status: "error",
|
|
2140
|
-
resultMessage: "Job timed out. Please try again."
|
|
2141
|
-
});
|
|
2142
2147
|
}
|
|
2143
2148
|
|
|
2144
2149
|
// src/api/tenants.ts
|