From 7912933c3456fb64829776fb5d8fa3362c37e950 Mon Sep 17 00:00:00 2001 From: vgcman16 <155417613+vgcman16@users.noreply.github.com> Date: Thu, 5 Jun 2025 21:23:06 -0500 Subject: [PATCH] Fix notes tab handler guard and lint --- .../@settings/tabs/notes/NotesTab.tsx | 27 ++++++--------- app/components/chat/BaseChat.tsx | 6 +--- app/components/chat/CodeBlock.tsx | 1 + .../chatExportAndImport/ImportButtons.tsx | 2 +- app/components/setup/SetupWizard.tsx | 28 +++++++++++++--- app/lib/api/features.ts | 4 +++ app/lib/common/prompt-library.ts | 16 ++------- app/lib/stores/notes.ts | 6 +++- app/lib/stores/workbench.ts | 9 ++--- app/routes/api.chat.ts | 33 ++++++++++--------- app/utils/constants.ts | 1 + 11 files changed, 68 insertions(+), 65 deletions(-) diff --git a/app/components/@settings/tabs/notes/NotesTab.tsx b/app/components/@settings/tabs/notes/NotesTab.tsx index da949f3e..1567371d 100644 --- a/app/components/@settings/tabs/notes/NotesTab.tsx +++ b/app/components/@settings/tabs/notes/NotesTab.tsx @@ -10,7 +10,11 @@ export default function NotesTab() { const handleAdd = () => { const text = noteText.trim(); - if (!text) return; + + if (!text) { + return; + } + addNote(text); setNoteText(''); }; @@ -27,7 +31,7 @@ export default function NotesTab() { 'border border-bolt-elements-borderColor', 'text-bolt-elements-textPrimary', 'focus:outline-none focus:ring-2 focus:ring-purple-500/30', - 'min-h-[80px] resize-vertical' + 'min-h-[80px] resize-vertical', )} placeholder="Add a note for the AI" /> @@ -37,25 +41,14 @@ export default function NotesTab() {
{notes.map((n) => ( -
-
- {n.text} -
-
))} - {notes.length === 0 && ( -

No notes added.

- )} + {notes.length === 0 &&

No notes added.

}
); diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 3d3fee88..d21aa626 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -485,11 +485,7 @@ export const BaseChat = React.forwardRef(
- {!chatStarted && ( -
- {ImportButtons(importChat)} -
- )} + {!chatStarted &&
{ImportButtons(importChat)}
}
{!chatStarted && ExamplePrompts((event, messageInput) => { diff --git a/app/components/chat/CodeBlock.tsx b/app/components/chat/CodeBlock.tsx index 2dc7c108..261d17e0 100644 --- a/app/components/chat/CodeBlock.tsx +++ b/app/components/chat/CodeBlock.tsx @@ -82,6 +82,7 @@ export const CodeBlock = memo( title="Ask Bolt about this code" onClick={() => { const askFn = (window as any).__BOLT_ASK_SNIPPET__; + if (typeof askFn === 'function') { askFn(code, language); } diff --git a/app/components/chat/chatExportAndImport/ImportButtons.tsx b/app/components/chat/chatExportAndImport/ImportButtons.tsx index f23b4e28..18a01c69 100644 --- a/app/components/chat/chatExportAndImport/ImportButtons.tsx +++ b/app/components/chat/chatExportAndImport/ImportButtons.tsx @@ -1,7 +1,7 @@ import type { Message } from 'ai'; import { toast } from 'react-toastify'; import { ImportFolderButton } from '~/components/chat/ImportFolderButton'; -import GitCloneButton from '../GitCloneButton'; +import GitCloneButton from '~/components/chat/GitCloneButton'; import { Button } from '~/components/ui/Button'; import { classNames } from '~/utils/classNames'; diff --git a/app/components/setup/SetupWizard.tsx b/app/components/setup/SetupWizard.tsx index f08cccf8..de3cc447 100644 --- a/app/components/setup/SetupWizard.tsx +++ b/app/components/setup/SetupWizard.tsx @@ -47,10 +47,22 @@ export function SetupWizard() {
Select a Provider
- { setProvider('supabase'); setStep(2); }}> + { + setProvider('supabase'); + setStep(2); + }} + > Supabase - { setProvider('firebase'); setStep(2); }}> + { + setProvider('firebase'); + setStep(2); + }} + > Firebase
@@ -85,7 +97,9 @@ export function SetupWizard() { )} {supabaseConn.credentials && (
-
Add these to your .env.local:
+
+ Add these to your .env.local: +
{`VITE_SUPABASE_URL=${supabaseConn.credentials.supabaseUrl}\nVITE_SUPABASE_ANON_KEY=${supabaseConn.credentials.anonKey}`}
Sample code:
{`import { createClient } from '@supabase/supabase-js';\n\nexport const supabase = createClient(import.meta.env.VITE_SUPABASE_URL!, import.meta.env.VITE_SUPABASE_ANON_KEY!);`}
@@ -111,12 +125,16 @@ export function SetupWizard() { value={firebase.projectId} onChange={(e) => updateFirebaseConfig({ projectId: e.currentTarget.value })} /> - Save + + Save +
)} {provider === 'firebase' && step === 3 && (
-
Add these to your .env.local:
+
+ Add these to your .env.local: +
{`VITE_FIREBASE_API_KEY=${firebase.apiKey}\nVITE_FIREBASE_AUTH_DOMAIN=${firebase.authDomain}\nVITE_FIREBASE_PROJECT_ID=${firebase.projectId}`}
Sample code:
{`import { initializeApp } from 'firebase/app';\nimport { getAuth } from 'firebase/auth';\nimport { getFirestore } from 'firebase/firestore';\n\nconst firebaseConfig = {\n  apiKey: import.meta.env.VITE_FIREBASE_API_KEY!,\n  authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN!,\n  projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID!,\n};\n\nconst app = initializeApp(firebaseConfig);\nexport const auth = getAuth(app);\nexport const db = getFirestore(app);`}
diff --git a/app/lib/api/features.ts b/app/lib/api/features.ts index 0797a2dd..aaaa946a 100644 --- a/app/lib/api/features.ts +++ b/app/lib/api/features.ts @@ -3,18 +3,22 @@ export interface Feature { * Unique identifier for the feature. */ id: string; + /** * Short title of the feature to display in the UI. */ name: string; + /** * Description of what the feature does. */ description: string; + /** * Whether the user has already viewed/acknowledged this feature. */ viewed: boolean; + /** * ISO date string for when the feature was released. */ diff --git a/app/lib/common/prompt-library.ts b/app/lib/common/prompt-library.ts index 68b8803c..a72e811a 100644 --- a/app/lib/common/prompt-library.ts +++ b/app/lib/common/prompt-library.ts @@ -31,24 +31,12 @@ export class PromptLibrary { default: { label: 'Default Prompt', description: 'This is the battle tested default system Prompt', - get: (options) => - getSystemPrompt( - options.cwd, - options.supabase, - options.designScheme, - options.userNotes, - ), + get: (options) => getSystemPrompt(options.cwd, options.supabase, options.designScheme, options.userNotes), }, enhanced: { label: 'Fine Tuned Prompt', description: 'An fine tuned prompt for better results', - get: (options) => - getFineTunedPrompt( - options.cwd, - options.supabase, - options.designScheme, - options.userNotes, - ), + get: (options) => getFineTunedPrompt(options.cwd, options.supabase, options.designScheme, options.userNotes), }, optimized: { label: 'Optimized Prompt (experimental)', diff --git a/app/lib/stores/notes.ts b/app/lib/stores/notes.ts index da2c7e39..a16ab1e3 100644 --- a/app/lib/stores/notes.ts +++ b/app/lib/stores/notes.ts @@ -12,6 +12,7 @@ function loadNotes(): Note[] { if (typeof localStorage === 'undefined') { return []; } + try { const json = localStorage.getItem(NOTES_KEY); return json ? JSON.parse(json) : []; @@ -21,7 +22,10 @@ function loadNotes(): Note[] { } function saveNotes(notes: Note[]) { - if (typeof localStorage === 'undefined') return; + if (typeof localStorage === 'undefined') { + return; + } + try { localStorage.setItem(NOTES_KEY, JSON.stringify(notes)); } catch {} diff --git a/app/lib/stores/workbench.ts b/app/lib/stores/workbench.ts index b033345d..9a3d01f9 100644 --- a/app/lib/stores/workbench.ts +++ b/app/lib/stores/workbench.ts @@ -629,12 +629,9 @@ export class WorkbenchStore { } } - actionStreamSampler = createSampler( - async (data: ActionCallbackData, isStreaming: boolean = false) => { - return await this._runAction(data, isStreaming); - }, - ACTION_STREAM_SAMPLE_INTERVAL, - ); + actionStreamSampler = createSampler(async (data: ActionCallbackData, isStreaming: boolean = false) => { + return await this._runAction(data, isStreaming); + }, ACTION_STREAM_SAMPLE_INTERVAL); #getArtifact(id: string) { const artifacts = this.artifacts.get(); diff --git a/app/routes/api.chat.ts b/app/routes/api.chat.ts index 2e5370fa..4d7af2c6 100644 --- a/app/routes/api.chat.ts +++ b/app/routes/api.chat.ts @@ -38,23 +38,24 @@ function parseCookies(cookieHeader: string): Record { } async function chatAction({ context, request }: ActionFunctionArgs) { - const { messages, files, promptId, contextOptimization, supabase, chatMode, designScheme, userNotes } = await request.json<{ - messages: Messages; - files: any; - promptId?: string; - contextOptimization: boolean; - chatMode: 'discuss' | 'build'; - designScheme?: DesignScheme; - userNotes?: string; - supabase?: { - isConnected: boolean; - hasSelectedProject: boolean; - credentials?: { - anonKey?: string; - supabaseUrl?: string; + const { messages, files, promptId, contextOptimization, supabase, chatMode, designScheme, userNotes } = + await request.json<{ + messages: Messages; + files: any; + promptId?: string; + contextOptimization: boolean; + chatMode: 'discuss' | 'build'; + designScheme?: DesignScheme; + userNotes?: string; + supabase?: { + isConnected: boolean; + hasSelectedProject: boolean; + credentials?: { + anonKey?: string; + supabaseUrl?: string; + }; }; - }; - }>(); + }>(); const cookieHeader = request.headers.get('Cookie'); const apiKeys = JSON.parse(parseCookies(cookieHeader || '').apiKeys || '{}'); diff --git a/app/utils/constants.ts b/app/utils/constants.ts index e4b4c49f..1e2315c3 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -8,6 +8,7 @@ export const MODEL_REGEX = /^\[Model: (.*?)\]\n\n/; export const PROVIDER_REGEX = /\[Provider: (.*?)\]\n\n/; export const DEFAULT_MODEL = 'claude-3-5-sonnet-latest'; export const PROMPT_COOKIE_KEY = 'cachedPrompt'; + // Interval used by actionStreamSampler in ms export const ACTION_STREAM_SAMPLE_INTERVAL = 100;