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 { getDirectory, getFilename } from "@opencode-ai/core/util/path" export type AtOption = | { type: "agent"; name: string; display: 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 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 rounded-[12px] bg-surface-raised-stronger-non-alpha shadow-[var(--shadow-lg-border-base)]" onMouseDown={(e) => e.preventDefault()} > 0} fallback={
{props.t("prompt.popover.emptyResults")}
} > {(item) => { const key = props.atKey(item) if (item.type === "agent") { 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) => ( )}
) }