Cartesiandocs

React

Reference

Components, hooks and types exported by @cogitx/cartesian-react.

Components

ComponentProps
CartesianProviderclient or config, options, listener, host, panel, children
CartesianChatonClose?, className?, style?. Fills its parent.
CartesianPanellayout? (auto, bottomSheet, sidePanel, floating, fullScreen), panel?, onHidden?, container?
CartesianAskButtonlabel?, expanded?, visible?, prompt?, icon?, containerColor?, contentColor?, panel?, className?, style?
CartesianAskBarplaceholder?, panel?, className?, style?
AgentOrbactivity, size?, color?, paused?, onDark?

CartesianComponents holds the default component for every slot, plus Orb, Icon, OfflineBanner, ErrorRecovery and PoweredBy.

Hooks

HookReturns
useCartesian()CartesianController
useCartesianClient()The provider's CartesianClient
useCartesianPanel()The provider's CartesianPanelState
usePanelSnapshot(panel?){ isVisible, detent, layout, pendingPrompt }
useCartesianHost()The provider's CartesianHostState

Cartesian.present(prompt?, detent?) and Cartesian.hide() control the panel of the latest mounted provider.

CartesianController

chatChatState
The conversation.
authAuthState
restoring, signedOut or signedIn with user.
connectionConnectionState
Socket state.
cart / wishlistCart / Wishlist
The built-in cart and wishlist.
cartCount / savedCountnumber
Header counts. They follow the feature mode, so in host mode they come from CartesianHostState.
suggestionsstring[]
Follow-ups to show now: empty while an answer is running or when follow-ups are off.
startersstring[]
Welcome-screen questions.
draft / setDraftstring / (text) => void
The composer text.
drawer"cart" | "wishlist" | null
The open drawer tab.
errorstring | null
The last action error.
canSendboolean
Online, connected, not loading and not answering.
isDeviceOnline / isRetryingboolean
From navigator.onLine and the restore or reconnect loop.
isWhiteLabel / licenseboolean / CartesianLicense
Licence result.
assistantName / cartName / heading / subtitle / placeholder / disclaimer / signedOutTextstring
Resolved copy.

Actions: send(text?), stop(), newChat(), retry(), rate(id, rating), addToCart(product, quantity?), setQuantity(id, quantity), toggleSaved(product), openProduct(product), openCart(), openWishlist(), showDrawer(tab | null), checkout(), saveForLater(product), moveToCart(product), dismissError(), retryConnection(). Lookups: quantityInCart(id), isSaved(id), isBusy(id).

CartesianClient

MemberDescription
signIn(token)Validates the token with GET /api/auth/session and connects.
restore()Re-checks a saved token. Called for you by the provider.
signOut()POST /api/auth/logout and clears local state.
hasSavedSessionA token is stored.
auth, connection, cart, wishlist, threads, licenseStores.
chatChatSession. See Headless.
Cart and wishlist methodsrefreshCart, addToCart, setCartQuantity, removeFromCart, clearCart, refreshWishlist, save, unsave
ThreadsrefreshThreads, renameThread, deleteThread
Otherprofile, compare, readPhotoText, connect, reconnectNow, disconnect, close

Models

Product wraps the backend JSON. Typed getters: id, name, brand, price, regularPrice, isOnSale, currency, imageUrl, productUrl, sku, size, category, department, aisle, shelf, color, description, features, promoLabel, rating, reviewCount, isUsual, isSnapEligible. get(key) reads any attribute and raw / toJson() give the full object.

Cart has lines ({ product, quantity }), itemCount, distinctItemCount, total, currency and quantityOf(id). Wishlist has products and has(id). Comparison has products, rows, summary, nextStep, recommendations and prosCons.

Options

CartesianOptionsInput: title, starters, theme (CartesianThemeInput), features (Partial<CartesianFeatures>), slots (CartesianSlots), strings (CartesianStrings). See Customize.

Accessibility

  • Every icon button has a label. Product cards, the cart drawer tabs and the sheet handle are reachable with the keyboard.
  • The sheet, side panel, full-screen panel and cart drawer are modal dialogs: focus is trapped inside and returns to the trigger on close. Escape closes the innermost one.
  • Live activity, connection status and errors are announced with aria-live regions.
  • With prefers-reduced-motion, transitions are shortened and the orbs stop animating.