Skip to main content

AdvancedComposer

Location: src/components/AdvancedComposer.jsx

Overview​

AdvancedComposer is the one post composer (FE-1, ADR-033). It is the popup the header Write button (and the W key) opens over any page (composer/ComposerModal.jsx, mounted by composer/ComposerHost.jsx), and the page at the /compose route, which stays for links and for the clips and storage pages that hand it content in location.state. It has several editor types (simple, longform, drawing, magnetic poetry, quotation, poll, loop), draft management (local auto-save and database-backed drafts), and a confirmation gate before publishing. The inline quick composer (CreatePost) no longer exists.

In the popup the props modal, onClose and onPosted replace navigation: Close, Cancel, Escape and the backdrop ask before dropping words (keep writing, save as draft and close, or discard), and a finished post calls onPosted({ id, post, destination }) and closes; where the post belongs on another page (a circle, or the feed from a room) the person lands there. On the page, Cancel goes back and a finished post navigates to its destination, as before.

Relevant Invariants​

  • Invariant #4: "Intent Precedes Interpretation" -- The intent badge on the card is chosen before sharing.
  • Invariant #10: "Expressive Freedom Is Spatially Contained" -- Rich style customization is contained to the author own posts.
  • Invariant #19: "Complexity Must Be Earned" -- Each option is one icon that opens its control only when asked for.

Props​

PropTypeRequiredDefaultDescription
sessionobjectYes--Supabase auth session

Editor Types​

IDLabelDescription
simpleQuick PostPlain text post
longformArticleRich text with formatting
drawingDrawingCanvas-based drawing
magnetic_poetryWord ArtDrag-and-drop word tiles

Style System​

The style panel has three tabs:

Appearance (Surface)

  • light, dark, warm, cool

Typography (Font + Emphasis)

  • Font options loaded from FONT_OPTIONS constant
  • Emphasis: subtle, normal, strong

Effects (Texture)

  • flat (clean and minimal), paper (subtle texture), soft-card (gentle shadows), ghost (translucent blur)

Advanced Token-Based Styling​

In addition to the simple style system (surface/texture/font/emphasis), AdvancedComposer integrates the full PostCustomizer for token-based visual styling:

  • "Advanced Style" button in the style panel footer opens a full-screen PostCustomizer overlay
  • Uses the usePostStyle hook to manage token state separately from the simple style
  • Token data is stored as style_tokens inside the existing post_style JSONB column on posts
  • An indicator badge appears when advanced style is active, with a "Remove" button to clear it
  • Draft saves (auto and manual) include token data
  • The usePostStyleFor(post) hook extracts tokens from stored posts for rendering

Key Behaviors​

  • Dual Draft System: useAutoSave persists to IndexedDB (commonplace_drafts database) on every change; useDrafts saves to the composer_drafts Supabase table for cross-device access.
  • Style Presets: Users can save and load style configurations from the style_presets table.
  • PostConfirmationGate: Before publishing, a modal asks the user to confirm their intent and review the post.
  • Navigation State: Receives content, intent, images, audience, selectedCircleIds, sharingAllowed, contentNote, clipData, and clipId in useLocation().state when it is the /compose page (the popup starts blank). Note: voiceData is not passed in; it is initialized as null and set via the VoiceRecorder component.
  • Live Preview: Real-time preview panel shows how the post will look with current style settings.
  • Content Note: Optional content note input for sensitive content.
  • External Clips: Can attach external content cards (URLs) to posts.

Constants​

ConstantValueDescription
MAX_FILE_SIZE5242880 (5 MB)Maximum image file size
MAX_IMAGES10Maximum images per post
ALLOWED_TYPES[image/jpeg, image/png, image/gif, image/webp]Accepted image MIME types

Usage​

// Typically navigated to, not rendered directly
import { useNavigate } from 'react-router-dom';

const navigate = useNavigate();
navigate('/compose', {
state: {
intent: 'tell',
content: 'Draft text...',
images: [],
audience: 'public',
selectedCircleIds: [],
sharingAllowed: true,
contentNote: '',
clipData: null,
clipId: null
}
});
  • Post -- Displays the styled post output
  • VoiceRecorder -- Voice recording integration
  • usePostStyle -- Token-based style management hook
  • PostCustomizer (src/components/customizer/src/components/PostCustomizer.jsx) -- Full-screen token style editor

Last updated: 2026-02-08