Indicate which apps have databases, tweak copy (#109)

This commit is contained in:
Brian Hackett 2025-04-26 18:23:12 -07:00 committed by GitHub
parent c55a0bdb68
commit b147f7503f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 11 deletions

View File

@ -60,7 +60,7 @@ export const ExampleLibraryApps = () => {
{displayApps.map((app) => (
<div
key={app.appId}
className={`${styles.appItem} ${app.outcome !== 'success' ? styles.appItemError : ''}`}
className={`${styles.appItem} ${!app.outcome.testsPassed ? styles.appItemError : ''}`}
onClick={() => {
importChat(
app.title ?? 'Untitled App',
@ -87,8 +87,10 @@ export const ExampleLibraryApps = () => {
<div>
Created at {formatDate(new Date(app.createdAt))} in {Math.round(app.elapsedMinutes)} minutes
</div>
<div>{app.totalPeanuts} peanuts</div>
{app.outcome !== 'success' && <div className={styles.warningText}> Not all tests are passing</div>}
<div>
{app.totalPeanuts} peanuts{app.outcome.hasDatabase ? ' (has database)' : ''}
</div>
{!app.outcome.testsPassed && <div className={styles.warningText}> Not all tests are passing</div>}
</div>
</div>
</div>

View File

@ -450,7 +450,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
handleSendMessage?.(event, messageInput);
})}
<div className="text-2xl lg:text-4xl font-bold text-bolt-elements-textPrimary mt-8 mb-4 animate-fade-in text-center max-w-chat mx-auto">
Library
Walk in the woods
</div>
<div className="text-bolt-elements-textSecondary text-center max-w-chat mx-auto">
Browse these auto-generated apps for a place to start

View File

@ -3,9 +3,9 @@
import { getSupabase } from '~/lib/supabase/client';
import type { Message } from './message';
export enum BuildAppOutcome {
Success = 'success',
Error = 'error',
export interface BuildAppOutcome {
testsPassed?: boolean;
hasDatabase?: boolean;
}
export interface BuildAppResult {
@ -20,12 +20,33 @@ export interface BuildAppResult {
createdAt: string;
}
function parseBuildAppOutcome(outcome: string): BuildAppOutcome {
try {
const json = JSON.parse(outcome);
return {
testsPassed: !!json.testsPassed,
hasDatabase: !!json.hasDatabase,
};
} catch (error) {
// 2025/04/26: Watch for old formats for outcomes.
if (outcome === 'success') {
return {
testsPassed: true,
};
}
if (outcome === 'error') {
return {
testsPassed: false,
};
}
console.error('Failed to parse outcome:', error);
return {};
}
}
function databaseRowToBuildAppResult(row: any): BuildAppResult {
// Determine the outcome based on the result field
let outcome = BuildAppOutcome.Error;
if (row.outcome === 'success') {
outcome = BuildAppOutcome.Success;
}
const outcome = parseBuildAppOutcome(row.outcome);
return {
title: row.title,