@umituz/react-native-ai-generation-content 1.83.3 → 1.83.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.83.3",
3
+ "version": "1.83.5",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -56,6 +56,14 @@ export function useProcessingJobsPoller(
56
56
  [creations],
57
57
  );
58
58
 
59
+ // Orphan jobs: processing but no requestId/model (e.g. blocking image jobs that got stuck)
60
+ const orphanJobs = useMemo(
61
+ () => creations.filter(
62
+ (c) => c.status === CREATION_STATUS.PROCESSING && !c.requestId && !c.model,
63
+ ),
64
+ [creations],
65
+ );
66
+
59
67
  // Use ref for stable function reference to prevent effect re-runs
60
68
  const pollJobRef = useRef<((creation: Creation) => Promise<void>) | undefined>(undefined);
61
69
 
@@ -166,6 +174,31 @@ export function useProcessingJobsPoller(
166
174
  }
167
175
  };
168
176
 
177
+ // Clean up orphan processing creations (no requestId/model) older than max poll time
178
+ useEffect(() => {
179
+ if (!enabled || !userId || orphanJobs.length === 0) return;
180
+
181
+ orphanJobs.forEach(async (creation) => {
182
+ const ageMs = Date.now() - creation.createdAt.getTime();
183
+ if (ageMs < DEFAULT_MAX_POLL_TIME_MS) return;
184
+
185
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
186
+ console.log("[ProcessingJobsPoller] Orphan job timed out, marking as failed:", creation.id, { ageMs });
187
+ }
188
+ try {
189
+ await repository.update(userId, creation.id, {
190
+ status: CREATION_STATUS.FAILED,
191
+ metadata: { ...creation.metadata, error: "Generation timed out" },
192
+ completedAt: new Date(),
193
+ });
194
+ } catch (e) {
195
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
196
+ console.error("[ProcessingJobsPoller] Failed to mark orphan job:", e);
197
+ }
198
+ }
199
+ });
200
+ }, [enabled, userId, orphanJobs, repository]);
201
+
169
202
  // Use ref to always get latest creations
170
203
  const creationsRef = useRef(creations);
171
204
  useEffect(() => {
@@ -109,7 +109,7 @@ export function usePhotoBlockingGeneration(
109
109
  const duration = typeof inputData?.duration === "number" ? inputData.duration : undefined;
110
110
  const resolution = typeof inputData?.resolution === "string" ? inputData.resolution : undefined;
111
111
 
112
- const creationId = await persistence.saveAsProcessing(userId, {
112
+ const result = await persistence.saveAsProcessing(userId, {
113
113
  scenarioId: scenario.id,
114
114
  scenarioTitle: scenario.title || scenario.id,
115
115
  prompt,
@@ -117,10 +117,10 @@ export function usePhotoBlockingGeneration(
117
117
  resolution,
118
118
  creditCost,
119
119
  });
120
- creationIdRef.current = creationId;
120
+ creationIdRef.current = result.creationId;
121
121
 
122
122
  if (typeof __DEV__ !== "undefined" && __DEV__) {
123
- console.log("[PhotoBlockingGeneration] Saved as processing:", creationId);
123
+ console.log("[PhotoBlockingGeneration] Saved as processing:", result.creationId);
124
124
  }
125
125
  } catch (err) {
126
126
  if (typeof __DEV__ !== "undefined" && __DEV__) {