Skip to content

Commit

Permalink
Fix problem submit UX
Browse files Browse the repository at this point in the history
  • Loading branch information
bhackett1024 committed Jan 17, 2025
1 parent 9eb75c8 commit 9e79118
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/components/chat/Chat.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const ChatImpl = memo(
*/
await workbenchStore.saveAllFiles();

const { contentBase64, uniqueProjectName } = await workbenchStore.generateZipBase64();
const { contentBase64 } = await workbenchStore.generateZipBase64();

let simulationClientData: SimulationPromptClientData | undefined;
if (simulation) {
Expand Down
6 changes: 2 additions & 4 deletions app/components/chat/LoadProblemButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ export const LoadProblemButton: React.FC<LoadProblemButtonProps> = ({ className,
});
}

const folderName = problem.prompt.uniqueProjectName;

try {
const messages = await createChatFromFolder(fileArtifacts, [], folderName);
const messages = await createChatFromFolder(fileArtifacts, [], "problem");

if (importChat) {
await importChat(folderName, [...messages]);
await importChat("Imported problem", [...messages]);
}

logStore.logSystem('Problem loaded successfully', {
Expand Down
26 changes: 9 additions & 17 deletions app/components/sidebar/SaveProblem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { toast } from "react-toastify";
import ReactModal from 'react-modal';
import { assert, sendCommandDedicatedClient } from "~/lib/replay/ReplayProtocolClient";
import { useState } from "react";
import { workbenchStore } from "~/lib/stores/workbench";

ReactModal.setAppElement('#root');

Expand All @@ -12,9 +13,7 @@ ReactModal.setAppElement('#root');
//
// Must be JSON serializable.
interface ProjectPrompt {
content: string; // base64 encoded
uniqueProjectName: string;
input: string;
content: string; // base64 encoded zip file
}

export interface BoltProblem {
Expand All @@ -28,7 +27,6 @@ export interface BoltProblem {

export function SaveProblem() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [currentProjectPrompt, setCurrentProjectPrompt] = useState<ProjectPrompt | null>(null);
const [formData, setFormData] = useState({
title: '',
description: '',
Expand All @@ -37,12 +35,7 @@ export function SaveProblem() {
});
const [problemId, setProblemId] = useState<string | null>(null);

const saveCurrentProblem = () => {
console.log('saveCurrentProblem');
};

const handleSaveProblem = (prompt: ProjectPrompt) => {
setCurrentProjectPrompt(prompt);
const handleSaveProblem = () => {
setIsModalOpen(true);
setFormData({
title: '',
Expand All @@ -61,9 +54,7 @@ export function SaveProblem() {
}));
};

const handleSubmitProblem = async (e: React.MouseEvent) => {
toast.error("SubmitProblem NYI");
/*
const handleSubmitProblem = async () => {
// Add validation here
if (!formData.title) {
toast.error('Please fill in title field');
Expand All @@ -74,15 +65,17 @@ export function SaveProblem() {

console.log("SubmitProblem", formData);

assert(currentProjectPrompt);
await workbenchStore.saveAllFiles();
const { contentBase64 } = await workbenchStore.generateZipBase64();
const prompt: ProjectPrompt = { content: contentBase64 };

const problem: BoltProblem = {
version: 1,
title: formData.title,
description: formData.description,
name: formData.name,
email: formData.email,
prompt: currentProjectPrompt,
prompt,
};

try {
Expand All @@ -99,15 +92,14 @@ export function SaveProblem() {
console.error("Error submitting problem", error);
toast.error("Failed to submit problem");
}
*/
}

return (
<>
<a
href="#"
className="flex gap-2 bg-bolt-elements-sidebar-buttonBackgroundDefault text-bolt-elements-sidebar-buttonText hover:bg-bolt-elements-sidebar-buttonBackgroundHover rounded-md p-2 transition-theme"
onClick={saveCurrentProblem}
onClick={handleSaveProblem}
>
Save Problem
</a>
Expand Down

0 comments on commit 9e79118

Please sign in to comment.