Compare commits

...

2 Commits

Author SHA1 Message Date
f9f3d95406 feature: new changes!
All checks were successful
Recommender Build and Deploy (internal) / Build Recommender Image (push) Successful in 3m59s
Recommender Build and Deploy (internal) / Deploy Recommender (internal) (push) Successful in 10s
2026-03-25 20:09:32 -03:00
26f61077b8 changess 2026-03-25 19:46:14 -03:00
33 changed files with 1111 additions and 648 deletions

View File

@@ -18,7 +18,7 @@ spec:
image: git.ivanch.me/ivanch/recommender:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
- containerPort: 80
env:
- name: OPENAI_API_KEY
valueFrom:
@@ -48,7 +48,7 @@ spec:
app: recommender
ports:
- port: 80
targetPort: 8080
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress

12
package-lock.json generated
View File

@@ -3822,6 +3822,15 @@
"url": "https://opencollective.com/preact"
}
},
"node_modules/preact-router": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/preact-router/-/preact-router-4.1.2.tgz",
"integrity": "sha512-uICUaUFYh+XQ+6vZtQn1q+X6rSqwq+zorWOCLWPF5FAsQh3EJ+RsDQ9Ee+fjk545YWQHfUxhrBAaemfxEnMOUg==",
"license": "MIT",
"peerDependencies": {
"preact": ">=10"
}
},
"node_modules/process-warning": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz",
@@ -4466,7 +4475,8 @@
"packages/frontend": {
"version": "0.0.0",
"dependencies": {
"preact": "^10.29.0"
"preact": "^10.29.0",
"preact-router": "^4.1.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.10.4",

View File

@@ -1,7 +1,7 @@
import { defineConfig } from 'drizzle-kit';
import * as dotenv from 'dotenv';
dotenv.config();
dotenv.config({ path: ['.env.local', '.env'] });
export default defineConfig({
schema: './src/db/schema.ts',

View File

@@ -0,0 +1,22 @@
CREATE TABLE "feedback" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"tv_show_name" text NOT NULL,
"stars" integer NOT NULL,
"feedback" text DEFAULT '' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "recommendations" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"title" text NOT NULL,
"main_prompt" text NOT NULL,
"liked_shows" text DEFAULT '' NOT NULL,
"disliked_shows" text DEFAULT '' NOT NULL,
"themes" text DEFAULT '' NOT NULL,
"brainstorm_count" integer DEFAULT 100 NOT NULL,
"recommendations" jsonb,
"status" text DEFAULT 'pending' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX "feedback_tv_show_name_idx" ON "feedback" USING btree ("tv_show_name");

View File

@@ -0,0 +1,161 @@
{
"id": "4ca81e42-26b0-46f5-988e-957360067861",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.feedback": {
"name": "feedback",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"tv_show_name": {
"name": "tv_show_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"stars": {
"name": "stars",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"feedback": {
"name": "feedback",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "''"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"feedback_tv_show_name_idx": {
"name": "feedback_tv_show_name_idx",
"columns": [
{
"expression": "tv_show_name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.recommendations": {
"name": "recommendations",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"main_prompt": {
"name": "main_prompt",
"type": "text",
"primaryKey": false,
"notNull": true
},
"liked_shows": {
"name": "liked_shows",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "''"
},
"disliked_shows": {
"name": "disliked_shows",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "''"
},
"themes": {
"name": "themes",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "''"
},
"brainstorm_count": {
"name": "brainstorm_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 100
},
"recommendations": {
"name": "recommendations",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'pending'"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1774479321371,
"tag": "0000_wild_joseph",
"breakpoints": true
}
]
}

View File

@@ -1,6 +1,6 @@
import OpenAI from 'openai';
import * as dotenv from 'dotenv';
dotenv.config();
dotenv.config({ path: ['.env.local', '.env'] });
export const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,

View File

@@ -1,7 +1,7 @@
import { openai } from '../agent.js';
import type { InterpreterOutput, RetrievalOutput } from '../types/agents.js';
export async function runRetrieval(input: InterpreterOutput): Promise<RetrievalOutput> {
export async function runRetrieval(input: InterpreterOutput, brainstormCount = 100): Promise<RetrievalOutput> {
const response = await openai.chat.completions.create({
model: 'gpt-5.4',
temperature: 0.9,
@@ -10,7 +10,7 @@ export async function runRetrieval(input: InterpreterOutput): Promise<RetrievalO
messages: [
{
role: 'system',
content: `You are a TV show candidate generator. Your goal is to brainstorm a LARGE, DIVERSE pool of 6080 TV show candidates that match the user's structured preferences.
content: `You are a TV show candidate generator. Your goal is to brainstorm a LARGE, DIVERSE pool of ${brainstormCount} TV show candidates that match the user's structured preferences.
Your output MUST be valid JSON matching this schema:
{
@@ -25,7 +25,7 @@ Rules:
- Each "reason" should briefly explain why the show matches the preferences
- Avoid duplicates
- Include shows from different decades, countries, and networks
- Aim for 6080 candidates minimum`,
- Aim for ${brainstormCount} candidates minimum`,
},
{
role: 'user',

View File

@@ -0,0 +1,28 @@
import { openai } from '../agent.js';
import type { InterpreterOutput } from '../types/agents.js';
export async function generateTitle(interpreter: InterpreterOutput): Promise<string> {
const response = await openai.chat.completions.create({
model: 'gpt-4o-mini',
temperature: 0.7,
service_tier: 'flex',
messages: [
{
role: 'system',
content: `Generate a concise 5-8 word title for a TV show recommendation session.
Capture the essence of the user's taste — genre, tone, key themes.
Respond with ONLY the title. No quotes, no trailing punctuation.
Examples: "Dark Crime Dramas With Moral Ambiguity", "Cozy British Mysteries With Quirky Detectives"`,
},
{
role: 'user',
content: `Liked: ${JSON.stringify(interpreter.liked)}
Themes: ${JSON.stringify(interpreter.themes)}
Tone: ${JSON.stringify(interpreter.tone)}
Character preferences: ${JSON.stringify(interpreter.character_preferences)}`,
},
],
});
return (response.choices[0]?.message?.content ?? '').trim() || 'My Recommendation Session';
}

View File

@@ -2,7 +2,7 @@ import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as dotenv from 'dotenv';
dotenv.config();
dotenv.config({ path: ['.env.local', '.env'] });
const connectionString = process.env.DATABASE_URL || 'postgres://user:password@iris.haven:5432/recommender';
export const client = postgres(connectionString);

View File

@@ -8,6 +8,7 @@ export const recommendations = pgTable('recommendations', {
liked_shows: text('liked_shows').notNull().default(''),
disliked_shows: text('disliked_shows').notNull().default(''),
themes: text('themes').notNull().default(''),
brainstorm_count: integer('brainstorm_count').notNull().default(100),
recommendations: jsonb('recommendations').$type<CuratorOutput[]>(),
status: text('status').notNull().default('pending'),
created_at: timestamp('created_at').defaultNow().notNull(),

View File

@@ -3,10 +3,10 @@ import * as dotenv from 'dotenv';
import recommendationsRoute from './routes/recommendations.js';
import feedbackRoute from './routes/feedback.js';
// Load .env first, then .env.local
// env vars set on the container take precedence over both files
dotenv.config();
dotenv.config({ path: '.env.local', override: true });
// Load .env.local first, then .env.
// dotenv 17+ supports array of paths, where the first path has the highest priority.
// Env vars set on the container (system) will take precedence over both.
dotenv.config({ path: ['.env.local', '.env'] });
const fastify = Fastify({ logger: true });

View File

@@ -6,6 +6,14 @@ import { runRetrieval } from '../agents/retrieval.js';
import { runRanking } from '../agents/ranking.js';
import { runCurator } from '../agents/curator.js';
import type { CuratorOutput, SSEEvent } from '../types/agents.js';
import { generateTitle } from '../agents/titleGenerator.js';
/* -- Agent pipeline --
[1] Interpreter -> gets user input, transforms into structured data
[2] Retrieval -> gets shows from OpenAI (high temperature)
[3] Ranking -> ranks shows based on user input
[4] Curator -> curates shows based on user input
*/
type RecommendationRecord = typeof recommendations.$inferSelect;
@@ -62,7 +70,7 @@ export async function runPipeline(
log(rec.id, 'Retrieval: start');
sseWrite({ stage: 'retrieval', status: 'start' });
const t1 = Date.now();
const retrievalOutput = await runRetrieval(interpreterOutput);
const retrievalOutput = await runRetrieval(interpreterOutput, rec.brainstorm_count);
log(rec.id, `Retrieval: done (${Date.now() - t1}ms) — ${retrievalOutput.candidates.length} candidates`, {
titles: retrievalOutput.candidates.map((c) => c.title),
});
@@ -91,11 +99,21 @@ export async function runPipeline(
log(rec.id, `Curator: done (${Date.now() - t3}ms) — ${curatorOutput.length} shows curated`);
sseWrite({ stage: 'curator', status: 'done', data: curatorOutput });
// Generate AI title
let aiTitle: string = rec.title;
try {
log(rec.id, 'Title generation: start');
aiTitle = await generateTitle(interpreterOutput);
log(rec.id, `Title generation: done — "${aiTitle}"`);
} catch (err) {
log(rec.id, `Title generation failed, keeping initial title: ${String(err)}`);
}
// Save results to DB
log(rec.id, 'Saving results to DB');
await db
.update(recommendations)
.set({ recommendations: curatorOutput, status: 'done' })
.set({ recommendations: curatorOutput, status: 'done', title: aiTitle })
.where(eq(recommendations.id, rec.id));
sseWrite({ stage: 'complete', status: 'done' });

View File

@@ -13,6 +13,7 @@ export default async function recommendationsRoute(fastify: FastifyInstance) {
liked_shows?: string;
disliked_shows?: string;
themes?: string;
brainstorm_count?: number;
};
const title = (body.main_prompt ?? '')
@@ -21,6 +22,9 @@ export default async function recommendationsRoute(fastify: FastifyInstance) {
.slice(0, 5)
.join(' ');
const rawCount = Number(body.brainstorm_count ?? 100);
const brainstorm_count = Number.isFinite(rawCount) ? Math.min(200, Math.max(50, rawCount)) : 100;
const [rec] = await db
.insert(recommendations)
.values({
@@ -29,6 +33,7 @@ export default async function recommendationsRoute(fastify: FastifyInstance) {
liked_shows: body.liked_shows ?? '',
disliked_shows: body.disliked_shows ?? '',
themes: body.themes ?? '',
brainstorm_count,
status: 'pending',
})
.returning({ id: recommendations.id });

View File

@@ -9,7 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.29.0"
"preact": "^10.29.0",
"preact-router": "^4.1.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.10.4",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@@ -19,6 +19,7 @@ export function createRecommendation(body: {
liked_shows: string;
disliked_shows: string;
themes: string;
brainstorm_count?: number;
}): Promise<{ id: string }> {
return request('/recommendations', {
method: 'POST',

View File

@@ -1,5 +1,15 @@
import { Router, Route } from 'preact-router';
import { Home } from './pages/Home.js';
import { Recom } from './pages/Recom.js';
import { RecommendationsProvider } from './context/RecommendationsContext.js';
export function App() {
return <Home />;
return (
<RecommendationsProvider>
<Router>
<Route path="/" component={Home} />
<Route path="/recom/:id" component={Recom} />
</Router>
</RecommendationsProvider>
);
}

View File

@@ -0,0 +1,151 @@
/* ── Cards ─────────────────────────────────────────────── */
.cards-grid {
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 32px;
}
.card {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px;
transition: border-color 0.15s;
}
.card:hover {
border-color: var(--bg-surface-3);
}
.card-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
flex-wrap: wrap;
}
.badge {
font-size: 11px;
font-weight: 600;
padding: 2px 8px;
border-radius: 100px;
text-transform: uppercase;
letter-spacing: 0.04em;
flex-shrink: 0;
}
.badge-green {
background: rgba(34, 197, 94, 0.15);
color: #4ade80;
}
.badge-blue {
background: rgba(59, 130, 246, 0.15);
color: #60a5fa;
}
.badge-yellow {
background: rgba(234, 179, 8, 0.15);
color: #facc15;
}
.badge-red {
background: rgba(239, 68, 68, 0.15);
color: #f87171;
}
.card-title {
font-size: 16px;
font-weight: 600;
color: var(--text);
}
.card-explanation {
font-size: 13px;
color: var(--text-muted);
line-height: 1.5;
margin-bottom: 12px;
}
.card-feedback {
border-top: 1px solid var(--border);
padding-top: 10px;
}
.star-rating {
display: flex;
align-items: center;
gap: 2px;
}
.star-btn {
background: none;
border: none;
cursor: pointer;
font-size: 18px;
color: var(--text-dim);
padding: 0 2px;
transition: color 0.1s, transform 0.1s;
}
.star-btn:hover,
.star-btn.star-active {
color: var(--yellow);
}
.star-btn:hover {
transform: scale(1.1);
}
.feedback-saved {
margin-left: 8px;
font-size: 12px;
color: var(--green);
font-weight: 500;
}
.comment-area {
margin-top: 8px;
display: flex;
flex-direction: column;
gap: 6px;
}
.comment-input {
font-size: 13px;
resize: vertical;
}
/* ── Rerank Button ──────────────────────────────────────── */
.rerank-section {
padding: 16px 0 32px;
display: flex;
justify-content: center;
}
.btn-rerank {
padding: 12px 28px;
background: var(--bg-surface-2);
color: var(--text);
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s, border-color 0.15s;
}
.btn-rerank:hover:not(:disabled) {
background: var(--bg-surface-3);
border-color: var(--accent);
color: var(--accent);
}
.btn-rerank:disabled {
opacity: 0.4;
cursor: not-allowed;
}

View File

@@ -0,0 +1,105 @@
/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
backdrop-filter: blur(2px);
}
.modal {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: 12px;
width: 650px;
max-width: 96vw;
max-height: 90vh;
overflow-y: auto;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 20px 0;
}
.modal-header h2 {
font-size: 18px;
font-weight: 700;
}
.modal-close {
background: none;
border: none;
font-size: 22px;
color: var(--text-muted);
cursor: pointer;
line-height: 1;
padding: 0;
}
.modal-close:hover {
color: var(--text);
}
.modal-form {
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
flex: 1;
}
.form-group label {
font-size: 13px;
font-weight: 500;
color: var(--text-muted);
}
.form-input,
.form-textarea {
background: var(--bg-surface-2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
color: var(--text);
font-size: 14px;
padding: 10px 12px;
outline: none;
transition: border-color 0.15s;
font-family: inherit;
width: 100%;
}
.form-input[type="range"] {
padding: 0;
cursor: pointer;
}
.form-input:focus,
.form-textarea:focus {
border-color: var(--accent);
}
.form-textarea {
resize: vertical;
min-height: 80px;
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
padding-top: 4px;
}

View File

@@ -1,4 +1,5 @@
import { useState } from 'preact/hooks';
import './Modal.css';
interface NewRecommendationModalProps {
onClose: () => void;
@@ -7,6 +8,7 @@ interface NewRecommendationModalProps {
liked_shows: string;
disliked_shows: string;
themes: string;
brainstorm_count?: number;
}) => Promise<void>;
}
@@ -15,6 +17,7 @@ export function NewRecommendationModal({ onClose, onSubmit }: NewRecommendationM
const [likedShows, setLikedShows] = useState('');
const [dislikedShows, setDislikedShows] = useState('');
const [themes, setThemes] = useState('');
const [brainstormCount, setBrainstormCount] = useState(100);
const [loading, setLoading] = useState(false);
const handleSubmit = async (e: Event) => {
@@ -27,6 +30,7 @@ export function NewRecommendationModal({ onClose, onSubmit }: NewRecommendationM
liked_shows: likedShows.trim(),
disliked_shows: dislikedShows.trim(),
themes: themes.trim(),
brainstorm_count: brainstormCount,
});
onClose();
} finally {
@@ -62,30 +66,28 @@ export function NewRecommendationModal({ onClose, onSubmit }: NewRecommendationM
/>
</div>
<div class="form-row">
<div class="form-group">
<label for="liked-shows">Shows you liked</label>
<input
id="liked-shows"
type="text"
class="form-input"
placeholder="e.g. Breaking Bad, The Wire"
value={likedShows}
onInput={(e) => setLikedShows((e.target as HTMLInputElement).value)}
/>
</div>
<div class="form-group">
<label for="liked-shows">Shows you liked</label>
<input
id="liked-shows"
type="text"
class="form-input"
placeholder="e.g. Breaking Bad, The Wire"
value={likedShows}
onInput={(e) => setLikedShows((e.target as HTMLInputElement).value)}
/>
</div>
<div class="form-group">
<label for="disliked-shows">Shows you disliked</label>
<input
id="disliked-shows"
type="text"
class="form-input"
placeholder="e.g. Game of Thrones"
value={dislikedShows}
onInput={(e) => setDislikedShows((e.target as HTMLInputElement).value)}
/>
</div>
<div class="form-group">
<label for="disliked-shows">Shows you disliked</label>
<input
id="disliked-shows"
type="text"
class="form-input"
placeholder="e.g. Game of Thrones"
value={dislikedShows}
onInput={(e) => setDislikedShows((e.target as HTMLInputElement).value)}
/>
</div>
<div class="form-group">
@@ -100,6 +102,20 @@ export function NewRecommendationModal({ onClose, onSubmit }: NewRecommendationM
/>
</div>
<div class="form-group">
<label for="brainstorm-count">Shows to brainstorm ({brainstormCount})</label>
<input
id="brainstorm-count"
type="range"
class="form-input"
min={50}
max={200}
step={10}
value={brainstormCount}
onInput={(e) => setBrainstormCount(Number((e.target as HTMLInputElement).value))}
/>
</div>
<div class="modal-actions">
<button type="button" class="btn-secondary" onClick={onClose} disabled={loading}>
Cancel

View File

@@ -0,0 +1,86 @@
/* ── Pipeline Progress ──────────────────────────────────── */
.pipeline-progress {
padding: 40px 0;
}
.pipeline-title {
font-size: 18px;
font-weight: 600;
color: var(--text);
margin-bottom: 24px;
}
.pipeline-steps {
list-style: none;
display: flex;
flex-direction: column;
gap: 12px;
}
.pipeline-step {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 14px;
}
.pipeline-step--running {
border-color: var(--accent);
background: var(--accent-dim);
}
.pipeline-step--done {
border-color: rgba(34, 197, 94, 0.3);
background: rgba(34, 197, 94, 0.05);
}
.pipeline-step--error {
border-color: rgba(239, 68, 68, 0.3);
background: rgba(239, 68, 68, 0.05);
}
.stage-icon {
font-size: 16px;
width: 20px;
text-align: center;
}
.stage-done {
color: var(--green);
}
.stage-error {
color: var(--red);
}
.stage-running {
color: var(--accent);
}
.stage-pending {
color: var(--text-dim);
}
.spinner {
display: inline-block;
animation: spin 1s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.pipeline-step-label {
font-weight: 500;
}

View File

@@ -1,3 +1,4 @@
import './PipelineProgress.css';
import type { StageMap, StageStatus } from '../types/index.js';
const STAGES: { key: keyof StageMap; label: string }[] = [

View File

@@ -1,4 +1,5 @@
import { useState } from 'preact/hooks';
import './Cards.css';
import type { CuratorOutput, CuratorCategory } from '../types/index.js';
interface RecommendationCardProps {

View File

@@ -0,0 +1,124 @@
/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
width: var(--sidebar-width);
background: var(--bg-surface);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow: hidden;
flex-shrink: 0;
}
.sidebar-header {
padding: 20px 16px 12px;
border-bottom: 1px solid var(--border);
text-align: center;
}
.sidebar-title {
font-size: 24px;
font-weight: 700;
color: var(--text);
letter-spacing: -0.3px;
text-decoration: none;
display: inline-block;
transition: color 0.15s ease;
padding-bottom: 10px;
}
.sidebar-title:hover {
color: var(--accent);
}
.btn-new {
margin: 12px;
padding: 10px 14px;
background: var(--accent);
color: #fff;
border: none;
border-radius: var(--radius);
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
text-align: left;
}
.btn-new:hover {
background: var(--accent-hover);
}
.sidebar-section-label {
padding: 8px 16px 4px;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--text-dim);
}
.sidebar-list {
list-style: none;
overflow-y: auto;
flex: 1;
padding: 4px 8px 8px;
}
.sidebar-empty {
padding: 8px;
color: var(--text-dim);
font-size: 13px;
}
.sidebar-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 10px;
border-radius: var(--radius-sm);
cursor: pointer;
color: var(--text-muted);
font-size: 13px;
transition: background 0.1s, color 0.1s;
user-select: none;
}
.sidebar-item:hover {
background: var(--bg-surface-2);
color: var(--text);
}
.sidebar-item.selected {
background: var(--accent-dim);
color: var(--text);
}
.sidebar-icon {
font-size: 12px;
width: 16px;
text-align: center;
flex-shrink: 0;
}
.status-done {
color: var(--green);
}
.status-error {
color: var(--red);
}
.status-running {
color: var(--accent);
}
.status-pending {
color: var(--text-dim);
}
.sidebar-item-title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

View File

@@ -1,3 +1,4 @@
import './Sidebar.css';
import type { RecommendationSummary } from '../types/index.js';
interface SidebarProps {
@@ -29,7 +30,7 @@ export function Sidebar({ list, selectedId, onSelect, onNewClick }: SidebarProps
return (
<aside class="sidebar">
<div class="sidebar-header">
<span class="sidebar-title">Recommender</span>
<a href="/" class="sidebar-title">Recommender</a>
</div>
<button class="btn-new" onClick={onNewClick}>

View File

@@ -0,0 +1,18 @@
import { createContext } from 'preact';
import { useContext } from 'preact/hooks';
import { useRecommendations } from '../hooks/useRecommendations.js';
import type { ComponentChildren } from 'preact';
type Value = ReturnType<typeof useRecommendations>;
const Ctx = createContext<Value | null>(null);
export function RecommendationsProvider({ children }: { children: ComponentChildren }) {
return <Ctx.Provider value={useRecommendations()}>{children}</Ctx.Provider>;
}
export function useRecommendationsContext(): Value {
const ctx = useContext(Ctx);
if (!ctx) throw new Error('Must be inside RecommendationsProvider');
return ctx;
}

View File

@@ -34,6 +34,7 @@ export function useRecommendations() {
liked_shows: string;
disliked_shows: string;
themes: string;
brainstorm_count?: number;
}) => {
const { id } = await createRecommendation(body);
await refreshList();

View File

@@ -1,4 +1,6 @@
*, *::before, *::after {
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
@@ -30,7 +32,9 @@
-webkit-font-smoothing: antialiased;
}
html, body, #app {
html,
body,
#app {
height: 100%;
width: 100%;
overflow: hidden;
@@ -50,112 +54,7 @@ html, body, #app {
padding: 32px;
}
/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
width: var(--sidebar-width);
background: var(--bg-surface);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow: hidden;
flex-shrink: 0;
}
.sidebar-header {
padding: 20px 16px 12px;
border-bottom: 1px solid var(--border);
}
.sidebar-title {
font-size: 16px;
font-weight: 700;
color: var(--text);
letter-spacing: -0.3px;
}
.btn-new {
margin: 12px;
padding: 10px 14px;
background: var(--accent);
color: #fff;
border: none;
border-radius: var(--radius);
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
text-align: left;
}
.btn-new:hover {
background: var(--accent-hover);
}
.sidebar-section-label {
padding: 8px 16px 4px;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--text-dim);
}
.sidebar-list {
list-style: none;
overflow-y: auto;
flex: 1;
padding: 4px 8px 8px;
}
.sidebar-empty {
padding: 8px;
color: var(--text-dim);
font-size: 13px;
}
.sidebar-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 10px;
border-radius: var(--radius-sm);
cursor: pointer;
color: var(--text-muted);
font-size: 13px;
transition: background 0.1s, color 0.1s;
user-select: none;
}
.sidebar-item:hover {
background: var(--bg-surface-2);
color: var(--text);
}
.sidebar-item.selected {
background: var(--accent-dim);
color: var(--text);
}
.sidebar-icon {
font-size: 12px;
width: 16px;
text-align: center;
flex-shrink: 0;
}
.status-done { color: var(--green); }
.status-error { color: var(--red); }
.status-running { color: var(--accent); }
.status-pending { color: var(--text-dim); }
.sidebar-item-title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ── Main content areas ─────────────────────────────────── */
/* ── Shared content areas ───────────────────────────────── */
.empty-state {
display: flex;
@@ -174,239 +73,6 @@ html, body, #app {
color: var(--text);
}
.content-area {
max-width: 860px;
margin: 0 auto;
}
.rec-title {
font-size: 20px;
font-weight: 700;
color: var(--text);
margin-bottom: 24px;
}
.error-state {
color: var(--text-muted);
}
.error-state h2 {
color: var(--red);
margin-bottom: 8px;
}
.error-state p {
margin-bottom: 16px;
}
/* ── Pipeline Progress ──────────────────────────────────── */
.pipeline-progress {
padding: 40px 0;
}
.pipeline-title {
font-size: 18px;
font-weight: 600;
color: var(--text);
margin-bottom: 24px;
}
.pipeline-steps {
list-style: none;
display: flex;
flex-direction: column;
gap: 12px;
}
.pipeline-step {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 14px;
}
.pipeline-step--running {
border-color: var(--accent);
background: var(--accent-dim);
}
.pipeline-step--done {
border-color: rgba(34, 197, 94, 0.3);
background: rgba(34, 197, 94, 0.05);
}
.pipeline-step--error {
border-color: rgba(239, 68, 68, 0.3);
background: rgba(239, 68, 68, 0.05);
}
.stage-icon {
font-size: 16px;
width: 20px;
text-align: center;
}
.stage-done { color: var(--green); }
.stage-error { color: var(--red); }
.stage-running { color: var(--accent); }
.stage-pending { color: var(--text-dim); }
.spinner {
display: inline-block;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.pipeline-step-label {
font-weight: 500;
}
/* ── Cards ─────────────────────────────────────────────── */
.cards-grid {
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 32px;
}
.card {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px;
transition: border-color 0.15s;
}
.card:hover {
border-color: var(--bg-surface-3);
}
.card-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
flex-wrap: wrap;
}
.badge {
font-size: 11px;
font-weight: 600;
padding: 2px 8px;
border-radius: 100px;
text-transform: uppercase;
letter-spacing: 0.04em;
flex-shrink: 0;
}
.badge-green { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-yellow{ background: rgba(234,179,8,0.15); color: #facc15; }
.badge-red { background: rgba(239,68,68,0.15); color: #f87171; }
.card-title {
font-size: 16px;
font-weight: 600;
color: var(--text);
}
.card-explanation {
font-size: 13px;
color: var(--text-muted);
line-height: 1.5;
margin-bottom: 12px;
}
.card-feedback {
border-top: 1px solid var(--border);
padding-top: 10px;
}
.star-rating {
display: flex;
align-items: center;
gap: 2px;
}
.star-btn {
background: none;
border: none;
cursor: pointer;
font-size: 18px;
color: var(--text-dim);
padding: 0 2px;
transition: color 0.1s, transform 0.1s;
}
.star-btn:hover,
.star-btn.star-active {
color: var(--yellow);
}
.star-btn:hover {
transform: scale(1.1);
}
.feedback-saved {
margin-left: 8px;
font-size: 12px;
color: var(--green);
font-weight: 500;
}
.comment-area {
margin-top: 8px;
display: flex;
flex-direction: column;
gap: 6px;
}
.comment-input {
font-size: 13px;
resize: vertical;
}
/* ── Rerank Button ──────────────────────────────────────── */
.rerank-section {
padding: 16px 0 32px;
display: flex;
justify-content: center;
}
.btn-rerank {
padding: 12px 28px;
background: var(--bg-surface-2);
color: var(--text);
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s, border-color 0.15s;
}
.btn-rerank:hover:not(:disabled) {
background: var(--bg-surface-3);
border-color: var(--accent);
color: var(--accent);
}
.btn-rerank:disabled {
opacity: 0.4;
cursor: not-allowed;
}
/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
@@ -450,109 +116,3 @@ html, body, #app {
.btn-secondary:hover:not(:disabled) {
background: var(--bg-surface-3);
}
/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
backdrop-filter: blur(2px);
}
.modal {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: 12px;
width: 540px;
max-width: 96vw;
max-height: 90vh;
overflow-y: auto;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 20px 0;
}
.modal-header h2 {
font-size: 18px;
font-weight: 700;
}
.modal-close {
background: none;
border: none;
font-size: 22px;
color: var(--text-muted);
cursor: pointer;
line-height: 1;
padding: 0;
}
.modal-close:hover {
color: var(--text);
}
.modal-form {
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
flex: 1;
}
.form-group label {
font-size: 13px;
font-weight: 500;
color: var(--text-muted);
}
.form-row {
display: flex;
gap: 12px;
}
.form-input,
.form-textarea {
background: var(--bg-surface-2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
color: var(--text);
font-size: 14px;
padding: 10px 12px;
outline: none;
transition: border-color 0.15s;
font-family: inherit;
width: 100%;
}
.form-input:focus,
.form-textarea:focus {
border-color: var(--accent);
}
.form-textarea {
resize: vertical;
min-height: 80px;
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
padding-top: 4px;
}

View File

@@ -0,0 +1,73 @@
/* ── Landing page ───────────────────────────────────────── */
.landing-layout {
display: flex;
height: 100vh;
position: relative;
overflow: hidden;
}
.landing-bg {
position: absolute;
inset: -6px;
/* overflow slightly to hide blur edges */
background: url('/wallpaper.png') center / cover no-repeat;
filter: blur(3px) brightness(0.35);
z-index: 0;
}
.landing-layout .sidebar {
position: relative;
z-index: 1;
background: rgba(26, 29, 39, 0.85);
backdrop-filter: blur(8px);
}
.landing-main {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 28px;
text-align: center;
position: relative;
z-index: 1;
padding: 40px;
}
.landing-title {
font-size: 5rem;
font-weight: 800;
color: #fff;
letter-spacing: -2px;
line-height: 1;
}
.landing-tagline {
font-size: 1.4rem;
color: rgba(255, 255, 255, 0.6);
font-weight: 400;
}
.btn-gradient {
padding: 16px 42px;
font-size: 1.20rem;
font-weight: 700;
color: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
cursor: pointer;
background: linear-gradient(135deg, rgba(113, 88, 226, 0.8), rgba(61, 59, 243, 0.8));
backdrop-filter: blur(6px);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.1);
transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
letter-spacing: 0.02em;
}
.btn-gradient:hover {
transform: translateY(-2px);
color: #fff;
background: linear-gradient(135deg, rgba(113, 88, 226, 0.95), rgba(41, 121, 255, 0.95));
box-shadow: 0 8px 24px rgba(113, 88, 226, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

View File

@@ -1,186 +1,43 @@
import { useState, useCallback, useEffect } from 'preact/hooks';
import { useState } from 'preact/hooks';
import './Home.css';
import { route } from 'preact-router';
import { Sidebar } from '../components/Sidebar.js';
import { NewRecommendationModal } from '../components/NewRecommendationModal.js';
import { PipelineProgress } from '../components/PipelineProgress.js';
import { RecommendationCard } from '../components/RecommendationCard.js';
import { useRecommendations } from '../hooks/useRecommendations.js';
import { useSSE } from '../hooks/useSSE.js';
import { getRecommendation } from '../api/client.js';
import type { Recommendation, SSEEvent, StageMap, PipelineStage } from '../types/index.js';
const DEFAULT_STAGES: StageMap = {
interpreter: 'pending',
retrieval: 'pending',
ranking: 'pending',
curator: 'pending',
};
const STAGE_ORDER: (keyof StageMap)[] = ['interpreter', 'retrieval', 'ranking', 'curator'];
import { useRecommendationsContext } from '../context/RecommendationsContext.js';
export function Home() {
const {
list,
selectedId,
feedback,
setSelectedId,
createNew,
rerank,
submitFeedback,
updateStatus,
refreshList,
} = useRecommendations();
const { list, createNew } = useRecommendationsContext();
const [showModal, setShowModal] = useState(false);
const [selectedRec, setSelectedRec] = useState<Recommendation | null>(null);
const [stages, setStages] = useState<StageMap>(DEFAULT_STAGES);
const [sseUrl, setSseUrl] = useState<string | null>(null);
// Load full recommendation when selected
useEffect(() => {
if (!selectedId) {
setSelectedRec(null);
return;
}
void getRecommendation(selectedId).then((rec) => {
setSelectedRec(rec);
// If already running or pending, open SSE
if (rec.status === 'running' || rec.status === 'pending') {
setStages(DEFAULT_STAGES);
setSseUrl(`/api/recommendations/${selectedId}/stream`);
}
});
}, [selectedId]);
const handleSSEEvent = useCallback(
(event: SSEEvent) => {
if (!selectedId) return;
if (event.stage !== 'complete') {
const stageKey = event.stage as keyof StageMap;
if (STAGE_ORDER.includes(stageKey)) {
setStages((prev) => ({
...prev,
[stageKey]: event.status === 'start' ? 'running' : event.status === 'done' ? 'done' : 'error',
}));
}
}
if (event.stage === 'complete' && event.status === 'done') {
setSseUrl(null);
updateStatus(selectedId, 'done');
// Reload full recommendation to get results
void getRecommendation(selectedId).then(setSelectedRec);
void refreshList();
}
if (event.status === 'error') {
setSseUrl(null);
updateStatus(selectedId, 'error');
const stageKey = event.stage as PipelineStage;
if (stageKey !== 'complete') {
setStages((prev) => ({ ...prev, [stageKey as keyof StageMap]: 'error' }));
}
}
},
[selectedId, updateStatus, refreshList],
);
useSSE(sseUrl, handleSSEEvent);
const handleSelect = (id: string) => {
setSseUrl(null);
setStages(DEFAULT_STAGES);
setSelectedId(id);
};
const handleSelect = (id: string) => route(`/recom/${id}`);
const handleCreateNew = async (body: {
main_prompt: string;
liked_shows: string;
disliked_shows: string;
themes: string;
brainstorm_count?: number;
}) => {
const id = await createNew(body);
setStages(DEFAULT_STAGES);
setSseUrl(`/api/recommendations/${id}/stream`);
route(`/recom/${id}`);
};
const handleRerank = async () => {
if (!selectedId) return;
await rerank(selectedId);
setStages(DEFAULT_STAGES);
setSseUrl(`/api/recommendations/${selectedId}/stream`);
setSelectedRec((prev) => (prev ? { ...prev, status: 'pending' } : null));
};
const isRunning =
selectedRec?.status === 'running' || selectedRec?.status === 'pending' || !!sseUrl;
const feedbackMap = new Map(feedback.map((f) => [f.tv_show_name, f]));
return (
<div class="layout">
<div class="landing-layout">
<div class="landing-bg" />
<Sidebar
list={list}
selectedId={selectedId}
selectedId={null}
onSelect={handleSelect}
onNewClick={() => setShowModal(true)}
/>
<main class="main-content">
{!selectedId && (
<div class="empty-state">
<h2>TV Show Recommender</h2>
<p>Click <strong>+ New Recommendation</strong> to get started.</p>
</div>
)}
{selectedId && isRunning && (
<div class="content-area">
<PipelineProgress stages={stages} />
</div>
)}
{selectedId && !isRunning && selectedRec?.status === 'done' && selectedRec.recommendations && (
<div class="content-area">
<h2 class="rec-title">{selectedRec.title}</h2>
<div class="cards-grid">
{selectedRec.recommendations.map((show) => (
<RecommendationCard
key={show.title}
show={show}
existingFeedback={feedbackMap.get(show.title)}
onFeedback={async (name, stars, comment) => {
await submitFeedback({ tv_show_name: name, stars, feedback: comment });
}}
/>
))}
</div>
<div class="rerank-section">
<button
class="btn-rerank"
onClick={handleRerank}
disabled={feedback.length === 0}
title={feedback.length === 0 ? 'Rate at least one show to enable re-ranking' : 'Re-rank based on your feedback'}
>
Re-rank with Feedback {feedback.length > 0 ? `(${feedback.length} rated)` : ''}
</button>
</div>
</div>
)}
{selectedId && !isRunning && selectedRec?.status === 'error' && (
<div class="content-area error-state">
<h2>Something went wrong</h2>
<p>The pipeline encountered an error. You can try again by clicking Re-rank.</p>
<button class="btn-primary" onClick={handleRerank}>
Try Again
</button>
</div>
)}
<main class="landing-main">
<h1 class="landing-title">Recommender</h1>
<p class="landing-tagline">Discover your next favorite show, powered by AI.</p>
<button class="btn-gradient" onClick={() => setShowModal(true)}>
Get Started
</button>
</main>
{showModal && (
<NewRecommendationModal
onClose={() => setShowModal(false)}

View File

@@ -0,0 +1,30 @@
/* ── Recom page ─────────────────────────────────────────── */
.recom-content {
min-height: 100%;
}
.content-area {
max-width: 860px;
margin: 0 auto;
}
.rec-title {
font-size: 20px;
font-weight: 700;
color: var(--text);
margin-bottom: 24px;
}
.error-state {
color: var(--text-muted);
}
.error-state h2 {
color: var(--red);
margin-bottom: 8px;
}
.error-state p {
margin-bottom: 16px;
}

View File

@@ -0,0 +1,169 @@
import { useState, useCallback, useEffect } from 'preact/hooks';
import './Recom.css';
import { route } from 'preact-router';
import { PipelineProgress } from '../components/PipelineProgress.js';
import { RecommendationCard } from '../components/RecommendationCard.js';
import { Sidebar } from '../components/Sidebar.js';
import { NewRecommendationModal } from '../components/NewRecommendationModal.js';
import { useRecommendationsContext } from '../context/RecommendationsContext.js';
import { useSSE } from '../hooks/useSSE.js';
import { getRecommendation } from '../api/client.js';
import type { Recommendation, SSEEvent, StageMap, PipelineStage } from '../types/index.js';
interface RecomProps {
id: string;
path?: string;
}
const DEFAULT_STAGES: StageMap = {
interpreter: 'pending',
retrieval: 'pending',
ranking: 'pending',
curator: 'pending',
};
const STAGE_ORDER: (keyof StageMap)[] = ['interpreter', 'retrieval', 'ranking', 'curator'];
export function Recom({ id }: RecomProps) {
const { list, feedback, submitFeedback, rerank, updateStatus, refreshList, createNew } = useRecommendationsContext();
const [rec, setRec] = useState<Recommendation | null>(null);
const [stages, setStages] = useState<StageMap>(DEFAULT_STAGES);
const [sseUrl, setSseUrl] = useState<string | null>(null);
const [showModal, setShowModal] = useState(false);
useEffect(() => {
setRec(null);
setStages(DEFAULT_STAGES);
setSseUrl(null);
getRecommendation(id)
.then((data) => {
setRec(data);
if (data.status === 'running' || data.status === 'pending') {
setStages(DEFAULT_STAGES);
setSseUrl(`/api/recommendations/${id}/stream`);
}
})
.catch(() => route('/'));
}, [id]);
const handleSSEEvent = useCallback(
(event: SSEEvent) => {
if (event.stage !== 'complete') {
const stageKey = event.stage as keyof StageMap;
if (STAGE_ORDER.includes(stageKey)) {
setStages((prev) => ({
...prev,
[stageKey]: event.status === 'start' ? 'running' : event.status === 'done' ? 'done' : 'error',
}));
}
}
if (event.stage === 'complete' && event.status === 'done') {
setSseUrl(null);
updateStatus(id, 'done');
void getRecommendation(id).then(setRec);
void refreshList();
}
if (event.status === 'error') {
setSseUrl(null);
updateStatus(id, 'error');
const stageKey = event.stage as PipelineStage;
if (stageKey !== 'complete') {
setStages((prev) => ({ ...prev, [stageKey as keyof StageMap]: 'error' }));
}
}
},
[id, updateStatus, refreshList],
);
useSSE(sseUrl, handleSSEEvent);
const handleRerank = async () => {
await rerank(id);
setStages(DEFAULT_STAGES);
setSseUrl(`/api/recommendations/${id}/stream`);
setRec((prev) => (prev ? { ...prev, status: 'pending' } : null));
};
const handleCreateNew = async (body: {
main_prompt: string;
liked_shows: string;
disliked_shows: string;
themes: string;
brainstorm_count?: number;
}) => {
const newId = await createNew(body);
route(`/recom/${newId}`);
};
const isRunning = rec?.status === 'running' || rec?.status === 'pending' || !!sseUrl;
const feedbackMap = new Map(feedback.map((f) => [f.tv_show_name, f]));
return (
<div class="layout">
<Sidebar
list={list}
selectedId={id}
onSelect={(sid) => route(`/recom/${sid}`)}
onNewClick={() => setShowModal(true)}
/>
<main class="main-content">
<div class="recom-content">
{isRunning && (
<div class="content-area">
<PipelineProgress stages={stages} />
</div>
)}
{!isRunning && rec?.status === 'done' && rec.recommendations && (
<div class="content-area">
<h2 class="rec-title">{rec.title}</h2>
<div class="cards-grid">
{rec.recommendations.map((show) => (
<RecommendationCard
key={show.title}
show={show}
existingFeedback={feedbackMap.get(show.title)}
onFeedback={async (name, stars, comment) => {
await submitFeedback({ tv_show_name: name, stars, feedback: comment });
}}
/>
))}
</div>
<div class="rerank-section">
<button
class="btn-rerank"
onClick={handleRerank}
disabled={feedback.length === 0}
title={feedback.length === 0 ? 'Rate at least one show to enable re-ranking' : 'Re-rank based on your feedback'}
>
Re-rank with Feedback {feedback.length > 0 ? `(${feedback.length} rated)` : ''}
</button>
</div>
</div>
)}
{!isRunning && rec?.status === 'error' && (
<div class="content-area error-state">
<h2>Something went wrong</h2>
<p>The pipeline encountered an error. You can try again by clicking Re-rank.</p>
<button class="btn-primary" onClick={handleRerank}>
Try Again
</button>
</div>
)}
</div>
</main>
{showModal && (
<NewRecommendationModal
onClose={() => setShowModal(false)}
onSubmit={handleCreateNew}
/>
)}
</div>
);
}