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.
paths:
- "packages/ee/src/onshape/**"
- "apps/erp/app/routes/onshape+/**"
- "apps/erp/app/routes/api+/integrations.onshape.panel.*"
- "apps/erp/app/routes/api+/integrations.onshape-v2.*"
- "apps/erp/app/routes/api+/integrations.onshape.detach.ts"
- "apps/erp/app/modules/settings/settings.service.ts"
- "apps/erp/app/modules/settings/settings.server.ts"
- "apps/erp/app/components/ExternalSource.tsx"
- "packages/jobs/src/inngest/functions/integrations/onshape-*"
Onshape panel (onshape-v2)
A Carbon panel in Onshape's element right panel. Users push parts, assemblies and releases from Onshape; Carbon never pulls on its own. Spec: .ai/specs/2026-08-28-onshape-app.md. User docs: docs/content/docs/integrations/cad.mdx.
Connections
- Three Onshape grants, each with its own
companyIntegrationrow and mapping namespace:onshapeandonshape-government(sync connections,config.tsx, one active per company) andonshape-v2(the panel,config-v2.tsx). A company can run the panel beside either sync connection. ONSHAPE_V2_INTEGRATION_ID(lib/integration-id.ts): pass it to every panel read and write, e.g.getOnshapeClient(…, ONSHAPE_V2_INTEGRATION_ID). Omitted,getOnshapeClientresolves the company's sync connection. A bare"onshape"literal in panel code is a bug.ONSHAPE_INTEGRATION_IDS,OnshapeIntegrationId,isOnshapeIntegrationIdandgetConflictingOnshapeIntegration(lib/connection.ts) cover the two sync connections only.OnshapeOAuthIntegrationIdcovers all three.- Status, releases and the three plan routes read the connection with the service role. The
companyIntegrationSELECT policy needs settings view; through a parts-view user's client the row reads as absent and the panel says Onshape is not connected. The Fields route uses the user's client: it requires settings update anyway. - Only an
onshape-v2item link means "the panel pushes to this item". A sync connection's item row is BOM-import bookkeeping for the BoM Explorer; the item card and Detach never read or delete it. - OAuth: the sync integration and the panel are two Onshape apps and share no variable.
onshapereadsONSHAPE_CLIENT_ID,ONSHAPE_CLIENT_SECRET,ONSHAPE_OAUTH_REDIRECT_URL(→/api/integrations/onshape/oauth);onshape-v2readsONSHAPE_V2_CLIENT_ID,ONSHAPE_V2_CLIENT_SECRET,ONSHAPE_V2_OAUTH_REDIRECT_URL(→/api/integrations/onshape-v2/oauth). Both ask forOAuth2Read OAuth2Write. Each card isactiveonly when its own client id is set (config.tsx,config-v2.tsx); otherwise it reads Not Configured, Install is disabled and an installed connection's Details link goes nowhere; the env schema groups them asonshapeandonshapeV2.onshape-v2is alsointernalOnly: on Carbon Cloud only Carbon staff (in any company) and the users theintegration-early-accessfeature flag is on for (in the companies its rules name), or listed inINTEGRATION_EARLY_ACCESS_USER_IDSuntil a flags source is live, can install it, and everyone else sees Coming soon (isIntegrationComingSoon,@carbon/ee/plan;hasIntegrationEarlyAccess,@carbon/ee/plan.server). The install route refuses them withcoming-soon(isIntegrationInstallWithheld,modules/settings/settings.service.ts); a company that has it installed keeps it. Install routes callbeginOnshapeAuthorization; callbacks callcompleteOnshapeAuthorization(modules/settings/settings.service.ts);getOnshapeOAuthConfigpicks the client and redirect per id and answersnot-configuredwhen one of that integration's three variables is missing. A connection's tokens belong to the app that issued them: changing an integration's client id means reconnecting. State is the cookie-bound one from@carbon/auth/oauth-state.server. - Connect opens a popup (
beginOAuthPopup,packages/ee/src/oauth-popup.ts, opened inside the click). The callback rendersoauthPopupResponse: it posts the outcome to the opener and closes, or lands on the integrations page with no opener. The drawer's Reconnect action POSTs to the install route and follows{ redirectUrl }. - Uninstall only sets
active = falseand keeps the tokens, sogetOnshapeClientreads theonshape-v2row only while it is active: after an uninstall every panel read answers "not connected". A plan already stored can still be applied until it expires (15 min); APPLY makes no Onshape call. onshapeHealthcheck(hooks.server.ts) builds the client (refreshing an expired token) and reads/companies; a revoked grant reads unhealthy.- Tokens live in Vault:
SECRET_KEYS["onshape-v2"](integrations/secrets.ts) names the access and refresh token. Migration20261016051650_onshape-v2-integration.sqlseeds theintegrationrow;20261016051651_onshape-v2-vault-secrets.sqlmoves any plaintext tokens already inonshape-v2metadata into Vault.
Integration metadata
Several writers share companyIntegration.metadata: token refresh, the OAuth callback, the settings save, the webhook's Onshape company id and the Fields save. Each writes only its own keys. The others go through patchIntegrationState (row lock, dot-path patches) via the helpers in lib/state.ts; the Fields save is one Kysely UPDATE that writes propertyMap and descriptionModes with jsonb_set and merges the five default* push-default keys. Never write the whole column from an earlier read.
Token refresh
getOnshapeClient refreshes within two minutes of expiry (a missing expiresAt counts as expired) and once more per client on a 401. Onshape rotates refresh tokens, so the refresh runs under a lease from @carbon/kv (acquireLease / withLease: Lua acquire that tells "held" from "Redis down", renewal during the exchange, compare-and-delete release). The lease key is onshape-token-refresh:<companyId>:<integrationId> (5 s, renewed every 2 s); waiters poll every 250 ms and give up after 20 s. With Redis down it refreshes without a lock. The holder re-reads the stored pair and adopts a token another caller already refreshed (resolveOnshapeRefresh, lib/token-refresh.ts). The token request times out after 15 s.
Panel auth
The carbon cookie is SameSite=Lax and never reaches a cross-site iframe, so the panel has its own credential.
onshape+/panel.tsxloads without auth and is the only framable route: itsContent-Security-Policy: frame-ancestors https://onshape.com https://*.onshape.comreplaces the app's baseline directive.onshape+/auth.tsxis a same-origin popup. It takes identity from the cookie session, refuses non-employees and console sessions, applies the app shell's account gates (MFA enrollment, ITAR attestation in a controlled environment), mintscps_<32 base64url>(Redispanel-session:<token>,panel/session.server.ts; 12 h, capped at the ERP session's absolute cap in a controlled environment) and posts it to the opener. The panel keeps it in sessionStorage (carbon:onshape-panel-session) and sendsAuthorization: Bearer; a 401 clears it.- A panel session holds identity only, never a Supabase token. Each request builds its client from a short-lived token signed for the user (
getUserScopedClient). Copying the cookie session's refresh token would make the panel and the ERP tab rotate one chain, and GoTrue revokes the family on reuse. - Panel writes are settings operations (
settings.server.ts):pushOnshapePart,pushOnshapeAssembly,pushOnshapeReleaseandsaveOnshapePropertyMap, with their bodies insettings.service.ts. A route authenticates withrequireOnshapePanelPermissions, binds the operations to that user withcarbonFor(auth)(@carbon/api/carbon.server), and makes one call. An operation answers aPanelReply({ status, body }), andpanelResponsesends it as given: the panel reads the status (410 expired, 422 withfieldErrors) and the body. Detach (detachOnshapeItem) runs on the cookie session throughcarbon(request). - Panel routes call
requireOnshapePanelPermissions(@carbon/ee/onshape/panel-session.server), notrequirePermissions. It applies the cookie path's session policy (panelSessionRefusal: absolute cap and idle lock in a controlled environment; a TOTP factor enrolled after minting everywhere), requires theemployeerole, then runs the same claims check. Denials are 401 or 403, never redirects. Activity is stamped only on an authorized request withSET … KEEPTTL XX, so a deleted session stays deleted. - Tokens never appear in URLs. postMessage targets
window.location.origin.
Identity (externalIntegrationMapping, integration onshape-v2)
| Entity | externalId |
|---|---|
| Part item | documentId:elementId:partId[:configuration] |
| Assembly item | documentId:elementId:assembly[:configuration] |
| Release revision item | release:<releaseId>:<partNumber> |
| Onshape-written BOM line | entityType methodMaterial; metadata.makeMethodId names the method |
| Draft the panel made | entityType makeMethod (DRAFT_MARKER_ENTITY_TYPE); externalId is the Draft id, metadata.sourceMethodId the Active method it copied |
| Source of an item's last assembly export | entityType modelSource, entityId the item, integration the connection's id; externalId hashes the document, element, configuration and the version or workspace microversion; metadata.modelUploadId the model it produced |
A non-default configuration is appended to the key (normalizeConfiguration, externalIdFor* in panel/status.ts).
Plan and apply
Every push is two requests. PLAN (api+/integrations.onshape.panel.plan-{part,assembly,release}) reads Onshape and Carbon, builds the plan with the pure builders in panel/plan.ts, stores it and returns { planId, expiresAt, plan }. APPLY (push-{part,assembly,release}) takes the stored plan and writes; it makes no Onshape call. A cancelled or expired review has spent its reads.
- Store:
lib/panel-plan-store.ts, Redispanel-plan:cpp_<32 base64url>, 15 min, bound to company and user. APPLY peeks to validate (a 422 leaves the plan in place) and takes it with GETDEL right before the first write. A plan Redis did not store answers 503 at PLAN; a missing, expired or foreign plan answers 410 at APPLY. - The review's only editors are three selects per row (
ItemFieldSelects.tsx: replenishment, method type, tracking type). A choice is written to Carbon only. A create validates them withmergeItemEdits; an existing item withmergeExistingItemEdits, writing only what differs fromcurrent. - A part is
unchangedwhen its microversion matches the one the last push recorded. If an "everyPush" value or description still differs, the row becomes anupdateflaggedcadUnchanged: apply writes values and link and skips the model export. - APPLY re-resolves items by readableId before creating. Parts adopt with
pickAdoptTarget: a Part at the same revision, else the latest Part (active rows first), never another item type with the same number. Revisions compare asgetNextRevisioncounts them (compareRevisions,panel/revision.ts). plan-assemblytakesdepth:all, ortop(the root's method only, each sub-assembly a line pointing at its own method). Withallit refuses more thanMAX_PLAN_PARTS(1500) distinct part numbers withcode: "too-large", and the panel offers "Push this level only". A root with no part number is refused.- Pushing needs
wvto beworv; a microversion view shows status only.plan-parttakes 1 to 50 part ids.
Item and BOM writes
- New item fields follow one precedence (
proposeMappedItem): the reviewer's choice, the mapped value, a BOM row with children is Make, a Standard content row is Buy, then the push defaults (parsePushDefaults,panel/preferences.ts: Make, Make to Order for Make, Pull from Inventory for Buy, Inventory tracking, and a unit that falls back to the configured one, thenEA, then the company's first unit). An unparseable default falls back, and an illegal pair moves to an allowed method (reconcilePushDefaults). A mapped Replenishment with no mapped method takes the push default for it (methodTypeForMake,methodTypeForBuy) when the pair allows it. An empty name becomes the part number; an empty revision becomes0. "Show Assembly only" (shownAsUnit) decides structure only; "Purchasing Level" is not read. - No field is locked. A linked item is a Carbon item; a later push writes only "everyPush" values.
- An assembly push links the root (unless it is released in Carbon: then only the children are linked) and links a child to its Onshape source only when neither is linked yet (
linkChildParts); two items claiming one source are reported, not linked. Every reused item linked to its BOM row takes the "everyPush" values (planExistingItem); an item linked to another Onshape source takes none. Only description values Onshape gives are written (assemblyTextChanges): an empty cell never blanks Carbon's text. Item fields are written before BOM lines. - BOM lines take only Part, Material or Consumable items (
BOM_LINE_ITEM_TYPES). The plan lists a part number Carbon holds as another type underskipped; apply reports it as an error. - Assembly BOM pushes are a diff. An owned line (one a previous push wrote, per its mapping row) is updated in place (
quantity,order,materialMakeMethodId) or skipped when those match; owned lines Onshape no longer lists are deleted with their mappings. New lines and their mapping rows are inserted in one Kysely transaction (insertOwnedMethodLines,modules/settings/settings.service.ts; a count mismatch rolls back). - A manual line for a part number Onshape also lists is taken over (
pairManualLinesinplan.ts, applied byclaimManualMethodLine): Onshape's quantity, order and child method, its operation and scrap kept. Only a line whoseitemTypematches is taken over. Other manual lines are left alone. - Active make methods are never edited. An Active method whose lines already match Onshape's is left as is. The plan marks it
unchangedwhen part numbers and quantities match in order with nothing taken over and no reusable Draft; apply decides again (linesWouldChange): owned lines paired by item id (FIFO), each with the samequantity,orderandmaterialMakeMethodId(the child method apply resolves), and no owned line left over. Otherwise the push writes into a Draft (ensureDraftMakeMethod,modules/settings/settings.service.ts). It reuses a Draft only when the panel made it from the current Active method and no change notice holds it (pickReusableDraft); otherwise it makes versionmax(version) + 1throughcreateMakeMethodVersion, which copies the BOM and routing as the system (a parts user need not hold production update). The Draft, its copy, the ownership carried withpairOwnedCopiedLines(carryLineOwnership, which reads the copied lines in the same transaction) and the marker row are one Kysely transaction, so any failure leaves no Draft. The assembly plan loads the reusable Draft (loadReusableDrafts), so the review names the Draft the push writes into. - With no Active method,
activeMakeMethodsreturns the newest Draft, which can be a change notice's;loadActiveMakeMethodsreads itschangeOrderIdfrommakeMethod.loadMethodWriteRefusals(modules/settings/settings.service.ts) refuses a change notice's Draft whatever the notice's stage, and a released (Production) revision whenplmReleaseControlisenforce(getLockVerdict, the verdictcheckRevisionLockgives the BOM editor). Plan drops those methods intoskippedwith the reason (withRefusedMethods; anunchangedActive method is not refused). Apply checks again before it makes a Draft and reports a refusal underskipped. - Every delete is scoped by
companyId. Never build a PostgREST.or()string from CAD values. - Item page: one mount point,
ExternalSourceCardinx+/part+/$itemId.details.tsx. It shows the fields a push replaces (everyPushTargets), last push time, Open in Onshape and Detach (api+/integrations.onshape.detachdeletes the item'sonshape-v2row only). A later push can link the item again by part number.
Property map
One map per company: metadata.propertyMap, plus metadata.descriptionModes for Name and Description. Entry: { onshapePropertyId, onshapeName, valueType, target, mode, translations? }; target is { kind: "customField", fieldId } or { kind: "item", field }. Pure logic in panel/properties.ts and panel/standard-fields.ts.
STANDARD_FIELDSis the only place an item field becomes mappable:mpn,replenishmentSystem,defaultMethodType,sourcingType,itemTrackingType,unitOfMeasureCode. Each names its writer key;STANDARD_FIELD_WRITERS(modules/settings/settings.service.ts, a typedRecord) holds one function per key:itemMethod(updateItemMethodAndSourcing, cascades onto Draft method materials),itemTracking(update pluscascadeItemTrackingType),itemColumn(updateItemColumns). There is no generic column write.- Translation: a list target carries rows
{ onshape, carbon | null }, matched ignoring case and end spaces (translateValue). A unit also matches by code or name.nullmeans "No value": the next precedence rule decides. An unmatched value is a review problem and is skipped. - Modes:
create(default) writes only when the push creates the item;everyPushalso writes to a linked existing item. - Existing items: "everyPush" values go through
interlockItemFieldsin the item page's order: Replenishment (with the methodmethodForReplenishmentgives: Make → Make to Order and Buy → Purchase to Order, asderiveItemMethodUpdatepins; Buy and Make keeps an allowed method and moves Make to Order to Pull from Inventory, since apply refuses that pair), method (refused when Replenishment does not allow it), Sourcing (Buy and Make only), then tracking, unit and MPN. - New items: every mapped value goes into the proposal.
upsertParttakes neither MPN nor Sourcing, so apply writes those after the insert (createdItemExtras). - Values are read from part metadata (
readPartProperties, one read atdepth=2), the root's element metadata, BOM cells (matched by column id, then name) and released metadata at the released version. A list value is read as its option's label (enumLabel). A BOM cell "N/A" means the row lacks the property and reads as null. An empty map costs no extra reads. loadPlanMappingandloadPlanOptionsread with the service role, for the same settings-view reason as the connection.- The Fields page (
api+/integrations.onshape.panel.fields.ts) lists the element's properties, the map, the modes, the push defaults, part custom fields and units; POST saves them. Both need settings update;panel.mereturnscanEditFields. The save refuses a value type the target does not take, a translation value outside the field's list, an Onshape value with two rows, two properties on one target, and deleted fields (422, per property). Limits: 100 entries, 100 translations each, 255-character values. MAPPABLE_VALUE_TYPESfor custom fields: STRING/ENUM/OBJECT → Text, BOOL → Yes/No, INT/DOUBLE → Numeric, DATE → Date. Nothing maps to a List custom field.- Custom field values land in
part.customFieldskeyed by readableId, shared across revisions. Writes merge only mapped keys (mergeCustomFieldValues); an emptied "everyPush" value deletes the key. A Yes/No field stores the string"on"(BOOLEAN_TRUE).
Release push
Releases come from
GET /revisions/d/{did}, grouped by releaseId (panel/releases.ts). An empty list triggers onegetCompanies()call; with no Onshape company the route returnsreleaseManagementAvailable: false.Each released model item gets an item at the released letter:
createRevisionfrom the newest revision below it, released or not (pickRevisionBase), else from the latest row; a fresh item only when Carbon has no row for the part number. Idempotent on part number and letter.Each released assembly's BOM is read at its released version and configuration, keyed by
releaseBomKey(element id, plus the normalized configuration when it is not the default), so two configurations of one element keep two BOMs.BOM children that are not release items are resolved in one lookup and point at the revision the released BOM names, else the latest row (
pickBomChildRow). A child that is a release item points only at the revision this push applied; a release item that was held back or failed is not created as a child, and its line is reported and not written.The release items the push creates are staged under one Draft change notice: an open notice from an earlier push of the same release whose engineering content is editable and that is not waiting for approval (
findOpenReleaseNotice: links matched onmetadata.releaseId, item reads batched), else a new one inserted before the first item write (a failed insert writes nothing).stageChangeNoticeItem(modules/settings/settings.service.ts) does whatcreateChangeNoticeDraftMethoddoes, in one transaction: the item is inactive, it and its Draft method carry the notice id, and one affected row (Revision or New Part) names the base item and both methods. Releasing the notice activates them.findOpenReleaseNoticefails closed: a failed read refuses the plan or the push (nothing written) rather than opening a second notice; the push reads it before taking the plan. An item the notice cannot take is deleted again (service role,deleteItem) and reported, so it never sits outside change control. A notice this push inserted is deleted when nothing was created.BOM children the release push creates are not staged on the notice. An assembly whose BOM was not read at review is not created, and any BOM read failure skips every BOM write.
With
createChangeNotice: false(API only; the panel always sends the plan's notice) revisions are created active and, unlessmakeDefaultis false,updateDefaultRevisionmakes each the default, repointing every BOM line that uses a revision of the part.Release BOM lines: the push deletes the revision's copies of the base's Onshape lines and every
onshape-v2-owned line on the target method (any earlier push's, not only this release's), then inserts one level per method in one transaction, withreleaseIdin the mapping metadata. The item link isrelease:<releaseId>:<partNumber>unless the reused revision is already linked to a part or assembly.A released method in Carbon is not edited; its BOM is reported as skipped.
A reused revision held by a change notice whose engineering content is locked (Implementation onward, or awaiting approval; any of the item's make methods carries the notice id) takes neither field values nor BOM lines; it is reported as skipped with
requireChangeNoticeEditable's reason. A Draft held by an editable notice, the release's own included, stays writable.Model exports carry the revision's
partIdand configuration (releaseExportSelection). A Part Studio item with no singlepartIdis skipped.A released drawing attaches to its model item as
<partNumber>-<revision>.pdf(releaseDrawingFileName), its only record. The Releases tab reads it back by name, so a drawing-only release reads In Carbon once its PDFs land. A re-push re-exports onto the same path.Models export as STEP (
exportStepModel,onshape-sync-element.ts), never a mesh: the row is what a manual STEP upload makes, so the optimizer builds the preview GLB, compaction keeps the original (originalPath, the Download) in the company bucket, and an assembly instruction can convert and plan it. A part's source id is taggedselected-part-step-v1; the GLTF generations holdselected-part-v1, and reusing that id fails the attach's identity check.Every model export gets its own
modelUploadrow (attachOnshapeAssetsToItem,packages/jobs/.../integrations/onshape-attach.ts). A released part is named by its source (sourceId,onshape-sync-element.ts); an assembly, or a workspace part with no microversion, by its bytes (contentSourceId: a hash of the content hash whoever staged the export reported, so the file is never read again). Unchanged bytes reuse the row. Changed bytes get a new row and the item is repointed to it. Never refresh a row in place: the compacted raw, the preview and the assembly graph are keyed by the model id, and a durable copy is never overwritten, so an in-place refresh kept the old geometry. The prior model is kept as an item document unless it is an earlier Onshape sync: anonshape-id, or, for an export with no source id, the same file name (the old in-place rows had plain ids). The new row startsmodel-optimize(queue_model_pipeline); no Onshape job sends it.
Batch every .in() sized by CAD data
The gateway rejects a request line over 4,096 bytes, and a PostgREST .in() list rides in the URL; 55-character mapping keys fail at about 56 entries. Every panel .in() sized by a BOM, part studio or release goes through selectInBatches / chunkFilterValues (lib/batched-filter.ts), which split on encoded bytes. It also pages each batch past PostgREST's 1,000-row cap (.range() until a short page, ORDER BY the query's own order then orderBy, default id), so the factory is called once per page and must return a fresh builder. Batched rows arrive in batch order; re-sort after, with a unique tie-break (BOM lines sort by order, then id).
Onshape API facts
- Root identity comes from element metadata ("Part number", "Name", "Description"); the BOM's top-level row (
includeTopLevelAssemblyRow=true) is the fallback. - A company BOM template can relabel columns ("PART NUMBER", "Qty") but never their
propertyName(item,quantity,partNumber,revision,name,description,bomBehavior).parseBomTreefinds each column bypropertyName, then by exact label, then by label ignoring case (headerIdFor,panel/bom.ts; a repeated label keeps its last header); the reserved and fixed property-name sets compare in lower case. - A Part Studio model export needs exactly one
partId. Thumbnails come from Carbon's model optimizer, never Onshape's thumbnail endpoint (it cannot select a part or configuration, and the optimizer renders one anyway). GET /documents/d/{did}/w/{wid}/currentmicroversionchanges on any edit to the document. An assembly's own element microversion does not change when a Part Studio it uses does, so the export skip keys on the document's.onshape.model.translation.completecan be registered per document (documentId,isTransient: true); its payload carriestranslationId. A webhook that answers errors is dropped by Onshape.- Unresolved action-URL placeholders arrive literally (
{$partNumber}) and are read as null (parsePanelContext). - Extensions render only for users subscribed to the app; an OAuth grant alone shows nothing.
- A linked document's BOM can report a different revision for a part than the source document's BOM at the same version.
- A private app's calls bill the owner's yearly quota; public App Store apps are exempt. A spent quota answers 402, and
onshapeFailure(lib/onshape-failure.ts) says so.
Background job and dev workflow
- An element's export is
runOnshapeElementSync(onshape-sync-element.ts), resumable steps namespaced by a prefix:existing(a released part's model id is known before any export; when its row exists the export is skipped and the item linked to it. An assembly is compared with itsmodelSourcemapping: the version, or the workspace's current microversion (one call), unchanged and the item still on the model it produced skips the export too),translate(the model and every drawing translation start at once), the wait (waitForTranslations: all translations polled together, six quick polls withstep.sleepbetween; one still running registers a transient translation.complete webhook (webhook) and waits oncarbon/onshape-translation-complete(wait-n, 5 min) with a poll after each wait, deleted (unwebhook) when done; with no webhook it polls every 30 s; an hour without finishing fails the sync. The webhook only wakes the run, the poll reads the result),fetch(astep.invokeofonshape-fetch,onshape-fetch.ts: the assembler'sfetchaction copies the STEP from Onshape into temp-staging at{companyId}/models/onshape-fetch-{translationId}.step, with a bearer fromOnshapeClient.externalDataDownloadminted inside the submit step; with no assembler configured, onedownloadstep stages it),drawingsandattach(moves the staged object to{companyId}/models/{id}.step, inserts the row, records an assembly'smodelSource). A retry resumes at the failed step, so a late failure never re-runs a translation. A fetch refused withLIMIT_EXCEEDEDreturnstooLarge(a permanent skip), never throws. Every Onshape-calling step is wrapped inwithRateLimitRetry(onshape-rate-limit.ts). A staged object a failed attach leaves behind is an unreferenced temp-staging object, which the 7-day staged-raw sweep (scheduled/cleanup.ts) removes. - A released drawing alone (no model element) is
runOnshapeDrawingSync, the same steps without the model:translate, the wait,attach(downloads the PDF and attaches it; a PDF past the document limit returnstooLarge). - Callers:
onshape-panel-syncandonshape-revision-sync(after itsresolve-revisionstep, which returns either an element or a drawing to sync) run the pipeline in their own run; the backfillstep.invokesonshape-element-syncper model item andonshape-drawing-syncper released drawing, so a long backfill stays under the per-run step limit. None of them carriesASSEMBLER_CONCURRENCY: Inngest counts every executing step of a function against its keys, so the Onshape polls would take the five env-wide assembler slots from optimize, convert and plan. Onlyonshape-fetchcarries it. The three run checkpointing (ONSHAPE_CHECKPOINTING,maxRuntime: "60s"): consecutive steps share one request. KeepmaxRuntimefar below Vercel's 300 s, since a step that starts late in the window gets only the rest of the request; checkpointing is not on client-wide because other functions have single steps that run for minutes. onshape-panel-sync(Inngest) is the panel's job: the element pipeline above, or a released drawing as PDF.elementKindispartstudio,assemblyordrawing; retries 1; concurrency 1 per item. Applies queue it with event id<planId>:<itemId>:<elementId>, so a retried apply exports once. A queue failure is reported and the writes stay; a part push then deletes the new link so the next push retries.ONSHAPE_DEV_CACHE=1serves repeated GETs from a 10-minute Redis cache, only forDEV_CACHEABLE_PATHSinlib/client.ts; the key is the path alone, so every company shares entries. Never add a polling endpoint (currentmicroversionis excluded for that reason). Live calls are counted in Redisonshape:api-calls:<year>, and per endpoint in the hashonshape:api-calls:<year>:paths(ids replaced by{id},apiCallPathKey).webhook.onshape.$companyId.tsanswersonshape.model.translation.completeand Onshape'swebhook.*events for any active Onshape connection, the panel's included, before the sync connection's checks; a translation event becomescarbon/onshape-translation-complete.
Panel UI
- Pages: the push page (labelled Parts, Assembly, or Push on any other element, where it says there is nothing to push), Releases (needs a
documentId) and Fields (settings update, on a Part Studio or assembly). The Carbon company and Sign out sit on the right. - Errors carry
diagnostics, shown byPanelDiagnosticsbehind Show details / Copy details together with the Carbon host and the panel's own URL parameters (onlyREPORTED_PANEL_PARAMS: the action-URL placeholders plusserver, raw so an unfilled{$elementId}shows; any other parameter is dropped). The report is rebuilt when the diagnostics change. Sources: everyonshapeFailurebody (OnshapeFailureDiagnostics: the read,onshapeApifromOnshapeApiError.apiOrigin, Onshape's status, themessageof its error body viaOnshapeApiError.onshapeMessage, or the transport error when nothing answered; never the raw body), and the missing-columns refusals ofstatus,plan-assemblyandplan-release(the request coordinates,onshapeApifromOnshapeClient.apiOrigin, the missing columns,describeBomPayload: payload keys, header ids, names and property names, row count, template id; never a cell value).plan-releasereturns them per unread BOM beside its warnings, and each route logs the same at warn. - The theme follows Onshape's
themeaction-URL parameter: theonshape+layout declareshandle.hostModeand the root renders that mode. Missing means light. - Part badges: Linked, Conflict (same part number, not linked to this source; a push uses that item), Unlinked, and Released (released in Onshape; its Push is disabled because changes come through a release). Release states: In Carbon, Partial, Not in Carbon. The assembly BOM is the structured tree (
panel/bom-view.ts). - Moving to another element clears a part or assembly review and the Fields state; a release review survives within the same document.
- Every action is disabled while a read or write is in flight.
panelFetchgives up after 60 s (PanelTimeoutError); applies pass no timeout, since a push keeps writing after the panel stops waiting. onshape+/_layout.tsxowns the scroll (h-dvh overflow-hidden): a pinned header, one scrolling body (min-h-0 flex-1 overflow-y-auto) and a sticky action bar. The document must never scroll: under the app shell'shtml.h-fullthe root becomes a scroll container, and opening a Radix Select there snaps it to the top and closes the popup. Never addmin-h-screenormin-h-dvhto the panel shell.