Add plus button to prompt input for file and image attachments#381
Add plus button to prompt input for file and image attachments#381
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cb43bad to
f345782
Compare
ramnique
left a comment
There was a problem hiding this comment.
Added some concerns to be addressed
| path: z.string(), // absolute file path | ||
| filename: z.string(), // display name ("photo.png") | ||
| mediaType: z.string(), // MIME type ("image/png", "text/plain") | ||
| size: z.number().optional(), // bytes |
There was a problem hiding this comment.
the fields type and mediaType are conveying the same information. What I suggest:
- drop field
type - rename
mediaTypetomimeType
Also, we can put these fields directly into UserAttachmentPart , so it becomes:
export const UserAttachmentPart = z.object({
type: z.literal("attachment"),
path: z.string(), // absolute file path
filename: z.string(), // display name ("photo.png")
mimeType: z.string(), // MIME type ("image/png", "text/plain")
size: z.number().optional(), // bytes
});| let textContent: string | undefined; | ||
| if (typeof content === 'string') { | ||
| textContent = content; | ||
| } else if (Array.isArray(content)) { |
There was a problem hiding this comment.
we shouldn't need else if here. An else should suffice, because content can either be string or array
| textContent = content; | ||
| } else if (Array.isArray(content)) { | ||
| textContent = content | ||
| .filter((p: { type: string }) => p.type === 'text') |
There was a problem hiding this comment.
we shouldn't need to type-cast within filter here. typescript ideally shouldn't complain if we do:
textContent = content
.filter(p => p.type === 'text')
.map(p => p.text)
.join('');| const textSegments: string[] = []; | ||
|
|
||
| // Collect attachments into a header block | ||
| const attachmentParts = msg.content.filter((p: { type: string }) => p.type === "attachment"); |
There was a problem hiding this comment.
type-casting shouldn't be required here. Also, for readability, we can use a for..of loop here
| if (attachmentParts.length > 0) { | ||
| textSegments.push("User has attached the following files:"); | ||
| for (const part of attachmentParts) { | ||
| const att = (part as { type: string; attachment: { filename: string; mediaType: string; size?: number; path: string } }).attachment; |
There was a problem hiding this comment.
this type-casting should not be required here
| const filePath = path.join(WorkDir, 'runs', `${id}.jsonl`); | ||
| await fsp.unlink(filePath); | ||
| // Clean up attachment sidecar directory if it exists | ||
| const attachmentsDir = path.join(WorkDir, 'runs', 'attachments', id); |
There was a problem hiding this comment.
why do we need these changes in delete()? AFAIK, attachments are just pointers to existing files on disk
Co-authored-by: Cursor <cursoragent@cursor.com>
…nts in chat input and sidebar
3601828 to
a0a7933
Compare
No description provided.