@alexkroman1/aai-ui 6.5.1 → 6.7.0

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 CHANGED
@@ -1849,14 +1849,18 @@ function useWorkflowRuns(workflow, opts = {}) {
1849
1849
  * - **Reporting the bytes.** The same `UploadStatus` `useWorkflowSubmit` reports,
1850
1850
  * so `<UploadProgressBar>` renders either without knowing which hook it came from.
1851
1851
  *
1852
- * ## A failed upload CANCELS the run
1852
+ * ## A failed upload is RESUMED once, and only then cancels the run
1853
1853
  *
1854
1854
  * An upload that dies stays in the store, incomplete, and `complete` never becomes
1855
1855
  * true — so a run left behind polls until its own abandonment bound and then fails,
1856
- * minutes after the page has already reported the error. Cancelling is the honest
1857
- * end to a submission that did not happen. The cost is that work already done is
1858
- * thrown away with the run; a caller who wants to resume instead drives
1859
- * `api.uploadStream` and `api.uploadInfo` directly.
1856
+ * minutes after the page has already reported the error.
1857
+ *
1858
+ * That used to be the whole story, and it threw away a run and a file together for
1859
+ * what is usually one dropped connection near the end. So a failure gets one more
1860
+ * attempt with `resume: true`, which sends only the windows the store does not
1861
+ * already have (`UploadInfo.ranges`) — the run is still waiting on the same id, so
1862
+ * a resume that succeeds is invisible to it. Cancelling is what happens when THAT
1863
+ * fails too, and it is the honest end to a submission that did not happen.
1860
1864
  */
1861
1865
  /**
1862
1866
  * Start a workflow run and stream a file into it while it works.
@@ -1913,16 +1917,22 @@ function useWorkflowStream(workflow, opts = {}) {
1913
1917
  started = await client.start(workflow, payload, omitUndefined({ key }));
1914
1918
  setRunId(started);
1915
1919
  if (!chosen) return;
1916
- await client.uploadStream(id, chosen, {
1917
- name: chosen.name,
1918
- onProgress: (progress) => setUpload({
1919
- ...progress,
1920
+ const send = async (resume) => {
1921
+ await client.uploadStream(id, chosen, {
1920
1922
  name: chosen.name,
1921
- index: 1,
1922
- count: 1
1923
- }),
1924
- ...omitUndefined({ parallel })
1925
- });
1923
+ onProgress: (progress) => setUpload({
1924
+ ...progress,
1925
+ name: chosen.name,
1926
+ index: 1,
1927
+ count: 1
1928
+ }),
1929
+ ...omitUndefined({
1930
+ parallel,
1931
+ resume: resume ? true : void 0
1932
+ })
1933
+ });
1934
+ };
1935
+ await send(false).catch(async () => await send(true));
1926
1936
  await client.wake(started).catch(() => void 0);
1927
1937
  } catch (err) {
1928
1938
  setStartError(errorMessage(err));
@@ -141,13 +141,14 @@ export type UseWorkflowSubmitOptions = {
141
141
  /**
142
142
  * Send each chosen file as concurrent parts instead of in one request.
143
143
  *
144
- * `true` for the defaults, or `{ partBytes, concurrency }` to tune them. This is
145
- * the wait a form with a recording in it actually spends: the run does not exist
146
- * until its input is stored, so until the last byte lands there is no run to
147
- * watch and nothing for `<WorkflowProgress>` to say. Splitting the file across
148
- * connections is what makes that stretch shorter, and it degrades to the single
149
- * request wherever it would not help — a small file, an older agent — so turning
150
- * it on is safe for every form. See `UploadOptions.parallel`.
144
+ * **On by default.** `false` opts out, `{ partBytes, concurrency }` tunes it.
145
+ * This is the wait a form with a recording in it actually spends: the run does
146
+ * not exist until its input is stored, so until the last byte lands there is no
147
+ * run to watch and nothing for `<WorkflowProgress>` to say. Splitting the file
148
+ * across connections is what makes that stretch shorter, and it degrades to the
149
+ * single request wherever it would not help — a small file, an older agent — so
150
+ * the default costs nothing where it would not have paid. See
151
+ * `UploadOptions.parallel`.
151
152
  */
152
153
  parallel?: UploadParallel;
153
154
  };
@@ -48,14 +48,18 @@
48
48
  * - **Reporting the bytes.** The same `UploadStatus` `useWorkflowSubmit` reports,
49
49
  * so `<UploadProgressBar>` renders either without knowing which hook it came from.
50
50
  *
51
- * ## A failed upload CANCELS the run
51
+ * ## A failed upload is RESUMED once, and only then cancels the run
52
52
  *
53
53
  * An upload that dies stays in the store, incomplete, and `complete` never becomes
54
54
  * true — so a run left behind polls until its own abandonment bound and then fails,
55
- * minutes after the page has already reported the error. Cancelling is the honest
56
- * end to a submission that did not happen. The cost is that work already done is
57
- * thrown away with the run; a caller who wants to resume instead drives
58
- * `api.uploadStream` and `api.uploadInfo` directly.
55
+ * minutes after the page has already reported the error.
56
+ *
57
+ * That used to be the whole story, and it threw away a run and a file together for
58
+ * what is usually one dropped connection near the end. So a failure gets one more
59
+ * attempt with `resume: true`, which sends only the windows the store does not
60
+ * already have (`UploadInfo.ranges`) — the run is still waiting on the same id, so
61
+ * a resume that succeeds is invisible to it. Cancelling is what happens when THAT
62
+ * fails too, and it is the honest end to a submission that did not happen.
59
63
  */
60
64
  import type { UploadParallel } from "@alexkroman1/aai/workflow-api";
61
65
  import type { UploadStatus } from "./use-workflow-form.ts";
@@ -77,8 +81,8 @@ export type UseWorkflowStreamOptions = {
77
81
  * the uplink sees the same growing file whether one connection or four are
78
82
  * filling it. What changes is only how fast it grows.
79
83
  *
80
- * `true` for the defaults, or `{ partBytes, concurrency }` to tune them. See
81
- * `UploadOptions.parallel`.
84
+ * **On by default.** `false` opts out, `{ partBytes, concurrency }` tunes it.
85
+ * See `UploadOptions.parallel`.
82
86
  */
83
87
  parallel?: UploadParallel;
84
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-ui",
3
- "version": "6.5.1",
3
+ "version": "6.7.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -29,7 +29,7 @@
29
29
  "remark-gfm": "^4.0.1",
30
30
  "use-stick-to-bottom": "^1.1.6",
31
31
  "use-sync-external-store": "^1.6.0",
32
- "@alexkroman1/aai": "6.5.1"
32
+ "@alexkroman1/aai": "6.7.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^19.0.0",