Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ async function submit(formData?: FormData, skip?: boolean) {

messages.push({ role: 'assistant', content: analysisResult.summary || 'Analysis complete.' });

const relatedQueries = await querySuggestor(uiStream, messages);
const sanitizedMessages: CoreMessage[] = messages.map(m => {
if (Array.isArray(m.content)) {
return {
...m,
content: m.content.filter(part => part.type !== 'image')
} as CoreMessage
}
return m
})

const relatedQueries = await querySuggestor(uiStream, sanitizedMessages);
Comment on lines +97 to +107

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sanitizedMessages currently preserves non-image parts but can leave a message with content: [] after filtering. Depending on how querySuggestor builds prompts, empty assistant/user messages can degrade results or cause edge-case failures (e.g., models or prompt builders expecting non-empty content). It’s safer to drop messages that become empty after sanitization, or replace them with a minimal text placeholder.

Also, this uses an as CoreMessage assertion even though you already annotated the array as CoreMessage[]. Prefer avoiding assertions here by constructing a value that naturally satisfies the type, or by narrowing in a way that doesn’t require casting—casts can mask future regressions when message shapes evolve.

Suggestion

Consider filtering out messages that become empty after removing image parts, and avoid the type assertion.

Example:

const sanitizedMessages: CoreMessage[] = messages
  .map(m => {
    if (!Array.isArray(m.content)) return m;
    const content = m.content.filter(part => part.type !== 'image');
    return { ...m, content };
  })
  .filter(m => !Array.isArray(m.content) || m.content.length > 0);

If you need to preserve message count, you could replace empty array content with a short text part instead.

Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this change.

uiStream.append(
<Section title="Follow-up">
<FollowupPanel />
Expand Down