From 66b18959ebc7b699a74ce69d3adfb4c4dcaa5fd1 Mon Sep 17 00:00:00 2001 From: Jay V Date: Mon, 26 May 2025 17:25:06 -0400 Subject: Merging docs and share app --- www/src/components/Header.astro | 57 ------- www/src/components/Hero.astro | 11 -- www/src/components/Lander.astro | 269 ------------------------------ www/src/components/Share.tsx | 353 ---------------------------------------- 4 files changed, 690 deletions(-) delete mode 100644 www/src/components/Header.astro delete mode 100644 www/src/components/Hero.astro delete mode 100644 www/src/components/Lander.astro delete mode 100644 www/src/components/Share.tsx (limited to 'www/src/components') diff --git a/www/src/components/Header.astro b/www/src/components/Header.astro deleted file mode 100644 index 85cdc2ea5..000000000 --- a/www/src/components/Header.astro +++ /dev/null @@ -1,57 +0,0 @@ ---- -import config from 'virtual:starlight/user-config'; -import { Icon } from '@astrojs/starlight/components'; -import { HeaderLinks } from 'toolbeam-docs-theme/components'; -import Default from 'toolbeam-docs-theme/overrides/Header.astro'; -import SiteTitle from '@astrojs/starlight/components/SiteTitle.astro'; - -const path = Astro.url.pathname; - -const links = config.social || []; ---- - -{ path.startsWith("/share/") - ?
-
- -
-
- -
-
- : -} - - - diff --git a/www/src/components/Hero.astro b/www/src/components/Hero.astro deleted file mode 100644 index f80f85266..000000000 --- a/www/src/components/Hero.astro +++ /dev/null @@ -1,11 +0,0 @@ ---- -import Default from '@astrojs/starlight/components/Hero.astro'; -import Lander from './Lander.astro'; - -const { slug } = Astro.locals.starlightRoute.entry; ---- - -{ slug === "" - ? - : -} diff --git a/www/src/components/Lander.astro b/www/src/components/Lander.astro deleted file mode 100644 index d27358f8f..000000000 --- a/www/src/components/Lander.astro +++ /dev/null @@ -1,269 +0,0 @@ ---- -import { Image } from 'astro:assets'; -import config from "virtual:starlight/user-config"; -import type { Props } from '@astrojs/starlight/props'; - -import CopyIcon from "../assets/lander/copy.svg"; -import CheckIcon from "../assets/lander/check.svg"; - -const { data } = Astro.locals.starlightRoute.entry; -const { title = data.title, tagline, image, actions = [] } = data.hero || {}; - -const imageAttrs = { - loading: 'eager' as const, - decoding: 'async' as const, - width: 400, - alt: image?.alt || '', -}; - -const github = config.social.filter(s => s.icon === 'github')[0]; - -const command = "npm i -g"; -const pkg = "opencode"; - -let darkImage: ImageMetadata | undefined; -let lightImage: ImageMetadata | undefined; -let rawHtml: string | undefined; -if (image) { - if ('file' in image) { - darkImage = image.file; - } else if ('dark' in image) { - darkImage = image.dark; - lightImage = image.light; - } else { - rawHtml = image.html; - } -} ---- -
-
- -

The AI coding agent built for the terminal.

-
- -
- -
- -
- -
- -
-
    -
  • Native TUI: A native terminal UI for a smoother, snappier experience.
  • -
  • LSP enabled: Loads the right LSPs for your codebase. Helps the LLM make fewer mistakes.
  • -
  • Multi-session: Start multiple conversations in a project to have agents working in parallel.
  • -
  • Use any model: Supports all the models from OpenAI, Anthropic, Google, OpenRouter, and more.
  • -
  • Change tracking: View the file changes from the current conversation in the sidebar.
  • -
  • Edit with Vim: Use Vim as an external editor to compose longer messages.
  • -
-
- - -
- - - - - - diff --git a/www/src/components/Share.tsx b/www/src/components/Share.tsx deleted file mode 100644 index 66748bcab..000000000 --- a/www/src/components/Share.tsx +++ /dev/null @@ -1,353 +0,0 @@ -import { createSignal, onCleanup, onMount, Show, For, createMemo } from "solid-js" - -type MessagePart = { - type: string - text?: string - [key: string]: any -} - -type MessageContent = { - role?: string - parts?: MessagePart[] - metadata?: { - time?: { - created?: number - } - } - [key: string]: any -} - -type Message = { - key: string - content: string -} - -type SessionInfo = { - tokens?: { - input?: number - output?: number - reasoning?: number - } -} - -export default function Share(props: { id: string, api: string }) { - const [messages, setMessages] = createSignal([]) - const [connectionStatus, setConnectionStatus] = createSignal("Disconnected") - const [sessionInfo, setSessionInfo] = createSignal(null) - - onMount(() => { - // Get the API URL from environment - const apiUrl = props.api - const shareId = props.id - - console.log("Mounting Share component with ID:", shareId) - console.log("API URL:", apiUrl) - - if (!shareId) { - console.error("Share ID not found in environment variables") - setConnectionStatus("Error: Share ID not found") - return - } - - if (!apiUrl) { - console.error("API URL not found in environment variables") - setConnectionStatus("Error: API URL not found") - return - } - - let reconnectTimer: number | undefined - let socket: WebSocket | null = null - - // Function to create and set up WebSocket with auto-reconnect - const setupWebSocket = () => { - // Close any existing connection - if (socket) { - socket.close() - } - - setConnectionStatus("Connecting...") - - // Always use secure WebSocket protocol (wss) - const wsBaseUrl = apiUrl.replace(/^https?:\/\//, "wss://") - const wsUrl = `${wsBaseUrl}/share_poll?shareID=${shareId}` - console.log("Connecting to WebSocket URL:", wsUrl) - - // Create WebSocket connection - socket = new WebSocket(wsUrl) - - // Handle connection opening - socket.onopen = () => { - setConnectionStatus("Connected") - console.log("WebSocket connection established") - } - - // Handle incoming messages - socket.onmessage = (event) => { - console.log("WebSocket message received") - try { - const data = JSON.parse(event.data) as Message - - // Check if this is a session info message - if (data.key.startsWith("session/info/")) { - try { - const infoContent = JSON.parse(data.content) as SessionInfo; - setSessionInfo(infoContent); - console.log("Session info updated:", infoContent); - } catch (e) { - console.error("Error parsing session info:", e); - } - } else { - // For all other messages - setMessages((prev) => { - // Check if message with this key already exists - const existingIndex = prev.findIndex(msg => msg.key === data.key) - - if (existingIndex >= 0) { - // Update existing message - const updated = [...prev] - updated[existingIndex] = data - return updated - } else { - // Add new message - return [...prev, data] - } - }) - } - } catch (error) { - console.error("Error parsing WebSocket message:", error) - } - } - - // Handle errors - socket.onerror = (error) => { - console.error("WebSocket error:", error) - setConnectionStatus("Error: Connection failed") - } - - // Handle connection close and reconnection - socket.onclose = (event) => { - console.log(`WebSocket closed: ${event.code} ${event.reason}`) - setConnectionStatus("Disconnected, reconnecting...") - - // Try to reconnect after 2 seconds - clearTimeout(reconnectTimer) - reconnectTimer = window.setTimeout( - setupWebSocket, - 2000, - ) as unknown as number - } - } - - // Initial connection - setupWebSocket() - - // Clean up on component unmount - onCleanup(() => { - console.log("Cleaning up WebSocket connection") - if (socket) { - socket.close() - } - clearTimeout(reconnectTimer) - }) - }) - - return ( -
-

Share: {props.id}

- -
-

WebSocket Connection

-

- Status: {connectionStatus()} -

- -

Live Updates

- - -
-

Session Information

-
-
- Input Tokens: {sessionInfo()?.tokens?.input || 0} -
-
- Output Tokens: {sessionInfo()?.tokens?.output || 0} -
-
- Reasoning Tokens: {sessionInfo()?.tokens?.reasoning || 0} -
-
-
-
- -
- 0} - fallback={

Waiting for messages...

} - > -
    - - {(msg) => ( -
  • -
    - Key: {msg.key} -
    - - {(() => { - try { - const parsed = JSON.parse(msg.content) as MessageContent; - const createdTime = parsed.metadata?.time?.created - ? new Date(parsed.metadata.time.created).toLocaleString() - : 'Unknown time'; - - return ( - <> -
    - Full Content: -
    -                                {JSON.stringify(parsed, null, 2)}
    -                              
    -
    - - {parsed.parts && parsed.parts.length > 0 && ( -
    -
    - Role: {parsed.role || 'Unknown'} - - {createdTime} - -
    - -
    - - {(part, index) => ( -
    - {part.type === "text" ? ( -
    -                                            {part.text}
    -                                          
    - ) : ( -
    -
    - Part type: {part.type} -
    -
    -                                              {JSON.stringify(part, null, 2)}
    -                                            
    -
    - )} -
    - )} -
    -
    -
    - )} - - ); - } catch (e) { - return ( -
    - Content: -
    -                              {msg.content}
    -                            
    -
    - ); - } - })()} -
  • - )} -
    -
-
-
-
-
- ) -} - -- cgit v1.2.3