@seedtactics/insight-client 17.0.1-beta.9 → 17.0.2

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 (62) hide show
  1. package/README.md +16 -4
  2. package/dist/assets/ProgramHighlight-mKbZxoXO.js +3 -0
  3. package/dist/assets/index-Cjt4dPv7.js +367 -0
  4. package/dist/cell-status/current-status.d.ts +1 -0
  5. package/dist/cell-status/current-status.js +46 -51
  6. package/dist/cell-status/loading.d.ts +13 -2
  7. package/dist/cell-status/loading.js +39 -7
  8. package/dist/cell-status/material-details.d.ts +2 -2
  9. package/dist/cell-status/material-details.js +33 -14
  10. package/dist/components/App.d.ts +0 -5
  11. package/dist/components/App.js +1 -1
  12. package/dist/components/ChooseMode.js +15 -3
  13. package/dist/components/ErrorsAndLoading.js +2 -1
  14. package/dist/components/LoadingIcon.js +3 -1
  15. package/dist/components/analysis/BufferChart.js +3 -2
  16. package/dist/components/operations/AllMaterial.js +9 -12
  17. package/dist/components/operations/RecentCycleChart.js +16 -21
  18. package/dist/components/quality/QualityMaterial.js +3 -12
  19. package/dist/components/station-monitor/BasketLoadStationWork.d.ts +4 -7
  20. package/dist/components/station-monitor/BasketLoadStationWork.js +97 -44
  21. package/dist/components/station-monitor/CancelLoadButton.js +8 -3
  22. package/dist/components/station-monitor/InvalidateCycle.js +26 -25
  23. package/dist/components/station-monitor/LoadStation.d.ts +0 -5
  24. package/dist/components/station-monitor/LoadStation.js +88 -115
  25. package/dist/components/station-monitor/Material.d.ts +6 -1
  26. package/dist/components/station-monitor/Material.js +22 -9
  27. package/dist/components/station-monitor/MoveMaterialArrows.js +9 -0
  28. package/dist/components/station-monitor/PrintedLabel.js +15 -19
  29. package/dist/components/station-monitor/QuarantineButton.js +21 -29
  30. package/dist/components/station-monitor/QueuesAddMaterial.js +2 -5
  31. package/dist/components/station-monitor/SystemOverview.js +59 -19
  32. package/dist/components/station-monitor/Whiteboard.js +14 -15
  33. package/dist/data/material-operation-policy.d.ts +6 -0
  34. package/dist/data/material-operation-policy.js +26 -2
  35. package/dist/data/move-arrows.d.ts +7 -0
  36. package/dist/data/move-arrows.js +107 -24
  37. package/dist/data/queue-material.d.ts +1 -0
  38. package/dist/data/queue-material.js +55 -48
  39. package/dist/extension.d.ts +1 -1
  40. package/dist/extension.js +1 -0
  41. package/dist/index.html +2 -39
  42. package/dist/index.js +1 -6
  43. package/dist/network/api-errors.d.ts +8 -0
  44. package/dist/network/api-errors.js +77 -0
  45. package/dist/network/api.d.ts +20 -34
  46. package/dist/network/api.js +68 -64
  47. package/dist/network/backend-mock.js +3 -0
  48. package/dist/network/backend.d.ts +3 -2
  49. package/dist/network/current-status-session.d.ts +27 -0
  50. package/dist/network/current-status-session.js +65 -0
  51. package/dist/network/websocket.d.ts +4 -0
  52. package/dist/network/websocket.js +176 -37
  53. package/dist/util/parseISODuration.js +10 -9
  54. package/docs/material-quarantine.md +5 -4
  55. package/docs/mazak.md +11 -14
  56. package/docs/operator-procedures.md +14 -0
  57. package/docs/server-config.md +20 -12
  58. package/package.json +25 -20
  59. package/dist/assets/ProgramHighlight-C6zSEXCX.js +0 -3
  60. package/dist/assets/index-MFZreX-b.js +0 -388
  61. package/dist/components/station-monitor/BasketMovementArrival.d.ts +0 -40
  62. package/dist/components/station-monitor/BasketMovementArrival.js +0 -165
@@ -37,7 +37,8 @@ import * as matDetails from "../../cell-status/material-details.js";
37
37
  import { MaterialDetailTitle, MaterialDetailContent, MaterialLoading, } from "../station-monitor/Material.js";
38
38
  import { buildPathString, extractPath } from "../../data/results.inspection.js";
39
39
  import { startOfToday, addDays, startOfDay, endOfDay } from "date-fns";
40
- import { ApiException, LogType } from "../../network/api.js";
40
+ import { LogType } from "../../network/api.js";
41
+ import { apiErrorMessage } from "../../network/api-errors.js";
41
42
  import { InspectionSankey } from "../analysis/InspectionSankey.js";
42
43
  import { useIsDemo, useSetTitle } from "../routes.js";
43
44
  import { extendRange, inspectionLogEntries, pathLookupRange } from "../../data/path-lookup.js";
@@ -68,17 +69,7 @@ function SerialLookup() {
68
69
  setError("No material found with serial " + serial);
69
70
  }
70
71
  })
71
- .catch((e) => {
72
- if (ApiException.isApiException(e)) {
73
- setError(e.response);
74
- }
75
- else if (e instanceof Error) {
76
- setError(e.message);
77
- }
78
- else {
79
- setError(e);
80
- }
81
- })
72
+ .catch((e) => setError(apiErrorMessage(e)))
82
73
  .finally(() => setLoading(false));
83
74
  }
84
75
  }
@@ -1,15 +1,12 @@
1
+ import { type ReactNode } from "react";
1
2
  import * as api from "../../network/api.js";
2
3
  import { MatCardFontSize } from "./Material.js";
3
- export interface BasketLoadStationCommand {
4
- readonly workId: string;
5
- }
6
- export type SubmitBasketLoadStationCommand = (stationNumber: number, command: BasketLoadStationCommand) => Promise<"accepted" | "conflict">;
7
4
  interface BasketLoadStationWorkflowProps {
8
- readonly stationNumber: number;
9
5
  readonly basket: Readonly<api.IBasketStatus>;
10
6
  readonly material: ReadonlyArray<Readonly<api.IInProcessMaterial>>;
11
7
  readonly fsize: MatCardFontSize;
12
- readonly submitCommand: SubmitBasketLoadStationCommand | undefined;
8
+ readonly title: ReactNode;
9
+ readonly elapsed: ReactNode;
13
10
  }
14
- export declare function BasketLoadStationWorkflow({ stationNumber, basket, material, fsize, submitCommand, }: BasketLoadStationWorkflowProps): import("react").JSX.Element;
11
+ export declare function BasketLoadStationWorkflow({ basket, material, fsize, title, elapsed, }: BasketLoadStationWorkflowProps): import("react").JSX.Element;
15
12
  export {};
@@ -31,8 +31,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
31
  import { useMemo, useState } from "react";
32
32
  import { Alert, Box, Button, Stack, Typography } from "@mui/material";
33
33
  import { LazySeq } from "@seedtactics/immutable-collections";
34
+ import { useSetAtom } from "jotai";
34
35
  import { basketSlotLabel } from "../../cell-status/station-cycles.js";
35
36
  import * as api from "../../network/api.js";
37
+ import { serverErrorMessage } from "../../network/api-errors.js";
38
+ import { JobsBackend } from "../../network/backend.js";
39
+ import { refreshCurrentStatus } from "../../network/websocket.js";
36
40
  import { InProcMaterial } from "./Material.js";
37
41
  import { MoveMaterialArrowNode } from "./MoveMaterialArrows.js";
38
42
  import { MoveMaterialNodeKindType } from "../../data/move-arrows.js";
@@ -112,36 +116,18 @@ function stationWork(material, basket) {
112
116
  },
113
117
  };
114
118
  }
115
- if (validActions.length === 0)
116
- return { type: "none" };
117
- const tagged = validActions.filter((action) => isNonBlank(action.workId));
118
- const workIds = LazySeq.of(tagged).toHashSet(({ workId }) => workId);
119
- if (tagged.length !== validActions.length || workIds.size !== 1) {
120
- return { type: "inconsistent" };
121
- }
122
- return {
123
- type: "active",
124
- work: { workId: tagged[0].workId, ready: true, confirmEmpty: false, awaitingSlots: [] },
125
- };
126
- }
127
- function loadingInstruction(mat) {
128
- if (mat.location.type === api.LocType.InBasket &&
129
- mat.location.basketId === mat.action.loadToBasketId &&
130
- mat.location.basketSlot === mat.action.loadToBasketSlot) {
131
- return "Unload, re-plate, and reload this slot";
132
- }
133
- if (mat.location.type === api.LocType.InQueue && mat.location.currentQueue) {
134
- return `Load from ${mat.location.currentQueue}`;
135
- }
136
- return "Load from raw material";
119
+ return { type: validActions.length === 0 ? "none" : "inconsistent" };
137
120
  }
138
- function SlotMaterial({ material, fsize, }) {
139
- return material.map((mat) => (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.Material, material: mat }, children: _jsx(InProcMaterial, { mat: mat, fsize: fsize }) }, mat.materialID)));
121
+ function SlotMaterial({ material, basketId, fsize, }) {
122
+ return material.map((mat) => (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.Material, material: mat }, children: _jsx(InProcMaterial, { mat: mat, displayActionForSingleBasket: basketId, fsize: fsize }) }, mat.materialID)));
140
123
  }
141
- export function BasketLoadStationWorkflow({ stationNumber, basket, material, fsize, submitCommand, }) {
124
+ export function BasketLoadStationWorkflow({ basket, material, fsize, title, elapsed, }) {
142
125
  const [submission, setSubmission] = useState();
126
+ const refresh = useSetAtom(refreshCurrentStatus);
127
+ const [refreshError, setRefreshError] = useState();
143
128
  const workState = useMemo(() => stationWork(material, basket), [basket, material]);
144
129
  const blockedReason = basket.loadStationWork?.confirmationBlockedReason?.trim();
130
+ const instructionWarning = basket.loadStationWork?.instructionWarning?.trim();
145
131
  const work = workState.type === "active" ? workState.work : undefined;
146
132
  const submissionState = submission !== undefined &&
147
133
  submission.workId === work?.workId &&
@@ -151,6 +137,7 @@ export function BasketLoadStationWorkflow({ stationNumber, basket, material, fsi
151
137
  (submission.basket === basket && submission.material === material))
152
138
  ? submission.state
153
139
  : "idle";
140
+ const submissionReason = submissionState === "idle" ? null : (submission?.reason ?? null);
154
141
  const materialBySlot = useMemo(() => LazySeq.of(material)
155
142
  .filter((mat) => mat.location.type === api.LocType.InBasket &&
156
143
  mat.location.basketId === basket.basketId &&
@@ -169,39 +156,105 @@ export function BasketLoadStationWorkflow({ stationNumber, basket, material, fsi
169
156
  .concat(loadsBySlot.keysToLazySeq())
170
157
  .distinctBy((slot) => slot)
171
158
  .toSortedArray((slot) => slot), [basket.emptySlots, basket.unknownSlots, materialBySlot, loadsBySlot]);
159
+ async function refreshStatus(workId) {
160
+ setRefreshError(undefined);
161
+ try {
162
+ if (!(await refresh(AbortSignal.timeout(5000))))
163
+ setRefreshError({ workId, message: "The connection changed while refreshing status." });
164
+ }
165
+ catch (error) {
166
+ setRefreshError({
167
+ workId,
168
+ message: serverErrorMessage(error) ?? "Unable to refresh status.",
169
+ });
170
+ }
171
+ }
172
172
  async function submit() {
173
- if (work === undefined || !work.ready || submitCommand === undefined)
173
+ if (work === undefined || !work.ready)
174
174
  return;
175
175
  const submittedWorkId = work.workId;
176
- const pending = { workId: submittedWorkId, basket, material, state: "submitting" };
176
+ const pending = {
177
+ workId: submittedWorkId,
178
+ basket,
179
+ material,
180
+ state: "submitting",
181
+ reason: null,
182
+ };
177
183
  setSubmission(pending);
178
184
  try {
179
- const state = await submitCommand(stationNumber, { workId: submittedWorkId });
185
+ await JobsBackend.completeBasketLoadStation(new api.BasketLoadStationCompletion({ workId: submittedWorkId }));
186
+ const state = "accepted";
180
187
  setSubmission((current) => (current === pending ? { ...pending, state } : current));
181
188
  }
182
- catch {
183
- setSubmission((current) => (current === pending ? { ...pending, state: "error" } : current));
189
+ catch (error) {
190
+ const state = api.ApiException.isApiException(error) && error.status === 409 ? "conflict" : "error";
191
+ const reason = serverErrorMessage(error);
192
+ setSubmission((current) => (current === pending ? { ...pending, state, reason } : current));
184
193
  }
194
+ await refreshStatus(submittedWorkId);
185
195
  }
186
196
  const submissionDisabled = !work?.ready ||
187
197
  submissionState === "submitting" ||
188
198
  submissionState === "accepted" ||
189
199
  submissionState === "conflict";
190
- return (_jsxs(Stack, { spacing: 2, sx: { mt: 2 }, children: [_jsx(Typography, { variant: "h6", children: "Basket slots" }), _jsx(Box, { sx: {
200
+ // Confirm sits in the header so it is visible without scrolling. Slots are drawn like pallet
201
+ // faces: stacked regions holding their material side by side. All material in a slot moves
202
+ // together.
203
+ return (_jsxs("div", { children: [_jsxs(Box, { sx: {
191
204
  display: "grid",
192
- gridTemplateColumns: "repeat(auto-fit, minmax(15em, 1fr))",
193
- gap: 2,
194
- }, children: slots.map((slot) => {
205
+ gridTemplateColumns: "1fr auto auto",
206
+ alignItems: "center",
207
+ columnGap: 4,
208
+ }, children: [title, _jsx(Box, { children: work ? (_jsx(Button, { variant: "contained", color: "secondary", size: "large", disabled: submissionDisabled, onClick: () => void submit(), children: "Confirm" })) : null }), _jsx(Box, { sx: {
209
+ justifySelf: "flex-end",
210
+ minWidth: "8ch",
211
+ textAlign: "right",
212
+ fontVariantNumeric: "tabular-nums",
213
+ }, children: elapsed })] }), _jsxs(Stack, { spacing: 2, sx: { ml: "4em", mr: "4em", mt: 2 }, children: [refreshError?.workId === work?.workId && refreshError && (_jsxs(Alert, { severity: "warning", action: _jsx(Button, { onClick: () => void refreshStatus(refreshError.workId), children: "Refresh status" }), children: [refreshError.message, " Refresh current status to review the latest work."] })), work?.confirmEmpty && work.ready && (_jsxs(Typography, { children: ["Confirm basket ", basket.basketId, " is empty."] })), instructionWarning && _jsx(Alert, { severity: "warning", children: instructionWarning }), work && !work.ready && (_jsx(Alert, { severity: "info", children: blockedReason ||
214
+ (work.awaitingSlots.length > 0
215
+ ? `Waiting for material for slots ${work.awaitingSlots.map(basketSlotLabel).join(", ")}.`
216
+ : "Basket work is not ready for confirmation.") })), !work && workState.type === "inconsistent" ? (_jsx(Alert, { severity: "warning", children: "Basket work is inconsistent. Wait for refreshed material actions before confirming." })) : null, submissionState === "accepted" ? (_jsx(Alert, { severity: "success", children: "Confirmation accepted. Waiting for refreshed work." })) : submissionState === "conflict" ? (_jsx(Alert, { severity: "warning", children: submissionReason ??
217
+ "Basket work changed before confirmation. Review the refreshed slots and try again." })) : submissionState === "error" ? (_jsxs(Alert, { severity: "error", children: ["Unable to confirm basket work", submissionReason ? `: ${submissionReason}` : ".", " No work was assumed complete."] })) : null] }), _jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.BasketZone, basketId: basket.basketId }, children: slots.map((slot, idx) => {
195
218
  const slotMaterial = materialBySlot.get(slot) ?? [];
196
- const loads = loadsBySlot.get(slot) ?? [];
197
219
  const isUnknown = basket.unknownSlots?.includes(slot) === true;
198
- return (_jsx(MoveMaterialArrowNode, { kind: {
199
- type: MoveMaterialNodeKindType.BasketSlotZone,
200
- basketId: basket.basketId,
201
- slot,
202
- }, children: _jsxs(Box, { component: "section", "data-testid": `basket-load-station-slot-${slot}`, sx: { border: "1px solid", borderColor: "text.primary", p: 2 }, children: [_jsxs(Typography, { variant: "h6", children: ["Slot ", basketSlotLabel(slot)] }), slotMaterial.length > 0 ? (_jsx(SlotMaterial, { material: slotMaterial, fsize: fsize })) : (_jsx(Typography, { color: isUnknown ? "warning.main" : "text.secondary", children: isUnknown ? "Unknown" : "Empty" })), loads.map((mat, index) => (_jsxs(Box, { sx: { mt: 1 }, children: [_jsx(Typography, { children: loadingInstruction(mat) }), _jsxs(Typography, { variant: "body2", color: "text.secondary", children: [mat.partName, " \u00B7 Process ", mat.action.processAfterLoad ?? mat.process] })] }, `${mat.jobUnique}-${mat.process}-${index}`)))] }) }, slot));
203
- }) }), work?.confirmEmpty && _jsxs(Typography, { children: ["Confirm basket ", basket.basketId, " is empty."] }), work && !work.ready && (_jsx(Alert, { severity: "info", children: blockedReason ||
204
- (work.awaitingSlots.length > 0
205
- ? `Waiting for material for slots ${work.awaitingSlots.map(basketSlotLabel).join(", ")}.`
206
- : "Basket work is not ready for confirmation.") })), work && submitCommand ? (_jsx(Box, { sx: { display: "flex", justifyContent: "flex-end" }, children: _jsx(Button, { variant: "contained", disabled: submissionDisabled, onClick: () => void submit(), children: "Confirm" }) })) : work ? (_jsx(Alert, { severity: "warning", children: "Basket work confirmation is not configured." })) : workState.type === "inconsistent" ? (_jsx(Alert, { severity: "warning", children: "Basket work is inconsistent. Wait for refreshed material actions before confirming." })) : null, submissionState === "accepted" ? (_jsx(Alert, { severity: "success", children: "Confirmation accepted. Waiting for refreshed work." })) : submissionState === "conflict" ? (_jsx(Alert, { severity: "warning", children: "Basket work changed before confirmation. Review the refreshed slots and try again." })) : submissionState === "error" ? (_jsx(Alert, { severity: "error", children: "Unable to confirm basket work. No work was assumed complete." })) : null] }));
220
+ const targetContents = LazySeq.of(slotMaterial)
221
+ .filter((mat) => mat.action.type !== api.ActionType.UnloadToInProcess &&
222
+ mat.action.type !== api.ActionType.UnloadToCompletedMaterial)
223
+ .concat(loadsBySlot.get(slot) ?? [])
224
+ .map((mat) => {
225
+ const process = mat.action.type === api.ActionType.LoadingToBasket
226
+ ? mat.action.processAfterLoad
227
+ : mat.process;
228
+ return `${mat.partName}${process !== undefined ? ` proc ${process}` : ""}`;
229
+ })
230
+ .distinctBy((label) => label)
231
+ .toRArray();
232
+ const targetEmpty = work?.confirmEmpty ||
233
+ (!isUnknown && (slotMaterial.length > 0 || basket.emptySlots?.includes(slot) === true));
234
+ const target = work && !work.awaitingSlots.includes(slot)
235
+ ? targetContents.length > 0
236
+ ? `Fill with ${targetContents.join(", ")}`
237
+ : targetEmpty
238
+ ? "Leave empty"
239
+ : undefined
240
+ : undefined;
241
+ return (_jsxs(Box, { component: "section", "data-testid": `basket-load-station-slot-${slot}`, sx: { borderTop: idx !== 0 ? "1px solid black" : undefined, py: 3 }, children: [_jsxs(Box, { sx: {
242
+ display: "flex",
243
+ justifyContent: "center",
244
+ alignItems: "center",
245
+ flexWrap: "wrap",
246
+ columnGap: 1,
247
+ color: "text.secondary",
248
+ mb: 2,
249
+ }, children: [_jsxs(Typography, { variant: "h6", sx: { color: "text.primary" }, children: ["Slot ", basketSlotLabel(slot)] }), target && (_jsxs(Box, { component: "span", sx: { display: "inline-flex", alignItems: "center", gap: 1 }, children: [_jsx(Typography, { component: "span", variant: "body2", color: "inherit", "aria-hidden": true, children: "\u00B7" }), _jsx(Typography, { component: "span", variant: "body2", color: "inherit", children: target })] }))] }), _jsx(Box, { sx: { ml: "4em", mr: "4em" }, children: _jsx(MoveMaterialArrowNode, { kind: {
250
+ type: MoveMaterialNodeKindType.BasketSlotZone,
251
+ basketId: basket.basketId,
252
+ slot,
253
+ }, children: _jsx(Box, { sx: {
254
+ display: "flex",
255
+ flexWrap: "wrap",
256
+ justifyContent: "space-around",
257
+ minHeight: "4em",
258
+ }, children: slotMaterial.length > 0 ? (_jsx(SlotMaterial, { material: slotMaterial, basketId: basket.basketId, fsize: fsize })) : isUnknown ? (_jsx(Typography, { color: "warning.main", children: "Unknown" })) : null }) }) })] }, slot));
259
+ }) })] }));
207
260
  }
@@ -7,7 +7,8 @@ import { currentStatus } from "../../cell-status/current-status.js";
7
7
  import { inProcessMaterialInDialog, materialDialogOpen, } from "../../cell-status/material-details.js";
8
8
  import { currentOperator } from "../../data/operators.js";
9
9
  import { JobsBackend } from "../../network/backend.js";
10
- import { ApiException, CancelLoadRequest } from "../../network/api.js";
10
+ import { CancelLoadRequest } from "../../network/api.js";
11
+ import { apiErrorMessage } from "../../network/api-errors.js";
11
12
  import { canCancelLoad } from "../../data/material-operation-policy.js";
12
13
  export function CancelLoadButton({ onClose, ignoreOperator = false, }) {
13
14
  const material = useAtomValue(inProcessMaterialInDialog);
@@ -41,11 +42,13 @@ export function CancelLoadButton({ onClose, ignoreOperator = false, }) {
41
42
  expectedLoadCancellationId: snapshot.cancellationId,
42
43
  reason: reason || undefined,
43
44
  }));
45
+ setOpen(false);
46
+ setSnapshot(null);
44
47
  setMaterialDialogOpen(null);
45
48
  onClose?.();
46
49
  }
47
50
  catch (e) {
48
- setError(ApiException.isApiException(e) ? e.response : e instanceof Error ? e.message : String(e));
51
+ setError(apiErrorMessage(e));
49
52
  }
50
53
  finally {
51
54
  setUpdating(false);
@@ -56,5 +59,7 @@ export function CancelLoadButton({ onClose, ignoreOperator = false, }) {
56
59
  setReason("");
57
60
  setError(null);
58
61
  setOpen(true);
59
- }, children: "Cancel Load" }) })) : null, _jsxs(Dialog, { open: open && snapshot !== null, onClose: () => setOpen(false), children: [_jsx(DialogTitle, { children: "Cancel Load" }), _jsxs(DialogContent, { children: [_jsx("p", { children: "The displayed load instruction will be cancelled and recalculated for:" }), _jsx("ul", { children: snapshot?.group.map((candidate) => (_jsx("li", { children: candidate.serial || `Material ID ${candidate.materialID}` }, candidate.materialID))) }), _jsx(TextField, { label: "Reason (optional)", value: reason, onChange: (e) => setReason(e.target.value), fullWidth: true, multiline: true }), error ? _jsx("p", { role: "alert", children: error }) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { color: "primary", disabled: updating, onClick: cancelLoad, children: "Cancel Load" }), _jsx(Button, { color: "secondary", disabled: updating, onClick: () => setOpen(false), children: "Keep Load" })] })] })] }));
62
+ }, children: "Cancel Load" }) })) : null, _jsxs(Dialog, { open: open && snapshot !== null, onClose: () => setOpen(false), children: [_jsx(DialogTitle, { children: "Cancel Load" }), _jsxs(DialogContent, { children: [_jsx("p", { children: "The displayed load instruction will be cancelled and recalculated for:" }), _jsx("ul", { children: snapshot?.group.map((candidate, index) => (_jsx("li", { children: candidate.materialID < 0
63
+ ? `${candidate.partName} raw material`
64
+ : candidate.serial || `Material ID ${candidate.materialID}` }, candidate.materialID >= 0 ? candidate.materialID : `raw-${index}`))) }), _jsx(TextField, { label: "Reason (optional)", value: reason, onChange: (e) => setReason(e.target.value), fullWidth: true, multiline: true }), error ? _jsx("p", { role: "alert", children: error }) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { color: "primary", disabled: updating, onClick: cancelLoad, children: "Cancel Load" }), _jsx(Button, { color: "secondary", disabled: updating, onClick: () => setOpen(false), children: "Keep Load" })] })] })] }));
60
65
  }
@@ -41,12 +41,12 @@ import { currentStatus } from "../../cell-status/current-status.js";
41
41
  import { barcodePotentialNewMaterial, inProcessMaterialInDialog, materialDialogOpen, materialInDialogInfo, materialInDialogLargestUsedProcess, materialInDialogLocalEvents, } from "../../cell-status/material-details.js";
42
42
  import { currentOperator } from "../../data/operators.js";
43
43
  import { fmsInformation } from "../../network/server-settings.js";
44
- import { useAtomValue, useSetAtom } from "jotai";
44
+ import { useAtomValue, useAtomValueRawSync, useSetAtom } from "jotai";
45
45
  import { useEffect, useRef } from "react";
46
46
  import { last30Jobs } from "../../cell-status/scheduled-jobs.js";
47
47
  import { PartIdenticon } from "./Material.js";
48
48
  import { isLogEntryInvalidated } from "../LogEntry.js";
49
- import { ApiException } from "../../network/api.js";
49
+ import { apiErrorMessage } from "../../network/api-errors.js";
50
50
  import { canInvalidateMaterial } from "../../data/material-operation-policy.js";
51
51
  const invalidatableEventTypes = LazySeq.of([
52
52
  LogType.AddToQueue,
@@ -82,12 +82,15 @@ function InvalidateSelect(props) {
82
82
  job: currentSt.jobs[j.jobUnique] ?? history.get(j.jobUnique) ?? null,
83
83
  }));
84
84
  const hasProc = lastMat !== null && lastMat.process >= 1;
85
- const hasChangeMat = castings.length > 0 || jobs.length > 0;
85
+ const canChangeAssignment = lastMat === null || lastMat.process <= 1;
86
+ const hasChangeMat = canChangeAssignment && (castings.length > 0 || jobs.length > 0);
86
87
  const selectedCasting = props.st?.changeRawMat !== null &&
87
88
  props.st?.changeRawMat !== undefined &&
89
+ canChangeAssignment &&
88
90
  castings.includes(props.st.changeRawMat);
89
91
  const selectedJob = props.st?.changeJobUnique !== null &&
90
92
  props.st?.changeJobUnique !== undefined &&
93
+ canChangeAssignment &&
91
94
  jobs.some((job) => job.jobUnique === props.st?.changeJobUnique);
92
95
  function change(e) {
93
96
  props.setState({
@@ -102,7 +105,7 @@ function InvalidateSelect(props) {
102
105
  ? "rawMat" + props.st.changeRawMat
103
106
  : selectedJob
104
107
  ? "job" + props.st.changeJobUnique
105
- : props.st?.process && hasProc
108
+ : props.st?.process && hasProc && props.st.process === lastMat.process
106
109
  ? "proc" + props.st.process.toString()
107
110
  : "", select: true, onChange: (e) => change(e.target.value), variant: "outlined", label: props.st?.changeRawMat
108
111
  ? "Change Raw Material"
@@ -119,11 +122,6 @@ function InvalidateSelect(props) {
119
122
  hasProc
120
123
  ? [
121
124
  _jsxs(MenuItem, { value: "proc" + lastMat.process.toString(), children: ["Invalidate Process ", lastMat.process] }, lastMat.process),
122
- ...(lastMat.process > 1
123
- ? [
124
- _jsx(MenuItem, { value: "proc1", children: "Invalidate All Processes" }, "all"),
125
- ]
126
- : []),
127
125
  ]
128
126
  : [],
129
127
  hasProc && hasChangeMat
@@ -131,15 +129,17 @@ function InvalidateSelect(props) {
131
129
  : [],
132
130
  hasChangeMat
133
131
  ? [
134
- ...castings.map((c) => (_jsxs(MenuItem, { value: "rawMat" + c, children: ["Invalidate Everything and Change to ", c] }, "rawMat" + c))),
135
- ...jobs.map(({ jobUnique, job }) => (_jsxs(MenuItem, { value: "job" + jobUnique, children: [job ? (_jsx(ListItemIcon, { children: _jsx(PartIdenticon, { part: job.partName }) })) : undefined, _jsx(ListItemText, { primary: "Invalidate Everything and Change to Job " + jobUnique, secondary: job?.partName })] }, "job" + jobUnique))),
132
+ ...castings.map((c) => (_jsxs(MenuItem, { value: "rawMat" + c, children: [hasProc ? "Invalidate Process 1 and Change to " : "Change to ", c] }, "rawMat" + c))),
133
+ ...jobs.map(({ jobUnique, job }) => (_jsxs(MenuItem, { value: "job" + jobUnique, children: [job ? (_jsx(ListItemIcon, { children: _jsx(PartIdenticon, { part: job.partName }) })) : undefined, _jsx(ListItemText, { primary: (hasProc ? "Invalidate Process 1 and Change to Job " : "Change to Job ") +
134
+ jobUnique, secondary: job?.partName })] }, "job" + jobUnique))),
136
135
  ]
137
136
  : [],
138
137
  ] }));
139
138
  }
140
139
  export function InvalidateCycleDialogContent(props) {
141
140
  const curMat = useAtomValue(materialInDialogInfo);
142
- const events = useAtomValue(materialInDialogLocalEvents);
141
+ // History can resolve while InvalidateSelect suspends, before this component subscribes.
142
+ const events = useAtomValueRawSync(materialInDialogLocalEvents);
143
143
  const status = useAtomValue(currentStatus);
144
144
  const show = props.st !== null && curMat !== null;
145
145
  const boxRef = useRef(null);
@@ -182,13 +182,15 @@ export function InvalidateCycleDialogButton(props) {
182
182
  return null;
183
183
  if (!canInvalidateMaterial(inProcMat))
184
184
  return null;
185
- const allowChange = possibleNew !== null &&
185
+ const allowChange = (lastMat === null || lastMat.process <= 1) &&
186
+ possibleNew !== null &&
186
187
  (!LazySeq.ofObject(possibleNew.possibleCastingsByQueue ?? {}).isEmpty() ||
187
188
  !LazySeq.ofObject(possibleNew.possibleJobsByQueue ?? {}).isEmpty());
188
189
  if (!allowChange && (lastMat === null || lastMat.process < 1))
189
190
  return null;
190
191
  if (props.ignoreOperator)
191
192
  operator = null;
193
+ const changingAssignment = props.st !== null && (props.st.changeRawMat !== null || props.st.changeJobUnique !== null);
192
194
  function showInvalidate() {
193
195
  props.setState({
194
196
  process: null,
@@ -219,27 +221,26 @@ export function InvalidateCycleDialogButton(props) {
219
221
  props.setState({
220
222
  ...props.st,
221
223
  updating: false,
222
- error: ApiException.isApiException(e)
223
- ? e.response
224
- : e instanceof Error
225
- ? e.message
226
- : String(e),
224
+ error: apiErrorMessage(e),
227
225
  });
228
226
  });
229
227
  }
230
228
  }
231
229
  return (_jsxs(_Fragment, { children: [props.st === null ? (_jsx(Button, { color: "primary", onClick: showInvalidate, children: "Invalidate Cycle" })) : undefined, props.st !== null ? (_jsx(Button, { color: "primary", onClick: invalidateCycle, disabled: props.st.updating ||
230
+ (changingAssignment && !allowChange) ||
231
+ (!changingAssignment &&
232
+ props.st.process !== null &&
233
+ props.st.process !== lastMat?.process) ||
232
234
  (props.st.process === null &&
233
235
  props.st.changeRawMat === null &&
234
236
  props.st.changeJobUnique === null), children: props.st.changeJobUnique !== null
235
- ? "Invalidate Everything and Change to Job " + props.st.changeJobUnique
237
+ ? (lastMat?.process === 1
238
+ ? "Invalidate Process 1 and Change to Job "
239
+ : "Change to Job ") + props.st.changeJobUnique
236
240
  : props.st.changeRawMat !== null
237
- ? "Invalidate Everything and Change to " + props.st.changeRawMat
241
+ ? (lastMat?.process === 1 ? "Invalidate Process 1 and Change to " : "Change to ") +
242
+ props.st.changeRawMat
238
243
  : props.st.process !== null
239
- ? props.st.process === 1
240
- ? lastMat && lastMat.process > 1
241
- ? "Invalidate All Processes"
242
- : "Invalidate Process 1"
243
- : "Invalidate Process " + props.st.process.toString()
244
+ ? "Invalidate Process " + props.st.process.toString()
244
245
  : "Invalidate Cycle" })) : undefined] }));
245
246
  }
@@ -1,14 +1,9 @@
1
1
  import { ReactNode } from "react";
2
- import { SubmitBasketLoadStationCommand } from "./BasketLoadStationWork.js";
3
- import { SubmitBasketLocationCorrection, SubmitBasketMovementCompletion } from "./BasketMovementArrival.js";
4
2
  interface LoadStationProps {
5
3
  readonly loadNum: number;
6
4
  readonly queues: ReadonlyArray<string>;
7
5
  readonly completed: boolean;
8
6
  readonly whiteBackground?: boolean;
9
- readonly submitBasketLoadStationCommand?: SubmitBasketLoadStationCommand;
10
- readonly submitBasketMovementCompletion?: SubmitBasketMovementCompletion;
11
- readonly submitBasketLocationCorrection?: SubmitBasketLocationCorrection;
12
7
  }
13
8
  export declare function LoadStation(props: LoadStationProps): import("react").JSX.Element;
14
9
  declare function LoadStationCheckWidth(props: LoadStationProps): ReactNode;