Component Blocks Reference
Reusable UI widgets for the Layout Designer
Overview
Blocks vs Widgets: Component blocks are self-contained layout sections (Asset Browser, Timeline, AI Chat). For individual field inputs (color pickers, sliders, entity selectors), see Field Widgets Reference.
Component blocks are self-contained UI widgets that can be placed in layout sections alongside form fields. They are defined in the Component Block Registry and rendered by ComponentBlockRenderer. Both live in the studiobrain-core frontend (frontend/src/lib/component-block-registry.ts and frontend/src/components/ComponentBlockRenderer.tsx); this repo consumes them through the pinned @biloxistudios/studiobrain-core-frontend package and does not carry its own copy. Block changes are a core-repo PR plus a pin refresh.
Block categories are display, media, interaction, workflow and plugin.
Built-in Blocks
entity-assets
| Property | Value |
|---|---|
| Category | media |
| Modes | edit, view |
| Source | builtin |
Full asset browser with upload, primary image selection, and asset role management.
Config Options:
title(string, default: “Assets”) — Section headingshowUpload(boolean, default: true) — Declared in the registry schema; the renderer currently passes onlytitleto the component
entity-timeline
| Property | Value |
|---|---|
| Category | display |
| Modes | edit, view |
| Source | builtin |
Timeline event panel showing entity history with auto-populate capability.
Config Options: None (the registry declares no config_schema, and the renderer does not forward config to the panel)
production-status
| Property | Value |
|---|---|
| Category | workflow |
| Modes | edit, view |
| Source | builtin |
Production pipeline status editor. Reads and writes the entity’s production_status field.
Config Options: None
markdown-content
| Property | Value |
|---|---|
| Category | display |
| Modes | view |
| Source | builtin |
Rendered markdown body content using the MarkdownRenderer component. Always renders the entity’s markdown_body.
Config Options: None
primary-image
| Property | Value |
|---|---|
| Category | media |
| Modes | view |
| Source | builtin |
Hero/primary image display with placeholder fallback when no image is set.
Config Options:
max_height(select, default: “500px”) —200px,300px,500px,700pxornoneobject_fit(select, default: “cover”) —cover,containorfillrounded(select, default: “lg”) —none,md,lg,xlorfull
entity-chat
| Property | Value |
|---|---|
| Category | interaction |
| Modes | view |
| Source | builtin |
AI-assisted chat panel for entity editing and brainstorming.
Config Options: None (the panel component accepts a visibility prop of team or private, but the renderer does not pass one, so it uses the default team)
entity-relationships
| Property | Value |
|---|---|
| Category | display |
| Modes | view |
| Source | builtin |
Automatically scans common relationship fields and renders them as grouped link cards. Scanned fields: relationships, allies, enemies, members, associated_characters, associated_locations, associated_factions, vendors, spawn_locations, drop_sources.
Config Options:
showAddButton(boolean, default: false) — Show an add button
entity-workflow-trigger
| Property | Value |
|---|---|
| Category | workflow |
| Modes | edit |
| Source | builtin |
ComfyUI workflow trigger buttons for entity-level AI generation.
Config Options: None
ai-generation-hub
| Property | Value |
|---|---|
| Category | workflow |
| Modes | edit, view |
| Source | builtin |
Unified AI media generation panel for images, audio, and video.
Config Options:
allowedMediaTypes(string, comma-separated, default: "") — Restrict media typesdefaultMediaType(string, default: “image”) — Initial media type
static-content
| Property | Value |
|---|---|
| Category | display |
| Modes | edit, view |
| Source | builtin |
Static text, markdown notes, headers, separators, or info/warning boxes placed directly in a layout.
Config Options:
content_type(select, default: “text”) —text,markdown,header,separator,infoorwarningcontent(textarea, default: "") — The contentheading_level(select, default: “h3”) —h2,h3orh4(forheader)
Creating a Custom Block
These steps are a change to core, not to this repo.
Step 1: Create the Component
// frontend/src/components/blocks/MyCustomBlock.tsx
interface MyCustomBlockProps {
config?: Record<string, any>;
entityType: string;
entityId: string;
data: any;
mode: 'edit' | 'view';
}
export default function MyCustomBlock({ config, data, mode }: MyCustomBlockProps) {
return <div>{/* Block UI */}</div>;
}Step 2: Register in ComponentBlockRenderer
// frontend/src/components/ComponentBlockRenderer.tsx — add a case to the switch
case 'my-custom-block':
return <MyCustomBlock config={config} entityType={entityType} entityId={entityId} data={data} mode={mode} />;Step 3: Add to Registry
// frontend/src/lib/component-block-registry.ts — add to BUILTIN_BLOCKS array
{
id: 'my-custom-block',
label: 'My Custom Block',
description: 'Does something useful',
icon: 'Sparkles',
category: 'display',
source: 'builtin',
default_config: {},
config_schema: {
title: { type: 'string', label: 'Title', default: 'Default Title' },
showExtra: { type: 'boolean', label: 'Show Extra', default: false },
},
modes: ['edit', 'view'],
}The block appears in the Layout Designer palette under its category.
A layout JSON can also set editor_component or viewer_component to a block id, which renders that block as the entire editor or viewer for the entity type and ignores the layout’s sections.
Config Schema
Blocks can declare a config_schema for designer-editable settings. The BlockConfigPanel (frontend/src/components/LayoutDesigner/BlockConfigPanel.tsx) renders it dynamically.
Supported Field Types
| Type | Renders As | Example |
|---|---|---|
string | Text input (the fallback for any unrecognized type) | type: 'string', label: 'Title', default: 'Assets' |
number | Number input | type: 'number', label: 'Max Items', default: 10 |
boolean | Checkbox | type: 'boolean', label: 'Show Upload', default: true |
select | Dropdown (requires options: [{ value, label }]) | type: 'select', label: 'Max Height', default: '500px', options: [...] |
textarea | Multi-line text area | type: 'textarea', label: 'Content', default: '' |
Rendering
ComponentBlockRenderer receives these props:
interface ComponentBlockRendererProps {
componentId: string; // Block ID or "plugin:{pluginId}:{panelId}"
config?: Record<string, any>;
entityType: string;
entityId: string;
data: any;
onChange?: (data: any) => void;
mode: 'edit' | 'view';
}It uses React.lazy for code-splitting the heavier components (EntityAssets, EntityChatPanel, AIGenerationHub) and dispatches to the correct block based on componentId. Unknown blocks show a warning fallback. Plugin blocks (ids starting with plugin:) are routed to PluginBlockIframe.
Manifest Components
These work with the project manifest for entity asset browsing.
Status:
GET /api/manifestcurrently returns only an aggregate (tenant_id,version,generated_at,entity_counts,status), not the per-entryProjectManifestthatuseManifestis typed against.entriesis therefore empty, andentityIndex,getEntityEntriesandgetEntityAssetSummaryreturn nothing until a server implements that contract.POST /api/manifest/refreshandGET /api/manifest/diffreturn501 Not Implemented.
EntityAssetIndicator
Location: none. This component no longer exists in the source tree. The section below is retained as historical reference.
Displayed asset count and total size for an entity using manifest data.
Showed asset indicators like “2 images, 1 video (14 MB)” or “6 assets (14 MB)” for an entity.
Props:
interface EntityAssetIndicatorProps {
summary: EntityAssetSummary | null; // From useManifest().getEntityAssetSummary()
compact?: boolean; // Use compact mode (default: false)
}useManifest Hook
Location:
studiobrain-core/shared/src/hooks/useManifest.ts(exported from the shared package)React hook that fetches and caches the project manifest.
Fetches GET {apiConfig.backendUrl}/api/manifest on mount and provides computed data for entity browsing.
Options:
interface UseManifestOptions {
apiConfig: APIConfig;
autoFetch?: boolean; // default: true
pollingInterval?: number; // default: 60000 (ms)
}Returns:
interface UseManifestResult {
manifest: ProjectManifest | null;
isLoading: boolean;
error: string | null;
entries: ManifestEntry[];
getEntityEntries: (entityType: string, entityId: string) => ManifestEntry[];
getEntityAssetSummary: (entityType: string, entityId: string) => EntityAssetSummary | null;
entityIndex: Record<string, string[]>; // type -> [id, id, ...]
refresh: () => Promise<void>;
lastRefreshed: Date | null;
manifestAge: number | null; // seconds since generation
}Behavior:
- Periodic polling — re-fetches every
pollingInterval(60 seconds by default) - Manual refresh —
refresh()re-runs the sameGET /api/manifest; there is no server-side refresh - Computed indices — entity index and asset summaries are memoized
Example usage:
import { useManifest } from '@studiobrain/shared';
function EntityBrowser({ apiConfig }) {
const { manifest, entityIndex, refresh, isLoading } = useManifest({ apiConfig });
if (isLoading) return <div>Loading manifest...</div>;
return (
<div>
<button onClick={refresh}>Refresh Manifest</button>
<p>Manifest generated: {new Date(manifest?.generated_at || '').toLocaleString()}</p>
{Object.entries(entityIndex).map(([type, ids]) => (
<p key={type}>{type} ({ids.length})</p>
))}
</div>
);
}Schema types:
| Type | Description |
|---|---|
ProjectManifest | Full manifest (project_id, entries, provider_type, etc.) |
ManifestEntry | Single entry (relative_path, entity_type, size_bytes, etc.) |
EntityAssetSummary | Computed summary (image_count, video_count, total_size_bytes, etc.) |