Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(viewer): gate the in-browser raw tier at 50 MB

Sidwebworkse218960dc240
diff --git a/apps/erp/app/components/CadModel.tsx b/apps/erp/app/components/CadModel.tsx
index 338cb4184c..6ab9dbf848 100644
--- a/apps/erp/app/components/CadModel.tsx
+++ b/apps/erp/app/components/CadModel.tsx
@@ -20,6 +20,7 @@ import {
import {
convertKbToString,
getFileSizeLimit,
+ MODEL_RAW_KEEP_MAX_BYTES,
supportedModelTypes
} from "@carbon/utils";
import { ModelPreview } from "@carbon/viewer/model-preview";
@@ -187,9 +188,9 @@ const CadModel = ({
const { artifacts, pending, retry } = useModelArtifacts(modelPath);
const reoptimizeFetcher = useFetcher<{ success: boolean }>();
// A server GLB may still be on its way while a fresh file uploads or the
- // optimise job runs. There is no in-browser tessellation fallback — the viewer
- // shows a spinner until the GLB lands, then "preview unavailable" if it never
- // does (optimise failed / non-mesh).
+ // optimise job runs. Raws <= MODEL_RAW_KEEP_MAX_BYTES render in-browser (WASM
+ // tier) in the meantime; bigger ones show a spinner until the GLB lands, then
+ // "preview unavailable" if it never does (optimise failed / non-mesh).
const awaitingModel = pending || Boolean(file);
const onDelete = async () => {
@@ -350,11 +351,14 @@ const CadModel = ({
artifacts?.lodPath ? getPrivateUrl(artifacts.lodPath) : null
}
rawUrl={
- artifacts?.rawPath
+ artifacts?.rawPath &&
+ (artifacts.size ?? 0) <= MODEL_RAW_KEEP_MAX_BYTES
? getRawModelUrl(artifacts.rawBucket, artifacts.rawPath)
: null
}
- rawFile={file}
+ rawFile={
+ file && file.size <= MODEL_RAW_KEEP_MAX_BYTES ? file : null
+ }
thumbnailUrl={
artifacts?.thumbnailPath
? getPrivateUrl(artifacts.thumbnailPath)
diff --git a/apps/mes/app/components/JobOperation/JobOperation.tsx b/apps/mes/app/components/JobOperation/JobOperation.tsx
index b32c4c048d..f70de0e6f6 100644
--- a/apps/mes/app/components/JobOperation/JobOperation.tsx
+++ b/apps/mes/app/components/JobOperation/JobOperation.tsx
@@ -53,7 +53,8 @@ import {
convertDateStringToIsoString,
convertKbToString,
formatDurationMilliseconds,
- getItemReadableId
+ getItemReadableId,
+ MODEL_RAW_KEEP_MAX_BYTES
} from "@carbon/utils";
import { ModelPreview } from "@carbon/viewer/model-preview";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -1769,7 +1770,8 @@ export const JobOperation = ({
artifacts?.lodPath ? getPrivateUrl(artifacts.lodPath) : null
}
rawUrl={
- artifacts?.rawPath
+ artifacts?.rawPath &&
+ (artifacts.size ?? 0) <= MODEL_RAW_KEEP_MAX_BYTES
? getRawModelUrl(artifacts.rawBucket, artifacts.rawPath)
: null
}