# Intent Understanding: Content Visualization & Exposure

**Date**: 2026-06-01  
**Issue**: jgwill/Miadi#388

---

## Why This Packet Exists Now

The view system refactoring (June 2026) is a structural choice to enable **knowledge exposure across contexts**. Before this work, files were:
- Embedded in application layout (navbar + chrome present during reading)
- Served only to humans (no programmatic access)
- Monolithic (one presentation mode)

The refactoring makes files:
- Presentation-agnostic (same file, multiple renderings)
- Consumable by systems (raw API mode)
- Distraction-free for reading (chrome hidden on `/v` routes)

---

## Desired Outcome

**Vision**: Files become discoverable, viewable, and embeddable across contexts.

**For humans**: 
- Click `/v?p=/path/to/file` → see rendered HTML or formatted Markdown
- Distraction-free reading experience (navbar hidden)
- Share file URLs with others

**For systems**:
- Fetch `/v?p=/path&raw=1` → raw content for processing
- Embed HTML in external dashboards: `<iframe src="...?raw=1">`
- Build custom readers/integrations

**For the platform**:
- Clear separation: application chrome vs. content display
- Reusable component (SiteChrome) for any audience-aware layout
- Foundation for future archival/distribution features

---

## Current Reality

**Before refactoring**:
- Layout.tsx tightly couples navbar, auto-refresh, and viewer
- ViewFile logic (loadViewFile, file branching, error handling) mixed into page.tsx
- No raw content API
- Navbar visible during reading (extraneous cognitive load)

**Tension**: Application chrome and content visualization should be independent concerns, but were woven together.

---

## Structural Tension Resolved

| Axis | Before | After |
|------|--------|-------|
| **Separation of Concerns** | Chrome + content in one layout | Chrome extracted to SiteChrome; content isolated in ViewFilePage |
| **Reusability** | Navbar logic baked into root layout | SiteChrome can be used by any layout-needing component |
| **API Access** | Files only renderable in UI | `?raw=1` mode enables programmatic access |
| **Reader Experience** | Navbar visible while reading | Navbar hidden on `/v` routes (cognitive load reduced) |
| **Format Support** | HTML and Markdown rendered the same way | Three modes: HTML (iframe), Markdown (formatted), raw (API) |

---

## Decisions This Packet Supports

### 1. "Why hide the navbar on `/v` routes?"
**Answer**: Cognitive load research (Sweller, CLT) shows extraneous load during reading impairs comprehension. Hiding navbar during reading respects the reader's attention — a form of relational accountability.

**References**: 
- Sweller, J. "Cognitive Load During Problem Solving" (1988)
- Cowan, N. "The Magical Mystery Number" (2001)

### 2. "Why three modes (rendered HTML, rendered Markdown, raw API)?"
**Answer**: Content format negotiation principle — the same file served to different audiences in different contexts (human reader, interactive explore, API consumer) requires multiple presentation layers. This is not new; HTTP content negotiation has modeled this for 30+ years.

**References**:
- Berners-Lee, T. "Information Management Proposal" (1989) — original vision of web
- Fielding, R. *Architectural Styles and the Design of Network-based Software Architectures* (2000) — REST principles

### 3. "Why sandbox the iframe?"
**Answer**: Security + interaction. Sandbox allows scripts, forms, popups (interactive content) while preventing navigation and plugin execution. Balances usability (HTML can be fully functional) with safety.

**References**:
- OWASP guidelines on iframe sandboxing
- Few, S. *Information Dashboard Design* (2006) — safe embedding patterns

### 4. "Why extract ViewFilePage as a separate component?"
**Answer**: Progressive disclosure pattern (Nielsen) + component reusability. The file viewer is a self-contained concern; extracting it makes the root layout readable and enables future reuse.

**References**:
- Nielsen, J. "Progressive Disclosure" (2006)
- McConnell, S. *Code Complete* (2004) — component cohesion

---

## Success Criteria

- [x] Files can be viewed in multiple formats without modifying the file
- [x] Raw API mode enables programmatic access
- [x] Navbar is hidden during reading (cognitive load reduced)
- [x] Root layout is simplified and readable
- [x] Component boundaries are clear (SiteChrome vs. ViewFilePage)
- [ ] External systems successfully embed or consume raw content (future validation)

---

## Downstream Implications

**For future work**:
1. **Archival**: Raw API enables exporting content to external systems (archive.org, knowledge bases, etc.)
2. **Integration**: Other applications can embed Miadi files: `<iframe src="miadi/v?raw=1">`
3. **Distribution**: Multi-format support prepares the platform for publication pipelines
4. **Narrative weaving**: Files can be composed into larger narratives (knowledge networks, story arcs)

**For stewardship**:
- This packet documents the *why*, not just the *what*
- Future refactorers will understand the cognitive science grounding the design choices
- New features (e.g., file permissions, format conversion) can be grounded in the same academic traditions

---

## Lines Worth Carrying into Voice & Chronicle

> "The toolbar disappears so the reader can think. This is not design; this is respect for attention."

> "A file served raw is a file freed. Without the constraint of a single presentation, content can find its own shape in other systems."

> "Three modes. One file. Different eyes. This is what it means to hold knowledge in trust."
