feat: add SQLite write-ahead log and shared memory files.
@@ -0,0 +1,41 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
@@ -0,0 +1,5 @@
|
||||
<!-- BEGIN:nextjs-agent-rules -->
|
||||
# This is NOT the Next.js you know
|
||||
|
||||
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
|
||||
<!-- END:nextjs-agent-rules -->
|
||||
@@ -0,0 +1 @@
|
||||
@AGENTS.md
|
||||
@@ -0,0 +1,36 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
@@ -0,0 +1,18 @@
|
||||
import { defineConfig, globalIgnores } from "eslint/config";
|
||||
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||
import nextTs from "eslint-config-next/typescript";
|
||||
|
||||
const eslintConfig = defineConfig([
|
||||
...nextVitals,
|
||||
...nextTs,
|
||||
// Override default ignores of eslint-config-next.
|
||||
globalIgnores([
|
||||
// Default ignores of eslint-config-next:
|
||||
".next/**",
|
||||
"out/**",
|
||||
"build/**",
|
||||
"next-env.d.ts",
|
||||
]),
|
||||
]);
|
||||
|
||||
export default eslintConfig;
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: 'export',
|
||||
trailingSlash: true,
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "eslint",
|
||||
"tauri": "tauri"
|
||||
},
|
||||
"dependencies": {
|
||||
"clsx": "^2.1.1",
|
||||
"framer-motion": "^12.38.0",
|
||||
"lucide-react": "^1.7.0",
|
||||
"next": "16.2.2",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4",
|
||||
"tailwind-merge": "^3.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@tauri-apps/api": "^2.10.1",
|
||||
"@tauri-apps/cli": "^2.10.1",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "16.2.2",
|
||||
"tailwindcss": "^4",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
const config = {
|
||||
plugins: {
|
||||
"@tailwindcss/postcss": {},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1 @@
|
||||
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 391 B |
@@ -0,0 +1 @@
|
||||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 128 B |
@@ -0,0 +1 @@
|
||||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
||||
|
After Width: | Height: | Size: 385 B |
@@ -0,0 +1,4 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
/gen/schemas
|
||||
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
name = "app_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.5.6" }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
log = "0.4"
|
||||
tauri = { version = "2.10.3" }
|
||||
tauri-plugin-log = "2"
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default"
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 49 KiB |
@@ -0,0 +1,16 @@
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
tauri_plugin_log::Builder::default()
|
||||
.level(log::LevelFilter::Info)
|
||||
.build(),
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
app_lib::run();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "tinix-story",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tinix.story",
|
||||
"build": {
|
||||
"frontendDist": "../out",
|
||||
"devUrl": "http://localhost:3000",
|
||||
"beforeDevCommand": "npm run dev",
|
||||
"beforeBuildCommand": "npm run build"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "TiniX Story 1.0",
|
||||
"width": 1200,
|
||||
"height": 800,
|
||||
"resizable": true,
|
||||
"fullscreen": false
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
export default function ContinuePage() {
|
||||
const [projects, setProjects] = useState<any[]>([]);
|
||||
const [selectedId, setSelectedId] = useState("");
|
||||
const [project, setProject] = useState<any>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
api.listProjects().then(setProjects).catch(console.error);
|
||||
}, []);
|
||||
|
||||
const handleLoad = async (id: string) => {
|
||||
setSelectedId(id);
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await api.getProject(id);
|
||||
setProject(data);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col flex-1 p-8">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-3xl font-bold text-foreground">Continue Story</h1>
|
||||
<p className="text-zinc-500 mt-2">Resume writing from where you left off.</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-4 gap-8">
|
||||
{/* Project List Sidebar */}
|
||||
<div className="lg:col-span-1 space-y-4">
|
||||
<h3 className="font-semibold text-zinc-300">Select Project</h3>
|
||||
<div className="space-y-2 max-h-[600px] overflow-y-auto">
|
||||
{projects.map((p) => (
|
||||
<button
|
||||
key={p.id}
|
||||
onClick={() => handleLoad(p.id)}
|
||||
className={`w-full text-left p-3 rounded-lg border transition-all ${
|
||||
selectedId === p.id
|
||||
? "bg-brand-primary/20 border-brand-primary text-white"
|
||||
: "bg-background-card border-border-glass text-zinc-400 hover:border-zinc-500"
|
||||
}`}
|
||||
>
|
||||
<div className="font-medium truncate">{p.title}</div>
|
||||
<div className="text-xs opacity-60">{p.genre}</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Content Area */}
|
||||
<div className="lg:col-span-3 space-y-6">
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center h-64 text-zinc-500 animate-pulse">
|
||||
Loading project data...
|
||||
</div>
|
||||
) : project ? (
|
||||
<div className="space-y-6">
|
||||
<div className="p-6 rounded-xl border border-border-glass bg-background-card">
|
||||
<h2 className="text-2xl font-bold text-white mb-4">{project.title}</h2>
|
||||
<div className="grid grid-cols-3 gap-4 text-sm">
|
||||
<div className="p-3 bg-black/30 rounded border border-border-glass">
|
||||
<div className="text-zinc-500 text-xs uppercase mb-1">Chapters</div>
|
||||
<div className="text-white font-semibold">{project.completed_count} / {project.chapters?.length}</div>
|
||||
</div>
|
||||
<div className="p-3 bg-black/30 rounded border border-border-glass">
|
||||
<div className="text-zinc-500 text-xs uppercase mb-1">Total Words</div>
|
||||
<div className="text-white font-semibold">{project.total_words?.toLocaleString()}</div>
|
||||
</div>
|
||||
<div className="p-3 bg-black/30 rounded border border-border-glass">
|
||||
<div className="text-zinc-500 text-xs uppercase mb-1">Last Updated</div>
|
||||
<div className="text-white font-semibold">{new Date(project.updated_at).toLocaleDateString()}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold text-zinc-200">Chapter List</h3>
|
||||
<div className="space-y-2">
|
||||
{project.chapters?.map((ch: any) => (
|
||||
<div key={ch.num} className="p-4 bg-background-card border border-border-glass rounded-lg flex items-center justify-between group hover:border-brand-primary/50 transition-colors">
|
||||
<div>
|
||||
<span className="text-zinc-500 mr-2">#{ch.num}</span>
|
||||
<span className="text-white font-medium">{ch.title}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-xs text-zinc-500">{ch.word_count || 0} words</span>
|
||||
<button
|
||||
onClick={async () => {
|
||||
try {
|
||||
await api.startBulkGen({ project_id: selectedId, chapter_nums: [ch.num] });
|
||||
alert("Generation task started. Check the Task Sidebar!");
|
||||
} catch (err) {
|
||||
alert("Failed to start task");
|
||||
}
|
||||
}}
|
||||
className="px-4 py-1.5 bg-brand-primary/10 text-brand-primary border border-brand-primary/30 rounded hover:bg-brand-primary hover:text-black transition-all"
|
||||
>
|
||||
{ch.content ? "Rewrite" : "Write"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center h-96 border-2 border-dashed border-border-glass rounded-2xl text-zinc-600">
|
||||
<p>Please select a project from the sidebar to continue writing.</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
export default function CreatePage() {
|
||||
const [genres, setGenres] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [formData, setFormData] = useState({
|
||||
title: "",
|
||||
genre: "",
|
||||
character_setting: "",
|
||||
world_setting: "",
|
||||
plot_idea: "",
|
||||
total_chapters: 20
|
||||
});
|
||||
const [outline, setOutline] = useState<string>("");
|
||||
const [statusMsg, setStatusMsg] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch genres on mount
|
||||
api.getGenres().then((data) => {
|
||||
setGenres(data || []);
|
||||
if (data && data.length > 0) {
|
||||
setFormData((prev) => ({ ...prev, genre: data[0].name }));
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error("Error fetching genres:", err);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleGenerateOutline = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
setStatusMsg("Generating outline. Please wait...");
|
||||
setOutline("");
|
||||
|
||||
const res = await api.generateOutline({
|
||||
title: formData.title,
|
||||
genre: formData.genre,
|
||||
sub_genres: [],
|
||||
total_chapters: formData.total_chapters,
|
||||
character_setting: formData.character_setting,
|
||||
world_setting: formData.world_setting,
|
||||
plot_idea: formData.plot_idea
|
||||
});
|
||||
|
||||
setOutline(res.content || "");
|
||||
setStatusMsg(res.message || "Success");
|
||||
} catch (err: any) {
|
||||
setStatusMsg("Error: " + err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col flex-1 p-8">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-3xl font-bold text-foreground">Create Story</h1>
|
||||
<p className="text-zinc-500 mt-2">Design your novel settings and generate an outline.</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
{/* Form Column */}
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium text-zinc-300">Novel Title</label>
|
||||
<input
|
||||
className="w-full bg-background-card border border-border-glass rounded-md p-2 text-sm focus:border-brand-primary outline-none text-white"
|
||||
value={formData.title}
|
||||
onChange={(e) => setFormData({...formData, title: e.target.value})}
|
||||
placeholder="Enter your novel title..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium text-zinc-300">Genre</label>
|
||||
<select
|
||||
className="w-full bg-background-card border border-border-glass rounded-md p-2 text-sm focus:border-brand-primary outline-none text-white"
|
||||
value={formData.genre}
|
||||
onChange={(e) => setFormData({...formData, genre: e.target.value})}
|
||||
>
|
||||
{genres.map(g => (
|
||||
<option key={g.name} value={g.name}>{g.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium text-zinc-300">Character Settings</label>
|
||||
<textarea
|
||||
className="w-full bg-background-card border border-border-glass rounded-md p-2 text-sm min-h-[100px] focus:border-brand-primary outline-none text-white"
|
||||
value={formData.character_setting}
|
||||
onChange={(e) => setFormData({...formData, character_setting: e.target.value})}
|
||||
placeholder="Describe main characters, personalities..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium text-zinc-300">World Setting</label>
|
||||
<textarea
|
||||
className="w-full bg-background-card border border-border-glass rounded-md p-2 text-sm min-h-[100px] focus:border-brand-primary outline-none text-white"
|
||||
value={formData.world_setting}
|
||||
onChange={(e) => setFormData({...formData, world_setting: e.target.value})}
|
||||
placeholder="Describe the world, magic system, laws..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium text-zinc-300">Plot Idea</label>
|
||||
<textarea
|
||||
className="w-full bg-background-card border border-border-glass rounded-md p-2 text-sm min-h-[100px] focus:border-brand-primary outline-none text-white"
|
||||
value={formData.plot_idea}
|
||||
onChange={(e) => setFormData({...formData, plot_idea: e.target.value})}
|
||||
placeholder="Main conflict, goals, and ending idea..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
disabled={loading || !formData.title || !formData.genre}
|
||||
onClick={handleGenerateOutline}
|
||||
className="w-full py-3 bg-brand-primary text-black font-semibold rounded-md hover:bg-brand-secondary transition-colors disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Generating..." : "Generate Outline"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Outline / Results Column */}
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold text-foreground">Generated Outline</h2>
|
||||
|
||||
{statusMsg && (
|
||||
<div className="p-3 bg-blue-900/30 border border-blue-500/30 text-blue-300 rounded-md text-sm">
|
||||
{statusMsg}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<textarea
|
||||
className="w-full bg-black/40 border border-border-glass rounded-md p-4 text-sm h-[600px] font-mono text-zinc-300 focus:border-brand-primary outline-none resize-none"
|
||||
value={outline}
|
||||
readOnly
|
||||
placeholder="Your generated outline will appear here..."
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,87 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-brand-primary: #8b5cf6;
|
||||
--color-brand-secondary: #c084fc;
|
||||
--color-brand-accent: #6366f1;
|
||||
--color-background-deep: #09090b;
|
||||
--color-background-card: rgba(24, 24, 27, 0.6);
|
||||
--color-border-glass: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
:root {
|
||||
--foreground-rgb: 255, 255, 255;
|
||||
--background-start-rgb: 9, 9, 11;
|
||||
--background-end-rgb: 0, 0, 0;
|
||||
|
||||
--primary: #8b5cf6;
|
||||
--secondary: #c084fc;
|
||||
--accent: #6366f1;
|
||||
}
|
||||
|
||||
body {
|
||||
color: rgb(var(--foreground-rgb));
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
rgb(var(--background-end-rgb))
|
||||
)
|
||||
rgb(var(--background-start-rgb));
|
||||
min-height: 100vh;
|
||||
font-family: var(--font-geist-sans), Inter, sans-serif;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Glassmorphism Utilities */
|
||||
.glass {
|
||||
background: var(--color-background-card);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--color-border-glass);
|
||||
}
|
||||
|
||||
.glass-hover {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.glass-hover:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
@keyframes gradient-x {
|
||||
0% { background-position: 0% 50%; }
|
||||
50% { background-position: 100% 50%; }
|
||||
100% { background-position: 0% 50%; }
|
||||
}
|
||||
|
||||
.animate-gradient {
|
||||
background-size: 200% 200%;
|
||||
animation: gradient-x 6s ease infinite;
|
||||
}
|
||||
|
||||
/* Scrollbar Styling */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(139, 92, 246, 0.3);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(139, 92, 246, 0.5);
|
||||
}
|
||||
|
||||
/* Custom Selection */
|
||||
::selection {
|
||||
background: rgba(139, 92, 246, 0.3);
|
||||
color: white;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import { Sidebar } from "@/components/layout/Sidebar";
|
||||
import { TaskSidebar } from "@/components/layout/TaskSidebar";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "TiniX Story - AI Novel Creator",
|
||||
description: "Create amazing stories with AI",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html
|
||||
lang="en"
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased dark`}
|
||||
>
|
||||
<body className="flex min-h-screen text-foreground selection:bg-brand-primary/30">
|
||||
<Sidebar />
|
||||
<main className="flex-1 overflow-y-auto">
|
||||
{children}
|
||||
</main>
|
||||
<TaskSidebar />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="flex flex-col flex-1 p-8">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-3xl font-bold text-foreground">Dashboard</h1>
|
||||
<p className="text-zinc-500 mt-2">Welcome to TiniX Story - Advanced AI Novel Generator.</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div className="p-6 rounded-xl border border-border-glass bg-background-card">
|
||||
<h3 className="font-semibold text-lg text-brand-secondary mb-2">Recent Projects</h3>
|
||||
<p className="text-zinc-400 text-sm">No projects yet. Start by creating a new story!</p>
|
||||
</div>
|
||||
<div className="p-6 rounded-xl border border-border-glass bg-background-card">
|
||||
<h3 className="font-semibold text-lg text-brand-primary mb-2">Capabilities</h3>
|
||||
<ul className="text-zinc-400 text-sm space-y-2">
|
||||
<li>✨ AI Novel Generation</li>
|
||||
<li>🔄 Smart Continue</li>
|
||||
<li>📝 Advanced Rewrite</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
export default function SettingsPage() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [config, setConfig] = useState<any>(null);
|
||||
const [backends, setBackends] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const [cfgData, backendsData] = await Promise.all([
|
||||
api.getGenerationConfig(),
|
||||
api.getBackends()
|
||||
]);
|
||||
setConfig(cfgData);
|
||||
setBackends(backendsData);
|
||||
} catch (err) {
|
||||
console.error("Failed to load settings:", err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
loadSettings();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col flex-1 p-8">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-3xl font-bold text-foreground">Settings</h1>
|
||||
<p className="text-zinc-500 mt-2">Configure API backends and generation parameters.</p>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<p className="text-zinc-400 animate-pulse">Loading configuration...</p>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
{/* Backends Section */}
|
||||
<div className="p-6 rounded-xl border border-border-glass bg-background-card">
|
||||
<h3 className="font-semibold text-lg text-brand-secondary mb-4">API Backends</h3>
|
||||
<div className="space-y-4">
|
||||
{backends.length === 0 ? (
|
||||
<p className="text-sm text-zinc-400">No active backends configured.</p>
|
||||
) : (
|
||||
backends.map((b, i) => (
|
||||
<div key={i} className="p-4 bg-black/40 border border-border-glass rounded-md">
|
||||
<div className="flex justify-between items-center mb-2">
|
||||
<h4 className="font-medium text-white">{b.name}</h4>
|
||||
<span className={`px-2 py-1 text-xs rounded-full ${b.enabled ? 'bg-green-500/20 text-green-400' : 'bg-red-500/20 text-red-400'}`}>
|
||||
{b.enabled ? "Active" : "Disabled"}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-zinc-400">Type: {b.type} | Model: {b.model}</p>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Prompt/Generation Config Section */}
|
||||
<div className="p-6 rounded-xl border border-border-glass bg-background-card space-y-6">
|
||||
<h3 className="font-semibold text-lg text-brand-primary mb-2">Generation Defaults</h3>
|
||||
|
||||
{config && (
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs text-zinc-400">Temperature</label>
|
||||
<p className="text-sm text-white">{config.temperature}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs text-zinc-400">Target Words</label>
|
||||
<p className="text-sm text-white">{config.chapter_target_words}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs text-zinc-400">Writing Style</label>
|
||||
<p className="text-sm text-white">{config.writing_style}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs text-zinc-400">Tone</label>
|
||||
<p className="text-sm text-white">{config.writing_tone}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<p className="text-xs text-zinc-500 mt-4 italic">
|
||||
* Frontend editing of configuration is currently pending backend payload schemas.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
export default function ToolsPage() {
|
||||
const [text, setText] = useState("");
|
||||
const [result, setResult] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [mode, setMode] = useState<"rewrite" | "polish">("rewrite");
|
||||
|
||||
const handleProcess = async () => {
|
||||
if (!text.trim()) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
if (mode === "rewrite") {
|
||||
const res = await fetch('http://127.0.0.1:8000/rewrite', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ text, style_template: "", use_reflection: false })
|
||||
}).then(r => r.json());
|
||||
setResult(res.content);
|
||||
} else {
|
||||
const res = await fetch('http://127.0.0.1:8000/polish', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ text, polish_type: "general", use_reflection: false })
|
||||
}).then(r => r.json());
|
||||
setResult(res.content);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
setResult("Error processing text.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col flex-1 p-8">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-3xl font-bold text-foreground">Writing Tools</h1>
|
||||
<p className="text-zinc-500 mt-2">Rewrite or polish your content with AI precision.</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
{/* Input Area */}
|
||||
<div className="space-y-4">
|
||||
<div className="flex bg-background-card p-1 rounded-lg border border-border-glass w-fit">
|
||||
<button
|
||||
onClick={() => setMode("rewrite")}
|
||||
className={`px-4 py-2 rounded-md text-sm transition-all ${mode === "rewrite" ? "bg-brand-primary text-black font-semibold" : "text-zinc-400 hover:text-white"}`}
|
||||
>
|
||||
Rewrite
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setMode("polish")}
|
||||
className={`px-4 py-2 rounded-md text-sm transition-all ${mode === "polish" ? "bg-brand-primary text-black font-semibold" : "text-zinc-400 hover:text-white"}`}
|
||||
>
|
||||
Polish
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
className="w-full bg-background-card border border-border-glass rounded-xl p-4 text-sm h-[500px] focus:border-brand-primary outline-none resize-none text-white"
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder="Paste your content here..."
|
||||
/>
|
||||
|
||||
<button
|
||||
onClick={handleProcess}
|
||||
disabled={loading || !text}
|
||||
className="w-full py-4 bg-brand-primary text-black font-bold rounded-xl hover:bg-brand-secondary transition-all disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Processing..." : `Run ${mode === "rewrite" ? "Rewrite" : "Polish"}`}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Output Area */}
|
||||
<div className="space-y-4">
|
||||
<h3 className="font-semibold text-zinc-300">AI Result</h3>
|
||||
<div className="w-full bg-black/40 border border-border-glass rounded-xl p-6 text-sm h-[500px] overflow-y-auto text-zinc-300 relative">
|
||||
{result ? (
|
||||
<div className="whitespace-pre-wrap leading-relaxed">{result}</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full text-zinc-600 italic">
|
||||
Result will be displayed here...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{result && (
|
||||
<button
|
||||
onClick={() => { navigator.clipboard.writeText(result); alert("Copied!"); }}
|
||||
className="w-full py-2 bg-white/5 border border-border-glass text-zinc-300 rounded-lg hover:bg-white/10 transition-all"
|
||||
>
|
||||
Copy to Clipboard
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const navigation = [
|
||||
{ name: "Dashboard", href: "/" },
|
||||
{ name: "Create New", href: "/create" },
|
||||
{ name: "Continue Story", href: "/continue" },
|
||||
{ name: "Writing Tools", href: "/tools" },
|
||||
{ name: "Settings", href: "/settings" },
|
||||
];
|
||||
|
||||
export function Sidebar() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col w-64 bg-background-card border-r border-border-glass h-screen sticky top-0">
|
||||
<div className="flex items-center justify-center h-20 border-b border-border-glass">
|
||||
<h1 className="text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-brand-primary to-brand-secondary">
|
||||
TiniX Story
|
||||
</h1>
|
||||
</div>
|
||||
<nav className="flex-1 px-4 py-6 space-y-2">
|
||||
{navigation.map((item) => {
|
||||
const isActive = pathname === item.href || (item.href !== "/" && pathname.startsWith(item.href));
|
||||
return (
|
||||
<Link
|
||||
key={item.name}
|
||||
href={item.href}
|
||||
className={`flex items-center px-4 py-3 text-sm font-medium rounded-lg transition-all duration-200 ${
|
||||
isActive
|
||||
? "bg-brand-primary/20 text-brand-secondary border border-brand-primary/30"
|
||||
: "text-zinc-400 hover:bg-white/5 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
{item.name}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
<div className="p-4 border-t border-border-glass text-xs text-zinc-500 text-center">
|
||||
TiniX Story v1.0
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
export function TaskSidebar() {
|
||||
const [tasks, setTasks] = useState<any[]>([]);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let interval: any;
|
||||
if (isOpen) {
|
||||
const fetchTasks = async () => {
|
||||
try {
|
||||
const data = await api.listTasks();
|
||||
setTasks(data || []);
|
||||
} catch (err) {
|
||||
console.error("Error fetching tasks:", err);
|
||||
}
|
||||
};
|
||||
|
||||
fetchTasks();
|
||||
interval = setInterval(fetchTasks, 3000);
|
||||
}
|
||||
return () => clearInterval(interval);
|
||||
}, [isOpen]);
|
||||
|
||||
const activeCount = tasks.filter(t => t.status === "running" || t.status === "pending").length;
|
||||
|
||||
return (
|
||||
<div className={`fixed bottom-0 right-0 z-50 transition-all duration-300 ${isOpen ? "w-80 h-[500px]" : "w-12 h-12"}`}>
|
||||
{/* Toggle Button */}
|
||||
{!isOpen ? (
|
||||
<button
|
||||
onClick={() => setIsOpen(true)}
|
||||
className="w-12 h-12 bg-brand-primary text-black rounded-tl-xl flex items-center justify-center shadow-lg hover:bg-brand-secondary transition-colors relative"
|
||||
>
|
||||
<span>📋</span>
|
||||
{activeCount > 0 && (
|
||||
<span className="absolute -top-1 -left-1 w-5 h-5 bg-red-500 text-white text-[10px] font-bold rounded-full flex items-center justify-center animate-bounce">
|
||||
{activeCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
) : (
|
||||
<div className="w-full h-full bg-background-card border-l border-t border-border-glass rounded-tl-2xl shadow-2xl flex flex-col overflow-hidden">
|
||||
<div className="p-4 border-b border-border-glass flex justify-between items-center bg-white/5">
|
||||
<h3 className="font-bold text-white flex items-center gap-2">
|
||||
<span>📋</span> Task Queue
|
||||
</h3>
|
||||
<button onClick={() => setIsOpen(false)} className="text-zinc-500 hover:text-white">✕</button>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto p-4 space-y-4">
|
||||
{tasks.length === 0 && (
|
||||
<p className="text-center text-zinc-500 text-sm mt-10">No recent tasks.</p>
|
||||
)}
|
||||
|
||||
{tasks.map((task) => (
|
||||
<div key={task.id} className="p-3 bg-black/30 border border-border-glass rounded-lg space-y-2">
|
||||
<div className="flex justify-between items-start">
|
||||
<div className="text-xs font-semibold text-brand-primary truncate max-w-[150px]">
|
||||
{task.name}
|
||||
</div>
|
||||
<span className={`text-[10px] px-1.5 py-0.5 rounded uppercase font-bold ${
|
||||
task.status === 'completed' ? 'bg-green-500/20 text-green-400' :
|
||||
task.status === 'failed' ? 'bg-red-500/20 text-red-400' :
|
||||
task.status === 'running' ? 'bg-blue-500/20 text-blue-400 animate-pulse' :
|
||||
'bg-zinc-700 text-zinc-400'
|
||||
}`}>
|
||||
{task.status}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="text-[11px] text-zinc-400 italic truncate">
|
||||
{task.message}
|
||||
</div>
|
||||
|
||||
{(task.status === 'running' || task.status === 'pending') && (
|
||||
<div className="space-y-1">
|
||||
<div className="w-full bg-white/5 h-1.5 rounded-full overflow-hidden">
|
||||
<div
|
||||
className="bg-brand-primary h-full transition-all duration-500"
|
||||
style={{ width: `${task.progress}%` }}
|
||||
></div>
|
||||
</div>
|
||||
<div className="flex justify-between text-[10px] text-zinc-500">
|
||||
<span>{Math.round(task.progress)}%</span>
|
||||
<button
|
||||
onClick={() => api.cancelTask(task.id)}
|
||||
className="text-red-400 hover:underline"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
const API_BASE_URL = 'http://127.0.0.1:8000';
|
||||
|
||||
export interface ProjectCreateReq {
|
||||
title: string;
|
||||
genre: string;
|
||||
sub_genres: string[];
|
||||
character_setting?: string;
|
||||
world_setting?: string;
|
||||
plot_idea?: string;
|
||||
}
|
||||
|
||||
export interface OutlineReq {
|
||||
title: string;
|
||||
genre: string;
|
||||
sub_genres: string[];
|
||||
total_chapters: number;
|
||||
character_setting: string;
|
||||
world_setting: string;
|
||||
plot_idea: string;
|
||||
custom_outline_prompt?: string;
|
||||
}
|
||||
|
||||
export const api = {
|
||||
// Check health
|
||||
async checkHealth() {
|
||||
const res = await fetch(`${API_BASE_URL}/health`);
|
||||
if (!res.ok) throw new Error('Network error');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Projects
|
||||
async listProjects() {
|
||||
const res = await fetch(`${API_BASE_URL}/projects`);
|
||||
if (!res.ok) throw new Error('Failed to fetch projects');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
async getProject(id: string) {
|
||||
const res = await fetch(`${API_BASE_URL}/projects/${id}`);
|
||||
if (!res.ok) throw new Error('Failed to fetch project');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Get genres
|
||||
async getGenres() {
|
||||
const res = await fetch(`${API_BASE_URL}/genres`);
|
||||
if (!res.ok) throw new Error('Failed to fetch genres');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Generate outline
|
||||
async generateOutline(data: OutlineReq) {
|
||||
const res = await fetch(`${API_BASE_URL}/generate-outline`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error('Outline generation failed');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Create project
|
||||
async createProject(data: ProjectCreateReq) {
|
||||
const res = await fetch(`${API_BASE_URL}/projects`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error('Create project failed');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Get generic config
|
||||
async getGenerationConfig() {
|
||||
const res = await fetch(`${API_BASE_URL}/config/generation`);
|
||||
if (!res.ok) throw new Error('Failed to fetch config');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Get backends
|
||||
async getBackends() {
|
||||
const res = await fetch(`${API_BASE_URL}/config/backends`);
|
||||
if (!res.ok) throw new Error('Failed to fetch backends');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
// Task Management
|
||||
async listTasks() {
|
||||
const res = await fetch(`${API_BASE_URL}/tasks`);
|
||||
if (!res.ok) throw new Error('Failed to fetch tasks');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
async startBulkGen(data: { project_id: string, chapter_nums: number[], use_reflection?: boolean }) {
|
||||
const res = await fetch(`${API_BASE_URL}/tasks/generate-bulk`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to start bulk generation');
|
||||
return res.json();
|
||||
},
|
||||
|
||||
async cancelTask(taskId: string) {
|
||||
const res = await fetch(`${API_BASE_URL}/tasks/${taskId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
".next/dev/types/**/*.ts",
|
||||
"**/*.mts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||