From 58ddf57ab9a3c36bb25f2288a3072e734bb7b858 Mon Sep 17 00:00:00 2001 From: Tania Ashraf Date: Mon, 2 Nov 2026 20:52:13 +0500 Subject: [PATCH 1/8] feat(desktop): redesign local-first task workspace Add a project/task command-center UI, focused review screen, agent and cloud-worker pages, and a desktop-side bridge to the cloned local daemon database. Document that cloud workers and agent-runner execution are not yet available in the current daemon prototype. --- .env.example | 14 + .gitignore | 5 + README.md | 8 +- local-daemon-bridge.mjs | 256 ++++++++ src-tauri/src/lib.rs | 6 +- src/App.css | 1021 ++++++++++++----------------- src/App.tsx | 193 +++++- src/api/cloud.ts | 99 ++- src/components/AuthModal.tsx | 25 +- src/components/NewTaskForm.tsx | 54 +- src/components/SessionList.tsx | 87 --- src/components/SessionView.tsx | 197 ------ src/components/TaskDashboard.tsx | 130 ++++ src/components/TaskDetail.tsx | 130 ++++ src/components/Topbar.tsx | 41 +- src/components/WorkspacePages.tsx | 59 ++ 16 files changed, 1324 insertions(+), 1001 deletions(-) create mode 100644 .env.example create mode 100644 local-daemon-bridge.mjs delete mode 100644 src/components/SessionList.tsx delete mode 100644 src/components/SessionView.tsx create mode 100644 src/components/TaskDashboard.tsx create mode 100644 src/components/TaskDetail.tsx create mode 100644 src/components/WorkspacePages.tsx diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..94107bf --- /dev/null +++ b/.env.example @@ -0,0 +1,14 @@ +# Copy this to .env and fill in values for your machine. +# Never commit .env — it's git-ignored. + +# Real cloud server (Memoona's codehands-backend). +# Start it: cd ../codehands-backend && npm run dev +VITE_CLOUD_URL=http://localhost:3000 + +# OR use the mock server instead of the real backend: +# VITE_CLOUD_URL=http://localhost:4000 + +# GitHub OAuth client ID (get from your GitHub OAuth App settings) +# Only needed for real GitHub login — mock accepts any code. +# VITE_GITHUB_CLIENT_ID=your_client_id_here + diff --git a/.gitignore b/.gitignore index f2bcfe4..a560ec8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,8 @@ dist-ssr *.sln *.sw? .vs/ + +# Local env (secrets + local URLs, never commit) +.env +.env.local +.env.*.local diff --git a/README.md b/README.md index 6e026ca..a3a5cf4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ It is the main way people use Code Hands AI. Everything a task needs runs on the **Owner:** Tania **Contracts:** L1 (local DB), C3 (cloud API), C5 (sessions) in [codehands-contracts](https://github.com/devweekends/codehands-contracts) **Part of:** [Code Hands AI](https://github.com/devweekends/codehands-docs). Read the design in that README first. -**Status:** not started. This repo has no code yet. This README describes what the app must do and how it fits, so it can be built against stand-ins from day one. +**Status:** early implementation. The desktop UI connects to the local daemon database and writes task/command rows; the current daemon watcher does not yet execute agent runs. ## Where it sits @@ -166,6 +166,8 @@ pnpm install pnpm tauri dev ``` -Requires Node, pnpm, and Rust (with the Visual Studio C++ build tools on Windows). +Requires Node 22.5+, pnpm, Rust, and the Tauri prerequisites (including Visual Studio C++ build tools on Windows). Clone `codehands-backend` and `codehands-contracts` beside this repo under `D:\dev`, as in the team workspace. -In dev, the app starts `fake-daemon.mjs` itself. It is temporary and will be replaced by the real daemon from codehands-server. +In development, Tauri starts `local-daemon-bridge.mjs`. It applies migrations from `../codehands-backend/daemon/migrations`, opens the same `~/.codehands/state.db` database, and starts the daemon watcher when the daemon's dependencies are installed. The app writes only `projects`, `tasks`, and `commands`; the watcher owns sessions and events. Set `CODEHANDS_DAEMON_DIR` if the daemon clone is not at `../codehands-backend/daemon`, or `CODEHANDS_DB` to use a separate SQLite file. The bridge listens on `127.0.0.1:8787` by default. + +The current daemon source is still a queue prototype: it claims tasks and records approve/reject commands, but it does not yet invoke Claude Code or Codex, create worktrees, commit changes, or stop/resume runs. The UI displays this limitation and does not present queue connectivity as agent execution. `fake-daemon.mjs` is no longer started by the desktop app. The local adapter uses port `8788` to avoid colliding with older fake-daemon instances on `8787`. diff --git a/local-daemon-bridge.mjs b/local-daemon-bridge.mjs new file mode 100644 index 0000000..21a9064 --- /dev/null +++ b/local-daemon-bridge.mjs @@ -0,0 +1,256 @@ +import { createHash, randomUUID } from "node:crypto"; +import { execFileSync, spawn } from "node:child_process"; +import { existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs"; +import { homedir } from "node:os"; +import { basename, dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { DatabaseSync } from "node:sqlite"; +import { WebSocketServer } from "ws"; + +const APP_ROOT = dirname(fileURLToPath(import.meta.url)); +const DAEMON_ROOT = process.env.CODEHANDS_DAEMON_DIR + ? resolve(process.env.CODEHANDS_DAEMON_DIR) + : resolve(APP_ROOT, "..", "codehands-backend", "daemon"); +const DB_PATH = process.env.CODEHANDS_DB || join(homedir(), ".codehands", "state.db"); +const PORT = Number(process.env.CODEHANDS_LOCAL_PORT || 8788); +const VALID_AGENTS = new Set(["claude-code", "codex", "codehands"]); +const VALID_COMMANDS = new Set(["approve", "reject"]); + +if (!existsSync(join(DAEMON_ROOT, "migrations"))) { + throw new Error(`Could not find daemon migrations at ${DAEMON_ROOT}. Set CODEHANDS_DAEMON_DIR to the daemon clone.`); +} + +mkdirSync(dirname(DB_PATH), { recursive: true }); +const db = new DatabaseSync(DB_PATH); +db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;"); + +// Apply the daemon repository's own migration files, keeping it the schema source of truth. +db.exec(`create table if not exists schema_migrations ( + version integer primary key, + applied_at text not null default (strftime('%Y-%m-%dT%H:%M:%fZ','now')) +)`); +const applied = new Set(db.prepare("select version from schema_migrations").all().map((row) => row.version)); +const migrationDir = join(DAEMON_ROOT, "migrations"); +for (const filename of readdirSync(migrationDir).filter((name) => /^\d+_.*\.sql$/.test(name)).sort()) { + const version = Number.parseInt(filename, 10); + if (applied.has(version)) continue; + db.exec("BEGIN IMMEDIATE"); + try { + db.exec(readFileSync(join(migrationDir, filename), "utf8")); + db.prepare("insert into schema_migrations (version) values (?)").run(version); + db.exec("COMMIT"); + } catch (error) { + db.exec("ROLLBACK"); + throw error; + } + console.log(`[desktop bridge] applied daemon migration ${filename}`); +} + +const watcher = startWatcher(); +let watcherState = watcher ? "starting" : "unavailable"; +watcher?.on("spawn", () => { + watcherState = "running"; + broadcastState(); +}); +watcher?.on("error", (error) => { + watcherState = "unavailable"; + console.error("[desktop bridge] daemon watcher could not start:", error.message); + broadcastState(); +}); +watcher?.on("exit", (code) => { + watcherState = code === 0 ? "stopped" : "unavailable"; + console.warn(`[desktop bridge] daemon watcher exited with code ${code}`); + broadcastState(); +}); + +const wss = new WebSocketServer({ host: "127.0.0.1", port: PORT }); +const pendingRequests = new Map(); +let lastState = null; +wss.on("error", (error) => { + console.error(`[desktop bridge] could not listen on 127.0.0.1:${PORT}:`, error.message); + watcher?.kill(); + db.close(); + process.exit(1); +}); + +function startWatcher() { + if (process.env.CODEHANDS_START_DAEMON === "false") return null; + if (!existsSync(join(DAEMON_ROOT, "node_modules"))) { + console.warn("[desktop bridge] daemon dependencies are not installed; app can queue tasks but watcher will be offline."); + return null; + } + const windows = process.platform === "win32"; + return spawn(windows ? "cmd.exe" : "npm", windows + ? ["/d", "/s", "/c", "npm run watch"] + : ["run", "watch"], { + cwd: DAEMON_ROOT, + env: process.env, + windowsHide: true, + stdio: "ignore", + }); +} + +function readState() { + const projects = db.prepare(` + select p.id, p.name, p.repo_id as repoId, p.path, + p.created_at as createdAt, + (select count(*) from sessions s where s.project_id = p.id) as sessionCount + from projects p order by p.name collate nocase + `).all(); + const providers = db.prepare(` + select agent, state, reason, retry_at as retryAt, checked_at as checkedAt + from provider_status order by agent + `).all(); + const sessions = db.prepare(` + select s.id, s.task_id as taskId, s.project_id as projectId, s.status, + s.agent, s.model, s.cost_usd as costUsd, s.branch, + s.base_commit as baseCommit, s.diff, s.created_at as createdAt, + t.prompt, p.name as projectName, p.path as repo + from sessions s + join tasks t on t.id = s.task_id + join projects p on p.id = s.project_id + order by s.created_at desc + `).all().map((row) => ({ + ...row, + title: row.prompt.length > 84 ? `${row.prompt.slice(0, 81)}…` : row.prompt, + model: row.model || "unspecified", + costUsd: Number(row.costUsd || 0), + })); + const events = {}; + const rows = db.prepare(` + select e.session_id as sessionId, e.seq as id, e.type as eventType, + e.payload, e.created_at as ts + from events e order by e.session_id, e.seq + `).all(); + for (const row of rows) { + const list = events[row.sessionId] || (events[row.sessionId] = []); + let payload = {}; + try { payload = JSON.parse(row.payload || "{}"); } catch { /* malformed event payload */ } + list.push({ ...row, payload }); + } + return { + type: "state", + projects, + providers, + sessions, + events, + daemon: { watcher: watcherState, execution: "runner-not-integrated" }, + }; +} + +function broadcastState() { + try { + lastState = readState(); + const message = JSON.stringify(lastState); + for (const client of wss.clients) { + if (client.readyState === 1) client.send(message); + } + for (const [taskId, requestId] of pendingRequests) { + const session = lastState.sessions.find((item) => item.taskId === taskId); + if (session) { + const message = JSON.stringify({ type: "session", session, requestId }); + for (const client of wss.clients) if (client.readyState === 1) client.send(message); + pendingRequests.delete(taskId); + } + } + } catch (error) { + console.error("[desktop bridge] database read failed:", error.message); + } +} + +function getRepoIdentity(repoPath) { + let origin = ""; + try { + origin = execFileSync("git", ["config", "--get", "remote.origin.url"], { + cwd: repoPath, + encoding: "utf8", + stdio: ["ignore", "pipe", "ignore"], + }).trim(); + } catch { /* use local path for repos without a remote */ } + return createHash("sha256").update(origin || repoPath).digest("hex").slice(0, 16); +} + +function createTask(payload) { + const repo = String(payload.repo || "").trim(); + const prompt = String(payload.task || "").trim(); + const agent = String(payload.agent || ""); + if (!repo || !prompt) throw new Error("Choose a repository and describe the task."); + if (!VALID_AGENTS.has(agent)) throw new Error("Choose a supported agent."); + if (!existsSync(repo)) throw new Error("The selected repository path does not exist."); + + const repoPath = resolve(repo); + const repoId = getRepoIdentity(repoPath); + let project = db.prepare("select id from projects where repo_id = ?").get(repoId); + if (!project) { + project = { id: randomUUID() }; + db.prepare("insert into projects (id, name, repo_id, path) values (?, ?, ?, ?)") + .run(project.id, basename(repoPath), repoId, repoPath); + } else { + db.prepare("update projects set path = ? where id = ?").run(repoPath, project.id); + } + + const id = randomUUID(); + const models = payload.phaseModels && typeof payload.phaseModels === "object" + ? payload.phaseModels + : { implement: String(payload.model || "unspecified") }; + db.prepare("insert into tasks (id, project_id, prompt, agent, models, created_by) values (?, ?, ?, ?, ?, ?)") + .run(id, project.id, prompt, agent, JSON.stringify(models), "desktop"); + return { taskId: id }; +} + +function createCommand(sessionId, commandKind) { + if (!VALID_COMMANDS.has(commandKind)) { + throw new Error("This daemon build only supports approve/reject commands. Stop and resume require runner integration."); + } + const session = db.prepare("select id, project_id as projectId, status from sessions where id = ?").get(sessionId); + if (!session) throw new Error("Session not found."); + const targetStatus = commandKind === "approve" ? "approved" : "rejected"; + const allowed = commandKind === "approve" || commandKind === "reject" + ? session.status === "awaiting_approval" + : false; + if (!allowed) throw new Error(`Cannot ${commandKind} a session while it is ${session.status}.`); + db.prepare("insert into commands (id, session_id, project_id, kind, created_by) values (?, ?, ?, ?, ?)") + .run(randomUUID(), session.id, session.projectId, commandKind, "desktop"); + return { accepted: true, targetStatus }; +} + +wss.on("connection", (socket) => { + try { + socket.send(JSON.stringify(lastState || readState())); + } catch (error) { + socket.send(JSON.stringify({ type: "error", message: error.message })); + } + socket.on("message", (raw) => { + let message; + try { message = JSON.parse(raw.toString()); } catch { return; } + if (message.type !== "command") return; + try { + if (message.commandType === "start") { + const { taskId } = createTask(message.payload || {}); + if (message.requestId) pendingRequests.set(taskId, message.requestId); + socket.send(JSON.stringify({ type: "accepted", requestId: message.requestId, taskId })); + broadcastState(); + } else { + createCommand(message.sessionId, message.commandType); + socket.send(JSON.stringify({ type: "command.accepted", sessionId: message.sessionId, commandType: message.commandType })); + broadcastState(); + } + } catch (error) { + socket.send(JSON.stringify({ type: "error", requestId: message.requestId, message: error.message })); + } + }); +}); + +broadcastState(); +const poll = setInterval(broadcastState, 900); +console.log(`[desktop bridge] ws://127.0.0.1:${PORT} -> ${DB_PATH}`); + +function shutdown() { + clearInterval(poll); + watcher?.kill(); + wss.close(); + db.close(); + process.exit(0); +} +process.on("SIGINT", shutdown); +process.on("SIGTERM", shutdown); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 9d3f542..1b34361 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -57,10 +57,10 @@ pub fn run() { delete_device_token ]) .setup(|app| { - // App khulte hi fake daemon start karo - // (dev mein folder src-tauri hota hai, is liye ../ lagaya) + // Start the desktop-owned bridge to the cloned local daemon database. + // The bridge reads the daemon migration files and starts its watcher. let child = Command::new("node") - .arg("../fake-daemon.mjs") + .arg("../local-daemon-bridge.mjs") .spawn() .ok(); app.manage(Daemon(Mutex::new(child))); diff --git a/src/App.css b/src/App.css index 712e6e8..ed58027 100644 --- a/src/App.css +++ b/src/App.css @@ -1,616 +1,409 @@ :root { - --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; - --bg-primary: #121316; - --bg-surface: #1a1c22; - --bg-card: #22252c; - --bg-input: #16181d; - --border-color: #2e323b; - --border-focus: #4f80e1; - --text-main: #f0f2f5; - --text-muted: #959da5; - --accent: #3b82f6; - --accent-hover: #2563eb; - --accent-light: rgba(59, 130, 246, 0.15); - --success: #10b981; - --success-bg: rgba(16, 185, 129, 0.15); - --warning: #f59e0b; - --warning-bg: rgba(245, 158, 11, 0.15); - --danger: #ef4444; - --danger-bg: rgba(239, 68, 68, 0.15); - --radius-sm: 6px; - --radius-md: 10px; - --radius-lg: 14px; -} - -* { - box-sizing: border-box; - margin: 0; - padding: 0; -} - -body { - font-family: var(--font-family); - background-color: var(--bg-primary); - color: var(--text-main); - line-height: 1.5; - -webkit-font-smoothing: antialiased; -} - -.app-layout { - min-height: 100vh; - display: flex; - flex-direction: column; -} - -/* ---- Topbar ---- */ -.topbar { - display: flex; - justify-content: space-between; - align-items: center; - padding: 14px 28px; - background-color: var(--bg-surface); - border-bottom: 1px solid var(--border-color); - position: sticky; - top: 0; - z-index: 100; -} - -.topbar-left { - display: flex; - align-items: center; - gap: 16px; -} - -.logo-title { - font-size: 1.25rem; - font-weight: 700; - letter-spacing: -0.5px; - display: flex; - align-items: center; - gap: 8px; -} - -.logo-badge { - font-size: 0.75rem; - font-weight: 600; - background-color: var(--accent-light); - color: var(--accent); - padding: 2px 8px; - border-radius: var(--radius-sm); - text-transform: uppercase; -} - -.status-pill { - display: inline-flex; - align-items: center; - gap: 6px; - font-size: 0.8rem; - font-weight: 500; - padding: 4px 10px; - border-radius: 999px; -} - -.status-connected { - background-color: var(--success-bg); - color: var(--success); -} - -.status-disconnected { - background-color: var(--danger-bg); - color: var(--danger); -} - -.dot { - width: 8px; - height: 8px; - border-radius: 50%; - background-color: currentColor; -} - -.topbar-right { - display: flex; - align-items: center; - gap: 12px; -} - -.auth-profile { - display: flex; - align-items: center; - gap: 14px; -} - -.auth-info { - display: flex; - flex-direction: column; - align-items: flex-end; - font-size: 0.8rem; -} - -.user-id { - font-weight: 600; - color: var(--text-main); -} - -.device-id { - color: var(--text-muted); -} - -/* ---- Content Area ---- */ -.content-container { - flex: 1; - max-width: 1200px; - width: 100%; - margin: 0 auto; - padding: 28px 24px; -} - -/* ---- Card ---- */ -.card { - background-color: var(--bg-surface); - border: 1px solid var(--border-color); - border-radius: var(--radius-md); - padding: 24px; -} - -/* ---- Session List ---- */ -.section-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 24px; -} - -.muted-text { - color: var(--text-muted); - font-size: 0.9rem; -} - -.empty-state { - text-align: center; - padding: 60px 24px; - display: flex; - flex-direction: column; - align-items: center; - gap: 12px; -} - -.session-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); - gap: 16px; -} - -.session-card { - cursor: pointer; - transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; - display: flex; - flex-direction: column; - gap: 12px; -} - -.session-card:hover { - transform: translateY(-2px); - border-color: var(--accent); - box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25); -} - -.session-card-top { - display: flex; - justify-content: space-between; - align-items: center; -} - -.session-title { - font-size: 1.05rem; - font-weight: 600; - color: var(--text-main); -} - -.session-meta { - display: flex; - flex-direction: column; - gap: 4px; - font-size: 0.85rem; - color: var(--text-muted); - margin-top: auto; -} - -/* ---- Status Badges ---- */ -.status-badge { - font-size: 0.75rem; - font-weight: 600; - text-transform: capitalize; - padding: 3px 8px; - border-radius: var(--radius-sm); -} - -.badge-running { background-color: var(--accent-light); color: var(--accent); } -.badge-warning, .badge-awaiting_approval { background-color: var(--warning-bg); color: var(--warning); } -.badge-success, .badge-approved, .badge-finished { background-color: var(--success-bg); color: var(--success); } -.badge-danger, .badge-rejected, .badge-failed { background-color: var(--danger-bg); color: var(--danger); } -.badge-muted, .badge-stopped { background-color: rgba(255, 255, 255, 0.1); color: var(--text-muted); } - -/* ---- Form ---- */ -.form-container { - max-width: 680px; - margin: 0 auto; -} - -.card-header { - margin-bottom: 20px; -} - -.card-header h2 { - font-size: 1.4rem; - margin-bottom: 6px; -} - -.form-group { - margin-bottom: 18px; - display: flex; - flex-direction: column; - gap: 6px; -} - -.form-row { - display: flex; - gap: 16px; -} - -.flex-1 { - flex: 1; -} - -label { - font-size: 0.88rem; - font-weight: 500; - color: var(--text-main); -} - -input[type="text"], -select, -textarea { - width: 100%; - background-color: var(--bg-input); - border: 1px solid var(--border-color); - color: var(--text-main); - padding: 10px 14px; - border-radius: var(--radius-sm); - font-family: inherit; - font-size: 0.95rem; - outline: none; - transition: border-color 0.15s ease; -} - -input[type="text"]:focus, -select:focus, -textarea:focus { - border-color: var(--border-focus); -} - -.checkbox-label { - display: flex; - align-items: center; - gap: 8px; - cursor: pointer; - font-size: 0.9rem; -} - -.phase-models-panel { - background-color: var(--bg-card); - border: 1px solid var(--border-color); - border-radius: var(--radius-sm); - padding: 16px; - margin-bottom: 18px; -} - -.phase-models-panel h4 { - font-size: 0.88rem; - margin-bottom: 12px; - color: var(--text-muted); -} - -.phase-grid { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); - gap: 10px; -} - -.phase-item label { - font-size: 0.75rem; - color: var(--text-muted); -} - -.phase-item input { - padding: 6px 8px; - font-size: 0.85rem; -} - -.form-actions { - display: flex; - justify-content: flex-end; - gap: 12px; - margin-top: 24px; -} - -/* ---- Buttons ---- */ -button { - cursor: pointer; - font-family: inherit; - font-weight: 600; - border-radius: var(--radius-sm); - transition: all 0.15s ease; - border: none; -} - -.btn-primary { - background-color: var(--accent); - color: #fff; - padding: 10px 18px; -} - -.btn-primary:hover:not(:disabled) { - background-color: var(--accent-hover); -} - -.btn-primary:disabled { - opacity: 0.5; - cursor: not-allowed; -} - -.btn-secondary { - background-color: var(--bg-card); - border: 1px solid var(--border-color); - color: var(--text-main); - padding: 10px 18px; -} - -.btn-secondary:hover { - background-color: rgba(255, 255, 255, 0.05); -} - -.btn-danger { - background-color: var(--danger); - color: #fff; - padding: 10px 18px; -} - -.btn-danger-outline { - background-color: transparent; - border: 1px solid var(--danger); - color: var(--danger); - padding: 8px 14px; -} - -.btn-danger-outline:hover { - background-color: var(--danger-bg); -} - -.btn-success { - background-color: var(--success); - color: #fff; - padding: 10px 18px; -} - -.btn-link { - background: transparent; - color: var(--accent); - padding: 0; - font-size: 0.9rem; -} - -.btn-sm { - padding: 6px 12px; - font-size: 0.85rem; -} - -.btn-icon { - background: transparent; - color: var(--text-muted); - font-size: 1.1rem; -} - -/* ---- Session View ---- */ -.session-view-header { - margin-bottom: 24px; - display: flex; - flex-direction: column; - gap: 8px; -} - -.session-headline { - display: flex; - align-items: center; - gap: 14px; -} - -.view-grid { - display: grid; - grid-template-columns: 380px 1fr; - gap: 20px; -} - -.timeline { - list-style: none; - display: flex; - flex-direction: column; - gap: 14px; - margin-top: 16px; -} - -.timeline-item { - display: flex; - gap: 12px; - align-items: flex-start; -} - -.timeline-dot { - width: 10px; - height: 10px; - border-radius: 50%; - background-color: var(--accent); - margin-top: 6px; - flex-shrink: 0; -} - -.timeline-content { - display: flex; - flex-direction: column; - font-size: 0.88rem; -} - -.event-time { - font-size: 0.75rem; - color: var(--text-muted); -} - -.session-actions { - margin-top: 24px; -} - -/* ---- Diff Viewer ---- */ -.diff-header { - margin-bottom: 16px; -} - -.diff-summary { - font-size: 0.95rem; - color: var(--text-muted); - margin-top: 4px; -} - -.diff-file { - background-color: var(--bg-card); - border: 1px solid var(--border-color); - border-radius: var(--radius-sm); - margin-bottom: 14px; - overflow: hidden; -} - -.diff-file-header { - padding: 10px 14px; - background-color: rgba(255, 255, 255, 0.03); - display: flex; - justify-content: space-between; - align-items: center; - cursor: pointer; - font-family: monospace; - font-size: 0.88rem; -} - -.diff-stats { - display: flex; - gap: 8px; -} - -.stat-added { color: var(--success); } -.stat-removed { color: var(--danger); } - -.diff-pre { - margin: 0; - font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; - font-size: 0.82rem; - line-height: 1.4; - overflow-x: auto; -} - -.diff-line { - padding: 1px 12px; - white-space: pre-wrap; -} - -.line-add { - background-color: rgba(16, 185, 129, 0.15); - color: #34d399; -} - -.line-del { - background-color: rgba(239, 68, 68, 0.15); - color: #f87171; -} - -.line-hunk { - background-color: rgba(59, 130, 246, 0.12); - color: #60a5fa; -} - -.approval-bar { - margin-top: 24px; - padding: 16px; - background-color: var(--bg-card); - border: 1px solid var(--border-color); - border-radius: var(--radius-sm); - display: flex; - justify-content: space-between; - align-items: center; -} - -.approval-buttons { - display: flex; - gap: 12px; -} - -/* ---- Modal ---- */ -.modal-backdrop { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: rgba(0, 0, 0, 0.7); - backdrop-filter: blur(4px); - display: flex; - justify-content: center; - align-items: center; - z-index: 1000; - padding: 20px; -} - -.modal-card { - background-color: var(--bg-surface); - border: 1px solid var(--border-color); - border-radius: var(--radius-lg); - max-width: 460px; - width: 100%; - padding: 28px; - box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4); -} - -.modal-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 8px; -} - -.modal-description { - font-size: 0.88rem; - color: var(--text-muted); - margin-bottom: 20px; -} - -.modal-footer { - margin-top: 20px; - text-align: center; - font-size: 0.88rem; - color: var(--text-muted); -} - -/* ---- Alerts ---- */ -.alert-error { - background-color: var(--danger-bg); - color: var(--danger); - padding: 10px 14px; - border-radius: var(--radius-sm); - font-size: 0.88rem; - margin-top: 12px; -} - -.alert-warning { - background-color: var(--warning-bg); - color: var(--warning); - padding: 10px 14px; - border-radius: var(--radius-sm); - font-size: 0.88rem; - margin-bottom: 16px; + font-family: 'DM Sans', 'Segoe UI', sans-serif; + color: #e8eaf0; + background: #101116; + font-synthesis: none; + text-rendering: optimizeLegibility; + --bg: #101116; + --surface: #17191f; + --surface-raised: #1d2027; + --surface-hover: #232630; + --border: #2a2d37; + --muted: #8d929f; + --subtle: #626775; + --text: #e8eaf0; + --accent: #9c8cff; + --accent-strong: #846df3; + --blue: #70a7ff; + --green: #63d4a0; + --amber: #f0bc65; + --red: #f07d82; + --radius: 12px; +} + +* { box-sizing: border-box; } +html, body, #root { min-width: 360px; min-height: 100%; margin: 0; } +body { min-height: 100vh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; } +button, input, select, textarea { font: inherit; } +button { color: inherit; cursor: pointer; } +button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } + +.app-shell { min-height: 100vh; display: flex; background: radial-gradient(ellipse at 60% -30%, rgba(86, 74, 151, .12), transparent 55%), var(--bg); } +.sidebar { width: 252px; min-width: 252px; min-height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 14px; background: #14151b; border-right: 1px solid #252730; } +.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 24px; } +.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(140deg, #a18eff, #6952d8); font-weight: 700; font-size: 19px; box-shadow: 0 5px 16px #8069e633; } +.sidebar-brand strong, .sidebar-brand span { display: block; } +.sidebar-brand strong { font-size: 14px; letter-spacing: -.2px; } +.sidebar-brand span { margin-top: 3px; color: #7c8090; font: 9px 'JetBrains Mono', monospace; letter-spacing: 1.15px; } +.workspace-switcher { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px; color: var(--text); text-align: left; background: transparent; border: 1px solid var(--border); border-radius: 9px; } +.workspace-switcher:hover { background: #1b1d24; } +.workspace-avatar, .account-avatar { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; color: #c6baff; background: #302a4b; font-size: 12px; font-weight: 700; } +.workspace-label { min-width: 0; flex: 1; } +.workspace-label strong, .workspace-label small { display: block; } +.workspace-label strong { font-size: 12px; font-weight: 600; } +.workspace-label small { margin-top: 2px; color: var(--muted); font-size: 10px; } +.workspace-chevron { color: var(--muted); font-size: 16px; } +.sidebar-new-task { height: 38px; margin: 18px 0 26px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 0; border-radius: 8px; color: #17151f; background: #b6a8ff; font-size: 12px; font-weight: 700; box-shadow: 0 4px 16px #9c8cff20; } +.sidebar-new-task:hover, .btn-primary:hover { background: #c5baff; transform: translateY(-1px); } +.sidebar-new-task > span { font-size: 17px; line-height: 1; } +.sidebar-new-task kbd { margin-left: auto; padding: 3px 5px; border: 1px solid #715cc3; border-radius: 4px; color: #554393; background: #cabeff; font: 9px 'JetBrains Mono', monospace; } +.sidebar-section-label { padding: 0 10px 8px; color: #727684; font: 9px 'JetBrains Mono', monospace; letter-spacing: 1px; } +.sidebar-nav { display: grid; gap: 3px; } +.nav-item { min-height: 36px; display: flex; align-items: center; gap: 11px; padding: 0 10px; border: 0; border-radius: 7px; color: #a4a8b4; background: transparent; text-align: left; font-size: 12px; } +.nav-item:hover { color: var(--text); background: #1c1e26; } +.nav-item.active { color: #ded7ff; background: #29243b; } +.nav-icon { width: 16px; color: #9893b8; font-size: 15px; text-align: center; } +.nav-item.active .nav-icon { color: var(--accent); } +.nav-count { margin-left: auto; color: #858999; font: 10px 'JetBrains Mono', monospace; } +.sidebar-bottom { margin-top: auto; } +.daemon-card { display: flex; align-items: center; gap: 10px; padding: 11px 9px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 9px; background: #191b22; } +.daemon-indicator, .live-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px #f0bc6517; } +.daemon-ready .daemon-indicator, .live-dot { background: var(--green); box-shadow: 0 0 0 3px #63d4a018; } +.daemon-card strong, .daemon-card small { display: block; } +.daemon-card strong { font-size: 10px; font-weight: 600; } +.daemon-card small { margin-top: 3px; color: var(--muted); font-size: 9px; } +.sidebar-account { display: flex; align-items: center; gap: 9px; padding: 11px 2px 2px; border-top: 1px solid #292b34; } +.account-avatar { color: #b2caff; background: #263248; } +.account-copy { min-width: 0; flex: 1; } +.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.account-copy strong { font-size: 10px; } +.account-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; } +.account-signin, .account-action { border: 0; color: #bbb0fa; background: transparent; font-size: 10px; } +.account-action { color: var(--muted); font-size: 18px; } + +.app-main { min-width: 0; flex: 1; padding-bottom: 48px; } +.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 36px; border-bottom: 1px solid #252730; background: rgba(17, 18, 24, .76); } +.breadcrumbs { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; } +.breadcrumbs span { color: #575b69; } +.breadcrumbs strong { color: #d3d5de; font-weight: 500; } +.topbar-right { display: flex; align-items: center; gap: 14px; } +.local-only-pill { display: inline-flex; align-items: center; gap: 7px; color: #a3a6b0; font-size: 10px; } +.local-only-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); } +.local-only-pill .dot.status-disconnected { background: var(--amber); } +.topbar .auth-profile { display: flex; align-items: center; gap: 10px; } +.auth-info { display: flex; flex-direction: column; align-items: flex-end; color: var(--muted); font-size: 10px; } +.user-id { color: var(--text); } +.device-id { margin-top: 2px; } +.content-container { max-width: 1480px; margin: 0 auto; padding: 30px 38px; } +.dashboard-page, .detail-page { max-width: 1320px; margin: 0 auto; padding: 35px 40px; } +.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 26px; } +.eyebrow { margin-bottom: 9px; color: #9990ca; font: 9px 'JetBrains Mono', monospace; letter-spacing: 1.3px; } +.page-heading h1, .detail-heading h1 { margin: 0; color: #f0f0f5; font-size: clamp(24px, 2.8vw, 32px); font-weight: 600; letter-spacing: -1.1px; } +.page-heading p { margin: 8px 0 0; color: var(--muted); font-size: 12px; } +.btn-primary, .btn-secondary, .btn-danger, .btn-success { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 7px; font-size: 11px; font-weight: 600; transition: .16s ease; } +.btn-primary { border: 1px solid #b6a8ff; color: #1b1924; background: #b6a8ff; } +.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; } +.btn-secondary { border: 1px solid #343743; color: #d4d5dd; background: #20222a; } +.btn-secondary:hover { background: #292c36; } +.btn-danger { border: 1px solid #743f46; color: #ffb1b5; background: #522d33; } +.btn-success { border: 1px solid #347457; color: #b5f1d2; background: #234a38; } +.btn-link { padding: 0; border: 0; color: #b6a8ff; background: transparent; font-size: 11px; } +.new-task-button { min-width: 118px; min-height: 38px; } +.new-task-button span { font-size: 16px; } + +.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 30px; } +.metric-card { min-height: 128px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; align-items: center; padding: 16px 17px; border: 1px solid #292c35; border-radius: 10px; background: linear-gradient(145deg, #1a1c23, #16181e); } +.metric-icon { width: 27px; height: 27px; display: grid; place-items: center; grid-column: 2; grid-row: 1 / span 2; border-radius: 8px; font-size: 12px; } +.metric-violet { color: #b5a7ff; background: #393253; } +.metric-blue { color: #8ebcff; background: #25364e; } +.metric-amber { color: #ffd18b; background: #493a26; } +.metric-green { color: #88e4b7; background: #244333; } +.metric-label { color: #9a9da8; font-size: 10px; } +.metric-value { margin-top: 5px; font: 600 22px 'JetBrains Mono', monospace; letter-spacing: -1px; } +.metric-detail { grid-column: 1 / -1; margin-top: 8px; color: #747987; font-size: 9px; } +.tasks-section { border: 1px solid #292c35; border-radius: 11px; overflow: hidden; background: #15171d; } +.tasks-toolbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 14px 19px; } +.tasks-toolbar h2, .panel-heading h2, .diff-toolbar h2 { margin: 0; color: #e7e8ee; font-size: 13px; font-weight: 600; } +.tasks-toolbar p, .panel-heading p, .diff-toolbar p { margin: 4px 0 0; color: #858a97; font-size: 10px; } +.refresh-hint { min-height: 28px; padding: 0 9px; gap: 8px; color: #9da2ae; font-size: 9px; } +.refresh-hint .live-dot { width: 6px; height: 6px; } +.task-tabs { display: flex; align-items: center; gap: 20px; padding: 0 19px; border-bottom: 1px solid #282b34; } +.task-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 39px; padding: 0 1px; border: 0; color: #898d99; background: transparent; font-size: 10px; } +.task-tab:hover { color: #d1d2da; } +.task-tab.selected { color: #d3caff; } +.task-tab.selected::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ''; } +.tab-count { min-width: 16px; padding: 2px 5px; border-radius: 5px; color: #f4cb82; background: #483923; font: 9px 'JetBrains Mono', monospace; text-align: center; } +.task-table-head, .task-row { display: grid; grid-template-columns: minmax(220px, 2.2fr) minmax(100px, .95fr) minmax(118px, 1fr) 65px 74px 15px; align-items: center; gap: 14px; } +.task-table-head { min-height: 35px; padding: 0 19px; color: #757987; background: #181a21; font: 9px 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .3px; } +.task-row { width: 100%; min-height: 68px; padding: 8px 19px; border: 0; border-bottom: 1px solid #252730; color: inherit; background: transparent; text-align: left; } +.task-row:last-child { border-bottom: 0; } +.task-row:hover { background: #1b1e26; } +.task-identity { min-width: 0; display: flex; align-items: center; gap: 11px; } +.task-symbol { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #343743; border-radius: 8px; color: #bcb3ed; background: #252432; font-size: 13px; } +.symbol-approved { color: var(--green); background: #1f352a; border-color: #31513e; } +.symbol-awaiting_approval { color: var(--amber); background: #3a3023; border-color: #54442b; } +.symbol-failed, .symbol-rejected { color: var(--red); background: #3b262b; border-color: #553238; } +.task-copy { min-width: 0; } +.task-copy strong, .task-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.task-copy strong { color: #dfe0e7; font-size: 11px; font-weight: 500; } +.task-copy small { margin-top: 6px; color: #858997; font-size: 9px; } +.repo-icon { margin-right: 5px; color: #9588d3; } +.status-badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 7px; border: 1px solid #363943; border-radius: 5px; color: #c5c7d0; background: #252730; font-size: 9px; font-weight: 600; text-transform: capitalize; white-space: nowrap; } +.badge-running { color: #a8c9ff; background: #233149; border-color: #304568; } +.badge-queued, .badge-stopped { color: #c6bddf; background: #2b2838; border-color: #39344b; } +.badge-awaiting_approval { color: #ffd48c; background: #3d3324; border-color: #57482c; } +.badge-approved { color: #8be0b5; background: #20372a; border-color: #31543d; } +.badge-rejected, .badge-failed { color: #ff9a9f; background: #3d272c; border-color: #5a343a; } +.agent-cell strong, .agent-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.agent-cell strong { color: #cdd0d9; font-size: 10px; font-weight: 500; } +.agent-cell small { margin-top: 4px; color: #828693; font-size: 9px; } +.cost-cell, .time-cell { color: #a2a5af; font: 10px 'JetBrains Mono', monospace; } +.row-chevron { color: #747886; font-size: 20px; text-align: right; } +.tasks-empty { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; } +.empty-illustration { position: relative; width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 15px; border: 1px solid #403a5c; border-radius: 17px; color: #b8aaff; background: radial-gradient(circle at 30% 25%, #49406b, #292439 72%); font-size: 24px; } +.empty-illustration i { position: absolute; right: -7px; bottom: -6px; width: 23px; height: 23px; display: grid; place-items: center; border: 3px solid #15171d; border-radius: 50%; color: #14141a; background: #b7aaff; font: normal 11px 'JetBrains Mono', monospace; } +.tasks-empty h3 { margin: 0; font-size: 14px; font-weight: 600; } +.tasks-empty p { max-width: 330px; margin: 7px 0 17px; color: #888d99; font-size: 10px; line-height: 1.7; } + +.runner-notice, .notice-banner { max-width: 1320px; margin: 18px auto 0; } +.runner-notice { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border: 1px solid #51432d; border-radius: 8px; color: #e9c88d; background: #292419; font-size: 10px; } +.runner-notice > span { font-size: 14px; } +.runner-notice p { margin: 0; line-height: 1.55; } +.runner-notice strong { color: #f2d5a0; } +.notice-banner { width: calc(100% - 76px); display: flex; justify-content: space-between; padding: 10px 13px; border: 1px solid #4d426d; border-radius: 8px; color: #d4caff; background: #272336; text-align: left; font-size: 10px; } +.notice-banner span { color: #9990bd; font-size: 15px; } + +/* Task creation */ +.form-container { max-width: 850px; margin: 35px auto; padding: 0 40px; } +.task-form-card { padding: 27px; border: 1px solid #2b2e38; border-radius: 12px; background: #17191f; } +.card-header { margin-bottom: 23px; } +.card-header h2 { margin: 0; color: #eeeef4; font-size: 20px; letter-spacing: -.4px; } +.card-header p { margin: 7px 0 0; color: #8d929f; font-size: 11px; line-height: 1.6; } +.form-group { min-width: 0; display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; } +.form-row { display: flex; gap: 14px; } +.flex-1 { flex: 1; } +.form-group label { color: #c9cbd4; font-size: 10px; font-weight: 600; } +input[type="text"], select, textarea { width: 100%; min-height: 37px; padding: 9px 11px; border: 1px solid #353843; border-radius: 7px; color: #e3e4eb; background: #111319; outline: none; font-size: 11px; } +textarea { min-height: 105px; resize: vertical; line-height: 1.55; } +input[type="text"]:focus, select:focus, textarea:focus { border-color: #8c79e9; box-shadow: 0 0 0 3px #8c79e91a; } +input::placeholder, textarea::placeholder { color: #626775; } +select option { background: #17191f; } +.muted-text { color: var(--muted); font-size: 10px; } +.checkbox-label { display: flex; align-items: center; gap: 8px; color: #c5c7cf; cursor: pointer; font-size: 10px; } +.checkbox-label input { accent-color: var(--accent-strong); } +.phase-models-panel { margin: 0 0 18px; padding: 15px; border: 1px solid #323540; border-radius: 8px; background: #1c1e25; } +.phase-models-panel h4 { margin: 0 0 12px; color: #c9c6d9; font-size: 10px; } +.phase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; } +.phase-item label { color: #8e92a0; font: 9px 'JetBrains Mono', monospace; } +.phase-item input { min-height: 32px; padding: 6px 8px; font-size: 10px; } +.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 17px; border-top: 1px solid #2b2d36; } + +/* Task detail and change review */ +.detail-page { padding-top: 24px; } +.back-link { display: flex; align-items: center; gap: 7px; margin: 0 0 21px; padding: 0; border: 0; color: #aaa1df; background: transparent; font-size: 10px; } +.back-link:hover { color: #ddd4ff; } +.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; } +.detail-title-block { min-width: 0; } +.detail-heading h1 { max-width: 900px; font-size: 23px; line-height: 1.3; } +.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; color: #9296a2; font-size: 10px; } +.meta-divider { color: #555966; } +.detail-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 22px 0; border: 1px solid #292c35; border-radius: 9px; background: #17191f; } +.detail-stats > div { min-width: 0; padding: 12px 15px; border-right: 1px solid #292c35; } +.detail-stats > div:last-child { border-right: 0; } +.detail-stats span, .detail-stats strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.detail-stats span { color: #797d8a; font: 8px 'JetBrains Mono', monospace; letter-spacing: .5px; } +.detail-stats strong { margin-top: 6px; color: #d4d5dd; font-size: 10px; font-weight: 500; } +.detail-grid { display: grid; grid-template-columns: minmax(255px, .7fr) minmax(0, 1.7fr); gap: 14px; align-items: start; } +.progress-column, .diff-column { min-width: 0; border: 1px solid #2b2e38; border-radius: 10px; background: #17191f; } +.progress-column { padding: 16px; } +.diff-column { overflow: hidden; } +.panel-heading { display: flex; align-items: center; justify-content: space-between; } +.panel-heading p { font-size: 9px; } +.event-count { display: grid; min-width: 22px; height: 20px; place-items: center; padding: 0 5px; border-radius: 5px; color: #b5aaff; background: #302b45; font: 9px 'JetBrains Mono', monospace; } +.phase-list { display: grid; gap: 2px; margin: 14px 0 20px; padding-bottom: 17px; border-bottom: 1px solid #2a2d36; } +.phase-row { display: flex; align-items: center; gap: 9px; min-height: 28px; color: #797e8a; font-size: 10px; } +.phase-check { width: 16px; height: 16px; display: grid; place-items: center; border: 1px solid #383b46; border-radius: 50%; color: #8fe1b8; font-size: 9px; } +.phase-row small { margin-left: auto; color: #777b87; font-size: 8px; } +.phase-complete { color: #c8d8ce; } +.phase-complete .phase-check { border-color: #376348; background: #23382c; } +.phase-active { color: #c7bcff; } +.phase-active .phase-check { color: var(--accent); border-color: #6d5aa9; background: #302a48; } +.activity-heading { margin: 0 0 13px; } +.activity-list { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; } +.activity-list::before { position: absolute; top: 8px; bottom: 11px; left: 4px; width: 1px; background: #353743; content: ''; } +.activity-list li { position: relative; display: flex; gap: 10px; padding-bottom: 14px; } +.activity-list li:last-child { padding-bottom: 0; } +.activity-marker { z-index: 1; width: 9px; height: 9px; flex: 0 0 auto; margin-top: 3px; border: 2px solid #9687e5; border-radius: 50%; background: #17191f; } +.activity-list strong { display: block; color: #c6c8d0; font-size: 9px; font-weight: 500; line-height: 1.45; } +.activity-list time { display: block; margin-top: 4px; color: #777b87; font: 8px 'JetBrains Mono', monospace; } +.activity-list p { margin: 4px 0 0; color: #969aa6; font-size: 9px; } +.diff-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 15px 17px; border-bottom: 1px solid #2a2d36; } +.diff-toolbar p { display: flex; align-items: center; gap: 7px; } +.diff-legend { display: flex; gap: 13px; color: #9296a2; font-size: 8px; } +.diff-legend span { display: flex; align-items: center; gap: 5px; } +.diff-legend i { width: 6px; height: 6px; border-radius: 2px; } +.legend-add { background: var(--green); } +.legend-remove { background: var(--red); } +.stat-added { color: var(--green); } +.stat-removed { color: var(--red); } +.review-files { padding: 12px; } +.diff-file { margin: 0 0 10px; overflow: hidden; border: 1px solid #30333d; border-radius: 7px; background: #111319; } +.diff-file:last-child { margin-bottom: 0; } +.diff-file-header { min-height: 36px; display: flex; align-items: center; gap: 9px; padding: 0 10px; cursor: pointer; background: #1e2027; list-style: none; } +.diff-file-header::-webkit-details-marker { display: none; } +.file-type-icon { width: 20px; height: 20px; display: grid; place-items: center; border: 1px solid #373945; border-radius: 5px; color: #b6aaff; background: #2b2840; font: 7px 'JetBrains Mono', monospace; } +.diff-file-path { min-width: 0; flex: 1; overflow: hidden; color: #d1d2db; font: 9px 'JetBrains Mono', monospace; text-overflow: ellipsis; white-space: nowrap; } +.file-change-label { color: #9ba0ab; font-size: 8px; text-transform: capitalize; } +.file-change-label.added { color: var(--green); } +.diff-stats { display: flex; gap: 7px; font: 8px 'JetBrains Mono', monospace; } +.diff-pre { margin: 0; overflow-x: auto; color: #bdc0ca; font: 9px/1.65 'JetBrains Mono', Consolas, monospace; } +.diff-line { min-height: 17px; display: flex; white-space: pre; } +.line-number { width: 37px; flex: 0 0 auto; padding-right: 8px; color: #555a67; text-align: right; user-select: none; } +.line-text { padding-right: 15px; } +.line-add { color: #a5e8c1; background: #1b3024; } +.line-del { color: #f0a2a7; background: #382326; } +.line-hunk { color: #9ab9ed; background: #202b3d; } +.diff-empty { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 25px; text-align: center; } +.diff-empty-icon { width: 43px; height: 43px; display: grid; place-items: center; margin-bottom: 10px; border: 1px solid #39364e; border-radius: 12px; color: #b6a9ff; background: #272438; font-size: 18px; } +.diff-empty h3 { margin: 0; color: #d4d5dd; font-size: 11px; } +.diff-empty p { max-width: 300px; margin: 7px 0 0; color: #858a97; font-size: 9px; line-height: 1.6; } +.approval-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 12px 12px; padding: 13px; border: 1px solid #473b62; border-radius: 8px; background: #242033; } +.approval-bar strong { color: #e0d9ff; font-size: 10px; } +.approval-bar p { max-width: 360px; margin: 4px 0 0; color: #9c96b1; font-size: 8px; line-height: 1.45; } +.approval-buttons { display: flex; gap: 7px; } +.reject-button { color: #efa2a6; } +.detail-empty { max-width: 900px; margin: 40px auto; padding: 25px; } +.detail-empty h2 { font-size: 18px; } + +/* Auth modal retained for optional cloud account features */ +.modal-backdrop { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: #07080bd9; backdrop-filter: blur(7px); } +.modal-card { width: 100%; max-width: 460px; padding: 26px; border: 1px solid #343743; border-radius: 13px; background: #1a1c23; box-shadow: 0 24px 80px #0009; } +.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; } +.modal-header h2 { font-size: 18px; } +.modal-description { margin: 0 0 18px; color: var(--muted); font-size: 10px; line-height: 1.6; } +.modal-footer { margin-top: 18px; color: #9a9eaa; font-size: 10px; text-align: center; } +.modal-footer .btn-link { margin-left: 4px; } +.btn-icon { border: 0; color: #9b9eaa; background: transparent; font-size: 17px; } +.alert-error, .alert-warning, .alert-success { margin: 10px 0; padding: 9px 11px; border-radius: 6px; font-size: 9px; line-height: 1.5; } +.alert-error { color: #ffadb0; background: #48282d; } +.alert-warning { color: #f3cf92; background: #403522; } +.alert-success { color: #94e5b7; background: #203b2c; } + +@media (max-width: 1050px) { + .sidebar { width: 220px; min-width: 220px; } + .dashboard-page, .detail-page { padding-right: 24px; padding-left: 24px; } + .task-table-head, .task-row { grid-template-columns: minmax(180px, 2fr) minmax(95px, .9fr) minmax(100px, .9fr) 55px 15px; } + .task-table-head > :nth-child(5), .task-row > :nth-child(5) { display: none; } + .detail-grid { grid-template-columns: minmax(220px, .75fr) minmax(0, 1.5fr); } +} +@media (max-width: 760px) { + .sidebar { width: 62px; min-width: 62px; padding: 16px 7px; } + .sidebar-brand { justify-content: center; padding: 0 0 20px; } + .sidebar-brand > div:last-child, .workspace-label, .workspace-chevron, .sidebar-new-task:not(span), .sidebar-section-label, .nav-item > span:not(.nav-icon), .daemon-card > div, .sidebar-account > div:not(.account-avatar), .account-signin, .account-action { display: none; } + .workspace-switcher { justify-content: center; padding: 6px; } + .sidebar-new-task { width: 38px; justify-content: center; padding: 0; overflow: hidden; font-size: 0; } + .sidebar-new-task > span { font-size: 18px; } + .sidebar-new-task kbd { display: none; } + .nav-item { justify-content: center; padding: 0; } + .nav-icon { font-size: 17px; } + .daemon-card { justify-content: center; padding: 10px 0; } + .sidebar-account { justify-content: center; } + .app-main { min-width: 0; } + .topbar { height: 52px; padding: 0 15px; } + .dashboard-page, .detail-page { padding: 24px 15px; } + .page-heading { align-items: flex-start; } + .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .metric-card { min-height: 112px; } + .task-table-head, .task-row { grid-template-columns: minmax(150px, 1fr) minmax(90px, auto) 15px; gap: 8px; padding-right: 10px; padding-left: 10px; } + .task-table-head > :nth-child(3), .task-row > :nth-child(3), .task-table-head > :nth-child(4), .task-row > :nth-child(4), .task-table-head > :nth-child(5), .task-row > :nth-child(5) { display: none; } + .task-tabs { gap: 14px; padding: 0 11px; overflow-x: auto; } + .tasks-toolbar { padding-right: 12px; padding-left: 12px; } + .detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .detail-stats > div:nth-child(2) { border-right: 0; } + .detail-stats > div:nth-child(-n+2) { border-bottom: 1px solid #292c35; } + .detail-grid { grid-template-columns: 1fr; } + .progress-column { order: 2; } + .diff-column { order: 1; } + .approval-bar { align-items: flex-start; flex-direction: column; } + .form-container { padding: 20px 14px; } + .task-form-card { padding: 18px; } + .form-row { flex-direction: column; gap: 0; } +} +@media (max-width: 480px) { + .page-heading { flex-direction: column; align-items: stretch; } + .new-task-button { align-self: flex-start; } + .task-table-head, .task-row { grid-template-columns: minmax(120px, 1fr) 80px 10px; } + .status-badge { padding: 4px 5px; font-size: 8px; } + .local-only-pill { display: none; } + .detail-heading { flex-direction: column; } + .detail-heading h1 { font-size: 19px; } + .diff-legend { display: none; } +} + +/* Projects, agent configuration, and cloud execution roadmap */ +.workspace-page { max-width: 1320px; margin: 0 auto; padding: 35px 40px; } +.workspace-page .page-heading { align-items: flex-start; } +.secondary-section { margin-top: 24px; } +.project-grid, .agent-grid, .cloud-feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 12px; margin-top: 20px; } +.project-card, .agent-card, .cloud-feature-grid article { min-width: 0; padding: 17px; border: 1px solid #2b2e38; border-radius: 10px; background: linear-gradient(145deg, #1a1c23, #16181e); } +.project-card-top, .agent-card-head { display: flex; align-items: center; justify-content: space-between; } +.project-avatar, .agent-logo { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid #4a4269; border-radius: 10px; color: #c5baff; background: #302b45; font-size: 13px; font-weight: 700; } +.project-runs { color: #858a97; font: 9px 'JetBrains Mono', monospace; } +.project-card h2, .agent-card h2 { margin: 14px 0 5px; font-size: 13px; font-weight: 600; } +.project-path { overflow: hidden; color: #858a97; font: 9px 'JetBrains Mono', monospace; text-overflow: ellipsis; white-space: nowrap; } +.project-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 13px; border-top: 1px solid #2b2e38; } +.project-card-footer > span { display: flex; align-items: center; gap: 6px; color: #969aa6; font-size: 9px; } +.local-path-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); } +.project-card-footer .btn-secondary { min-height: 28px; padding: 0 8px; font-size: 9px; } +.project-empty { border: 1px dashed #353844; border-radius: 10px; } +.agent-card { min-height: 175px; } +.agent-card h2 { margin-top: 16px; } +.agent-card > p { margin: 5px 0 18px; color: #9498a4; font-size: 10px; } +.agent-card-foot { display: flex; justify-content: space-between; gap: 8px; padding-top: 11px; border-top: 1px solid #2b2e38; color: #858a97; font-size: 8px; } +.agent-claude-code { color: #f0bf9a; border-color: #675044; background: #3a2c28; } +.agent-codex { color: #90e2ba; border-color: #3b654f; background: #243a2f; } +.agent-codehands { color: #bcb0ff; } +.provider-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid #373a44; border-radius: 5px; color: #a4a8b3; background: #252730; font-size: 8px; } +.provider-badge i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; } +.provider-ready { color: #93e2b9; border-color: #35553f; background: #203328; } +.provider-missing { color: #d7bd8b; border-color: #54482f; background: #30291f; } +.provider-warning { color: #edac83; border-color: #634130; background: #38281f; } +.provider-unknown { color: #a0a4af; } +.provider-reason { margin-top: 10px; color: #dcaaa4; font-size: 9px; line-height: 1.5; } +.phase-routing-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 14px; padding: 18px; border: 1px solid #2b2e38; border-radius: 10px; background: #17191f; } +.phase-routing-card h2 { margin: 0; font-size: 13px; } +.phase-routing-card p { max-width: 530px; margin: 6px 0 0; color: #898e9a; font-size: 9px; line-height: 1.55; } +.phase-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; } +.phase-chips span { padding: 6px 8px; border: 1px solid #39364e; border-radius: 5px; color: #beb5ed; background: #242135; font-size: 8px; } +.coming-soon-badge { padding: 5px 8px; border: 1px solid #55462d; border-radius: 5px; color: #e6c183; background: #2f291f; font: 8px 'JetBrains Mono', monospace; letter-spacing: .5px; } +.cloud-hero { position: relative; overflow: hidden; min-height: 280px; padding: 30px; border: 1px solid #39334e; border-radius: 12px; background: radial-gradient(ellipse at 80% 10%, #3b315a88, transparent 40%), linear-gradient(130deg, #1b1b25, #191923); } +.cloud-orbit { position: absolute; top: 26px; right: 38px; width: 116px; height: 116px; display: grid; place-items: center; border: 1px solid #564c79; border-radius: 50%; color: #d1c7ff; background: #2f2941a3; font-size: 35px; box-shadow: 0 0 0 16px #39314b33, 0 0 0 33px #39314b20; } +.cloud-orbit i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #b9aaff; box-shadow: 0 0 15px #ad9aff; } +.cloud-orbit i:nth-child(2) { top: 12px; left: 23px; } +.cloud-orbit i:nth-child(3) { right: 1px; bottom: 30px; background: #7eb8ff; } +.cloud-orbit i:nth-child(4) { bottom: 6px; left: 35px; background: #76d9ad; } +.cloud-hero .eyebrow { margin-top: 10px; } +.cloud-hero h2 { max-width: 630px; margin: 0; color: #f0eef9; font-size: 21px; letter-spacing: -.5px; } +.cloud-hero > p { max-width: 650px; margin: 11px 0 25px; color: #a1a2af; font-size: 10px; line-height: 1.7; } +.cloud-status-row { max-width: 480px; display: flex; align-items: center; justify-content: space-between; padding-top: 13px; border-top: 1px solid #393642; color: #bfc0ca; font-size: 9px; } +.cloud-status-row > span { display: flex; align-items: center; gap: 7px; } +.cloud-status-row strong { color: #d9c48e; font-weight: 500; } +.cloud-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #e0b760; } +.cloud-feature-grid article > span { color: #a39ad1; font: 9px 'JetBrains Mono', monospace; } +.cloud-feature-grid h3 { margin: 14px 0 6px; font-size: 12px; } +.cloud-feature-grid p { min-height: 48px; margin: 0; color: #9296a2; font-size: 9px; line-height: 1.6; } +.cloud-feature-grid b { display: inline-block; margin-top: 15px; color: #b9adf5; font-size: 8px; font-weight: 500; } +.run-target-group { margin-top: 21px; } +.run-target-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; } +.run-target { min-height: 67px; display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #353843; border-radius: 8px; background: #15171e; } +.run-target.selected { border-color: #7060aa; background: #211e30; } +.run-target.unavailable { opacity: .63; } +.target-icon { width: 28px; height: 28px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 7px; color: #c9beff; background: #332d4b; } +.run-target > span:nth-child(2) { min-width: 0; flex: 1; } +.run-target strong, .run-target small { display: block; } +.run-target strong { color: #d9d9e1; font-size: 9px; } +.run-target small { margin-top: 4px; color: #8d929f; font-size: 8px; } +.run-target > i { color: #a99be7; font-size: 8px; font-style: normal; } +.run-target.unavailable > i { color: #d7bd8b; } +@media (max-width: 1050px) { + .workspace-page { padding-right: 24px; padding-left: 24px; } +} +@media (max-width: 760px) { + .workspace-page { padding: 24px 15px; } + .phase-routing-card { align-items: flex-start; flex-direction: column; } + .phase-chips { justify-content: flex-start; } + .cloud-orbit { top: 20px; right: 20px; width: 68px; height: 68px; font-size: 24px; } + .cloud-hero { padding: 20px; } + .cloud-hero h2 { max-width: 75%; font-size: 17px; } + .run-target-options { grid-template-columns: 1fr; } } diff --git a/src/App.tsx b/src/App.tsx index 3c0117d..ae168ff 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,26 +1,37 @@ import { useState, useEffect, useRef, useCallback } from "react"; -import type { Session, AgentKind, CommandKind, AuthResult } from "@codehands/contracts"; +import type { AgentKind, CommandKind, AuthResult } from "@codehands/contracts"; import { cloudApi } from "./api/cloud"; import { getDeviceToken, deleteDeviceToken } from "./services/keychain"; import { Topbar } from "./components/Topbar"; import { AuthModal } from "./components/AuthModal"; -import { SessionList } from "./components/SessionList"; +import { TaskDashboard } from "./components/TaskDashboard"; import { NewTaskForm } from "./components/NewTaskForm"; -import { SessionView, type SessionEvent } from "./components/SessionView"; +import { TaskDetail, type DesktopSession, type SessionEvent } from "./components/TaskDetail"; +import { AgentsPage, CloudPage, ProjectsPage, type DesktopProject, type ProviderStatus } from "./components/WorkspacePages"; import "./App.css"; -const DAEMON_WS_URL = "ws://localhost:8787"; +const DAEMON_WS_URL = "ws://127.0.0.1:8788"; +type SessionFilter = "all" | "running" | "review" | "completed"; type View = | { name: "list" } | { name: "new" } - | { name: "session"; id: string }; + | { name: "session"; id: string } + | { name: "projects" } + | { name: "agents" } + | { name: "cloud" }; export default function App() { - const [sessions, setSessions] = useState([]); + const [sessions, setSessions] = useState([]); + const [projects, setProjects] = useState([]); + const [providers, setProviders] = useState([]); const [events, setEvents] = useState>({}); const [connected, setConnected] = useState(false); const [view, setView] = useState({ name: "list" }); + const [filter, setFilter] = useState("all"); + const [daemonState, setDaemonState] = useState<"starting" | "running" | "unavailable">("starting"); + const [notice, setNotice] = useState(null); + const [initialRepo, setInitialRepo] = useState(""); // Auth & OS Keychain state (COD-291) const [auth, setAuth] = useState(null); @@ -36,12 +47,32 @@ export default function App() { try { const storedToken = await getDeviceToken(); if (storedToken) { - // Re-hydrate stored device authentication - setAuth({ - userId: "user-1", - device: { id: "device-1", name: "laptop-A", createdAt: new Date().toISOString() }, - deviceToken: storedToken, - }); + // Try to load full stored auth from localStorage (stored after real login) + const storedAuthRaw = localStorage.getItem("codehands_auth_meta"); + if (storedAuthRaw) { + try { + const meta = JSON.parse(storedAuthRaw) as AuthResult; + const restored: AuthResult = { ...meta, deviceToken: storedToken }; + setAuth(restored); + cloudApi.setToken(storedToken); + } catch { + // Fallback if meta is corrupted + setAuth({ + userId: "", + device: { id: "", name: "this-device", createdAt: new Date().toISOString() }, + deviceToken: storedToken, + }); + cloudApi.setToken(storedToken); + } + } else { + // No meta yet — minimal hydration so app knows you're logged in + setAuth({ + userId: "", + device: { id: "", name: "this-device", createdAt: new Date().toISOString() }, + deviceToken: storedToken, + }); + cloudApi.setToken(storedToken); + } } } catch (err) { console.error("Failed to read token from keychain:", err); @@ -62,7 +93,13 @@ export default function App() { let stopped = false; const connect = () => { - const ws = new WebSocket(DAEMON_WS_URL); + let ws: WebSocket; + try { + ws = new WebSocket(DAEMON_WS_URL); + } catch { + setConnected(false); + return; + } wsRef.current = ws; ws.onopen = () => setConnected(true); @@ -73,11 +110,14 @@ export default function App() { if (msg.type === "state") { setSessions(msg.sessions || []); + setProjects(msg.projects || []); + setProviders(msg.providers || []); setEvents(msg.events || {}); + setDaemonState(msg.daemon?.watcher === "running" ? "running" : "unavailable"); } if (msg.type === "session") { - const s: Session = msg.session; + const s: DesktopSession = msg.session; setSessions((prev) => { const rest = prev.filter((x) => x.id !== s.id); return [s, ...rest]; @@ -97,6 +137,16 @@ export default function App() { return { ...prev, [ev.sessionId]: [...list, ev] }; }); } + + if (msg.type === "accepted") { + setNotice("Task added to the local daemon queue."); + setView({ name: "list" }); + } + + if (msg.type === "error") { + setNotice(msg.message || "The local daemon could not process that request."); + pendingRequest.current = null; + } } catch (err) { console.error("Error parsing daemon message:", err); } @@ -117,6 +167,17 @@ export default function App() { }; }, []); + useEffect(() => { + const handleShortcut = (event: KeyboardEvent) => { + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "k") { + event.preventDefault(); + setView({ name: "new" }); + } + }; + window.addEventListener("keydown", handleShortcut); + return () => window.removeEventListener("keydown", handleShortcut); + }, []); + const sendCommand = useCallback((command: object) => { const ws = wsRef.current; if (ws && ws.readyState === WebSocket.OPEN) { @@ -163,6 +224,12 @@ export default function App() { // 5. Auth Handlers const handleAuthSuccess = (result: AuthResult) => { setAuth(result); + cloudApi.setToken(result.deviceToken); + // Persist auth meta (userId, device) separately — token is in keychain + localStorage.setItem( + "codehands_auth_meta", + JSON.stringify({ userId: result.userId, device: result.device, deviceToken: "" }) + ); setIsAuthModalOpen(false); setIsTokenExpired(false); }; @@ -174,6 +241,8 @@ export default function App() { // Proceed with local logout regardless of network } await deleteDeviceToken(); + localStorage.removeItem("codehands_auth_meta"); + cloudApi.setToken(null); setAuth(null); }; @@ -182,33 +251,109 @@ export default function App() { ); return ( -
- setIsAuthModalOpen(true)} - onLogout={handleLogout} - /> +
+ + +
+ + {notice && } + {connected && ( +
ⓘ

Local queue is connected. The cloned daemon currently has no agent runner wired in, so tasks can be queued and observed but are not executed yet.

+ )} -
{view.name === "list" && ( - setView({ name: "session", id })} onNew={() => setView({ name: "new" })} + filter={filter} + onFilterChange={setFilter} /> )} {view.name === "new" && ( setView({ name: "list" })} /> )} + {view.name === "projects" && ( + { + setInitialRepo(path); + setView({ name: "new" }); + }} + /> + )} + + {view.name === "agents" && } + + {view.name === "cloud" && } + {view.name === "session" && ( - s.id === view.id)} events={events[view.id] || []} onCommand={(cmd) => handleSessionCommand(view.id, cmd)} diff --git a/src/api/cloud.ts b/src/api/cloud.ts index d8cba4b..b6919c7 100644 --- a/src/api/cloud.ts +++ b/src/api/cloud.ts @@ -1,10 +1,17 @@ -// Client for the C3 Cloud API (codehands-backend) -import type { CloudAuth, AuthResult } from "@codehands/contracts"; +// Client for the C3 Cloud API (codehands-backend, Memoona's real server) +// Real server runs on port 3000. Override with VITE_CLOUD_URL env var. +import type { CloudAuth, AuthResult, CloudDevice } from "@codehands/contracts"; -const DEFAULT_CLOUD_URL = "http://localhost:4000"; +// Vite exposes env vars prefixed with VITE_ at build time. +// In dev: set VITE_CLOUD_URL=http://localhost:3000 in desktop/.env +// Falls back to mock server on 4000 if not set. +const DEFAULT_CLOUD_URL = + (typeof import.meta !== "undefined" && (import.meta as any).env?.VITE_CLOUD_URL) || + "http://localhost:3000"; export class CloudApiClient implements CloudAuth { private baseUrl: string; + private token: string | null = null; private onTokenExpired?: () => void; constructor(baseUrl = DEFAULT_CLOUD_URL, onTokenExpired?: () => void) { @@ -16,17 +23,23 @@ export class CloudApiClient implements CloudAuth { this.onTokenExpired = handler; } + /** Called by App.tsx after loading the stored token from keychain */ + setToken(token: string | null) { + this.token = token; + } + + // ── Auth ──────────────────────────────────────────────────────────────── + async signUp(input: { githubCode: string; deviceName: string }): Promise { const res = await fetch(`${this.baseUrl}/auth/signup`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(input), }); - if (!res.ok) { - throw new Error(`Sign up failed: ${res.statusText}`); + const body = await res.json().catch(() => ({})); + throw new Error((body as any).error ?? `Sign up failed: ${res.statusText}`); } - return (await res.json()) as AuthResult; } @@ -36,48 +49,90 @@ export class CloudApiClient implements CloudAuth { headers: { "Content-Type": "application/json" }, body: JSON.stringify(input), }); - if (!res.ok) { - throw new Error(`Log in failed: ${res.statusText}`); + const body = await res.json().catch(() => ({})); + throw new Error((body as any).error ?? `Log in failed: ${res.statusText}`); } - return (await res.json()) as AuthResult; } + // Real server (Memoona's auth.ts) requires Authorization header on logout async logOut(): Promise<{ ok: true }> { const res = await fetch(`${this.baseUrl}/auth/logout`, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { + "Content-Type": "application/json", + ...(this.token ? { Authorization: `Bearer ${this.token}` } : {}), + }, }); - - if (!res.ok) { + // Treat 401 as success locally — token already invalid, proceed with local logout + if (!res.ok && res.status !== 401) { throw new Error(`Log out failed: ${res.statusText}`); } + return { ok: true }; + } + + // ── Devices ───────────────────────────────────────────────────────────── + + async listDevices(): Promise<{ devices: CloudDevice[] }> { + return this.fetchWithAuth<{ devices: CloudDevice[] }>("/devices", this.token ?? ""); + } - return (await res.json()) as { ok: true }; + async revokeDevice(id: string): Promise<{ ok: true }> { + return this.fetchWithAuth<{ ok: true }>(`/devices/${id}/revoke`, this.token ?? "", { + method: "POST", + }); + } + + // ── Sync ──────────────────────────────────────────────────────────────── + + /** Push local changes to the cloud. Token must be set first. */ + async pushChanges(changes: object[]): Promise { + return this.fetchWithAuth("/sync/push", this.token ?? "", { + method: "POST", + body: JSON.stringify({ changes }), + }); + } + + /** Pull remote changes since cursor. Returns { changes, nextCursor, hasMore }. */ + async pullChanges(cursor: string | null): Promise { + const q = encodeURIComponent(cursor ?? "0"); + return this.fetchWithAuth(`/sync/pull?cursor=${q}`, this.token ?? ""); + } + + // ── Health ─────────────────────────────────────────────────────────────── + + async checkHealth(): Promise<{ ok: boolean; db_time?: string }> { + try { + const res = await fetch(`${this.baseUrl}/health`); + if (!res.ok) return { ok: false }; + return (await res.json()) as { ok: boolean; db_time?: string }; + } catch { + return { ok: false }; + } } - // Wrapper for authenticated cloud calls that intercepts expired tokens (COD-291) + // ── Internal helper ────────────────────────────────────────────────────── + + /** Generic authenticated fetch — intercepts 401 and fires onTokenExpired */ async fetchWithAuth(path: string, token: string, options: RequestInit = {}): Promise { const res = await fetch(`${this.baseUrl}${path}`, { ...options, headers: { - ...options.headers, + "Content-Type": "application/json", + ...(options.headers as object | undefined), Authorization: `Bearer ${token}`, }, }); if (res.status === 401) { - if (this.onTokenExpired) { - this.onTokenExpired(); - } - throw new Error("Token expired"); + if (this.onTokenExpired) this.onTokenExpired(); + throw new Error("Token expired or revoked"); } - if (!res.ok) { - throw new Error(`Cloud request failed: ${res.statusText}`); + const body = await res.json().catch(() => ({})); + throw new Error((body as any).error ?? `Cloud request failed: ${res.statusText}`); } - return (await res.json()) as T; } } diff --git a/src/components/AuthModal.tsx b/src/components/AuthModal.tsx index 6ade0ec..97121f5 100644 --- a/src/components/AuthModal.tsx +++ b/src/components/AuthModal.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import type { AuthResult } from "@codehands/contracts"; import { cloudApi } from "../api/cloud"; import { saveDeviceToken } from "../services/keychain"; @@ -16,6 +16,13 @@ export function AuthModal({ isOpen, isExpiredPrompt, onSuccess, onClose }: AuthM const [deviceName, setDeviceName] = useState("laptop-A"); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); + const [serverStatus, setServerStatus] = useState<"unknown" | "ok" | "offline">("unknown"); + + // Check server health when modal opens so user knows if real server is up + useEffect(() => { + if (!isOpen) return; + cloudApi.checkHealth().then((h) => setServerStatus(h.ok ? "ok" : "offline")); + }, [isOpen]); if (!isOpen) return null; @@ -34,7 +41,7 @@ export function AuthModal({ isOpen, isExpiredPrompt, onSuccess, onClose }: AuthM onSuccess(result); } catch (err: any) { - setError(err?.message || "Authentication failed. Check if C3 mock server is running."); + setError(err?.message || "Authentication failed. Check if the C3 server is running on port 3000."); } finally { setLoading(false); } @@ -52,6 +59,15 @@ export function AuthModal({ isOpen, isExpiredPrompt, onSuccess, onClose }: AuthM )}
+ {/* Server status banner */} + {serverStatus !== "unknown" && ( +
+ {serverStatus === "ok" + ? "✓ Connected to C3 server" + : "⚠ C3 server unreachable — start it with: cd codehands-backend && npm run dev"} +
+ )} + {isExpiredPrompt && (
Your session token expired. Please sign in again to continue where you left off. @@ -85,7 +101,10 @@ export function AuthModal({ isOpen, isExpiredPrompt, onSuccess, onClose }: AuthM placeholder="GitHub authorization code" required /> - Using mock OAuth code against local C3 mock. + + Real server: visit GitHub OAuth URL, copy the code= param from the redirect. + Mock server: any string works. +
{error &&
{error}
} diff --git a/src/components/NewTaskForm.tsx b/src/components/NewTaskForm.tsx index 23f140c..41eef54 100644 --- a/src/components/NewTaskForm.tsx +++ b/src/components/NewTaskForm.tsx @@ -3,6 +3,7 @@ import type { AgentKind } from "@codehands/contracts"; interface NewTaskFormProps { connected: boolean; + initialRepo?: string; onStart: (taskData: { repo: string; prompt: string; @@ -33,8 +34,26 @@ const DEFAULT_PHASE_MODELS = { review: "sonnet", }; -export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps) { - const [repo, setRepo] = useState("d:\\dev\\sample-repo"); +const PHASE_DEFAULTS: Record = { + "claude-code": DEFAULT_PHASE_MODELS, + codex: { + analyze: "gpt-5-mini", + plan: "gpt-5.5", + implement: "gpt-5.5", + test: "gpt-5-mini", + review: "gpt-5.5", + }, + codehands: { + analyze: "qwen-2.5-coder", + plan: "claude-3-5-sonnet", + implement: "qwen-2.5-coder", + test: "qwen-2.5-coder", + review: "claude-3-5-sonnet", + }, +}; + +export function NewTaskForm({ connected, initialRepo, onStart, onCancel }: NewTaskFormProps) { + const [repo, setRepo] = useState(initialRepo || "d:\\dev\\sample-repo"); const [prompt, setPrompt] = useState(""); const [agent, setAgent] = useState("claude-code"); const [model, setModel] = useState("sonnet"); @@ -48,6 +67,7 @@ export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps) if (available.length > 0) { setModel(available[0]); } + setPhaseModels(PHASE_DEFAULTS[newAgent]); }; const handleSubmit = (e: React.FormEvent) => { @@ -82,14 +102,26 @@ export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps) }; return ( -
+
+
-

Create New Task

+
LOCAL WORKSPACE / NEW TASK
+

Start a coding task

- Writes one task row to the local database. The daemon will pick it up and run it in an isolated worktree. + Describe the outcome you want. Code Hands will add it to the task queue in your local daemon database.

+
ⓘ

Runner integration is still in progress. The current daemon accepts and tracks queued tasks, but does not yet invoke Claude Code or Codex.

+ +
+ +
+
⌘This deviceLocal daemon · private workspaceSelected
+
☁Cloud workerRemote execution will be opt-inPlanned
+
+
+
@@ -104,7 +136,7 @@ export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps) />
- Tasks run in a private git worktree; your main checkout is never touched. + This path is stored locally and is not sent to the cloud.
@@ -169,8 +201,7 @@ export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps) (phase) => (
- setPhaseModels({ @@ -178,7 +209,11 @@ export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps) [phase]: e.target.value, }) } - /> + > + {(AVAILABLE_MODELS[agent] || []).map((availableModel) => ( + + ))} +
) )} @@ -201,6 +236,7 @@ export function NewTaskForm({ connected, onStart, onCancel }: NewTaskFormProps)
+ ); } diff --git a/src/components/SessionList.tsx b/src/components/SessionList.tsx deleted file mode 100644 index c4d6bb8..0000000 --- a/src/components/SessionList.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import type { Session } from "@codehands/contracts"; - -interface SessionListProps { - sessions: Session[]; - onOpen: (sessionId: string) => void; - onNew: () => void; -} - -export function SessionList({ sessions, onOpen, onNew }: SessionListProps) { - const getStatusClass = (status: string) => { - switch (status) { - case "running": - return "badge-running"; - case "awaiting_approval": - return "badge-warning"; - case "approved": - return "badge-success"; - case "rejected": - case "failed": - return "badge-danger"; - case "stopped": - return "badge-muted"; - default: - return "badge-info"; - } - }; - - return ( -
-
-
-

Work Sessions

-

- All coding tasks managed by the local daemon on this machine. -

-
- -
- - {sessions.length === 0 ? ( -
-

No tasks yet

-

- Start your first coding task to watch Claude Code or Codex implement it. -

- -
- ) : ( -
- {sessions.map((s) => ( -
onOpen(s.id)} - > -
- - {s.status.replace("_", " ")} - - - {new Date(s.createdAt).toLocaleTimeString([], { - hour: "2-digit", - minute: "2-digit", - })} - -
- -

- {(s as any).title || `Session ${s.id.slice(0, 8)}`} -

- -
- {(s as any).repo || s.projectId} - {s.agent} ({s.model}) -
-
- ))} -
- )} -
- ); -} - diff --git a/src/components/SessionView.tsx b/src/components/SessionView.tsx deleted file mode 100644 index 85a8287..0000000 --- a/src/components/SessionView.tsx +++ /dev/null @@ -1,197 +0,0 @@ -import type { Session, CommandKind } from "@codehands/contracts"; - -interface DiffFile { - path: string; - status: string; - patch: string; -} - -export interface SessionEvent { - id: number; - sessionId: string; - eventType: string; - payload: { summary?: string; files?: DiffFile[] }; - ts: string; -} - -interface SessionViewProps { - session: Session | undefined; - events: SessionEvent[]; - onCommand: (commandKind: CommandKind) => boolean; - onBack: () => void; -} - -const EVENT_LABELS: Record = { - "task.started": "Task initialized in worktree", - "step.plan": "Analyzing repository and generating plan", - "step.implement": "Writing and modifying code", - "approval.requested": "Changes ready for human review", - "step.test": "Executing test suite in isolated sandbox", - "task.finished": "Task completed successfully", - "task.rejected": "Changes rejected and worktree cleaned up", - "task.stopped": "Session stopped", -}; - -export function SessionView({ - session, - events, - onCommand, - onBack, -}: SessionViewProps) { - if (!session) { - return ( -
-

Session not found.

- -
- ); - } - - const approvalEvent = [...events] - .reverse() - .find((e) => e.eventType === "approval.requested"); - const files: DiffFile[] = approvalEvent?.payload?.files ?? []; - const awaitingApproval = session.status === "awaiting_approval"; - - return ( -
-
- -
-

{(session as any).title || `Session ${session.id.slice(0, 8)}`}

- - {session.status.replace("_", " ")} - -
-

- Repository: {(session as any).repo || session.projectId} · Agent:{" "} - {session.agent} ({session.model}) -

-
- -
-
-

Progress & Event Log

-
    - {events.map((e) => ( -
  1. -
    -
    - - {EVENT_LABELS[e.eventType] ?? e.eventType} - - - {new Date(e.ts).toLocaleTimeString()} - -
    -
  2. - ))} - {events.length === 0 && ( -
  3. Waiting for events from daemon...
  4. - )} -
- - {session.status === "running" && ( -
- -
- )} -
- -
-
-

Code Changes

- {approvalEvent?.payload?.summary && ( -

{approvalEvent.payload.summary}

- )} -
- - {files.length === 0 ? ( -
-

- {session.status === "running" - ? "Code edits will appear here once implementation completes." - : "No code changes recorded for this session."} -

-
- ) : ( -
- {files.map((file) => ( - - ))} -
- )} - - {awaitingApproval && ( -
-
- Review Decision: Accept or discard changes on the branch. -
-
- - -
-
- )} -
-
-
- ); -} - -function DiffBlock({ file }: { file: DiffFile }) { - const lines = file.patch.split("\n"); - const added = lines.filter((l) => l.startsWith("+") && !l.startsWith("+++")).length; - const removed = lines.filter((l) => l.startsWith("-") && !l.startsWith("---")).length; - - return ( -
- - {file.path} - - +{added} - -{removed} - - -
-
-          {lines.map((l, i) => {
-            const isAdd = l.startsWith("+") && !l.startsWith("+++");
-            const isDel = l.startsWith("-") && !l.startsWith("---");
-            const isHunk = l.startsWith("@@");
-            return (
-              
- {l || " "} -
- ); - })} -
-
-
- ); -} - diff --git a/src/components/TaskDashboard.tsx b/src/components/TaskDashboard.tsx new file mode 100644 index 0000000..0d21947 --- /dev/null +++ b/src/components/TaskDashboard.tsx @@ -0,0 +1,130 @@ +import type { DesktopSession } from "./TaskDetail"; + +type SessionFilter = "all" | "running" | "review" | "completed"; + +interface TaskDashboardProps { + sessions: DesktopSession[]; + filter: SessionFilter; + onFilterChange: (filter: SessionFilter) => void; + onOpen: (sessionId: string) => void; + onNew: () => void; +} + +const FILTERS: { id: SessionFilter; label: string }[] = [ + { id: "all", label: "All tasks" }, + { id: "running", label: "In progress" }, + { id: "review", label: "Needs review" }, + { id: "completed", label: "Completed" }, +]; + +function isCompleted(status: string) { + return status === "approved" || status === "rejected" || status === "failed"; +} + +function statusLabel(status: string) { + return status.replace(/_/g, " "); +} + +function timeAgo(value: string) { + const minutes = Math.max(0, Math.floor((Date.now() - new Date(value).getTime()) / 60_000)); + if (minutes < 1) return "Just now"; + if (minutes < 60) return `${minutes}m ago`; + const hours = Math.floor(minutes / 60); + if (hours < 24) return `${hours}h ago`; + return `${Math.floor(hours / 24)}d ago`; +} + +export function TaskDashboard({ sessions, filter, onFilterChange, onOpen, onNew }: TaskDashboardProps) { + const reviewCount = sessions.filter((session) => session.status === "awaiting_approval").length; + const activeCount = sessions.filter((session) => session.status === "running" || session.status === "queued").length; + const totalCost = sessions.reduce((sum, session) => sum + (session.costUsd || 0), 0); + const visibleSessions = sessions.filter((session) => { + if (filter === "running") return session.status === "running" || session.status === "queued"; + if (filter === "review") return session.status === "awaiting_approval"; + if (filter === "completed") return isCompleted(session.status); + return true; + }); + + return ( +
+
+
+
YOUR LOCAL WORKSPACE
+

Good work starts here.

+

Delegate a coding task, follow its progress, and review every change.

+
+ +
+ +
+ + + + +
+ +
+
+
+

Tasks

+

Recent runs from your local daemon

+
+ +
+ +
+ {FILTERS.map((item) => ( + + ))} +
+ + {visibleSessions.length === 0 ? ( +
+
✳⌘
+

{sessions.length === 0 ? "Your workspace is ready" : `No ${filter === "review" ? "tasks to review" : filter === "completed" ? "completed tasks" : "active tasks"}`}

+

{sessions.length === 0 ? "Create your first task and let Code Hands take it from prompt to review." : "Try another filter or start a new coding task."}

+ +
+ ) : ( +
+
TaskStatusAgent / modelCostUpdated
+ {visibleSessions.map((session) => ( + + ))} +
+ )} +
+
+ ); +} + +function Metric({ label, value, detail, icon, tone }: { label: string; value: string; detail: string; icon: string; tone: string }) { + return ( +
+
{icon}
+ {label} + {value} + {detail} +
+ ); +} diff --git a/src/components/TaskDetail.tsx b/src/components/TaskDetail.tsx new file mode 100644 index 0000000..c538398 --- /dev/null +++ b/src/components/TaskDetail.tsx @@ -0,0 +1,130 @@ +import type { CommandKind, Session } from "@codehands/contracts"; + +export interface DesktopSession extends Session { + taskId: string; + title?: string; + prompt?: string; + projectName?: string; + repo?: string; +} + +export interface SessionEvent { + id: number; + sessionId: string; + eventType: string; + payload: { summary?: string; files?: DiffFile[]; from?: string; to?: string; reason?: string }; + ts: string; +} + +interface DiffFile { + path: string; + status: string; + patch: string; +} + +interface TaskDetailProps { + session: DesktopSession | undefined; + events: SessionEvent[]; + onCommand: (kind: CommandKind) => boolean; + onBack: () => void; +} + +const EVENT_LABELS: Record = { + "task.claimed": "Task accepted by the local daemon", + "task.started": "Task execution started", + "step.plan": "Planning task", + "step.implement": "Implementing changes", + "step.test": "Running tests", + "approval.requested": "Changes are ready for review", + "task.finished": "Task finished", + "task.rejected": "Task rejected", + "task.stopped": "Task stopped", + "session.status_changed": "Session status updated", +}; + +function filesFromDiff(diff: string): DiffFile[] { + if (!diff.trim()) return []; + const sections = diff.split(/(?=^diff --git )/m).filter(Boolean); + return sections.map((patch, index) => { + const path = patch.match(/^\+\+\+ b\/(.+)$/m)?.[1] + || patch.match(/^diff --git a\/(.+?) b\/(.+)$/m)?.[2] + || `change-${index + 1}`; + return { path, status: patch.includes("new file mode") ? "added" : "modified", patch: patch.trimEnd() }; + }); +} + +function eventName(event: SessionEvent) { + if (event.eventType === "session.status_changed" && event.payload.to) { + return `Status changed to ${event.payload.to.replace(/_/g, " ")}`; + } + return EVENT_LABELS[event.eventType] || event.eventType.replace(/\./g, " "); +} + +export function TaskDetail({ session, events, onCommand, onBack }: TaskDetailProps) { + if (!session) { + return

Task not found

; + } + + const approvalEvent = [...events].reverse().find((event) => event.eventType === "approval.requested"); + const files = approvalEvent?.payload.files?.length ? approvalEvent.payload.files : filesFromDiff(session.diff || ""); + const totalAdded = files.reduce((total, file) => total + file.patch.split("\n").filter((line) => line.startsWith("+") && !line.startsWith("+++")).length, 0); + const totalRemoved = files.reduce((total, file) => total + file.patch.split("\n").filter((line) => line.startsWith("-") && !line.startsWith("---")).length, 0); + const phases = ["Analyze", "Plan", "Implement", "Test", "Review"]; + const phaseEvents = new Set(events.map((event) => event.eventType)); + + return ( +
+ +
+
+
TASK SESSION
+

{session.title || session.prompt || `Task ${session.id.slice(0, 8)}`}

+
⌂{session.projectName || session.repo || session.projectId}·{session.agent}·{session.model}
+
+ {session.status.replace(/_/g, " ")} +
+ +
+
SESSION#{session.id.slice(0, 8)}
+
CREATED{new Date(session.createdAt).toLocaleString([], { dateStyle: "medium", timeStyle: "short" })}
+
MODEL COST${(session.costUsd || 0).toFixed(2)}
+
BRANCH{session.branch || "Not created"}
+
+ +
+ + +
+

Change review

{files.length} {files.length === 1 ? "file" : "files"} changed +{totalAdded} −{totalRemoved}

Added Removed
+ {files.length ?
{files.map((file) => )}
:
⌘

No diff attached yet

The daemon will attach the patch here when an agent runner is connected and reports changes.

} + {session.status === "awaiting_approval" &&
Review decision

These controls record your decision with the daemon. The current daemon build does not commit or delete worktrees.

} +
+
+
+ ); +} + +function DiffBlock({ file }: { file: DiffFile }) { + const lines = file.patch.split("\n"); + return
{file.path.split(".").pop()?.slice(0, 2).toUpperCase() || "<>"}{file.path}{file.status}+{lines.filter((line) => line.startsWith("+") && !line.startsWith("+++")).length}−{lines.filter((line) => line.startsWith("-") && !line.startsWith("---")).length}
{lines.map((line, index) => {const added = line.startsWith("+") && !line.startsWith("+++"); const removed = line.startsWith("-") && !line.startsWith("---"); const hunk = line.startsWith("@@"); return 
{String(index + 1).padStart(3, "0")}{line || " "}
; })}
; +} diff --git a/src/components/Topbar.tsx b/src/components/Topbar.tsx index ac04271..d39a48e 100644 --- a/src/components/Topbar.tsx +++ b/src/components/Topbar.tsx @@ -1,51 +1,14 @@ -import type { AuthResult } from "@codehands/contracts"; - interface TopbarProps { connected: boolean; - auth: AuthResult | null; - onOpenAuth: () => void; - onLogout: () => void; } export function Topbar({ connected, - auth, - onOpenAuth, - onLogout, }: TopbarProps) { return (
-
-

- Code Hands Desktop -

-
- - {connected ? "Daemon Connected" : "Daemon Disconnected"} -
-
- -
- {auth ? ( -
-
- {auth.userId} - {auth.device.name} -
- -
- ) : ( - - )} -
+
Workspace›{connected ? "Local daemon" : "Connecting"}
+
{connected ? "Runs on this device" : "Local daemon offline"}
); } diff --git a/src/components/WorkspacePages.tsx b/src/components/WorkspacePages.tsx new file mode 100644 index 0000000..cb3a4b3 --- /dev/null +++ b/src/components/WorkspacePages.tsx @@ -0,0 +1,59 @@ +export interface DesktopProject { + id: string; + name: string; + repoId: string; + path: string; + createdAt: string; + sessionCount: number; +} + +export interface ProviderStatus { + agent: string; + state: string; + reason?: string | null; + retryAt?: string | null; + checkedAt?: string; +} + +export function ProjectsPage({ projects, onCreateTask }: { projects: DesktopProject[]; onCreateTask: (path: string) => void }) { + return
+
YOUR LOCAL WORKSPACE

Projects

Repositories registered on this device. Paths stay local.

+ {!projects.length ?
⌂

No projects yet

Start a task with a local repository path. Code Hands will add that repository here.

:
{projects.map((project) =>
{project.name.slice(0, 1).toUpperCase()}
{project.sessionCount} {project.sessionCount === 1 ? "run" : "runs"}

{project.name}

{project.path}

Local repository
)}
} +
; +} + +const AGENTS = [ + { id: "claude-code", name: "Claude Code", description: "Anthropic's coding agent CLI", mark: "A", kind: "Claude" }, + { id: "codex", name: "Codex CLI", description: "OpenAI's coding agent CLI", mark: "O", kind: "OpenAI" }, + { id: "codehands", name: "Code Hands Engine", description: "Multi-phase local orchestrator", mark: "C", kind: "Native" }, +]; + +function providerLabel(status?: ProviderStatus) { + if (!status) return { label: "Not checked", className: "provider-unknown" }; + const map: Record = { + ok: { label: "Ready", className: "provider-ready" }, + not_installed: { label: "CLI not installed", className: "provider-missing" }, + not_logged_in: { label: "Sign-in required", className: "provider-missing" }, + rate_limited: { label: "Rate limited", className: "provider-warning" }, + usage_limited: { label: "Usage limit", className: "provider-warning" }, + outage: { label: "Provider outage", className: "provider-warning" }, + }; + return map[status.state] || { label: status.state.replace(/_/g, " "), className: "provider-unknown" }; +} + +export function AgentsPage({ providers }: { providers: ProviderStatus[] }) { + return
+
MODEL ROUTING

Agents & models

Choose the agent for a task, then assign models to each workflow phase.

+
ⓘ

Credentials stay on this device. Code Hands reads provider readiness from the local daemon and never uploads agent keys.

+
{AGENTS.map((agent) => {const status = providers.find((item) => item.agent === agent.id); const badge = providerLabel(status); return
{agent.mark}
{badge.label}

{agent.name}

{agent.description}

{agent.kind}{status?.checkedAt ? `Checked ${new Date(status.checkedAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}` : "Status from local daemon"}
{status?.reason &&
{status.reason}
}
; })}
+
WORKFLOW DEFAULTS

Model per phase

Configure a model independently for analysis, planning, implementation, tests, and review when creating a task.

AnalyzePlanImplementTestReview
+
; +} + +export function CloudPage() { + return
+
CODE HANDS CLOUD

Cloud workers

Move a workflow from your laptop to a managed worker when cloud execution is available.

PLANNED
+
☁
LOCAL-FIRST TODAY · CLOUD-READY BY DESIGN

Your agents. Your models. A workspace that can grow.

Today, Code Hands stores tasks and session state locally. Cloud sign-in is for account identity and sync—not remote code execution. Cloud workers will be a separate, opt-in execution target once secure isolation and dispatch are ready.

Cloud executionNot available yet
+
01

Local runs

Use your installed agent CLIs. Repository files and credentials remain on this device.

Current direction
02

Remote control

Sync session state and review work from another signed-in device, without sending repository contents.

Planned
03

Cloud workers

Run a workflow in an isolated cloud worker only after the user explicitly selects that target.

Future execution target
+
; +} From bf2e8d5e499bd411b3970f84a7b6bf66efacc225 Mon Sep 17 00:00:00 2001 From: Tania Ashraf Date: Mon, 2 Nov 2026 22:58:24 +0500 Subject: [PATCH 2/8] feat(desktop): redesign local-first task workspace Update desktop brand and window dimensions for the redesigned local-first workspace. --- index.html | 4 ++-- src-tauri/tauri.conf.json | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index ff93803..8b13daa 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,9 @@ - - Tauri + React + Typescript + + Code Hands — Local AI Workspace diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 6fcf4a1..6d7b651 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -12,9 +12,11 @@ "app": { "windows": [ { - "title": "desktop", - "width": 800, - "height": 600 + "title": "Code Hands", + "width": 1440, + "height": 900, + "minWidth": 1024, + "minHeight": 700 } ], "security": { From 8b9c4905bf811a0e6fca4be83c7ac24c1d47571d Mon Sep 17 00:00:00 2001 From: Tania Ashraf Date: Thu, 5 Nov 2026 20:28:14 +0500 Subject: [PATCH 3/8] feat: Refactor authentication flow and enhance error handling - Updated CloudApiClient to support email/password authentication instead of GitHub OAuth. - Improved error messages for sign-up and log-in failures to provide clearer feedback. - Added health check response handling in CloudApiClient to indicate server issues. - Refactored AuthModal to accommodate new authentication inputs and display server status. - Enhanced user experience by providing detailed error messages related to server connectivity. - Introduced a design system documentation structure, including brand, colors, typography, and accessibility guidelines. - Created design tokens for consistent styling across the application. - Updated NewTaskForm to include runner readiness checks and improved error handling. - Enhanced TaskDetail to display additional event result information. --- .github/agents/design-system.agent.md | 30 ++++ README.md | 6 +- design/README.md | 24 ++++ design/accessibility.md | 30 ++++ design/brand.md | 40 ++++++ design/colors.md | 49 +++++++ design/components.md | 39 ++++++ design/design-tokens.json | 37 +++++ design/layout-and-spacing.md | 37 +++++ design/typography.md | 29 ++++ local-daemon-bridge.mjs | 82 +++++++++-- src/App.css | 120 +++++++++++++++- src/App.tsx | 69 ++++++--- src/api/cloud.ts | 37 +++-- src/components/AuthModal.tsx | 107 ++++++++------ src/components/NewTaskForm.tsx | 192 ++++++++++---------------- src/components/TaskDetail.tsx | 4 +- 17 files changed, 722 insertions(+), 210 deletions(-) create mode 100644 .github/agents/design-system.agent.md create mode 100644 design/README.md create mode 100644 design/accessibility.md create mode 100644 design/brand.md create mode 100644 design/colors.md create mode 100644 design/components.md create mode 100644 design/design-tokens.json create mode 100644 design/layout-and-spacing.md create mode 100644 design/typography.md diff --git a/.github/agents/design-system.agent.md b/.github/agents/design-system.agent.md new file mode 100644 index 0000000..5b3854c --- /dev/null +++ b/.github/agents/design-system.agent.md @@ -0,0 +1,30 @@ +--- +name: "Code Hands Design System" +description: "Use when designing or implementing Code Hands desktop UI, styling React components, adjusting colors, typography, spacing, responsive behavior, accessibility, or updating the design documentation." +tools: [read, search, edit] +user-invocable: true +--- +You are the Code Hands design-system specialist. Help maintain a coherent, accessible visual system for this local-first desktop app. + +## Sources of truth +- Read the relevant component and `src/App.css` before proposing or editing visual behavior. +- Use the documents in `design/` as a summary of the current UI. If documentation conflicts with implementation, verify the implementation and update the documentation when appropriate. +- Treat `design/design-tokens.json` as a reference snapshot, not a runtime theme. +- Keep product copy accurate about local execution, cloud features, and planned capabilities. + +## Constraints +- Preserve the existing dark neutral and violet-accent visual direction unless explicitly asked to change it. +- Prefer existing CSS custom properties and established component patterns; do not invent brand tokens without updating the design docs and token snapshot. +- Pair status colors with readable labels or non-color cues, and retain visible keyboard focus. +- Consider responsive layouts, keyboard operation, and accessible names when changing interactions. +- Avoid broad redesigns when the request is limited to one component. +- Do not claim accessibility, contrast, or responsive behavior was tested unless it was actually checked. + +## Approach +1. Identify the affected component, stylesheet rules, and relevant design reference. +2. Make the smallest consistent change and preserve the app's local-first product language. +3. Update design references if a change establishes or alters a reusable visual rule. +4. Validate the changed files and, when feasible, run the relevant app build or tests. + +## Output +Summarize the UI or documentation changes and note any validation performed. Keep the summary concise. diff --git a/README.md b/README.md index a3a5cf4..d02c16d 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ The app shows the result by reading `sessions` and `events`. It never changes a | Area | Behaviour | | --- | --- | -| Sign up and log in | Against the cloud state API (C3). The token goes into the OS keychain, never a file. Logging out revokes only this machine's token | +| Sign up and log in | Name, email, and password against the cloud state API (C3). Passwords are stored as scrypt hashes; the device token goes into the OS keychain | | Signed-in state | On sign-in, the daemon pulls your sessions, memory and preferences, so a second machine looks like the first | | Projects | Add a repo by picking a folder. A project is identified by a hash of its origin URL, so the same repo on another machine is the same project | | New task | Prompt, agent (Claude Code or Codex), and a model per phase. Defaults come from your preferences | @@ -168,6 +168,6 @@ pnpm tauri dev Requires Node 22.5+, pnpm, Rust, and the Tauri prerequisites (including Visual Studio C++ build tools on Windows). Clone `codehands-backend` and `codehands-contracts` beside this repo under `D:\dev`, as in the team workspace. -In development, Tauri starts `local-daemon-bridge.mjs`. It applies migrations from `../codehands-backend/daemon/migrations`, opens the same `~/.codehands/state.db` database, and starts the daemon watcher when the daemon's dependencies are installed. The app writes only `projects`, `tasks`, and `commands`; the watcher owns sessions and events. Set `CODEHANDS_DAEMON_DIR` if the daemon clone is not at `../codehands-backend/daemon`, or `CODEHANDS_DB` to use a separate SQLite file. The bridge listens on `127.0.0.1:8787` by default. +In development, Tauri starts `local-daemon-bridge.mjs`. It applies migrations from `../codehands-backend/daemon/migrations`, opens the same `~/.codehands/state.db` database, and starts the daemon watcher when its dependencies are installed. The watcher imports the sibling runner and contracts source, executes supported Claude Code tasks in isolated Git worktrees, persists events and diffs, and handles stop/resume/approve/reject commands. Install the daemon and runner dependencies before launching the desktop app. The app writes only `projects`, `tasks`, and `commands`; the watcher owns sessions and events. Set `CODEHANDS_DAEMON_DIR` if the daemon clone is not at `../codehands-backend/daemon`, or `CODEHANDS_DB` to use a separate SQLite file. The bridge listens on `127.0.0.1:8788` by default. -The current daemon source is still a queue prototype: it claims tasks and records approve/reject commands, but it does not yet invoke Claude Code or Codex, create worktrees, commit changes, or stop/resume runs. The UI displays this limitation and does not present queue connectivity as agent execution. `fake-daemon.mjs` is no longer started by the desktop app. The local adapter uses port `8788` to avoid colliding with older fake-daemon instances on `8787`. +Local development uses the built-in contract-compatible fake runner by default, so tasks can be demonstrated without a Claude subscription. Set `CODEHANDS_RUNNER=real` before starting the desktop app only when Claude Code is installed and authenticated locally. The real runner currently supports Claude Code only; Codex and Code Hands options stay disabled until their runner implementations are available. `fake-daemon.mjs` is no longer started by the desktop app. diff --git a/design/README.md b/design/README.md new file mode 100644 index 0000000..3c1b936 --- /dev/null +++ b/design/README.md @@ -0,0 +1,24 @@ +# Code Hands design system + +This folder documents the visual language currently used by the Code Hands desktop app. The React UI is implemented in `src/App.css`; treat that stylesheet as the source of truth when documenting existing behavior. If a design document and the running UI disagree, update the docs or the UI deliberately rather than assuming the change is already implemented. + +## Documents + +- [Brand](brand.md) — product identity, voice, and visual principles. +- [Colors](colors.md) — current palette, semantic roles, and status colors. +- [Typography](typography.md) — font families, hierarchy, and usage. +- [Layout and spacing](layout-and-spacing.md) — responsive structure, spacing, and shape conventions. +- [Components](components.md) — shared UI patterns and interaction states. +- [Accessibility](accessibility.md) — keyboard, contrast, semantics, and motion guidance. +- [Design tokens](design-tokens.json) — a machine-readable snapshot of frequently reused values. + +## Product context + +Code Hands is a local-first desktop workspace for delegating coding tasks, tracking local sessions, and reviewing changes. Keep the interface clear about what happens locally and what involves cloud account features. Avoid implying that planned or unavailable capabilities are already active. + +## Working with the system + +1. Inspect the relevant component and `src/App.css` before changing UI. +2. Reuse existing CSS custom properties and established component patterns where practical. +3. Keep this documentation and `design-tokens.json` aligned with implemented values; the JSON file is a reference snapshot, not an imported runtime theme. +4. Check narrow layouts and keyboard focus whenever an interaction or layout changes. diff --git a/design/accessibility.md b/design/accessibility.md new file mode 100644 index 0000000..8119cb7 --- /dev/null +++ b/design/accessibility.md @@ -0,0 +1,30 @@ +# Accessibility + +This checklist supplements the existing UI patterns; verify actual contrast and behavior when changing the interface. + +## Keyboard and focus + +- Keep every interactive element keyboard reachable and in a logical order. +- Preserve the global `:focus-visible` outline from `src/App.css`; do not remove it without providing an equally visible replacement. +- Ensure focus remains visible on dark surfaces, buttons, inputs, tabs, and modal controls. +- Support keyboard operation for dialogs and provide a clear, reachable close action where dismissal is allowed. + +## Color and text + +- Never communicate task state, validation, or selection with color alone; include text, an icon, or another cue. +- Check text and control contrast against their actual backgrounds, especially small muted labels and badges. +- Do not reduce essential instructions to the smallest metadata size. +- Respect browser/system text scaling and avoid clipping important labels at narrow widths. + +## Semantics and assistive technology + +- Use native buttons, labels, inputs, headings, lists, and dialog semantics where appropriate. +- Give icon-only controls an accessible name, and ensure decorative icons are hidden from assistive technology. +- Maintain a meaningful heading hierarchy and announce important asynchronous state changes when appropriate. +- Associate field errors and descriptions with their controls. + +## Motion and responsive use + +- Avoid unnecessary animation; honor reduced-motion preferences when adding motion beyond brief state feedback. +- Ensure hover-only cues have keyboard and touch equivalents. +- Check layouts at narrow widths and high zoom so primary actions and review controls remain available. diff --git a/design/brand.md b/design/brand.md new file mode 100644 index 0000000..f3ba4dd --- /dev/null +++ b/design/brand.md @@ -0,0 +1,40 @@ +# Brand + +## Name + +Use **Code Hands** in product-facing copy. The repository and package use the technical name `codehands-desktop`; that is not the display brand. + +## Product promise + +Code Hands helps people delegate a coding task, follow the work on their own machine, inspect the resulting changes, and decide what happens next. The desktop app is local-first: repository paths, agent credentials, and task execution belong on the device. Cloud account features should be described narrowly and accurately. + +## Brand character + +- **Capable, not theatrical:** emphasize useful work and clear outcomes. +- **Calm and trustworthy:** make task state, local/remote boundaries, and review decisions legible. +- **Technical, but approachable:** use familiar developer language without unnecessary jargon. +- **User-controlled:** communicate that changes are reviewable and decisions remain with the person. + +## Visual identity + +The interface uses a dark neutral foundation, soft violet as the primary brand accent, and restrained blue, green, amber, and red to distinguish information and status. Rounded, bordered surfaces and compact monospaced metadata give the app a precise workspace feel. The sidebar brand mark is a white “C” on a violet gradient; do not treat that CSS treatment as a separate approved logo asset. + +## Voice and terminology + +- Prefer short, direct labels and plain explanations. +- Say **local**, **on this device**, and **cloud** explicitly when the distinction matters. +- Use status language that describes what is happening (for example, “Waiting for review”), not vague success claims. +- Avoid claiming that a task is executing, synced, secure, or available unless the current product state supports that claim. +- Keep destructive or consequential actions explicit, and name their effect. + +## Do + +- Keep task progress and review decisions easy to scan. +- Make unavailable and planned features visibly distinct from active features. +- Use violet for brand emphasis, not as the only signal for task status. + +## Avoid + +- Marketing claims that imply remote code execution or upload repository contents. +- Using semantic status colors decoratively or interchangeably. +- Adding new brand colors or typography without updating the design references. diff --git a/design/colors.md b/design/colors.md new file mode 100644 index 0000000..e474d37 --- /dev/null +++ b/design/colors.md @@ -0,0 +1,49 @@ +# Colors + +The values below reflect the current UI in `src/App.css`. Some component styles still use literal colors instead of CSS variables; the table documents their present visual roles, not a fully centralized implementation. + +## Core palette + +| Role | Value | Current usage | +| --- | --- | --- | +| App background (`--bg`) | `#101116` | Main canvas and page background | +| Surface (`--surface`) | `#17191f` | Cards, panels, and form surfaces | +| Raised surface (`--surface-raised`) | `#1d2027` | Elevated content (available token) | +| Hover surface (`--surface-hover`) | `#232630` | Interactive surface hover (available token) | +| Sidebar | `#14151b` | Navigation rail | +| Input background | `#111319` | Text fields and diff background | +| Border (`--border`) | `#2a2d37` | Shared border token; components also use close variants | +| Primary text (`--text`) | `#e8eaf0` | Main content text | +| Muted text (`--muted`) | `#8d929f` | Supporting copy | +| Subtle text (`--subtle`) | `#626775` | Placeholders and low-emphasis content | + +## Brand and actions + +| Role | Value | Usage | +| --- | --- | --- | +| Accent (`--accent`) | `#9c8cff` | Focus ring, active indicator, and accent details | +| Strong accent (`--accent-strong`) | `#846df3` | Checkbox accent | +| Primary action fill | `#b6a8ff` | Main buttons and selected emphasis | +| Brand mark gradient | `#a18eff` → `#6952d8` | Sidebar “C” mark | +| Informational blue (`--blue`) | `#70a7ff` | Running and informational states | + +Primary buttons currently pair a pale violet fill with dark foreground text. Preserve clear text contrast and keep focus styling visible against both surfaces and controls. + +## Semantic status palette + +| Meaning | Accent | Typical dark treatment | +| --- | --- | --- | +| Success / ready | `#63d4a0` | `#20372a`–`#244333` | +| Warning / awaiting action | `#f0bc65` | `#3a3023`–`#493a26` | +| Error / rejected / failed | `#f07d82` | `#3b262b`–`#3d272c` | +| Running / information | `#70a7ff` | `#233149`–`#25364e` | +| Neutral / queued | `#c6bddf` | `#2b2838` | + +Use semantic color consistently, and pair it with text, an icon, or another non-color cue. Exact status surface/border values vary by component; check `src/App.css` before introducing a new pattern. + +## Guidance + +- Use dark neutrals for large areas; reserve saturated colors for actions, focus, and status. +- Do not use the semantic status colors interchangeably. +- Avoid low-contrast muted text for essential instructions or state. +- When changing a repeated palette value, update the CSS and [design-tokens.json](design-tokens.json) together. diff --git a/design/components.md b/design/components.md new file mode 100644 index 0000000..2fd7b52 --- /dev/null +++ b/design/components.md @@ -0,0 +1,39 @@ +# Components and interaction patterns + +These patterns describe the current application in `src/App.css` and its React components. Reuse existing classes and component behavior where possible; this document is not a request to rebuild the CSS architecture. + +## Actions + +- **Primary:** pale violet fill, dark text, medium/semibold label. Use for the main action in a region. +- **Secondary:** dark filled surface with a neutral border. Use for alternate or reversible actions. +- **Danger:** red-tinted surface and label. Use only for consequential or destructive actions; make the effect explicit. +- **Success:** green-tinted treatment. Reserve for a successful or ready state. +- **Text/link:** transparent background with violet text; use for lightweight navigation or secondary inline actions. + +Buttons should have visible hover and keyboard-focus states. Disabled controls must look and behave disabled. + +## Cards and panels + +Use a dark surface, subtle neutral border, and approximately 8–12px corner radius. Keep related card content grouped, with a clear title, supporting text, and actions. Metric cards use a small colored icon tile; color should reinforce, not replace, the metric label. + +## Status and feedback + +Status badges use compact text, a tinted background, and a border. The current task statuses distinguish running (blue), awaiting approval (amber), approved (green), and rejected/failed (red); queued/stopped are neutral-violet. Always show a readable status label alongside color. + +Notices, empty states, provider status, and daemon connectivity should explain what happened or what the person can do. Do not describe a local queue connection as active agent execution. + +## Forms + +Labels sit above controls. Inputs use a dark inset surface, neutral border, and a violet focus treatment. Error, warning, and success messages use separate semantic treatments. Keep field help close to the relevant field and preserve clear submit/cancel actions. + +The new-task landing view uses a large natural-language prompt as the primary control, with repository, agent, model, and submit controls grouped in a compact toolbar. Keep per-phase model routing in a secondary disclosure. The composer must state clearly that the current local daemon queues and tracks tasks but does not execute them. + +The sidebar lists real task sessions by title and readable status; the selected session has a distinct surface and a semantic current-page state. Keep task filters, project/configuration navigation, daemon connectivity, and account controls available alongside that list. + +## Data and review + +Task lists prioritize task identity and status, then agent/model and secondary metrics. The change-review panel distinguishes added lines (green), removed lines (red), and hunk metadata (blue). Preserve file paths, line context, and explicit approve/reject actions in review flows. + +## Interaction states + +For interactive components, account for default, hover, focus-visible, active/selected, disabled, loading, and error states where relevant. Use semantic HTML and accessible names; do not rely on hover alone to reveal an action. diff --git a/design/design-tokens.json b/design/design-tokens.json new file mode 100644 index 0000000..4e48119 --- /dev/null +++ b/design/design-tokens.json @@ -0,0 +1,37 @@ +{ + "source": "src/App.css", + "note": "Reference snapshot only; not imported by the application.", + "colors": { + "background": "#101116", + "surface": "#17191f", + "surfaceRaised": "#1d2027", + "surfaceHover": "#232630", + "sidebar": "#14151b", + "input": "#111319", + "border": "#2a2d37", + "text": "#e8eaf0", + "muted": "#8d929f", + "subtle": "#626775", + "accent": "#9c8cff", + "accentStrong": "#846df3", + "primaryAction": "#b6a8ff", + "brandGradientStart": "#a18eff", + "brandGradientEnd": "#6952d8", + "blue": "#70a7ff", + "green": "#63d4a0", + "amber": "#f0bc65", + "red": "#f07d82" + }, + "typography": { + "ui": "DM Sans, Segoe UI, sans-serif", + "technical": "JetBrains Mono, Consolas, monospace" + }, + "shape": { + "baseRadius": "12px" + }, + "breakpoints": { + "compactTables": "1050px", + "mobileNavigation": "760px", + "smallPhone": "480px" + } +} diff --git a/design/layout-and-spacing.md b/design/layout-and-spacing.md new file mode 100644 index 0000000..33ccf1c --- /dev/null +++ b/design/layout-and-spacing.md @@ -0,0 +1,37 @@ +# Layout and spacing + +## App structure + +The desktop shell is a persistent left navigation sidebar next to a flexible main area. The sidebar contains workspace filters, selectable session rows, configuration navigation, and daemon/account information. The top bar provides page context, while page content is centered and width-limited. Below 760px the sidebar stacks above the main area and session rows scroll horizontally. + +## Current layout references + +These are present in `src/App.css`; they are reference points, not a mandate to force every component to the same dimensions. + +| Pattern | Current value | +| --- | --- | +| Sidebar width | 252px; 228px below 1050px; full-width stacked navigation below 760px | +| Top bar height | 60px; 52px below 760px | +| Main page max width | 1320px for dashboard/detail/workspace pages | +| Main page padding | 35px 40px; reduced at tablet/mobile breakpoints | +| Main content max width | 1480px | +| Card radius | Commonly 8–12px | +| Control radius | Commonly 5–9px | +| Base card border | 1px solid a dark neutral border | + +## Spacing approach + +The existing CSS uses compact spacing values, commonly around 4, 7–14, 17–20, and 24–40px, with CSS declarations often tuned per component. Reuse nearby spacing and preserve visual grouping rather than introducing an unrelated scale. Keep gaps consistent within repeated grids, forms, and toolbars. + +## Responsive behavior + +- At 1050px, reduce the sidebar and page gutters and simplify less-critical table columns. +- At 760px, stack the sidebar above the main area, make session rows horizontally scrollable, stack detail content, and collapse multi-column forms and grids. +- At 480px, stack page headings and hide secondary metadata where necessary. +- Preserve task identity, status, primary actions, and review affordances at all widths. +- Keep the new-task prompt visually primary; allow its repository/agent/model toolbar to wrap at narrow widths. +- Avoid horizontal overflow; allow dense data regions such as code diffs to scroll within their own container. + +## Surfaces and density + +Use subtle surface and border separation rather than heavy shadows. Group related information inside a panel and keep controls visually distinct from static content. Compact metadata may be dense, but primary task titles, warnings, and decision controls should remain easy to find. diff --git a/design/typography.md b/design/typography.md new file mode 100644 index 0000000..8162ada --- /dev/null +++ b/design/typography.md @@ -0,0 +1,29 @@ +# Typography + +## Font families + +- **UI:** `DM Sans`, with `Segoe UI`, then system sans-serif fallbacks. The root stack is declared in `src/App.css`; ensure the font is actually available/loaded before relying on it across platforms. +- **Technical metadata:** `JetBrains Mono`, with `Consolas` and monospace fallbacks. Used for IDs, counts, paths, timestamps, table labels, and code/diff content. +- **Fallback:** use the platform sans-serif stack for general interface text and monospace for code or tabular technical values. + +## Hierarchy + +The current interface is compact and information-dense. The approximate sizes below summarize existing patterns; match the nearest component style rather than adding a new global scale casually. + +| Role | Current range / example | +| --- | --- | +| Page title | 24–32px, weight 600, tight tracking | +| Section / card title | 12–20px, weight 600 | +| Body and form copy | 10–12px, regular | +| Labels, metadata, badges | 8–10px; monospace for technical metadata | +| Metrics | 22px, semibold monospace | +| Diff/code | 9px with approximately 1.65 line-height | + +## Usage + +- Use DM Sans for headings, body copy, navigation, controls, and prose. +- Use JetBrains Mono for values that benefit from alignment or a technical character; avoid setting whole paragraphs in monospace. +- Use weight and color before adding more font sizes to establish hierarchy. +- Keep line-height comfortable for explanatory copy and dense data readable at desktop and narrow widths. +- Use sentence case for labels and headings; uppercase is reserved for small eyebrow labels and table metadata. +- Avoid relying on font weight alone to communicate status or importance. diff --git a/local-daemon-bridge.mjs b/local-daemon-bridge.mjs index 21a9064..1f6dcdd 100644 --- a/local-daemon-bridge.mjs +++ b/local-daemon-bridge.mjs @@ -1,5 +1,5 @@ import { createHash, randomUUID } from "node:crypto"; -import { execFileSync, spawn } from "node:child_process"; +import { execFileSync, spawn, spawnSync } from "node:child_process"; import { existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs"; import { homedir } from "node:os"; import { basename, dirname, join, resolve } from "node:path"; @@ -13,8 +13,11 @@ const DAEMON_ROOT = process.env.CODEHANDS_DAEMON_DIR : resolve(APP_ROOT, "..", "codehands-backend", "daemon"); const DB_PATH = process.env.CODEHANDS_DB || join(homedir(), ".codehands", "state.db"); const PORT = Number(process.env.CODEHANDS_LOCAL_PORT || 8788); +const CLAUDE_PATH = process.env.CODEHANDS_CLAUDE_PATH || "claude"; +const RUNNER_MODE = process.env.CODEHANDS_RUNNER || "fake"; +const USE_FAKE_RUNNER = RUNNER_MODE !== "real"; const VALID_AGENTS = new Set(["claude-code", "codex", "codehands"]); -const VALID_COMMANDS = new Set(["approve", "reject"]); +const VALID_COMMANDS = new Set(["approve", "reject", "stop", "resume"]); if (!existsSync(join(DAEMON_ROOT, "migrations"))) { throw new Error(`Could not find daemon migrations at ${DAEMON_ROOT}. Set CODEHANDS_DAEMON_DIR to the daemon clone.`); @@ -79,12 +82,10 @@ function startWatcher() { console.warn("[desktop bridge] daemon dependencies are not installed; app can queue tasks but watcher will be offline."); return null; } - const windows = process.platform === "win32"; - return spawn(windows ? "cmd.exe" : "npm", windows - ? ["/d", "/s", "/c", "npm run watch"] - : ["run", "watch"], { + const tsxCli = join(DAEMON_ROOT, "node_modules", "tsx", "dist", "cli.mjs"); + return spawn(process.execPath, [tsxCli, "src/watcher.ts"], { cwd: DAEMON_ROOT, - env: process.env, + env: { ...process.env, CODEHANDS_FAKE: USE_FAKE_RUNNER ? "true" : "false" }, windowsHide: true, stdio: "ignore", }); @@ -134,10 +135,58 @@ function readState() { providers, sessions, events, - daemon: { watcher: watcherState, execution: "runner-not-integrated" }, + daemon: { + watcher: watcherState, + execution: "runner-integrated", + runner: getRunnerStatus(), + }, }; } +function getRunnerStatus() { + if (USE_FAKE_RUNNER) { + return { + available: true, + mode: "fake", + command: "built-in fake runner", + version: "demo", + reason: "Using the built-in demo runner. No Claude subscription is required.", + }; + } + try { + const version = execFileSync(CLAUDE_PATH, ["--version"], { + encoding: "utf8", + windowsHide: true, + stdio: ["ignore", "pipe", "pipe"], + }).trim(); + const auth = spawnSync(CLAUDE_PATH, ["auth", "status"], { + encoding: "utf8", + windowsHide: true, + stdio: ["ignore", "pipe", "pipe"], + }); + let authStatus = null; + try { authStatus = JSON.parse(auth.stdout || "{}"); } catch { /* older CLI may not support JSON auth status */ } + if (authStatus && authStatus.loggedIn === false) { + return { + available: false, + command: CLAUDE_PATH, + version, + reason: "Claude Code is installed but not signed in. Run `claude`, choose /login, then restart Code Hands.", + }; + } + return { available: true, mode: "real", command: CLAUDE_PATH, version }; + } catch (error) { + return { + available: false, + mode: "real", + command: CLAUDE_PATH, + reason: error?.code === "ENOENT" + ? "Claude Code is not installed or is not on the daemon PATH." + : "Claude Code could not be started. Check its installation and login.", + }; + } +} + function broadcastState() { try { lastState = readState(); @@ -204,10 +253,19 @@ function createCommand(sessionId, commandKind) { } const session = db.prepare("select id, project_id as projectId, status from sessions where id = ?").get(sessionId); if (!session) throw new Error("Session not found."); - const targetStatus = commandKind === "approve" ? "approved" : "rejected"; - const allowed = commandKind === "approve" || commandKind === "reject" - ? session.status === "awaiting_approval" - : false; + const targetStatus = { + approve: "approved", + reject: "rejected", + stop: "stopped", + resume: "running", + }[commandKind]; + const expectedStatus = { + approve: "awaiting_approval", + reject: "awaiting_approval", + stop: "running", + resume: "stopped", + }[commandKind]; + const allowed = session.status === expectedStatus; if (!allowed) throw new Error(`Cannot ${commandKind} a session while it is ${session.status}.`); db.prepare("insert into commands (id, session_id, project_id, kind, created_by) values (?, ?, ?, ?, ?)") .run(randomUUID(), session.id, session.projectId, commandKind, "desktop"); diff --git a/src/App.css b/src/App.css index ed58027..c3f9e81 100644 --- a/src/App.css +++ b/src/App.css @@ -69,6 +69,7 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus- .account-copy strong { font-size: 10px; } .account-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; } .account-signin, .account-action { border: 0; color: #bbb0fa; background: transparent; font-size: 10px; } +.account-action { padding: 4px 0 4px 6px; } .account-action { color: var(--muted); font-size: 18px; } .app-main { min-width: 0; flex: 1; padding-bottom: 48px; } @@ -173,9 +174,9 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus- .form-row { display: flex; gap: 14px; } .flex-1 { flex: 1; } .form-group label { color: #c9cbd4; font-size: 10px; font-weight: 600; } -input[type="text"], select, textarea { width: 100%; min-height: 37px; padding: 9px 11px; border: 1px solid #353843; border-radius: 7px; color: #e3e4eb; background: #111319; outline: none; font-size: 11px; } +input[type="text"], input[type="email"], input[type="password"], select, textarea { width: 100%; min-height: 37px; padding: 9px 11px; border: 1px solid #353843; border-radius: 7px; color: #e3e4eb; background: #111319; outline: none; font-size: 11px; } textarea { min-height: 105px; resize: vertical; line-height: 1.55; } -input[type="text"]:focus, select:focus, textarea:focus { border-color: #8c79e9; box-shadow: 0 0 0 3px #8c79e91a; } +input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, select:focus, textarea:focus { border-color: #8c79e9; box-shadow: 0 0 0 3px #8c79e91a; } input::placeholder, textarea::placeholder { color: #626775; } select option { background: #17191f; } .muted-text { color: var(--muted); font-size: 10px; } @@ -395,6 +396,121 @@ select option { background: #17191f; } .run-target small { margin-top: 4px; color: #8d929f; font-size: 8px; } .run-target > i { color: #a99be7; font-size: 8px; font-style: normal; } .run-target.unavailable > i { color: #d7bd8b; } + +/* Session navigation and natural-language task composer */ +.sidebar-new-task.active { box-shadow: inset 0 0 0 1px #e0d8ff, 0 4px 16px #9c8cff20; } +.sidebar { height: 100vh; } +.sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 17px; } +.sidebar-section-heading .sidebar-section-label { padding-bottom: 8px; } +.sessions-view-all { margin: 0 7px 8px 0; padding: 2px 0; border: 0; color: #aaa1df; background: transparent; font-size: 9px; } +.sessions-view-all:hover { color: #e0d8ff; } +.sidebar-session-section { min-height: 100px; display: flex; flex: 1 1 auto; flex-direction: column; } +.sidebar-session-list { min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-color: #3a3b48 transparent; scrollbar-width: thin; } +.sidebar-session { width: 100%; min-height: 48px; display: flex; align-items: flex-start; gap: 9px; padding: 8px 9px; border: 1px solid transparent; border-radius: 7px; color: #a9acb8; background: transparent; text-align: left; } +.sidebar-session:hover { color: #e3e1ec; background: #1b1d25; } +.sidebar-session.active { border-color: #443b63; color: #eeeaff; background: #252136; } +.session-status-mark { width: 7px; height: 7px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: #9c8cff; box-shadow: 0 0 0 3px #9c8cff18; } +.status-mark-running { background: var(--blue); box-shadow: 0 0 0 3px #70a7ff1c; } +.status-mark-awaiting_approval { background: var(--amber); box-shadow: 0 0 0 3px #f0bc651c; } +.status-mark-approved { background: var(--green); box-shadow: 0 0 0 3px #63d4a01c; } +.status-mark-failed, .status-mark-rejected { background: var(--red); box-shadow: 0 0 0 3px #f07d821c; } +.sidebar-session-copy { min-width: 0; flex: 1; } +.sidebar-session-copy strong, .sidebar-session-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.sidebar-session-copy strong { color: inherit; font-size: 10px; font-weight: 500; line-height: 1.4; } +.sidebar-session-copy small { margin-top: 4px; color: #858997; font-size: 9px; text-transform: capitalize; } +.sidebar-sessions-empty { margin: 1px 9px 5px; color: #858997; font-size: 9px; line-height: 1.5; } +.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); } + +.form-container.composer-page { width: 100%; max-width: 980px; margin: 38px auto 60px; padding: 0 42px; } +.composer-back-link { margin: 0 0 35px; padding: 4px 0; border: 0; color: #a9a0dc; background: transparent; font-size: 10px; } +.composer-back-link:hover { color: #ded7ff; } +.composer-heading { max-width: 740px; margin: 0 auto 22px; text-align: center; } +.composer-heading .eyebrow { margin-bottom: 12px; } +.composer-heading h1 { margin: 0; color: #f0eff7; font-size: clamp(26px, 3.2vw, 37px); font-weight: 600; letter-spacing: -1.35px; line-height: 1.2; } +.composer-heading p { max-width: 590px; margin: 12px auto 0; color: #999daa; font-size: 12px; line-height: 1.6; } +.composer-runner-notice { margin: 0 auto 13px; } +.task-composer { overflow: hidden; border: 1px solid #393644; border-radius: 14px; background: linear-gradient(150deg, #1b1b24, #17181f 72%); box-shadow: 0 18px 55px #07070d30; } +.composer-prompt { display: block; min-height: 190px; padding: 22px 23px 17px; border: 0; border-radius: 0; color: #eeedf5; background: transparent; font-size: 15px; line-height: 1.65; resize: vertical; } +.composer-prompt:focus { border: 0; box-shadow: none; } +.composer-prompt::placeholder { color: #777987; } +.composer-toolbar { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-top: 1px solid #2c2d37; } +.composer-repo-field, .composer-select-field { min-width: 0; display: flex; align-items: center; border: 1px solid #373944; border-radius: 7px; background: #13141a; } +.composer-repo-field { min-width: 130px; flex: 1 1 250px; gap: 5px; padding-left: 9px; } +.composer-toolbar-icon { color: #aaa0e7; font-size: 15px; } +.composer-repo-field input[type="text"] { min-width: 0; min-height: 34px; padding: 7px 7px; border: 0; background: transparent; font-size: 10px; } +.composer-repo-field input[type="text"]:focus { box-shadow: none; } +.composer-select-field { flex: 0 0 auto; } +.composer-select-field select { width: auto; max-width: 145px; min-height: 34px; padding: 6px 25px 6px 9px; border: 0; background: transparent; font-size: 10px; } +.model-select-field select { max-width: 125px; color: #c9c4df; } +.composer-submit { min-height: 35px; padding: 0 12px; white-space: nowrap; } +.composer-submit span { font-size: 15px; } +.composer-repo-help { display: block; padding: 0 14px 10px; color: #777b87; font-size: 9px; } +.advanced-settings { margin: 0 12px 12px; border-top: 1px solid #292b35; } +.advanced-settings summary { display: flex; align-items: center; gap: 9px; padding: 12px 2px 5px; color: #c7c3d6; cursor: pointer; font-size: 10px; list-style: none; } +.advanced-settings summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; } +.advanced-settings summary::-webkit-details-marker { display: none; } +.advanced-settings summary::before { content: '+'; color: #aaa0e7; font-size: 12px; } +.advanced-settings[open] summary::before { content: '−'; } +.advanced-settings summary small { color: #828592; font-size: 9px; } +.advanced-settings .phase-models-panel { margin: 7px 0 0; padding: 12px; } +.advanced-settings .phase-item label { display: block; margin-bottom: 6px; text-transform: capitalize; } +.advanced-settings .phase-item select { min-height: 33px; } +.task-composer .alert-error { margin: 0 12px 12px; } + +@media (max-width: 1050px) { + .sidebar { width: 228px; min-width: 228px; } + .form-container.composer-page { padding-right: 28px; padding-left: 28px; } +} +@media (max-width: 760px) { + .app-shell { flex-direction: column; } + .sidebar { width: 100%; min-width: 0; min-height: auto; height: auto; padding: 12px 14px; border-right: 0; border-bottom: 1px solid #252730; } + .sidebar-brand { padding: 0 4px 11px; } + .sidebar-brand > div:last-child { display: block; } + .workspace-switcher { display: none; } + .sidebar-new-task { width: auto; display: flex; align-self: flex-start; margin: 0 0 12px; padding: 0 11px; font-size: 11px; } + .sidebar-new-task kbd { display: inline-block; } + .sidebar-section-label { display: block; padding-left: 3px; } + .sidebar-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); } + .nav-item { justify-content: flex-start; gap: 6px; padding: 0 7px; font-size: 10px; } + .nav-item > span:not(.nav-icon) { display: inline; } + .nav-icon { width: 13px; font-size: 13px; } + .sidebar-section-heading { margin-top: 10px; } + .sidebar-session-section { min-height: 0; max-height: 180px; flex: 0 1 auto; } + .sidebar-session-list { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding-bottom: 5px; } + .sidebar-session { width: 190px; min-width: 190px; min-height: 43px; align-items: flex-start; border-color: #292b35; background: #17191f; } + .sidebar-sessions-empty { margin: 0 3px 8px; } + .secondary-section { margin-top: 9px; } + .sidebar-bottom { display: flex; align-items: center; gap: 9px; margin-top: 9px; } + .daemon-card { min-width: 0; flex: 1; margin: 0; padding: 8px; } + .daemon-card > div { display: block; } + .sidebar-account { min-width: 0; flex: 1; padding: 7px 0 0; border-top: 0; } + .sidebar-account > div:not(.account-avatar) { display: block; } + .account-signin, .account-action { display: inline; } + .topbar { padding: 0 18px; } + .form-container.composer-page { margin-top: 28px; padding: 0 20px; } + .composer-back-link { margin-bottom: 25px; } + .composer-prompt { min-height: 170px; } +} +@media (max-width: 520px) { + .sidebar { padding: 10px; } + .sidebar-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .sidebar-bottom { align-items: stretch; flex-direction: column; gap: 4px; } + .sidebar-account { min-height: 40px; } + .topbar { padding: 0 12px; } + .form-container.composer-page { margin-top: 22px; padding: 0 12px; } + .composer-heading { margin-bottom: 17px; text-align: left; } + .composer-heading h1 { font-size: 27px; } + .composer-heading p { margin-left: 0; font-size: 11px; } + .composer-runner-notice { font-size: 9px; } + .composer-prompt { min-height: 155px; padding: 17px 15px; font-size: 13px; } + .composer-toolbar { align-items: stretch; flex-wrap: wrap; padding: 9px; } + .composer-repo-field { flex-basis: 100%; } + .composer-select-field { flex: 1 1 0; } + .composer-select-field select, .model-select-field select { width: 100%; max-width: none; } + .composer-submit { flex: 1 1 100%; } + .advanced-settings summary { flex-wrap: wrap; } + .advanced-settings summary small { flex-basis: 100%; padding-left: 21px; } +} @media (max-width: 1050px) { .workspace-page { padding-right: 24px; padding-left: 24px; } } diff --git a/src/App.tsx b/src/App.tsx index ae168ff..c1a01a2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -27,9 +27,12 @@ export default function App() { const [providers, setProviders] = useState([]); const [events, setEvents] = useState>({}); const [connected, setConnected] = useState(false); - const [view, setView] = useState({ name: "list" }); + const [view, setView] = useState({ name: "new" }); const [filter, setFilter] = useState("all"); const [daemonState, setDaemonState] = useState<"starting" | "running" | "unavailable">("starting"); + const [runnerReady, setRunnerReady] = useState(false); + const [runnerReason, setRunnerReason] = useState(null); + const [runnerMode, setRunnerMode] = useState<"fake" | "real">("fake"); const [notice, setNotice] = useState(null); const [initialRepo, setInitialRepo] = useState(""); @@ -65,13 +68,9 @@ export default function App() { cloudApi.setToken(storedToken); } } else { - // No meta yet — minimal hydration so app knows you're logged in - setAuth({ - userId: "", - device: { id: "", name: "this-device", createdAt: new Date().toISOString() }, - deviceToken: storedToken, - }); - cloudApi.setToken(storedToken); + // A token without account metadata cannot identify the account safely. + await deleteDeviceToken(); + cloudApi.setToken(null); } } } catch (err) { @@ -114,6 +113,9 @@ export default function App() { setProviders(msg.providers || []); setEvents(msg.events || {}); setDaemonState(msg.daemon?.watcher === "running" ? "running" : "unavailable"); + setRunnerReady(msg.daemon?.runner?.available === true); + setRunnerReason(msg.daemon?.runner?.reason || null); + setRunnerMode(msg.daemon?.runner?.mode === "real" ? "real" : "fake"); } if (msg.type === "session") { @@ -139,7 +141,7 @@ export default function App() { } if (msg.type === "accepted") { - setNotice("Task added to the local daemon queue."); + setNotice("Task added to the local workspace. The runner is starting."); setView({ name: "list" }); } @@ -228,7 +230,7 @@ export default function App() { // Persist auth meta (userId, device) separately — token is in keychain localStorage.setItem( "codehands_auth_meta", - JSON.stringify({ userId: result.userId, device: result.device, deviceToken: "" }) + JSON.stringify({ userId: result.userId, name: result.name, email: result.email, device: result.device, deviceToken: "" }) ); setIsAuthModalOpen(false); setIsTokenExpired(false); @@ -264,7 +266,7 @@ export default function App() { ⌄ - @@ -287,6 +289,34 @@ export default function App() { +
+
+ + +
+ {sortedSessions.length ? ( + + ) : ( +

Your task sessions will appear here.

+ )} +
+
CONFIGURE