feat(web): add lightweight workspace matching existing UI
This commit is contained in:
+1
-42
@@ -411,48 +411,7 @@ export async function deleteSearch(searchId: string) {
|
||||
await api<{ deleted: true }>(`/v1/searches/${searchId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function getMessageAttachments(metadata: unknown): ChatAttachment[] {
|
||||
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) return [];
|
||||
const attachments = (metadata as Record<string, unknown>).attachments;
|
||||
if (!Array.isArray(attachments)) return [];
|
||||
|
||||
const parsed: ChatAttachment[] = [];
|
||||
for (const entry of attachments) {
|
||||
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
||||
const record = entry as Record<string, unknown>;
|
||||
const kind = record.kind;
|
||||
const id = typeof record.id === "string" ? record.id : "";
|
||||
const filename = typeof record.filename === "string" ? record.filename : "";
|
||||
const mimeType = typeof record.mimeType === "string" ? record.mimeType : "";
|
||||
const sizeBytes = typeof record.sizeBytes === "number" ? record.sizeBytes : 0;
|
||||
|
||||
if (kind === "image" && typeof record.dataUrl === "string" && (mimeType === "image/png" || mimeType === "image/jpeg")) {
|
||||
parsed.push({
|
||||
kind,
|
||||
id,
|
||||
filename,
|
||||
mimeType,
|
||||
sizeBytes,
|
||||
dataUrl: record.dataUrl,
|
||||
} satisfies ChatImageAttachment);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kind === "text" && typeof record.text === "string") {
|
||||
parsed.push({
|
||||
kind,
|
||||
id,
|
||||
filename,
|
||||
mimeType,
|
||||
sizeBytes,
|
||||
text: record.text,
|
||||
truncated: record.truncated === true,
|
||||
} satisfies ChatTextAttachment);
|
||||
}
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
export { getMessageAttachments } from "./chat-attachments";
|
||||
|
||||
type RunSearchStreamHandlers = {
|
||||
onSearchResults?: (payload: { requestId: string | null; results: SearchResultItem[] }) => void;
|
||||
|
||||
Reference in New Issue
Block a user