import { Component, For, Match, Show, Switch } from "solid-js" import { FileIcon } from "@opencode-ai/ui/file-icon" import { Icon } from "@opencode-ai/ui/icon" import { Tag } from "@opencode-ai/ui/v2/badge-v2" import { KeybindV2 } from "@opencode-ai/ui/v2/keybind-v2" import { getDirectory, getFilename } from "@opencode-ai/core/util/path" export type AtOption = | { type: "agent"; name: string; display: string } | { type: "resource" name: string uri: string client: string display: string description?: string mime?: string } | { type: "reference"; name: string; path: string; display: string; description: string } | { type: "file"; path: string; display: string; recent?: boolean } export interface SlashCommand { id: string trigger: string title: string description?: string keybind?: string type: "builtin" | "custom" source?: "command" | "mcp" | "skill" } type PromptPopoverProps = { popover: "at" | "slash" | null setSlashPopoverRef: (el: HTMLDivElement) => void atFlat: AtOption[] atActive?: string atKey: (item: AtOption) => string setAtActive: (id: string) => void onAtSelect: (item: AtOption) => void slashFlat: SlashCommand[] slashActive?: string setSlashActive: (id: string) => void onSlashSelect: (item: SlashCommand) => void commandKeybind: (id: string) => string | undefined commandKeybindParts: (id: string) => string[] newLayoutDesigns: boolean t: (key: string) => string } export const PromptPopover: Component = (props) => { return (
{ if (props.popover === "slash") props.setSlashPopoverRef(el) }} class="absolute inset-x-0 -top-2 -translate-y-full origin-bottom-left max-h-80 min-h-10 overflow-auto no-scrollbar flex flex-col p-2" classList={{ "z-[70] rounded-[10px] bg-v2-background-bg-base shadow-[var(--v2-elevation-raised)]": props.newLayoutDesigns, "rounded-[12px] bg-surface-raised-stronger-non-alpha shadow-[var(--shadow-lg-border-base)]": !props.newLayoutDesigns, }} onMouseDown={(e) => e.preventDefault()} > 0} fallback={
{props.t("prompt.popover.emptyResults")}
} > {(item) => { const key = props.atKey(item) if (item.type === "agent") { return ( ) } if (item.type === "resource") { return ( ) } if (item.type === "reference") { return ( ) } const isDirectory = item.path.endsWith("/") const directory = isDirectory ? item.path : getDirectory(item.path) const filename = isDirectory ? "" : getFilename(item.path) return ( ) }}
0} fallback={
{props.t("prompt.popover.emptyCommands")}
} > {(cmd) => { const keybind = () => props.commandKeybind(cmd.id) const keybindParts = () => props.commandKeybindParts(cmd.id) return ( ) }}
) }