DeveloperComponent Blocks Reference

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

PropertyValue
Categorymedia
Modesedit, view
Sourcebuiltin

Full asset browser with upload, primary image selection, and asset role management.

Config Options:

  • title (string, default: “Assets”) — Section heading
  • showUpload (boolean, default: true) — Declared in the registry schema; the renderer currently passes only title to the component

entity-timeline

PropertyValue
Categorydisplay
Modesedit, view
Sourcebuiltin

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

PropertyValue
Categoryworkflow
Modesedit, view
Sourcebuiltin

Production pipeline status editor. Reads and writes the entity’s production_status field.

Config Options: None


markdown-content

PropertyValue
Categorydisplay
Modesview
Sourcebuiltin

Rendered markdown body content using the MarkdownRenderer component. Always renders the entity’s markdown_body.

Config Options: None


primary-image

PropertyValue
Categorymedia
Modesview
Sourcebuiltin

Hero/primary image display with placeholder fallback when no image is set.

Config Options:

  • max_height (select, default: “500px”) — 200px, 300px, 500px, 700px or none
  • object_fit (select, default: “cover”) — cover, contain or fill
  • rounded (select, default: “lg”) — none, md, lg, xl or full

entity-chat

PropertyValue
Categoryinteraction
Modesview
Sourcebuiltin

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

PropertyValue
Categorydisplay
Modesview
Sourcebuiltin

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

PropertyValue
Categoryworkflow
Modesedit
Sourcebuiltin

ComfyUI workflow trigger buttons for entity-level AI generation.

Config Options: None


ai-generation-hub

PropertyValue
Categoryworkflow
Modesedit, view
Sourcebuiltin

Unified AI media generation panel for images, audio, and video.

Config Options:

  • allowedMediaTypes (string, comma-separated, default: "") — Restrict media types
  • defaultMediaType (string, default: “image”) — Initial media type

static-content

PropertyValue
Categorydisplay
Modesedit, view
Sourcebuiltin

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, info or warning
  • content (textarea, default: "") — The content
  • heading_level (select, default: “h3”) — h2, h3 or h4 (for header)

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

TypeRenders AsExample
stringText input (the fallback for any unrecognized type)type: 'string', label: 'Title', default: 'Assets'
numberNumber inputtype: 'number', label: 'Max Items', default: 10
booleanCheckboxtype: 'boolean', label: 'Show Upload', default: true
selectDropdown (requires options: [{ value, label }])type: 'select', label: 'Max Height', default: '500px', options: [...]
textareaMulti-line text areatype: '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/manifest currently returns only an aggregate (tenant_id, version, generated_at, entity_counts, status), not the per-entry ProjectManifest that useManifest is typed against. entries is therefore empty, and entityIndex, getEntityEntries and getEntityAssetSummary return nothing until a server implements that contract. POST /api/manifest/refresh and GET /api/manifest/diff return 501 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 same GET /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:

TypeDescription
ProjectManifestFull manifest (project_id, entries, provider_type, etc.)
ManifestEntrySingle entry (relative_path, entity_type, size_bytes, etc.)
EntityAssetSummaryComputed summary (image_count, video_count, total_size_bytes, etc.)