eventsCalendarAGENTS.md6 matches
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
191- **React Configuration:** When using React libraries, pin versions with `?deps=react@18.2.0,react-dom@18.2.0` and start the file with `/** @jsxImportSource https://esm.sh/react@18.2.0 */`
192- Ensure all React dependencies and sub-dependencies are pinned to the same version
193- **Styling:** Default to using TailwindCSS via `<script src="https://cdn.twind.style" crossorigin></script>` unless otherwise specified
194275- Always run table creation before querying
2762773. **React Configuration:**
278- All React dependencies must be pinned to 18.2.0
279- Always include `@jsxImportSource https://esm.sh/react@18.2.0` at the top of React files
280- Rendering issues often come from mismatched React versions
2812824. **File Handling:**
6970### HTML Content Handling
71When serving the React frontend, initial data is injected into the HTML to avoid loading states. To prevent HTML content from Notion pages (like `<script>` tags or other HTML elements) from breaking the JavaScript bootstrapping process, all `<` characters in the JSON data are escaped using Unicode escape sequences (`\u003c`). This ensures that any HTML tags in Notion content are safely rendered as text rather than executed as HTML.
7273## Usage
12const id = c.req.param("id");
13
14// Always serve React frontend for glimpse routes
15try {
16let html = await readFile("/frontend/glimpse.html", import.meta.url);
23
24// Inject initial data into HTML - escape < characters to prevent HTML injection
25// from Notion content breaking the JavaScript when bootstrapping React
26const dataScript = `<script>
27window.__GLIMPSE_DATA__ = ${JSON.stringify(result).replace(/</g, "\\u003c")};
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useEffect } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
34// TypeScript declaration for Prism global
21</h1>
22<div id="header-right" class="flex items-center gap-3">
23<!-- Dynamic content will be populated here by React -->
24</div>
25</div>
1# Frontend Architecture
23This directory contains the frontend application with a clean, scalable architecture following React best practices and separation of concerns.
45## Directory Structure
7```
8frontend/
9โโโ components/ # React components (UI rendering only)
10โ โโโ GlimpseView.tsx # Main glimpse viewing component
11โ โโโ NotionBlock.tsx # Notion block rendering with semantic HTML
12โ โโโ NotionProperty.tsx # Notion property rendering with type-specific formatting
13โโโ hooks/ # Custom React hooks (stateful logic)
14โ โโโ useAuth.ts # Authentication and authorization
15โ โโโ useGlimpseData.ts # Glimpse data fetching and state
33โ โโโ notion-content.css # Notion-specific styling
34โโโ pages/ # Page entry points
35โ โโโ glimpse.tsx # Glimpse page React entry point
36โโโ *.html # HTML templates with semantic structure
37```
48### **Data Flow**
49```
50HTML Template โ React Entry Point โ Components โ Hooks โ Services โ Utils
51โ โ โ โ โ
52DOM Mount UI Rendering State API Calls Pure Logic
703. **HTML template** served with semantic structure (header/main/footer)
714. **Initial data injection** - glimpse data embedded in `window.__GLIMPSE_DATA__`
725. **React entry point** (`glimpse.tsx`) mounts to `#root`
7374#### **React Initialization**
751. **`glimpse.tsx`** extracts initial data from window
762. **`GlimpseView`** component renders with initial data
83- **Orchestrates** all data and UI logic
84- **Uses custom hooks** for all stateful operations
85- **Renders header content** via React portals to HTML header
86- **Conditionally shows** agent connection UI and page content
87- **Handles loading/error states** with user-friendly UI
175### **Technical Features**
176- **Server-side data injection** - eliminates loading states
177- **React portals** - dynamic header content population
178- **Automatic polling** - real-time agent data updates
179- **Smart error handling** - graceful degradation
259### **Adding New Pages**
2601. **Create HTML template** with same header/footer structure
2612. **Create React entry point** following glimpse.tsx pattern
2623. **Reuse existing hooks** for common functionality
2634. **Add page-specific components** as needed
2731. **Utils** - Unit test pure functions
2742. **Services** - Mock API responses
2753. **Hooks** - Test with React Testing Library
2764. **Components** - Test rendering with mocked dependencies
277278This architecture provides a solid foundation for building scalable, maintainable React applications with clear separation of concerns and excellent developer experience.
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
3import { extractPlainText, formatNotionDate, formatMultiSelect, formatBoolean } from "../utils/notionFormatting.ts";
4
3*/
45import { useEffect, useRef } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
6import { updateViewingStatus } from "../services/viewingService.ts";
7
3*/
45import { useState, useEffect } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
6import { fetchGlimpseData } from "../services/glimpseService.ts";
7import type { UseGlimpseDataReturn } from "../types/hooks.ts";
3*/
45import { useMemo } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
6import { getUserEmailFromWindow, checkAuthorization } from "../utils/validation.ts";
7import type { UseAuthReturn } from "../types/hooks.ts";