mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
remove unnecessary toast and save file to tmp
This commit is contained in:
1 parent
3fe03007d2
commit
7ff1f639ce
2 files changed
+3
-54
No files matched your search
@@ -13,7 +13,6 @@ import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useKeepAlive } from '@/hooks/useKeepAlive';
|
||||
import { useAIChat } from '@/hooks/useAIChat';
|
||||
import { useProviderModels } from '@/hooks/useProviderModels';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { ModelSelector } from '@/components/ModelSelector';
|
||||
import { AIMessageItem } from '@/components/AIMessageItem';
|
||||
import { TextEditorViewTool } from '@/lib/tools/TextEditorViewTool';
|
||||
@@ -73,7 +72,6 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
|
||||
const [attachedFiles, setAttachedFiles] = useState<File[]>([]);
|
||||
const [isDragOver, setIsDragOver] = useState(false);
|
||||
const { toast } = useToast();
|
||||
const [scrolledProjects] = useState(() => new Set<string>());
|
||||
|
||||
// Use external state if provided, otherwise default to false
|
||||
@@ -347,19 +345,6 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
|
||||
// Add all files without validation
|
||||
setAttachedFiles(prev => [...prev, ...files]);
|
||||
|
||||
// Announce files added via toast
|
||||
if (files.length === 1) {
|
||||
toast({
|
||||
title: "File added",
|
||||
description: `${files[0].name} has been added to attachments.`,
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
title: "Files added",
|
||||
description: `${files.length} files have been added to attachments.`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleSend = async () => {
|
||||
|
||||
+3
-39
@@ -9,7 +9,6 @@ import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { AppLayout } from '@/components/AppLayout';
|
||||
import { DotAI } from '@/lib/DotAI';
|
||||
import type { AIMessage } from '@/lib/SessionManager';
|
||||
import { saveFileToTmp } from '@/lib/fileUtils';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
@@ -24,7 +23,7 @@ export default function Index() {
|
||||
const [storedPrompt, setStoredPrompt] = useLocalStorage('shakespeare-draft-prompt', '');
|
||||
const navigate = useNavigate();
|
||||
const projectsManager = useProjectsManager();
|
||||
const { fs } = useFS();
|
||||
const { fs } = useFS();
|
||||
const { generateProjectId, isLoading: isGeneratingId, isConfigured: isAIConfigured } = useAIProjectId();
|
||||
const { settings, addRecentlyUsedModel } = useAISettings();
|
||||
const [providerModel, setProviderModel] = useState(() => {
|
||||
@@ -135,7 +134,7 @@ export default function Index() {
|
||||
};
|
||||
|
||||
const handleCreateProject = async () => {
|
||||
if (!prompt.trim() && attachedFiles.length === 0) return;
|
||||
if (!prompt.trim() || !providerModel.trim()) return;
|
||||
|
||||
// Clear stored prompt when creating project
|
||||
setStoredPrompt('');
|
||||
@@ -154,45 +153,10 @@ export default function Index() {
|
||||
// Store the initial message in chat history using DotAI
|
||||
const dotAI = new DotAI(fs, `/projects/${project.id}`);
|
||||
const sessionName = DotAI.generateSessionName();
|
||||
|
||||
// Build message content as text parts array
|
||||
const contentParts: Array<{ type: 'text'; text: string }> = [];
|
||||
|
||||
// Add user input as text part if present
|
||||
if (prompt.trim()) {
|
||||
contentParts.push({
|
||||
type: 'text',
|
||||
text: prompt.trim()
|
||||
});
|
||||
}
|
||||
|
||||
// Process attached files and add as separate text parts
|
||||
if (attachedFiles.length > 0) {
|
||||
const filePromises = attachedFiles.map(async (file) => {
|
||||
try {
|
||||
const savedPath = await saveFileToTmp(fs, file);
|
||||
return `Added file: ${savedPath}`;
|
||||
} catch (error) {
|
||||
console.error('Failed to save file:', error);
|
||||
return `Failed to save file: ${file.name}`;
|
||||
}
|
||||
});
|
||||
|
||||
const fileResults = await Promise.all(filePromises);
|
||||
|
||||
// Add each file as a separate text part
|
||||
fileResults.forEach(fileResult => {
|
||||
contentParts.push({
|
||||
type: 'text',
|
||||
text: fileResult
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Create initial message with content parts
|
||||
const initialMessage: AIMessage = {
|
||||
role: 'user',
|
||||
content: contentParts.length === 1 ? contentParts[0].text : contentParts
|
||||
content: prompt.trim()
|
||||
};
|
||||
await dotAI.setHistory(sessionName, [initialMessage]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user