fix(tui): normalize autocomplete attachments
This commit is contained in:
parent
f8c9bfd454
commit
53076999c5
@ -261,7 +261,7 @@ export function Autocomplete(props: {
|
|||||||
filename,
|
filename,
|
||||||
part: {
|
part: {
|
||||||
type: "file" as const,
|
type: "file" as const,
|
||||||
mime: item.mime,
|
mime: item.type === "directory" ? "application/x-directory" : "text/plain",
|
||||||
filename,
|
filename,
|
||||||
url: urlObj.href,
|
url: urlObj.href,
|
||||||
source: {
|
source: {
|
||||||
|
|||||||
@ -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: {
|
function UserMessage(props: {
|
||||||
message: UserMessage
|
message: UserMessage
|
||||||
parts: Part[]
|
parts: Part[]
|
||||||
@ -1417,14 +1407,12 @@ function UserMessage(props: {
|
|||||||
<box flexDirection="row" paddingBottom={metadataVisible() ? 1 : 0} paddingTop={1} gap={1} flexWrap="wrap">
|
<box flexDirection="row" paddingBottom={metadataVisible() ? 1 : 0} paddingTop={1} gap={1} flexWrap="wrap">
|
||||||
<For each={files()}>
|
<For each={files()}>
|
||||||
{(file) => {
|
{(file) => {
|
||||||
const bg = createMemo(() => {
|
const directory = file.mime === "application/x-directory"
|
||||||
if (file.mime.startsWith("image/")) return theme.accent
|
|
||||||
if (file.mime === "application/pdf") return theme.primary
|
|
||||||
return theme.secondary
|
|
||||||
})
|
|
||||||
return (
|
return (
|
||||||
<text fg={theme.text}>
|
<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>
|
<span style={{ bg: theme.backgroundElement, fg: theme.textMuted }}> {file.filename} </span>
|
||||||
</text>
|
</text>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user