Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ a wall others can remix, with attribution back to the original.

## Quick start

Node.js >= 18 and pnpm. Nothing else — no database to install, no tmux.
Node.js >= 22 and pnpm. Nothing else — no database to install, no tmux.

```bash
git clone https://github.com/CodeFox-Repo/codefox.git
Expand Down
15 changes: 15 additions & 0 deletions frontend/jest.onboarding-copy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
rootDir: '.',
testEnvironment: 'jsdom',
testMatch: ['<rootDir>/src/**/__tests__/onboarding-copy.test.tsx'],
moduleNameMapper: { '^@/(.*)$': '<rootDir>/src/$1' },
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: { jsx: 'react-jsx', module: 'commonjs' },
diagnostics: false,
},
],
},
};
4 changes: 2 additions & 2 deletions frontend/src/components/auth-choice-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function AuthChoiceModal({
<DialogContent className="sm:max-w-[425px] fixed top-[50%] left-[50%] transform -translate-x-[50%] -translate-y-[50%]">
{/* Invisible but accessible DialogTitle */}
<VisuallyHidden>
<DialogTitle>Choose Authentication Method</DialogTitle>
<DialogTitle>Welcome to CodeFox</DialogTitle>
</VisuallyHidden>

<BackgroundGradient className="rounded-[22px] p-4 bg-background">
Expand All @@ -32,7 +32,7 @@ export function AuthChoiceModal({
Welcome to CodeFox
</h2>
<p className="text-center text-muted-foreground">
Choose how you want to continue
Sign in or create an account to continue
</p>
<div className="space-y-4">
{/* Sign In button */}
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/chat/chat-bottombar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
* entry fall back to the raw tag so a config change still renders.
*/
const MODEL_LABELS: Record<string, string> = {
'google/gemini-3.7-flash@openrouter': '快速 · Fast',
'accounts/fireworks/models/qwen3p8-max': '强力 · Max',
'google/gemini-3.7-flash@openrouter': 'Fast',
'accounts/fireworks/models/qwen3p8-max': 'Max',
};
const modelLabel = (id: string) => MODEL_LABELS[id] ?? id;

Expand Down Expand Up @@ -366,9 +366,10 @@ export default function ChatBottombar({
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
name="message"
aria-label="Message CodeFox"
placeholder={
isStreaming
? 'Keep typing — sends when the agent finishes this turn'
? 'Write your next message. Press Enter or select Send to queue it.'
: 'Describe a change — the agent edits the real files'
}
className="resize-none px-2 py-2.5 w-full focus:outline-none bg-transparent text-foreground text-sm placeholder:text-muted-foreground dark:placeholder:text-muted-foreground"
Expand All @@ -387,7 +388,7 @@ export default function ChatBottombar({
type="button"
onClick={queueCurrentInput}
className="flex h-7 w-7 items-center justify-center rounded-md bg-secondary text-foreground transition-colors hover:bg-accent"
aria-label="Queue for the next turn"
aria-label="Send: queue message for the next turn"
>
<Send className="h-3.5 w-3.5" />
</button>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/chat/question-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export function QuestionCard({
{q.label}
{q.multi && (
<span className="ml-2 font-mono text-[10px] uppercase text-muted-foreground">
multi
Select all that apply
</span>
)}
</p>
Expand Down Expand Up @@ -322,6 +322,7 @@ export function QuestionCard({
{interactive && (
<div className="mt-5 space-y-3">
<input
aria-label="Additional details (optional)"
value={note}
onChange={(e) => setNote(e.target.value)}
placeholder="Anything else the agent should know? (optional)"
Expand Down
189 changes: 189 additions & 0 deletions frontend/src/components/root/__tests__/onboarding-copy.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import React, { createRef } from 'react';
import { act, fireEvent, render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { PromptForm } from '../prompt-form';
import ChatBottombar from '../../chat/chat-bottombar';

let mockMutationOptions: {
onCompleted: (data: unknown) => void;
onError: (error: Error) => void;
};
const mockRegenerate = jest.fn();
jest.mock('@apollo/client', () => ({
gql: () => 'query',
useQuery: () => ({ data: undefined }),
useMutation: (_query: unknown, options: typeof mockMutationOptions) => {
mockMutationOptions = options;
return [mockRegenerate];
},
}));
jest.mock('@/hooks/useModels', () => ({
useModels: () => ({
models: [],
loading: false,
setSelectedModel: jest.fn(),
}),
}));
jest.mock('@/app/log/logger', () => ({ logger: { error: jest.fn() } }));
jest.mock('typewriter-effect', () => () => null);
jest.mock('next/image', () => ({
__esModule: true,
default: (props: React.ImgHTMLAttributes<HTMLImageElement>) => (
<img {...props} />
),
}));
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, initial, animate, exit, transition, ...props }: any) => (
<div {...props}>{children}</div>
),
},
AnimatePresence: ({ children }: { children: React.ReactNode }) => (
<>{children}</>
),
}));

beforeEach(() => jest.clearAllMocks());

function prompt(authorized = true) {
const onSubmit = jest.fn();
const onAuthRequired = jest.fn();
render(
<PromptForm
isAuthorized={authorized}
onSubmit={onSubmit}
onAuthRequired={onAuthRequired}
/>
);
const input = screen.getByRole('textbox', { name: 'Describe your project' });
return { input, onSubmit, onAuthRequired };
}

test('empty creation explains what is needed without opening sign-in', () => {
const { input, onSubmit, onAuthRequired } = prompt(false);
fireEvent.click(screen.getByRole('button', { name: 'Create project' }));
expect(screen.getByRole('alert')).toHaveTextContent(
'Describe your project first.'
);
expect(input).toHaveAttribute('aria-invalid', 'true');
expect(onSubmit).not.toHaveBeenCalled();
expect(onAuthRequired).not.toHaveBeenCalled();
fireEvent.change(input, { target: { value: 'A portfolio' } });
expect(screen.queryByRole('alert')).toBeNull();
});

test('empty improvement explains the prerequisite and makes no request', () => {
prompt();
fireEvent.click(screen.getByRole('button', { name: 'Improve prompt' }));
expect(screen.getByRole('alert')).toHaveTextContent(
'Describe your project first.'
);
expect(mockRegenerate).not.toHaveBeenCalled();
});

test('sign-in interruption keeps the entered prompt without starting generation', () => {
const { input, onAuthRequired, onSubmit } = prompt(false);
fireEvent.change(input, {
target: { value: 'A portfolio for an architect' },
});
fireEvent.click(screen.getByRole('button', { name: 'Create project' }));
expect(onAuthRequired).toHaveBeenCalledTimes(1);
expect(onSubmit).not.toHaveBeenCalled();
expect(input).toHaveValue('A portfolio for an architect');
});

test('improvement reports pending until the mutation succeeds and blocks repeated clicks', () => {
const { input } = prompt();
fireEvent.change(input, { target: { value: 'A portfolio' } });
fireEvent.click(screen.getByRole('button', { name: 'Improve prompt' }));
const pending = screen.getByRole('button', { name: 'Improving prompt…' });
expect(pending).toBeDisabled();
expect(input).toBeDisabled();
fireEvent.click(pending);
expect(mockRegenerate).toHaveBeenCalledTimes(1);
act(() =>
mockMutationOptions.onCompleted({
regenerateDescription: 'A portfolio with selected projects',
})
);
expect(input).toHaveValue('A portfolio with selected projects');
expect(screen.getByRole('button', { name: 'Prompt improved' })).toBeEnabled();
fireEvent.change(input, { target: { value: 'A changed brief' } });
expect(screen.getByRole('button', { name: 'Improve prompt' })).toBeEnabled();
});

test('failed improvement preserves text and exposes a retryable error', () => {
const { input } = prompt();
fireEvent.change(input, { target: { value: 'A portfolio' } });
fireEvent.click(screen.getByRole('button', { name: 'Improve prompt' }));
act(() => mockMutationOptions.onError(new Error('Network unavailable')));
expect(input).toHaveValue('A portfolio');
expect(input).toBeEnabled();
expect(screen.getByRole('alert')).toHaveTextContent(
"Couldn't improve your prompt. Your text is still here. Try again."
);
fireEvent.click(screen.getByRole('button', { name: 'Improve prompt' }));
expect(mockRegenerate).toHaveBeenCalledTimes(2);
expect(screen.queryByRole('alert')).toBeNull();
});

test('an empty mutation result never replaces the draft or reports success', () => {
const { input } = prompt();
fireEvent.change(input, { target: { value: 'A portfolio' } });
fireEvent.click(screen.getByRole('button', { name: 'Improve prompt' }));
act(() => mockMutationOptions.onCompleted({ regenerateDescription: '' }));
expect(input).toHaveValue('A portfolio');
expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Prompt improved' })).toBeNull();
});

function chat() {
const onQueue = jest.fn();
const setInput = jest.fn();
const submit = jest.fn();
render(
<ChatBottombar
messages={[]}
input="Make it green"
handleInputChange={jest.fn()}
handleSubmit={submit}
stop={jest.fn()}
formRef={createRef<HTMLFormElement>()}
setInput={setInput}
setMessages={jest.fn()}
isStreaming
onQueue={onQueue}
/>
);
return {
onQueue,
setInput,
submit,
input: screen.getByRole('textbox', { name: 'Message CodeFox' }),
};
}

test('writing alone does not queue; Enter queues and clears the input', () => {
const { onQueue, setInput, submit, input } = chat();
expect(input).toHaveAttribute(
'placeholder',
'Write your next message. Press Enter or select Send to queue it.'
);
expect(onQueue).not.toHaveBeenCalled();
fireEvent.keyDown(input, { key: 'Enter', shiftKey: true });
expect(onQueue).not.toHaveBeenCalled();
fireEvent.keyDown(input, { key: 'Enter' });
expect(onQueue).toHaveBeenCalledWith('Make it green');
expect(setInput).toHaveBeenCalledWith('');
expect(submit).not.toHaveBeenCalled();
});

test('the Send control explicitly queues the next message', () => {
const { onQueue } = chat();
fireEvent.click(
screen.getByRole('button', {
name: 'Send: queue message for the next turn',
})
);
expect(onQueue).toHaveBeenCalledTimes(1);
});
49 changes: 24 additions & 25 deletions frontend/src/components/root/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ const TOOL_CALLS = [

const FACTS = [
{
n: '365',
title: 'files in the app starter',
hint: 'Next.js 15 + shadcn — or a one-file HTML page, your pick',
n: '2',
title: 'starter types',
hint: 'A self-contained HTML page or a Next.js app',
accent: true,
},
{
n: '1',
title: 'dependency install, ever',
hint: '629 packages cached once, shared by every project',
n: 'Live',
title: 'preview beside the chat',
hint: 'Review the page as you build and refine it',
},
{
n: '0',
title: 'cloud keys required',
hint: 'Any OpenAI- or Anthropic-compatible endpoint works',
n: 'Your choice',
title: 'model provider',
hint: 'Self-hosting requires a configured model provider',
},
];

const LIMITS = [
{
title: 'The sandbox is not isolation',
tag: 'by design',
body: 'The agent runs with the backend process privileges inside a scoped directory. That is the trade for using the CLI you are already signed into. Swap in a network sandbox provider for anything untrusted — same interface.',
body: 'The agent runs with the backend process privileges inside a scoped directory. Swap in a network sandbox provider for anything untrusted — same interface.',
},
{
title: 'Projects share one node_modules',
tag: 'known',
body: 'Every project comes from the same template, so they symlink a single install. That stops being true the moment the agent is allowed to add a dependency.',
body: 'Next.js projects share the starter dependency install. That stops being true the moment the agent is allowed to add a dependency.',
},
{
title: 'Two starters, not a marketplace',
Expand Down Expand Up @@ -153,21 +153,20 @@ export function Landing() {
transition={{ duration: 0.5, ease: [0.16, 1, 0.3, 1] }}
>
<div className="mb-7 flex flex-wrap gap-2">
<Chip>Local-first</Chip>
<Chip>Claude Code inside</Chip>
<Chip>Self-hostable</Chip>
<Chip>AI-assisted</Chip>
<Chip>MIT</Chip>
</div>

<h1 className="font-display text-[clamp(2.5rem,5vw,4rem)] font-bold leading-[1.02] tracking-[-0.035em] text-foreground">
One prompt.
<br />A repo that{' '}
<span className="text-primary">already runs</span>.
Describe a page.
<br />
<span className="text-primary">Build it.</span>
</h1>

<p className="mt-6 max-w-[54ch] text-[1.0625rem] leading-relaxed text-muted-foreground">
CodeFox scaffolds a real Next.js project on your disk, points
Claude Code at it, and boots a dev server beside the chat. Not a
preview of code — the code, on a port, in your browser.
CodeFox creates a webpage or Next.js app from your prompt. Preview
the result beside the chat, then describe what to change.
</p>
</motion.div>

Expand Down Expand Up @@ -216,7 +215,7 @@ export function Landing() {
</div>

<p className="mt-4 font-mono text-xs text-muted-foreground">
Node 18+ · no database to install · no cloud API key
Self-host with Node 22+ and a configured model provider
</p>
</motion.div>
</section>
Expand Down Expand Up @@ -393,11 +392,11 @@ export function Landing() {
<div className="grid gap-x-14 gap-y-9 border-t-[3px] border-border pt-12 lg:grid-cols-[1fr_auto] lg:items-end">
<div>
<h2 className="max-w-[20ch] text-balance font-display text-[clamp(1.75rem,3.4vw,2.5rem)] font-bold leading-[1.08] tracking-[-0.025em] text-foreground">
Clone it, run one command, type one sentence.
Run CodeFox on your own machine.
</h2>
<p className="mt-5 max-w-[52ch] text-pretty text-[1.0625rem] leading-relaxed text-muted-foreground">
All of it happens on your machine. If it does not work in the
first minute, that is a bug worth filing.
Clone the repository, install the dependencies, and configure a
model provider. The setup guide walks you through each step.
</p>
</div>

Expand All @@ -419,7 +418,7 @@ export function Landing() {
</button>
)}
<a
href="https://github.com/Sma1lboy/codefox"
href="https://github.com/CodeFox-Repo/codefox"
target="_blank"
rel="noopener noreferrer"
className="rounded-lg border border-border px-6 py-3 text-sm font-medium text-foreground transition-colors hover:border-primary"
Expand All @@ -428,7 +427,7 @@ export function Landing() {
</a>
</div>
<p className="mt-6 font-mono text-xs text-muted-foreground">
MIT · Node 18+ · macOS, Linux, WSL
MIT · Node 22+ · macOS, Linux, WSL
</p>
</div>
</div>
Expand Down
Loading
Loading