From dc6e54503cb400ea2533740c9a92d09c8a50d077 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 30 Oct 2025 13:49:29 -0500 Subject: wip: desktop work --- packages/desktop/src/components/code.tsx | 2 +- packages/desktop/src/components/markdown.tsx | 23 -- packages/desktop/src/components/message.tsx | 304 --------------------------- 3 files changed, 1 insertion(+), 328 deletions(-) delete mode 100644 packages/desktop/src/components/markdown.tsx delete mode 100644 packages/desktop/src/components/message.tsx (limited to 'packages/desktop/src/components') diff --git a/packages/desktop/src/components/code.tsx b/packages/desktop/src/components/code.tsx index 11518e73a..c214fd5e6 100644 --- a/packages/desktop/src/components/code.tsx +++ b/packages/desktop/src/components/code.tsx @@ -2,7 +2,7 @@ import { bundledLanguages, type BundledLanguage, type ShikiTransformer } from "s import { splitProps, type ComponentProps, createEffect, onMount, onCleanup, createMemo, createResource } from "solid-js" import { useLocal, type TextSelection } from "@/context/local" import { getFileExtension, getNodeOffsetInLine, getSelectionInContainer } from "@/utils" -import { useShiki } from "@/context/shiki" +import { useShiki } from "@opencode-ai/ui" type DefinedSelection = Exclude diff --git a/packages/desktop/src/components/markdown.tsx b/packages/desktop/src/components/markdown.tsx deleted file mode 100644 index e0f185f5f..000000000 --- a/packages/desktop/src/components/markdown.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { useMarked } from "@/context/marked" -import { createResource } from "solid-js" - -function strip(text: string): string { - const wrappedRe = /^\s*<([A-Za-z]\w*)>\s*([\s\S]*?)\s*<\/\1>\s*$/ - const match = text.match(wrappedRe) - return match ? match[2] : text -} -export function Markdown(props: { text: string; class?: string }) { - const marked = useMarked() - const [html] = createResource( - () => strip(props.text), - async (markdown) => { - return marked.parse(markdown) - }, - ) - return ( -
- ) -} diff --git a/packages/desktop/src/components/message.tsx b/packages/desktop/src/components/message.tsx deleted file mode 100644 index 70d03591a..000000000 --- a/packages/desktop/src/components/message.tsx +++ /dev/null @@ -1,304 +0,0 @@ -import type { Part, TextPart, ToolPart, Message } from "@opencode-ai/sdk" -import { createMemo, For, Match, Show, Switch } from "solid-js" -import { Dynamic } from "solid-js/web" -import { Markdown } from "./markdown" -import { Card, Checkbox, Diff, Icon } from "@opencode-ai/ui" -import { Message as MessageDisplay, registerPartComponent } from "@opencode-ai/ui" -import { BasicTool, GenericTool, ToolRegistry, DiffChanges } from "@opencode-ai/ui" -import { getDirectory, getFilename } from "@/utils" - -export function Message(props: { message: Message; parts: Part[] }) { - return -} - -registerPartComponent("text", function TextPartDisplay(props) { - const part = props.part as TextPart - return ( - - - - ) -}) - -registerPartComponent("reasoning", function ReasoningPartDisplay(props) { - const part = props.part as any - return ( - - - - ) -}) - -registerPartComponent("tool", function ToolPartDisplay(props) { - const part = props.part as ToolPart - const component = createMemo(() => { - const render = ToolRegistry.render(part.tool) ?? GenericTool - const metadata = part.state.status === "pending" ? {} : (part.state.metadata ?? {}) - const input = part.state.status === "completed" ? part.state.input : {} - - return ( - - - {(error) => { - const cleaned = error().replace("Error: ", "") - const [title, ...rest] = cleaned.split(": ") - return ( - -
- - - -
-
{title}
- {rest.join(": ")} -
-
- {cleaned} -
-
-
- ) - }} -
- - - -
- ) - }) - - return {component()} -}) - -ToolRegistry.register({ - name: "read", - render(props) { - return ( - - ) - }, -}) - -ToolRegistry.register({ - name: "list", - render(props) { - return ( - - -
{props.output}
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "glob", - render(props) { - return ( - {props.output}
- - - ) - }, -}) - -ToolRegistry.register({ - name: "grep", - render(props) { - const args = [] - if (props.input.pattern) args.push("pattern=" + props.input.pattern) - if (props.input.include) args.push("include=" + props.input.include) - return ( - - -
{props.output}
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "webfetch", - render(props) { - return ( - - - - ), - }} - > - -
{props.output}
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "task", - render(props) { - return ( - - -
{props.output}
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "bash", - render(props) { - return ( - - -
{props.output}
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "edit", - render(props) { - return ( - -
-
Edit
-
- - {getDirectory(props.input.filePath!)} - - {getFilename(props.input.filePath ?? "")} -
-
-
- - - -
- - } - > - -
- -
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "write", - render(props) { - return ( - -
-
Write
-
- - {getDirectory(props.input.filePath!)} - - {getFilename(props.input.filePath ?? "")} -
-
-
{/* */}
- - } - > - -
{props.output}
-
-
- ) - }, -}) - -ToolRegistry.register({ - name: "todowrite", - render(props) { - return ( - t.status === "completed").length}/${props.input.todos?.length}`, - }} - > - -
- - {(todo: any) => ( - -
{todo.content}
-
- )} -
-
-
-
- ) - }, -}) -- cgit v1.2.3