fix(gtm): Fix white screen and implement URL persistence v2.6.1
- Fixed TypeError in SessionBrowser by adding defensive checks for the sessions array. - Implemented mandatory URL persistence: The research URL is now saved in DB, shown in UI, and included in reports. - Added 'Start New Analysis' button to the session browser for better UX flow. - Updated documentation to reflect v2.6.1 changes.
This commit is contained in:
@@ -253,9 +253,14 @@ const App: React.FC = () => {
|
||||
const fetchSessions = async () => {
|
||||
try {
|
||||
const res = await Gemini.listSessions();
|
||||
if (res && Array.isArray(res.projects)) {
|
||||
setSessions(res.projects);
|
||||
} else {
|
||||
setSessions([]);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to load sessions", e);
|
||||
setSessions([]);
|
||||
}
|
||||
};
|
||||
fetchSessions();
|
||||
@@ -385,8 +390,10 @@ const App: React.FC = () => {
|
||||
const generateFullReportMarkdown = (): string => {
|
||||
if (!state.phase5Result || !state.phase5Result.report) return "";
|
||||
|
||||
let fullReport = state.phase5Result.report;
|
||||
const sourceUrl = state.phase1Result?.specs?.metadata?.manufacturer_url;
|
||||
let fullReport = sourceUrl ? `# GTM Strategy\n\n**Recherche-URL:** ${sourceUrl}\n\n---\n\n` : '# GTM Strategy\n\n';
|
||||
|
||||
fullReport += state.phase5Result.report;
|
||||
if (state.phase6Result) {
|
||||
fullReport += `\n\n# SALES ENABLEMENT & VISUALS (PHASE 6)\n\n`;
|
||||
fullReport += `## Kill-Critique Battlecards\n\n`;
|
||||
@@ -920,6 +927,7 @@ const App: React.FC = () => {
|
||||
sessions={sessions}
|
||||
onLoadSession={handleLoadSession}
|
||||
onDeleteSession={handleDeleteSession}
|
||||
onStartNew={() => setViewingSessions(false)}
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full max-w-4xl grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
|
||||
@@ -1,82 +1,4 @@
|
||||
.session-browser {
|
||||
padding: 20px;
|
||||
background-color: #f0f2f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
|
||||
.session-browser h2 {
|
||||
text-align: center;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.session-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.session-card {
|
||||
background-color: #ffffff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.session-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.category-icon {
|
||||
font-size: 24px;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.card-header h3 {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
color: #1a1a1a;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.thumbnail-placeholder {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
background-color: #e9ecef;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #adb5bd;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.thumbnail-placeholder span {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
.thumbnail-placeholder p {
|
||||
margin-top: 8px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding: 16px;
|
||||
flex-grow: 1; /* Ensures content area expands */
|
||||
}
|
||||
/* ... (existing styles) ... */
|
||||
|
||||
.product-description {
|
||||
font-size: 0.9rem;
|
||||
@@ -90,45 +12,26 @@
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.source-url {
|
||||
font-size: 0.8rem;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.source-url a {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.source-url a:hover {
|
||||
color: #0056b3;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.last-updated {
|
||||
font-size: 0.8rem;
|
||||
color: #888;
|
||||
margin-top: auto; /* Pushes to the bottom if content is short */
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.card-actions button {
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 8px 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
.load-btn {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.load-btn:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
background-color: #fceeee;
|
||||
color: #d9534f;
|
||||
}
|
||||
|
||||
.delete-btn:hover {
|
||||
background-color: #f8d7da;
|
||||
color: #b0413e;
|
||||
}
|
||||
|
||||
/* ... (rest of the styles) ... */
|
||||
@@ -1,47 +1,69 @@
|
||||
import React from 'react';
|
||||
import { ProjectHistoryItem } from './types';
|
||||
import './SessionBrowser.css';
|
||||
import { Plus, FileText } from 'lucide-react';
|
||||
|
||||
interface SessionBrowserProps {
|
||||
sessions: ProjectHistoryItem[];
|
||||
onLoadSession: (projectId: string) => void;
|
||||
onDeleteSession: (projectId: string) => void;
|
||||
onStartNew: () => void;
|
||||
}
|
||||
|
||||
const SessionBrowser: React.FC<SessionBrowserProps> = ({ sessions, onLoadSession, onDeleteSession }) => {
|
||||
const SessionBrowser: React.FC<SessionBrowserProps> = ({ sessions, onLoadSession, onDeleteSession, onStartNew }) => {
|
||||
|
||||
const getCategoryIcon = (category: string) => {
|
||||
// Return an icon based on the category, default to a generic robot
|
||||
if (!category) return '🤖';
|
||||
switch (category.toLowerCase()) {
|
||||
case 'reinigungsroboter':
|
||||
return '🧹'; // Sweeping broom emoji
|
||||
return '🧹';
|
||||
case 'serviceroboter':
|
||||
return '🛎️'; // Bellhop bell emoji
|
||||
return '🛎️';
|
||||
case 'transportroboter':
|
||||
return '📦'; // Package emoji
|
||||
return '📦';
|
||||
case 'security roboter':
|
||||
return '🛡️'; // Shield emoji
|
||||
return '🛡️';
|
||||
default:
|
||||
return '🤖'; // Default robot emoji
|
||||
return '🤖';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="session-browser">
|
||||
<h2>Gespeicherte Sitzungen</h2>
|
||||
<div className="browser-header">
|
||||
<h2 className="flex items-center gap-2"><FileText size={28}/> Gespeicherte Sitzungen</h2>
|
||||
<button onClick={onStartNew} className="start-new-btn">
|
||||
<Plus size={16}/> Neue Analyse starten
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{(!sessions || sessions.length === 0) ? (
|
||||
<div className="empty-state">
|
||||
<p>Keine gespeicherten Sitzungen gefunden.</p>
|
||||
<button onClick={onStartNew} className="start-new-btn-secondary">
|
||||
Jetzt eine neue Analyse starten
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="session-grid">
|
||||
{sessions.map((session) => (
|
||||
<div key={session.id} className="session-card">
|
||||
<div className="card-header">
|
||||
<span className="category-icon">{getCategoryIcon(session.productCategory)}</span>
|
||||
<h3 title={session.productName}>{session.productName}</h3>
|
||||
<h3 title={session.productName}>{session.productName || 'Unbenannt'}</h3>
|
||||
</div>
|
||||
{/* Thumbnail placeholder */}
|
||||
<div className="thumbnail-placeholder">
|
||||
<span>🖼️</span>
|
||||
<p>Thumbnail</p>
|
||||
</div>
|
||||
<div className="card-content">
|
||||
<p className="product-description">{session.productDescription}</p>
|
||||
<p className="product-description">{session.productDescription || 'Keine Beschreibung verfügbar.'}</p>
|
||||
<p className="source-url">
|
||||
<a href={session.sourceUrl} target="_blank" rel="noopener noreferrer">
|
||||
Quelle anzeigen
|
||||
</a>
|
||||
</p>
|
||||
<p className="last-updated">Zuletzt bearbeitet: {new Date(session.updated_at).toLocaleString()}</p>
|
||||
</div>
|
||||
<div className="card-actions">
|
||||
@@ -51,6 +73,7 @@ const SessionBrowser: React.FC<SessionBrowserProps> = ({ sessions, onLoadSession
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -168,5 +168,6 @@ export interface ProjectHistoryItem {
|
||||
productName: string;
|
||||
productCategory: string;
|
||||
productDescription: string;
|
||||
sourceUrl: string;
|
||||
productThumbnail?: string; // Optional for now
|
||||
}
|
||||
@@ -91,6 +91,11 @@ Das System verwaltet persistente Sitzungen in der SQLite-Datenbank:
|
||||
|
||||
## 7. Historie & Fixes (Jan 2026)
|
||||
|
||||
* **[UPGRADE] v2.6.1: Stability & URL Persistence**
|
||||
* **Bugfix:** Behebung des "Weißen Bildschirms" durch Absicherung der Session-Liste gegen `undefined`-Werte.
|
||||
* **URL Tracking:** Die Recherche-URL wird nun zwingend im Projekt gespeichert, in der Lade-Übersicht angezeigt und in den finalen Report-Export integriert.
|
||||
* **UX Flow:** Direkter Wechsel zwischen "Letzte Sitzungen" und "Neue Analyse starten" jederzeit möglich.
|
||||
|
||||
* **[UPGRADE] v2.6: Rich Session Browser**
|
||||
* **Neues UI:** Die textbasierte Liste für "Letzte Sitzungen" wurde durch eine dedizierte, kartenbasierte UI (`SessionBrowser.tsx`) ersetzt.
|
||||
* **Angereicherte Daten:** Jede Sitzungskarte zeigt nun den Produktnamen, die Produktkategorie (mit Icon), eine Kurzbeschreibung und einen Thumbnail-Platzhalter an.
|
||||
|
||||
@@ -282,6 +282,13 @@ def phase1(payload):
|
||||
|
||||
try:
|
||||
specs_data = json.loads(specs_response)
|
||||
|
||||
# FORCE URL PERSISTENCE: If input was a URL, ensure it's in the metadata
|
||||
if product_input.strip().startswith('http'):
|
||||
if 'metadata' not in specs_data:
|
||||
specs_data['metadata'] = {}
|
||||
specs_data['metadata']['manufacturer_url'] = product_input.strip()
|
||||
|
||||
data['specs'] = specs_data
|
||||
except json.JSONDecodeError:
|
||||
logging.error(f"Failed to decode JSON from Gemini response in phase1 (specs): {specs_response}")
|
||||
|
||||
@@ -104,7 +104,8 @@ def get_all_projects():
|
||||
updated_at,
|
||||
json_extract(data, '$.phases.phase1_result.specs.metadata.model_name') AS productName,
|
||||
json_extract(data, '$.phases.phase1_result.specs.metadata.category') AS productCategory,
|
||||
json_extract(data, '$.phases.phase1_result.specs.metadata.description') AS productDescription
|
||||
json_extract(data, '$.phases.phase1_result.specs.metadata.description') AS productDescription,
|
||||
json_extract(data, '$.phases.phase1_result.specs.metadata.manufacturer_url') AS sourceUrl
|
||||
FROM gtm_projects
|
||||
ORDER BY updated_at DESC
|
||||
"""
|
||||
@@ -119,6 +120,8 @@ def get_all_projects():
|
||||
project_dict['productCategory'] = "Uncategorized" # Default category
|
||||
if project_dict.get('productDescription') is None:
|
||||
project_dict['productDescription'] = "No description available." # Default description
|
||||
if project_dict.get('sourceUrl') is None:
|
||||
project_dict['sourceUrl'] = "No source URL found." # Default URL
|
||||
project_list.append(project_dict)
|
||||
return project_list
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user