full-bleed-doc-types.ts2.7 KBView on GitHub
/**
 * The document types that are a SURFACE rather than a document, and so render without the
 * reading column.
 *
 * None of their content is the prosemirror fragment, each scrolls on its own axis, and each is
 * wider than 80ch by design. `html` qualifies on all three: it is a self-contained page in a
 * sandboxed iframe, so clamping it to a reading column crops a page that already chose its own
 * width. `card` is deliberately absent — it is a form, and a form reads better at a measure.
 *
 * ── Why this is its own module ──
 *
 * The decision has two halves that must agree, and they live on opposite sides of an import
 * cycle. `FileBrowser` RENDERS the document full bleed and keeps its breadcrumb in the column;
 * `AgentView`, three levels above it, owns the column that would otherwise trap it — a
 * `max-width` cannot be cancelled from inside. Two copies of this list would mean a type that
 * bleeds in one place while the other still clamps it, which renders as a table squeezed into
 * 80ch.
 *
 * It cannot live in either of them: `FileBrowser → AgentDocumentView → AgentView →
 * AgentOutputTab → FileBrowser` is a real cycle, held open only by a `lazy()` edge, and its
 * own note warns that the first top-level `const` read across the loop becomes a "cannot
 * access before initialization" that reproduces only in the production chunk order. So the
 * shared value sits below both, in a module that imports nothing.
 *
 * ── THIS SET IS NOT THE DOCUMENT-TYPE REGISTRY, and there isn't one ──
 *
 * It is the closest thing, which is exactly why it is worth saying here: adding a type to this
 * set makes it render WIDE, not makes it render AT ALL. A document type is dispatched at FIVE
 * separate sites, each its own if/ternary chain, and a type added to four of them renders as an
 * empty TipTap body in the fifth — silently, because an empty body is what a document with no
 * prosemirror content legitimately looks like:
 *
 *   1. this set
 *   2. `modules/files/components/FileBrowser.tsx` → `OpenFileView`
 *   3. `modules/home/components/FileArtifactPanel.tsx`
 *   4. `modules/conversations/components/files/FilesTab.tsx`, via `resolveOpenDoc.ts`
 *   5. `modules/company/components/CompanyExplorer.tsx`
 *
 * …plus `modules/files/components/list/FileTypeIcon.tsx` for the glyph and label.
 *
 * See `apps/server/docs/wiki/graph-documents.md` → "Where a document type has to be registered".
 */
export const FULL_BLEED_DOC_TYPES: ReadonlySet<string> = new Set(['table', 'board', 'graph', 'html']);

/** Whether a document of this type renders as a full-bleed surface. */
export function isFullBleedDocType(documentType: string | null | undefined): boolean {
  return FULL_BLEED_DOC_TYPES.has(documentType ?? '');
}