use them
This commit is contained in:
1 parent
f7f5408814
commit
1377b3760f
24 files changed
+520
-953
No files matched your search
@@ -13,7 +13,7 @@
|
||||
* the first render). For production mode (no React DevTools message), we
|
||||
* instead check that no fatal errors appeared.
|
||||
*/
|
||||
import { spawn, execSync } from "node:child_process";
|
||||
import { execSync, spawn } from "node:child_process";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -75,7 +75,7 @@ child.on("exit", () => {
|
||||
for (const f of failures) {
|
||||
console.error(` • ${f}`);
|
||||
}
|
||||
console.error("\nFull output:\n" + output);
|
||||
console.error(`\nFull output:\n${output}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Electron Todo</title>
|
||||
</head>
|
||||
<body class="bg-slate-100">
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
|
||||
@@ -31,10 +31,10 @@ function Layout() {
|
||||
|
||||
if (!api) {
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-[#0c0c0c] text-[#e0e0e0]">
|
||||
<div className="flex h-screen flex-col bg-background text-foreground">
|
||||
<div className="drag-region h-[52px] shrink-0" />
|
||||
<div className="flex flex-1 items-center justify-center">
|
||||
<p className="text-sm text-[#a0a0a0]/60">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Native bridge unavailable. Launch through Electron.
|
||||
</p>
|
||||
</div>
|
||||
@@ -43,7 +43,7 @@ function Layout() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen overflow-hidden bg-[#0c0c0c] text-[#e0e0e0]">
|
||||
<div className="flex h-screen overflow-hidden bg-background text-foreground">
|
||||
<EventRouter />
|
||||
<Sidebar />
|
||||
<ChatView />
|
||||
|
||||
@@ -15,7 +15,7 @@ const markdownComponents: Components = {
|
||||
|
||||
export default function ChatMarkdown({ text }: ChatMarkdownProps) {
|
||||
return (
|
||||
<div className="chat-markdown text-sm leading-relaxed text-[#d0d0d0]">
|
||||
<div className="chat-markdown text-sm leading-relaxed text-foreground/80">
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
rehypePlugins={[[rehypeHighlight, { detect: true, ignoreMissing: true }]]}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4,13 +4,15 @@ export default function DiffPanel() {
|
||||
const { dispatch } = useStore();
|
||||
|
||||
return (
|
||||
<aside className="flex h-full w-[400px] shrink-0 flex-col border-l border-white/[0.08] bg-[#141414]">
|
||||
<aside className="flex h-full w-[400px] shrink-0 flex-col border-l border-border bg-card">
|
||||
{/* Header */}
|
||||
<div className="drag-region flex items-center justify-between border-b border-white/[0.08] px-4 pt-[28px] pb-3">
|
||||
<h3 className="text-xs font-medium text-[#e0e0e0]">Uncommitted changes</h3>
|
||||
<div className="drag-region flex items-center justify-between border-b border-border px-4 pt-[28px] pb-3">
|
||||
<h3 className="text-xs font-medium text-foreground">
|
||||
Uncommitted changes
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
className="text-[#a0a0a0]/40 transition-colors duration-150 hover:text-[#a0a0a0]/70"
|
||||
className="text-muted-foreground/60 transition-colors duration-150 hover:text-muted-foreground"
|
||||
onClick={() => dispatch({ type: "TOGGLE_DIFF" })}
|
||||
>
|
||||
<span className="text-sm">×</span>
|
||||
@@ -20,30 +22,36 @@ export default function DiffPanel() {
|
||||
{/* Placeholder content */}
|
||||
<div className="flex-1 overflow-y-auto p-4">
|
||||
<div className="space-y-3">
|
||||
<div className="rounded-lg border border-white/[0.06] bg-white/[0.02] p-3">
|
||||
<div className="rounded-lg border border-border/80 bg-muted p-3">
|
||||
<div className="mb-2 flex items-center gap-2">
|
||||
<span className="rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400">
|
||||
M
|
||||
</span>
|
||||
<span className="font-mono text-xs text-[#a0a0a0]/60">src/App.tsx</span>
|
||||
<span className="font-mono text-xs text-muted-foreground/80">
|
||||
src/App.tsx
|
||||
</span>
|
||||
</div>
|
||||
<div className="space-y-0.5 font-mono text-[11px]">
|
||||
<div className="text-red-400/60">- const oldValue = "hello";</div>
|
||||
<div className="text-emerald-400/60">+ const newValue = "world";</div>
|
||||
<div className="text-emerald-400/60">
|
||||
+ const newValue = "world";
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-lg border border-white/[0.06] bg-white/[0.02] p-3">
|
||||
<div className="rounded-lg border border-border/80 bg-muted p-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="rounded bg-blue-500/20 px-1.5 py-0.5 text-[9px] font-medium text-blue-400">
|
||||
A
|
||||
</span>
|
||||
<span className="font-mono text-xs text-[#a0a0a0]/60">src/utils.ts</span>
|
||||
<span className="font-mono text-xs text-muted-foreground/80">
|
||||
src/utils.ts
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="mt-6 text-center text-[10px] text-[#a0a0a0]/25">
|
||||
<p className="mt-6 text-center text-[10px] text-muted-foreground/30">
|
||||
Diff integration coming soon
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { DEFAULT_MODEL } from "../model-logic";
|
||||
import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTheme } from "../hooks/useTheme";
|
||||
import { DEFAULT_MODEL, MODEL_OPTIONS, resolveModelSlug } from "../model-logic";
|
||||
import { readNativeApi } from "../session-logic";
|
||||
import { useStore } from "../store";
|
||||
import type { Project } from "../types";
|
||||
|
||||
|
||||
function formatRelativeTime(iso: string): string {
|
||||
const diff = Date.now() - new Date(iso).getTime();
|
||||
const minutes = Math.floor(diff / 60_000);
|
||||
@@ -15,58 +16,53 @@ function formatRelativeTime(iso: string): string {
|
||||
return `${Math.floor(hours / 24)}d ago`;
|
||||
}
|
||||
|
||||
function threadStatusLabel(
|
||||
status: "connecting" | "ready" | "running" | "error" | "closed" | undefined,
|
||||
): "Working" | "Connecting" | null {
|
||||
if (status === "running") return "Working";
|
||||
if (status === "connecting") return "Connecting";
|
||||
return null;
|
||||
}
|
||||
const THEME_CYCLE = { system: "light", light: "dark", dark: "system" } as const;
|
||||
|
||||
export default function Sidebar() {
|
||||
const { state, dispatch } = useStore();
|
||||
const api = useMemo(() => readNativeApi(), []);
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [addingProject, setAddingProject] = useState(false);
|
||||
const [newCwd, setNewCwd] = useState("");
|
||||
const [newModel, setNewModel] = useState(DEFAULT_MODEL);
|
||||
const [isPickingFolder, setIsPickingFolder] = useState(false);
|
||||
|
||||
const handleAddProject = () => {
|
||||
const cwd = newCwd.trim();
|
||||
if (!cwd) return;
|
||||
const name = cwd.split("/").filter(Boolean).pop() ?? "project";
|
||||
const normalizedModel = resolveModelSlug(newModel);
|
||||
const project: Project = {
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
cwd,
|
||||
model: DEFAULT_MODEL,
|
||||
model: normalizedModel,
|
||||
expanded: true,
|
||||
};
|
||||
dispatch({ type: "ADD_PROJECT", project });
|
||||
setNewCwd("");
|
||||
setNewModel(DEFAULT_MODEL);
|
||||
setAddingProject(false);
|
||||
};
|
||||
|
||||
const handleNewThread = useCallback(
|
||||
(projectId: string) => {
|
||||
dispatch({
|
||||
type: "ADD_THREAD",
|
||||
thread: {
|
||||
id: crypto.randomUUID(),
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model:
|
||||
state.projects.find((p) => p.id === projectId)?.model ??
|
||||
DEFAULT_MODEL,
|
||||
session: null,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
},
|
||||
[dispatch, state.projects],
|
||||
);
|
||||
const handleNewThread = (projectId: string) => {
|
||||
dispatch({
|
||||
type: "ADD_THREAD",
|
||||
thread: {
|
||||
id: crypto.randomUUID(),
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model:
|
||||
state.projects.find((p) => p.id === projectId)?.model ??
|
||||
DEFAULT_MODEL,
|
||||
session: null,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handlePickFolder = async () => {
|
||||
if (!api || isPickingFolder) return;
|
||||
@@ -80,62 +76,40 @@ export default function Sidebar() {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const onWindowKeyDown = (event: KeyboardEvent) => {
|
||||
const isNewThreadShortcut =
|
||||
event.metaKey &&
|
||||
event.shiftKey &&
|
||||
!event.ctrlKey &&
|
||||
!event.altKey &&
|
||||
event.key.toLowerCase() === "o";
|
||||
if (!isNewThreadShortcut) return;
|
||||
|
||||
const target = event.target;
|
||||
if (target instanceof HTMLElement) {
|
||||
const tagName = target.tagName;
|
||||
if (
|
||||
target.isContentEditable ||
|
||||
tagName === "INPUT" ||
|
||||
tagName === "TEXTAREA" ||
|
||||
tagName === "SELECT"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const activeThread = state.threads.find(
|
||||
(t) => t.id === state.activeThreadId,
|
||||
);
|
||||
const projectId = activeThread?.projectId ?? state.projects[0]?.id;
|
||||
if (!projectId) return;
|
||||
|
||||
event.preventDefault();
|
||||
handleNewThread(projectId);
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", onWindowKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onWindowKeyDown);
|
||||
};
|
||||
}, [handleNewThread, state.activeThreadId, state.projects, state.threads]);
|
||||
|
||||
return (
|
||||
<aside className="sidebar flex h-full w-[260px] shrink-0 flex-col border-r border-white/8 bg-[#141414]">
|
||||
<aside className="sidebar flex h-full w-[260px] shrink-0 flex-col border-r border-border bg-card">
|
||||
{/* Drag region / traffic light space */}
|
||||
<div className="drag-region h-[52px] shrink-0" />
|
||||
{/* Branding */}
|
||||
<div className="flex items-center gap-2 px-4 pb-4">
|
||||
<div className="flex h-7 w-7 items-center justify-center rounded-lg bg-white text-xs font-bold text-[#0c0c0c]">
|
||||
<div className="flex h-7 w-7 items-center justify-center rounded-lg bg-primary text-xs font-bold text-primary-foreground">
|
||||
CT
|
||||
</div>
|
||||
<span className="text-sm font-semibold tracking-tight text-[#e0e0e0]">CodeThing</span>
|
||||
<span className="flex-1 text-sm font-semibold tracking-tight text-foreground">
|
||||
CodeThing
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="rounded-md p-1.5 text-muted-foreground/80 transition-colors duration-150 hover:bg-accent hover:text-muted-foreground"
|
||||
onClick={() => setTheme(THEME_CYCLE[theme])}
|
||||
aria-label={`Theme: ${theme}`}
|
||||
title={`Theme: ${theme}`}
|
||||
>
|
||||
{theme === "system" ? (
|
||||
<MonitorIcon className="size-3.5" />
|
||||
) : theme === "light" ? (
|
||||
<SunIcon className="size-3.5" />
|
||||
) : (
|
||||
<MoonIcon className="size-3.5" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* New thread (global) */}
|
||||
<div className="px-3 pb-3">
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center gap-2 rounded-lg border border-white/8 bg-white/4 px-3 py-2 text-xs text-[#a0a0a0]/80 transition-colors duration-150 hover:bg-white/[0.07]"
|
||||
className="flex w-full items-center gap-2 rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground transition-colors duration-150 hover:bg-accent"
|
||||
onClick={() => {
|
||||
if (state.projects.length === 0) {
|
||||
setAddingProject(true);
|
||||
@@ -145,7 +119,7 @@ export default function Sidebar() {
|
||||
if (firstProject) handleNewThread(firstProject.id);
|
||||
}}
|
||||
>
|
||||
<span className="text-white">+</span>
|
||||
<span className="text-foreground">+</span>
|
||||
New thread
|
||||
</button>
|
||||
</div>
|
||||
@@ -153,46 +127,43 @@ export default function Sidebar() {
|
||||
{/* Project list */}
|
||||
<nav className="flex-1 overflow-y-auto px-2">
|
||||
{state.projects.map((project) => {
|
||||
const threads = state.threads
|
||||
.filter((t) => t.projectId === project.id)
|
||||
.sort((a, b) => {
|
||||
const byDate =
|
||||
new Date(b.createdAt).getTime() -
|
||||
new Date(a.createdAt).getTime();
|
||||
if (byDate !== 0) return byDate;
|
||||
return b.id.localeCompare(a.id);
|
||||
});
|
||||
const threads = state.threads.filter(
|
||||
(t) => t.projectId === project.id,
|
||||
);
|
||||
return (
|
||||
<div key={project.id} className="mb-1">
|
||||
{/* Project header */}
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150 hover:bg-white/5"
|
||||
onClick={() => dispatch({ type: "TOGGLE_PROJECT", projectId: project.id })}
|
||||
className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150 hover:bg-accent"
|
||||
onClick={() =>
|
||||
dispatch({ type: "TOGGLE_PROJECT", projectId: project.id })
|
||||
}
|
||||
>
|
||||
<span className="text-[10px] text-[#a0a0a0]/50">
|
||||
<span className="text-[10px] text-muted-foreground/70">
|
||||
{project.expanded ? "▼" : "▶"}
|
||||
</span>
|
||||
<span className="flex-1 truncate text-xs font-medium text-[#e0e0e0]/90">
|
||||
<span className="flex-1 truncate text-xs font-medium text-foreground/90">
|
||||
{project.name}
|
||||
</span>
|
||||
<span className="text-[10px] text-[#a0a0a0]/40">{threads.length}</span>
|
||||
<span className="text-[10px] text-muted-foreground/60">
|
||||
{threads.length}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{/* Threads */}
|
||||
{project.expanded && (
|
||||
<div className="ml-2 border-l border-white/6 pl-2">
|
||||
<div className="ml-2 border-l border-border/80 pl-2">
|
||||
{threads.map((thread) => {
|
||||
const isActive = state.activeThreadId === thread.id;
|
||||
const threadStatus = threadStatusLabel(
|
||||
thread.session?.status,
|
||||
);
|
||||
return (
|
||||
<button
|
||||
key={thread.id}
|
||||
type="button"
|
||||
className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150 ${
|
||||
isActive ? "bg-white/10 text-white" : "text-[#a0a0a0]/70 hover:bg-white/4"
|
||||
isActive
|
||||
? "bg-accent text-foreground"
|
||||
: "text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
onClick={() =>
|
||||
dispatch({
|
||||
@@ -201,20 +172,10 @@ export default function Sidebar() {
|
||||
})
|
||||
}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5">
|
||||
{threadStatus && (
|
||||
<span className="inline-flex items-center gap-1 text-[10px] text-[#7ed8ff]/80">
|
||||
<span className="h-1.5 w-1.5 animate-pulse rounded-full bg-sky-300/80" />
|
||||
<span className="hidden xl:inline">
|
||||
{threadStatus}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1 truncate text-xs">
|
||||
{thread.title}
|
||||
</span>
|
||||
</div>
|
||||
<span className="shrink-0 text-[10px] text-[#a0a0a0]/30">
|
||||
<span className="flex-1 truncate text-xs">
|
||||
{thread.title}
|
||||
</span>
|
||||
<span className="shrink-0 text-[10px] text-muted-foreground/40">
|
||||
{formatRelativeTime(thread.createdAt)}
|
||||
</span>
|
||||
</button>
|
||||
@@ -224,7 +185,7 @@ export default function Sidebar() {
|
||||
{/* New thread within project */}
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center gap-1 px-2 py-1 text-[10px] text-[#a0a0a0]/40 transition-colors duration-150 hover:text-[#a0a0a0]/60"
|
||||
className="flex w-full items-center gap-1 px-2 py-1 text-[10px] text-muted-foreground/60 transition-colors duration-150 hover:text-muted-foreground/80"
|
||||
onClick={() => handleNewThread(project.id)}
|
||||
>
|
||||
<span>+</span> New thread
|
||||
@@ -236,7 +197,7 @@ export default function Sidebar() {
|
||||
})}
|
||||
|
||||
{state.projects.length === 0 && !addingProject && (
|
||||
<div className="px-2 pt-4 text-center text-xs text-[#a0a0a0]/40">
|
||||
<div className="px-2 pt-4 text-center text-xs text-muted-foreground/60">
|
||||
No projects yet.
|
||||
<br />
|
||||
Add one to get started.
|
||||
@@ -246,12 +207,12 @@ export default function Sidebar() {
|
||||
|
||||
{/* Add project form */}
|
||||
{addingProject ? (
|
||||
<div className="border-t border-white/8 p-3">
|
||||
<p className="mb-2 text-[10px] font-medium uppercase tracking-wider text-[#a0a0a0]/50">
|
||||
<div className="border-t border-border p-3">
|
||||
<p className="mb-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70">
|
||||
Add project
|
||||
</p>
|
||||
<input
|
||||
className="mb-2 w-full rounded-md border border-white/10 bg-white/4 px-2 py-1.5 font-mono text-xs text-[#e0e0e0] placeholder:text-[#a0a0a0]/30 focus:border-white/30 focus:outline-none"
|
||||
className="mb-2 w-full rounded-md border border-border bg-secondary px-2 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground/40 focus:border-ring focus:outline-none"
|
||||
placeholder="/path/to/project"
|
||||
value={newCwd}
|
||||
onChange={(e) => setNewCwd(e.target.value)}
|
||||
@@ -263,24 +224,39 @@ export default function Sidebar() {
|
||||
{api && (
|
||||
<button
|
||||
type="button"
|
||||
className="mb-2 flex w-full items-center justify-center rounded-md border border-white/10 px-2 py-1.5 text-xs text-[#a0a0a0]/70 transition-colors duration-150 hover:bg-white/4 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
className="mb-2 flex w-full items-center justify-center rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground transition-colors duration-150 hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-60"
|
||||
onClick={() => void handlePickFolder()}
|
||||
disabled={isPickingFolder}
|
||||
>
|
||||
{isPickingFolder ? "Picking folder..." : "Browse for folder"}
|
||||
</button>
|
||||
)}
|
||||
<select
|
||||
className="mb-2 w-full rounded-md border border-border bg-secondary px-2 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground/40 focus:border-ring focus:outline-none"
|
||||
value={newModel}
|
||||
onChange={(e) => setNewModel(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") handleAddProject();
|
||||
if (e.key === "Escape") setAddingProject(false);
|
||||
}}
|
||||
>
|
||||
{MODEL_OPTIONS.map((model) => (
|
||||
<option key={model} value={model} className="bg-card">
|
||||
{model}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="flex-1 rounded-md bg-white px-2 py-1 text-xs font-medium text-[#0c0c0c] transition-colors duration-150 hover:bg-white/90"
|
||||
className="flex-1 rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition-colors duration-150 hover:bg-primary/90"
|
||||
onClick={handleAddProject}
|
||||
>
|
||||
Add
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="flex-1 rounded-md border border-white/10 px-2 py-1 text-xs text-[#a0a0a0]/60 transition-colors duration-150 hover:bg-white/4"
|
||||
className="flex-1 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground/80 transition-colors duration-150 hover:bg-secondary"
|
||||
onClick={() => setAddingProject(false)}
|
||||
>
|
||||
Cancel
|
||||
@@ -288,10 +264,10 @@ export default function Sidebar() {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="border-t border-white/8 p-3">
|
||||
<div className="border-t border-border p-3">
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center justify-center gap-1 rounded-md border border-dashed border-white/12 py-2 text-xs text-[#a0a0a0]/50 transition-colors duration-150 hover:border-white/20 hover:text-[#a0a0a0]/70"
|
||||
className="flex w-full items-center justify-center gap-1 rounded-md border border-dashed border-border py-2 text-xs text-muted-foreground/70 transition-colors duration-150 hover:border-ring hover:text-muted-foreground"
|
||||
onClick={() => setAddingProject(true)}
|
||||
>
|
||||
+ Add project
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
import type * as React from "react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Autocomplete as AutocompletePrimitive } from "@base-ui/react/autocomplete";
|
||||
import { ChevronsUpDownIcon, XIcon } from "lucide-react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
import { Input } from "#/components/ui/input";
|
||||
import { ScrollArea } from "#/components/ui/scroll-area";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
const Autocomplete = AutocompletePrimitive.Root;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { mergeProps } from "@base-ui/react/merge-props";
|
||||
import { useRender } from "@base-ui/react/use-render";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { mergeProps } from "@base-ui/react/merge-props";
|
||||
import { useRender } from "@base-ui/react/use-render";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
import type * as React from "react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
@@ -2,9 +2,9 @@ import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox";
|
||||
import { ChevronsUpDownIcon, XIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
import { Input } from "#/components/ui/input";
|
||||
import { ScrollArea } from "#/components/ui/scroll-area";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
const ComboboxContext = React.createContext<{
|
||||
chipsRef: React.RefObject<Element | null> | null;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Dialog as CommandDialogPrimitive } from "@base-ui/react/dialog";
|
||||
import { SearchIcon } from "lucide-react";
|
||||
import type * as React from "react";
|
||||
import { cn } from "#/lib/utils";
|
||||
import {
|
||||
Autocomplete,
|
||||
AutocompleteCollection,
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
AutocompleteList,
|
||||
AutocompleteSeparator,
|
||||
} from "#/components/ui/autocomplete";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
const CommandDialog = CommandDialogPrimitive.Root;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
||||
import { XIcon } from "lucide-react";
|
||||
import { cn } from "#/lib/utils";
|
||||
import { Button } from "#/components/ui/button";
|
||||
import { ScrollArea } from "#/components/ui/scroll-area";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
const DialogCreateHandle = DialogPrimitive.createHandle;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
import type * as React from "react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
import { Input, type InputProps } from "#/components/ui/input";
|
||||
import { Textarea, type TextareaProps } from "#/components/ui/textarea";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronsUpDownIcon,
|
||||
ChevronUpIcon,
|
||||
ChevronsUpDownIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
|
||||
import { XIcon } from "lucide-react";
|
||||
import { cn } from "#/lib/utils";
|
||||
import { Button } from "#/components/ui/button";
|
||||
import { ScrollArea } from "#/components/ui/scroll-area";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
const Sheet = SheetPrimitive.Root;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
TriangleAlertIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
import { cn } from "#/lib/utils";
|
||||
import { buttonVariants } from "#/components/ui/button";
|
||||
import { cn } from "#/lib/utils";
|
||||
|
||||
const toastManager = Toast.createToastManager();
|
||||
const anchoredToastManager = Toast.createToastManager();
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import * as React from "react";
|
||||
|
||||
const MOBILE_BREAKPOINT = 768;
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
|
||||
undefined,
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
};
|
||||
mql.addEventListener("change", onChange);
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
return () => mql.removeEventListener("change", onChange);
|
||||
}, []);
|
||||
|
||||
return !!isMobile;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { useCallback, useEffect, useSyncExternalStore } from "react";
|
||||
|
||||
type Theme = "light" | "dark" | "system";
|
||||
|
||||
const STORAGE_KEY = "codething:theme";
|
||||
const MEDIA_QUERY = "(prefers-color-scheme: dark)";
|
||||
|
||||
let listeners: Array<() => void> = [];
|
||||
function emitChange() {
|
||||
for (const listener of listeners) listener();
|
||||
}
|
||||
|
||||
function getSystemDark(): boolean {
|
||||
return window.matchMedia(MEDIA_QUERY).matches;
|
||||
}
|
||||
|
||||
function getStored(): Theme {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
if (raw === "light" || raw === "dark" || raw === "system") return raw;
|
||||
return "system";
|
||||
}
|
||||
|
||||
function applyTheme(theme: Theme, suppressTransitions = false) {
|
||||
if (suppressTransitions) {
|
||||
document.documentElement.classList.add("no-transitions");
|
||||
}
|
||||
const isDark = theme === "dark" || (theme === "system" && getSystemDark());
|
||||
document.documentElement.classList.toggle("dark", isDark);
|
||||
if (suppressTransitions) {
|
||||
// Force a reflow so the no-transitions class takes effect before removal
|
||||
document.documentElement.offsetHeight;
|
||||
requestAnimationFrame(() => {
|
||||
document.documentElement.classList.remove("no-transitions");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply immediately on module load to prevent flash
|
||||
applyTheme(getStored());
|
||||
|
||||
function getSnapshot(): Theme {
|
||||
return getStored();
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.push(listener);
|
||||
|
||||
// Listen for system preference changes
|
||||
const mq = window.matchMedia(MEDIA_QUERY);
|
||||
const handleChange = () => {
|
||||
if (getStored() === "system") applyTheme("system", true);
|
||||
emitChange();
|
||||
};
|
||||
mq.addEventListener("change", handleChange);
|
||||
|
||||
// Listen for storage changes from other tabs
|
||||
const handleStorage = (e: StorageEvent) => {
|
||||
if (e.key === STORAGE_KEY) {
|
||||
applyTheme(getStored(), true);
|
||||
emitChange();
|
||||
}
|
||||
};
|
||||
window.addEventListener("storage", handleStorage);
|
||||
|
||||
return () => {
|
||||
listeners = listeners.filter((l) => l !== listener);
|
||||
mq.removeEventListener("change", handleChange);
|
||||
window.removeEventListener("storage", handleStorage);
|
||||
};
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
const theme = useSyncExternalStore(subscribe, getSnapshot);
|
||||
|
||||
const resolvedTheme: "light" | "dark" =
|
||||
theme === "system" ? (getSystemDark() ? "dark" : "light") : theme;
|
||||
|
||||
const setTheme = useCallback((next: Theme) => {
|
||||
localStorage.setItem(STORAGE_KEY, next);
|
||||
applyTheme(next, true);
|
||||
emitChange();
|
||||
}, []);
|
||||
|
||||
// Keep DOM in sync on mount/change
|
||||
useEffect(() => {
|
||||
applyTheme(theme);
|
||||
}, [theme]);
|
||||
|
||||
return { theme, setTheme, resolvedTheme } as const;
|
||||
}
|
||||
+34
-27
@@ -1,6 +1,6 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
@custom-variant dark (&:is(.dark, .dark *));
|
||||
|
||||
@theme inline {
|
||||
--animate-skeleton: skeleton 2s -1s infinite linear;
|
||||
@@ -65,8 +65,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Suppress all transitions during theme changes */
|
||||
.no-transitions,
|
||||
.no-transitions *,
|
||||
.no-transitions *::before,
|
||||
.no-transitions *::after {
|
||||
transition-duration: 0s !important;
|
||||
animation-duration: 0s !important;
|
||||
}
|
||||
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
color-scheme: light;
|
||||
--radius: 0.625rem;
|
||||
--background: var(--color-white);
|
||||
--foreground: var(--color-neutral-800);
|
||||
@@ -112,6 +121,7 @@
|
||||
--warning-foreground: var(--color-amber-700);
|
||||
|
||||
@variant dark {
|
||||
color-scheme: dark;
|
||||
--background: color-mix(
|
||||
in srgb,
|
||||
var(--color-neutral-950) 95%,
|
||||
@@ -171,8 +181,6 @@ body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
min-height: 100vh;
|
||||
color: #e0e0e0;
|
||||
background: #0c0c0c;
|
||||
}
|
||||
|
||||
body::after {
|
||||
@@ -216,25 +224,20 @@ input {
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
/* Reasoning select — clickable label surface */
|
||||
label:has(> select#reasoning-effort) {
|
||||
position: relative;
|
||||
.dark ::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
label:has(> select#reasoning-effort) select {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.dark ::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
|
||||
/* Chat markdown rendering */
|
||||
@@ -269,34 +272,38 @@ label:has(> select#reasoning-effort) select {
|
||||
}
|
||||
|
||||
.chat-markdown a {
|
||||
color: #93c5fd;
|
||||
color: var(--info-foreground);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: rgba(147, 197, 253, 0.4);
|
||||
text-decoration-color: color-mix(
|
||||
in srgb,
|
||||
var(--info-foreground) 40%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.chat-markdown a:hover {
|
||||
color: #bfdbfe;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.chat-markdown blockquote {
|
||||
border-left: 2px solid rgba(255, 255, 255, 0.2);
|
||||
border-left: 2px solid var(--border);
|
||||
padding-left: 0.8rem;
|
||||
color: rgba(224, 224, 224, 0.75);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.chat-markdown :not(pre) > code {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.375rem;
|
||||
background: rgba(255, 255, 255, 0.07);
|
||||
background: var(--muted);
|
||||
padding: 0.1rem 0.35rem;
|
||||
color: #f4f4f5;
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.chat-markdown pre {
|
||||
overflow-x: auto;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.75rem;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
background: var(--muted);
|
||||
padding: 0.8rem 0.9rem;
|
||||
}
|
||||
|
||||
@@ -314,7 +321,7 @@ label:has(> select#reasoning-effort) select {
|
||||
|
||||
.chat-markdown th,
|
||||
.chat-markdown td {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid var(--border);
|
||||
padding: 0.35rem 0.45rem;
|
||||
text-align: left;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import path from "node:path";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
@@ -11,6 +12,11 @@ export default defineConfig({
|
||||
}),
|
||||
tailwindcss(),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"#": path.resolve(__dirname, "src"),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: Number(process.env.ELECTRON_RENDERER_PORT ?? 5173),
|
||||
strictPort: true,
|
||||
|
||||
Reference in new issue
Block a user