fix(tui): normalize autocomplete attachments

This commit is contained in:
Dax Raad 2026-06-23 21:41:14 -04:00
parent f8c9bfd454
commit 53076999c5
2 changed files with 5 additions and 17 deletions

View File

@ -261,7 +261,7 @@ export function Autocomplete(props: {
filename,
part: {
type: "file" as const,
mime: item.mime,
mime: item.type === "directory" ? "application/x-directory" : "text/plain",
filename,
url: urlObj.href,
source: {

View File

@ -1347,16 +1347,6 @@ export function Session() {
)
}
const MIME_BADGE: Record<string, string> = {
"text/plain": "txt",
"image/png": "img",
"image/jpeg": "img",
"image/gif": "img",
"image/webp": "img",
"application/pdf": "pdf",
"application/x-directory": "dir",
}
function UserMessage(props: {
message: UserMessage
parts: Part[]
@ -1417,14 +1407,12 @@ function UserMessage(props: {
<box flexDirection="row" paddingBottom={metadataVisible() ? 1 : 0} paddingTop={1} gap={1} flexWrap="wrap">
<For each={files()}>
{(file) => {
const bg = createMemo(() => {
if (file.mime.startsWith("image/")) return theme.accent
if (file.mime === "application/pdf") return theme.primary
return theme.secondary
})
const directory = file.mime === "application/x-directory"
return (
<text fg={theme.text}>
<span style={{ bg: bg(), fg: theme.background }}> {MIME_BADGE[file.mime] ?? file.mime} </span>
<span style={{ bg: theme.secondary, fg: theme.background }}>
{directory ? " Directory " : " File "}
</span>
<span style={{ bg: theme.backgroundElement, fg: theme.textMuted }}> {file.filename} </span>
</text>
)