From 0ce7d92a8b67c5660669b7850d758131d39b076d Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 11 Aug 2025 16:12:26 -0400 Subject: ignore: fix share page --- packages/opencode/src/provider/provider.ts | 2 +- packages/web/package.json | 2 +- packages/web/src/components/Share.tsx | 391 +++++++++++++++-------------- 3 files changed, 203 insertions(+), 192 deletions(-) (limited to 'packages') diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 184b938da..c72ae7ef3 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -448,7 +448,7 @@ export namespace Provider { } } - const priority = ["gemini-2.5-pro-preview", "codex-mini", "claude-sonnet-4"] + const priority = ["gemini-2.5-pro-preview", "gpt-5", "claude-sonnet-4"] export function sort(models: ModelsDev.Model[]) { return sortBy( models, diff --git a/packages/web/package.json b/packages/web/package.json index a60f38dba..d3c8baaab 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/cloudflare": "^12.5.4", + "@astrojs/cloudflare": "12.6.3", "@astrojs/markdown-remark": "6.3.1", "@astrojs/solid-js": "5.1.0", "@astrojs/starlight": "0.34.3", diff --git a/packages/web/src/components/Share.tsx b/packages/web/src/components/Share.tsx index 646ee7710..2b0e52c1a 100644 --- a/packages/web/src/components/Share.tsx +++ b/packages/web/src/components/Share.tsx @@ -1,7 +1,6 @@ import { For, Show, onMount, Suspense, onCleanup, createMemo, createSignal, SuspenseList, createEffect } from "solid-js" import { DateTime } from "luxon" import { createStore, reconcile, unwrap } from "solid-js/store" -import { mapValues } from "remeda" import { IconArrowDown } from "./icons" import { IconOpencode } from "./icons/custom" import styles from "./share.module.css" @@ -42,7 +41,6 @@ export default function Share(props: { id: string api: string info: Session.Info - messages: Record }) { let lastScrollY = 0 let hasScrolledToAnchor = false @@ -50,7 +48,6 @@ export default function Share(props: { let scrollSentinel: HTMLElement | undefined let scrollObserver: IntersectionObserver | undefined - const id = props.id const params = new URLSearchParams(window.location.search) const debug = params.get("debug") === "true" @@ -61,17 +58,27 @@ export default function Share(props: { const [store, setStore] = createStore<{ info?: Session.Info messages: Record - }>({ info: props.info, messages: {} }) + }>({ + info: { + id: props.id, + title: props.info.title, + version: props.info.version, + time: { + created: props.info.time.created, + updated: props.info.time.updated, + }, + }, messages: {} + }) const messages = createMemo(() => Object.values(store.messages).toSorted((a, b) => a.id?.localeCompare(b.id))) const [connectionStatus, setConnectionStatus] = createSignal<[Status, string?]>(["disconnected", "Disconnected"]) - // createEffect(() => { - // console.log(unwrap(store)) - // }) + createEffect(() => { + console.log(unwrap(store)) + }) onMount(() => { const apiUrl = props.api - if (!id) { + if (!props.id) { setConnectionStatus(["error", "id not found"]) return } @@ -96,7 +103,7 @@ export default function Share(props: { // Always use secure WebSocket protocol (wss) const wsBaseUrl = apiUrl.replace(/^https?:\/\//, "wss://") - const wsUrl = `${wsBaseUrl}/share_poll?id=${id}` + const wsUrl = `${wsBaseUrl}/share_poll?id=${props.id}` console.log("Connecting to WebSocket URL:", wsUrl) // Create WebSocket connection @@ -261,7 +268,9 @@ export default function Share(props: { }, } - result.created = props.info.time.created + if (!store.info) return result + + result.created = store.info.time.created const msgs = messages() for (let i = 0; i < msgs.length; i++) { @@ -290,197 +299,199 @@ export default function Share(props: { }) return ( -
-
-

{store.info?.title}

-
-
    -
  • -
    - -
    - - v{store.info?.version} - -
  • - {Object.values(data().models).length > 0 ? ( - - {([provider, model]) => ( -
  • -
    - -
    - {model} -
  • - )} -
    - ) : ( -
  • - Models - + +
    +
    +

    {store.info?.title}

    +
    +
      +
    • +
      + +
      + + v{store.info?.version} +
    • - )} -
    -
    - {DateTime.fromMillis(data().created || 0).toLocaleString(DateTime.DATETIME_MED)} + {Object.values(data().models).length > 0 ? ( + + {([provider, model]) => ( +
  • +
    + +
    + {model} +
  • + )} +
    + ) : ( +
  • + Models + +
  • + )} +
+
+ {DateTime.fromMillis(data().created || 0).toLocaleString(DateTime.DATETIME_MED)} +
- - -
- 0} fallback={

Waiting for messages...

}> -
- - - {(msg, msgIndex) => { - const filteredParts = createMemo(() => - msg.parts.filter((x, index) => { - if (x.type === "step-start" && index > 0) return false - if (x.type === "snapshot") return false - if (x.type === "patch") return false - if (x.type === "step-finish") return false - if (x.type === "text" && x.synthetic === true) return false - if (x.type === "tool" && x.tool === "todoread") return false - if (x.type === "text" && !x.text) return false - if (x.type === "tool" && (x.state.status === "pending" || x.state.status === "running")) - return false - return true - }), - ) - - return ( - - - {(part, partIndex) => { - const last = createMemo( - () => - data().messages.length === msgIndex() + 1 && filteredParts().length === partIndex() + 1, - ) - - onMount(() => { - const hash = window.location.hash.slice(1) - // Wait till all parts are loaded - if ( - hash !== "" && - !hasScrolledToAnchor && - filteredParts().length === partIndex() + 1 && - data().messages.length === msgIndex() + 1 - ) { - hasScrolledToAnchor = true - scrollToAnchor(hash) - } - }) - - return - }} - - - ) - }} - - -
-
- + +
+ 0} fallback={

Waiting for messages...

}> +
+ + + {(msg, msgIndex) => { + const filteredParts = createMemo(() => + msg.parts.filter((x, index) => { + if (x.type === "step-start" && index > 0) return false + if (x.type === "snapshot") return false + if (x.type === "patch") return false + if (x.type === "step-finish") return false + if (x.type === "text" && x.synthetic === true) return false + if (x.type === "tool" && x.tool === "todoread") return false + if (x.type === "text" && !x.text) return false + if (x.type === "tool" && (x.state.status === "pending" || x.state.status === "running")) + return false + return true + }), + ) + + return ( + + + {(part, partIndex) => { + const last = createMemo( + () => + data().messages.length === msgIndex() + 1 && filteredParts().length === partIndex() + 1, + ) + + onMount(() => { + const hash = window.location.hash.slice(1) + // Wait till all parts are loaded + if ( + hash !== "" && + !hasScrolledToAnchor && + filteredParts().length === partIndex() + 1 && + data().messages.length === msgIndex() + 1 + ) { + hasScrolledToAnchor = true + scrollToAnchor(hash) + } + }) + + return + }} + + + ) + }} + + +
+
+ +
+
+

{getStatusText(connectionStatus())}

+
    +
  • + Cost + {data().cost !== undefined ? ( + ${data().cost.toFixed(2)} + ) : ( + + )} +
  • +
  • + Input Tokens + {data().tokens.input ? {data().tokens.input} : } +
  • +
  • + Output Tokens + {data().tokens.output ? {data().tokens.output} : } +
  • +
  • + Reasoning Tokens + {data().tokens.reasoning ? ( + {data().tokens.reasoning} + ) : ( + + )} +
  • +
+
-
-

{getStatusText(connectionStatus())}

-
    -
  • - Cost - {data().cost !== undefined ? ( - ${data().cost.toFixed(2)} - ) : ( - - )} -
  • -
  • - Input Tokens - {data().tokens.input ? {data().tokens.input} : } -
  • -
  • - Output Tokens - {data().tokens.output ? {data().tokens.output} : } -
  • -
  • - Reasoning Tokens - {data().tokens.reasoning ? ( - {data().tokens.reasoning} - ) : ( - +
+ +
+ + +
+
+ 0} fallback={

Waiting for messages...

}> +
    + + {(msg) => ( +
  • +
    + Key: {msg.id} +
    +
    {JSON.stringify(msg, null, 2)}
    +
  • )} - +
-
+
-
- - -
-
+
-
-
- - - - -
+ + + + + ) } -- cgit v1.2.3