chore: format

This commit is contained in:
Timothy Jaeryang Baek
2026-06-29 13:35:39 -05:00
parent c33fadc266
commit 403392b41b
68 changed files with 602 additions and 291 deletions
+54 -52
View File
@@ -1286,14 +1286,14 @@
let contents = [];
messages.forEach((message) => {
if (message?.role !== 'user') {
const messageContent = getOutputText(message?.output) || removeAllDetails(message?.content ?? '');
const messageContent =
getOutputText(message?.output) || removeAllDetails(message?.content ?? '');
if (!messageContent.trim()) {
return;
}
const { codeBlocks: codeBlocks, htmlGroups: htmlGroups } = getCodeBlockContents(
messageContent
);
const { codeBlocks: codeBlocks, htmlGroups: htmlGroups } =
getCodeBlockContents(messageContent);
if (htmlGroups && htmlGroups.length > 0) {
htmlGroups.forEach((group) => {
@@ -2016,7 +2016,8 @@
if (done) {
message.done = true;
const visibleContent = getOutputText(message?.output) || removeAllDetails(message?.content ?? '');
const visibleContent =
getOutputText(message?.output) || removeAllDetails(message?.content ?? '');
if ($settings.responseAutoCopy) {
copyToClipboard(visibleContent);
@@ -2460,60 +2461,61 @@
true;
// Always include system prompt — backend extracts it and prepends to DB messages.
// Only temp chats need conversation messages (persisted chats load from DB).
let messages: any[] = [
params?.system || $settings.system
? { role: 'system', content: `${params?.system ?? $settings?.system ?? ''}` }
: undefined
].filter(Boolean);
let messages: any[] = [
params?.system || $settings.system
? { role: 'system', content: `${params?.system ?? $settings?.system ?? ''}` }
: undefined
].filter(Boolean);
if ($temporaryChatEnabled) {
messages = [
...messages,
..._messages.map((message) => ({
...message,
...(message.output && message.role === 'assistant'
? { output: message.output }
: { content: processDetails(message.content) })
}))
].filter((message) => message);
if ($temporaryChatEnabled) {
messages = [
...messages,
..._messages.map((message) => ({
...message,
...(message.output && message.role === 'assistant'
? { output: message.output }
: { content: processDetails(message.content) })
}))
].filter((message) => message);
messages = messages
.map((message) => {
const imageFiles = (message?.files ?? []).filter(
(file) => file.type === 'image' || (file?.content_type ?? '').startsWith('image/')
);
messages = messages
.map((message) => {
const imageFiles = (message?.files ?? []).filter(
(file) => file.type === 'image' || (file?.content_type ?? '').startsWith('image/')
);
if (message.output && message.role === 'assistant') {
return { role: message.role, output: message.output };
}
if (message.role === 'user' && imageFiles.length > 0) {
return {
role: message.role,
content: [
{
type: 'text',
text: message?.merged?.content ?? message.content
},
...imageFiles.map((file) => ({
type: 'image_url',
image_url: {
url: file.url
}
}))
]
};
}
if (message.output && message.role === 'assistant') {
return { role: message.role, output: message.output };
}
if (message.role === 'user' && imageFiles.length > 0) {
return {
role: message.role,
content: message?.merged?.content ?? message.content
content: [
{
type: 'text',
text: message?.merged?.content ?? message.content
},
...imageFiles.map((file) => ({
type: 'image_url',
image_url: {
url: file.url
}
}))
]
};
})
.filter(
(message) => message?.role === 'user' || message?.content?.trim() || message?.output?.length
);
}
}
return {
role: message.role,
content: message?.merged?.content ?? message.content
};
})
.filter(
(message) =>
message?.role === 'user' || message?.content?.trim() || message?.output?.length
);
}
const toolIds = [];
const toolServerIds = [];
+20 -20
View File
@@ -385,16 +385,16 @@
const message = history.messages[messageId];
const parentId = message.parentId;
const responseMessage = {
...message,
id: responseMessageId,
parentId: parentId,
childrenIds: [],
files: undefined,
content: output !== undefined ? '' : content,
...(output !== undefined ? { output } : {}),
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
const responseMessage = {
...message,
id: responseMessageId,
parentId: parentId,
childrenIds: [],
files: undefined,
content: output !== undefined ? '' : content,
...(output !== undefined ? { output } : {}),
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
history.messages[responseMessageId] = responseMessage;
history.currentId = responseMessageId;
@@ -408,16 +408,16 @@
}
await updateChat();
} else {
// Edit response message
if (content !== undefined) {
history.messages[messageId].originalContent = history.messages[messageId].content;
history.messages[messageId].content = content;
}
if (output !== undefined) {
history.messages[messageId].output = output;
history.messages[messageId].content = '';
}
} else {
// Edit response message
if (content !== undefined) {
history.messages[messageId].originalContent = history.messages[messageId].content;
history.messages[messageId].content = content;
}
if (output !== undefined) {
history.messages[messageId].output = output;
history.messages[messageId].content = '';
}
await updateChat();
}
}
@@ -129,30 +129,32 @@
)
: messageContent;
const markdownUpdateHandler = /** @type {any} */ (async (
/** @type {{ lang?: string; text?: string }} */ token
) => {
const { lang = '', text: code = '' } = token;
const markdownUpdateHandler = /** @type {any} */ (
async (/** @type {{ lang?: string; text?: string }} */ token) => {
const { lang = '', text: code = '' } = token;
if (
($settings?.detectArtifacts ?? true) &&
(['html', 'svg'].includes(lang) || (lang === 'xml' && code.includes('svg'))) &&
!$mobile &&
$chatId
) {
await tick();
showArtifacts.set(true);
showControls.set(true);
if (
($settings?.detectArtifacts ?? true) &&
(['html', 'svg'].includes(lang) || (lang === 'xml' && code.includes('svg'))) &&
!$mobile &&
$chatId
) {
await tick();
showArtifacts.set(true);
showControls.set(true);
}
}
});
);
const previewHandler = /** @type {any} */ (async (/** @type {string} */ value) => {
console.log('Preview', value);
await artifactCode.set(/** @type {any} */ (value));
await showControls.set(true);
await showArtifacts.set(true);
await showEmbeds.set(false);
});
const previewHandler = /** @type {any} */ (
async (/** @type {string} */ value) => {
console.log('Preview', value);
await artifactCode.set(/** @type {any} */ (value));
await showControls.set(true);
await showArtifacts.set(true);
await showEmbeds.set(false);
}
);
const updateButtonPosition = (event) => {
const buttonsContainerElement = document.getElementById(`floating-buttons-${id}`);
@@ -273,7 +275,7 @@
{topPadding}
{sourceIds}
renderMarkdown={$settings?.renderMarkdownInAssistantMessages ?? true}
formatMessageContent={formatMessageContent}
{formatMessageContent}
{onSourceClick}
{onTaskClick}
{onSave}
@@ -64,11 +64,7 @@
import StatusHistory from './ResponseMessage/StatusHistory.svelte';
import FullHeightIframe from '$lib/components/common/FullHeightIframe.svelte';
import OutputEditView from './OutputEditView.svelte';
import {
getOutputText,
replaceOutputMessageText,
type OutputItem
} from './structuredOutput';
import { getOutputText, replaceOutputMessageText, type OutputItem } from './structuredOutput';
interface MessageType {
id: string;
@@ -185,7 +181,8 @@
(model?.info?.meta?.capabilities?.status_updates ?? true) &&
statusEntries.length > 0 &&
!(statusEntries.at(-1)?.hidden ?? false);
$: visibleResponseContent = getOutputText(message.output) || removeAllDetails(message.content ?? '');
$: visibleResponseContent =
getOutputText(message.output) || removeAllDetails(message.content ?? '');
$: hasResponseContent = Boolean((message.content ?? '').trim() || message.output?.length);
let edit = false;
@@ -107,7 +107,7 @@ function getMessageText(item: OutputItem): string {
}
function getReasoningText(item: OutputItem): string {
return getTextFromParts((item.summary ?? item.content) ?? []);
return getTextFromParts(item.summary ?? item.content ?? []);
}
function getToolResultText(item?: OutputItem): string {