mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 02:04:22 +01:00
wip: desktop work
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.svg" />
|
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.svg" />
|
||||||
<title>OpenCode</title>
|
<title>OpenCode</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="overscroll-none select-none text-12-regular">
|
<body class="antialiased overscroll-none select-none text-12-regular">
|
||||||
<!-- <script> -->
|
<!-- <script> -->
|
||||||
<!-- ;(function () { -->
|
<!-- ;(function () { -->
|
||||||
<!-- const savedTheme = localStorage.getItem("theme") || "opencode" -->
|
<!-- const savedTheme = localStorage.getItem("theme") || "opencode" -->
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { Part, AssistantMessage, ReasoningPart, TextPart, ToolPart } from "@opencode-ai/sdk"
|
import type { Part, AssistantMessage, ReasoningPart, TextPart, ToolPart } from "@opencode-ai/sdk"
|
||||||
import type { Tool } from "opencode/tool/tool"
|
|
||||||
import type { ReadTool } from "opencode/tool/read"
|
|
||||||
import { children, Component, createMemo, For, Match, Show, Switch, type JSX } from "solid-js"
|
import { children, Component, createMemo, For, Match, Show, Switch, type JSX } from "solid-js"
|
||||||
import { Dynamic } from "solid-js/web"
|
import { Dynamic } from "solid-js/web"
|
||||||
import { Markdown } from "./markdown"
|
import { Markdown } from "./markdown"
|
||||||
import { Collapsible, Icon, IconProps } from "@opencode-ai/ui"
|
import { Collapsible, Icon, IconProps } from "@opencode-ai/ui"
|
||||||
import { getDirectory, getFilename } from "@/utils"
|
import { getDirectory, getFilename } from "@/utils"
|
||||||
|
import type { Tool } from "opencode/tool/tool"
|
||||||
|
import type { ReadTool } from "opencode/tool/read"
|
||||||
import type { ListTool } from "opencode/tool/ls"
|
import type { ListTool } from "opencode/tool/ls"
|
||||||
import type { GlobTool } from "opencode/tool/glob"
|
import type { GlobTool } from "opencode/tool/glob"
|
||||||
import type { GrepTool } from "opencode/tool/grep"
|
import type { GrepTool } from "opencode/tool/grep"
|
||||||
@@ -188,7 +188,7 @@ ToolRegistry.register<typeof ListTool>({
|
|||||||
name: "list",
|
name: "list",
|
||||||
render(props) {
|
render(props) {
|
||||||
return (
|
return (
|
||||||
<BasicTool icon="bullet-list" trigger={{ title: props.tool, subtitle: props.input.path || "/" }}>
|
<BasicTool icon="bullet-list" trigger={{ title: props.tool, subtitle: getDirectory(props.input.path || "/") }}>
|
||||||
<Show when={false && props.output}>
|
<Show when={false && props.output}>
|
||||||
<div class="whitespace-pre">{props.output}</div>
|
<div class="whitespace-pre">{props.output}</div>
|
||||||
</Show>
|
</Show>
|
||||||
@@ -205,7 +205,7 @@ ToolRegistry.register<typeof GlobTool>({
|
|||||||
icon="magnifying-glass-menu"
|
icon="magnifying-glass-menu"
|
||||||
trigger={{
|
trigger={{
|
||||||
title: props.tool,
|
title: props.tool,
|
||||||
subtitle: props.input.path || "/",
|
subtitle: getDirectory(props.input.path || "/"),
|
||||||
args: props.input.pattern ? ["pattern=" + props.input.pattern] : [],
|
args: props.input.pattern ? ["pattern=" + props.input.pattern] : [],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -228,7 +228,7 @@ ToolRegistry.register<typeof GrepTool>({
|
|||||||
icon="magnifying-glass-menu"
|
icon="magnifying-glass-menu"
|
||||||
trigger={{
|
trigger={{
|
||||||
title: props.tool,
|
title: props.tool,
|
||||||
subtitle: props.input.path || "/",
|
subtitle: getDirectory(props.input.path || "/"),
|
||||||
args,
|
args,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -315,7 +315,7 @@ ToolRegistry.register<typeof EditTool>({
|
|||||||
<div class="text-12-medium text-text-base capitalize">Edit</div>
|
<div class="text-12-medium text-text-base capitalize">Edit</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<Show when={props.input.filePath?.includes("/")}>
|
<Show when={props.input.filePath?.includes("/")}>
|
||||||
<span class="text-text-weak">{getDirectory(props.input.filePath!)}/</span>
|
<span class="text-text-weak">{getDirectory(props.input.filePath!)}</span>
|
||||||
</Show>
|
</Show>
|
||||||
<span class="text-text-strong">{getFilename(props.input.filePath ?? "")}</span>
|
<span class="text-text-strong">{getFilename(props.input.filePath ?? "")}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -344,7 +344,7 @@ ToolRegistry.register<typeof WriteTool>({
|
|||||||
<div class="text-12-medium text-text-base capitalize">Write</div>
|
<div class="text-12-medium text-text-base capitalize">Write</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<Show when={props.input.filePath?.includes("/")}>
|
<Show when={props.input.filePath?.includes("/")}>
|
||||||
<span class="text-text-weak">{getDirectory(props.input.filePath!)}/</span>
|
<span class="text-text-weak">{getDirectory(props.input.filePath!)}</span>
|
||||||
</Show>
|
</Show>
|
||||||
<span class="text-text-strong">{getFilename(props.input.filePath ?? "")}</span>
|
<span class="text-text-strong">{getFilename(props.input.filePath ?? "")}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
<FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" />
|
<FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" />
|
||||||
<div class="flex items-center text-14-regular">
|
<div class="flex items-center text-14-regular">
|
||||||
<span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0">
|
<span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0">
|
||||||
{getDirectory(i)}/
|
{getDirectory(i)}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span>
|
<span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ export default function Page() {
|
|||||||
<div class="flex justify-center items-center gap-3">
|
<div class="flex justify-center items-center gap-3">
|
||||||
<Icon name="folder" size="small" />
|
<Icon name="folder" size="small" />
|
||||||
<div class="text-12-medium text-text-weak">
|
<div class="text-12-medium text-text-weak">
|
||||||
{getDirectory(sync.data.path.directory)}/
|
{getDirectory(sync.data.path.directory)}
|
||||||
<span class="text-text-strong">{getFilename(sync.data.path.directory)}</span>
|
<span class="text-text-strong">{getFilename(sync.data.path.directory)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -705,7 +705,7 @@ export default function Page() {
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<Show when={diff.file.includes("/")}>
|
<Show when={diff.file.includes("/")}>
|
||||||
<span class="text-text-base">
|
<span class="text-text-base">
|
||||||
{getDirectory(diff.file)}/
|
{getDirectory(diff.file)}
|
||||||
</span>
|
</span>
|
||||||
</Show>
|
</Show>
|
||||||
<span class="text-text-strong">
|
<span class="text-text-strong">
|
||||||
@@ -858,7 +858,7 @@ export default function Page() {
|
|||||||
<FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" />
|
<FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" />
|
||||||
<div class="flex items-center text-14-regular">
|
<div class="flex items-center text-14-regular">
|
||||||
<span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0">
|
<span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0">
|
||||||
{getDirectory(i)}/
|
{getDirectory(i)}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span>
|
<span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { useSync } from "@/context/sync"
|
||||||
|
|
||||||
export function getFilename(path: string) {
|
export function getFilename(path: string) {
|
||||||
if (!path) return ""
|
if (!path) return ""
|
||||||
const trimmed = path.replace(/[\/]+$/, "")
|
const trimmed = path.replace(/[\/]+$/, "")
|
||||||
@@ -6,8 +8,10 @@ export function getFilename(path: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getDirectory(path: string) {
|
export function getDirectory(path: string) {
|
||||||
|
const sync = useSync()
|
||||||
const parts = path.split("/")
|
const parts = path.split("/")
|
||||||
return parts.slice(0, parts.length - 1).join("/")
|
const dir = parts.slice(0, parts.length - 1).join("/")
|
||||||
|
return dir ? sync.sanitize(dir + "/") : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFileExtension(path: string) {
|
export function getFileExtension(path: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user