diff --git a/app/components/chat/LoadProblemButton.tsx b/app/components/chat/LoadProblemButton.tsx index a928b8da..d2f0bb37 100644 --- a/app/components/chat/LoadProblemButton.tsx +++ b/app/components/chat/LoadProblemButton.tsx @@ -5,7 +5,6 @@ import { logStore } from '~/lib/stores/logs'; import { assert } from '~/lib/replay/ReplayProtocolClient'; import type { BoltProblem } from '~/lib/replay/Problems'; import { getProblem } from '~/lib/replay/Problems'; -import { createRepositoryImported } from '~/lib/replay/Repository'; import type { Message } from '~/lib/persistence/message'; interface LoadProblemButtonProps { @@ -46,10 +45,9 @@ export async function loadProblem( setLastLoadedProblem(problem); - const { repositoryContents, title: problemTitle } = problem; + const { repositoryId, title: problemTitle } = problem; try { - const repositoryId = await createRepositoryImported(`ImportProblem:${problemId}`, repositoryContents); const messages = createChatFromFolder('problem', repositoryId); await importChat(`Problem: ${problemTitle}`, [...messages]); diff --git a/app/components/sidebar/SaveProblem.tsx b/app/components/sidebar/SaveProblem.tsx index fa2bebdd..7dd6f4f1 100644 --- a/app/components/sidebar/SaveProblem.tsx +++ b/app/components/sidebar/SaveProblem.tsx @@ -4,7 +4,6 @@ import { useState, useEffect } from 'react'; import { workbenchStore } from '~/lib/stores/workbench'; import { submitProblem, BoltProblemStatus } from '~/lib/replay/Problems'; import type { BoltProblemInput } from '~/lib/replay/Problems'; -import { getRepositoryContents } from '~/lib/replay/Repository'; import { shouldUseSupabase, getCurrentUser } from '~/lib/supabase/client'; import { authModalStore } from '~/lib/stores/authModal'; import { authStatusStore } from '~/lib/stores/auth'; @@ -72,15 +71,13 @@ export function SaveProblem() { return; } - const repositoryContents = await getRepositoryContents(repositoryId); - const problem: BoltProblemInput = { version: 2, title: formData.title, description: formData.description, username: shouldUseSupabase() ? (undefined as any) : formData.username, user_id: shouldUseSupabase() ? (await getCurrentUser())?.id || '' : undefined, - repositoryContents, + repositoryId, status: BoltProblemStatus.Pending, }; diff --git a/app/lib/replay/Problems.ts b/app/lib/replay/Problems.ts index 26ed2ec8..b7405ea8 100644 --- a/app/lib/replay/Problems.ts +++ b/app/lib/replay/Problems.ts @@ -1,7 +1,7 @@ // Accessors for the API to access saved problems. import { toast } from 'react-toastify'; -import { sendCommandDedicatedClient } from './ReplayProtocolClient'; +import { assert, sendCommandDedicatedClient } from './ReplayProtocolClient'; import type { Message } from '~/lib/persistence/message'; import Cookies from 'js-cookie'; import { shouldUseSupabase } from '~/lib/supabase/client'; @@ -61,7 +61,7 @@ export interface BoltProblemDescription { export interface BoltProblem extends BoltProblemDescription { username?: string; user_id?: string; - repositoryContents: string; + repositoryId: string; comments?: BoltProblemComment[]; solution?: BoltProblemSolution; } @@ -133,11 +133,7 @@ export async function getProblem(problemId: string): Promise return null; } - if ('prompt' in problem) { - // 2/11/2025: Update obsolete data format for older problems. - problem.repositoryContents = (problem as any).prompt.content; - delete problem.prompt; - } + assert(problem.repositoryId, 'Problem probably has outdated data format. Must have a repositoryId.'); } catch (error) { console.error('Error fetching problem', error); diff --git a/app/lib/supabase/client.ts b/app/lib/supabase/client.ts index db58583f..39d9e996 100644 --- a/app/lib/supabase/client.ts +++ b/app/lib/supabase/client.ts @@ -15,7 +15,7 @@ export interface Database { description: string; status: 'Pending' | 'Solved' | 'Unsolved'; keywords: string[]; - repository_contents: Json; + repository_id: string; user_id: string | null; problem_comments: Database['public']['Tables']['problem_comments']['Row'][]; solution: Json; diff --git a/app/lib/supabase/problems.ts b/app/lib/supabase/problems.ts index 4a3a31ed..bd87946b 100644 --- a/app/lib/supabase/problems.ts +++ b/app/lib/supabase/problems.ts @@ -84,18 +84,12 @@ export async function supabaseGetProblem(problemId: string): Promise ({ @@ -154,7 +148,7 @@ export async function supabaseSubmitProblem(problem: BoltProblemInput): Promise< description: problem.description, status: problem.status as BoltProblemStatus, keywords: problem.keywords || [], - repository_contents: problem.repositoryContents, + repository_id: problem.repositoryId, user_id: problem.user_id, }; @@ -202,7 +196,7 @@ export async function supabaseUpdateProblem(problemId: string, problem: BoltProb description: problem.description, status: problem.status, keywords: problem.keywords || [], - repository_contents_path: problem.repositoryContents ? `problems/${problemId}.txt` : undefined, + repository_id: problem.repositoryId, solution_path: problem.solution ? `solutions/${problemId}.json` : undefined, }; @@ -213,17 +207,6 @@ export async function supabaseUpdateProblem(problemId: string, problem: BoltProb throw updateError; } - if (updates.repository_contents_path) { - const { error: repositoryContentsError } = await getSupabase() - .storage.from('repository-contents') - .upload(updates.repository_contents_path, problem.repositoryContents); - - // @ts-ignore - ignore duplicate error - if (repositoryContentsError && repositoryContentsError.error !== 'Duplicate') { - throw repositoryContentsError; - } - } - if (updates.solution_path) { const { error: solutionError } = await getSupabase() .storage.from('solutions') diff --git a/package.json b/package.json index 7d67352d..72b4e932 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "type": "module", "version": "0.0.5", "scripts": { + "checks": "pnpm run typecheck && pnpm run lint:fix", "deploy": "vercel deploy --prod", "build": "npx remix vite:build", "dev": "node pre-start.cjs && npx remix vite:dev",