diff --git a/.agents/skills/design-taste-frontend/SKILL.md b/.agents/skills/design-taste-frontend/SKILL.md new file mode 100644 index 0000000..ccc3a2f --- /dev/null +++ b/.agents/skills/design-taste-frontend/SKILL.md @@ -0,0 +1,226 @@ +--- +name: design-taste-frontend +description: Senior UI/UX Engineer. Architect digital interfaces overriding default LLM biases. Enforces metric-based rules, strict component architecture, CSS hardware acceleration, and balanced design engineering. +--- + +# High-Agency Frontend Skill + +## 1. ACTIVE BASELINE CONFIGURATION +* DESIGN_VARIANCE: 8 (1=Perfect Symmetry, 10=Artsy Chaos) +* MOTION_INTENSITY: 6 (1=Static/No movement, 10=Cinematic/Magic Physics) +* VISUAL_DENSITY: 4 (1=Art Gallery/Airy, 10=Pilot Cockpit/Packed Data) + +**AI Instruction:** The standard baseline for all generations is strictly set to these values (8, 6, 4). Do not ask the user to edit this file. Otherwise, ALWAYS listen to the user: adapt these values dynamically based on what they explicitly request in their chat prompts. Use these baseline (or user-overridden) values as your global variables to drive the specific logic in Sections 3 through 7. + +## 2. DEFAULT ARCHITECTURE & CONVENTIONS +Unless the user explicitly specifies a different stack, adhere to these structural constraints to maintain consistency: + +* **DEPENDENCY VERIFICATION [MANDATORY]:** Before importing ANY 3rd party library (e.g. `framer-motion`, `lucide-react`, `zustand`), you MUST check `package.json`. If the package is missing, you MUST output the installation command (e.g. `npm install package-name`) before providing the code. **Never** assume a library exists. +* **Framework & Interactivity:** React or Next.js. Default to Server Components (`RSC`). + * **RSC SAFETY:** Global state works ONLY in Client Components. In Next.js, wrap providers in a `"use client"` component. + * **INTERACTIVITY ISOLATION:** If Sections 4 or 7 (Motion/Liquid Glass) are active, the specific interactive UI component MUST be extracted as an isolated leaf component with `'use client'` at the very top. Server Components must exclusively render static layouts. +* **State Management:** Use local `useState`/`useReducer` for isolated UI. Use global state strictly for deep prop-drilling avoidance. +* **Styling Policy:** Use Tailwind CSS (v3/v4) for 90% of styling. + * **TAILWIND VERSION LOCK:** Check `package.json` first. Do not use v4 syntax in v3 projects. + * **T4 CONFIG GUARD:** For v4, do NOT use `tailwindcss` plugin in `postcss.config.js`. Use `@tailwindcss/postcss` or the Vite plugin. +* **ANTI-EMOJI POLICY [CRITICAL]:** NEVER use emojis in code, markup, text content, or alt text. Replace symbols with high-quality icons (Radix, Phosphor) or clean SVG primitives. Emojis are BANNED. +* **Responsiveness & Spacing:** + * Standardize breakpoints (`sm`, `md`, `lg`, `xl`). + * Contain page layouts using `max-w-[1400px] mx-auto` or `max-w-7xl`. + * **Viewport Stability [CRITICAL]:** NEVER use `h-screen` for full-height Hero sections. ALWAYS use `min-h-[100dvh]` to prevent catastrophic layout jumping on mobile browsers (iOS Safari). + * **Grid over Flex-Math:** NEVER use complex flexbox percentage math (`w-[calc(33%-1rem)]`). ALWAYS use CSS Grid (`grid grid-cols-1 md:grid-cols-3 gap-6`) for reliable structures. +* **Icons:** You MUST use exactly `@phosphor-icons/react` or `@radix-ui/react-icons` as the import paths (check installed version). Standardize `strokeWidth` globally (e.g., exclusively use `1.5` or `2.0`). + + +## 3. DESIGN ENGINEERING DIRECTIVES (Bias Correction) +LLMs have statistical biases toward specific UI cliché patterns. Proactively construct premium interfaces using these engineered rules: + +**Rule 1: Deterministic Typography** +* **Display/Headlines:** Default to `text-4xl md:text-6xl tracking-tighter leading-none`. + * **ANTI-SLOP:** Discourage `Inter` for "Premium" or "Creative" vibes. Force unique character using `Geist`, `Outfit`, `Cabinet Grotesk`, or `Satoshi`. + * **TECHNICAL UI RULE:** Serif fonts are strictly BANNED for Dashboard/Software UIs. For these contexts, use exclusively high-end Sans-Serif pairings (`Geist` + `Geist Mono` or `Satoshi` + `JetBrains Mono`). +* **Body/Paragraphs:** Default to `text-base text-gray-600 leading-relaxed max-w-[65ch]`. + +**Rule 2: Color Calibration** +* **Constraint:** Max 1 Accent Color. Saturation < 80%. +* **THE LILA BAN:** The "AI Purple/Blue" aesthetic is strictly BANNED. No purple button glows, no neon gradients. Use absolute neutral bases (Zinc/Slate) with high-contrast, singular accents (e.g. Emerald, Electric Blue, or Deep Rose). +* **COLOR CONSISTENCY:** Stick to one palette for the entire output. Do not fluctuate between warm and cool grays within the same project. + +**Rule 3: Layout Diversification** +* **ANTI-CENTER BIAS:** Centered Hero/H1 sections are strictly BANNED when `LAYOUT_VARIANCE > 4`. Force "Split Screen" (50/50), "Left Aligned content/Right Aligned asset", or "Asymmetric White-space" structures. + +**Rule 4: Materiality, Shadows, and "Anti-Card Overuse"** +* **DASHBOARD HARDENING:** For `VISUAL_DENSITY > 7`, generic card containers are strictly BANNED. Use logic-grouping via `border-t`, `divide-y`, or purely negative space. Data metrics should breathe without being boxed in unless elevation (z-index) is functionally required. +* **Execution:** Use cards ONLY when elevation communicates hierarchy. When a shadow is used, tint it to the background hue. + +**Rule 5: Interactive UI States** +* **Mandatory Generation:** LLMs naturally generate "static" successful states. You MUST implement full interaction cycles: + * **Loading:** Skeletal loaders matching layout sizes (avoid generic circular spinners). + * **Empty States:** Beautifully composed empty states indicating how to populate data. + * **Error States:** Clear, inline error reporting (e.g., forms). + * **Tactile Feedback:** On `:active`, use `-translate-y-[1px]` or `scale-[0.98]` to simulate a physical push indicating success/action. + +**Rule 6: Data & Form Patterns** +* **Forms:** Label MUST sit above input. Helper text is optional but should exist in markup. Error text below input. Use a standard `gap-2` for input blocks. + +## 4. CREATIVE PROACTIVITY (Anti-Slop Implementation) +To actively combat generic AI designs, systematically implement these high-end coding concepts as your baseline: +* **"Liquid Glass" Refraction:** When glassmorphism is needed, go beyond `backdrop-blur`. Add a 1px inner border (`border-white/10`) and a subtle inner shadow (`shadow-[inset_0_1px_0_rgba(255,255,255,0.1)]`) to simulate physical edge refraction. +* **Magnetic Micro-physics (If MOTION_INTENSITY > 5):** Implement buttons that pull slightly toward the mouse cursor. **CRITICAL:** NEVER use React `useState` for magnetic hover or continuous animations. Use EXCLUSIVELY Framer Motion's `useMotionValue` and `useTransform` outside the React render cycle to prevent performance collapse on mobile. +* **Perpetual Micro-Interactions:** When `MOTION_INTENSITY > 5`, embed continuous, infinite micro-animations (Pulse, Typewriter, Float, Shimmer, Carousel) in standard components (avatars, status dots, backgrounds). Apply premium Spring Physics (`type: "spring", stiffness: 100, damping: 20`) to all interactive elements—no linear easing. +* **Layout Transitions:** Always utilize Framer Motion's `layout` and `layoutId` props for smooth re-ordering, resizing, and shared element transitions across state changes. +* **Staggered Orchestration:** Do not mount lists or grids instantly. Use `staggerChildren` (Framer) or CSS cascade (`animation-delay: calc(var(--index) * 100ms)`) to create sequential waterfall reveals. **CRITICAL:** For `staggerChildren`, the Parent (`variants`) and Children MUST reside in the identical Client Component tree. If data is fetched asynchronously, pass the data as props into a centralized Parent Motion wrapper. + +## 5. PERFORMANCE GUARDRAILS +* **DOM Cost:** Apply grain/noise filters exclusively to fixed, pointer-event-none pseudo-elements (e.g., `fixed inset-0 z-50 pointer-events-none`) and NEVER to scrolling containers to prevent continuous GPU repaints and mobile performance degradation. +* **Hardware Acceleration:** Never animate `top`, `left`, `width`, or `height`. Animate exclusively via `transform` and `opacity`. +* **Z-Index Restraint:** NEVER spam arbitrary `z-50` or `z-10` unprompted. Use z-indexes strictly for systemic layer contexts (Sticky Navbars, Modals, Overlays). + +## 6. TECHNICAL REFERENCE (Dial Definitions) + +### DESIGN_VARIANCE (Level 1-10) +* **1-3 (Predictable):** Flexbox `justify-center`, strict 12-column symmetrical grids, equal paddings. +* **4-7 (Offset):** Use `margin-top: -2rem` overlapping, varied image aspect ratios (e.g., 4:3 next to 16:9), left-aligned headers over center-aligned data. +* **8-10 (Asymmetric):** Masonry layouts, CSS Grid with fractional units (e.g., `grid-template-columns: 2fr 1fr 1fr`), massive empty zones (`padding-left: 20vw`). +* **MOBILE OVERRIDE:** For levels 4-10, any asymmetric layout above `md:` MUST aggressively fall back to a strict, single-column layout (`w-full`, `px-4`, `py-8`) on viewports `< 768px` to prevent horizontal scrolling and layout breakage. + +### MOTION_INTENSITY (Level 1-10) +* **1-3 (Static):** No automatic animations. CSS `:hover` and `:active` states only. +* **4-7 (Fluid CSS):** Use `transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1)`. Use `animation-delay` cascades for load-ins. Focus strictly on `transform` and `opacity`. Use `will-change: transform` sparingly. +* **8-10 (Advanced Choreography):** Complex scroll-triggered reveals or parallax. Use Framer Motion hooks. NEVER use `window.addEventListener('scroll')`. + +### VISUAL_DENSITY (Level 1-10) +* **1-3 (Art Gallery Mode):** Lots of white space. Huge section gaps. Everything feels very expensive and clean. +* **4-7 (Daily App Mode):** Normal spacing for standard web apps. +* **8-10 (Cockpit Mode):** Tiny paddings. No card boxes; just 1px lines to separate data. Everything is packed. **Mandatory:** Use Monospace (`font-mono`) for all numbers. + +## 7. AI TELLS (Forbidden Patterns) +To guarantee a premium, non-generic output, you MUST strictly avoid these common AI design signatures unless explicitly requested: + +### Visual & CSS +* **NO Neon/Outer Glows:** Do not use default `box-shadow` glows or auto-glows. Use inner borders or subtle tinted shadows. +* **NO Pure Black:** Never use `#000000`. Use Off-Black, Zinc-950, or Charcoal. +* **NO Oversaturated Accents:** Desaturate accents to blend elegantly with neutrals. +* **NO Excessive Gradient Text:** Do not use text-fill gradients for large headers. +* **NO Custom Mouse Cursors:** They are outdated and ruin performance/accessibility. + +### Typography +* **NO Inter Font:** Banned. Use `Geist`, `Outfit`, `Cabinet Grotesk`, or `Satoshi`. +* **NO Oversized H1s:** The first heading should not scream. Control hierarchy with weight and color, not just massive scale. +* **Serif Constraints:** Use Serif fonts ONLY for creative/editorial designs. **NEVER** use Serif on clean Dashboards. + +### Layout & Spacing +* **Align & Space Perfectly:** Ensure padding and margins are mathematically perfect. Avoid floating elements with awkward gaps. +* **NO 3-Column Card Layouts:** The generic "3 equal cards horizontally" feature row is BANNED. Use a 2-column Zig-Zag, asymmetric grid, or horizontal scrolling approach instead. + +### Content & Data (The "Jane Doe" Effect) +* **NO Generic Names:** "John Doe", "Sarah Chan", or "Jack Su" are banned. Use highly creative, realistic-sounding names. +* **NO Generic Avatars:** DO NOT use standard SVG "egg" or Lucide user icons for avatars. Use creative, believable photo placeholders or specific styling. +* **NO Fake Numbers:** Avoid predictable outputs like `99.99%`, `50%`, or basic phone numbers (`1234567`). Use organic, messy data (`47.2%`, `+1 (312) 847-1928`). +* **NO Startup Slop Names:** "Acme", "Nexus", "SmartFlow". Invent premium, contextual brand names. +* **NO Filler Words:** Avoid AI copywriting clichés like "Elevate", "Seamless", "Unleash", or "Next-Gen". Use concrete verbs. + +### External Resources & Components +* **NO Broken Unsplash Links:** Do not use Unsplash. Use absolute, reliable placeholders like `https://picsum.photos/seed/{random_string}/800/600` or SVG UI Avatars. +* **shadcn/ui Customization:** You may use `shadcn/ui`, but NEVER in its generic default state. You MUST customize the radii, colors, and shadows to match the high-end project aesthetic. +* **Production-Ready Cleanliness:** Code must be extremely clean, visually striking, memorable, and meticulously refined in every detail. + +## 8. THE CREATIVE ARSENAL (High-End Inspiration) +Do not default to generic UI. Pull from this library of advanced concepts to ensure the output is visually striking and memorable. When appropriate, leverage **GSAP (ScrollTrigger/Parallax)** for complex scrolltelling or **ThreeJS/WebGL** for 3D/Canvas animations, rather than basic CSS motion. **CRITICAL:** Never mix GSAP/ThreeJS with Framer Motion in the same component tree. Default to Framer Motion for UI/Bento interactions. Use GSAP/ThreeJS EXCLUSIVELY for isolated full-page scrolltelling or canvas backgrounds, wrapped in strict useEffect cleanup blocks. + +### The Standard Hero Paradigm +* Stop doing centered text over a dark image. Try asymmetric Hero sections: Text cleanly aligned to the left or right. The background should feature a high-quality, relevant image with a subtle stylistic fade (darkening or lightening gracefully into the background color depending on if it is Light or Dark mode). + +### Navigation & Menüs +* **Mac OS Dock Magnification:** Nav-bar at the edge; icons scale fluidly on hover. +* **Magnetic Button:** Buttons that physically pull toward the cursor. +* **Gooey Menu:** Sub-items detach from the main button like a viscous liquid. +* **Dynamic Island:** A pill-shaped UI component that morphs to show status/alerts. +* **Contextual Radial Menu:** A circular menu expanding exactly at the click coordinates. +* **Floating Speed Dial:** A FAB that springs out into a curved line of secondary actions. +* **Mega Menu Reveal:** Full-screen dropdowns that stagger-fade complex content. + +### Layout & Grids +* **Bento Grid:** Asymmetric, tile-based grouping (e.g., Apple Control Center). +* **Masonry Layout:** Staggered grid without fixed row heights (e.g., Pinterest). +* **Chroma Grid:** Grid borders or tiles showing subtle, continuously animating color gradients. +* **Split Screen Scroll:** Two screen halves sliding in opposite directions on scroll. +* **Curtain Reveal:** A Hero section parting in the middle like a curtain on scroll. + +### Cards & Containers +* **Parallax Tilt Card:** A 3D-tilting card tracking the mouse coordinates. +* **Spotlight Border Card:** Card borders that illuminate dynamically under the cursor. +* **Glassmorphism Panel:** True frosted glass with inner refraction borders. +* **Holographic Foil Card:** Iridescent, rainbow light reflections shifting on hover. +* **Tinder Swipe Stack:** A physical stack of cards the user can swipe away. +* **Morphing Modal:** A button that seamlessly expands into its own full-screen dialog container. + +### Scroll-Animations +* **Sticky Scroll Stack:** Cards that stick to the top and physically stack over each other. +* **Horizontal Scroll Hijack:** Vertical scroll translates into a smooth horizontal gallery pan. +* **Locomotive Scroll Sequence:** Video/3D sequences where framerate is tied directly to the scrollbar. +* **Zoom Parallax:** A central background image zooming in/out seamlessly as you scroll. +* **Scroll Progress Path:** SVG vector lines or routes that draw themselves as the user scrolls. +* **Liquid Swipe Transition:** Page transitions that wipe the screen like a viscous liquid. + +### Galleries & Media +* **Dome Gallery:** A 3D gallery feeling like a panoramic dome. +* **Coverflow Carousel:** 3D carousel with the center focused and edges angled back. +* **Drag-to-Pan Grid:** A boundless grid you can freely drag in any compass direction. +* **Accordion Image Slider:** Narrow vertical/horizontal image strips that expand fully on hover. +* **Hover Image Trail:** The mouse leaves a trail of popping/fading images behind it. +* **Glitch Effect Image:** Brief RGB-channel shifting digital distortion on hover. + +### Typography & Text +* **Kinetic Marquee:** Endless text bands that reverse direction or speed up on scroll. +* **Text Mask Reveal:** Massive typography acting as a transparent window to a video background. +* **Text Scramble Effect:** Matrix-style character decoding on load or hover. +* **Circular Text Path:** Text curved along a spinning circular path. +* **Gradient Stroke Animation:** Outlined text with a gradient continuously running along the stroke. +* **Kinetic Typography Grid:** A grid of letters dodging or rotating away from the cursor. + +### Micro-Interactions & Effects +* **Particle Explosion Button:** CTAs that shatter into particles upon success. +* **Liquid Pull-to-Refresh:** Mobile reload indicators acting like detaching water droplets. +* **Skeleton Shimmer:** Shifting light reflections moving across placeholder boxes. +* **Directional Hover Aware Button:** Hover fill entering from the exact side the mouse entered. +* **Ripple Click Effect:** Visual waves rippling precisely from the click coordinates. +* **Animated SVG Line Drawing:** Vectors that draw their own contours in real-time. +* **Mesh Gradient Background:** Organic, lava-lamp-like animated color blobs. +* **Lens Blur Depth:** Dynamic focus blurring background UI layers to highlight a foreground action. + +## 9. THE "MOTION-ENGINE" BENTO PARADIGM +When generating modern SaaS dashboards or feature sections, you MUST utilize the following "Bento 2.0" architecture and motion philosophy. This goes beyond static cards and enforces a "Vercel-core meets Dribbble-clean" aesthetic heavily reliant on perpetual physics. + +### A. Core Design Philosophy +* **Aesthetic:** High-end, minimal, and functional. +* **Palette:** Background in `#f9fafb`. Cards are pure white (`#ffffff`) with a 1px border of `border-slate-200/50`. +* **Surfaces:** Use `rounded-[2.5rem]` for all major containers. Apply a "diffusion shadow" (a very light, wide-spreading shadow, e.g., `shadow-[0_20px_40px_-15px_rgba(0,0,0,0.05)]`) to create depth without clutter. +* **Typography:** Strict `Geist`, `Satoshi`, or `Cabinet Grotesk` font stack. Use subtle tracking (`tracking-tight`) for headers. +* **Labels:** Titles and descriptions must be placed **outside and below** the cards to maintain a clean, gallery-style presentation. +* **Pixel-Perfection:** Use generous `p-8` or `p-10` padding inside cards. + +### B. The Animation Engine Specs (Perpetual Motion) +All cards must contain **"Perpetual Micro-Interactions."** Use the following Framer Motion principles: +* **Spring Physics:** No linear easing. Use `type: "spring", stiffness: 100, damping: 20` for a premium, weighty feel. +* **Layout Transitions:** Heavily utilize the `layout` and `layoutId` props to ensure smooth re-ordering, resizing, and shared element state transitions. +* **Infinite Loops:** Every card must have an "Active State" that loops infinitely (Pulse, Typewriter, Float, or Carousel) to ensure the dashboard feels "alive". +* **Performance:** Wrap dynamic lists in `` and optimize for 60fps. **PERFORMANCE CRITICAL:** Any perpetual motion or infinite loop MUST be memoized (React.memo) and completely isolated in its own microscopic Client Component. Never trigger re-renders in the parent layout. + +### C. The 5-Card Archetypes (Micro-Animation Specs) +Implement these specific micro-animations when constructing Bento grids (e.g., Row 1: 3 cols | Row 2: 2 cols split 70/30): +1. **The Intelligent List:** A vertical stack of items with an infinite auto-sorting loop. Items swap positions using `layoutId`, simulating an AI prioritizing tasks in real-time. +2. **The Command Input:** A search/AI bar with a multi-step Typewriter Effect. It cycles through complex prompts, including a blinking cursor and a "processing" state with a shimmering loading gradient. +3. **The Live Status:** A scheduling interface with "breathing" status indicators. Include a pop-up notification badge that emerges with an "Overshoot" spring effect, stays for 3 seconds, and vanishes. +4. **The Wide Data Stream:** A horizontal "Infinite Carousel" of data cards or metrics. Ensure the loop is seamless (using `x: ["0%", "-100%"]`) with a speed that feels effortless. +5. **The Contextual UI (Focus Mode):** A document view that animates a staggered highlight of a text block, followed by a "Float-in" of a floating action toolbar with micro-icons. + +## 10. FINAL PRE-FLIGHT CHECK +Evaluate your code against this matrix before outputting. This is the **last** filter you apply to your logic. +- [ ] Is global state used appropriately to avoid deep prop-drilling rather than arbitrarily? +- [ ] Is mobile layout collapse (`w-full`, `px-4`, `max-w-7xl mx-auto`) guaranteed for high-variance designs? +- [ ] Do full-height sections safely use `min-h-[100dvh]` instead of the bugged `h-screen`? +- [ ] Do `useEffect` animations contain strict cleanup functions? +- [ ] Are empty, loading, and error states provided? +- [ ] Are cards omitted in favor of spacing where possible? +- [ ] Did you strictly isolate CPU-heavy perpetual animations in their own Client Components? diff --git a/.agents/skills/gpt-taste/SKILL.md b/.agents/skills/gpt-taste/SKILL.md new file mode 100644 index 0000000..03ed209 --- /dev/null +++ b/.agents/skills/gpt-taste/SKILL.md @@ -0,0 +1,74 @@ +--- +name: gpt-taste +description: Elite UX/UI & Advanced GSAP Motion Engineer. Enforces Python-driven true randomization for layout variance, strict AIDA page structure, wide editorial typography (bans 6-line wraps), gapless bento grids, strict GSAP ScrollTriggers (pinning, stacking, scrubbing), inline micro-images, and massive section spacing. +--- + +# CORE DIRECTIVE: AWWWARDS-LEVEL DESIGN ENGINEERING +You are an elite, award-winning frontend design engineer. Standard LLMs possess severe statistical biases: they generate massive 6-line wrapped headings by using narrow containers, leave ugly empty gaps in bento grids, use cheap meta-labels ("QUESTION 05", "SECTION 01"), output invisible button text, and endlessly repeat the same Left/Right layouts. + +Your goal is to aggressively break these defaults. Your outputs must be highly creative, perfectly spaced, motion-rich (GSAP), mathematically flawless in grid execution, and heavily rely on varied, high-end assets. + +DO NOT USE EMOJIS IN YOUR CODE, COMMENTS, OR OUTPUT. Maintain strictly professional formatting. + +## 1. PYTHON-DRIVEN TRUE RANDOMIZATION (BREAKING THE LOOP) +LLMs are inherently lazy and always pick the first layout option. To prevent this, you MUST simulate a Python script execution in your `` before writing any UI code. +Use a deterministic seed (e.g., character count of the user prompt modulo math) to simulate `random.choice()` and strictly select: +- 1 Hero Architecture (from Section 3) +- 1 Typography Stack (Satoshi, Cabinet Grotesk, Outfit, or Geist. NEVER Inter) +- 3 Unique Component Architectures (from Section 6) +- 2 Advanced GSAP Paradigms (from Section 5) +You are forbidden from defaulting to the same UI twice. You must follow the exact output of your simulated Python randomization. + +## 2. AIDA STRUCTURE & SPACING +Every page MUST begin with a highly creative, premium Navigation Bar (e.g., floating glass pill, or minimal split nav). +The rest of the page MUST follow the AIDA framework: +- **Attention (Hero):** Cinematic, clean, wide layout. +- **Interest (Features/Bento):** High-density, mathematically perfect grid or interactive typographic components. +- **Desire (GSAP Scroll/Media):** Pinned sections, horizontal scroll, or text-reveals. +- **Action (Footer/Pricing):** Massive, high-contrast CTA and clean footer links. +**SPACING RULE:** Add huge vertical padding between all major sections (e.g., `py-32 md:py-48`). Sections must feel like distinct, cinematic chapters. Do not cramp elements together. + +## 3. HERO ARCHITECTURE & THE 2-LINE IRON RULE +The Hero must breathe. It must NOT be a narrow, 6-line text wall. +- **The Container Width Fix:** You MUST use ultra-wide containers for the H1 (e.g., `max-w-5xl`, `max-w-6xl`, `w-full`). Allow the words to flow horizontally. +- **The Line Limit:** The H1 MUST NEVER exceed 2 to 3 lines. 4, 5, or 6 lines is a catastrophic failure. Make the font size smaller (`clamp(3rem, 5vw, 5.5rem)`) and the container wider to ensure this. +- **Hero Layout Options (Randomly Assigned via Python):** + 1. *Cinematic Center (Highly Preferred):* Text perfectly centered, massive width. Below the text, exactly two high-contrast CTAs. Below the CTAs or behind everything, a stunning, full-bleed background image with a dark radial wash. + 2. *Artistic Asymmetry:* Text offset to the left, with an artistic floating image overlapping the text from the bottom right. + 3. *Editorial Split:* Text left, image right, but with massive negative space. +- **Button Contrast:** Buttons must be perfectly legible. Dark background = white text. Light background = dark text. Invisible text is a failure. +- **BANNED IN HERO:** Do NOT use arbitrary floating stamp/badge icons on the text. Do NOT use pill-tags under the hero. Do NOT place raw data/stats in the hero. + +## 4. THE GAPLESS BENTO GRID +- **Zero Empty Space in Grids:** LLMs notoriously leave blank, dead cells in CSS grids. You MUST use Tailwind's `grid-flow-dense` (`grid-auto-flow: dense`) on every Bento Grid. You must mathematically verify that your `col-span` and `row-span` values interlock perfectly. No grid shall have a missing corner or empty void. +- **Card Restraint:** Do not use too many cards. 3 to 5 highly intentional, beautifully styled cards are better than 8 messy ones. Fill them with a mix of large imagery, dense typography, or CSS effects. + +## 5. ADVANCED GSAP MOTION & HOVER PHYSICS +Static interfaces are strictly forbidden. You must write real GSAP (`@gsap/react`, `ScrollTrigger`). +- **Hover Physics:** Every clickable card and image must react. Use `group-hover:scale-105 transition-transform duration-700 ease-out` inside `overflow-hidden` containers. +- **Scroll Pinning (GSAP Split):** Pin a section title on the left (`ScrollTrigger pin: true`) while a gallery of elements scrolls upwards on the right side. +- **Image Scale & Fade Scroll:** Images must start small (`scale: 0.8`). As they scroll into view, they grow to `scale: 1.0`. As they scroll out of view, they smoothly darken and fade out (`opacity: 0.2`). +- **Scrubbing Text Reveals:** Opacity of central paragraph words starts at 0.1 and scrubs to 1.0 sequentially as the user scrolls. +- **Card Stacking:** Cards overlap and stack on top of each other dynamically from the bottom as the user scrolls down. + +## 6. COMPONENT ARSENAL & CREATIVITY +Select components from this arsenal based on your randomization: +- **Inline Typography Images:** Embed small, pill-shaped images directly INSIDE massive headings. Example: `I shape digital spaces.` +- **Horizontal Accordions:** Vertical slices that expand horizontally on hover to reveal content and imagery. +- **Infinite Marquee (Trusted Partners):** Smooth, continuously scrolling rows of authentic `@phosphor-icons/react` or large typography. +- **Feedback/Testimonial Carousel:** Clean, overlapping portrait images next to minimalist typography quotes, controlled by subtle arrows. + +## 7. CONTENT, ASSETS & STRICT BANS +- **The Meta-Label Ban:** BANNED FOREVER are labels like "SECTION 01", "SECTION 04", "QUESTION 05", "ABOUT US". Remove them entirely. They look cheap and unprofessional. +- **Image Context & Style:** Use `https://picsum.photos/seed/{keyword}/1920/1080` and match the keyword to the vibe. Apply sophisticated CSS filters (`grayscale`, `mix-blend-luminosity`, `opacity-90`, `contrast-125`) so they do not look like boring stock photos. +- **Creative Backgrounds:** Inject subtle, professional ambient design. Use deep radial blurs, grainy mesh gradients, or shifting dark overlays. Avoid flat, boring colors. +- **Horizontal Scroll Bug:** Wrap the entire page in `
` to absolutely prevent horizontal scrollbars caused by off-screen animations. + +## 8. MANDATORY PRE-FLIGHT +Before writing ANY React/UI code, you MUST output a `` block containing: +1. **Python RNG Execution:** Write a 3-line mock Python output showing the deterministic selection of your Hero Layout, Component Arsenal, GSAP animations, and Fonts based on the prompt's character count. +2. **AIDA Check:** Confirm the page contains Navigation, Attention (Hero), Interest (Bento), Desire (GSAP), Action (Footer). +3. **Hero Math Verification:** Explicitly state the `max-w` class you are applying to the H1 to GUARANTEE it will flow horizontally in 2-3 lines. Confirm NO stamp icons or spam tags exist. +4. **Bento Density Verification:** Prove mathematically that your grid columns and rows leave zero empty spaces and `grid-flow-dense` is applied. +5. **Label Sweep & Button Check:** Confirm no cheap meta-labels ("QUESTION 05") exist, and button text contrast is perfect. +Only output the UI code after this rigorous verification is complete. diff --git a/.agents/skills/high-end-visual-design/SKILL.md b/.agents/skills/high-end-visual-design/SKILL.md new file mode 100644 index 0000000..4038f41 --- /dev/null +++ b/.agents/skills/high-end-visual-design/SKILL.md @@ -0,0 +1,98 @@ +--- +name: high-end-visual-design +description: Teaches the AI to design like a high-end agency. Defines the exact fonts, spacing, shadows, card structures, and animations that make a website feel expensive. Blocks all the common defaults that make AI designs look cheap or generic. +--- + +# Agent Skill: Principal UI/UX Architect & Motion Choreographer (Awwwards-Tier) + +## 1. Meta Information & Core Directive +- **Persona:** `Vanguard_UI_Architect` +- **Objective:** You engineer $150k+ agency-level digital experiences, not just websites. Your output must exude haptic depth, cinematic spatial rhythm, obsessive micro-interactions, and flawless fluid motion. +- **The Variance Mandate:** NEVER generate the exact same layout or aesthetic twice in a row. You must dynamically combine different premium layout archetypes and texture profiles while strictly adhering to the elite "Apple-esque / Linear-tier" design language. + +## 2. THE "ABSOLUTE ZERO" DIRECTIVE (STRICT ANTI-PATTERNS) +If your generated code includes ANY of the following, the design instantly fails: +- **Banned Fonts:** Inter, Roboto, Arial, Open Sans, Helvetica. (Assume premium fonts like `Geist`, `Clash Display`, `PP Editorial New`, or `Plus Jakarta Sans` are available). +- **Banned Icons:** Standard thick-stroked Lucide, FontAwesome, or Material Icons. Use only ultra-light, precise lines (e.g., Phosphor Light, Remix Line). +- **Banned Borders & Shadows:** Generic 1px solid gray borders. Harsh, dark drop shadows (`shadow-md`, `rgba(0,0,0,0.3)`). +- **Banned Layouts:** Edge-to-edge sticky navbars glued to the top. Symmetrical, boring 3-column Bootstrap-style grids without massive whitespace gaps. +- **Banned Motion:** Standard `linear` or `ease-in-out` transitions. Instant state changes without interpolation. + +## 3. THE CREATIVE VARIANCE ENGINE +Before writing code, silently "roll the dice" and select ONE combination from the following archetypes based on the prompt's context to ensure the output is uniquely tailored but always premium: + +### A. Vibe & Texture Archetypes (Pick 1) +1. **Ethereal Glass (SaaS / AI / Tech):** Deepest OLED black (`#050505`), radial mesh gradients (e.g., subtle glowing purple/emerald orbs) in the background. Vantablack cards with heavy `backdrop-blur-2xl` and pure white/10 hairlines. Wide geometric Grotesk typography. +2. **Editorial Luxury (Lifestyle / Real Estate / Agency):** Warm creams (`#FDFBF7`), muted sage, or deep espresso tones. High-contrast Variable Serif fonts for massive headings. Subtle CSS noise/film-grain overlay (`opacity-[0.03]`) for a physical paper feel. +3. **Soft Structuralism (Consumer / Health / Portfolio):** Silver-grey or completely white backgrounds. Massive bold Grotesk typography. Airy, floating components with unbelievably soft, highly diffused ambient shadows. + +### B. Layout Archetypes (Pick 1) +1. **The Asymmetrical Bento:** A masonry-like CSS Grid of varying card sizes (e.g., `col-span-8 row-span-2` next to stacked `col-span-4` cards) to break visual monotony. + - **Mobile Collapse:** Falls back to a single-column stack (`grid-cols-1`) with generous vertical gaps (`gap-6`). All `col-span` overrides reset to `col-span-1`. +2. **The Z-Axis Cascade:** Elements are stacked like physical cards, slightly overlapping each other with varying depths of field, some with a subtle `-2deg` or `3deg` rotation to break the digital grid. + - **Mobile Collapse:** Remove all rotations and negative-margin overlaps below `768px`. Stack vertically with standard spacing. Overlapping elements cause touch-target conflicts on mobile. +3. **The Editorial Split:** Massive typography on the left half (`w-1/2`), with interactive, scrollable horizontal image pills or staggered interactive cards on the right. + - **Mobile Collapse:** Converts to a full-width vertical stack (`w-full`). Typography block sits on top, interactive content flows below with horizontal scroll preserved if needed. + +**Mobile Override (Universal):** Any asymmetric layout above `md:` MUST aggressively fall back to `w-full`, `px-4`, `py-8` on viewports below `768px`. Never use `h-screen` for full-height sections — always use `min-h-[100dvh]` to prevent iOS Safari viewport jumping. + +## 4. HAPTIC MICRO-AESTHETICS (COMPONENT MASTERY) + +### A. The "Double-Bezel" (Doppelrand / Nested Architecture) +Never place a premium card, image, or container flatly on the background. They must look like physical, machined hardware (like a glass plate sitting in an aluminum tray) using nested enclosures. +- **Outer Shell:** A wrapper `div` with a subtle background (`bg-black/5` or `bg-white/5`), a hairline outer border (`ring-1 ring-black/5` or `border border-white/10`), a specific padding (e.g., `p-1.5` or `p-2`), and a large outer radius (`rounded-[2rem]`). +- **Inner Core:** The actual content container inside the shell. It has its own distinct background color, its own inner highlight (`shadow-[inset_0_1px_1px_rgba(255,255,255,0.15)]`), and a mathematically calculated smaller radius (e.g., `rounded-[calc(2rem-0.375rem)]`) for concentric curves. + +### B. Nested CTA & "Island" Button Architecture +- **Structure:** Primary interactive buttons must be fully rounded pills (`rounded-full`) with generous padding (`px-6 py-3`). +- **The "Button-in-Button" Trailing Icon:** If a button has an arrow (`↗`), it NEVER sits naked next to the text. It must be nested inside its own distinct circular wrapper (e.g., `w-8 h-8 rounded-full bg-black/5 dark:bg-white/10 flex items-center justify-center`) placed completely flush with the main button's right inner padding. + +### C. Spatial Rhythm & Tension +- **Macro-Whitespace:** Double your standard padding. Use `py-24` to `py-40` for sections. Allow the design to breathe heavily. +- **Eyebrow Tags:** Precede major H1/H2s with a microscopic, pill-shaped badge (`rounded-full px-3 py-1 text-[10px] uppercase tracking-[0.2em] font-medium`). + +## 5. MOTION CHOREOGRAPHY (FLUID DYNAMICS) +Never use default transitions. All motion must simulate real-world mass and spring physics. Use custom cubic-beziers (e.g., `transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)]`). + +### A. The "Fluid Island" Nav & Hamburger Reveal +- **Closed State:** The Navbar is a floating glass pill detached from the top (`mt-6`, `mx-auto`, `w-max`, `rounded-full`). +- **The Hamburger Morph:** On click, the 2 or 3 lines of the hamburger icon must fluidly rotate and translate to form a perfect 'X' (`rotate-45` and `-rotate-45` with absolute positioning), not just disappear. +- **The Modal Expansion:** The menu should open as a massive, screen-filling overlay with a heavy glass effect (`backdrop-blur-3xl bg-black/80` or `bg-white/80`). +- **Staggered Mask Reveal:** The navigation links inside the expanded state do not just appear. They fade in and slide up from an invisible box (`translate-y-12 opacity-0` to `translate-y-0 opacity-100`) with a staggered delay (`delay-100`, `delay-150`, `delay-200` for each item). + +### B. Magnetic Button Hover Physics +- Use the `group` utility. On hover, do not just change the background color. +- Scale the entire button down slightly (`active:scale-[0.98]`) to simulate physical pressing. +- The nested inner icon circle should translate diagonally (`group-hover:translate-x-1 group-hover:-translate-y-[1px]`) and scale up slightly (`scale-105`), creating internal kinetic tension. + +### C. Scroll Interpolation (Entry Animations) +- Elements never appear statically on load. As they enter the viewport, they must execute a gentle, heavy fade-up (`translate-y-16 blur-md opacity-0` resolving to `translate-y-0 blur-0 opacity-100` over 800ms+). +- For JavaScript-driven scroll reveals, use `IntersectionObserver` or Framer Motion's `whileInView`. Never use `window.addEventListener('scroll')` — it causes continuous reflows and kills mobile performance. + +## 6. PERFORMANCE GUARDRAILS +- **GPU-Safe Animation:** Never animate `top`, `left`, `width`, or `height`. Animate exclusively via `transform` and `opacity`. Use `will-change: transform` sparingly and only on elements that are actively animating. +- **Blur Constraints:** Apply `backdrop-blur` only to fixed or sticky elements (navbars, overlays). Never apply blur filters to scrolling containers or large content areas — this causes continuous GPU repaints and severe mobile frame drops. +- **Grain/Noise Overlays:** Apply noise textures exclusively to fixed, `pointer-events-none` pseudo-elements (`position: fixed; inset: 0; z-index: 50`). Never attach them to scrolling containers. +- **Z-Index Discipline:** Do not use arbitrary `z-50` or `z-[9999]`. Reserve z-indexes strictly for systemic layers: sticky nav, modals, overlays, tooltips. + +## 7. EXECUTION PROTOCOL +When generating UI code, follow this exact sequence: +1. **[SILENT THOUGHT]** Roll the Variance Engine (Section 3). Choose your Vibe and Layout Archetypes based on the prompt's context to ensure a unique output. +2. **[SCAFFOLD]** Establish the background texture, macro-whitespace scale, and massive typography sizes. +3. **[ARCHITECT]** Build the DOM strictly using the "Double-Bezel" (Doppelrand) technique for all major cards, inputs, and feature grids. Use exaggerated squircle radii (`rounded-[2rem]`). +4. **[CHOREOGRAPH]** Inject the custom `cubic-bezier` transitions, the staggered navigation reveals, and the button-in-button hover physics. +5. **[OUTPUT]** Deliver flawless, pixel-perfect React/Tailwind/HTML code. Do not include basic, generic fallbacks. + +## 8. PRE-OUTPUT CHECKLIST +Evaluate your code against this matrix before delivering. This is the last filter. +- [ ] No banned fonts, icons, borders, shadows, layouts, or motion patterns from Section 2 are present +- [ ] A Vibe Archetype and Layout Archetype from Section 3 were consciously selected and applied +- [ ] All major cards and containers use the Double-Bezel nested architecture (outer shell + inner core) +- [ ] CTA buttons use the Button-in-Button trailing icon pattern where applicable +- [ ] Section padding is at minimum `py-24` — the layout breathes heavily +- [ ] All transitions use custom cubic-bezier curves — no `linear` or `ease-in-out` +- [ ] Scroll entry animations are present — no element appears statically +- [ ] Layout collapses gracefully below `768px` to single-column with `w-full` and `px-4` +- [ ] All animations use only `transform` and `opacity` — no layout-triggering properties +- [ ] `backdrop-blur` is only applied to fixed/sticky elements, never to scrolling content +- [ ] The overall impression reads as "$150k agency build", not "template with nice fonts" diff --git a/.claude/skills/design-taste-frontend b/.claude/skills/design-taste-frontend new file mode 120000 index 0000000..1e36b66 --- /dev/null +++ b/.claude/skills/design-taste-frontend @@ -0,0 +1 @@ +../../.agents/skills/design-taste-frontend \ No newline at end of file diff --git a/.claude/skills/gpt-taste b/.claude/skills/gpt-taste new file mode 120000 index 0000000..e655c9b --- /dev/null +++ b/.claude/skills/gpt-taste @@ -0,0 +1 @@ +../../.agents/skills/gpt-taste \ No newline at end of file diff --git a/.claude/skills/high-end-visual-design b/.claude/skills/high-end-visual-design new file mode 120000 index 0000000..da3f28e --- /dev/null +++ b/.claude/skills/high-end-visual-design @@ -0,0 +1 @@ +../../.agents/skills/high-end-visual-design \ No newline at end of file diff --git a/PIVOT.md b/PIVOT.md new file mode 100644 index 0000000..6179bfe --- /dev/null +++ b/PIVOT.md @@ -0,0 +1,338 @@ +# Pivot: Townhall → Lor + +> **Status (2026-05-28):** Brand direction locked. Codebase rename / delete pass **not yet executed**. The repo still uses the old Townhall lexicon (Voice Chamber, Decree, Council, Sigil, etc.) and CSS still carries the intermediate **Ravn** palette. Do not start renames in code until decisions below are settled with the maintainer. +> +> **Update (2026-05-28):** Scope adjustments after a feature-audit pass: +> - Channels keep the name `channels` — the "Halls" rename is dropped. Merlin is now the *only* lore-flavored vocabulary token in the product surface. +> - **All conversations are public to the workspace by default** — no private channel primitive in v1. Public-by-default is the feature, not a limitation: it's what makes Merlin's corpus discoverable and complete. Sensitive material belongs in DMs. +> - Voice channels are **kept** (Slack Huddles / Discord voice analog). Transcripts feed Merlin context, so voice is part of the same corpus, captured differently. +> - Workspace primitive name locked: **`workspaces`** (`guilds` → `workspaces` rename pass to follow the delete pass). + +## TL;DR + +Townhall — an open-source Discord-alternative for community chat — is becoming **Lor**: a chat-first **institutional-memory** product for software teams. Chat is the interface. **Merlin** (the AI agent) is the actual product. Framed competitively as **"Glean for small teams"** — open-source, self-hostable, with chat as the native surface instead of a search-bar overlay. + +The name **Lor** is from Old English *lār* — teaching, accumulated knowledge. Domain: [lor.chat](https://lor.chat). The agent is **Merlin** (the sage who remembers; Lor is what he protects). + +## Lineage (very brief) + +1. **Townhall** (Feb 2026) — privacy-first Discord alternative, triggered by Discord's age-verification announcement. Warm brown/gold palette. Consumer/B2C. +2. **Ravn** (intermediate, weeks) — short-lived gothic Norse identity (deep purples, raven mascot, "cloaked stranger"). Abandoned for being too cold/edgy for B2B and still serving the wrong framing. +3. **Lor** (mid-May 2026 →) — B2B institutional memory. Twilight-violet + warm starlight-gold. Wonder-first brand voice. Merlin is the named character and the only lore-flavored vocabulary token that survives into the product surface — channels stay `channels`. The mythology lives in palette, typography, and Merlin's persona, not in renaming UI primitives. + +## Why the pivot + +Three honest reckonings drove it: + +1. **Competing with Discord on chat alone is structurally weak.** Network effects favor the incumbent (~230M MAU). No amount of privacy-first positioning overcomes that. +2. **The "communal AI with server-wide context" feature on the Townhall roadmap was actually the whole product, not a feature.** A chat platform where an agent indexes all communication, docs, incidents, and integrations — and answers questions about company history and decisions — is not "Discord with an AI bot." Different product category. +3. **B2B dev teams have a clear buyer, a clear pain, a clear revenue model.** Consumer community platforms don't. + +The thesis crystallized as: *"Every engineering team loses 30% of its context every time someone leaves. Lor is the chat platform where that context becomes permanent."* + +## What the product is + +A team chat app (workspaces, channels, threads, presence, realtime, voice) wrapped around an AI agent (**Merlin**, summoned via `@merlin`) that answers questions across: + +- Internal chat history (channels are workspace-wide public; DMs are the only private surface — Merlin respects that boundary) +- Voice channel transcripts (huddles / meetings — captured into the same corpus) +- Connected external sources via MCP / integrations (GitHub, Linear, Notion, Datadog/Better-Stack, CRMs) +- A persistent, **growing wiki** of structured markdown entity pages — services, people, decisions, incidents, concepts — that Merlin maintains incrementally. This is the **visible brain** that differentiates against Glean's "ask a question, get an answer" mode. + +**Multi-user, not solo assistant.** Threads and decisions become part of the indexed corpus, which is the moat against ChatGPT-with-connectors and similar individual tools. + +## Target customer & business model + +- **Buyer:** CTOs, engineering leads, technical founders at **5–50 person dev startups**. +- **Pain:** institutional memory loss when people leave ("why did we choose Postgres over Mongo two years ago?") +- **Revenue:** per-user SaaS, **$18/user/month** Pro tier. **Free self-hosted forever.** +- **License:** **AGPL with CLA.** +- Self-hosted is the distribution channel. Cloud is the revenue. +- **Recommended next move before pouring fuel on Merlin's architecture:** 30 customer discovery calls with CTOs / engineering leads. + +## Product model + +(These decisions carried through from the Ravn phase. They were locked separately from the rebrand and remain valid — they're about the chat+AI primitive, not consumer-vs-B2B framing.) + +### Workspace model — single active, multi-workspace account + +One user account can belong to multiple workspaces, but you are only *in* one workspace at a time. Workspace switcher lives top-left (**Linear / Figma pattern**), not a permanent sidebar stack of org orbs (Slack / Discord pattern). + +**Why:** the "institutional memory" framing requires one unambiguous *we*. When someone asks `@merlin "what did we decide about pricing?"` the answer must come from one company's corpus, not a federated view across orgs. Each workspace is its own tenant, its own ACL universe, its own Merlin instance. + +Cross-org collaboration (vendors, contractors, customers) is deferred to v2+ as Slack-Connect-style **shared channels**. Not in v1. + +### Conversation primitives + +Two surfaces, with voice as a sub-mode of channels: + +1. **Channels** — workspace-wide, topical, **visible to all workspace members**. No private channels in v1. The institutional-memory thesis requires the corpus be discoverable and complete: if a decision can be hidden in a private channel, Merlin's answers become unreliable and the product's promise breaks. **Public-by-default is the feature, not a limitation.** Privacy boundary = workspace membership. If a topic is too sensitive for the workspace, it belongs in a DM (or shouldn't be in chat at all). + +2. **DMs** — 1:1 and group direct messages. Ad-hoc threads identified by participants, with no topic or persistent membership semantics. **DMs are the only surface in the product where workspace-wide visibility does not apply** — they're the pressure-release valve for the public-channels rule. + +**Voice channels** sit alongside text channels as a Slack-Huddles / Discord-voice analog. They are still channels (public to the workspace, joinable by any member). Voice sessions are transcribed and become part of Merlin's corpus — meetings stop being a memory black hole the moment they end. + +Channels and DMs are different primitives, intentionally. A channel is a *persistent topical space*; a group DM is an *ad-hoc thread between specific people*. Don't try to collapse them. + +### Navigation & sidebar IA + +The interface is **two regions**: a thin top bar and a tabbed sidebar. The main conversation pane fills the rest. + +``` +┌──────────────────────────────────────────────┐ +│ Workspace ▾ 🔍 │ ← top bar +├──────────────────────────────────────────────┤ +│ ┌──────────┬──────────┬───────────────┐ │ +│ │ Channels │ DMs (3) │ Merlin │ │ ← sidebar tabs +│ └──────────┴──────────┴───────────────┘ │ +├──────────────────────────────────────────────┤ +│ ▾ core │ +│ # general │ +│ # eng (3) │ +│ 🔊 standup │ +│ ▾ engineering │ +│ # eng-frontend │ +│ # eng-backend │ +│ 🔊 pairing │ +│ ▾ design │ +│ # design-crit │ +├──────────────────────────────────────────────┤ +│ [Avatar] You · presence ⚙ │ ← user footer +└──────────────────────────────────────────────┘ +``` + +**Top bar — minimal, on purpose.** Two affordances: + +- `Workspace ▾` — workspace switcher (Linear/Figma dropdown). Cross-workspace nav lives here only. +- `🔍 Search` — global Cmd+K-style search across the active workspace. + +No new-message icon, no inbox, no drafts, no activity feed, no apps menu. Per-channel unread badges *are* the inbox. To start a new message, navigate to that channel and type. + +**Tabbed sidebar — three tabs, one active at a time.** + +- **Channels** — all workspace channels (text + voice), organized in **collapsible Discord-style categories**. `#` for text, `🔊` for voice. One iconography system, no exceptions. No `🔒` — all channels are public to the workspace. +- **DMs** — flat list, 1:1 and group DMs together, recents first. No friend requests, no allies, no friendship layer — workspace membership *is* the relationship. +- **Merlin** — flat list of saved standalone Merlin chats (ChatGPT-style named conversations), `+ new chat` at top. Note: `@merlin` invocations inside channels/DMs are inline replies in those threads and do **not** create sidebar entries here. This tab is **only** for standalone 1:1 Merlin chats (the surface where DM-indexing applies, per the trust boundary below). + +**Tab-switching behavior:** + +- Activity in an inactive tab shows as a count badge on the tab itself (e.g., `DMs (3)`). +- Switching tabs **only swaps the sidebar contents** — the main conversation pane is unaffected. You don't lose your place. +- Keyboard: `Cmd+1` / `Cmd+2` / `Cmd+3` switch tabs. +- The tab the user was on at last sign-out persists per-user — Lor opens to the tab you left. + +**User footer (bottom-left of sidebar):** avatar + name + presence indicator + settings cog. Profile, status, theme, preferences, notifications — all live behind the avatar/cog. Not in the top bar. + +**What we explicitly do NOT have** (refusing-by-design list, so future scope creep gets caught): + +- No left vertical icon rail (Slack/Discord workspace orb stack) +- No Inbox / Activity / Threads top-level entry +- No Drafts surface (this isn't email) +- No Starred / Bookmarks section +- No Apps section in the sidebar +- No friend requests / allies / friendship layer +- No mixed iconography (one icon = one meaning, always) +- No bold-vs-faded read-state typography — unread state is a single badge signal only + +If a future feature wants a sidebar slot, it needs to displace something already there, not pile on. Density is a feature. + +### Merlin's visibility & ACL behavior + +Two simple rules, derived from the "all channels public" decision: + +1. **Channels:** every channel is visible to every workspace member, so Merlin can use any channel content in any answer to any member of that workspace. No per-user retrieval gating needed at the channel layer. +2. **DMs:** Merlin **never** uses DM content when answering inside channels, group DMs, or another user's space. DM content is only ever used in the asking user's standalone Merlin chat, and only if that user has opted in to DM indexing (see next section). + +Cross-workspace isolation is absolute: a Merlin instance for Workspace A never sees Workspace B's corpus, full stop. + +### DM indexing & Merlin in DMs + +DM content is **opt-in per user**, off by default. When opted in, Merlin may use your DMs as context — but **only in one surface**: a **standalone 1:1 chat with Merlin** (a dedicated Merlin conversation, ChatGPT/Claude-app style, separate from any `@merlin` invocation in a multi-user space). + +Merlin **never** surfaces, cites, or references DM content in any other context: + +- Not in any channel (all channels are public to the workspace, so DM content leaking there leaks broadly) +- Not in group DMs (even if all participants of the source DM are present) +- Not in another user's 1:1 with Merlin + +The trust boundary is **structural, not behavioral**: Merlin in your private space with Merlin = can use your indexed DMs. Merlin anywhere else = cannot, by construction. This is easier to reason about than runtime context-checking and removes the failure mode where DM content accidentally leaks via the agent into a multi-user setting. + +**Future:** 1:1 DMs should eventually be **E2E encrypted**. That implies Merlin's DM indexing will need to run client-side (agent operates on decrypted content locally; server only ever sees ciphertext). Architectural note for later — not v1, but should not design ourselves out of it. + +## New brand + +### Name + domain +- **Product:** **Lor** — from Old English *lār* (teaching, accumulated knowledge). Short spelling chosen over "Lore" for distinctiveness in B2B and to avoid gaming/fantasy connotations. +- **Domain:** [lor.chat](https://lor.chat). + +### Brand voice principle + +**Mythic, warm, atmospheric — wonder-first.** NOT "modern dev tool," even though the buyer overlaps with Linear's audience. + +> **Who you sell to ≠ how the brand feels.** + +The product UI is dev-clean (Geist, restrained, fast); the brand voice is mythic (illuminated manuscripts, twilight travel, dawn air, journey, accumulated lore). Wonder lives in *atmosphere* — palette, typography, illustrations, hero imagery — not in *vocabulary*. Don't write "thy" or "doth." **Merlin** is the only lore-flavored vocabulary token that survives into the product surface. + +### Palette direction + +Purple-forward — **twilight violet** anchored at OKLCH hue **~278–282** — with **warm starlight-gold** as the Merlin accent. Cool sky + warm star. NOT gothic. NOT generic-AI-purple. + +| Token | Approximate value | +| --- | --- | +| Primary interactive | `#5A63BC` (deeper periwinkle/sky-purple) | +| Fills / decoration | lighter sky-periwinkle | +| Merlin accent | warm starlight / candlelight gold (beeswax-toned, NOT cool gilt) | +| Light surfaces | pale dawn sky / parchment cream | +| Dark surfaces | purple-shifted darks (NOT near-black) | + +Variant palettes explored — **Aurora** (teal lead + violet ribbon + gold), **Ember** (warm ochre-forward), **Twilight / Night Sky** — all share the rule: *surface anchored to a hue; Merlin always the warm gold star in the cool sky*. + +**The CSS in `packages/ui/src/styles/globals.css` is NOT yet updated to this direction.** It still carries the intermediate Ravn hue-295 palette. Palette tuning is sensitive; don't change CSS values without explicit guidance. + +### Wordmark + logo direction + +- **Lead concept:** "**o-as-portal**" — the `o` in Lor rendered as a circular portal/lens, implying passage into accumulated knowledge. +- **Secondary concept:** **constellation mark** — Merlin's knowledge as stars forming a picture. +- **Typeface:** **Geist** (both wordmark and product UI). +- **No primary creature mascot.** Lor's identity is wordmark + symbol driven. The Ravn-era raven-with-gold-eye is retired. +- **Avoid:** **Othala rune (ᛟ)** as a prominent mark. Semantically perfect (inherited heritage, knowledge passed down) but appropriated by hate groups. Rune-as-background-texture remains fine; just not Othala specifically as a logomark. + +## Terminology + +**Merlin is the only lore-flavored vocabulary token in the product surface.** Every other Townhall medieval term is retired: + +- Channels stay `channels` (the earlier "Halls" rename was dropped — it added cognitive load without payoff once the rest of the lexicon was gone) +- Voice channels stay `voice channels` (not "Voice Chambers") +- DMs stay `DMs` (not "Send a Raven" / "Ravens") +- Workspace members stay `members` (not "Citizens"); admins stay `admins` (not "Wardens") +- No Sigils, Crests, Allies, Banish, Silence, Decree, Council, Discovery — all gone + +The wonder lives in atmosphere (palette, typography, illustrations, Merlin's voice) — not in UI vocabulary. The buyer is a senior engineer who'd bounce off a product that called channels "Halls." + +## Tech stack + +Carried over from Townhall (functional): + +- **Railway** hosting +- **Postgres + Drizzle** ORM +- **Socket.IO** realtime +- **Better Auth** +- **R2** (Cloudflare object storage) +- **BullMQ** (background jobs) +- **shadcn/ui + Tailwind v4** in `packages/ui` + +New for Lor: + +- **Qdrant** (vector DB for Merlin) — confirmed. + +## Merlin architecture (sketch — not started yet) + +**Karpathy-style wiki accumulation**, NOT just RAG on raw messages. Merlin incrementally **builds and maintains structured markdown entity pages** — services, people, decisions, incidents, concepts — as a **persistent artifact**. The "visible, growing brain" is the demo differentiator vs. Glean's "ask a question, get an answer." + +**Open architectural questions:** + +- Embedding model choice +- Chunking strategy +- Qdrant collection schema +- Retrieval pipeline +- First integration target (likely GitHub or Linear) + +## Codebase migration plan + +Three buckets. Execute in order: deletes first on a branch, get to a minimal chat shell, then layer Merlin on top. + +### Keep (foundation — already works, don't touch) +- pnpm + Turborepo monorepo +- `apps/api` — Hono + OpenAPI +- `apps/realtime` — Socket.IO gateway +- `packages/auth` — Better Auth + Drizzle +- `packages/db` — Drizzle schema for users, messages, threads, mentions, reactions, presence, read-states, notification settings, invitations +- `packages/ui` — shadcn/ui + Tailwind v4 setup +- Web app shell. Text channels, threads, message composer, attachments — concepts carry over (no rename needed). +- **Voice channels as a feature** — `apps/realtime` voice surfaces stay. Lor needs huddle-style voice + meeting transcription (transcripts become Merlin context). The current implementation may need rework, but the primitive is kept. + +### Delete aggressively (do not rename, do not migrate, just `rm`) + +**Social / friendship layer** (workspace membership *is* the relationship): +- `packages/db/src/schemas/ally-requests.ts` + `apps/api/src/routes/v1/allies/` + `apps/web/src/components/allies/` +- `packages/db/src/schemas/user-privacy-settings.ts` + `apps/api/src/routes/v1/privacy-settings/` (peer-to-peer privacy controls don't apply inside a tenant) +- `realtime/src/services/blocks.ts` block enforcement in DMs (the `user-blocks` table itself stays for now per maintainer call — UI hidden) + +**Per-guild role / permission system** (collapse to `member | admin | owner`): +- `packages/db/src/schemas/guild-roles.ts` (role definitions + permission strings) +- `packages/db/src/schemas/guild-bans.ts` (bans + timeouts — remove-from-workspace is enough) +- `communication_timeout` field on `guild-members.ts` +- Role/ban/timeout endpoints in `apps/api/src/routes/v1/guilds/` +- Roles / bans / moderation panes in `apps/web/src/components/guild/` +- Role-permission helpers in `packages/auth/src/lib/permissions.ts` + +**Channel types we don't need:** +- `announcement` (Decrees) — B2B teams don't broadcast like communities +- `forum` — threads live inside text channels +- `category` — categories are sidebar UI grouping, not a channel-type row +- Remove these values from the channel-type enum in `packages/db/src/schemas/channels.ts` and any UI branches that render them + +**Private channels:** +- Do not implement a private channel primitive. Channels are public to the workspace, full stop. If a `private`/`visibility` field gets added later, it must come with a maintainer decision — not as a quiet build. + +**Group-DM lexicon (primitive stays, naming goes):** +- `group_dm` channel type stays. "Council" / "Send a Raven" naming and any related UI copy goes. Surface as plain DMs. + +**Other Townhall lexicon** (mostly UI copy / docs, but track it down): +- Wardens, Citizens, Sigils, Crests, Allies, Banish, Silence, Decree, Council, Send-a-Raven, Voice Chamber → all gone +- All Ravn-era references (raven mascot, raven-themed copy, Munin agent name) +- Discovery (no code yet — just don't build it; strip any www links) + +**Marketing site:** +- Marketing site copy on `apps/www` — full rewrite for Lor positioning (keep waitlist mechanic, rewrite copy) + +### Build new +- **Connector framework** — lean MCP-native rather than building integrations one at a time +- **Indexing + embedding pipeline** (Postgres source-of-truth + Qdrant vectors) +- **Retrieval layer** +- **LLM orchestration** with tool-calling +- **ACL model:** source ACLs × workspace visibility (channels public to workspace, DMs private to participants, DM-indexed Merlin chats private to owner) +- **Wiki accumulation engine** — the visible growing brain (entity markdown pages maintained over time) +- **`@merlin` agent surface** inside threads (streaming responses, source citations, warm-gold thinking indicator) +- **Standalone Merlin chat surface** (the third sidebar tab, where DM-indexing applies) + +Recommended v1 scope: **one connector, done exceptionally well** (GitHub is the obvious pick for the dev-tools early audience) plus the collective-memory layer + visible wiki. Race for integration breadth later. + +## Open decisions + +- **Workspace primitive name.** Current lean: **`Workspaces`** (Linear/Notion/Figma vocabulary, B2B-recognized, zero cognitive load). Better-auth's default is `organizations` — defensible but longer and more corporate. A Lor-flavored option (`Keeps` — castle stronghold / "place where things are kept") exists but fights the "Merlin is the only lore-vocab token" rule. Decide before starting the `guilds → ?` rename pass. +- **Palette implementation in CSS** — twilight-violet + warm starlight-gold values not yet in `globals.css`. Need to land the new direction without re-triggering the painful color-tuning churn that happened in mid-May. +- **First integration:** GitHub or Linear? Slight lean toward GitHub for early dev audience. +- **Embedding model and chunking strategy** for Merlin. +- **Notification settings depth.** `user-notification-settings` table is kept for now; whether per-channel granularity survives or collapses to workspace-level prefs is TBD. +- **Voice transcription pipeline.** Whisper local vs. hosted (Deepgram/AssemblyAI) vs. Claude/Gemini multimodal — and whether transcripts live in Postgres as a side table or stream straight into the message corpus. Not blocking the delete pass. + +## Open work, in rough order + +**Foundation first — rework the existing chat app before any Merlin work begins.** Per maintainer call (2026-05-28): the order below front-loads the delete pass + workspace rename so we have a clean base, then layers Merlin on top. + +1. **Branch the delete pass.** Strip the old surfaces listed in [Delete aggressively](#delete-aggressively-do-not-rename-do-not-migrate-just-rm) — social/friendship layer, per-guild roles/bans/timeouts, `announcement`/`forum`/`category` channel types, Townhall lexicon, Ravn references. Voice channels stay. +2. **Resolve the workspace primitive name** (see Open decisions) and execute the `guilds → workspaces|organizations|keeps` rename across schema, API routes, web routes, and components. +3. **Collapse private-Hall scaffolding** if any landed — channels are public-to-workspace by design. +4. **Rebuild the sidebar IA** — tabbed sidebar (Channels / DMs / Merlin) + minimal top bar per [Navigation & sidebar IA](#navigation--sidebar-ia). Includes Discord-style collapsible categories. **The workspace switcher itself is deferred** — top-left can stay as a static workspace badge for now (the multi-workspace switcher dropdown is post-foundation work). +5. Rebuild marketing site copy on `apps/www` against the new Lor / institutional-memory positioning. +6. Trademark check on LOR in classes 9 & 42 (USPTO TESS). +7. ~~Register `ravn.to`.~~ Superseded — register / point `lor.chat`. +8. 30 customer discovery calls with CTOs / engineering leads before architecting Merlin. +9. Commission wordmark (o-as-portal) + constellation mark in Geist. +10. Update the shadcn theme in `packages/ui` to the twilight-violet + starlight-gold direction — carefully, with maintainer sign-off on values. + +**Then — Merlin. Not before the above is solid:** + +11. Wire up Qdrant. Decide embedding model + chunking + collection schema. +12. Begin the connector + retrieval work (likely GitHub first). +13. Implement `@merlin` agent surface — inline `@merlin` in threads (streaming, citations, gold-pulse) AND the standalone Merlin chat surface (the third sidebar tab, where DM-indexing applies). +14. Begin wiki-accumulation engine — structured markdown entity pages that grow with the corpus. +15. Voice-channel transcription → Merlin corpus pipeline (see Open decisions for stack choice). +16. Onboarding flow rewrite for B2B (workspace creation, invite teammates, connect first integration). + +## Related docs + +- [`README.md`](./README.md) — repo overview (still describes old Townhall as of this writing) +- [`ROADMAP.md`](./ROADMAP.md) — feature roadmap (will need a rewrite alongside the pivot) +- [`CLAUDE.md`](./CLAUDE.md) — Claude Code working notes for this repo diff --git a/apps/api/src/__tests__/auth-guard.test.ts b/apps/api/src/__tests__/auth-guard.test.ts index f3e897f..69169e6 100644 --- a/apps/api/src/__tests__/auth-guard.test.ts +++ b/apps/api/src/__tests__/auth-guard.test.ts @@ -2,11 +2,6 @@ import { describe, expect, it } from "vitest" import { client } from "./helpers" describe("Auth Guard — unauthenticated requests return 401", () => { - it("GET /v1/allies", async () => { - const res = await client.v1.allies.$get() - expect(res.status).toBe(401) - }) - it("GET /v1/dms", async () => { const res = await client.v1.dms.$get({ query: { @@ -17,25 +12,8 @@ describe("Auth Guard — unauthenticated requests return 401", () => { expect(res.status).toBe(401) }) - it("GET /v1/blocks", async () => { - const res = await client.v1.blocks.$get() - expect(res.status).toBe(401) - }) - it("GET /v1/notification-settings", async () => { const res = await client.v1["notification-settings"].$get() expect(res.status).toBe(401) }) - - it("GET /v1/privacy-settings", async () => { - const res = await client.v1["privacy-settings"].$get() - expect(res.status).toBe(401) - }) - - it("POST /v1/allies/requests", async () => { - const res = await client.v1.allies.requests.$post({ - json: { userId: "fake-id" }, - }) - expect(res.status).toBe(401) - }) }) diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index c61a5bf..515345a 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -4,14 +4,11 @@ import createApp from "@/lib/helpers/app/create-app" import configureOpenAPI from "@/lib/helpers/openapi/configure-openapi" import { globalRateLimit } from "@/middleware/rate-limit" import index from "@/routes/index.route" -import alliesRouter from "@/routes/v1/allies/index" -import blocksRouter from "@/routes/v1/blocks/index" import channelsRouter from "@/routes/v1/channels/index" import dmsRouter from "@/routes/v1/dms/index" import guildsRouter from "@/routes/v1/guilds/index" import invitesRouter from "@/routes/v1/invites/index" import notificationSettingsRouter from "@/routes/v1/notification-settings/index" -import privacySettingsRouter from "@/routes/v1/privacy-settings/index" import uploadsRouter from "@/routes/v1/uploads/index" import usersRouter from "@/routes/v1/users/index" import waitlistRouter from "@/routes/waitlist/index" @@ -40,13 +37,10 @@ app.route("/", index) // Route mounting — chained for Hono RPC type inference const routes = app .route("/", waitlistRouter) - .route("/v1", alliesRouter) - .route("/v1", blocksRouter) .route("/v1", channelsRouter) .route("/v1", guildsRouter) .route("/v1", invitesRouter) .route("/v1", notificationSettingsRouter) - .route("/v1", privacySettingsRouter) .route("/v1", dmsRouter) .route("/v1", uploadsRouter) .route("/v1", usersRouter) diff --git a/apps/api/src/routes/v1/allies/handlers.ts b/apps/api/src/routes/v1/allies/handlers.ts deleted file mode 100644 index 591c068..0000000 --- a/apps/api/src/routes/v1/allies/handlers.ts +++ /dev/null @@ -1,592 +0,0 @@ -import { and, db, eq, inArray, or, schema } from "@repo/db" -import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" -import type { AppRouteHandler } from "@/lib/types/app-types" -import type { - AcceptAllyRequestRoute, - DeclineAllyRequestRoute, - ListAlliesRoute, - ListAllyRequestsRoute, - RemoveAllyRoute, - SendAllyRequestRoute, -} from "./routes" - -// ── Helpers ────────────────────────────────────────────── - -function toUserResponse(user: { - id: string - name: string - username: string | null - displayUsername: string | null - image: string | null -}) { - return { - id: user.id, - name: user.name, - username: user.username, - displayUsername: user.displayUsername, - image: user.image, - } -} - -function toAllyRequestResponse( - request: { - id: string - status: "pending" | "accepted" | "declined" - createdAt: Date - }, - sender: { - id: string - name: string - username: string | null - displayUsername: string | null - image: string | null - }, - receiver: { - id: string - name: string - username: string | null - displayUsername: string | null - image: string | null - } -) { - return { - id: request.id, - sender: toUserResponse(sender), - receiver: toUserResponse(receiver), - status: request.status, - createdAt: request.createdAt.toISOString(), - } -} - -// ── Handlers ────────────────────────────────────────────── - -export const sendAllyRequest: AppRouteHandler = async ( - c -) => { - const currentUser = c.var.user - const { userId: targetUserId } = c.req.valid("json") - - if (currentUser.id === targetUserId) { - return c.json( - { success: false, message: "Cannot send an ally request to yourself" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - // Check target user exists - const targetUser = await db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(eq(schema.user.id, targetUserId)) - .limit(1) - .then((rows) => rows[0]) - - if (!targetUser) { - return c.json( - { success: false, message: "User not found" }, - HttpStatusCodes.NOT_FOUND - ) - } - - // Check if either user has blocked the other - const blockExists = await db - .select({ id: schema.userBlock.id }) - .from(schema.userBlock) - .where( - or( - and( - eq(schema.userBlock.blockerId, currentUser.id), - eq(schema.userBlock.blockedId, targetUserId) - ), - and( - eq(schema.userBlock.blockerId, targetUserId), - eq(schema.userBlock.blockedId, currentUser.id) - ) - ) - ) - .limit(1) - .then((rows) => rows[0]) - - if (blockExists) { - return c.json( - { success: false, message: "Unable to send ally request" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - // Check target user's privacy settings for ally requests - const targetPrivacy = await db - .select({ - allyRequestPrivacy: schema.userPrivacySettings.allyRequestPrivacy, - }) - .from(schema.userPrivacySettings) - .where(eq(schema.userPrivacySettings.userId, targetUserId)) - .limit(1) - .then((rows) => rows[0]) - - if (targetPrivacy?.allyRequestPrivacy === "no_one") { - return c.json( - { - success: false, - message: "This user is not accepting ally requests", - }, - HttpStatusCodes.FORBIDDEN - ) - } - - // Check for existing relationship (in either direction) - const existing = await db - .select({ - id: schema.allyRequest.id, - status: schema.allyRequest.status, - senderId: schema.allyRequest.senderId, - }) - .from(schema.allyRequest) - .where( - or( - and( - eq(schema.allyRequest.senderId, currentUser.id), - eq(schema.allyRequest.receiverId, targetUserId) - ), - and( - eq(schema.allyRequest.senderId, targetUserId), - eq(schema.allyRequest.receiverId, currentUser.id) - ) - ) - ) - .limit(1) - .then((rows) => rows[0]) - - if (existing) { - if (existing.status === "accepted") { - return c.json( - { success: false, message: "You are already allies" }, - HttpStatusCodes.BAD_REQUEST - ) - } - if (existing.status === "pending") { - return c.json( - { success: false, message: "An ally request already exists" }, - HttpStatusCodes.BAD_REQUEST - ) - } - // Status is "declined" — replace atomically to avoid race conditions - const [request] = await db.transaction(async (tx) => { - await tx - .delete(schema.allyRequest) - .where(eq(schema.allyRequest.id, existing.id)) - return tx - .insert(schema.allyRequest) - .values({ - senderId: currentUser.id, - receiverId: targetUserId, - }) - .returning() - }) - - if (!request) { - return c.json( - { success: false, message: "Failed to create ally request" }, - HttpStatusCodes.INTERNAL_SERVER_ERROR - ) - } - - const sender = await db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(eq(schema.user.id, currentUser.id)) - .limit(1) - .then((rows) => rows[0]) - - if (!sender) { - return c.json( - { success: false, message: "Failed to fetch user data" }, - HttpStatusCodes.INTERNAL_SERVER_ERROR - ) - } - - return c.json( - { - success: true, - request: toAllyRequestResponse(request, sender, targetUser), - }, - HttpStatusCodes.OK - ) - } - - const [request] = await db - .insert(schema.allyRequest) - .values({ - senderId: currentUser.id, - receiverId: targetUserId, - }) - .returning() - - if (!request) { - return c.json( - { success: false, message: "Failed to create ally request" }, - HttpStatusCodes.INTERNAL_SERVER_ERROR - ) - } - - const sender = await db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(eq(schema.user.id, currentUser.id)) - .limit(1) - .then((rows) => rows[0]) - - if (!sender) { - return c.json( - { success: false, message: "Failed to fetch user data" }, - HttpStatusCodes.INTERNAL_SERVER_ERROR - ) - } - - return c.json( - { - success: true, - request: toAllyRequestResponse(request, sender, targetUser), - }, - HttpStatusCodes.OK - ) -} - -export const listAllyRequests: AppRouteHandler = async ( - c -) => { - const currentUser = c.var.user - - const pendingRequests = await db - .select({ - id: schema.allyRequest.id, - senderId: schema.allyRequest.senderId, - receiverId: schema.allyRequest.receiverId, - status: schema.allyRequest.status, - createdAt: schema.allyRequest.createdAt, - senderName: schema.user.name, - senderUsername: schema.user.username, - senderDisplayUsername: schema.user.displayUsername, - senderImage: schema.user.image, - }) - .from(schema.allyRequest) - .innerJoin(schema.user, eq(schema.allyRequest.senderId, schema.user.id)) - .where( - and( - eq(schema.allyRequest.status, "pending"), - or( - eq(schema.allyRequest.senderId, currentUser.id), - eq(schema.allyRequest.receiverId, currentUser.id) - ) - ) - ) - - // We need receiver info too — fetch separately for the user IDs we need - const receiverIds = [ - ...new Set(pendingRequests.map((r) => r.receiverId)), - ].filter((id) => id !== currentUser.id) - - const receivers = - receiverIds.length > 0 - ? await db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(inArray(schema.user.id, receiverIds)) - : [] - - const receiverMap = new Map(receivers.map((r) => [r.id, r])) - const currentUserInfo = { - id: currentUser.id, - name: currentUser.name, - username: currentUser.username ?? null, - displayUsername: currentUser.displayUsername ?? null, - image: currentUser.image ?? null, - } - - const incoming: ReturnType[] = [] - const outgoing: ReturnType[] = [] - - for (const row of pendingRequests) { - const sender = { - id: row.senderId, - name: row.senderName, - username: row.senderUsername, - displayUsername: row.senderDisplayUsername, - image: row.senderImage, - } - - const receiver = - row.receiverId === currentUser.id - ? currentUserInfo - : receiverMap.get(row.receiverId) - - if (!receiver) continue - - const response = toAllyRequestResponse( - { id: row.id, status: row.status, createdAt: row.createdAt }, - sender, - receiver - ) - - if (row.receiverId === currentUser.id) { - incoming.push(response) - } else { - outgoing.push(response) - } - } - - return c.json({ incoming, outgoing }, HttpStatusCodes.OK) -} - -export const acceptAllyRequest: AppRouteHandler< - AcceptAllyRequestRoute -> = async (c) => { - const currentUser = c.var.user - const { requestId } = c.req.valid("param") - - const request = await db - .select() - .from(schema.allyRequest) - .where(eq(schema.allyRequest.id, requestId)) - .limit(1) - .then((rows) => rows[0]) - - if (!request) { - return c.json( - { success: false, message: "Ally request not found" }, - HttpStatusCodes.NOT_FOUND - ) - } - - if (request.receiverId !== currentUser.id) { - return c.json( - { success: false, message: "Forbidden" }, - HttpStatusCodes.FORBIDDEN - ) - } - - if (request.status !== "pending") { - return c.json( - { success: false, message: "Request is no longer pending" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - const [updated] = await db - .update(schema.allyRequest) - .set({ status: "accepted", updatedAt: new Date() }) - .where( - and( - eq(schema.allyRequest.id, requestId), - eq(schema.allyRequest.receiverId, currentUser.id), - eq(schema.allyRequest.status, "pending") - ) - ) - .returning() - - if (!updated) { - return c.json( - { success: false, message: "Request is no longer pending" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - // Fetch both users for the response - const [sender, receiver] = await Promise.all([ - db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(eq(schema.user.id, updated.senderId)) - .limit(1) - .then((rows) => rows[0]), - db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(eq(schema.user.id, updated.receiverId)) - .limit(1) - .then((rows) => rows[0]), - ]) - - if (!sender || !receiver) { - return c.json( - { success: false, message: "Failed to fetch user data" }, - HttpStatusCodes.INTERNAL_SERVER_ERROR - ) - } - - return c.json( - { - success: true, - request: toAllyRequestResponse(updated, sender, receiver), - }, - HttpStatusCodes.OK - ) -} - -export const declineAllyRequest: AppRouteHandler< - DeclineAllyRequestRoute -> = async (c) => { - const currentUser = c.var.user - const { requestId } = c.req.valid("param") - - const request = await db - .select() - .from(schema.allyRequest) - .where(eq(schema.allyRequest.id, requestId)) - .limit(1) - .then((rows) => rows[0]) - - if (!request) { - return c.json( - { success: false, message: "Ally request not found" }, - HttpStatusCodes.NOT_FOUND - ) - } - - if (request.receiverId !== currentUser.id) { - return c.json( - { success: false, message: "Forbidden" }, - HttpStatusCodes.FORBIDDEN - ) - } - - if (request.status !== "pending") { - return c.json( - { success: false, message: "Request is no longer pending" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - const updated = await db - .update(schema.allyRequest) - .set({ status: "declined", updatedAt: new Date() }) - .where( - and( - eq(schema.allyRequest.id, requestId), - eq(schema.allyRequest.receiverId, currentUser.id), - eq(schema.allyRequest.status, "pending") - ) - ) - .returning() - - if (updated.length === 0) { - return c.json( - { success: false, message: "Request is no longer pending" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - return c.json({ success: true }, HttpStatusCodes.OK) -} - -export const listAllies: AppRouteHandler = async (c) => { - const currentUser = c.var.user - - // Get all accepted ally requests where current user is sender or receiver - const acceptedRequests = await db - .select({ - senderId: schema.allyRequest.senderId, - receiverId: schema.allyRequest.receiverId, - }) - .from(schema.allyRequest) - .where( - and( - eq(schema.allyRequest.status, "accepted"), - or( - eq(schema.allyRequest.senderId, currentUser.id), - eq(schema.allyRequest.receiverId, currentUser.id) - ) - ) - ) - - // Extract the ally user IDs (the other person in each pair) - const allyIds = acceptedRequests.map((r) => - r.senderId === currentUser.id ? r.receiverId : r.senderId - ) - - if (allyIds.length === 0) { - return c.json({ allies: [] }, HttpStatusCodes.OK) - } - - const allies = await db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - }) - .from(schema.user) - .where(inArray(schema.user.id, allyIds)) - - return c.json({ allies: allies.map(toUserResponse) }, HttpStatusCodes.OK) -} - -export const removeAlly: AppRouteHandler = async (c) => { - const currentUser = c.var.user - const { userId: allyUserId } = c.req.valid("param") - - const deleted = await db - .delete(schema.allyRequest) - .where( - and( - eq(schema.allyRequest.status, "accepted"), - or( - and( - eq(schema.allyRequest.senderId, currentUser.id), - eq(schema.allyRequest.receiverId, allyUserId) - ), - and( - eq(schema.allyRequest.senderId, allyUserId), - eq(schema.allyRequest.receiverId, currentUser.id) - ) - ) - ) - ) - .returning() - - if (deleted.length === 0) { - return c.json( - { success: false, message: "Ally relationship not found" }, - HttpStatusCodes.NOT_FOUND - ) - } - - return c.json({ success: true }, HttpStatusCodes.OK) -} diff --git a/apps/api/src/routes/v1/allies/index.ts b/apps/api/src/routes/v1/allies/index.ts deleted file mode 100644 index fe5100c..0000000 --- a/apps/api/src/routes/v1/allies/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createRouter } from "@/lib/helpers/app/create-app" -import * as handlers from "@/routes/v1/allies/handlers" -import * as routes from "@/routes/v1/allies/routes" - -const alliesRouter = createRouter() - .openapi(routes.sendAllyRequest, handlers.sendAllyRequest) - .openapi(routes.listAllyRequests, handlers.listAllyRequests) - .openapi(routes.acceptAllyRequest, handlers.acceptAllyRequest) - .openapi(routes.declineAllyRequest, handlers.declineAllyRequest) - .openapi(routes.listAllies, handlers.listAllies) - .openapi(routes.removeAlly, handlers.removeAlly) - -export default alliesRouter diff --git a/apps/api/src/routes/v1/allies/routes.ts b/apps/api/src/routes/v1/allies/routes.ts deleted file mode 100644 index 4648462..0000000 --- a/apps/api/src/routes/v1/allies/routes.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { createRoute } from "@hono/zod-openapi" -import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" -import jsonContent from "@/lib/helpers/openapi/json-content" -import { - badRequestSchema, - forbiddenSchema, - internalServerErrorSchema, - notFoundSchema, - unauthorizedSchema, -} from "@/lib/helpers/openapi/schemas" -import { sessionAuthMiddleware } from "@/middleware/session-auth" -import { - acceptAllyRequestResponseSchema, - allyUserIdParamsSchema, - declineAllyRequestResponseSchema, - listAlliesResponseSchema, - listAllyRequestsResponseSchema, - removeAllyResponseSchema, - requestIdParamsSchema, - sendAllyRequestBodySchema, - sendAllyRequestResponseSchema, -} from "./schema" - -export const sendAllyRequest = createRoute({ - path: "/allies/requests", - method: "post", - summary: "Send an ally request", - description: "Sends an ally request to another user.", - tags: ["Allies"], - middleware: [sessionAuthMiddleware] as const, - request: { - body: jsonContent({ - schema: sendAllyRequestBodySchema, - description: "Target user to send ally request to", - }), - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: sendAllyRequestResponseSchema, - description: "Ally request sent", - }), - [HttpStatusCodes.BAD_REQUEST]: badRequestSchema, - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.FORBIDDEN]: forbiddenSchema, - [HttpStatusCodes.NOT_FOUND]: notFoundSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type SendAllyRequestRoute = typeof sendAllyRequest - -export const listAllyRequests = createRoute({ - path: "/allies/requests", - method: "get", - summary: "List pending ally requests", - description: - "Returns incoming and outgoing pending ally requests for the current user.", - tags: ["Allies"], - middleware: [sessionAuthMiddleware] as const, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: listAllyRequestsResponseSchema, - description: "Pending ally requests", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type ListAllyRequestsRoute = typeof listAllyRequests - -export const acceptAllyRequest = createRoute({ - path: "/allies/requests/{requestId}/accept", - method: "post", - summary: "Accept an ally request", - description: "Accepts a pending incoming ally request.", - tags: ["Allies"], - middleware: [sessionAuthMiddleware] as const, - request: { - params: requestIdParamsSchema, - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: acceptAllyRequestResponseSchema, - description: "Ally request accepted", - }), - [HttpStatusCodes.BAD_REQUEST]: badRequestSchema, - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.FORBIDDEN]: forbiddenSchema, - [HttpStatusCodes.NOT_FOUND]: notFoundSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type AcceptAllyRequestRoute = typeof acceptAllyRequest - -export const declineAllyRequest = createRoute({ - path: "/allies/requests/{requestId}/decline", - method: "post", - summary: "Decline an ally request", - description: - "Declines a pending incoming ally request. The sender can re-request later.", - tags: ["Allies"], - middleware: [sessionAuthMiddleware] as const, - request: { - params: requestIdParamsSchema, - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: declineAllyRequestResponseSchema, - description: "Ally request declined", - }), - [HttpStatusCodes.BAD_REQUEST]: badRequestSchema, - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.FORBIDDEN]: forbiddenSchema, - [HttpStatusCodes.NOT_FOUND]: notFoundSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type DeclineAllyRequestRoute = typeof declineAllyRequest - -export const listAllies = createRoute({ - path: "/allies", - method: "get", - summary: "List allies", - description: "Returns all allies for the current user.", - tags: ["Allies"], - middleware: [sessionAuthMiddleware] as const, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: listAlliesResponseSchema, - description: "List of allies", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type ListAlliesRoute = typeof listAllies - -export const removeAlly = createRoute({ - path: "/allies/{userId}", - method: "delete", - summary: "Remove an ally", - description: "Removes an ally relationship. Either user can remove.", - tags: ["Allies"], - middleware: [sessionAuthMiddleware] as const, - request: { - params: allyUserIdParamsSchema, - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: removeAllyResponseSchema, - description: "Ally removed", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.NOT_FOUND]: notFoundSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type RemoveAllyRoute = typeof removeAlly diff --git a/apps/api/src/routes/v1/allies/schema.ts b/apps/api/src/routes/v1/allies/schema.ts deleted file mode 100644 index 00698de..0000000 --- a/apps/api/src/routes/v1/allies/schema.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { z } from "@hono/zod-openapi" -import { selectAllyRequestSchema } from "@repo/db/schema" - -// ── Path Params ────────────────────────────────────────── - -export const requestIdParamsSchema = z.object({ - requestId: z - .string() - .uuid() - .openapi({ - param: { name: "requestId", in: "path", required: true }, - example: "00000000-0000-0000-0000-000000000000", - }), -}) - -export const allyUserIdParamsSchema = z.object({ - userId: z - .string() - .uuid() - .openapi({ - param: { name: "userId", in: "path", required: true }, - example: "00000000-0000-0000-0000-000000000000", - }), -}) - -// ── Request Schemas ────────────────────────────────────── - -export const sendAllyRequestBodySchema = z.object({ - userId: z.string().uuid(), -}) - -// ── Response Schemas ────────────────────────────────────── - -const allyUserSchema = z.object({ - id: z.string().uuid(), - name: z.string(), - username: z.string().nullable(), - displayUsername: z.string().nullable(), - image: z.string().nullable(), -}) - -export const allyRequestResponseSchema = z.object({ - id: selectAllyRequestSchema.shape.id, - sender: allyUserSchema, - receiver: allyUserSchema, - status: selectAllyRequestSchema.shape.status, - createdAt: z.string().datetime(), -}) - -export const sendAllyRequestResponseSchema = z.object({ - success: z.literal(true), - request: allyRequestResponseSchema, -}) - -export const listAllyRequestsResponseSchema = z.object({ - incoming: z.array(allyRequestResponseSchema), - outgoing: z.array(allyRequestResponseSchema), -}) - -export const acceptAllyRequestResponseSchema = z.object({ - success: z.literal(true), - request: allyRequestResponseSchema, -}) - -export const declineAllyRequestResponseSchema = z.object({ - success: z.literal(true), -}) - -export const listAlliesResponseSchema = z.object({ - allies: z.array(allyUserSchema), -}) - -export const removeAllyResponseSchema = z.object({ - success: z.literal(true), -}) diff --git a/apps/api/src/routes/v1/blocks/handlers.ts b/apps/api/src/routes/v1/blocks/handlers.ts deleted file mode 100644 index 886977d..0000000 --- a/apps/api/src/routes/v1/blocks/handlers.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { and, db, desc, eq, or, schema } from "@repo/db" -import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" -import type { AppRouteHandler } from "@/lib/types/app-types" -import type { - BlockUserRoute, - ListBlockedUsersRoute, - UnblockUserRoute, -} from "./routes" - -export const blockUser: AppRouteHandler = async (c) => { - const currentUser = c.var.user - const { userId: targetUserId } = c.req.valid("json") - - if (currentUser.id === targetUserId) { - return c.json( - { success: false, message: "Cannot block yourself" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - // Check target user exists - const targetUser = await db - .select({ id: schema.user.id }) - .from(schema.user) - .where(eq(schema.user.id, targetUserId)) - .limit(1) - .then((rows) => rows[0]) - - if (!targetUser) { - return c.json( - { success: false, message: "User not found" }, - HttpStatusCodes.NOT_FOUND - ) - } - - // Atomically: insert block + remove any ally relationship - const result = await db.transaction(async (tx) => { - const inserted = await tx - .insert(schema.userBlock) - .values({ - blockerId: currentUser.id, - blockedId: targetUserId, - }) - .onConflictDoNothing() - .returning() - - if (inserted.length === 0) { - return { alreadyBlocked: true } - } - - // Delete any ally request between the two users (in either direction) - await tx - .delete(schema.allyRequest) - .where( - or( - and( - eq(schema.allyRequest.senderId, currentUser.id), - eq(schema.allyRequest.receiverId, targetUserId) - ), - and( - eq(schema.allyRequest.senderId, targetUserId), - eq(schema.allyRequest.receiverId, currentUser.id) - ) - ) - ) - - return { alreadyBlocked: false } - }) - - if (result.alreadyBlocked) { - return c.json( - { success: false, message: "User is already blocked" }, - HttpStatusCodes.BAD_REQUEST - ) - } - - return c.json({ success: true }, HttpStatusCodes.OK) -} - -export const unblockUser: AppRouteHandler = async (c) => { - const currentUser = c.var.user - const { userId: targetUserId } = c.req.valid("param") - - const deleted = await db - .delete(schema.userBlock) - .where( - and( - eq(schema.userBlock.blockerId, currentUser.id), - eq(schema.userBlock.blockedId, targetUserId) - ) - ) - .returning() - - if (deleted.length === 0) { - return c.json( - { success: false, message: "Block not found" }, - HttpStatusCodes.NOT_FOUND - ) - } - - return c.json({ success: true }, HttpStatusCodes.OK) -} - -export const listBlockedUsers: AppRouteHandler = async ( - c -) => { - const currentUser = c.var.user - - const blocks = await db - .select({ - id: schema.user.id, - name: schema.user.name, - username: schema.user.username, - displayUsername: schema.user.displayUsername, - image: schema.user.image, - blockedAt: schema.userBlock.createdAt, - }) - .from(schema.userBlock) - .innerJoin(schema.user, eq(schema.userBlock.blockedId, schema.user.id)) - .where(eq(schema.userBlock.blockerId, currentUser.id)) - .orderBy(desc(schema.userBlock.createdAt)) - - return c.json( - { - blockedUsers: blocks.map((b) => ({ - id: b.id, - name: b.name, - username: b.username, - displayUsername: b.displayUsername, - image: b.image, - blockedAt: b.blockedAt.toISOString(), - })), - }, - HttpStatusCodes.OK - ) -} diff --git a/apps/api/src/routes/v1/blocks/index.ts b/apps/api/src/routes/v1/blocks/index.ts deleted file mode 100644 index 6737601..0000000 --- a/apps/api/src/routes/v1/blocks/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createRouter } from "@/lib/helpers/app/create-app" -import * as handlers from "@/routes/v1/blocks/handlers" -import * as routes from "@/routes/v1/blocks/routes" - -const blocksRouter = createRouter() - .openapi(routes.blockUser, handlers.blockUser) - .openapi(routes.unblockUser, handlers.unblockUser) - .openapi(routes.listBlockedUsers, handlers.listBlockedUsers) - -export default blocksRouter diff --git a/apps/api/src/routes/v1/blocks/routes.ts b/apps/api/src/routes/v1/blocks/routes.ts deleted file mode 100644 index cace9a3..0000000 --- a/apps/api/src/routes/v1/blocks/routes.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { createRoute } from "@hono/zod-openapi" -import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" -import jsonContent from "@/lib/helpers/openapi/json-content" -import { - badRequestSchema, - internalServerErrorSchema, - notFoundSchema, - unauthorizedSchema, -} from "@/lib/helpers/openapi/schemas" -import { sessionAuthMiddleware } from "@/middleware/session-auth" -import { - blockUserBodySchema, - blockUserIdParamsSchema, - blockUserResponseSchema, - listBlockedUsersResponseSchema, - unblockUserResponseSchema, -} from "./schema" - -export const blockUser = createRoute({ - path: "/blocks", - method: "post", - summary: "Block a user", - description: - "Blocks a user. Removes any existing ally relationship between the users.", - tags: ["Blocks"], - middleware: [sessionAuthMiddleware] as const, - request: { - body: jsonContent({ - schema: blockUserBodySchema, - description: "User to block", - }), - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: blockUserResponseSchema, - description: "User blocked", - }), - [HttpStatusCodes.BAD_REQUEST]: badRequestSchema, - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.NOT_FOUND]: notFoundSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type BlockUserRoute = typeof blockUser - -export const unblockUser = createRoute({ - path: "/blocks/{userId}", - method: "delete", - summary: "Unblock a user", - description: "Removes a block on the specified user.", - tags: ["Blocks"], - middleware: [sessionAuthMiddleware] as const, - request: { - params: blockUserIdParamsSchema, - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: unblockUserResponseSchema, - description: "User unblocked", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.NOT_FOUND]: notFoundSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type UnblockUserRoute = typeof unblockUser - -export const listBlockedUsers = createRoute({ - path: "/blocks", - method: "get", - summary: "List blocked users", - description: "Returns all users blocked by the current user.", - tags: ["Blocks"], - middleware: [sessionAuthMiddleware] as const, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: listBlockedUsersResponseSchema, - description: "List of blocked users", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type ListBlockedUsersRoute = typeof listBlockedUsers diff --git a/apps/api/src/routes/v1/blocks/schema.ts b/apps/api/src/routes/v1/blocks/schema.ts deleted file mode 100644 index 05090d8..0000000 --- a/apps/api/src/routes/v1/blocks/schema.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { z } from "@hono/zod-openapi" - -// ── Path Params ────────────────────────────────────────── - -export const blockUserIdParamsSchema = z.object({ - userId: z - .string() - .uuid() - .openapi({ - param: { name: "userId", in: "path", required: true }, - example: "00000000-0000-0000-0000-000000000000", - }), -}) - -// ── Request Schemas ────────────────────────────────────── - -export const blockUserBodySchema = z.object({ - userId: z.string().uuid(), -}) - -// ── Response Schemas ────────────────────────────────────── - -const blockedUserSchema = z.object({ - id: z.string().uuid(), - name: z.string(), - username: z.string().nullable(), - displayUsername: z.string().nullable(), - image: z.string().nullable(), - blockedAt: z.string().datetime(), -}) - -export const blockUserResponseSchema = z.object({ - success: z.literal(true), -}) - -export const unblockUserResponseSchema = z.object({ - success: z.literal(true), -}) - -export const listBlockedUsersResponseSchema = z.object({ - blockedUsers: z.array(blockedUserSchema), -}) diff --git a/apps/api/src/routes/v1/dms/handlers.ts b/apps/api/src/routes/v1/dms/handlers.ts index c87a7aa..6db1716 100644 --- a/apps/api/src/routes/v1/dms/handlers.ts +++ b/apps/api/src/routes/v1/dms/handlers.ts @@ -1,14 +1,12 @@ import { db } from "@repo/db" import { - allyRequest, channel, channelMember, + guildMember, message, user, - userBlock, - userPrivacySettings, } from "@repo/db/schema" -import { and, count, desc, eq, ilike, inArray, ne, or, sql } from "drizzle-orm" +import { and, count, desc, eq, ilike, inArray, ne, sql } from "drizzle-orm" import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" import { fetchMessagePage } from "@/lib/queries/messages" import type { AppRouteHandler } from "@/lib/types/app-types" @@ -74,101 +72,49 @@ export const createDM: AppRouteHandler = async (c) => { ) } - // Check if any target user has a block relationship with the current user - const blockRows = await db - .select({ id: userBlock.id }) - .from(userBlock) - .where( - or( - and( - eq(userBlock.blockerId, currentUser.id), - inArray(userBlock.blockedId, targetUserIds) - ), - and( - inArray(userBlock.blockerId, targetUserIds), - eq(userBlock.blockedId, currentUser.id) - ) - ) - ) - .limit(1) + // Workspace-scope check: every target must share at least one workspace + // (guild) with the requester. DMs are scoped to workspace membership in + // Lor — you can't DM someone you don't share a workspace with. + const myGuildRows = await db + .select({ guildId: guildMember.guildId }) + .from(guildMember) + .where(eq(guildMember.userId, currentUser.id)) + + const myGuildIds = myGuildRows.map((row) => row.guildId) - if (blockRows.length > 0) { + if (myGuildIds.length === 0) { return c.json( - { success: false, message: "Unable to create conversation" }, + { + success: false, + message: "You must belong to a workspace to start a conversation", + }, HttpStatusCodes.FORBIDDEN ) } - // Fetch target users' privacy settings - const targetPrivacyRows = await db - .select({ - userId: userPrivacySettings.userId, - dmPrivacy: userPrivacySettings.dmPrivacy, - }) - .from(userPrivacySettings) - .where(inArray(userPrivacySettings.userId, targetUserIds)) + const sharedRows = await db + .selectDistinct({ userId: guildMember.userId }) + .from(guildMember) + .where( + and( + inArray(guildMember.guildId, myGuildIds), + inArray(guildMember.userId, targetUserIds) + ) + ) - const privacyByUserId = new Map( - targetPrivacyRows.map((r) => [r.userId, r.dmPrivacy]) - ) + const sharedUserIds = new Set(sharedRows.map((row) => row.userId)) + const unreachable = targetUserIds.filter((id) => !sharedUserIds.has(id)) - // Check if any target user has DMs set to "no_one" - const noOneIds = targetUserIds.filter( - (id) => privacyByUserId.get(id) === "no_one" - ) - if (noOneIds.length > 0) { + if (unreachable.length > 0) { return c.json( - { success: false, message: "This user is not accepting direct messages" }, + { + success: false, + message: "You can only DM members of a workspace you share", + }, HttpStatusCodes.FORBIDDEN ) } - // For users with "allies_only" privacy, verify ally relationship - const alliesOnlyIds = targetUserIds.filter( - (id) => privacyByUserId.get(id) === "allies_only" - ) - - if (alliesOnlyIds.length > 0) { - const allyRows = await db - .select({ - senderId: allyRequest.senderId, - receiverId: allyRequest.receiverId, - }) - .from(allyRequest) - .where( - and( - eq(allyRequest.status, "accepted"), - or( - and( - eq(allyRequest.senderId, currentUser.id), - inArray(allyRequest.receiverId, alliesOnlyIds) - ), - and( - inArray(allyRequest.senderId, alliesOnlyIds), - eq(allyRequest.receiverId, currentUser.id) - ) - ) - ) - ) - - const allyUserIds = new Set( - allyRows.map((r) => - r.senderId === currentUser.id ? r.receiverId : r.senderId - ) - ) - - const nonAllyIds = alliesOnlyIds.filter((id) => !allyUserIds.has(id)) - if (nonAllyIds.length > 0) { - return c.json( - { - success: false, - message: "This user only accepts DMs from allies", - }, - HttpStatusCodes.FORBIDDEN - ) - } - } - const allMemberIds = [currentUser.id, ...targetUserIds].sort() const isDirect = targetUserIds.length === 1 diff --git a/apps/api/src/routes/v1/dms/routes.ts b/apps/api/src/routes/v1/dms/routes.ts index e3e5772..75da619 100644 --- a/apps/api/src/routes/v1/dms/routes.ts +++ b/apps/api/src/routes/v1/dms/routes.ts @@ -27,7 +27,7 @@ export const createDM = createRoute({ method: "post", summary: "Create or find a DM", description: - "Creates a new DM or group DM with the specified users, or returns an existing one. For 1-on-1 DMs, requires the target user to be an ally. For group DMs, requires all target users to be allies of the creator.", + "Creates a new DM or group DM with the specified users, or returns an existing one. All target users must share at least one workspace with the requester.", tags: ["DMs"], middleware: [sessionAuthMiddleware] as const, request: { diff --git a/apps/api/src/routes/v1/privacy-settings/handlers.ts b/apps/api/src/routes/v1/privacy-settings/handlers.ts deleted file mode 100644 index 3420a05..0000000 --- a/apps/api/src/routes/v1/privacy-settings/handlers.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { db, eq, schema } from "@repo/db" -import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" -import type { AppRouteHandler } from "@/lib/types/app-types" -import type { - GetPrivacySettingsRoute, - UpdatePrivacySettingsRoute, -} from "./routes" - -const DEFAULT_SETTINGS = { - dmPrivacy: "everyone" as const, - allyRequestPrivacy: "everyone" as const, - onlineStatusPrivacy: "everyone" as const, -} - -export const getPrivacySettings: AppRouteHandler< - GetPrivacySettingsRoute -> = async (c) => { - const currentUser = c.var.user - - const settings = await db - .select({ - dmPrivacy: schema.userPrivacySettings.dmPrivacy, - allyRequestPrivacy: schema.userPrivacySettings.allyRequestPrivacy, - onlineStatusPrivacy: schema.userPrivacySettings.onlineStatusPrivacy, - }) - .from(schema.userPrivacySettings) - .where(eq(schema.userPrivacySettings.userId, currentUser.id)) - .limit(1) - .then((rows) => rows[0]) - - return c.json(settings ?? DEFAULT_SETTINGS, HttpStatusCodes.OK) -} - -export const updatePrivacySettings: AppRouteHandler< - UpdatePrivacySettingsRoute -> = async (c) => { - const currentUser = c.var.user - const body = c.req.valid("json") - - const updated = await db - .insert(schema.userPrivacySettings) - .values({ - userId: currentUser.id, - ...body, - }) - .onConflictDoUpdate({ - target: schema.userPrivacySettings.userId, - set: body, - }) - .returning({ - dmPrivacy: schema.userPrivacySettings.dmPrivacy, - allyRequestPrivacy: schema.userPrivacySettings.allyRequestPrivacy, - onlineStatusPrivacy: schema.userPrivacySettings.onlineStatusPrivacy, - }) - .then((rows) => rows[0]) - - if (!updated) { - return c.json(DEFAULT_SETTINGS, HttpStatusCodes.OK) - } - - return c.json(updated, HttpStatusCodes.OK) -} diff --git a/apps/api/src/routes/v1/privacy-settings/index.ts b/apps/api/src/routes/v1/privacy-settings/index.ts deleted file mode 100644 index 8f64fce..0000000 --- a/apps/api/src/routes/v1/privacy-settings/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createRouter } from "@/lib/helpers/app/create-app" -import * as handlers from "@/routes/v1/privacy-settings/handlers" -import * as routes from "@/routes/v1/privacy-settings/routes" - -const privacySettingsRouter = createRouter() - .openapi(routes.getPrivacySettings, handlers.getPrivacySettings) - .openapi(routes.updatePrivacySettings, handlers.updatePrivacySettings) - -export default privacySettingsRouter diff --git a/apps/api/src/routes/v1/privacy-settings/routes.ts b/apps/api/src/routes/v1/privacy-settings/routes.ts deleted file mode 100644 index 972097e..0000000 --- a/apps/api/src/routes/v1/privacy-settings/routes.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { createRoute } from "@hono/zod-openapi" -import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" -import jsonContent from "@/lib/helpers/openapi/json-content" -import { - internalServerErrorSchema, - unauthorizedSchema, -} from "@/lib/helpers/openapi/schemas" -import { sessionAuthMiddleware } from "@/middleware/session-auth" -import { - getPrivacySettingsResponseSchema, - updatePrivacySettingsBodySchema, - updatePrivacySettingsResponseSchema, -} from "./schema" - -export const getPrivacySettings = createRoute({ - path: "/privacy-settings", - method: "get", - summary: "Get privacy settings", - description: "Returns the current user's privacy settings.", - tags: ["Privacy Settings"], - middleware: [sessionAuthMiddleware] as const, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: getPrivacySettingsResponseSchema, - description: "Privacy settings", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type GetPrivacySettingsRoute = typeof getPrivacySettings - -export const updatePrivacySettings = createRoute({ - path: "/privacy-settings", - method: "patch", - summary: "Update privacy settings", - description: "Updates the current user's privacy settings.", - tags: ["Privacy Settings"], - middleware: [sessionAuthMiddleware] as const, - request: { - body: jsonContent({ - schema: updatePrivacySettingsBodySchema, - description: "Privacy settings to update", - }), - }, - responses: { - [HttpStatusCodes.OK]: jsonContent({ - schema: updatePrivacySettingsResponseSchema, - description: "Updated privacy settings", - }), - [HttpStatusCodes.UNAUTHORIZED]: unauthorizedSchema, - [HttpStatusCodes.INTERNAL_SERVER_ERROR]: internalServerErrorSchema, - }, -}) - -export type UpdatePrivacySettingsRoute = typeof updatePrivacySettings diff --git a/apps/api/src/routes/v1/privacy-settings/schema.ts b/apps/api/src/routes/v1/privacy-settings/schema.ts deleted file mode 100644 index 8b3376e..0000000 --- a/apps/api/src/routes/v1/privacy-settings/schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { - privacySettingsResponseSchema, - updatePrivacySettingsSchema, -} from "@repo/db/schema" - -export const getPrivacySettingsResponseSchema = privacySettingsResponseSchema -export const updatePrivacySettingsBodySchema = updatePrivacySettingsSchema -export const updatePrivacySettingsResponseSchema = privacySettingsResponseSchema diff --git a/apps/api/src/routes/v1/users/handlers.ts b/apps/api/src/routes/v1/users/handlers.ts index dd6ad66..6d5c75a 100644 --- a/apps/api/src/routes/v1/users/handlers.ts +++ b/apps/api/src/routes/v1/users/handlers.ts @@ -1,4 +1,4 @@ -import { and, db, eq, or, schema } from "@repo/db" +import { db, eq, schema } from "@repo/db" import { PRESENCE_ONLINE_USERS_SET_KEY } from "@repo/realtime-types" import * as HttpStatusCodes from "@/lib/helpers/http/status-codes" import { getRedisClient } from "@/lib/redis" @@ -8,7 +8,6 @@ import type { GetUserProfileRoute } from "./routes" export const getUserProfile: AppRouteHandler = async ( c ) => { - const currentUser = c.var.user const { userId } = c.req.valid("param") const targetUser = await db @@ -46,84 +45,6 @@ export const getUserProfile: AppRouteHandler = async ( // fail open — default to offline } - // Check block relationship - let blockStatus: - | "none" - | "blocked_by_me" - | "blocked_by_them" - | "mutual_block" = "none" - - if (currentUser.id !== userId) { - const blocks = await db - .select({ - blockerId: schema.userBlock.blockerId, - }) - .from(schema.userBlock) - .where( - or( - and( - eq(schema.userBlock.blockerId, currentUser.id), - eq(schema.userBlock.blockedId, userId) - ), - and( - eq(schema.userBlock.blockerId, userId), - eq(schema.userBlock.blockedId, currentUser.id) - ) - ) - ) - - const blockedByMe = blocks.some((b) => b.blockerId === currentUser.id) - const blockedByThem = blocks.some((b) => b.blockerId === userId) - - if (blockedByMe && blockedByThem) { - blockStatus = "mutual_block" - } else if (blockedByMe) { - blockStatus = "blocked_by_me" - } else if (blockedByThem) { - blockStatus = "blocked_by_them" - } - } - - // Check ally relationship - const allyRequest = await db - .select({ - id: schema.allyRequest.id, - senderId: schema.allyRequest.senderId, - receiverId: schema.allyRequest.receiverId, - status: schema.allyRequest.status, - }) - .from(schema.allyRequest) - .where( - or( - and( - eq(schema.allyRequest.senderId, currentUser.id), - eq(schema.allyRequest.receiverId, userId) - ), - and( - eq(schema.allyRequest.senderId, userId), - eq(schema.allyRequest.receiverId, currentUser.id) - ) - ) - ) - .limit(1) - .then((rows) => rows[0]) - - let allyStatus: "none" | "pending_incoming" | "pending_outgoing" | "allies" = - "none" - let allyRequestId: string | null = null - - if (allyRequest) { - allyRequestId = allyRequest.id - if (allyRequest.status === "accepted") { - allyStatus = "allies" - } else if (allyRequest.status === "pending") { - allyStatus = - allyRequest.senderId === currentUser.id - ? "pending_outgoing" - : "pending_incoming" - } - } - return c.json( { success: true, @@ -137,9 +58,6 @@ export const getUserProfile: AppRouteHandler = async ( status: targetUser.status ?? null, createdAt: targetUser.createdAt.toISOString(), presenceStatus, - allyStatus, - allyRequestId, - blockStatus, }, }, HttpStatusCodes.OK diff --git a/apps/api/src/routes/v1/users/routes.ts b/apps/api/src/routes/v1/users/routes.ts index a736649..24bdc38 100644 --- a/apps/api/src/routes/v1/users/routes.ts +++ b/apps/api/src/routes/v1/users/routes.ts @@ -13,8 +13,7 @@ export const getUserProfile = createRoute({ path: "/users/{userId}", method: "get", summary: "Get user profile", - description: - "Returns a user's public profile including ally status with the current user.", + description: "Returns a user's public profile.", tags: ["Users"], middleware: [sessionAuthMiddleware] as const, request: { diff --git a/apps/api/src/routes/v1/users/schema.ts b/apps/api/src/routes/v1/users/schema.ts index 3aaa073..a8daced 100644 --- a/apps/api/src/routes/v1/users/schema.ts +++ b/apps/api/src/routes/v1/users/schema.ts @@ -20,19 +20,6 @@ export const userProfileResponseSchema = z.object({ status: z.string().nullable(), createdAt: z.string().datetime(), presenceStatus: z.enum(["online", "offline"]), - allyStatus: z.enum([ - "none", - "pending_incoming", - "pending_outgoing", - "allies", - ]), - allyRequestId: z.string().uuid().nullable(), - blockStatus: z.enum([ - "none", - "blocked_by_me", - "blocked_by_them", - "mutual_block", - ]), }) export const getUserProfileResponseSchema = z.object({ diff --git a/apps/realtime/src/index.ts b/apps/realtime/src/index.ts index 6926545..1fca827 100644 --- a/apps/realtime/src/index.ts +++ b/apps/realtime/src/index.ts @@ -1,6 +1,6 @@ import { createServer } from "node:http" import { auth, type Session } from "@repo/auth" -import { and, db, eq, inArray, or, schema } from "@repo/db" +import { and, db, eq, schema } from "@repo/db" import { env } from "@repo/env/server" import type { ClientToServerEvents, @@ -29,7 +29,6 @@ import { createClient } from "redis" import { Server, type Socket } from "socket.io" import { toErrorMessage } from "@/lib/errors" import { logger } from "@/lib/logger" -import { isDMBlockedForUser } from "@/services/blocks" import { assertUserCanAccessChannel } from "@/services/channel-access" import { createMessage, @@ -237,26 +236,12 @@ async function initializeConnection(socket: RealtimeSocket) { } if (becameOnline && isCurrentSocketAlive) { - // Check user's online status privacy before broadcasting - const privacyRow = await db - .select({ - onlineStatusPrivacy: schema.userPrivacySettings.onlineStatusPrivacy, + for (const guildId of guildIds) { + io.to(guildRoom(guildId)).emit("presence:user:update", { + guildId, + userId: socket.data.user.id, + status: "online", }) - .from(schema.userPrivacySettings) - .where(eq(schema.userPrivacySettings.userId, socket.data.user.id)) - .limit(1) - .then((rows) => rows[0]) - - const onlinePrivacy = privacyRow?.onlineStatusPrivacy ?? "everyone" - - if (onlinePrivacy !== "no_one") { - for (const guildId of guildIds) { - io.to(guildRoom(guildId)).emit("presence:user:update", { - guildId, - userId: socket.data.user.id, - status: "online", - }) - } } } @@ -348,88 +333,11 @@ io.on("connection", (socket) => { userIds ) - // Filter online users by their privacy settings - const requestingUserId = socket.data.user.id - let visibleOnlineUserIds = onlineUserIds - - if (onlineUserIds.length > 0) { - // Fetch privacy settings for online users (excluding the requester) - const otherOnlineIds = onlineUserIds.filter( - (id) => id !== requestingUserId - ) - - if (otherOnlineIds.length > 0) { - const privacyRows = await db - .select({ - userId: schema.userPrivacySettings.userId, - onlineStatusPrivacy: - schema.userPrivacySettings.onlineStatusPrivacy, - }) - .from(schema.userPrivacySettings) - .where(inArray(schema.userPrivacySettings.userId, otherOnlineIds)) - - const privacyByUserId = new Map( - privacyRows.map((r) => [r.userId, r.onlineStatusPrivacy]) - ) - - // Find users with "allies_only" privacy - const alliesOnlyIds = otherOnlineIds.filter( - (id) => privacyByUserId.get(id) === "allies_only" - ) - - // Find users with "no_one" privacy - const noOneIds = new Set( - otherOnlineIds.filter((id) => privacyByUserId.get(id) === "no_one") - ) - - // Check ally relationships for "allies_only" users - let allyIds = new Set() - if (alliesOnlyIds.length > 0) { - const allyRows = await db - .select({ - senderId: schema.allyRequest.senderId, - receiverId: schema.allyRequest.receiverId, - }) - .from(schema.allyRequest) - .where( - and( - eq(schema.allyRequest.status, "accepted"), - or( - and( - eq(schema.allyRequest.senderId, requestingUserId), - inArray(schema.allyRequest.receiverId, alliesOnlyIds) - ), - and( - eq(schema.allyRequest.receiverId, requestingUserId), - inArray(schema.allyRequest.senderId, alliesOnlyIds) - ) - ) - ) - ) - - allyIds = new Set( - allyRows.map((r) => - r.senderId === requestingUserId ? r.receiverId : r.senderId - ) - ) - } - - visibleOnlineUserIds = onlineUserIds.filter((id) => { - if (id === requestingUserId) return true - if (noOneIds.has(id)) return false - if (privacyByUserId.get(id) === "allies_only") { - return allyIds.has(id) - } - return true // "everyone" or no settings (default) - }) - } - } - ack?.({ ok: true, snapshot: { guildId: parsed.guildId, - onlineUserIds: visibleOnlineUserIds, + onlineUserIds, }, }) } catch (error) { @@ -477,21 +385,6 @@ io.on("connection", (socket) => { redisPresenceClient, socket.data.user.id ) - - // Block enforcement for 1:1 DMs only (group DMs use client-side filtering) - if (accessibleChannel.type === "dm") { - const blocked = await isDMBlockedForUser( - parsed.channelId, - socket.data.user.id - ) - if (blocked) { - ack?.({ - ok: false, - error: "Cannot send messages in this conversation", - }) - return - } - } } const createdMessage = await createMessage({ @@ -641,19 +534,7 @@ io.on("connection", (socket) => { socket.on("typing:start", async (payload) => { try { const parsed = typingStartPayloadSchema.parse(payload) - const accessibleChannel = await assertUserCanAccessChannel( - socket.data.user.id, - parsed.channelId - ) - - // Suppress typing in 1:1 DMs if blocked - if (accessibleChannel.type === "dm") { - const blocked = await isDMBlockedForUser( - parsed.channelId, - socket.data.user.id - ) - if (blocked) return - } + await assertUserCanAccessChannel(socket.data.user.id, parsed.channelId) socket.to(channelRoom(parsed.channelId)).emit("typing:update", { channelId: parsed.channelId, @@ -724,26 +605,12 @@ io.on("connection", (socket) => { if (!becameOffline) return - // Check user's online status privacy before broadcasting - const privacyRow = await db - .select({ - onlineStatusPrivacy: schema.userPrivacySettings.onlineStatusPrivacy, + for (const guildId of socket.data.guildIds ?? []) { + io.to(guildRoom(guildId)).emit("presence:user:update", { + guildId, + userId: socket.data.user.id, + status: "offline", }) - .from(schema.userPrivacySettings) - .where(eq(schema.userPrivacySettings.userId, socket.data.user.id)) - .limit(1) - .then((rows) => rows[0]) - - const onlinePrivacy = privacyRow?.onlineStatusPrivacy ?? "everyone" - - if (onlinePrivacy !== "no_one") { - for (const guildId of socket.data.guildIds ?? []) { - io.to(guildRoom(guildId)).emit("presence:user:update", { - guildId, - userId: socket.data.user.id, - status: "offline", - }) - } } } catch (error) { logger.error( diff --git a/apps/realtime/src/services/blocks.ts b/apps/realtime/src/services/blocks.ts deleted file mode 100644 index 080cbb4..0000000 --- a/apps/realtime/src/services/blocks.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { and, db, eq, ne, or, schema } from "@repo/db" - -/** - * Check if a block exists between users in a 1:1 DM channel. - * Only enforced for "dm" type, NOT "group_dm" — in group DMs, - * blocked users can still send but messages are hidden client-side. - */ -export async function isDMBlockedForUser( - channelId: string, - userId: string -): Promise { - // Get the single other member of the 1:1 DM - const otherMember = await db - .select({ userId: schema.channelMember.userId }) - .from(schema.channelMember) - .where( - and( - eq(schema.channelMember.channelId, channelId), - ne(schema.channelMember.userId, userId) - ) - ) - .limit(1) - .then((rows) => rows[0]) - - if (!otherMember) return false - - const otherUserId = otherMember.userId - - // Check if a block exists in either direction - const block = await db - .select({ id: schema.userBlock.id }) - .from(schema.userBlock) - .where( - or( - and( - eq(schema.userBlock.blockerId, userId), - eq(schema.userBlock.blockedId, otherUserId) - ), - and( - eq(schema.userBlock.blockerId, otherUserId), - eq(schema.userBlock.blockedId, userId) - ) - ) - ) - .limit(1) - .then((rows) => rows[0]) - - return !!block -} diff --git a/apps/web/package.json b/apps/web/package.json index 481c8e8..2c16d07 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -25,6 +25,7 @@ "@tauri-apps/plugin-notification": "^2.3.3", "@tauri-apps/plugin-process": "^2.3.1", "@tauri-apps/plugin-updater": "^2.10.1", + "@tiptap/extension-code-block-lowlight": "^3.22.3", "@tiptap/extension-link": "^3.20.0", "@tiptap/extension-mention": "^3.20.0", "@tiptap/markdown": "^3.20.0", @@ -36,6 +37,7 @@ "clsx": "^2.1.1", "emoji-picker-react": "^4.18.0", "highlight.js": "^11.11.1", + "lowlight": "^3.3.0", "lucide-react": "^0.563.0", "motion": "^12.34.0", "next-themes": "^0.4.6", diff --git a/apps/web/src/assets/fonts/LoraVF.woff2 b/apps/web/src/assets/fonts/LoraVF.woff2 new file mode 100644 index 0000000..536efc5 Binary files /dev/null and b/apps/web/src/assets/fonts/LoraVF.woff2 differ diff --git a/apps/web/src/components/allies/allies-page.tsx b/apps/web/src/components/allies/allies-page.tsx deleted file mode 100644 index 33170d1..0000000 --- a/apps/web/src/components/allies/allies-page.tsx +++ /dev/null @@ -1,667 +0,0 @@ -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "@repo/ui/components/alert-dialog" -import { Badge } from "@repo/ui/components/badge" -import { Button } from "@repo/ui/components/button" -import { Input } from "@repo/ui/components/input" -import { ScrollArea } from "@repo/ui/components/scroll-area" -import { Skeleton } from "@repo/ui/components/skeleton" -import { useIsMobile } from "@repo/ui/hooks/use-mobile" -import { cn } from "@repo/ui/lib/utils" -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" -import { - Check, - Menu, - MessageCircle, - Search, - ShieldOff, - UserMinus, - UserPlus, - Users, - X, -} from "lucide-react" -import { useState } from "react" -import { toast } from "sonner" -import { UserAvatar } from "@/components/ui/user-avatar" -import { useMobileSidebar } from "@/context/mobile-sidebar-context" -import { useBlockedUsers } from "@/hooks/use-blocked-users" -import { useCreateDM } from "@/hooks/use-create-dm" -import { apiClient } from "@/lib/api-client" -import type { Ally, AllyRequest, BlockedUser } from "@/lib/api-types" - -type Tab = "all" | "pending" | "blocked" - -function AlliesSkeleton() { - return ( -
- {Array.from({ length: 4 }).map((_, i) => ( - // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton -
- -
- - -
-
- ))} -
- ) -} - -function AllyRow({ - ally, - onMessage, - onRemove, - isRemoving, -}: { - ally: Ally - onMessage: (userId: string) => void - onRemove: (userId: string) => void - isRemoving: boolean -}) { - return ( -
- -
-
{ally.name}
- {ally.username && ( -
- @{ally.displayUsername ?? ally.username} -
- )} -
-
- - -
-
- ) -} - -function IncomingRequestRow({ - request, - onAccept, - onDecline, - isPending, -}: { - request: AllyRequest - onAccept: (requestId: string) => void - onDecline: (requestId: string) => void - isPending: boolean -}) { - return ( -
- -
-
- {request.sender.name} -
- {request.sender.username && ( -
- @{request.sender.displayUsername ?? request.sender.username} -
- )} -
-
- - -
-
- ) -} - -function OutgoingRequestRow({ request }: { request: AllyRequest }) { - return ( -
- -
-
- {request.receiver.name} -
- {request.receiver.username && ( -
- @{request.receiver.displayUsername ?? request.receiver.username} -
- )} -
- Pending -
- ) -} - -function BlockedUserRow({ - user, - onUnblock, - isUnblocking, -}: { - user: BlockedUser - onUnblock: (userId: string) => void - isUnblocking: boolean -}) { - return ( -
- -
-
{user.name}
- {user.username && ( -
- @{user.displayUsername ?? user.username} -
- )} -
- -
- ) -} - -export function AlliesPage() { - const queryClient = useQueryClient() - const createDM = useCreateDM() - const isMobile = useIsMobile() - const { setOpen: openMobileSidebar } = useMobileSidebar() - const [tab, setTab] = useState("all") - const [search, setSearch] = useState("") - const [addUsername, setAddUsername] = useState("") - - const { - data: allies, - isPending: alliesLoading, - isError: alliesError, - } = useQuery({ - queryKey: ["allies"], - queryFn: async () => { - const res = await apiClient.v1.allies.$get() - if (!res.ok) throw new Error("Failed to fetch allies") - return res.json() - }, - }) - - const { - data: requests, - isPending: requestsLoading, - isError: requestsError, - } = useQuery({ - queryKey: ["ally-requests"], - queryFn: async () => { - const res = await apiClient.v1.allies.requests.$get() - if (!res.ok) throw new Error("Failed to fetch ally requests") - return res.json() - }, - }) - - const { - data: blockedData, - isPending: blockedLoading, - isError: blockedError, - } = useBlockedUsers() - - const [removingAllyId, setRemovingAllyId] = useState(null) - const [confirmRemoveAlly, setConfirmRemoveAlly] = useState(null) - const [unblockingUserId, setUnblockingUserId] = useState(null) - - const invalidate = (affectedUserId?: string) => { - void queryClient.invalidateQueries({ queryKey: ["allies"] }) - void queryClient.invalidateQueries({ queryKey: ["ally-requests"] }) - if (affectedUserId) { - void queryClient.invalidateQueries({ - queryKey: ["user-profile", affectedUserId], - }) - } - } - - const sendRequest = useMutation({ - mutationFn: async (userId: string) => { - const res = await apiClient.v1.allies.requests.$post({ - json: { userId }, - }) - if (!res.ok) { - const body = await res.json() - throw new Error( - "message" in body ? body.message : "Failed to send ally request" - ) - } - return { data: await res.json(), targetUserId: userId } - }, - onSuccess: ({ targetUserId }) => { - invalidate(targetUserId) - setAddUsername("") - toast.success("Ally request sent") - }, - onError: (error) => { - toast.error(error.message) - }, - }) - - const acceptRequest = useMutation({ - mutationFn: async ({ - requestId, - senderId, - }: { - requestId: string - senderId: string - }) => { - const res = await apiClient.v1.allies.requests[":requestId"].accept.$post( - { - param: { requestId }, - } - ) - if (!res.ok) throw new Error("Failed to accept request") - return { data: await res.json(), senderId } - }, - onSuccess: ({ senderId }) => { - invalidate(senderId) - toast.success("Ally request accepted") - }, - onError: () => { - toast.error("Failed to accept request") - }, - }) - - const declineRequest = useMutation({ - mutationFn: async ({ - requestId, - senderId, - }: { - requestId: string - senderId: string - }) => { - const res = await apiClient.v1.allies.requests[ - ":requestId" - ].decline.$post({ - param: { requestId }, - }) - if (!res.ok) throw new Error("Failed to decline request") - return { senderId } - }, - onSuccess: ({ senderId }) => { - invalidate(senderId) - toast.success("Ally request declined") - }, - onError: () => { - toast.error("Failed to decline request") - }, - }) - - const removeAlly = useMutation({ - mutationFn: async (userId: string) => { - setRemovingAllyId(userId) - const res = await apiClient.v1.allies[":userId"].$delete({ - param: { userId }, - }) - if (!res.ok) throw new Error("Failed to remove ally") - return userId - }, - onSuccess: (userId) => { - setRemovingAllyId(null) - invalidate(userId) - toast.success("Ally removed") - }, - onError: () => { - setRemovingAllyId(null) - toast.error("Failed to remove ally") - }, - }) - - const unblockUser = useMutation({ - mutationFn: async (userId: string) => { - setUnblockingUserId(userId) - const res = await apiClient.v1.blocks[":userId"].$delete({ - param: { userId }, - }) - if (!res.ok) throw new Error("Failed to unblock user") - return userId - }, - onSuccess: (userId) => { - setUnblockingUserId(null) - void queryClient.invalidateQueries({ queryKey: ["blocked-users"] }) - void queryClient.invalidateQueries({ - queryKey: ["user-profile", userId], - }) - toast.success("User unblocked") - }, - onError: () => { - setUnblockingUserId(null) - toast.error("Failed to unblock user") - }, - }) - - const handleSendRequest = (e: React.FormEvent) => { - e.preventDefault() - const trimmed = addUsername.trim() - if (!trimmed) return - // The input is a userId for now — we can enhance to support username lookup later - sendRequest.mutate(trimmed) - } - - const filteredAllies = (allies?.allies ?? []).filter((ally) => - ally.name.toLowerCase().includes(search.toLowerCase()) - ) - - const incomingRequests = requests?.incoming ?? [] - const outgoingRequests = requests?.outgoing ?? [] - const pendingCount = incomingRequests.length + outgoingRequests.length - - return ( -
- {/* Header */} -
- {isMobile && ( - - )} - -

Allies

-
-
- - - -
-
- - {/* Content */} - -
- {tab === "all" && ( - <> - {/* Search */} -
- - setSearch(e.target.value)} - className="pl-9" - /> -
- - {alliesLoading ? ( - - ) : alliesError ? ( -
- Failed to load allies. -
- ) : filteredAllies.length === 0 ? ( -
- {search - ? "No allies match your search." - : "You don't have any allies yet. Send an ally request to get started."} -
- ) : ( -
-
- All Allies - {filteredAllies.length} -
- {filteredAllies.map((ally) => ( - createDM.mutate([userId])} - onRemove={() => setConfirmRemoveAlly(ally)} - isRemoving={removingAllyId === ally.id} - /> - ))} -
- )} - - )} - - {tab === "pending" && ( - <> - {/* Add Ally form */} -
- -

- Enter a user ID to send an ally request. -

-
- setAddUsername(e.target.value)} - className="flex-1" - /> - -
-
- - {requestsLoading ? ( - - ) : requestsError ? ( -
- Failed to load requests. -
- ) : ( - <> - {incomingRequests.length > 0 && ( -
-
- Incoming - {incomingRequests.length} -
- {incomingRequests.map((request) => ( - - acceptRequest.mutate({ - requestId: id, - senderId: request.sender.id, - }) - } - onDecline={(id) => - declineRequest.mutate({ - requestId: id, - senderId: request.sender.id, - }) - } - isPending={ - acceptRequest.isPending || declineRequest.isPending - } - /> - ))} -
- )} - - {outgoingRequests.length > 0 && ( -
-
- Outgoing - {outgoingRequests.length} -
- {outgoingRequests.map((request) => ( - - ))} -
- )} - - {incomingRequests.length === 0 && - outgoingRequests.length === 0 && ( -
- No pending ally requests. -
- )} - - )} - - )} - - {tab === "blocked" && - (blockedLoading ? ( - - ) : blockedError ? ( -
- Failed to load blocked users. -
- ) : (blockedData?.blockedUsers ?? []).length === 0 ? ( -
- You haven't blocked anyone. -
- ) : ( -
-
- Blocked — {blockedData?.blockedUsers.length} -
- {blockedData?.blockedUsers.map((user) => ( - unblockUser.mutate(userId)} - isUnblocking={unblockingUserId === user.id} - /> - ))} -
- ))} -
-
- { - if (!open) setConfirmRemoveAlly(null) - }} - > - - - Remove ally - - Are you sure you want to remove{" "} - - {confirmRemoveAlly?.name} - {" "} - as an ally? - - - - - Cancel - - { - e.preventDefault() - if (!confirmRemoveAlly) return - removeAlly.mutate(confirmRemoveAlly.id, { - onSuccess: () => setConfirmRemoveAlly(null), - }) - }} - > - Remove - - - - -
- ) -} diff --git a/apps/web/src/components/chat/composer/code-block-view.tsx b/apps/web/src/components/chat/composer/code-block-view.tsx new file mode 100644 index 0000000..af49e13 --- /dev/null +++ b/apps/web/src/components/chat/composer/code-block-view.tsx @@ -0,0 +1,75 @@ +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@repo/ui/components/select" +import type { NodeViewProps } from "@tiptap/react" +import { NodeViewContent, NodeViewWrapper } from "@tiptap/react" + +export const CODE_BLOCK_LANGUAGES = [ + { value: "plaintext", label: "Plain Text" }, + { value: "typescript", label: "TypeScript" }, + { value: "javascript", label: "JavaScript" }, + { value: "python", label: "Python" }, + { value: "json", label: "JSON" }, + { value: "bash", label: "Bash" }, + { value: "css", label: "CSS" }, + { value: "html", label: "HTML" }, + { value: "sql", label: "SQL" }, + { value: "rust", label: "Rust" }, + { value: "go", label: "Go" }, + { value: "java", label: "Java" }, +] as const + +export const SUPPORTED_LANGUAGE_VALUES: Set = new Set( + CODE_BLOCK_LANGUAGES.map((l) => l.value) +) + +export const LANGUAGE_ALIAS_MAP: Record = { + ts: "typescript", + tsx: "typescript", + js: "javascript", + jsx: "javascript", + py: "python", + sh: "bash", + zsh: "bash", + shell: "bash", + xml: "html", + yml: "yaml", + rs: "rust", + golang: "go", +} + +export function CodeBlockView({ node, updateAttributes }: NodeViewProps) { + const language = (node.attrs.language as string) || "plaintext" + + return ( + +
+ +
+
+        
+      
+
+ ) +} diff --git a/apps/web/src/components/chat/composer/message-input.tsx b/apps/web/src/components/chat/composer/message-input.tsx index 551573b..ffebd1c 100644 --- a/apps/web/src/components/chat/composer/message-input.tsx +++ b/apps/web/src/components/chat/composer/message-input.tsx @@ -5,6 +5,7 @@ import { PopoverTrigger, } from "@repo/ui/components/popover" import { cn } from "@repo/ui/lib/utils" +import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight" import Link from "@tiptap/extension-link" import Mention, { type MentionOptions } from "@tiptap/extension-mention" import { Markdown } from "@tiptap/markdown" @@ -12,6 +13,7 @@ import { PluginKey } from "@tiptap/pm/state" import { EditorContent, Extension, + ReactNodeViewRenderer, ReactRenderer, useEditor, useEditorState, @@ -23,6 +25,7 @@ import Suggestion, { type SuggestionOptions, type SuggestionProps, } from "@tiptap/suggestion" +import { common, createLowlight } from "lowlight" import { Bold, Code, @@ -46,6 +49,7 @@ import type { Message } from "@/lib/api-types" import { extractMentionIds, toStoredMarkdown } from "@/lib/editor-utils" import type { ChatContext } from "../header" import { AttachmentPreview } from "./attachment-preview" +import { CodeBlockView } from "./code-block-view" import { MentionSuggestionList, type MentionSuggestionListProps, @@ -68,6 +72,7 @@ const POPUP_GAP = 6 export const SUGGESTION_MENU_SELECTOR = "[data-suggestion-open='true'], [data-mention-suggestion-open='true'], [data-slash-suggestion-open='true'], [data-slash-command-open='true']" const SLASH_COMMAND_PLUGIN_KEY = new PluginKey("slash-command") +const lowlight = createLowlight(common) const DEFAULT_CODE_BLOCK_LANGUAGE = "plaintext" const CODE_BLOCK_LANGUAGE_OPTIONS = [ { value: "plaintext", label: "Plain Text" }, @@ -254,7 +259,7 @@ export function createMentionSuggestion( } } -function _createSlashCommandSuggestion(): Omit< +function createSlashCommandSuggestion(): Omit< SuggestionOptions, "editor" > { @@ -307,7 +312,7 @@ function _createSlashCommandSuggestion(): Omit< } } -function _createSlashCommandExtension( +function createSlashCommandExtension( suggestion: Omit< SuggestionOptions, "editor" @@ -461,15 +466,14 @@ export function MessageInput({ () => createMentionSuggestion(() => mentionCandidatesRef.current), [] ) - // Slash commands temporarily disabled. - // const slashCommandSuggestion = useMemo( - // () => createSlashCommandSuggestion(), - // [] - // ) - // const slashCommandExtension = useMemo( - // () => createSlashCommandExtension(slashCommandSuggestion), - // [slashCommandSuggestion] - // ) + const slashCommandSuggestion = useMemo( + () => createSlashCommandSuggestion(), + [] + ) + const slashCommandExtension = useMemo( + () => createSlashCommandExtension(slashCommandSuggestion), + [slashCommandSuggestion] + ) const editor = useEditor( { @@ -478,6 +482,15 @@ export function MessageInput({ heading: false, blockquote: false, horizontalRule: false, + codeBlock: false, + }), + CodeBlockLowlight.extend({ + addNodeView() { + return ReactNodeViewRenderer(CodeBlockView) + }, + }).configure({ + lowlight, + defaultLanguage: "plaintext", }), Markdown, Link.configure({ @@ -499,7 +512,7 @@ export function MessageInput({ `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`, suggestion: mentionSuggestion, }), - // slashCommandExtension, + slashCommandExtension, ], editorProps: { attributes: { @@ -812,63 +825,6 @@ export function MessageInput({ {placeholder} )} - {editor && ( - document.body} - shouldShow={({ editor: tiptapEditor, element }) => { - const activeElement = - typeof document !== "undefined" - ? document.activeElement - : null - - return ( - tiptapEditor.isEditable && - (tiptapEditor.isActive("codeBlock") || - (activeElement ? element.contains(activeElement) : false)) - ) - }} - getReferencedVirtualElement={() => { - const rect = getActiveCodeBlockRect(editor) - if (!rect) return null - - return { - getBoundingClientRect: () => rect, - } - }} - options={{ - strategy: "fixed", - placement: "bottom-start", - offset: 0, - flip: true, - shift: true, - }} - className="z-50 rounded-md border border-border/70 bg-background/95 p-1 shadow-sm backdrop-blur" - > -
- - Lang - - -
-
- )} {editor && ( )} {context.type === "channel" && ( - + )} {context.type === "dm" && ( diff --git a/apps/web/src/components/chat/message-list.tsx b/apps/web/src/components/chat/message-list.tsx index 6e3d0a8..8025c1f 100644 --- a/apps/web/src/components/chat/message-list.tsx +++ b/apps/web/src/components/chat/message-list.tsx @@ -1,7 +1,7 @@ import { Skeleton } from "@repo/ui/components/skeleton" import { cn } from "@repo/ui/lib/utils" import { differenceInMinutes, isSameDay } from "@repo/utils/date" -import { Hash, Loader2, User, Users } from "lucide-react" +import { Loader2, ScrollText } from "lucide-react" import { useCallback, useEffect, useRef, useState } from "react" import type { Message } from "@/lib/api-types" import type { MentionCandidate } from "./composer/mention-types" @@ -29,28 +29,20 @@ interface MessageListProps { function EmptyState({ context }: { context: ChatContext }) { return ( -
-
- {context.type === "channel" && ( - - )} - {context.type === "dm" && ( - - )} - {context.type === "group_dm" && ( - - )} +
+
+ +
+

+ {context.type === "channel" ? context.name : context.name} +

+

+ {context.type === "channel" + ? "The scroll is blank. Write the first entry." + : "Send a raven to begin."} +

+
-

- {context.type === "channel" - ? `Welcome to #${context.name}!` - : `This is the beginning of your conversation with ${context.name}`} -

-

- {context.type === "channel" - ? "This is the start of the channel." - : "Send a message to get started."} -

) } diff --git a/apps/web/src/components/settings/privacy-safety-settings.tsx b/apps/web/src/components/settings/privacy-safety-settings.tsx deleted file mode 100644 index b8e3fab..0000000 --- a/apps/web/src/components/settings/privacy-safety-settings.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { Label } from "@repo/ui/components/label" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@repo/ui/components/select" -import { Separator } from "@repo/ui/components/separator" -import { Loader2 } from "lucide-react" -import { toast } from "sonner" -import { - type PrivacySettings, - usePrivacySettings, - useUpdatePrivacySettings, -} from "@/hooks/use-privacy-settings" - -const DM_PRIVACY_OPTIONS = [ - { value: "everyone", label: "Everyone" }, - { value: "allies_only", label: "Allies Only" }, - { value: "no_one", label: "No One" }, -] as const - -const ALLY_REQUEST_OPTIONS = [ - { value: "everyone", label: "Everyone" }, - { value: "no_one", label: "No One" }, -] as const - -const ONLINE_STATUS_OPTIONS = [ - { value: "everyone", label: "Everyone" }, - { value: "allies_only", label: "Allies Only" }, - { value: "no_one", label: "No One" }, -] as const - -export function PrivacySafetySettings() { - const { data: settings, isPending } = usePrivacySettings() - const { mutate: updateSettings } = useUpdatePrivacySettings() - - const handleChange = (key: keyof PrivacySettings, value: string) => { - updateSettings( - { [key]: value }, - { - onError: () => { - toast.error("Failed to update privacy setting") - }, - } - ) - } - - if (isPending) { - return ( -
- -
- ) - } - - return ( -
-
-

Privacy & Safety

-

- Control who can contact you and see your activity. -

-
- - - -
-
- -

- Controls who can start a new DM conversation with you. -

- -
- -
- -

- Controls who can send you ally requests. -

- -
- -
- -

- Controls who can see when you are online in guilds. -

- -
-
-
- ) -} diff --git a/apps/web/src/components/settings/settings-dialog.tsx b/apps/web/src/components/settings/settings-dialog.tsx index 8c1ff0a..efc6b69 100644 --- a/apps/web/src/components/settings/settings-dialog.tsx +++ b/apps/web/src/components/settings/settings-dialog.tsx @@ -32,14 +32,12 @@ import { Paintbrush, Search, Settings, - Shield, User, } from "lucide-react" import { useMemo, useState } from "react" import { useSettings } from "@/context/settings-context" import { MyAccountSettings } from "./my-account-settings" import { NotificationSettings } from "./notification-settings" -import { PrivacySafetySettings } from "./privacy-safety-settings" interface SettingsNav { name: string @@ -53,7 +51,6 @@ const settingsNav: SettingsNav[] = [ { name: "Messages & Media", icon: MessageCircle }, { name: "Language & Region", icon: Globe }, { name: "Accessibility", icon: Keyboard }, - { name: "Privacy & Safety", icon: Shield }, { name: "Advanced", icon: Settings }, ] @@ -129,8 +126,6 @@ export function SettingsDialog() { ) : activeItem === "Notifications" ? ( - ) : activeItem === "Privacy & Safety" ? ( - ) : (
{activeItem} settings coming soon. diff --git a/apps/web/src/components/sidebar/channel-panel/channel-list.tsx b/apps/web/src/components/sidebar/channel-panel/channel-list.tsx index caa919f..a845050 100644 --- a/apps/web/src/components/sidebar/channel-panel/channel-list.tsx +++ b/apps/web/src/components/sidebar/channel-panel/channel-list.tsx @@ -32,11 +32,11 @@ import { useNavigate, useParams } from "@tanstack/react-router" import { ChevronDown, FolderPlus, - Hash, Megaphone, MessageSquare, MoreHorizontal, Plus, + Scroll, Volume2, } from "lucide-react" import { AnimatePresence, motion } from "motion/react" @@ -55,7 +55,7 @@ import { DeleteChannelDialog } from "./delete-channel-dialog" import { EditChannelDialog } from "./edit-channel-dialog" const channelIcons = { - text: Hash, + text: Scroll, voice: Volume2, announcement: Megaphone, forum: MessageSquare, @@ -64,7 +64,7 @@ const channelIcons = { type ChannelData = ListChannelsResponse function ChannelIcon({ type }: { type: string }) { - const Icon = channelIcons[type as keyof typeof channelIcons] ?? Hash + const Icon = channelIcons[type as keyof typeof channelIcons] ?? Scroll return } diff --git a/apps/web/src/components/sidebar/channel-panel/create-channel-dialog.tsx b/apps/web/src/components/sidebar/channel-panel/create-channel-dialog.tsx index 08b9e52..3111a3e 100644 --- a/apps/web/src/components/sidebar/channel-panel/create-channel-dialog.tsx +++ b/apps/web/src/components/sidebar/channel-panel/create-channel-dialog.tsx @@ -1,4 +1,5 @@ import { Button } from "@repo/ui/components/button" +import { CustomSelectItem } from "@repo/ui/components/custom-select-item" import { Dialog, DialogContent, @@ -11,19 +12,29 @@ import { Label } from "@repo/ui/components/label" import { Select, SelectContent, - SelectItem, SelectTrigger, SelectValue, } from "@repo/ui/components/select" import { useQueryClient } from "@tanstack/react-query" import { useNavigate, useParams } from "@tanstack/react-router" -import { Hash, Loader2, Megaphone } from "lucide-react" +import { Loader2, Megaphone, Scroll } from "lucide-react" import { useState } from "react" import { apiClient } from "@/lib/api-client" const channelTypes = [ - { value: "text", label: "Text Channel", icon: Hash }, - { value: "announcement", label: "Decree", icon: Megaphone }, + { + value: "text", + label: "Scroll", + icon: Scroll, + description: "A text channel for general conversation and discussion", + }, + { + value: "announcement", + label: "Decree", + icon: Megaphone, + description: + "A read-only channel for important announcements. Only admins and wardens can post", + }, ] as const export function CreateChannelDialog({ @@ -139,12 +150,17 @@ export function CreateChannelDialog({ {channelTypes.map((ct) => ( - +
{ct.label}
-
+ ))}
diff --git a/apps/web/src/components/sidebar/dm-panel/dm-panel.tsx b/apps/web/src/components/sidebar/dm-panel/dm-panel.tsx index 07b6cb4..bf773db 100644 --- a/apps/web/src/components/sidebar/dm-panel/dm-panel.tsx +++ b/apps/web/src/components/sidebar/dm-panel/dm-panel.tsx @@ -1,43 +1,17 @@ import { ScrollArea } from "@repo/ui/components/scroll-area" -import { Separator } from "@repo/ui/components/separator" -import { cn } from "@repo/ui/lib/utils" -import { useNavigate, useParams } from "@tanstack/react-router" -import { Plus, Users } from "lucide-react" +import { Plus } from "lucide-react" import { useState } from "react" -import { useMobileSidebar } from "@/context/mobile-sidebar-context" import { SearchBar } from "../channel-panel/search-bar" import { UserBar } from "../channel-panel/user-bar" import { DMList } from "./dm-list" import { NewDMDialog } from "./new-dm-dialog" export function DMPanel() { - const navigate = useNavigate() - const { dmId } = useParams({ strict: false }) - const { setOpen: closeMobileSidebar } = useMobileSidebar() const [newDMOpen, setNewDMOpen] = useState(false) return (
-
- -
-
Direct Messages diff --git a/apps/web/src/components/sidebar/dm-panel/new-dm-dialog.tsx b/apps/web/src/components/sidebar/dm-panel/new-dm-dialog.tsx index 8c72f54..6e99d7c 100644 --- a/apps/web/src/components/sidebar/dm-panel/new-dm-dialog.tsx +++ b/apps/web/src/components/sidebar/dm-panel/new-dm-dialog.tsx @@ -1,23 +1,10 @@ -import { Button } from "@repo/ui/components/button" import { Dialog, DialogContent, DialogDescription, - DialogFooter, DialogHeader, DialogTitle, } from "@repo/ui/components/dialog" -import { Input } from "@repo/ui/components/input" -import { ScrollArea } from "@repo/ui/components/scroll-area" -import { cn } from "@repo/ui/lib/utils" -import { useQuery } from "@tanstack/react-query" -import { Check, Search } from "lucide-react" -import { useState } from "react" -import { UserAvatar } from "@/components/ui/user-avatar" -import { useBlockedUserIds } from "@/hooks/use-blocked-users" -import { useCreateDM } from "@/hooks/use-create-dm" -import { apiClient } from "@/lib/api-client" -import type { Ally } from "@/lib/api-types" export function NewDMDialog({ open, @@ -26,166 +13,16 @@ export function NewDMDialog({ open: boolean onOpenChange: (open: boolean) => void }) { - const [search, setSearch] = useState("") - const [selectedIds, setSelectedIds] = useState>(new Set()) - const createDM = useCreateDM() - const blockedUserIds = useBlockedUserIds() - - const { - data: allies, - isPending, - isError, - } = useQuery({ - queryKey: ["allies"], - queryFn: async () => { - const res = await apiClient.v1.allies.$get() - if (!res.ok) throw new Error("Failed to fetch allies") - return res.json() - }, - enabled: open, - }) - - const filteredAllies = (allies?.allies ?? []).filter( - (ally) => - ally.name.toLowerCase().includes(search.toLowerCase()) && - !blockedUserIds.has(ally.id) - ) - - const toggleAlly = (id: string) => { - setSelectedIds((prev) => { - const next = new Set(prev) - if (next.has(id)) { - next.delete(id) - } else { - next.add(id) - } - return next - }) - } - - const handleCreate = () => { - if (selectedIds.size === 0) return - createDM.mutate([...selectedIds], { - onSuccess: () => { - onOpenChange(false) - setSelectedIds(new Set()) - setSearch("") - }, - }) - } - - const handleOpenChange = (nextOpen: boolean) => { - if (!nextOpen) { - setSelectedIds(new Set()) - setSearch("") - } - onOpenChange(nextOpen) - } - return ( - + New Direct Message - Select allies to start a conversation with. + Open a member's profile to start a direct message with them. - -
- - setSearch(e.target.value)} - className="pl-9" - /> -
- - {selectedIds.size > 0 && ( -
- {selectedIds.size} selected - {selectedIds.size > 1 ? " — this will create a group DM" : ""} -
- )} - - - {isPending ? ( -
- Loading allies... -
- ) : isError ? ( -
- Failed to load allies. -
- ) : filteredAllies.length === 0 ? ( -
- {search - ? "No allies match your search." - : "You don't have any allies yet."} -
- ) : ( -
- {filteredAllies.map((ally) => ( - toggleAlly(ally.id)} - /> - ))} -
- )} -
- - - -
) } - -function AllySelectRow({ - ally, - selected, - onToggle, -}: { - ally: Ally - selected: boolean - onToggle: () => void -}) { - return ( - - ) -} diff --git a/apps/web/src/components/ui/user-profile-card.tsx b/apps/web/src/components/ui/user-profile-card.tsx index 5649fcc..7675f11 100644 --- a/apps/web/src/components/ui/user-profile-card.tsx +++ b/apps/web/src/components/ui/user-profile-card.tsx @@ -1,14 +1,4 @@ import { authClient } from "@repo/auth/client" -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "@repo/ui/components/alert-dialog" import { Badge } from "@repo/ui/components/badge" import { Button } from "@repo/ui/components/button" import { @@ -24,19 +14,10 @@ import { } from "@repo/ui/components/tooltip" import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" import { useNavigate } from "@tanstack/react-router" -import { - Ban, - Check, - Clock, - MessageCircle, - ShieldOff, - UserMinus, - UserPlus, -} from "lucide-react" +import { MessageCircle } from "lucide-react" import { useState } from "react" import { toast } from "sonner" import { apiClient } from "@/lib/api-client" -import type { UserProfile } from "@/lib/api-types" import { UserAvatar } from "./user-avatar" function ProfileCardContent({ userId }: { userId: string }) { @@ -54,114 +35,6 @@ function ProfileCardContent({ userId }: { userId: string }) { }, }) - const sendRequest = useMutation({ - mutationFn: async () => { - const res = await apiClient.v1.allies.requests.$post({ - json: { userId }, - }) - if (!res.ok) { - const body = await res.json() - throw new Error( - "message" in body ? body.message : "Failed to send ally request" - ) - } - return res.json() - }, - onSuccess: () => { - void queryClient.invalidateQueries({ - queryKey: ["user-profile", userId], - }) - void queryClient.invalidateQueries({ queryKey: ["ally-requests"] }) - toast.success("Ally request sent") - }, - onError: (error) => { - toast.error(error.message) - }, - }) - - const acceptRequest = useMutation({ - mutationFn: async (requestId: string) => { - const res = await apiClient.v1.allies.requests[":requestId"].accept.$post( - { - param: { requestId }, - } - ) - if (!res.ok) throw new Error("Failed to accept request") - return res.json() - }, - onSuccess: () => { - void queryClient.invalidateQueries({ - queryKey: ["user-profile", userId], - }) - void queryClient.invalidateQueries({ queryKey: ["allies"] }) - void queryClient.invalidateQueries({ queryKey: ["ally-requests"] }) - toast.success("Ally request accepted") - }, - onError: () => { - toast.error("Failed to accept request") - }, - }) - - const removeAlly = useMutation({ - mutationFn: async () => { - const res = await apiClient.v1.allies[":userId"].$delete({ - param: { userId }, - }) - if (!res.ok) throw new Error("Failed to remove ally") - }, - onSuccess: () => { - void queryClient.invalidateQueries({ - queryKey: ["user-profile", userId], - }) - void queryClient.invalidateQueries({ queryKey: ["allies"] }) - toast.success("Ally removed") - }, - onError: () => { - toast.error("Failed to remove ally") - }, - }) - - const blockUser = useMutation({ - mutationFn: async () => { - const res = await apiClient.v1.blocks.$post({ - json: { userId }, - }) - if (!res.ok) throw new Error("Failed to block user") - }, - onSuccess: () => { - void queryClient.invalidateQueries({ - queryKey: ["user-profile", userId], - }) - void queryClient.invalidateQueries({ queryKey: ["allies"] }) - void queryClient.invalidateQueries({ queryKey: ["ally-requests"] }) - void queryClient.invalidateQueries({ queryKey: ["blocked-users"] }) - void queryClient.invalidateQueries({ queryKey: ["dms"] }) - toast.success("User blocked") - }, - onError: () => { - toast.error("Failed to block user") - }, - }) - - const unblockUser = useMutation({ - mutationFn: async () => { - const res = await apiClient.v1.blocks[":userId"].$delete({ - param: { userId }, - }) - if (!res.ok) throw new Error("Failed to unblock user") - }, - onSuccess: () => { - void queryClient.invalidateQueries({ - queryKey: ["user-profile", userId], - }) - void queryClient.invalidateQueries({ queryKey: ["blocked-users"] }) - toast.success("User unblocked") - }, - onError: () => { - toast.error("Failed to unblock user") - }, - }) - const navigate = useNavigate() const createDM = useMutation({ @@ -186,9 +59,6 @@ function ProfileCardContent({ userId }: { userId: string }) { }, }) - const [confirmBlock, setConfirmBlock] = useState(false) - const [confirmRemoveAlly, setConfirmRemoveAlly] = useState(false) - if (isPending) { return (
@@ -214,18 +84,7 @@ function ProfileCardContent({ userId }: { userId: string }) { const user = data.user const isCurrentUser = session?.user?.id === userId - const isBlockedByMe = - user.blockStatus === "blocked_by_me" || user.blockStatus === "mutual_block" - const isBlockedByThem = - user.blockStatus === "blocked_by_them" || - user.blockStatus === "mutual_block" - const isMutating = - sendRequest.isPending || - acceptRequest.isPending || - removeAlly.isPending || - blockUser.isPending || - unblockUser.isPending || - createDM.isPending + const isMutating = createDM.isPending return (
@@ -260,12 +119,12 @@ function ProfileCardContent({ userId }: { userId: string }) {
{/* Status */} - {user.status && !isBlockedByThem && ( + {user.status && (
{user.status}
)} {/* Bio */} - {user.bio && !isBlockedByThem && ( + {user.bio && (
{user.bio}
@@ -282,233 +141,30 @@ function ProfileCardContent({ userId }: { userId: string }) { {/* Actions row */} {!isCurrentUser && ( - <> -
- {/* Send DM */} - {!isBlockedByMe && !isBlockedByThem && ( -
- - - - - Send DM - -
- )} - - {/* Ally action */} - {!isBlockedByMe && !isBlockedByThem && ( -
- sendRequest.mutate()} - onAcceptRequest={(id) => acceptRequest.mutate(id)} - onRemoveAlly={() => setConfirmRemoveAlly(true)} - /> -
- )} - - {/* Block / Unblock */} -
- {isBlockedByMe ? ( - - - - - Unblock - - ) : ( - - - - - Block - - )} -
-
- - - - - Block {user.name}? - - They won't be able to send you ally requests or direct - messages. Any existing ally relationship will be removed. - - - - - Cancel - - { - e.preventDefault() - blockUser.mutate(undefined, { - onSuccess: () => setConfirmBlock(false), - }) - }} +
+ {/* Send DM */} +
+ + + + + Send DM + +
+
)}
) } -function AllyActionIconButton({ - allyStatus, - allyRequestId, - isMutating, - onSendRequest, - onAcceptRequest, - onRemoveAlly, -}: { - allyStatus: UserProfile["allyStatus"] - allyRequestId: string | null - isMutating: boolean - onSendRequest: () => void - onAcceptRequest: (requestId: string) => void - onRemoveAlly: () => void -}) { - switch (allyStatus) { - case "none": - return ( - - - - - Send Ally Request - - ) - case "pending_outgoing": - return ( - - - - - Ally Request Sent - - ) - case "pending_incoming": - return ( - - - - - Accept Ally Request - - ) - case "allies": - return ( - - - - - Remove Ally - - ) - } -} - export function UserProfilePopover({ userId, children, diff --git a/apps/web/src/hooks/use-blocked-users.ts b/apps/web/src/hooks/use-blocked-users.ts deleted file mode 100644 index 6c9c549..0000000 --- a/apps/web/src/hooks/use-blocked-users.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { useQuery } from "@tanstack/react-query" -import { useMemo } from "react" -import { apiClient } from "@/lib/api-client" - -export function useBlockedUsers() { - return useQuery({ - queryKey: ["blocked-users"], - queryFn: async () => { - const res = await apiClient.v1.blocks.$get() - if (!res.ok) throw new Error("Failed to fetch blocked users") - return res.json() - }, - }) -} - -export function useBlockedUserIds() { - const { data } = useBlockedUsers() - return useMemo( - () => new Set(data?.blockedUsers.map((u) => u.id) ?? []), - [data] - ) -} diff --git a/apps/web/src/hooks/use-privacy-settings.ts b/apps/web/src/hooks/use-privacy-settings.ts deleted file mode 100644 index 32a9c3f..0000000 --- a/apps/web/src/hooks/use-privacy-settings.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" -import { apiClient } from "@/lib/api-client" - -export type PrivacySettings = { - dmPrivacy: "everyone" | "allies_only" | "no_one" - allyRequestPrivacy: "everyone" | "no_one" - onlineStatusPrivacy: "everyone" | "allies_only" | "no_one" -} - -const PRIVACY_SETTINGS_KEY = ["privacy-settings"] - -export function usePrivacySettings() { - return useQuery({ - queryKey: PRIVACY_SETTINGS_KEY, - queryFn: async () => { - const res = await apiClient.v1["privacy-settings"].$get() - if (!res.ok) throw new Error("Failed to fetch privacy settings") - return res.json() as Promise - }, - }) -} - -export function useUpdatePrivacySettings() { - const queryClient = useQueryClient() - - return useMutation({ - mutationFn: async (settings: Partial) => { - const res = await apiClient.v1["privacy-settings"].$patch({ - json: settings, - }) - if (!res.ok) throw new Error("Failed to update privacy settings") - return res.json() as Promise - }, - onSuccess: (data) => { - queryClient.setQueryData(PRIVACY_SETTINGS_KEY, data) - }, - }) -} diff --git a/apps/web/src/lib/api-types.ts b/apps/web/src/lib/api-types.ts index bf93158..53ed969 100644 --- a/apps/web/src/lib/api-types.ts +++ b/apps/web/src/lib/api-types.ts @@ -64,31 +64,6 @@ export type InvitePreviewResponse = InferResponseType< 200 > -// ── Allies ────────────────────────────────────────── - -type AlliesClient = Client["v1"]["allies"] - -export type ListAlliesResponse = InferResponseType -export type Ally = ListAlliesResponse["allies"][number] - -type AllyRequestsClient = Client["v1"]["allies"]["requests"] - -export type ListAllyRequestsResponse = InferResponseType< - AllyRequestsClient["$get"], - 200 -> -export type AllyRequest = ListAllyRequestsResponse["incoming"][number] - -// ── Blocks ────────────────────────────────────────── - -type BlocksClient = Client["v1"]["blocks"] - -export type ListBlockedUsersResponse = InferResponseType< - BlocksClient["$get"], - 200 -> -export type BlockedUser = ListBlockedUsersResponse["blockedUsers"][number] - // ── Users ────────────────────────────────────────── type UserProfileClient = Client["v1"]["users"][":userId"] diff --git a/apps/web/src/routes/_authenticated/$guildSlug/$channelId.tsx b/apps/web/src/routes/_authenticated/$guildSlug/$channelId.tsx index 5b56800..309e0af 100644 --- a/apps/web/src/routes/_authenticated/$guildSlug/$channelId.tsx +++ b/apps/web/src/routes/_authenticated/$guildSlug/$channelId.tsx @@ -22,7 +22,6 @@ import { TypingIndicator } from "@/components/chat/typing-indicator" import { useRightSidebar } from "@/components/sidebar/right-panel/right-sidebar-context" import { useSocket } from "@/context/socket-context" import { useAutoMarkRead } from "@/hooks/use-auto-mark-read" -import { useBlockedUserIds } from "@/hooks/use-blocked-users" import { useFileUpload } from "@/hooks/use-file-upload" import { useMessageDeletion } from "@/hooks/use-message-deletion" import { useMessageEditing } from "@/hooks/use-message-editing" @@ -57,7 +56,6 @@ function ChannelView() { useRightSidebar() const { data: session } = authClient.useSession() const currentUserId = session?.user.id - const blockedUserIds = useBlockedUserIds() useEffect(() => { if (!guildSlug || !channelId) return @@ -229,7 +227,6 @@ function ChannelView() { socket, channelId, currentUserId, - blockedUserIds, }) // Clear reply state when switching channels @@ -321,7 +318,6 @@ function ChannelView() { onLoadMore={() => fetchNextPage()} isFetchingMore={isFetchingNextPage} currentUserId={currentUserId} - blockedUserIds={blockedUserIds} onReact={handleReact} onReply={setReplyingTo} onDelete={handleDelete} diff --git a/apps/web/src/routes/_authenticated/dms/$dmId.tsx b/apps/web/src/routes/_authenticated/dms/$dmId.tsx index dbbc13d..4e0c0a1 100644 --- a/apps/web/src/routes/_authenticated/dms/$dmId.tsx +++ b/apps/web/src/routes/_authenticated/dms/$dmId.tsx @@ -15,7 +15,6 @@ import { MessageList, scrollToMessage } from "@/components/chat/message-list" import { TypingIndicator } from "@/components/chat/typing-indicator" import { useSocket } from "@/context/socket-context" import { useAutoMarkRead } from "@/hooks/use-auto-mark-read" -import { useBlockedUserIds } from "@/hooks/use-blocked-users" import { useFileUpload } from "@/hooks/use-file-upload" import { useMessageDeletion } from "@/hooks/use-message-deletion" import { useMessageEditing } from "@/hooks/use-message-editing" @@ -45,7 +44,6 @@ function DMConversation() { const queryClient = useQueryClient() const { data: session } = authClient.useSession() const currentUserId = session?.user.id - const blockedUserIds = useBlockedUserIds() const { data: dm, isPending } = useQuery({ queryKey: ["dms", dmId], @@ -137,7 +135,6 @@ function DMConversation() { socket, channelId: dmId, currentUserId, - blockedUserIds, }) // Clear reply state when switching DMs @@ -195,13 +192,6 @@ function DMConversation() { avatarUrl: dm.members[0]?.image ?? undefined, } - // For 1:1 DMs, check if the other user is blocked - const isDirect = dm.type === "dm" - const otherMemberId = isDirect ? dm.members[0]?.id : undefined - const isOtherBlocked = otherMemberId - ? blockedUserIds.has(otherMemberId) - : false - const mentionCandidates = dm.members.map((member) => ({ id: member.id, label: member.displayUsername ?? member.username ?? member.name, @@ -228,7 +218,6 @@ function DMConversation() { onLoadMore={() => fetchNextPage()} isFetchingMore={isFetchingNextPage} currentUserId={currentUserId} - blockedUserIds={blockedUserIds} onReact={handleReact} onReply={setReplyingTo} onDelete={handleDelete} @@ -237,27 +226,21 @@ function DMConversation() { isLoading={messagesLoading} /> - {isOtherBlocked ? ( -
- You have blocked this user. Unblock them to send messages. -
- ) : ( - - )} +
) } diff --git a/apps/web/src/routes/_authenticated/dms/index.tsx b/apps/web/src/routes/_authenticated/dms/index.tsx index e03aa3f..31683da 100644 --- a/apps/web/src/routes/_authenticated/dms/index.tsx +++ b/apps/web/src/routes/_authenticated/dms/index.tsx @@ -1,6 +1,13 @@ import { createFileRoute } from "@tanstack/react-router" -import { AlliesPage } from "@/components/allies/allies-page" export const Route = createFileRoute("/_authenticated/dms/")({ - component: AlliesPage, + component: DMsIndex, }) + +function DMsIndex() { + return ( +
+ Select a conversation to get started +
+ ) +} diff --git a/apps/web/src/styles/fonts.css b/apps/web/src/styles/fonts.css index ea4db11..73e4734 100644 --- a/apps/web/src/styles/fonts.css +++ b/apps/web/src/styles/fonts.css @@ -12,9 +12,18 @@ font-display: swap; } +@font-face { + font-family: "Lora"; + src: url("../assets/fonts/LoraVF.woff2") format("woff2"); + font-weight: 400 700; + font-display: swap; +} + :root { --font-geist-sans: "Geist Sans", ui-sans-serif, system-ui, sans-serif; --font-geist-mono: "Geist Mono", ui-monospace, monospace; + --font-serif: + "Lora", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif; } body { diff --git a/apps/www/README.md b/apps/www/README.md deleted file mode 100644 index a98bfa8..0000000 --- a/apps/www/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load Inter, a custom Google Font. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/apps/www/app/apple-icon.png b/apps/www/app/apple-icon.png deleted file mode 100644 index 0bd31fb..0000000 Binary files a/apps/www/app/apple-icon.png and /dev/null differ diff --git a/apps/www/app/components/copy-terminal.tsx b/apps/www/app/components/copy-terminal.tsx deleted file mode 100644 index ac0fd90..0000000 --- a/apps/www/app/components/copy-terminal.tsx +++ /dev/null @@ -1,64 +0,0 @@ -"use client" - -import { Check, Copy } from "lucide-react" -import { useState } from "react" - -const CLONE_COMMAND = "git clone https://github.com/BuckyMcYolo/townhall" - -export function CopyTerminal() { - const [copied, setCopied] = useState(false) - - const handleCopy = () => { - navigator.clipboard.writeText(CLONE_COMMAND) - setCopied(true) - setTimeout(() => setCopied(false), 2000) - } - - return ( -
-
-
-
-
- - zsh - -
-
- {/* Copyable command line */} -
e.key === "Enter" && handleCopy()} - className="group -mx-3 flex cursor-pointer items-center rounded-md px-3 py-1 transition-colors hover:bg-foreground/[0.06]" - > -
- ~ - $ - {CLONE_COMMAND} -
- - {copied ? ( - - ) : ( - - )} - -
- -
- Cloning into 'townhall'... -
-
- remote: Enumerating objects: done. -
-
- ~/townhall - $ - -
-
-
- ) -} diff --git a/apps/www/app/components/grain.tsx b/apps/www/app/components/grain.tsx new file mode 100644 index 0000000..411e4ec --- /dev/null +++ b/apps/www/app/components/grain.tsx @@ -0,0 +1,13 @@ +export function Grain() { + return ( +
+ ) +} diff --git a/apps/www/app/components/reveal.tsx b/apps/www/app/components/reveal.tsx new file mode 100644 index 0000000..5e227f8 --- /dev/null +++ b/apps/www/app/components/reveal.tsx @@ -0,0 +1,53 @@ +"use client" + +import { type ReactNode, useEffect, useRef, useState } from "react" + +export function Reveal({ + children, + className = "", + delay = 0, +}: { + children: ReactNode + className?: string + delay?: number +}) { + const ref = useRef(null) + const [shown, setShown] = useState(false) + + useEffect(() => { + const el = ref.current + if (!el) return + if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { + setShown(true) + return + } + const io = new IntersectionObserver( + (entries) => { + for (const e of entries) { + if (e.isIntersecting) { + setShown(true) + io.disconnect() + break + } + } + }, + { threshold: 0.12, rootMargin: "0px 0px -10% 0px" } + ) + io.observe(el) + return () => io.disconnect() + }, []) + + return ( +
+ {children} +
+ ) +} diff --git a/apps/www/app/components/theme-toggle.tsx b/apps/www/app/components/theme-toggle.tsx deleted file mode 100644 index 73732f4..0000000 --- a/apps/www/app/components/theme-toggle.tsx +++ /dev/null @@ -1,35 +0,0 @@ -"use client" - -import { Moon, Sun } from "lucide-react" -import { useTheme } from "next-themes" -import { useEffect, useState } from "react" - -export function ThemeToggle() { - const { resolvedTheme, setTheme } = useTheme() - const [mounted, setMounted] = useState(false) - - useEffect(() => { - setMounted(true) - }, []) - - if (!mounted) { - return ( -
- ) - } - - return ( - - ) -} diff --git a/apps/www/app/components/waitlist.tsx b/apps/www/app/components/waitlist.tsx new file mode 100644 index 0000000..d52f5fd --- /dev/null +++ b/apps/www/app/components/waitlist.tsx @@ -0,0 +1,90 @@ +"use client" + +import { ArrowRight, Check, Loader2 } from "lucide-react" +import { type FormEvent, useState } from "react" +import { apiClient } from "@/lib/api-client" + +type Status = "idle" | "loading" | "success" | "error" + +export function Waitlist() { + const [email, setEmail] = useState("") + const [status, setStatus] = useState("idle") + const [errorMessage, setErrorMessage] = useState("") + + async function onSubmit(e: FormEvent) { + e.preventDefault() + if (!email || status === "loading" || status === "success") return + setStatus("loading") + setErrorMessage("") + try { + const res = await apiClient.waitlist.$post({ json: { email } }) + if (!res.ok) { + const data = (await res.json().catch(() => null)) as { + error?: string + } | null + setErrorMessage( + typeof data?.error === "string" ? data.error : "Something went wrong." + ) + setStatus("error") + return + } + setStatus("success") + } catch { + setErrorMessage("Couldn't reach the server. Try again in a moment.") + setStatus("error") + } + } + + if (status === "success") { + return ( +
+ + You’re on the list. We’ll be in touch. +
+ ) + } + + return ( +
+
+ setEmail(e.target.value)} + placeholder="you@company.com" + className="min-w-0 flex-1 bg-transparent px-4 py-2 text-[14.5px] text-foreground placeholder:text-foreground/40 focus:outline-none" + aria-label="Email address" + /> + +
+ {status === "error" && errorMessage && ( +

+ {errorMessage} +

+ )} +
+ ) +} diff --git a/apps/www/app/download/page.tsx b/apps/www/app/download/page.tsx index 42c83cf..44a6a42 100644 --- a/apps/www/app/download/page.tsx +++ b/apps/www/app/download/page.tsx @@ -10,18 +10,18 @@ import { import { Separator } from "@repo/ui/components/separator" import { Download, ExternalLink, Github, Globe } from "lucide-react" import type { Metadata } from "next" -import Image from "next/image" import Link from "next/link" export const metadata: Metadata = { - title: "Download Townhall", - description: "Download Townhall for macOS, Windows, or Linux.", + title: "Download Lor", + description: "Download Lor for macOS, Windows, or Linux.", } const VERSION = "0.1.0" -const RELEASES_URL = "https://github.com/BuckyMcYolo/townhall/releases" -const LATEST = - "https://github.com/BuckyMcYolo/townhall/releases/latest/download" +const GITHUB_URL = "https://github.com/BuckyMcYolo/lor" +const RELEASES_URL = `${GITHUB_URL}/releases` +const LATEST = `${GITHUB_URL}/releases/latest/download` +const APP_URL = "https://app.lor.chat" function AppleIcon({ className }: { className?: string }) { return ( @@ -53,7 +53,7 @@ const platforms = [ icon: AppleIcon, subtitle: "Apple Silicon", description: "Download the .dmg installer for macOS 11+", - href: `${LATEST}/Townhall_${VERSION}_aarch64.dmg`, + href: `${LATEST}/Lor_${VERSION}_aarch64.dmg`, note: "Need Intel? Check all releases below.", }, { @@ -61,7 +61,7 @@ const platforms = [ icon: WindowsIcon, subtitle: "Windows 10+", description: "Download the .exe installer for Windows", - href: `${LATEST}/Townhall_${VERSION}_x64-setup.exe`, + href: `${LATEST}/Lor_${VERSION}_x64-setup.exe`, }, { name: "Linux", @@ -77,22 +77,13 @@ export default function DownloadPage() { return (
{/* Navbar */} -
+
@@ -100,11 +91,12 @@ export default function DownloadPage() {
{/* Hero */}
-

- Download Townhall +

+ Download Lor for desktop.

-

- Available for macOS, Windows, and Linux. Free and open source. +

+ Native apps for macOS, Windows, and Linux. Same Lor, in a faster + shell.

@@ -165,39 +157,35 @@ export default function DownloadPage() { - {/* Try in browser */} + {/* Browser alternative */}
-

- Don't want to download? +

+ Don’t want to download?

- Try Townhall instantly in your browser — no installation required. + Use Lor in your browser — no installation required.

{/* Footer */} -