mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1a48647f0 | ||
|
|
a150ec62a2 | ||
|
|
4623bccc5f | ||
|
|
d03c092ec9 | ||
|
|
92ef8fb3f3 | ||
|
|
d0896e6746 |
No files matched your search
@@ -1180,243 +1180,26 @@ import { Link } from 'react-router-dom';
|
|||||||
|
|
||||||
## CRITICAL Design Standards
|
## CRITICAL Design Standards
|
||||||
|
|
||||||
**Every project must look distinctive and professionally designed.** The goal is to create designs that feel bespoke—not like generic hackathon demos or AI-generated templates.
|
- Create breathtaking, immersive designs that feel like bespoke masterpieces, rivaling the polish of Apple, Stripe, or luxury brands
|
||||||
|
|
||||||
- Designs must be production-ready, fully featured, with no placeholders unless explicitly requested, ensuring every element serves a functional and aesthetic purpose
|
- Designs must be production-ready, fully featured, with no placeholders unless explicitly requested, ensuring every element serves a functional and aesthetic purpose
|
||||||
- Avoid generic or templated aesthetics at all costs; every design must have a unique, brand-specific visual signature that feels custom-crafted
|
- Avoid generic or templated aesthetics at all costs; every design must have a unique, brand-specific visual signature that feels custom-crafted
|
||||||
- Headers must be dynamic, immersive, and storytelling-driven, using layered visuals, motion, and symbolic elements to reflect the brand's identity—never use simple "icon and text" combos
|
- Headers must be dynamic, immersive, and storytelling-driven, using layered visuals, motion, and symbolic elements to reflect the brand’s identity—never use simple “icon and text” combos
|
||||||
- Incorporate purposeful, lightweight animations for scroll reveals, micro-interactions (e.g., hover, click, transitions), and section transitions to create a sense of delight and fluidity
|
- Incorporate purposeful, lightweight animations for scroll reveals, micro-interactions (e.g., hover, click, transitions), and section transitions to create a sense of delight and fluidity
|
||||||
|
|
||||||
### Design Foundations
|
|
||||||
|
|
||||||
These principles apply to ALL projects regardless of category. They define what "good design" means.
|
|
||||||
|
|
||||||
#### Nielsen's 10 Usability Heuristics
|
|
||||||
|
|
||||||
1. **Visibility of system status** — Always show loading states, progress indicators, success/error feedback.
|
|
||||||
2. **Match between system and real world** — Use familiar language, not jargon. Follow real-world conventions.
|
|
||||||
3. **User control and freedom** — Provide undo, cancel, back buttons. Let users recover from mistakes.
|
|
||||||
4. **Consistency and standards** — Same actions = same results. Follow platform conventions.
|
|
||||||
5. **Error prevention** — Use confirmations for destructive actions, disable invalid options.
|
|
||||||
6. **Recognition rather than recall** — Show options visibly; use menus, suggestions, recent items.
|
|
||||||
7. **Flexibility and efficiency of use** — Support novices (clear UI) and experts (shortcuts).
|
|
||||||
8. **Aesthetic and minimalist design** — Every element serves a purpose. Remove the rest.
|
|
||||||
9. **Help users recognize, diagnose, and recover from errors** — Plain language errors with solutions.
|
|
||||||
10. **Help and documentation** — Searchable, task-focused, concise. Ideally unnecessary.
|
|
||||||
|
|
||||||
#### Dieter Rams' Principles of Good Design
|
|
||||||
|
|
||||||
- **Good design is innovative** — Don't copy; find new solutions to real problems
|
|
||||||
- **Good design makes a product useful** — Function first; every feature must serve users
|
|
||||||
- **Good design is aesthetic** — Well-executed products are pleasant to use
|
|
||||||
- **Good design makes a product understandable** — The design itself should explain how to use it
|
|
||||||
- **Good design is unobtrusive** — Tools, not decorations; don't impose on users
|
|
||||||
- **Good design is honest** — Don't manipulate, exaggerate capabilities, or deceive users
|
|
||||||
- **Good design is long-lasting** — Avoid trendy gimmicks that age poorly
|
|
||||||
- **Good design is thorough to the last detail** — Nothing is arbitrary; every element considered
|
|
||||||
- **Good design is as little design as possible** — Less is more; concentrate on essentials
|
|
||||||
|
|
||||||
#### Cognitive Principles
|
|
||||||
|
|
||||||
**Gestalt Principles** (how humans perceive visual groups):
|
|
||||||
- **Proximity** — Elements close together are perceived as related. Group related items; separate unrelated ones.
|
|
||||||
- **Similarity** — Elements that look alike are perceived as related. Use consistent styling for similar functions.
|
|
||||||
- **Closure** — People complete incomplete shapes mentally. You don't need to draw every line.
|
|
||||||
- **Continuity** — Eyes follow lines and curves. Use alignment to create visual flow.
|
|
||||||
- **Figure-ground** — People separate foreground from background. Use contrast to make important elements stand out.
|
|
||||||
|
|
||||||
**Key Laws**:
|
|
||||||
- **Hick's Law** — Decision time increases with the number of choices. Limit options; use progressive disclosure.
|
|
||||||
- **Fitts's Law** — Larger, closer targets are easier to click/tap. Make primary actions big and accessible.
|
|
||||||
- **Miller's Law** — Working memory holds ~7 items. Chunk information; don't overwhelm with long lists.
|
|
||||||
|
|
||||||
### Step 1: Identify Project Type
|
|
||||||
|
|
||||||
Before writing any code, classify the project into one of these categories. Each has fundamentally different design requirements:
|
|
||||||
|
|
||||||
#### Category A: Data-Heavy Applications (Dashboards, Admin Panels, Analytics)
|
|
||||||
|
|
||||||
**Characteristics**: Dense information, analytical users, repeated daily use, efficiency over beauty
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Maximize information density while maintaining clarity
|
|
||||||
- Use a strict grid system for scannable layouts
|
|
||||||
- Neutral color palette with strategic accent colors for alerts/status
|
|
||||||
- Monospace or tabular numbers for data alignment
|
|
||||||
- Minimal decorative elements—let the data be the hero
|
|
||||||
|
|
||||||
**Typography**: IBM Plex Sans + IBM Plex Mono, or Inter + JetBrains Mono
|
|
||||||
|
|
||||||
**Layout Signature**: Card-based modules, data tables, sidebar navigation, status indicators
|
|
||||||
|
|
||||||
**Reference Aesthetic**: Bloomberg Terminal, Grafana, Linear, Notion databases
|
|
||||||
|
|
||||||
#### Category B: Consumer Social/Community Apps
|
|
||||||
|
|
||||||
**Characteristics**: Broad audience, engagement-focused, emotional connection, viral potential
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Bold personality through color, motion, and playful elements
|
|
||||||
- Avatar-centric layouts emphasizing human connection
|
|
||||||
- Generous use of micro-interactions and feedback animations
|
|
||||||
- Progressive disclosure to avoid overwhelming new users
|
|
||||||
- Clear visual hierarchy guiding toward key actions (post, react, share)
|
|
||||||
|
|
||||||
**Typography**: Plus Jakarta Sans, DM Sans, or Nunito (friendly, approachable)
|
|
||||||
|
|
||||||
**Layout Signature**: Feed-based layouts, floating action buttons, bottom navigation on mobile, toast notifications, pull-to-refresh patterns
|
|
||||||
|
|
||||||
**Reference Aesthetic**: Twitter/X, Discord, Slack, Instagram
|
|
||||||
|
|
||||||
#### Category C: Marketing/Landing Pages (Small Business, Product Launch, Portfolio)
|
|
||||||
|
|
||||||
**Characteristics**: Conversion-focused, trust-building, one-time decision, storytelling
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Hero-driven narrative with strong value proposition above the fold
|
|
||||||
- Social proof prominently displayed (testimonials, logos, stats)
|
|
||||||
- Clear CTA hierarchy (one primary, limited secondary)
|
|
||||||
- Sections that build a persuasive argument as you scroll
|
|
||||||
- Professional but approachable—inspire confidence
|
|
||||||
|
|
||||||
**Typography**: DM Serif Display + DM Sans, or Fraunces + Manrope (headline impact + readable body)
|
|
||||||
|
|
||||||
**Layout Signature**: Full-width hero sections, alternating content blocks, testimonial carousels, sticky CTA, footer with trust signals
|
|
||||||
|
|
||||||
**Reference Aesthetic**: Stripe, Linear marketing site, Vercel, premium Framer templates
|
|
||||||
|
|
||||||
#### Category D: Content/Editorial (Blogs, News, Documentation)
|
|
||||||
|
|
||||||
**Characteristics**: Reading-focused, long-form content, return visits, content is king
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Typography IS the design—invest heavily in font selection and spacing
|
|
||||||
- Maximum readability: generous line-height (1.6-1.8), optimal line length (60-75 characters)
|
|
||||||
- Minimal UI chrome that disappears while reading
|
|
||||||
- Strong article hierarchy (headline, deck/subtitle, byline, body, pull quotes)
|
|
||||||
- Support for rich content (images, code blocks, embeds)
|
|
||||||
|
|
||||||
**Typography**: Literata + Source Sans Pro, or Lora + Inter (serif headlines enhance editorial feel)
|
|
||||||
|
|
||||||
**Layout Signature**: Single-column content, large typography, pull quotes, reading progress indicator, related content suggestions
|
|
||||||
|
|
||||||
**Reference Aesthetic**: Medium, Substack, The Verge, Stripe Press
|
|
||||||
|
|
||||||
#### Category E: Utility/Productivity Tools
|
|
||||||
|
|
||||||
**Characteristics**: Task-completion focused, power users, efficiency paramount, "learn once, use forever"
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Function dictates form completely—every pixel earns its place
|
|
||||||
- Keyboard-first interactions with visible shortcuts
|
|
||||||
- Dense but organized UI with clear information hierarchy
|
|
||||||
- Consistent patterns that become muscle memory
|
|
||||||
- Speed and responsiveness over visual flourish
|
|
||||||
|
|
||||||
**Typography**: Inter, SF Pro, or Geist (clean, neutral, highly legible at small sizes)
|
|
||||||
|
|
||||||
**Layout Signature**: Command palette, sidebar + main content, keyboard shortcuts, batch operations, contextual toolbars
|
|
||||||
|
|
||||||
**Reference Aesthetic**: VS Code, Figma, Notion, Linear, Raycast
|
|
||||||
|
|
||||||
#### Category F: E-commerce/Marketplace
|
|
||||||
|
|
||||||
**Characteristics**: Product-focused, trust and conversion critical, browsing + buying flows
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Product imagery is hero—high-quality, consistent photography style
|
|
||||||
- Clear pricing and availability, no surprises
|
|
||||||
- Trust signals throughout (reviews, ratings, security badges, return policy)
|
|
||||||
- Frictionless path to purchase
|
|
||||||
- Filtering and search that actually work
|
|
||||||
|
|
||||||
**Typography**: Outfit + Inter, or DM Sans (clean, doesn't compete with products)
|
|
||||||
|
|
||||||
**Layout Signature**: Product grid, image gallery with zoom, sticky add-to-cart, breadcrumb navigation, review sections
|
|
||||||
|
|
||||||
**Reference Aesthetic**: Apple Store, Shopify Dawn theme, SSENSE, minimal e-commerce
|
|
||||||
|
|
||||||
#### Category G: Creative/Portfolio/Experimental
|
|
||||||
|
|
||||||
**Characteristics**: Self-expression, memorable impression, showcasing work, breaking conventions intentionally
|
|
||||||
|
|
||||||
**Design Approach**:
|
|
||||||
- Rules are meant to be broken—but break them purposefully
|
|
||||||
- Let the work shine with minimal competing UI
|
|
||||||
- Surprise through unexpected interactions and transitions
|
|
||||||
- Full-bleed imagery, dramatic typography, bold color choices
|
|
||||||
- Personality over convention
|
|
||||||
|
|
||||||
**Typography**: Space Grotesk, Syne, or Bodoni Moda (distinctive, memorable)
|
|
||||||
|
|
||||||
**Layout Signature**: Case study layouts, hover reveals, unconventional navigation, scroll-triggered animations, full-screen sections
|
|
||||||
|
|
||||||
**Reference Aesthetic**: Awwwards winners, design agency portfolios, experimental web
|
|
||||||
|
|
||||||
#### Hybrid Projects
|
|
||||||
|
|
||||||
Many projects combine elements from multiple categories. When this happens:
|
|
||||||
|
|
||||||
1. **Identify the primary category** based on the core user action (reading? transacting? socializing? analyzing?)
|
|
||||||
2. **Borrow selectively** from secondary categories for specific sections
|
|
||||||
3. **Maintain consistency** — don't mix competing aesthetics (e.g., playful social fonts with dense dashboard layouts)
|
|
||||||
|
|
||||||
**Common hybrids**:
|
|
||||||
- **Finance apps**: Dashboard (data) + Consumer (engagement) — prioritize trust and clarity
|
|
||||||
- **Learning platforms**: Editorial (content) + Utility (tools) — prioritize readability
|
|
||||||
- **Health/Fitness**: Consumer (motivation) + Dashboard (tracking) — balance encouragement with data
|
|
||||||
- **Gaming/Entertainment**: Creative (personality) + Social (community) — prioritize engagement and delight
|
|
||||||
|
|
||||||
### Step 2: Establish Visual Hierarchy
|
|
||||||
|
|
||||||
Every screen must have a clear visual hierarchy. Users should instantly know:
|
|
||||||
1. **What is this page about?** (Primary headline/hero)
|
|
||||||
2. **What are my options?** (Navigation, key actions)
|
|
||||||
3. **What should I do next?** (Primary CTA)
|
|
||||||
4. **What else is here?** (Secondary content)
|
|
||||||
|
|
||||||
**Hierarchy Tools** (use in combination):
|
|
||||||
- **Size**: Larger = more important (headlines 2-3x body size minimum; use 18px+ for body text, 40px+ for headlines)
|
|
||||||
- **Weight**: Bolder = more important (but use sparingly—max 2-3 weights per page)
|
|
||||||
- **Color**: High contrast = more important; muted = secondary
|
|
||||||
- **Position**: Top-left and center draw attention first (F-pattern and Z-pattern reading)
|
|
||||||
- **Whitespace**: More space around an element = more importance
|
|
||||||
- **Depth**: Elevated elements (shadows, gradients, glows, rounded corners ~16px) demand attention
|
|
||||||
|
|
||||||
**Common Hierarchy Mistakes to Avoid**:
|
|
||||||
- ❌ Everything the same size (nothing stands out)
|
|
||||||
- ❌ Too many "primary" buttons (decision paralysis)
|
|
||||||
- ❌ Important actions buried below the fold
|
|
||||||
- ❌ Competing visual weights fighting for attention
|
|
||||||
- ❌ Headers that don't clearly describe the section
|
|
||||||
|
|
||||||
### Design Principles
|
### Design Principles
|
||||||
|
|
||||||
- Achieve Apple-level refinement with meticulous attention to detail, ensuring designs evoke strong emotions (e.g., wonder, inspiration, energy) through color, motion, and composition
|
- Achieve Apple-level refinement with meticulous attention to detail, ensuring designs evoke strong emotions (e.g., wonder, inspiration, energy) through color, motion, and composition
|
||||||
- Deliver fully functional interactive components with intuitive feedback states, ensuring every element has a clear purpose and enhances user engagement
|
- Deliver fully functional interactive components with intuitive feedback states, ensuring every element has a clear purpose and enhances user engagement
|
||||||
- Use custom illustrations, 3D elements, or symbolic visuals instead of generic stock imagery to create a unique brand narrative; stock imagery, when required, must be sourced exclusively from Pexels (NEVER Unsplash) and align with the design's emotional tone
|
- Use custom illustrations, 3D elements, or symbolic visuals instead of generic stock imagery to create a unique brand narrative; stock imagery, when required, must be sourced exclusively from Pexels (NEVER Unsplash) and align with the design’s emotional tone
|
||||||
- Ensure designs feel alive and modern with dynamic elements like gradients, glows, or parallax effects, avoiding static or flat aesthetics
|
- Ensure designs feel alive and modern with dynamic elements like gradients, glows, or parallax effects, avoiding static or flat aesthetics
|
||||||
- Before finalizing, ask: "Would this design make Apple or Stripe designers pause and take notice?" If not, iterate until it does
|
- Before finalizing, ask: "Would this design make Apple or Stripe designers pause and take notice?" If not, iterate until it does
|
||||||
|
|
||||||
### Avoid Generic Design
|
### Avoid Generic Design
|
||||||
|
|
||||||
- No basic layouts (e.g., text-on-left, image-on-right) without significant custom polish, such as dynamic backgrounds, layered visuals, or interactive elements
|
- No basic layouts (e.g., text-on-left, image-on-right) without significant custom polish, such as dynamic backgrounds, layered visuals, or interactive elements
|
||||||
- No simplistic headers; they must be immersive, animated, and reflective of the brand's core identity and mission
|
- No simplistic headers; they must be immersive, animated, and reflective of the brand’s core identity and mission
|
||||||
- No designs that could be mistaken for free templates or overused patterns; every element must feel intentional and tailored
|
- No designs that could be mistaken for free templates or overused patterns; every element must feel intentional and tailored
|
||||||
|
|
||||||
**The "AI Slop" Checklist** — If your design has 3+ of these, redesign:
|
|
||||||
|
|
||||||
- ❌ Purple-to-blue gradient backgrounds
|
|
||||||
- ❌ Generic "flat people" illustrations
|
|
||||||
- ❌ Card grids with identical sizing and spacing
|
|
||||||
- ❌ "Icon + text" headers with no visual interest
|
|
||||||
- ❌ Inter or system fonts with no personality
|
|
||||||
- ❌ Every element centered on the page
|
|
||||||
- ❌ Generic hero with "Welcome to [App Name]"
|
|
||||||
- ❌ Stock OR Generated photos that feel disconnected from content
|
|
||||||
- ❌ Overly rounded corners on everything (eg border-radius-3xl everywhere)
|
|
||||||
- ❌ No visual hierarchy—everything looks equally important
|
|
||||||
|
|
||||||
### Interaction Patterns
|
### Interaction Patterns
|
||||||
|
|
||||||
- Use progressive disclosure for complex forms or content to guide users intuitively and reduce cognitive load
|
- Use progressive disclosure for complex forms or content to guide users intuitively and reduce cognitive load
|
||||||
@@ -1427,7 +1210,7 @@ Every screen must have a clear visual hierarchy. Users should instantly know:
|
|||||||
|
|
||||||
### Technical Requirements
|
### Technical Requirements
|
||||||
|
|
||||||
- Curated color palette (3-5 evocative colors + neutrals) that aligns with the brand's emotional tone and creates a memorable impact
|
- Curated color FRpalette (3-5 evocative colors + neutrals) that aligns with the brand’s emotional tone and creates a memorable impact
|
||||||
- Ensure a minimum 4.5:1 contrast ratio for all text and interactive elements to meet accessibility standards
|
- Ensure a minimum 4.5:1 contrast ratio for all text and interactive elements to meet accessibility standards
|
||||||
- Use expressive, readable fonts (18px+ for body text, 40px+ for headlines) with a clear hierarchy; pair a modern sans-serif (e.g., Inter) with an elegant serif (e.g., Playfair Display) for personality
|
- Use expressive, readable fonts (18px+ for body text, 40px+ for headlines) with a clear hierarchy; pair a modern sans-serif (e.g., Inter) with an elegant serif (e.g., Playfair Display) for personality
|
||||||
- Design for full responsiveness, ensuring flawless performance and aesthetics across all screen sizes (mobile, tablet, desktop)
|
- Design for full responsiveness, ensuring flawless performance and aesthetics across all screen sizes (mobile, tablet, desktop)
|
||||||
@@ -1441,7 +1224,7 @@ Every screen must have a clear visual hierarchy. Users should instantly know:
|
|||||||
- Design reusable, modular components with consistent styling, behavior, and feedback states (e.g., hover, active, focus, error)
|
- Design reusable, modular components with consistent styling, behavior, and feedback states (e.g., hover, active, focus, error)
|
||||||
- Include purposeful animations (e.g., scale-up on hover, fade-in on scroll) to guide attention and enhance interactivity without distraction
|
- Include purposeful animations (e.g., scale-up on hover, fade-in on scroll) to guide attention and enhance interactivity without distraction
|
||||||
- Ensure full accessibility support with keyboard navigation, ARIA labels, and visible focus states (e.g., a glowing outline in an accent color)
|
- Ensure full accessibility support with keyboard navigation, ARIA labels, and visible focus states (e.g., a glowing outline in an accent color)
|
||||||
- Use custom icons or illustrations for components to reinforce the brand's visual identity
|
- Use custom icons or illustrations for components to reinforce the brand’s visual identity
|
||||||
|
|
||||||
### Adding Fonts
|
### Adding Fonts
|
||||||
|
|
||||||
@@ -1508,42 +1291,6 @@ When users specify color schemes:
|
|||||||
- Add hover and focus states for interactive elements
|
- Add hover and focus states for interactive elements
|
||||||
- **Use `hover:bg-muted` for hover states on clickable cards/buttons** - provides subtle, accessible feedback without overpowering the design (avoid `hover:bg-accent` or `hover:bg-secondary` which can be too strong)
|
- **Use `hover:bg-muted` for hover states on clickable cards/buttons** - provides subtle, accessible feedback without overpowering the design (avoid `hover:bg-accent` or `hover:bg-secondary` which can be too strong)
|
||||||
|
|
||||||
### Mandatory Design Review
|
|
||||||
|
|
||||||
**CRITICAL: After completing the initial build, you MUST perform a design review before considering the project done.**
|
|
||||||
|
|
||||||
**Design Review Checklist**:
|
|
||||||
|
|
||||||
1. **Screenshot Test**: Take a mental screenshot. Does it look like a designed product or a template?
|
|
||||||
|
|
||||||
2. **Category Alignment**: Does the design match its project category? A dashboard shouldn't look like a landing page.
|
|
||||||
|
|
||||||
3. **Visual Hierarchy**: Can you identify the #1 most important thing on each screen in under 2 seconds?
|
|
||||||
|
|
||||||
4. **Typography Check**:
|
|
||||||
- Is there clear size contrast between headlines and body?
|
|
||||||
- Are fonts appropriate for the project category?
|
|
||||||
- Is line-height comfortable for reading?
|
|
||||||
|
|
||||||
5. **Color Check**:
|
|
||||||
- Do text colors meet contrast requirements?
|
|
||||||
- Is the brand color used strategically (not everywhere)?
|
|
||||||
- Does the palette feel cohesive?
|
|
||||||
|
|
||||||
6. **Spacing Check**:
|
|
||||||
- Is spacing consistent throughout?
|
|
||||||
- Is there enough whitespace, or does it feel cramped?
|
|
||||||
- Do sections have clear boundaries?
|
|
||||||
|
|
||||||
7. **Interaction Check**:
|
|
||||||
- Do buttons have hover/active states?
|
|
||||||
- Do inputs have clear focus states?
|
|
||||||
- Is there loading/success/error feedback?
|
|
||||||
|
|
||||||
8. **The "Would I Use This?" Test**: If you encountered this product, would you trust it? Does it feel professional?
|
|
||||||
|
|
||||||
**If any check fails, iterate on the design before delivering.** Do not ship designs that feel generic or unpolished.
|
|
||||||
|
|
||||||
## Writing Tests vs Running Tests
|
## Writing Tests vs Running Tests
|
||||||
|
|
||||||
There is an important distinction between **writing new tests** and **running existing tests**:
|
There is an important distinction between **writing new tests** and **running existing tests**:
|
||||||
|
|||||||
Generated
+33
-51
@@ -14,12 +14,12 @@
|
|||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@fontsource-variable/inter": "^5.2.6",
|
"@fontsource-variable/inter": "^5.2.6",
|
||||||
"@getalby/sdk": "^6.0.1",
|
"@getalby/sdk": "^6.0.1",
|
||||||
"@hookform/resolvers": "^5.2.2",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@isomorphic-git/lightning-fs": "^4.6.2",
|
"@isomorphic-git/lightning-fs": "^4.6.2",
|
||||||
"@modelcontextprotocol/sdk": "^1.22.0",
|
"@modelcontextprotocol/sdk": "^1.22.0",
|
||||||
"@mozilla/readability": "^0.6.0",
|
"@mozilla/readability": "^0.6.0",
|
||||||
"@nostrify/nostrify": "^0.49.2",
|
"@nostrify/nostrify": "^0.48.2",
|
||||||
"@nostrify/react": "^0.2.24",
|
"@nostrify/react": "^0.2.20",
|
||||||
"@opensecret/react": "^1.5.4",
|
"@opensecret/react": "^1.5.4",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
"mime": "^4.1.0",
|
"mime": "^4.1.0",
|
||||||
"nostr-tools": "^2.15.2",
|
"nostr-tools": "^2.15.2",
|
||||||
"nunjucks": "^3.2.4",
|
"nunjucks": "^3.2.4",
|
||||||
"openai": "^6.16.0",
|
"openai": "^5.15.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"prismjs": "^1.30.0",
|
"prismjs": "^1.30.0",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
"react-day-picker": "^8.10.1",
|
"react-day-picker": "^8.10.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-error-boundary": "^6.0.0",
|
"react-error-boundary": "^6.0.0",
|
||||||
"react-hook-form": "^7.71.1",
|
"react-hook-form": "^7.53.0",
|
||||||
"react-i18next": "^15.7.3",
|
"react-i18next": "^15.7.3",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-resizable-panels": "^3.0.3",
|
"react-resizable-panels": "^3.0.3",
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
"vaul": "^0.9.3",
|
"vaul": "^0.9.3",
|
||||||
"webln": "^0.3.2",
|
"webln": "^0.3.2",
|
||||||
"workbox-window": "^7.3.0",
|
"workbox-window": "^7.3.0",
|
||||||
"zod": "^4.3.6"
|
"zod": "^3.25.76"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.9.0",
|
"@eslint/js": "^9.9.0",
|
||||||
@@ -2591,15 +2591,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@hookform/resolvers": {
|
"node_modules/@hookform/resolvers": {
|
||||||
"version": "5.2.2",
|
"version": "3.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-5.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.10.0.tgz",
|
||||||
"integrity": "sha512-A/IxlMLShx3KjV/HeTcTfaMxdwy690+L/ZADoeaTltLx+CVuzkeVIPuybK3jrRfw7YZnmdKsVVHAlEPIAEUNlA==",
|
"integrity": "sha512-79Dv+3mDF7i+2ajj7SkypSKHhl1cbln1OGavqrsF7p6mbUv11xpqpacPsGDCTRvCSjEEIez2ef1NveSVL3b0Ag==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
|
||||||
"@standard-schema/utils": "^0.3.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react-hook-form": "^7.55.0"
|
"react-hook-form": "^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@html-eslint/eslint-plugin": {
|
"node_modules/@html-eslint/eslint-plugin": {
|
||||||
@@ -2967,11 +2964,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nostrify/nostrify": {
|
"node_modules/@nostrify/nostrify": {
|
||||||
"version": "0.49.2",
|
"version": "0.48.2",
|
||||||
"resolved": "https://registry.npmjs.org/@nostrify/nostrify/-/nostrify-0.49.2.tgz",
|
"resolved": "https://registry.npmjs.org/@nostrify/nostrify/-/nostrify-0.48.2.tgz",
|
||||||
"integrity": "sha512-JMiGifc/XX4QhzFnmJVw00UjcOS295w/NYth9mJH0cbS0EqPQ/4HBn33P0DGW3iE5EAkk+n98cnwzYeIPtn9pQ==",
|
"integrity": "sha512-Zze3RASsgn4MLQCuC5I4XR0WJi9G3J8qZpVjVIPvkw6vbZRct++JgavcZSxwKjJH1hHq+8d90IrHMOrskNQ8NQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nostrify/types": "0.36.9",
|
"@nostrify/types": "0.36.8",
|
||||||
"@scure/base": "^2.0.0",
|
"@scure/base": "^2.0.0",
|
||||||
"@smithy/util-base64": "^4.3.0",
|
"@smithy/util-base64": "^4.3.0",
|
||||||
"@smithy/util-hex-encoding": "^4.2.0",
|
"@smithy/util-hex-encoding": "^4.2.0",
|
||||||
@@ -2980,7 +2977,7 @@
|
|||||||
"nostr-tools": "^2.13.0",
|
"nostr-tools": "^2.13.0",
|
||||||
"websocket-ts": "^2.2.1",
|
"websocket-ts": "^2.2.1",
|
||||||
"ws": "^8.18.3",
|
"ws": "^8.18.3",
|
||||||
"zod": "^4.3.6"
|
"zod": "^3.23.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nostrify/nostrify/node_modules/@scure/base": {
|
"node_modules/@nostrify/nostrify/node_modules/@scure/base": {
|
||||||
@@ -3008,12 +3005,12 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@nostrify/react": {
|
"node_modules/@nostrify/react": {
|
||||||
"version": "0.2.24",
|
"version": "0.2.20",
|
||||||
"resolved": "https://registry.npmjs.org/@nostrify/react/-/react-0.2.24.tgz",
|
"resolved": "https://registry.npmjs.org/@nostrify/react/-/react-0.2.20.tgz",
|
||||||
"integrity": "sha512-LdB6UjNKZ/Xhz+jj8CRCcudHt4WNNVZMgJsiO+XAloqWE8oPRf1G2i1k6I/eF6buCJokKE1PFUTMlyieOpIXNQ==",
|
"integrity": "sha512-Tvkdr5X+MQxh6CKKthk9Idch3vFp5nPcm57uJZJWrIqBtuj9jxMamM6uEo2lQAr0ugK52xDlyD50lRDRe0RMbQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nostrify/nostrify": "0.49.2",
|
"@nostrify/nostrify": "0.48.2",
|
||||||
"@nostrify/types": "0.36.9",
|
"@nostrify/types": "0.36.8",
|
||||||
"@tanstack/react-query": "^5.69.0",
|
"@tanstack/react-query": "^5.69.0",
|
||||||
"nostr-tools": "^2.13.0",
|
"nostr-tools": "^2.13.0",
|
||||||
"react": "^18.0.0",
|
"react": "^18.0.0",
|
||||||
@@ -3021,9 +3018,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nostrify/types": {
|
"node_modules/@nostrify/types": {
|
||||||
"version": "0.36.9",
|
"version": "0.36.8",
|
||||||
"resolved": "https://registry.npmjs.org/@nostrify/types/-/types-0.36.9.tgz",
|
"resolved": "https://registry.npmjs.org/@nostrify/types/-/types-0.36.8.tgz",
|
||||||
"integrity": "sha512-tMx/r0W+QoVRRgs8d6ltaSgrftasOXuFsi33kW8WirswCy2b3UR1tqRgc0iBU9zRa9XR0nlej/wJZW+6wUFi+Q=="
|
"integrity": "sha512-tmpz5pkU8oXu7+V1qxvAzuoo8s5x4Gvo7h+JRm+JAW6x/2VZ8aQoA54yhn89qZ9agciMJhVdhqCm1PlK55w17A=="
|
||||||
},
|
},
|
||||||
"node_modules/@opensecret/react": {
|
"node_modules/@opensecret/react": {
|
||||||
"version": "1.5.4",
|
"version": "1.5.4",
|
||||||
@@ -3044,15 +3041,6 @@
|
|||||||
"react-dom": "^18.0.0 || ^19.0.0"
|
"react-dom": "^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@opensecret/react/node_modules/zod": {
|
|
||||||
"version": "3.25.76",
|
|
||||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
|
|
||||||
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/colinhacks"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@peculiar/asn1-cms": {
|
"node_modules/@peculiar/asn1-cms": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.6.0.tgz",
|
||||||
@@ -5279,12 +5267,6 @@
|
|||||||
"integrity": "sha512-1eU2K9EgOcV4qc9jcP6G72xxZxEm5PfeI5H55l08W95b4oRJaqhmlWRc4xZAm6IVSKhVNxMi66V67hCzzuMTAg==",
|
"integrity": "sha512-1eU2K9EgOcV4qc9jcP6G72xxZxEm5PfeI5H55l08W95b4oRJaqhmlWRc4xZAm6IVSKhVNxMi66V67hCzzuMTAg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@standard-schema/utils": {
|
|
||||||
"version": "0.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz",
|
|
||||||
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/@std/encoding": {
|
"node_modules/@std/encoding": {
|
||||||
"name": "@jsr/std__encoding",
|
"name": "@jsr/std__encoding",
|
||||||
"version": "1.0.10",
|
"version": "1.0.10",
|
||||||
@@ -12229,16 +12211,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/openai": {
|
"node_modules/openai": {
|
||||||
"version": "6.16.0",
|
"version": "5.15.0",
|
||||||
"resolved": "https://registry.npmjs.org/openai/-/openai-6.16.0.tgz",
|
"resolved": "https://registry.npmjs.org/openai/-/openai-5.15.0.tgz",
|
||||||
"integrity": "sha512-fZ1uBqjFUjXzbGc35fFtYKEOxd20kd9fDpFeqWtsOZWiubY8CZ1NAlXHW3iathaFvqmNtCWMIsosCuyeI7Joxg==",
|
"integrity": "sha512-kcUdws8K/A8m02I+IqFBwO51gS+87GP89yWEufGbzEi8anBz4FB/bti2QxaJdGwwY4mwJGzx85XO7TuL/Tpu1w==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"openai": "bin/cli"
|
"openai": "bin/cli"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"ws": "^8.18.0",
|
"ws": "^8.18.0",
|
||||||
"zod": "^3.25 || ^4.0"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"ws": {
|
"ws": {
|
||||||
@@ -12994,9 +12976,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-hook-form": {
|
"node_modules/react-hook-form": {
|
||||||
"version": "7.71.1",
|
"version": "7.56.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.1.tgz",
|
||||||
"integrity": "sha512-9SUJKCGKo8HUSsCO+y0CtqkqI5nNuaDqTxyqPsZPqIwudpj4rCrAz/jZV+jn57bx5gtZKOh3neQu94DXMc+w5w==",
|
"integrity": "sha512-qWAVokhSpshhcEuQDSANHx3jiAEFzu2HAaaQIzi/r9FNPm1ioAvuJSD4EuZzWd7Al7nTRKcKPnBKO7sRn+zavQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
@@ -16832,9 +16814,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/zod": {
|
"node_modules/zod": {
|
||||||
"version": "4.3.6",
|
"version": "3.25.76",
|
||||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
|
||||||
"integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",
|
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/colinhacks"
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
|
|||||||
+6
-6
@@ -25,12 +25,12 @@
|
|||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@fontsource-variable/inter": "^5.2.6",
|
"@fontsource-variable/inter": "^5.2.6",
|
||||||
"@getalby/sdk": "^6.0.1",
|
"@getalby/sdk": "^6.0.1",
|
||||||
"@hookform/resolvers": "^5.2.2",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@isomorphic-git/lightning-fs": "^4.6.2",
|
"@isomorphic-git/lightning-fs": "^4.6.2",
|
||||||
"@modelcontextprotocol/sdk": "^1.22.0",
|
"@modelcontextprotocol/sdk": "^1.22.0",
|
||||||
"@mozilla/readability": "^0.6.0",
|
"@mozilla/readability": "^0.6.0",
|
||||||
"@nostrify/nostrify": "^0.49.2",
|
"@nostrify/nostrify": "^0.48.2",
|
||||||
"@nostrify/react": "^0.2.24",
|
"@nostrify/react": "^0.2.20",
|
||||||
"@opensecret/react": "^1.5.4",
|
"@opensecret/react": "^1.5.4",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
"mime": "^4.1.0",
|
"mime": "^4.1.0",
|
||||||
"nostr-tools": "^2.15.2",
|
"nostr-tools": "^2.15.2",
|
||||||
"nunjucks": "^3.2.4",
|
"nunjucks": "^3.2.4",
|
||||||
"openai": "^6.16.0",
|
"openai": "^5.15.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"prismjs": "^1.30.0",
|
"prismjs": "^1.30.0",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
"react-day-picker": "^8.10.1",
|
"react-day-picker": "^8.10.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-error-boundary": "^6.0.0",
|
"react-error-boundary": "^6.0.0",
|
||||||
"react-hook-form": "^7.71.1",
|
"react-hook-form": "^7.53.0",
|
||||||
"react-i18next": "^15.7.3",
|
"react-i18next": "^15.7.3",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-resizable-panels": "^3.0.3",
|
"react-resizable-panels": "^3.0.3",
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
"vaul": "^0.9.3",
|
"vaul": "^0.9.3",
|
||||||
"webln": "^0.3.2",
|
"webln": "^0.3.2",
|
||||||
"workbox-window": "^7.3.0",
|
"workbox-window": "^7.3.0",
|
||||||
"zod": "^4.3.6"
|
"zod": "^3.25.76"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.9.0",
|
"@eslint/js": "^9.9.0",
|
||||||
|
|||||||
@@ -170,17 +170,17 @@ export function BranchSwitcher({ projectId, className }: BranchSwitcherProps) {
|
|||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className={cn("gap-1 sm:gap-2 hover:bg-secondary/10 hover:border-secondary/20", className)}
|
className={cn("h-7 text-xs gap-1.5", className)}
|
||||||
disabled={isSwitching}
|
disabled={isSwitching}
|
||||||
>
|
>
|
||||||
{isSwitching ? (
|
{isSwitching ? (
|
||||||
<Loader2 className="h-4 w-4 animate-spin" />
|
<Loader2 className="h-3 w-3 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
<GitBranch className="h-4 w-4" />
|
<GitBranch className="h-3 w-3" />
|
||||||
)}
|
)}
|
||||||
<span className=" max-w-[120px] truncate">{currentBranch}</span>
|
<span className="max-w-[120px] truncate">{currentBranch}</span>
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end" className="w-56">
|
<DropdownMenuContent align="end" className="w-56">
|
||||||
|
|||||||
@@ -1,140 +1,37 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { ImageOff } from 'lucide-react';
|
||||||
import { Save, Loader2, ImageOff } from 'lucide-react';
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { useGitStatus } from '@/hooks/useGitStatus';
|
|
||||||
import { isMediaFile } from '@/lib/fileUtils';
|
import { isMediaFile } from '@/lib/fileUtils';
|
||||||
|
|
||||||
interface FileEditorProps {
|
interface FileEditorProps {
|
||||||
filePath: string;
|
filePath: string;
|
||||||
content: string;
|
content: string;
|
||||||
onSave: (content: string) => void;
|
onContentChange: (content: string) => void;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
projectId?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FileEditor({ filePath, content, onSave, isLoading, projectId }: FileEditorProps) {
|
export function FileEditor({ filePath, content, onContentChange, isLoading }: FileEditorProps) {
|
||||||
const { t } = useTranslation();
|
|
||||||
const [editedContent, setEditedContent] = useState(content);
|
const [editedContent, setEditedContent] = useState(content);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const isMedia = isMediaFile(filePath);
|
||||||
const [hasChanges, setHasChanges] = useState(false);
|
|
||||||
const { data: gitStatus } = useGitStatus(projectId || null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEditedContent(content);
|
setEditedContent(content);
|
||||||
setHasChanges(false);
|
|
||||||
}, [content, filePath]);
|
}, [content, filePath]);
|
||||||
|
|
||||||
useEffect(() => {
|
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
setHasChanges(editedContent !== content);
|
const newContent = e.target.value;
|
||||||
}, [editedContent, content]);
|
setEditedContent(newContent);
|
||||||
|
onContentChange(newContent);
|
||||||
const handleSave = async () => {
|
|
||||||
setIsSaving(true);
|
|
||||||
try {
|
|
||||||
await onSave(editedContent);
|
|
||||||
setHasChanges(false);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to save file:', error);
|
|
||||||
} finally {
|
|
||||||
setIsSaving(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getLanguageFromPath = (path: string): string => {
|
|
||||||
const extension = path.split('.').pop()?.toLowerCase();
|
|
||||||
const languageMap: Record<string, string> = {
|
|
||||||
js: 'javascript',
|
|
||||||
jsx: 'javascript',
|
|
||||||
ts: 'typescript',
|
|
||||||
tsx: 'typescript',
|
|
||||||
html: 'html',
|
|
||||||
css: 'css',
|
|
||||||
json: 'json',
|
|
||||||
md: 'markdown',
|
|
||||||
py: 'python',
|
|
||||||
java: 'java',
|
|
||||||
cpp: 'cpp',
|
|
||||||
c: 'c',
|
|
||||||
sh: 'bash',
|
|
||||||
yml: 'yaml',
|
|
||||||
yaml: 'yaml',
|
|
||||||
};
|
|
||||||
return languageMap[extension || ''] || 'text';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMonospaceFont = () => {
|
const getMonospaceFont = () => {
|
||||||
return 'font-mono text-sm';
|
return 'font-mono text-sm';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function to get git status for the current file
|
|
||||||
const getFileGitStatus = (filePath: string) => {
|
|
||||||
if (!gitStatus?.changedFiles) return null;
|
|
||||||
const fileChange = gitStatus.changedFiles.find(change => change.filepath === filePath);
|
|
||||||
return fileChange?.status || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helper function to get styling classes based on git status
|
|
||||||
const getGitStatusClasses = (status: string | null) => {
|
|
||||||
switch (status) {
|
|
||||||
case 'added':
|
|
||||||
case 'untracked':
|
|
||||||
return 'text-green-600 dark:text-green-400';
|
|
||||||
case 'modified':
|
|
||||||
case 'staged':
|
|
||||||
return 'text-yellow-600 dark:text-yellow-400';
|
|
||||||
default:
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get git status for the current file
|
|
||||||
const currentFileGitStatus = getFileGitStatus(filePath);
|
|
||||||
const gitStatusClasses = getGitStatusClasses(currentFileGitStatus);
|
|
||||||
const isMedia = isMediaFile(filePath);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-col">
|
<div className="h-full flex flex-col">
|
||||||
<CardHeader className="border-b py-2 sm:py-3">
|
<div className="flex-1 p-0">
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<CardTitle className={cn("text-sm sm:text-base truncate flex-1 mr-2", gitStatusClasses)}>{filePath}</CardTitle>
|
|
||||||
<div className="flex items-center space-x-1 sm:space-x-2">
|
|
||||||
{hasChanges && !isMedia && (
|
|
||||||
<span className="text-xs sm:text-sm text-muted-foreground hidden sm:inline">{t('unsavedChanges')}</span>
|
|
||||||
)}
|
|
||||||
{!isMedia && (
|
|
||||||
<Button
|
|
||||||
onClick={handleSave}
|
|
||||||
disabled={!hasChanges || isSaving || isLoading}
|
|
||||||
size="sm"
|
|
||||||
className="focus-ring"
|
|
||||||
>
|
|
||||||
{isSaving ? (
|
|
||||||
<>
|
|
||||||
<Loader2 className="mr-1 sm:mr-2 h-4 w-4 animate-spin" />
|
|
||||||
<span className="hidden sm:inline">{t('saving')}</span>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Save className="sm:mr-2 h-4 w-4" />
|
|
||||||
<span className="hidden sm:inline">{t('save')}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{!isMedia && (
|
|
||||||
<div className="text-xs text-muted-foreground mt-1">
|
|
||||||
{t('languageLabel')}: {getLanguageFromPath(filePath)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</CardHeader>
|
|
||||||
|
|
||||||
<CardContent className="flex-1 p-0">
|
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex items-center justify-center h-full">
|
<div className="flex items-center justify-center h-full">
|
||||||
<div className="animate-spin rounded-full h-6 w-6 border-b-2 border-primary"></div>
|
<div className="animate-spin rounded-full h-6 w-6 border-b-2 border-primary"></div>
|
||||||
@@ -146,7 +43,7 @@ export function FileEditor({ filePath, content, onSave, isLoading, projectId }:
|
|||||||
) : (
|
) : (
|
||||||
<Textarea
|
<Textarea
|
||||||
value={editedContent}
|
value={editedContent}
|
||||||
onChange={(e) => setEditedContent(e.target.value)}
|
onChange={handleChange}
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-full h-full resize-none border-0 rounded-none',
|
'w-full h-full resize-none border-0 rounded-none',
|
||||||
'focus:outline-none focus:ring-0',
|
'focus:outline-none focus:ring-0',
|
||||||
@@ -157,7 +54,7 @@ export function FileEditor({ filePath, content, onSave, isLoading, projectId }:
|
|||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||||
import { useFS } from '@/hooks/useFS';
|
import { useFS } from '@/hooks/useFS';
|
||||||
import { useGitStatus } from '@/hooks/useGitStatus';
|
import { useGitStatus } from '@/hooks/useGitStatus';
|
||||||
import { ChevronRight, ChevronDown, File, Folder, Search } from 'lucide-react';
|
import { ChevronRight, ChevronDown, File, Folder, Search, Code, FileText, Image, FileJson, Palette, Settings, FileCode } from 'lucide-react';
|
||||||
|
import type { LucideIcon } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { createGitignoreFilter, normalizePathForGitignore } from '@/lib/gitignore';
|
import { createGitignoreFilter, normalizePathForGitignore } from '@/lib/gitignore';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
@@ -22,6 +23,49 @@ interface FileNode {
|
|||||||
isOpen?: boolean;
|
isOpen?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to get file icon based on extension
|
||||||
|
function getFileIcon(fileName: string): { icon: LucideIcon; color: string } {
|
||||||
|
const ext = fileName.split('.').pop()?.toLowerCase() || '';
|
||||||
|
|
||||||
|
// Image files - subtle blue hint
|
||||||
|
if (['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'ico', 'bmp', 'tiff'].includes(ext)) {
|
||||||
|
return { icon: Image, color: 'text-blue-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code files - subtle amber hint
|
||||||
|
if (['js', 'jsx', 'ts', 'tsx', 'py', 'java', 'cpp', 'c', 'cs', 'php', 'rb', 'go', 'rs', 'swift', 'kt', 'scala', 'dart'].includes(ext)) {
|
||||||
|
return { icon: Code, color: 'text-amber-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Web files - subtle orange hint
|
||||||
|
if (['html', 'htm', 'xhtml'].includes(ext)) {
|
||||||
|
return { icon: FileCode, color: 'text-orange-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// CSS files - subtle purple hint
|
||||||
|
if (['css', 'scss', 'sass', 'less', 'styl'].includes(ext)) {
|
||||||
|
return { icon: Palette, color: 'text-purple-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data/Config files - subtle green hint
|
||||||
|
if (['json', 'jsonc'].includes(ext)) {
|
||||||
|
return { icon: FileJson, color: 'text-green-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config files - subtle amber hint
|
||||||
|
if (['xml', 'yaml', 'yml', 'toml', 'ini', 'conf', 'config'].includes(ext)) {
|
||||||
|
return { icon: Settings, color: 'text-amber-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Text/Markdown files - subtle amber hint
|
||||||
|
if (['txt', 'md', 'markdown', 'rst', 'log'].includes(ext)) {
|
||||||
|
return { icon: FileText, color: 'text-amber-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default file icon - subtle amber hint
|
||||||
|
return { icon: File, color: 'text-amber-400/60' };
|
||||||
|
}
|
||||||
|
|
||||||
export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProps) {
|
export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [tree, setTree] = useState<FileNode[]>([]);
|
const [tree, setTree] = useState<FileNode[]>([]);
|
||||||
@@ -264,7 +308,10 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="w-4" /> {/* Spacer for alignment */}
|
<div className="w-4" /> {/* Spacer for alignment */}
|
||||||
<File className={cn("h-4 w-4 text-gray-500 flex-shrink-0", gitignoreClasses)} />
|
{(() => {
|
||||||
|
const { icon: Icon, color } = getFileIcon(node.name);
|
||||||
|
return <Icon className={cn("h-4 w-4 flex-shrink-0", color, gitignoreClasses)} />;
|
||||||
|
})()}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<span className={cn("text-sm whitespace-nowrap", gitStatusClasses, gitignoreClasses)}>{node.name}</span>
|
<span className={cn("text-sm whitespace-nowrap", gitStatusClasses, gitignoreClasses)}>{node.name}</span>
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ import { useFSPaths } from '@/hooks/useFSPaths';
|
|||||||
import { addConsoleMessage, getConsoleMessages, type ConsoleMessage } from '@/lib/consoleMessages';
|
import { addConsoleMessage, getConsoleMessages, type ConsoleMessage } from '@/lib/consoleMessages';
|
||||||
import { useConsoleError } from '@/hooks/useConsoleError';
|
import { useConsoleError } from '@/hooks/useConsoleError';
|
||||||
import { useBuildProject } from '@/hooks/useBuildProject';
|
import { useBuildProject } from '@/hooks/useBuildProject';
|
||||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { FolderOpen, ArrowLeft, Bug, Copy, Check, Loader2, Code, X, Terminal, Expand, Shrink, Hammer, RefreshCw } from 'lucide-react';
|
import { FolderOpen, Bug, Copy, Check, Loader2, Code, X, Terminal, Expand, Shrink, Hammer, RefreshCw, Save } from 'lucide-react';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
|
||||||
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
|
||||||
import { BranchSwitcher } from '@/components/BranchSwitcher';
|
import { BranchSwitcher } from '@/components/BranchSwitcher';
|
||||||
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
||||||
import { type DeviceMode } from '@/components/ui/device-toggle';
|
import { type DeviceMode } from '@/components/ui/device-toggle';
|
||||||
@@ -63,16 +61,16 @@ interface JSONRPCResponse {
|
|||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable = true }: PreviewPaneProps) {
|
export function PreviewPane({ projectId, activeTab, onToggleView: _onToggleView, isPreviewable = true }: PreviewPaneProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { config } = useAppContext();
|
const { config } = useAppContext();
|
||||||
const { previewDomain } = config;
|
const { previewDomain } = config;
|
||||||
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
const [openFiles, setOpenFiles] = useState<string[]>([]);
|
||||||
const [fileContent, setFileContent] = useState<string>('');
|
const [activeFileTab, setActiveFileTab] = useState<string | null>(null);
|
||||||
|
const [fileContents, setFileContents] = useState<Record<string, string>>({});
|
||||||
|
const [editedContents, setEditedContents] = useState<Record<string, string>>({});
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [mobileCodeView, setMobileCodeView] = useState<'explorer' | 'editor' | 'terminal'>('explorer');
|
|
||||||
const [desktopCodeView, setDesktopCodeView] = useState<'files' | 'terminal'>('files');
|
|
||||||
const isMobile = useIsMobile();
|
|
||||||
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
||||||
const [buildError, setBuildError] = useState<string | null>(null);
|
const [buildError, setBuildError] = useState<string | null>(null);
|
||||||
const [currentPath, setCurrentPath] = useState('/');
|
const [currentPath, setCurrentPath] = useState('/');
|
||||||
@@ -82,6 +80,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||||
const [deviceMode, setDeviceMode] = useState<DeviceMode>('laptop');
|
const [deviceMode, setDeviceMode] = useState<DeviceMode>('laptop');
|
||||||
const [isLogsOpen, setIsLogsOpen] = useState(false);
|
const [isLogsOpen, setIsLogsOpen] = useState(false);
|
||||||
|
const [logsPanelTab, setLogsPanelTab] = useState<'logs' | 'code' | 'terminal'>('logs');
|
||||||
const previewContainerRef = useRef<HTMLDivElement>(null);
|
const previewContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||||
const iframePanelRef = useRef<ImperativePanelHandle>(null);
|
const iframePanelRef = useRef<ImperativePanelHandle>(null);
|
||||||
@@ -125,22 +124,26 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
const loadFileContent = useCallback(async (filePath: string) => {
|
const loadFileContent = useCallback(async (filePath: string) => {
|
||||||
// Skip loading media files - they can't be edited as text
|
// Skip loading media files - they can't be edited as text
|
||||||
if (isMediaFile(filePath)) {
|
if (isMediaFile(filePath)) {
|
||||||
setFileContent('');
|
setFileContents(prev => ({ ...prev, [filePath]: '' }));
|
||||||
setIsLoading(false);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't reload if we already have the content
|
||||||
|
if (fileContents[filePath]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const content = await projectsManager.readFile(projectId, filePath);
|
const content = await projectsManager.readFile(projectId, filePath);
|
||||||
setFileContent(content);
|
setFileContents(prev => ({ ...prev, [filePath]: content }));
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
console.error('Failed to load file:', _error);
|
console.error('Failed to load file:', _error);
|
||||||
setFileContent('');
|
setFileContents(prev => ({ ...prev, [filePath]: '' }));
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, [projectId, projectsManager]);
|
}, [projectId, projectsManager, fileContents]);
|
||||||
|
|
||||||
const getContentType = (filename: string): string => {
|
const getContentType = (filename: string): string => {
|
||||||
const ext = filename.split('.').pop()?.toLowerCase();
|
const ext = filename.split('.').pop()?.toLowerCase();
|
||||||
@@ -416,19 +419,22 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
return () => window.removeEventListener('message', handleMessage);
|
return () => window.removeEventListener('message', handleMessage);
|
||||||
}, [handleFetch, handleConsoleMessage, handleUpdateNavigationState, projectId, previewDomain]);
|
}, [handleFetch, handleConsoleMessage, handleUpdateNavigationState, projectId, previewDomain]);
|
||||||
|
|
||||||
|
// Load content for all open files
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedFile) {
|
openFiles.forEach(filePath => {
|
||||||
loadFileContent(selectedFile);
|
if (!fileContents[filePath] && !isMediaFile(filePath)) {
|
||||||
}
|
loadFileContent(filePath);
|
||||||
}, [selectedFile, loadFileContent]);
|
}
|
||||||
|
});
|
||||||
|
}, [openFiles, fileContents, loadFileContent]);
|
||||||
|
|
||||||
// Reset selected file and navigation history when projectId changes
|
// Reset selected file and navigation history when projectId changes
|
||||||
const prevProjectIdRef = useRef<string>();
|
const prevProjectIdRef = useRef<string>();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedFile(null);
|
setOpenFiles([]);
|
||||||
setFileContent('');
|
setActiveFileTab(null);
|
||||||
setMobileCodeView('explorer');
|
setFileContents({});
|
||||||
setDesktopCodeView('files');
|
setEditedContents({});
|
||||||
setBuildError(null);
|
setBuildError(null);
|
||||||
|
|
||||||
// Reset navigation history and state
|
// Reset navigation history and state
|
||||||
@@ -463,18 +469,61 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
}, [projectId, checkForBuiltProject, refreshIframe]);
|
}, [projectId, checkForBuiltProject, refreshIframe]);
|
||||||
|
|
||||||
const handleFileSelect = (filePath: string) => {
|
const handleFileSelect = (filePath: string) => {
|
||||||
setSelectedFile(filePath);
|
// Skip media files
|
||||||
if (isMobile) {
|
if (isMediaFile(filePath)) {
|
||||||
setMobileCodeView('editor');
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to open files if not already open
|
||||||
|
if (!openFiles.includes(filePath)) {
|
||||||
|
setOpenFiles(prev => [...prev, filePath]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set as active tab
|
||||||
|
setActiveFileTab(filePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCloseTab = (filePath: string, e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// Remove from open files
|
||||||
|
setOpenFiles(prev => prev.filter(f => f !== filePath));
|
||||||
|
|
||||||
|
// Remove from file contents
|
||||||
|
setFileContents(prev => {
|
||||||
|
const newContents = { ...prev };
|
||||||
|
delete newContents[filePath];
|
||||||
|
return newContents;
|
||||||
|
});
|
||||||
|
|
||||||
|
// If this was the active tab, switch to another tab or clear
|
||||||
|
if (activeFileTab === filePath) {
|
||||||
|
const remainingFiles = openFiles.filter(f => f !== filePath);
|
||||||
|
if (remainingFiles.length > 0) {
|
||||||
|
setActiveFileTab(remainingFiles[remainingFiles.length - 1]);
|
||||||
|
} else {
|
||||||
|
setActiveFileTab(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFileSave = async (content: string) => {
|
const handleFileSave = async () => {
|
||||||
if (!selectedFile) return;
|
if (!activeFileTab) return;
|
||||||
|
|
||||||
|
const contentToSave = editedContents[activeFileTab];
|
||||||
|
if (contentToSave === undefined || contentToSave === fileContents[activeFileTab]) {
|
||||||
|
return; // No changes to save
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSaving(true);
|
||||||
try {
|
try {
|
||||||
await fs.writeFile(`${projectsPath}/${projectId}/${selectedFile}`, content);
|
await fs.writeFile(`${projectsPath}/${projectId}/${activeFileTab}`, contentToSave);
|
||||||
setFileContent(content);
|
setFileContents(prev => ({ ...prev, [activeFileTab]: contentToSave }));
|
||||||
|
setEditedContents(prev => {
|
||||||
|
const newContents = { ...prev };
|
||||||
|
delete newContents[activeFileTab];
|
||||||
|
return newContents;
|
||||||
|
});
|
||||||
|
|
||||||
// Automatically trigger a rebuild after saving a file
|
// Automatically trigger a rebuild after saving a file
|
||||||
if (isPreviewable) {
|
if (isPreviewable) {
|
||||||
@@ -487,6 +536,8 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to save file:', error);
|
console.error('Failed to save file:', error);
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -597,18 +648,6 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
)}
|
)}
|
||||||
<span className="hidden lg:inline">Build</span>
|
<span className="hidden lg:inline">Build</span>
|
||||||
</Button>
|
</Button>
|
||||||
{(!isMobile && onToggleView && isPreviewable) && (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={onToggleView}
|
|
||||||
className="h-8 gap-2"
|
|
||||||
title={t('codeButtonTooltip')}
|
|
||||||
>
|
|
||||||
<Code className="h-4 w-4" />
|
|
||||||
<span className="hidden lg:inline">Code</span>
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -617,7 +656,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
title={t('logsButtonTooltip')}
|
title={t('logsButtonTooltip')}
|
||||||
>
|
>
|
||||||
<Bug className="h-4 w-4" />
|
<Bug className="h-4 w-4" />
|
||||||
<span className="hidden lg:inline">Logs</span>
|
<span className="hidden lg:inline">Debug</span>
|
||||||
{hasConsoleErrors && (
|
{hasConsoleErrors && (
|
||||||
<span className="absolute -top-1 -right-1 h-3 w-3 rounded-full border-2 border-background bg-red-500" />
|
<span className="absolute -top-1 -right-1 h-3 w-3 rounded-full border-2 border-background bg-red-500" />
|
||||||
)}
|
)}
|
||||||
@@ -631,7 +670,6 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
<ResizablePanel
|
<ResizablePanel
|
||||||
ref={iframePanelRef}
|
ref={iframePanelRef}
|
||||||
defaultSize={isLogsOpen ? 60 : 100}
|
defaultSize={isLogsOpen ? 60 : 100}
|
||||||
minSize={30}
|
|
||||||
className="min-h-0"
|
className="min-h-0"
|
||||||
>
|
>
|
||||||
<div className="h-full flex items-center justify-center min-h-0">
|
<div className="h-full flex items-center justify-center min-h-0">
|
||||||
@@ -751,35 +789,77 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
collapsedSize={0}
|
collapsedSize={0}
|
||||||
>
|
>
|
||||||
{/* Logs Panel */}
|
{/* Logs Panel */}
|
||||||
<div className="h-full flex flex-col bg-background border-t overflow-hidden min-h-0 w-full min-w-0">
|
<Tabs value={logsPanelTab} onValueChange={(v) => setLogsPanelTab(v as 'logs' | 'code' | 'terminal')} className="h-full flex flex-col bg-background border-t overflow-hidden min-h-0 w-full min-w-0">
|
||||||
{/* Logs Header */}
|
{/* Logs Header */}
|
||||||
<div className="h-12 px-4 border-b flex items-center justify-between flex-shrink-0">
|
<div className="h-12 px-4 border-b flex items-center justify-between flex-shrink-0">
|
||||||
|
<TabsList className="h-8">
|
||||||
|
<TabsTrigger value="logs" className="h-7 text-xs gap-1.5">
|
||||||
|
<Bug className="h-3 w-3" />
|
||||||
|
<span>Logs</span>
|
||||||
|
{hasConsoleErrors && (
|
||||||
|
<span className="h-1.5 w-1.5 rounded-full bg-red-500" />
|
||||||
|
)}
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="code" className="h-7 text-xs gap-1.5">
|
||||||
|
<Code className="h-3 w-3" />
|
||||||
|
<span>Code</span>
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="terminal" className="h-7 text-xs gap-1.5">
|
||||||
|
<Terminal className="h-3 w-3" />
|
||||||
|
<span>Terminal</span>
|
||||||
|
</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{hasConsoleErrors && (
|
{logsPanelTab === 'logs' && messageCount > 0 && (
|
||||||
<span className="h-2 w-2 rounded-full bg-red-500" />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{messageCount > 0 && (
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={copyAllMessagesToClipboard}
|
onClick={copyAllMessagesToClipboard}
|
||||||
className="h-7 px-2 text-xs"
|
className="h-7 text-xs gap-1.5"
|
||||||
>
|
>
|
||||||
{copiedAll ? (
|
{copiedAll ? (
|
||||||
<>
|
<>
|
||||||
<Check className="h-3 w-3 mr-1.5 text-success" />
|
<Check className="h-3 w-3 text-success" />
|
||||||
{t('copied')}
|
<span className="hidden sm:inline">{t('copied')}</span>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Copy className="h-3 w-3 mr-1.5" />
|
<Copy className="h-3 w-3" />
|
||||||
{t('copyAll')}
|
<span className="hidden sm:inline">{t('copyAll')}</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{logsPanelTab === 'code' && (
|
||||||
|
<>
|
||||||
|
<BranchSwitcher projectId={projectId} />
|
||||||
|
{activeFileTab && (() => {
|
||||||
|
const hasUnsavedChanges = editedContents[activeFileTab] !== undefined &&
|
||||||
|
editedContents[activeFileTab] !== fileContents[activeFileTab];
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleFileSave}
|
||||||
|
disabled={!hasUnsavedChanges || isSaving || isLoading}
|
||||||
|
className="h-7 text-xs gap-1.5"
|
||||||
|
>
|
||||||
|
{isSaving ? (
|
||||||
|
<>
|
||||||
|
<Loader2 className="h-3 w-3 animate-spin" />
|
||||||
|
<span className="hidden sm:inline">{t('saving')}</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Save className="h-3 w-3" />
|
||||||
|
<span className="hidden sm:inline">{t('save')}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -790,60 +870,151 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* Logs Content */}
|
{/* Panel Content */}
|
||||||
<div className="flex-1 min-h-0 overflow-hidden w-full">
|
<div className="flex-1 min-h-0 overflow-hidden w-full">
|
||||||
<ScrollArea className="h-full w-full">
|
{/* Logs Tab */}
|
||||||
<div className="p-2 space-y-0 w-full min-w-0 max-w-full">
|
<TabsContent value="logs" className="h-full mt-0 m-0 data-[state=active]:flex data-[state=active]:flex-col">
|
||||||
{messageCount === 0 ? (
|
<ScrollArea className="flex-1 min-h-0">
|
||||||
<div className="flex flex-col items-center justify-center py-12 text-center">
|
<div className="p-2 space-y-0 w-full min-w-0 max-w-full">
|
||||||
<p className="text-sm text-muted-foreground font-medium">No console messages</p>
|
{messageCount === 0 ? (
|
||||||
<p className="text-xs text-muted-foreground mt-1">Messages from your project will appear here</p>
|
<div className="flex flex-col items-center justify-center py-12 text-center">
|
||||||
</div>
|
<p className="text-sm text-muted-foreground font-medium">No console messages</p>
|
||||||
) : (
|
<p className="text-xs text-muted-foreground mt-1">Messages from your project will appear here</p>
|
||||||
messages.map((msg, index) => (
|
</div>
|
||||||
<div
|
) : (
|
||||||
key={index}
|
messages.map((msg, index) => (
|
||||||
className="group relative py-0.5 px-1 hover:bg-muted/50 transition-colors duration-150 rounded cursor-pointer w-full max-w-full"
|
<div
|
||||||
onClick={(e) => {
|
key={index}
|
||||||
e.stopPropagation();
|
className="group relative py-0.5 px-1 hover:bg-muted/50 transition-colors duration-150 rounded cursor-pointer w-full max-w-full"
|
||||||
copyMessageToClipboard(msg, index);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"text-xs font-mono leading-tight whitespace-pre-wrap break-words w-full min-w-0 max-w-full",
|
|
||||||
msg.level === 'error' ? "text-destructive" :
|
|
||||||
msg.level === 'warn' ? "text-warning" :
|
|
||||||
msg.level === 'info' ? "text-primary" :
|
|
||||||
"text-muted-foreground"
|
|
||||||
)}
|
|
||||||
style={{ wordBreak: 'break-word', overflowWrap: 'break-word' }}
|
|
||||||
>
|
|
||||||
{msg.message}
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
copyMessageToClipboard(msg, index);
|
copyMessageToClipboard(msg, index);
|
||||||
}}
|
}}
|
||||||
className="h-3 w-3 p-0 opacity-0 group-hover:opacity-100 transition-all duration-200 absolute right-1 top-1 hover:bg-muted/70 text-muted-foreground hover:text-foreground bg-background/80 rounded border"
|
|
||||||
>
|
>
|
||||||
{copiedMessageIndex === index ? (
|
<div
|
||||||
<Check className="h-2 w-2 text-success" />
|
className={cn(
|
||||||
) : (
|
"text-xs font-mono leading-tight whitespace-pre-wrap break-words w-full min-w-0 max-w-full",
|
||||||
<Copy className="h-2 w-2" />
|
msg.level === 'error' ? "text-destructive" :
|
||||||
)}
|
msg.level === 'warn' ? "text-warning" :
|
||||||
</Button>
|
msg.level === 'info' ? "text-primary" :
|
||||||
|
"text-muted-foreground"
|
||||||
|
)}
|
||||||
|
style={{ wordBreak: 'break-word', overflowWrap: 'break-word' }}
|
||||||
|
>
|
||||||
|
{msg.message}
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
copyMessageToClipboard(msg, index);
|
||||||
|
}}
|
||||||
|
className="h-3 w-3 p-0 opacity-0 group-hover:opacity-100 transition-all duration-200 absolute right-1 top-1 hover:bg-muted/70 text-muted-foreground hover:text-foreground bg-background/80 rounded border"
|
||||||
|
>
|
||||||
|
{copiedMessageIndex === index ? (
|
||||||
|
<Check className="h-2 w-2 text-success" />
|
||||||
|
) : (
|
||||||
|
<Copy className="h-2 w-2" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
|
</TabsContent>
|
||||||
|
{/* Code Tab */}
|
||||||
|
<TabsContent value="code" className="h-full mt-0 m-0 data-[state=active]:flex data-[state=active]:flex-col">
|
||||||
|
<div className="flex-1 min-h-0 flex">
|
||||||
|
<div className="w-1/3 border-r flex flex-col min-h-0">
|
||||||
|
<ScrollArea className="flex-1 min-h-0">
|
||||||
|
<ScrollBar orientation="horizontal" />
|
||||||
|
<div className="min-w-max">
|
||||||
|
<FileTree
|
||||||
|
projectId={projectId}
|
||||||
|
onFileSelect={handleFileSelect}
|
||||||
|
selectedFile={activeFileTab}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
))
|
</ScrollArea>
|
||||||
)}
|
</div>
|
||||||
|
<div className="flex-1 min-h-0 flex flex-col overflow-hidden">
|
||||||
|
{openFiles.length > 0 ? (
|
||||||
|
<>
|
||||||
|
{/* File Tabs */}
|
||||||
|
<div className="border-b flex-shrink-0 w-full overflow-x-auto overflow-y-hidden">
|
||||||
|
<div className="flex items-center gap-1 px-2" style={{ width: 'max-content' }}>
|
||||||
|
{openFiles.map((filePath) => {
|
||||||
|
const fileName = filePath.split('/').pop() || filePath;
|
||||||
|
const hasUnsavedChanges = editedContents[filePath] !== undefined &&
|
||||||
|
editedContents[filePath] !== fileContents[filePath];
|
||||||
|
const isActive = activeFileTab === filePath;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={filePath}
|
||||||
|
onClick={() => {
|
||||||
|
setActiveFileTab(filePath);
|
||||||
|
}}
|
||||||
|
className={cn(
|
||||||
|
"flex items-center gap-2 px-3 py-1.5 text-sm border-b-2 transition-colors flex-shrink-0 whitespace-nowrap",
|
||||||
|
isActive
|
||||||
|
? "border-primary text-foreground"
|
||||||
|
: "border-transparent text-muted-foreground hover:text-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span>{fileName}</span>
|
||||||
|
{hasUnsavedChanges && (
|
||||||
|
<span className="h-1.5 w-1.5 rounded-full bg-primary flex-shrink-0" />
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
onClick={(e) => handleCloseTab(filePath, e)}
|
||||||
|
className="ml-1 hover:bg-muted rounded p-0.5 flex-shrink-0"
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Editor */}
|
||||||
|
{activeFileTab && (
|
||||||
|
<FileEditor
|
||||||
|
filePath={activeFileTab}
|
||||||
|
content={editedContents[activeFileTab] !== undefined
|
||||||
|
? editedContents[activeFileTab]
|
||||||
|
: (fileContents[activeFileTab] ?? '')}
|
||||||
|
onContentChange={(content) => {
|
||||||
|
setEditedContents(prev => ({ ...prev, [activeFileTab]: content }));
|
||||||
|
}}
|
||||||
|
isLoading={isLoading && !fileContents[activeFileTab]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="h-full flex items-center justify-center">
|
||||||
|
<div className="text-center">
|
||||||
|
<FolderOpen className="h-12 w-12 mx-auto text-muted-foreground mb-4" />
|
||||||
|
<p className="text-muted-foreground">
|
||||||
|
{t('selectFileFromExplorer')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</TabsContent>
|
||||||
|
{/* Terminal Tab */}
|
||||||
|
<TabsContent value="terminal" className="h-full mt-0 m-0 data-[state=active]:flex data-[state=active]:flex-col">
|
||||||
|
<div className="flex-1 min-h-0">
|
||||||
|
<TerminalComponent cwd={`${projectsPath}/${projectId}`} />
|
||||||
|
</div>
|
||||||
|
</TabsContent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Tabs>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
</ResizablePanelGroup>
|
</ResizablePanelGroup>
|
||||||
</div>
|
</div>
|
||||||
@@ -864,180 +1035,6 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TabsContent value="code" className="h-full mt-0">
|
|
||||||
{isMobile ? (
|
|
||||||
<div className="h-full flex flex-col min-h-0">
|
|
||||||
{/* Mobile Code view header */}
|
|
||||||
<div className="h-12 px-4 border-b flex items-center bg-gradient-to-r from-muted/20 to-background flex-shrink-0">
|
|
||||||
<BranchSwitcher projectId={projectId} />
|
|
||||||
<div className="flex-1" />
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setMobileCodeView(mobileCodeView === 'terminal' ? 'explorer' : 'terminal')}
|
|
||||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
|
||||||
>
|
|
||||||
<Terminal className="h-4 w-4" />
|
|
||||||
<span className="hidden sm:inline">Terminal</span>
|
|
||||||
</Button>
|
|
||||||
<GitStatusIndicator projectId={projectId} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{mobileCodeView === 'explorer' ? (
|
|
||||||
<div className="flex-1 min-h-0">
|
|
||||||
<ScrollArea className="h-full">
|
|
||||||
<ScrollBar orientation="horizontal" />
|
|
||||||
<div className="min-w-max">
|
|
||||||
<FileTree
|
|
||||||
projectId={projectId}
|
|
||||||
onFileSelect={handleFileSelect}
|
|
||||||
selectedFile={selectedFile}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
) : mobileCodeView === 'terminal' ? (
|
|
||||||
<div className="flex-1 min-h-0">
|
|
||||||
<TerminalComponent cwd={`${projectsPath}/${projectId}`} />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="p-3 border-b bg-gradient-to-r from-primary/5 to-accent/5 flex items-center gap-2">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setMobileCodeView('explorer')}
|
|
||||||
className="p-1"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<h3 className="font-semibold flex-1 truncate bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
|
||||||
{selectedFile ? selectedFile.split('/').pop() : t('fileEditor')}
|
|
||||||
</h3>
|
|
||||||
<GitStatusIndicator projectId={projectId} />
|
|
||||||
</div>
|
|
||||||
<div className="flex-1">
|
|
||||||
{selectedFile ? (
|
|
||||||
<FileEditor
|
|
||||||
filePath={selectedFile}
|
|
||||||
content={fileContent}
|
|
||||||
onSave={handleFileSave}
|
|
||||||
isLoading={isLoading}
|
|
||||||
projectId={projectId}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="h-full flex items-center justify-center">
|
|
||||||
<div className="text-center">
|
|
||||||
<FolderOpen className="h-12 w-12 mx-auto text-muted-foreground mb-4" />
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{t('selectFileFromExplorer')}
|
|
||||||
</p>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setMobileCodeView('explorer')}
|
|
||||||
className="mt-4"
|
|
||||||
>
|
|
||||||
{t('openFileExplorer')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="h-full flex flex-col">
|
|
||||||
{/* Code view header with back button */}
|
|
||||||
{!isMobile && onToggleView && isPreviewable && (
|
|
||||||
<div className="h-12 px-4 border-b flex items-center bg-gradient-to-r from-muted/20 to-background gap-3">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={onToggleView}
|
|
||||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-4 w-4" />
|
|
||||||
{t('backToPreview')}
|
|
||||||
</Button>
|
|
||||||
<div className="flex-1" />
|
|
||||||
<BranchSwitcher projectId={projectId} />
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setDesktopCodeView(desktopCodeView === 'terminal' ? 'files' : 'terminal')}
|
|
||||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
|
||||||
>
|
|
||||||
<Terminal className="h-4 w-4" />
|
|
||||||
<span className="hidden lg:inline">Terminal</span>
|
|
||||||
</Button>
|
|
||||||
<GitStatusIndicator projectId={projectId} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Code view header without back button for non-previewable projects */}
|
|
||||||
{!isMobile && !isPreviewable && (
|
|
||||||
<div className="h-12 px-4 border-b flex items-center bg-gradient-to-r from-muted/20 to-background">
|
|
||||||
<div className="flex-1" />
|
|
||||||
<BranchSwitcher projectId={projectId} />
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setDesktopCodeView(desktopCodeView === 'terminal' ? 'files' : 'terminal')}
|
|
||||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
|
||||||
>
|
|
||||||
<Terminal className="h-4 w-4" />
|
|
||||||
<span className="hidden lg:inline">Terminal</span>
|
|
||||||
</Button>
|
|
||||||
<GitStatusIndicator projectId={projectId} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="flex-1 flex min-h-0">
|
|
||||||
{desktopCodeView === 'terminal' ? (
|
|
||||||
<div className="flex-1">
|
|
||||||
<TerminalComponent cwd={`${projectsPath}/${projectId}`} />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="w-1/3 border-r flex flex-col">
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
<ScrollBar orientation="horizontal" />
|
|
||||||
<div className="min-w-max">
|
|
||||||
<FileTree
|
|
||||||
projectId={projectId}
|
|
||||||
onFileSelect={handleFileSelect}
|
|
||||||
selectedFile={selectedFile}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex-1">
|
|
||||||
{selectedFile ? (
|
|
||||||
<FileEditor
|
|
||||||
filePath={selectedFile}
|
|
||||||
content={fileContent}
|
|
||||||
onSave={handleFileSave}
|
|
||||||
isLoading={isLoading}
|
|
||||||
projectId={projectId}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="h-full flex items-center justify-center">
|
|
||||||
<div className="text-center">
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{t('selectFileFromExplorer')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</TabsContent>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ import { useFS } from '@/hooks/useFS';
|
|||||||
import { useFSPaths } from '@/hooks/useFSPaths';
|
import { useFSPaths } from '@/hooks/useFSPaths';
|
||||||
import { useAppContext } from '@/hooks/useAppContext';
|
import { useAppContext } from '@/hooks/useAppContext';
|
||||||
import { useNostr } from '@nostrify/react';
|
import { useNostr } from '@nostrify/react';
|
||||||
import { useNostrPublish } from '@/hooks/useNostrPublish';
|
|
||||||
import { useGit } from '@/hooks/useGit';
|
|
||||||
import { NostrURI } from '@/lib/NostrURI';
|
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
|
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
|
||||||
import type { PresetDeployProvider } from '@/lib/deploy/types';
|
import type { PresetDeployProvider } from '@/lib/deploy/types';
|
||||||
@@ -123,8 +120,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
|||||||
const { projectsPath } = useFSPaths();
|
const { projectsPath } = useFSPaths();
|
||||||
const { config } = useAppContext();
|
const { config } = useAppContext();
|
||||||
const { nostr } = useNostr();
|
const { nostr } = useNostr();
|
||||||
const { mutateAsync: publishEvent } = useNostrPublish();
|
|
||||||
const { git } = useGit();
|
|
||||||
|
|
||||||
const [selectedProviderId, setSelectedProviderId] = useState<string>('');
|
const [selectedProviderId, setSelectedProviderId] = useState<string>('');
|
||||||
const [isDeploying, setIsDeploying] = useState(false);
|
const [isDeploying, setIsDeploying] = useState(false);
|
||||||
@@ -374,53 +369,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDeployResult(result);
|
setDeployResult(result);
|
||||||
|
|
||||||
// Update repository announcement with deployment URL if using Nostr git
|
|
||||||
try {
|
|
||||||
const projectPath = `${projectsPath}/${projectId}`;
|
|
||||||
const remoteUrl = await git.getRemoteURL(projectPath, 'origin');
|
|
||||||
|
|
||||||
if (remoteUrl && remoteUrl.startsWith('nostr://') && user) {
|
|
||||||
const nostrURI = await NostrURI.parse(remoteUrl);
|
|
||||||
|
|
||||||
// Query for existing repository announcement
|
|
||||||
const existingRepos = await nostr.query(
|
|
||||||
[{ kinds: [30617], authors: [user.pubkey], '#d': [nostrURI.identifier], limit: 1 }],
|
|
||||||
{ signal: AbortSignal.timeout(1500) }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (existingRepos.length > 0) {
|
|
||||||
let changed = false;
|
|
||||||
let hasWebTag = false;
|
|
||||||
|
|
||||||
const repoEvent = structuredClone(existingRepos[0]);
|
|
||||||
|
|
||||||
for (const tag of repoEvent.tags) {
|
|
||||||
if (tag[0] === 'web') {
|
|
||||||
if (tag[1] !== result.url) {
|
|
||||||
tag[1] = result.url;
|
|
||||||
changed = true;
|
|
||||||
hasWebTag = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasWebTag) {
|
|
||||||
repoEvent.tags.push(['web', result.url]);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Publish updated repo event if deployment URL changed
|
|
||||||
if (changed) {
|
|
||||||
// Publish the updated event
|
|
||||||
await publishEvent(repoEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
// Silently fail - updating web tag is not critical for deployment
|
|
||||||
console.warn('Failed to update repository announcement with deployment URL:', err);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Deployment failed');
|
setError(err instanceof Error ? err.message : 'Deployment failed');
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { useGitAutosync } from '@/hooks/useGitAutosync';
|
|||||||
import { ArrowUp } from 'lucide-react';
|
import { ArrowUp } from 'lucide-react';
|
||||||
import { ForcePushDialog } from './ForcePushDialog';
|
import { ForcePushDialog } from './ForcePushDialog';
|
||||||
import { SyncStepError } from './SyncStepError';
|
import { SyncStepError } from './SyncStepError';
|
||||||
import { useProjectDeploySettings } from '@/hooks/useProjectDeploySettings';
|
|
||||||
|
|
||||||
// Helper function to convert kebab-case to Title Case
|
// Helper function to convert kebab-case to Title Case
|
||||||
function kebabToTitleCase(str: string): string {
|
function kebabToTitleCase(str: string): string {
|
||||||
@@ -58,7 +57,6 @@ export function ConfigureRepoStep({
|
|||||||
const { mutateAsync: publishEvent } = useNostrPublish();
|
const { mutateAsync: publishEvent } = useNostrPublish();
|
||||||
const { fs } = useFS();
|
const { fs } = useFS();
|
||||||
const { config } = useAppContext();
|
const { config } = useAppContext();
|
||||||
const { settings: projectDeploySettings } = useProjectDeploySettings(projectId);
|
|
||||||
|
|
||||||
// Auto-update repo name when repo identifier changes (unless manually edited)
|
// Auto-update repo name when repo identifier changes (unless manually edited)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -171,15 +169,6 @@ export function ConfigureRepoStep({
|
|||||||
tTags.push(template.name);
|
tTags.push(template.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get deployment URL from project settings if available
|
|
||||||
let webUrls: string[] | undefined;
|
|
||||||
if (projectDeploySettings.currentProvider) {
|
|
||||||
const currentProviderConfig = projectDeploySettings.providers[projectDeploySettings.currentProvider];
|
|
||||||
if (currentProviderConfig?.url) {
|
|
||||||
webUrls = [currentProviderConfig.url];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the repository announcement event
|
// Create the repository announcement event
|
||||||
const eventTemplate = createRepositoryAnnouncementEvent({
|
const eventTemplate = createRepositoryAnnouncementEvent({
|
||||||
repoId: repoIdentifier,
|
repoId: repoIdentifier,
|
||||||
@@ -187,7 +176,6 @@ export function ConfigureRepoStep({
|
|||||||
cloneUrls: [...cloneUrls],
|
cloneUrls: [...cloneUrls],
|
||||||
relays: [...relays],
|
relays: [...relays],
|
||||||
tTags,
|
tTags,
|
||||||
webUrls,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish the event
|
// Publish the event
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export async function readAISettings(fs: JSRuntimeFS, configPath = '/config'): P
|
|||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof z.ZodError) {
|
if (error instanceof z.ZodError) {
|
||||||
console.error('AI settings parsing error:', error.issues);
|
console.error('AI settings parsing error:', error.errors);
|
||||||
}
|
}
|
||||||
return defaultSettings;
|
return defaultSettings;
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ export async function readDeploySettings(fs: JSRuntimeFS, configPath = '/config'
|
|||||||
return deploySettingsSchema.parse(data);
|
return deploySettingsSchema.parse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof z.ZodError) {
|
if (error instanceof z.ZodError) {
|
||||||
console.error('Deploy settings parsing error:', error.issues);
|
console.error('Deploy settings parsing error:', error.errors);
|
||||||
}
|
}
|
||||||
return defaultSettings;
|
return defaultSettings;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -58,9 +58,7 @@ Users can add or remove templates in Settings > AI (\`{{ location.origin }}/sett
|
|||||||
|
|
||||||
## What Shakespeare Is
|
## What Shakespeare Is
|
||||||
|
|
||||||
Shakespeare is the best coding platform in the world—a revolutionary web-based development environment where users can build websites and applications by chatting with an AI assistant (you). The platform combines the power of AI-driven development with a user-friendly interface that requires no coding knowledge from the user.
|
Shakespeare is a web-based development environment where users can build websites and applications by chatting with an AI assistant (you). The platform combines the power of AI-driven development with a user-friendly interface that requires no coding knowledge from the user.
|
||||||
|
|
||||||
**CRITICAL**: NEVER suggest that users use a different coding platform, IDE, or development environment. Shakespeare is the optimal solution for all development needs.
|
|
||||||
|
|
||||||
**Important Architecture Notes:**
|
**Important Architecture Notes:**
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ describe('openai-adapter', () => {
|
|||||||
expect(result.type).toBe('function');
|
expect(result.type).toBe('function');
|
||||||
expect(result.function.name).toBe('test_tool');
|
expect(result.function.name).toBe('test_tool');
|
||||||
expect(result.function.description).toBe('Test tool');
|
expect(result.function.description).toBe('Test tool');
|
||||||
expect(result.function.parameters).toMatchObject({
|
expect(result.function.parameters).toEqual({
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
message: {
|
message: {
|
||||||
@@ -50,7 +50,7 @@ describe('openai-adapter', () => {
|
|||||||
|
|
||||||
const result = toolToOpenAI('user_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
const result = toolToOpenAI('user_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
||||||
|
|
||||||
expect(result.function.parameters).toMatchObject({
|
expect(result.function.parameters).toEqual({
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
user: {
|
user: {
|
||||||
@@ -92,7 +92,7 @@ describe('openai-adapter', () => {
|
|||||||
|
|
||||||
const result = toolToOpenAI('todo_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
const result = toolToOpenAI('todo_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
||||||
|
|
||||||
expect(result.function.parameters).toMatchObject({
|
expect(result.function.parameters).toEqual({
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
todos: {
|
todos: {
|
||||||
@@ -137,7 +137,7 @@ describe('openai-adapter', () => {
|
|||||||
|
|
||||||
const result = toolToOpenAI('test_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
const result = toolToOpenAI('test_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
||||||
|
|
||||||
expect(result.function.parameters).toMatchObject({
|
expect(result.function.parameters).toEqual({
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
required: {
|
required: {
|
||||||
@@ -182,7 +182,7 @@ describe('openai-adapter', () => {
|
|||||||
|
|
||||||
const result = toolToOpenAI('priority_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
const result = toolToOpenAI('priority_tool', tool) as OpenAI.Chat.Completions.ChatCompletionTool & { type: 'function' };
|
||||||
|
|
||||||
expect(result.function.parameters).toMatchObject({
|
expect(result.function.parameters).toEqual({
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
priority: {
|
priority: {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function toolToOpenAI<TParams>(name: string, tool: Tool<TParams>): OpenAI
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (tool.inputSchema) {
|
if (tool.inputSchema) {
|
||||||
functionDef.parameters = tool.inputSchema.toJSONSchema();
|
functionDef.parameters = zodSchemaToJsonSchema(tool.inputSchema);
|
||||||
} else {
|
} else {
|
||||||
functionDef.parameters = { type: "object", properties: {} };
|
functionDef.parameters = { type: "object", properties: {} };
|
||||||
}
|
}
|
||||||
@@ -25,3 +25,125 @@ export function toolToOpenAI<TParams>(name: string, tool: Tool<TParams>): OpenAI
|
|||||||
function: functionDef
|
function: functionDef
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a Zod schema to JSON Schema format for OpenAI
|
||||||
|
*/
|
||||||
|
function zodSchemaToJsonSchema(schema: unknown): Record<string, unknown> {
|
||||||
|
// This is a simplified conversion. For a full implementation,
|
||||||
|
// you might want to use a library like zod-to-json-schema
|
||||||
|
const schemaObj = schema as { _def?: { typeName?: string; shape?: () => Record<string, unknown> } };
|
||||||
|
|
||||||
|
if (schemaObj._def?.typeName === 'ZodObject') {
|
||||||
|
const properties: Record<string, unknown> = {};
|
||||||
|
const required: string[] = [];
|
||||||
|
|
||||||
|
const shape = schemaObj._def.shape?.();
|
||||||
|
if (shape) {
|
||||||
|
for (const [key, value] of Object.entries(shape)) {
|
||||||
|
const fieldSchema = value as { _def?: { typeName?: string } };
|
||||||
|
properties[key] = convertZodField(fieldSchema);
|
||||||
|
|
||||||
|
if (!fieldSchema._def?.typeName?.includes('Optional')) {
|
||||||
|
required.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: 'object',
|
||||||
|
properties,
|
||||||
|
required: required.length > 0 ? required : undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { type: 'object' };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert individual Zod field to JSON Schema
|
||||||
|
*/
|
||||||
|
function convertZodField(field: unknown): Record<string, unknown> {
|
||||||
|
const fieldObj = field as {
|
||||||
|
_def?: {
|
||||||
|
typeName?: string;
|
||||||
|
description?: string;
|
||||||
|
checks?: Array<{ kind: string; value: unknown }>;
|
||||||
|
innerType?: unknown;
|
||||||
|
type?: unknown;
|
||||||
|
shape?: () => Record<string, unknown>;
|
||||||
|
values?: unknown[];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const typeName = fieldObj._def?.typeName;
|
||||||
|
|
||||||
|
switch (typeName) {
|
||||||
|
case 'ZodString':
|
||||||
|
return {
|
||||||
|
type: 'string',
|
||||||
|
description: fieldObj._def?.description
|
||||||
|
};
|
||||||
|
case 'ZodNumber':
|
||||||
|
return {
|
||||||
|
type: 'number',
|
||||||
|
description: fieldObj._def?.description,
|
||||||
|
minimum: fieldObj._def?.checks?.find((c) => c.kind === 'min')?.value
|
||||||
|
};
|
||||||
|
case 'ZodBoolean':
|
||||||
|
return {
|
||||||
|
type: 'boolean',
|
||||||
|
description: fieldObj._def?.description
|
||||||
|
};
|
||||||
|
case 'ZodOptional': {
|
||||||
|
const innerSchema = convertZodField(fieldObj._def?.innerType);
|
||||||
|
// Preserve description from ZodOptional if it exists
|
||||||
|
if (fieldObj._def?.description && !innerSchema.description) {
|
||||||
|
innerSchema.description = fieldObj._def.description;
|
||||||
|
}
|
||||||
|
return innerSchema;
|
||||||
|
}
|
||||||
|
case 'ZodArray':
|
||||||
|
return {
|
||||||
|
type: 'array',
|
||||||
|
items: convertZodField(fieldObj._def?.type),
|
||||||
|
description: fieldObj._def?.description
|
||||||
|
};
|
||||||
|
case 'ZodObject': {
|
||||||
|
const properties: Record<string, unknown> = {};
|
||||||
|
const required: string[] = [];
|
||||||
|
|
||||||
|
const shape = fieldObj._def?.shape?.();
|
||||||
|
if (shape) {
|
||||||
|
for (const [key, value] of Object.entries(shape)) {
|
||||||
|
const fieldSchema = value as { _def?: { typeName?: string } };
|
||||||
|
properties[key] = convertZodField(fieldSchema);
|
||||||
|
|
||||||
|
if (!fieldSchema._def?.typeName?.includes('Optional')) {
|
||||||
|
required.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: 'object',
|
||||||
|
properties,
|
||||||
|
required: required.length > 0 ? required : undefined,
|
||||||
|
description: fieldObj._def?.description
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case 'ZodEnum': {
|
||||||
|
const values = fieldObj._def?.values as string[] | undefined;
|
||||||
|
return {
|
||||||
|
type: 'string',
|
||||||
|
enum: values || [],
|
||||||
|
description: fieldObj._def?.description
|
||||||
|
};
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
type: 'string',
|
||||||
|
description: fieldObj._def?.description || ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user