Skip to content
Closed
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
5 changes: 4 additions & 1 deletion apps/desktop/scripts/dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ while (!(await ready())) await sleep(100);

let electron;
function startElectron() {
electron = run("node", ["scripts/start-electron.mjs"], {
// pnpm inserts a lone `--` before arguments meant for the script.
const extra = process.argv.slice(2);
if (extra[0] === "--") extra.shift();
electron = run("node", ["scripts/start-electron.mjs", ...extra], {
cwd: desktopDir,
env: { ...process.env, CODEWORK_WEB_URL: WEB_URL },
});
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/scripts/start-electron.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const electronPath = process.platform === "darwin" ? brandedElectron() : electro
const env = { ...process.env };
delete env.ELECTRON_RUN_AS_NODE;

const child = spawn(electronPath, ["."], {
// Extra arguments reach Electron, `--remote-debugging-port=9222` say.
const child = spawn(electronPath, [".", ...process.argv.slice(2)], {
stdio: "inherit",
cwd: desktopDir,
env,
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ function createMainWindow(): BrowserWindow {
minWidth: 840,
minHeight: 620,
// The web shell draws its own title bar (workspace switcher) beside the
// inset traffic lights, which sit centered in its 48px height.
// inset traffic lights, which sit centered in its 40px height.
...(process.platform === "darwin" && {
titleBarStyle: "hiddenInset",
trafficLightPosition: { x: 14, y: 18 },
trafficLightPosition: { x: 14, y: 14 },
}),
// Windows and Linux take the window's icon; macOS ignores it for the Dock's.
icon: ICON,
Expand Down
9 changes: 5 additions & 4 deletions apps/web/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<!doctype html>
<html lang="en">
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CodeWork</title>
<!-- The saved theme (src/theme.ts) lands before first paint; an unknown id falls back to the default. -->
<script>
try {
document.documentElement.dataset.theme = localStorage.getItem("codework-theme") ?? "tokyo-night";
const saved = localStorage.getItem("codework-theme");
document.documentElement.dataset.theme = saved === "light" ? "light" : "dark";
} catch {}
</script>
<!-- Linked here rather than imported by style.css, so the splash paints in the theme before the app's JS runs. -->
Expand All @@ -22,10 +23,10 @@

/* The app's desktop tint (--cw-desktop in style.css), so the swap to the app does not shift colour. */
body {
background: color-mix(in oklab, var(--t-bg) 96%, var(--t-text));
background: var(--cw-desktop, var(--t-bg));
color: var(--t-text);
font:
13px/1.4 system-ui,
var(--text-ui, 12px) / 1.4 var(--font-sans, system-ui),
-apple-system,
"Segoe UI",
sans-serif;
Expand Down
34 changes: 11 additions & 23 deletions apps/web/src/components/composer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CornerDownLeft, X, type LucideIcon } from "lucide-react";
import type { ComponentProps, ReactNode, Ref } from "react";
import type { ReactNode, Ref } from "react";

import { cn } from "@/lib/utils";
import { isMac } from "@codeworksh/widget/view";
Expand Down Expand Up @@ -48,10 +48,8 @@ export function Composer({
return (
<div className="w-full">
<form
// Raised like a frame (the theme's top-down gradient, top highlight and shadows), with a deeper
// drop so it still floats when it sits inside one.
className={cn(
"relative z-10 flex flex-col rounded-[22px] border border-edge bg-linear-to-b from-frame-top to-frame to-60% shadow-[inset_0_1px_0_var(--cw-highlight),0_1px_2px_var(--cw-shadow-near),0_14px_36px_-12px_var(--cw-shadow-far)] transition-colors focus-within:border-edge-focus",
"composer-surface relative z-10 flex flex-col transition-colors duration-120 focus-within:border-edge-focus",
className,
)}
onSubmit={(event) => {
Expand Down Expand Up @@ -84,20 +82,20 @@ export function Composer({
placeholder={placeholder}
aria-label="Prompt"
// Grows with its text, from four lines (one when compact) up to about nine, then scrolls.
className={`block max-h-52 w-full resize-none bg-transparent text-[14px] leading-relaxed text-ink outline-none [field-sizing:content] placeholder:text-ink-muted ${compact ? "min-h-6" : "min-h-19.5"}`}
className={`block max-h-52 w-full resize-none bg-transparent text-body text-ink outline-none [field-sizing:content] placeholder:text-ink-muted ${compact ? "min-h-6" : "min-h-19.5"}`}
/>
</div>
<div className={`flex items-center gap-2 ${compact ? "px-2.5 pb-2.5" : "px-4 pb-4"}`}>
{/* Pulled left by a control's padding, so the first one's icon lines up with the prompt's text. */}
<div className="-ml-2.5 flex min-w-0 flex-1 items-center gap-1 text-[14px] font-medium text-ink-muted">
<div className="-ml-2.5 flex min-w-0 flex-1 flex-wrap items-center gap-1 text-ui font-medium text-ink-muted">
{controls}
</div>
{actions}
</div>
</form>
{tray !== undefined && (
// Inset from the card's rounded corners, tucked under its bottom edge.
<div className="mx-5.5 -mt-4 flex items-center gap-2 rounded-b-[16px] border border-edge bg-frame/60 px-2 pt-5 pb-1 text-[12px] text-ink-muted/70">
<div className="mx-3 -mt-3 flex items-center gap-2 rounded-b-lg border border-edge bg-selection-subtle px-2 pt-4 pb-1 text-ui text-ink-muted">
{tray}
</div>
)}
Expand All @@ -106,17 +104,7 @@ export function Composer({
}

/** Shared expanded surface for starting a session and replying to one. */
export function PromptComposer(props: ComponentProps<typeof Composer>) {
return (
<Composer
{...props}
className={cn(
"rounded-xl bg-frame-top [&_textarea]:rounded-lg [&_textarea]:bg-ink/4 [&_textarea]:px-3 [&_textarea]:py-2",
props.className,
)}
/>
);
}
export const PromptComposer = Composer;

export function ComposerHeader({
title,
Expand All @@ -128,9 +116,9 @@ export function ComposerHeader({
readonly onClose?: () => void;
}) {
return (
<div className="flex h-10 items-center gap-2 px-4 text-[12px] text-ink-muted">
<Icon className="size-3.5 text-brand" aria-hidden />
<span className="flex-1 font-medium text-ink">{title}</span>
<div className="flex h-pane items-center gap-2 px-4 text-ui text-ink-muted">
<Icon className="size-3.5" aria-hidden />
<span className="flex-1 font-medium">{title}</span>
{onClose !== undefined && (
<button
type="button"
Expand Down Expand Up @@ -159,7 +147,7 @@ export function ComposerSubmit({
<button
type="submit"
disabled={disabled}
className="flex h-8 shrink-0 items-center gap-2 rounded-md bg-brand px-3 text-[12px] font-medium text-brand-ink outline-none hover:brightness-110 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-frame press disabled:pointer-events-none disabled:opacity-50"
className="flex h-7 shrink-0 items-center gap-2 rounded-md bg-primary px-2.5 text-ui font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-frame press disabled:pointer-events-none disabled:bg-primary/25 disabled:text-primary-foreground/60"
title={title ?? `${label} (Enter)`}
>
{label}
Expand Down Expand Up @@ -188,7 +176,7 @@ export function ComposerButton({
title={label}
disabled={disabled}
onClick={onClick}
className="grid size-8 shrink-0 place-items-center rounded-full bg-brand text-brand-ink shadow-xs transition-[opacity,scale,filter] duration-150 ease-out enabled:hover:brightness-110 enabled:active:scale-[0.97] disabled:opacity-64"
className="grid size-7 shrink-0 place-items-center rounded-md bg-primary text-primary-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring press enabled:hover:bg-primary/90 disabled:bg-primary/25 disabled:text-primary-foreground/60"
>
{children}
</button>
Expand Down
18 changes: 10 additions & 8 deletions apps/web/src/kernel/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface Problem {
/** The default server's problem from its status; undefined while the app can work with it. */
export function problemOf(status: ServerStatus): Problem | undefined {
const { cli, server } = status;
// An already running, compatible server is usable even without a local CLI.
if (server._tag === "Running") return undefined;
if (cli === null)
return {
title: "CodeWork Isn't Installed",
Expand All @@ -43,25 +45,25 @@ export function problemOf(status: ServerStatus): Problem | undefined {
title: "Incompatible Server Version",
line: `${status.name} runs codework v${server.version}, which this app can't read.`,
};
case "Running":
return undefined;
}
}

/**
* Every server's status, as the app server last checked it, kept current as it checks again. When
* the default server becomes usable, whatever failed while it was not loads again.
* the default server becomes usable or its home changes, its queries load again.
*/
export const serversAtom = Server.runtime
.atom(
Stream.suspend(() => {
let wasUsable: boolean | undefined;
let previous: { readonly home: string | undefined; readonly usable: boolean } | undefined;
return Stream.unwrap(Server.use((client) => Effect.succeed(client("servers.watch", undefined)))).pipe(
Stream.tap((statuses) => {
const now = statuses.some((status) => status.isDefault && problemOf(status) === undefined);
const recovered = wasUsable === false && now;
wasUsable = now;
return recovered ? Reactivity.invalidate(codeworkKey) : Effect.void;
const current = statuses.find((status) => status.isDefault);
const home = current?.home.path;
const usable = current !== undefined && problemOf(current) === undefined;
const refresh = usable && previous !== undefined && (!previous.usable || previous.home !== home);
previous = { home, usable };
return refresh ? Reactivity.invalidate(codeworkKey) : Effect.void;
}),
// The app server is local, so a dropped stream is only a moment's gap.
Stream.retry(Schedule.spaced("1 second")),
Expand Down
11 changes: 6 additions & 5 deletions apps/web/src/landing/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ export function Landing() {
<div className="flex h-full min-w-0 flex-col select-none">
<main className="relative flex min-h-0 flex-1 flex-col items-center overflow-auto px-4">
<div className="flex-[0.8]" />
<Wordmark className="pointer-events-none w-[min(88%,44rem)] shrink-0 text-brand opacity-15" />
<div className="mt-10 w-full max-w-2xl shrink-0">
<Wordmark className="pointer-events-none w-[min(60%,22rem)] shrink-0 text-ink opacity-20" />
<p className="mt-5 text-body text-ink-muted">What would you like to work on?</p>
<div className="mt-6 w-full max-w-2xl shrink-0">
{notice !== undefined && <ComposerNotice {...notice} />}
<PromptComposer
header={<ComposerHeader title="New Session" icon={SquarePen} />}
header={<ComposerHeader title="New session" icon={SquarePen} />}
autoFocus
value={query}
onChange={setQuery}
onSubmit={() => void send()}
placeholder="Ask for changes, send follow-ups, or attach images"
placeholder="Describe a task or ask a question…"
controls={
<>
<ModelPicker
Expand All @@ -105,7 +106,7 @@ export function Landing() {
/>
</>
}
actions={<ComposerSubmit label="Start Session" disabled={!canSend} />}
actions={<ComposerSubmit label="Start session" disabled={!canSend} />}
tray={
<>
<DropdownMenu>
Expand Down
23 changes: 13 additions & 10 deletions apps/web/src/landing/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,23 @@ export function SessionsSidebar() {
aria-label="Search sessions"
value={query}
onChange={(event) => setQuery(event.target.value)}
className="h-8 rounded-lg border-transparent bg-transparent pl-8 text-sm shadow-none focus-visible:bg-ink/5"
className="h-7 rounded-md border-transparent bg-transparent pl-8 text-ui shadow-none focus-visible:bg-selection-subtle"
/>
</div>
<button
type="button"
onClick={startNew}
className="mt-1 flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-sm text-ink transition-colors outline-none hover:bg-ink/5 focus-visible:bg-ink/5"
className="mt-1 flex h-7 w-full items-center gap-2 rounded-md px-2.5 text-left text-ui text-ink outline-none hover:bg-selection-subtle focus-visible:ring-2 focus-visible:ring-ring press"
>
<SquarePen className="size-3.5 text-ink-muted" aria-hidden />
New
New session
</button>
</div>
</SidebarHeader>
<SidebarContent className="px-2 pt-2 pb-2">
<SidebarContent className="gap-0 px-2 pb-2">
<h2 className="flex h-7 shrink-0 items-center px-2.5 text-2xs font-medium text-ink-muted">
Recent sessions
</h2>
{problem !== undefined ? (
<OpenProviderSettings
problem={problem}
Expand All @@ -103,18 +106,18 @@ export function SessionsSidebar() {
<Empty>
{place.kind === "none" && result.value.length === 0 ? (
<>
<span>No Projects Yet</span>
<span>No projects yet</span>
{addProject !== undefined && (
<EmptyAction
icon={<Plus className="-mx-0.5 size-3" strokeWidth={2} aria-hidden />}
onClick={addProject}
>
Add Project
Add project
</EmptyAction>
)}
</>
) : (
<span>No Sessions Yet</span>
<span>No sessions yet</span>
)}
</Empty>
)
Expand All @@ -126,16 +129,16 @@ export function SessionsSidebar() {
type="button"
title={`${session.project.path}\n${isMac ? "⌘" : "Ctrl"}-click opens it in a new frame\n⇧-click opens it in a new workspace`}
aria-current={sessionAddress(session.id) === current ? "true" : undefined}
className="block w-full rounded-lg px-2.5 py-2 text-left transition-colors outline-none hover:bg-ink/5 focus-visible:bg-ink/5 aria-current:bg-ink/8"
className="block w-full rounded-md px-2.5 py-2 text-left outline-none hover:bg-selection-subtle focus-visible:ring-2 focus-visible:ring-ring aria-current:bg-selection"
onClick={(event) => open(session, event)}
onAuxClick={(event) => open(session, event)}
>
<div className="flex h-5 min-w-0 items-center gap-1.5 text-xs text-ink-muted">
<div className="flex h-4 min-w-0 items-center gap-1.5 text-2xs text-ink-muted">
<Monogram id={session.project.id} name={session.project.name} />
<span className="min-w-0 flex-1 truncate">{session.project.name}</span>
<span className="shrink-0 tabular-nums">{ago(session.updated)}</span>
</div>
<div className="mt-1 truncate text-sm text-ink">{session.title}</div>
<div className="mt-1 truncate text-ui text-ink">{session.title}</div>
</button>
</li>
))}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ function Root() {
return (
<SidebarProvider
className="app-shell h-full min-h-0 flex-col bg-desktop"
style={{ "--sidebar-width": "15rem" } as CSSProperties}
style={{ "--sidebar-width": "16.25rem" } as CSSProperties}
widthStorageKey="codework.sidebar.width"
>
<NavigationControls />
<div className="mb-2 mr-2 ml-[52px] flex min-h-0 flex-1 overflow-hidden rounded-xl bg-frame">
<div className="mb-2 mr-2 ml-rail flex min-h-0 flex-1 overflow-hidden rounded-xl border border-edge bg-frame">
<Navigation />
{inSettings ? <SettingsSidebar /> : <SessionsSidebar />}
<div className="flex min-w-0 flex-1 flex-col overflow-hidden">
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/settings/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export function Page({
children: ReactNode;
}) {
return (
<div className="mx-auto flex w-full max-w-248 flex-col gap-8 px-5 py-8 text-sm sm:px-8 sm:py-10">
<div className="@container mx-auto flex w-full max-w-conversation flex-col gap-6 px-5 py-8 text-ui sm:px-8">
<header className="flex flex-col gap-2">
<div className="flex items-center gap-4">
<h1 className="min-w-0 flex-1 text-2xl/tight font-semibold tracking-tight">{title}</h1>
<h1 className="min-w-0 flex-1 text-[22px]/tight font-semibold tracking-tight">{title}</h1>
{actions}
</div>
{description !== undefined && <p className="text-ink-muted">{description}</p>}
Expand All @@ -31,8 +31,8 @@ export function Page({

export function Section({ title, children }: { title: string; children: ReactNode }) {
return (
<section className="flex flex-col gap-3">
<h2 className="text-sm font-semibold">{title}</h2>
<section className="flex flex-col gap-2">
<h2 className="flex min-h-7 items-center text-ui font-medium text-ink-muted">{title}</h2>
{children}
</section>
);
Expand All @@ -54,10 +54,10 @@ export function Row({
children?: ReactNode;
}) {
return (
<div className="flex flex-col items-start gap-3 px-4 py-4 sm:flex-row sm:items-center sm:gap-4">
<div className="flex flex-col items-start gap-3 px-4 py-3 @min-[560px]:flex-row @min-[560px]:items-center @min-[560px]:gap-4">
<div className="flex min-w-0 flex-1 flex-col gap-1">
<span className="font-medium">{title}</span>
{description !== undefined && <span className="text-sm text-ink-muted">{description}</span>}
{description !== undefined && <span className="text-ui text-ink-muted">{description}</span>}
</div>
{children}
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function SettingsSidebar() {
return (
<Sidebar collapsible="offcanvas" className="shell-sidebar select-none">
<SidebarHeader className="gap-1 px-2 pt-2 pb-2">
<h1 className="flex h-8 items-center px-2.5 text-sm font-semibold text-ink">Settings</h1>
<h1 className="flex h-7 items-center px-2.5 text-ui font-medium text-ink">Settings</h1>
<div className="relative">
<Search
className="pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-ink-muted"
Expand All @@ -37,7 +37,7 @@ export function SettingsSidebar() {
placeholder="Search"
aria-label="Search settings"
value={query}
className="h-8 rounded-lg border-transparent bg-transparent pl-8 text-sm shadow-none focus-visible:bg-ink/5"
className="h-7 rounded-md border-transparent bg-transparent pl-8 text-ui shadow-none focus-visible:bg-selection-subtle"
onChange={(event) => setQuery(event.target.value)}
onKeyDown={(event) => {
const first = matches[0];
Expand Down Expand Up @@ -65,7 +65,7 @@ export function SettingsSidebar() {
<SidebarMenuButton
asChild
isActive={current}
className="h-8 rounded-lg px-2.5 text-sm text-ink-muted data-[active=true]:bg-ink/8 data-[active=true]:text-ink"
className="h-7 rounded-md px-2.5 text-ui text-ink-muted data-[active=true]:bg-selection data-[active=true]:text-ink"
>
<Link to={to} aria-current={current ? "page" : undefined}>
<Icon className="size-4" strokeWidth={1.5} aria-hidden />
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/settings/themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function ThemesSettings() {
}
>
<Section title="Theme">
<div role="radiogroup" aria-label="Theme" className="grid grid-cols-2 gap-3 sm:grid-cols-3">
<div role="radiogroup" aria-label="Theme" className="grid grid-cols-2 gap-3">
{THEMES.map((theme) => {
const selected = theme.id === current;
return (
Expand Down
Loading
Loading