Probably fine

This commit is contained in:
Theo Browne committed 2026-02-08 14:21:55 -08:00
1 parent 2f4051ed30
commit 54bc785f36
11 files changed
+485 -40

No files matched your search

+16 -1
View File
@@ -3,7 +3,7 @@ fixPath();
import { spawn } from "node:child_process";
import path from "node:path";
import { BrowserWindow, app, ipcMain, session } from "electron";
import { BrowserWindow, app, dialog, ipcMain, session } from "electron";
import {
IPC_CHANNELS,
@@ -78,6 +78,21 @@ function registerIpcHandlers(): void {
return todoStore.remove(todoIdSchema.parse(id));
});
ipcMain.handle(IPC_CHANNELS.dialogPickFolder, async () => {
const owner =
BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0];
const result = owner
? await dialog.showOpenDialog(owner, {
properties: ["openDirectory", "createDirectory"],
})
: await dialog.showOpenDialog({
properties: ["openDirectory", "createDirectory"],
});
if (result.canceled) return null;
return result.filePaths[0] ?? null;
});
// Terminal handlers
ipcMain.handle(IPC_CHANNELS.terminalRun, async (_event, payload: unknown) => {
return runTerminalCommand(terminalCommandInputSchema.parse(payload));
+3
View File
@@ -9,6 +9,9 @@ const nativeApi: NativeApi = {
toggle: (id) => ipcRenderer.invoke(IPC_CHANNELS.todosToggle, id),
remove: (id) => ipcRenderer.invoke(IPC_CHANNELS.todosRemove, id),
},
dialogs: {
pickFolder: () => ipcRenderer.invoke(IPC_CHANNELS.dialogPickFolder),
},
terminal: {
run: (input) => ipcRenderer.invoke(IPC_CHANNELS.terminalRun, input),
},
+5 -1
View File
@@ -13,8 +13,12 @@
},
"dependencies": {
"@acme/contracts": "workspace:*",
"highlight.js": "^11.11.1",
"react-markdown": "^10.1.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"react-dom": "^19.0.0",
"rehype-highlight": "^7.0.2",
"remark-gfm": "^4.0.1"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
@@ -0,0 +1,30 @@
import type { Components } from "react-markdown";
import ReactMarkdown from "react-markdown";
import rehypeHighlight from "rehype-highlight";
import remarkGfm from "remark-gfm";
interface ChatMarkdownProps {
text: string;
}
const markdownComponents: Components = {
a({ node: _node, ...props }) {
return <a {...props} target="_blank" rel="noreferrer" />;
},
};
export default function ChatMarkdown({ text }: ChatMarkdownProps) {
return (
<div className="chat-markdown text-sm leading-relaxed text-[#d0d0d0]">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[
[rehypeHighlight, { detect: true, ignoreMissing: true }],
]}
components={markdownComponents}
>
{text}
</ReactMarkdown>
</div>
);
}
+100 -29
View File
@@ -7,13 +7,6 @@ import {
useState,
} from "react";
import {
derivePhase,
deriveWorkLogEntries,
formatElapsed,
formatTimestamp,
readNativeApi,
} from "../session-logic";
import {
DEFAULT_MODEL,
DEFAULT_REASONING,
@@ -21,7 +14,15 @@ import {
REASONING_OPTIONS,
resolveModelSlug,
} from "../model-logic";
import {
derivePhase,
deriveWorkLogEntries,
formatElapsed,
formatTimestamp,
readNativeApi,
} from "../session-logic";
import { useStore } from "../store";
import ChatMarkdown from "./ChatMarkdown";
function formatMessageMeta(createdAt: string, duration: string | null): string {
if (!duration) return formatTimestamp(createdAt);
@@ -49,9 +50,8 @@ export default function ChatView() {
const [isSending, setIsSending] = useState(false);
const [isConnecting, setIsConnecting] = useState(false);
const [isModelMenuOpen, setIsModelMenuOpen] = useState(false);
const [selectedEffort, setSelectedEffort] = useState<string>(
DEFAULT_REASONING,
);
const [selectedEffort, setSelectedEffort] =
useState<string>(DEFAULT_REASONING);
const [nowTick, setNowTick] = useState(() => Date.now());
const messagesEndRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
@@ -356,9 +356,11 @@ export default function ChatView() {
</div>
) : (
<div className="border-l-2 border-white/[0.15] pl-4">
<pre className="whitespace-pre-wrap break-words font-mono text-sm leading-relaxed text-[#d0d0d0]">
{msg.text || (msg.streaming ? "" : "(empty response)")}
</pre>
<ChatMarkdown
text={
msg.text || (msg.streaming ? "" : "(empty response)")
}
/>
{msg.streaming && (
<div className="pt-1.5">
<span className="inline-flex items-center gap-2 rounded-full border border-sky-400/25 bg-sky-500/[0.08] px-2 py-0.5 text-[10px] text-sky-100/90">
@@ -422,10 +424,7 @@ export default function ChatView() {
{/* Input bar */}
<div className="px-5 pb-4 pt-2">
<form
onSubmit={onSend}
className="mx-auto max-w-3xl"
>
<form onSubmit={onSend} className="mx-auto max-w-3xl">
<div className="group rounded-[20px] border border-white/[0.08] bg-[#141416] transition-colors duration-200 focus-within:border-white/[0.16]">
{/* Textarea area */}
<div className="px-4 pt-4 pb-2">
@@ -458,8 +457,21 @@ export default function ChatView() {
<span className="max-w-[180px] truncate">
{selectedModel}
</span>
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" className="opacity-50">
<path d="M2.5 4L5 6.5L7.5 4" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
<svg
width="10"
height="10"
viewBox="0 0 10 10"
fill="none"
className="opacity-50"
aria-hidden="true"
>
<path
d="M2.5 4L5 6.5L7.5 4"
stroke="currentColor"
strokeWidth="1.2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</button>
{isModelMenuOpen && (
@@ -505,7 +517,10 @@ export default function ChatView() {
className="inline-flex cursor-pointer items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[13px] text-[#a0a0a0]/70 transition-colors duration-150 hover:bg-white/[0.06] hover:text-[#d0d0d0]"
htmlFor="reasoning-effort"
>
<span>{selectedEffort.charAt(0).toUpperCase() + selectedEffort.slice(1)}</span>
<span>
{selectedEffort.charAt(0).toUpperCase() +
selectedEffort.slice(1)}
</span>
<select
id="reasoning-effort"
className="absolute opacity-0 w-0 h-0"
@@ -513,14 +528,31 @@ export default function ChatView() {
onChange={(event) => setSelectedEffort(event.target.value)}
>
{REASONING_OPTIONS.map((effort) => (
<option key={effort} value={effort} className="bg-[#1b1b1d]">
<option
key={effort}
value={effort}
className="bg-[#1b1b1d]"
>
{effort}
{effort === DEFAULT_REASONING ? " (default)" : ""}
</option>
))}
</select>
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" className="opacity-50">
<path d="M2.5 4L5 6.5L7.5 4" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
<svg
width="10"
height="10"
viewBox="0 0 10 10"
fill="none"
className="opacity-50"
aria-hidden="true"
>
<path
d="M2.5 4L5 6.5L7.5 4"
stroke="currentColor"
strokeWidth="1.2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</label>
</div>
@@ -539,7 +571,13 @@ export default function ChatView() {
onClick={() => void onInterrupt()}
aria-label="Stop generation"
>
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
<svg
width="12"
height="12"
viewBox="0 0 12 12"
fill="currentColor"
aria-hidden="true"
>
<rect x="2" y="2" width="8" height="8" rx="1.5" />
</svg>
</button>
@@ -548,15 +586,48 @@ export default function ChatView() {
type="submit"
className="flex h-8 w-8 items-center justify-center rounded-full bg-white/90 text-[#0c0c0c] transition-all duration-150 hover:bg-white hover:scale-105 disabled:opacity-30 disabled:hover:scale-100"
disabled={isSending || isConnecting || !prompt.trim()}
aria-label={isConnecting ? "Connecting" : isSending ? "Sending" : "Send message"}
aria-label={
isConnecting
? "Connecting"
: isSending
? "Sending"
: "Send message"
}
>
{isConnecting || isSending ? (
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" className="animate-spin">
<circle cx="7" cy="7" r="5.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeDasharray="20 12" />
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
className="animate-spin"
aria-hidden="true"
>
<circle
cx="7"
cy="7"
r="5.5"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeDasharray="20 12"
/>
</svg>
) : (
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<path d="M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
aria-hidden="true"
>
<path
d="M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5"
stroke="currentColor"
strokeWidth="1.8"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)}
</button>
+26 -1
View File
@@ -1,5 +1,6 @@
import { useState } from "react";
import { useMemo, useState } from "react";
import { DEFAULT_MODEL, MODEL_OPTIONS, resolveModelSlug } from "../model-logic";
import { readNativeApi } from "../session-logic";
import { useStore } from "../store";
import type { Project } from "../types";
@@ -15,9 +16,11 @@ function formatRelativeTime(iso: string): string {
export default function Sidebar() {
const { state, dispatch } = useStore();
const api = useMemo(() => readNativeApi(), []);
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();
@@ -56,6 +59,18 @@ export default function Sidebar() {
});
};
const handlePickFolder = async () => {
if (!api || isPickingFolder) return;
setIsPickingFolder(true);
try {
const pickedPath = await api.dialogs.pickFolder();
if (!pickedPath) return;
setNewCwd(pickedPath);
} finally {
setIsPickingFolder(false);
}
};
return (
<aside className="sidebar flex h-full w-[260px] shrink-0 flex-col border-r border-white/[0.08] bg-[#141414]">
{/* Drag region / traffic light space */}
@@ -186,6 +201,16 @@ export default function Sidebar() {
if (e.key === "Escape") setAddingProject(false);
}}
/>
{api && (
<button
type="button"
className="mb-2 flex w-full items-center justify-center rounded-md border border-white/[0.1] px-2 py-1.5 text-xs text-[#a0a0a0]/70 transition-colors duration-150 hover:bg-white/[0.04] 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-white/[0.1] bg-white/[0.04] px-2 py-1.5 font-mono text-xs text-[#e0e0e0] placeholder:text-[#a0a0a0]/30 focus:border-white/30 focus:outline-none"
value={newModel}
+82
View File
@@ -76,3 +76,85 @@ label:has(> select#reasoning-effort) select {
width: 100%;
height: 100%;
}
/* Chat markdown rendering */
.chat-markdown {
overflow-wrap: anywhere;
}
.chat-markdown > :first-child {
margin-top: 0;
}
.chat-markdown > :last-child {
margin-bottom: 0;
}
.chat-markdown p,
.chat-markdown ul,
.chat-markdown ol,
.chat-markdown blockquote,
.chat-markdown pre,
.chat-markdown table {
margin: 0.65rem 0;
}
.chat-markdown ul,
.chat-markdown ol {
padding-left: 1.25rem;
}
.chat-markdown li + li {
margin-top: 0.25rem;
}
.chat-markdown a {
color: #93c5fd;
text-decoration: underline;
text-decoration-color: rgba(147, 197, 253, 0.4);
}
.chat-markdown a:hover {
color: #bfdbfe;
}
.chat-markdown blockquote {
border-left: 2px solid rgba(255, 255, 255, 0.2);
padding-left: 0.8rem;
color: rgba(224, 224, 224, 0.75);
}
.chat-markdown :not(pre) > code {
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 0.375rem;
background: rgba(255, 255, 255, 0.07);
padding: 0.1rem 0.35rem;
color: #f4f4f5;
}
.chat-markdown pre {
overflow-x: auto;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 0.75rem;
background: rgba(0, 0, 0, 0.3);
padding: 0.8rem 0.9rem;
}
.chat-markdown pre code {
border: none;
background: transparent;
padding: 0;
line-height: 1.5;
}
.chat-markdown table {
width: 100%;
border-collapse: collapse;
}
.chat-markdown th,
.chat-markdown td {
border: 1px solid rgba(255, 255, 255, 0.12);
padding: 0.35rem 0.45rem;
text-align: left;
}
+1
View File
@@ -1,5 +1,6 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "highlight.js/styles/github-dark.css";
import App from "./App";
import "./index.css";