adjust attachments to hopefully fix them?

This commit is contained in:
Frederik Spirgi
2026-09-23 11:06:46 +02:00
parent b8399155dd
commit 4380f1f3d8
11 changed files with 305 additions and 62 deletions
+8 -5
View File
@@ -1,7 +1,7 @@
import { del, get, post, put, stream } from "./api.js?v=20260909-account-controls";
import { regenerateInline } from "./regeneration.js";
import { appendSources, createWebSearchToggle } from "./webSearch.js";
import { appendAttachments, createAttachmentComposer } from "./attachments.js";
import { appendAttachments, createAttachmentComposer } from "./attachments.js?v=20260923-vision-provenance";
import { createReasoningToggle, finishReasoning, updateReasoning } from "./reasoning.js?v=20260921-reasoning-capability";
import { closeChatDrawer, openChatDrawer } from "./chatDrawer.js?v=20260909-account-controls";
import { onboardingPrompts, requestedChatId } from "./constants.js?v=20260909-account-controls";
@@ -1427,7 +1427,8 @@ async function stopGeneration() {
setNotice(res.stopped ? "Stopping generation..." : "Generation already finished.");
}
async function setActiveChat(id) {
async function setActiveChat(id, {preserveComposer = false} = {}) {
if (!preserveComposer && id !== activeChatId) attachmentComposer.discard();
if (isMobileLayout()) closeMobileSidebar();
setChatLoading(true, "Opening chat...");
setChatActivity(true, {
@@ -1479,7 +1480,8 @@ async function loadChatSessions() {
return setNotice("Pick a starting action to begin.", "success");
}
async function createNewChat() {
async function createNewChat({preserveComposer = false} = {}) {
if (!preserveComposer) attachmentComposer.discard();
setChatLoading(true, "Creating chat...");
setChatActivity(true, {
eyebrow: "Creating chat",
@@ -1492,7 +1494,7 @@ async function createNewChat() {
setChatActivity(false);
return setNotice(res.error || "Unable to create chat.", "error");
}
chatSessions.unshift(res.chat); await loadSummary(); renderChatList(); await setActiveChat(res.chat.id); setNotice("New chat created.", "success");
chatSessions.unshift(res.chat); await loadSummary(); renderChatList(); await setActiveChat(res.chat.id, {preserveComposer}); setNotice("New chat created.", "success");
msgInput.focus();
setChatLoading(false);
setChatActivity(false);
@@ -1855,7 +1857,8 @@ async function sendMessage() {
if (!message) return;
const webSearch = webSearchToggle.enabled;
const reasoning = reasoningToggle.enabled;
if (!activeChatId) await createNewChat();
if (!activeChatId) await createNewChat({preserveComposer: true});
if (!activeChatId) return;
const currentChat = getChatById(activeChatId);
if (currentChat && !currentChat.assistant_persona_id && currentChat.title === "New chat") {
const autoTitle = message.length > 40 ? `${message.slice(0, 40)}...` : message;