fix(ui): label reverted attachments by mime

input-cleanup
David Hill 2026-03-20 13:11:18 +00:00
parent 085f66daed
commit 1594fb962f
2 changed files with 24 additions and 3 deletions

View File

@ -1324,9 +1324,22 @@ export default function Page() {
attachmentName: language.t("common.attachment"),
})
const tag = (mime: string | undefined) => {
if (mime === "application/pdf") return "pdf"
if (mime?.startsWith("image/")) return "image"
return "file"
}
const chip = (part: { filename: string; mime: string }) => `[${tag(part.mime)}:${part.filename}]`
const line = (id: string) => {
const text = draft(id)
.map((part) => (part.type === "image" ? `[image:${part.filename}]` : part.content))
.map((part) => {
if (part.type === "image") return chip(part)
if (part.type === "file") return `[file:${part.path}]`
if (part.type === "agent") return `@${part.name}`
return part.content
})
.join("")
.replace(/\s+/g, " ")
.trim()
@ -1394,7 +1407,7 @@ export default function Page() {
const followupText = (item: FollowupDraft) => {
const text = item.prompt
.map((part) => {
if (part.type === "image") return `[image:${part.filename}]`
if (part.type === "image") return chip(part)
if (part.type === "file") return `[file:${part.path}]`
if (part.type === "agent") return `@${part.name}`
return part.content

View File

@ -46,6 +46,14 @@ export function SessionComposerRegion(props: {
const language = useLanguage()
const route = useSessionKey()
const tag = (mime: string) => {
if (mime === "application/pdf") return "pdf"
if (mime.startsWith("image/")) return "image"
return "file"
}
const chip = (part: { filename: string; mime: string }) => `[${tag(part.mime)}:${part.filename}]`
const handoffPrompt = createMemo(() => getSessionHandoff(route.sessionKey())?.prompt)
const previewPrompt = () =>
@ -54,7 +62,7 @@ export function SessionComposerRegion(props: {
.map((part) => {
if (part.type === "file") return `[file:${part.path}]`
if (part.type === "agent") return `@${part.name}`
if (part.type === "image") return `[image:${part.filename}]`
if (part.type === "image") return chip(part)
return part.content
})
.join("")