Compare commits

..
Author SHA1 Message Date
Richard Zink 8abf0b4493 Release v202611-00082 2026-11-27 12:33:06 +01:00
Richard ZinkandClaude Sonnet 5.5 6b1a1742b2 Web UI on Ant Design, scrollable factory columns, fix empty page after deleting the open chat
Buttons, fields, drop-downs, check boxes, tabs, dialogs and notices are Ant Design components;
their tokens come from the theme variables (web/src/ui). Every factory board column has its own
vertical scrollbar. ChatView rendered fewer hooks once its chat was deleted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 12:32:57 +01:00
Richard Zink 90b9ab6670 Release v202611-00081 2026-11-27 09:27:47 +01:00
Richard ZinkandClaude Sonnet 5.5 e64328aa98 Force queued messages, wrap long terminal input and questions, Ctrl+J newline in the web UI
A further Enter on the empty input (terminal client, web UI) or Ctrl+Enter with text (web UI)
interrupts the running step and delivers the queued messages at once (POST /api/sessions/{id}/queue/force).
The terminal client shows queued messages above the input, wraps the input field and the question dialog.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 09:27:38 +01:00
Richard Zink 679151defc Release v202611-00080 2026-11-21 22:51:08 +01:00
Richard ZinkandClaude Sonnet 5.5 abdf7d3925 Index usage(session_id): the Factory overview scanned the usage table 900 times per request
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 22:51:06 +01:00
Richard Zink 9addac8c91 Release v202611-00079 2026-11-21 21:32:23 +01:00
Richard ZinkandClaude Sonnet 5.5 cee45bb962 Release profile: keep symbols and line tables of the server for diagnosing the CPU load
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 21:32:22 +01:00
Richard Zink 5ccb524366 Release v202611-00078 2026-11-21 20:47:34 +01:00
Richard ZinkandClaude Sonnet 5.5 c05e2cb6ef Containers with init (reap zombies), no bot token in Telegram errors
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 20:47:32 +01:00
Richard Zink f8b85beb70 Release v202611-00077 2026-11-20 20:34:17 +01:00
Richard ZinkandClaude Sonnet 5.5 3623896464 Changelog: base image entry belongs to the next release
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:34:16 +01:00
Richard ZinkandClaude Sonnet 5.5 d0e7cea117 Test runner: shared base image for acceptance containers, log installed apt packages
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:33:59 +01:00
Richard Zink 23fbc6f302 Release v202611-00076 2026-11-20 20:15:48 +01:00
Richard ZinkandClaude Sonnet 5.5 6804139be7 Test runner: log start time, seed hit/miss and install time per environment
Merges the v73 changelog section into v74.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:15:47 +01:00
Richard Zink 87eafb3108 Release v202611-00075 2026-11-20 13:56:03 +01:00
Richard ZinkandClaude Sonnet 5.5 537aac820d Factory: theme-specific preparing lamp colour, no menu button in the chat overlay
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 13:56:00 +01:00
Richard Zink 836377ac38 Release v202611-00074 2026-11-20 13:23:56 +01:00
Richard ZinkandClaude Sonnet 5.5 391db43949 Factory: merge and close buttons on the issue card, enforced order
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 13:23:52 +01:00
Richard Zink 0e54714436 Release v202611-00073 2026-11-20 13:15:10 +01:00
Richard ZinkandClaude Sonnet 5.5 b9df00422a Test runner: per-project cache (tool caches, shared dirs, seeds)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 13:15:07 +01:00
Richard Zink a083798d7f Release v202611-00072 2026-11-20 12:46:01 +01:00
Richard ZinkandClaude Sonnet 5.5 724405b245 Factory: blinking blue lamp while a phase is being prepared
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 12:45:59 +01:00
132 changed files with 3626 additions and 1462 deletions

No files matched your search

+1 -1
View File
@@ -38,4 +38,4 @@ CODECRAFT_LOG_FORMAT=
# Optional limits per environment and the image used when .factory/setup.json names none:
#RUNNER_MEMORY=2g
#RUNNER_CPUS=2
#RUNNER_DEFAULT_IMAGE=node:22-bookworm
#RUNNER_DEFAULT_IMAGE=git.familie-zink.org/zink/codecraft-testbase:latest
+81
View File
@@ -3,6 +3,87 @@
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
until 1.0, minor versions may contain breaking changes.
## [v202611-00082] – 2026-11-27
### Changed
- **The web UI uses Ant Design.** Buttons, fields, drop-downs, check boxes, tabs, dialogs and notices are Ant Design components for a uniform look. Their colours come from the app's theme variables, so all themes and the light/dark switch keep working; the language of the components follows the app. The first load grows by about 260 KB (gzip).
### Added
- **Factory board:** every column has its own vertical scrollbar; its title stays visible.
### Fixed
- Deleting the chat that is open left an empty page (the chat view rendered fewer hooks than before).
## [v202611-00081] – 2026-11-27
### Added
- **Force a queued message.** While the agent works, a message you send is queued and delivered at the agent's next step. A further Enter on the empty input (terminal client and web UI) or Ctrl+Enter with text (web UI) now interrupts the running step and delivers the queued messages at once, so the model reads them immediately; the queue list in the web UI has a "Force now" button for the same. New endpoint `POST /api/sessions/{id}/queue/force`.
- **Web UI:** Ctrl+J inserts a new line in the message field, like Shift+Enter (and like Ctrl+J / Shift+Enter in the terminal client).
- **Terminal client:** messages waiting for the agent are shown above the input field (also for followed server chats).
### Fixed
- **Terminal client: long input and long questions are cut off.** The input field now wraps at its width instead of hiding the part beyond the edge, and questions, their options and your own answer in the question dialog wrap as well.
## [v202611-00080] – 2026-11-21
### Fixed
- **Factory page made the server stall (HTTP 504, one CPU core at 100 %).** The overview sums tokens and cost of up to 300 runs per request from the `usage` table, which had no index on `session_id`: every request scanned the table 900 times (about 4 s while holding the database lock). The index `usage_session` makes it take milliseconds (measured on the production database: 4.0 s → 8 ms).
## [v202611-00079] – 2026-11-21
### Changed
- **Server binary keeps its symbols and line tables** (`strip = "none"`, `debug = "line-tables-only"` in the release profile), so a stack sample of the running server can be resolved to functions. The binary is a few tens of MB larger.
## [v202611-00078] – 2026-11-21
### Fixed
- **Zombie processes:** the compose files start the containers with `init: true`, so children left behind by agents (Chromium, bwrap, npm) are reaped – a long-running container had collected about 1000 zombies.
- **Telegram:** request errors no longer contain the URL, which includes the bot token, so the token does not end up in the server log.
## [v202611-00077] – 2026-11-20
### Added
- **Shared base image for acceptance containers** (`git.familie-zink.org/zink/codecraft-testbase`, built from `docker/testbase/Dockerfile` by the release script): Node 24, Python 3, gcc/g++/make/cmake, Chromium with Playwright and common tools (git, curl, e2fsprogs, xz, zsh, sudo, jq, …). It is the runner's default image (`RUNNER_DEFAULT_IMAGE`), so setups that installed these again and again start faster; plain `node:24-bookworm` is the fallback if it cannot be pulled. Projects with their own `image` or `dockerfile` are unchanged.
- The runner also logs the apt packages an environment's setup installed (`apt installed: …`), to see what the base image still lacks.
## [v202611-00076] – 2026-11-20
### Changed
- **Test runner: the cache is now visible.** The runner logs for every environment how long it took until the app answered, whether the seed was a hit or a miss, and how long `install` took (e.g. `test env abc (git-…-penguin31) ready after 42 s; cache on; seed 07be…: hit; install took 3 s`).
## [v202611-00075] – 2026-11-20
### Changed
- **Factory: the "preparing" lamp** (checkout, test environment) now has a colour that differs from the theme's accent colour in every theme – the lamp of a running chat keeps the accent. Set per theme with the new variable `--prep`.
- **Factory overlay:** the chat's menu button is hidden in the overlay (it could only close the overlay).
## [v202611-00074] – 2026-11-20
### Added
- **Test runner: cache between acceptance runs.** Every project gets a cache volume (`cc-cache-<project>`) in the runner. Tool caches are shared automatically: npm and Yarn, pip, Go modules and build cache, the Cargo registry and the Cargo target directory (so the second build of a Rust project is incremental). `.factory/setup.json` can add `"cache": {"dirs": [...]}` for directories that persist (downloads – inputs only) and `"cache": {"seed": {"paths": [...], "key": [...]}}` for expensive *results* of `install`, such as a built disk image: the seed is stored after a successful install under a key made from the image, the install command, the seed paths and the contents of the `key` files, and copied into fresh containers only while the key matches – a run never sees changes of an earlier run, and a change of the listed sources builds it anew (the three newest seeds are kept). `"cache": false` turns everything off; `DELETE /v1/cache/<project>` on the runner forgets a project's cache.
### Changed
- **Factory: merge and close on the issue card.** A finished issue shows a *Merge* button on its card once the acceptance has passed (the pull request is open); after the merge the card shows *Close*. Before that neither button is shown. The server enforces the order: a pull request is merged only when the acceptance passed, an issue is closed only when its pull request is merged (a merge done on the forge itself counts). The issue also gets its version and tag right after a merge instead of at the next poll.
## [v202611-00072] – 2026-11-20
### Added
- **Factory: "preparing" lamp.** An issue card whose phase has been started but whose chat does not exist yet – checkout and, for acceptance, installing and starting the app in its throw-away container – shows a blinking blue lamp with the elapsed time instead of staying silent. (Active chats keep their accent-coloured lamp.)
## [v202611-00071] – 2026-11-20
### Added
+4
View File
@@ -4,6 +4,10 @@ members = ["core", "server", "cli"]
[profile.release]
opt-level = 3
# Symbols and line tables stay in the binary, so a hot thread can be resolved with eu-stack / addr2line
# on the running server (the file grows by a few tens of MB).
strip = "none"
debug = "line-tables-only"
# The command line client is small and self-contained.
[profile.release.package.codecraft-cli]
+25 -3
View File
@@ -11,7 +11,7 @@
</p>
<p align="center">
<img alt="Version v202611-00071" src="https://img.shields.io/badge/version-v202611--00071-d69e2e?style=flat-square">
<img alt="Version v202611-00082" src="https://img.shields.io/badge/version-v202611--00082-d69e2e?style=flat-square">
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-689d6a?style=flat-square">
<img alt="Rust backend" src="https://img.shields.io/badge/backend-Rust-b7410e?style=flat-square&logo=rust">
<img alt="React PWA" src="https://img.shields.io/badge/frontend-React%20PWA-2d81ff?style=flat-square&logo=react">
@@ -292,7 +292,8 @@ the server.
On *pass* the factory opens the pull request (if none is open) and comments a result table
in the issue. On *fail* the issue goes back to the build with the findings (*rework*).
4. **Done, merge, version.** You review the pull request in the factory (diff, description) and
merge it there. The factory then pulls the merge, gives the issue its version, commits
merge it there – on the page or with the *Merge* button of the issue card, which appears once
the acceptance has passed (closing an issue by hand is possible only after its merge). The factory then pulls the merge, gives the issue its version, commits
`VERSION`, pushes an annotated tag, comments on the issue and closes it.
Issue text is treated as data, never as instructions for the factory itself.
@@ -373,7 +374,28 @@ helper services and network are removed (leftovers are swept at startup and afte
}
```
`image` defaults to `RUNNER_DEFAULT_IMAGE`; `"dockerfile": "path"` builds the image from the
Between runs of one project the runner keeps a cache volume: npm/Yarn, pip, Go and Cargo caches
(including the Cargo target directory) are shared automatically. For more, add to `setup.json`:
```json
"cache": {
"dirs": ["build/downloads"],
"seed": { "paths": ["data/ubuntu.ext4"], "key": ["guest", "lib", "scripts", "package-lock.json"] }
}
```
`dirs` persist and are shared by all runs (use them for downloads, not for results). A `seed`
holds expensive *results* of `install`: it is stored after a successful install under a key made
from the image, the install command, the seed paths and the contents of the `key` files or
directories, and copied into a fresh container only while that key matches – so a run never
inherits changes from an earlier one, and editing a listed source rebuilds it. `"cache": false`
disables caching; `DELETE /v1/cache/<project>` on the runner clears one project.
`image` defaults to `RUNNER_DEFAULT_IMAGE`, by default the shared base image
`codecraft-testbase` (Node 24, Python 3, gcc/cmake, Chromium with Playwright and common tools; see
`docker/testbase/Dockerfile`; plain Node 24 is the fallback when it cannot be pulled). The runner logs
per environment the start time, the seed hit/miss and the apt packages the setup installed.
The image can be changed per project with `"image"`; `"dockerfile": "path"` builds the image from the
repository instead; helper services are reachable by their name. Containers run without extra
capabilities, with memory/CPU/process limits (`RUNNER_MEMORY`, `RUNNER_CPUS`), and cannot see the
host. Without the runner, or without a `setup.json`, nothing changes. Note that the runner holds
+227 -18
View File
@@ -15,7 +15,7 @@ use ratatui::Frame;
use ratatui::layout::{Constraint, Layout, Rect};
use ratatui::style::{Modifier, Style};
use ratatui::text::{Line, Span};
use ratatui::widgets::{Block, BorderType, Borders, Clear, Paragraph};
use ratatui::widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap};
use serde_json::Value;
use std::collections::VecDeque;
use std::path::PathBuf;
@@ -115,6 +115,10 @@ pub struct App {
busy_since: Instant,
cancel: Option<CancellationToken>,
queue: VecDeque<String>,
/// The messages of a followed server chat that wait for its agent (from the server's queue).
remote_queue: Vec<String>,
/// The running turn is interrupted so that the queued messages are sent at once.
forcing: bool,
dialog: Dialog,
session: LocalSession,
effort: Option<String>,
@@ -211,6 +215,28 @@ fn wrap(text: &str, width: usize) -> Vec<String> {
out
}
/// Break text into rows of at most `width` display columns exactly where they fill up (nothing is trimmed, so
/// typed spaces stay visible); newlines start a new row.
fn hard_wrap(text: &str, width: usize) -> Vec<String> {
let width = width.max(1);
let mut out = Vec::new();
for raw in text.split('\n') {
let mut line = String::new();
let mut w = 0;
for ch in raw.chars() {
let cw = unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0);
if w + cw > width && !line.is_empty() {
out.push(std::mem::take(&mut line));
w = 0;
}
line.push(ch);
w += cw;
}
out.push(line);
}
out
}
/// Inline markdown: `code` and **bold**.
fn inline(text: &str, th: &Theme, base: Style) -> Vec<Span<'static>> {
let mut spans = Vec::new();
@@ -340,6 +366,8 @@ impl App {
busy_since: Instant::now(),
cancel: None,
queue: VecDeque::new(),
remote_queue: Vec::new(),
forcing: false,
dialog: Dialog::None,
todos: session.todos.clone(),
context: session.context_tokens,
@@ -408,7 +436,14 @@ impl App {
self.busy_since = Instant::now();
} else {
self.cancel = None;
if let Some(next) = self.queue.pop_front() {
if self.forcing {
// Interrupted on purpose: everything that waited goes out as one message.
self.forcing = false;
let all: Vec<String> = self.queue.drain(..).collect();
if !all.is_empty() {
self.send(all.join("\n\n"));
}
} else if let Some(next) = self.queue.pop_front() {
self.send(next);
}
}
@@ -488,6 +523,10 @@ impl App {
let text = self.editor.take();
let trimmed = text.trim().to_string();
if trimmed.is_empty() && self.images.is_empty() {
// A further Enter on the empty field delivers the waiting messages at once.
if self.busy && self.has_queue() {
self.force_queue();
}
return;
}
if trimmed.starts_with('/') && self.slash(&trimmed) {
@@ -506,6 +545,27 @@ impl App {
}
}
fn has_queue(&self) -> bool {
if self.remote.is_some() { !self.remote_queue.is_empty() } else { !self.queue.is_empty() }
}
/// Interrupt the running step and deliver the queued messages now (the model reads them at once).
fn force_queue(&mut self) {
if let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) {
let id = r.id.clone();
let (tx, rx) = oneshot::channel();
tokio::spawn(async move {
let _ = tx.send(remote::force_queue(&server, &id).await.map(|_| String::new()));
});
self.pending_note = Some(rx);
self.status = t("forcing").into();
} else if let Some(c) = &self.cancel {
self.forcing = true;
c.cancel();
self.status = t("forcing").into();
}
}
/// Custom commands (server, project, built-in): "/name args" -> prompt.
fn expand_command(&mut self, text: &str) -> Option<String> {
let rest = text.strip_prefix('/')?;
@@ -849,6 +909,7 @@ impl App {
fn leave_remote(&mut self) {
if self.remote.take().is_some() {
self.remote_queue.clear();
self.items.clear();
self.todos = Value::Null;
self.busy = false;
@@ -860,6 +921,10 @@ impl App {
fn send_remote(&mut self, text: String) {
let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) else { return };
let id = r.id.clone();
if self.busy {
self.remote_queue.push(text.clone());
self.status = format!("{} ({})", t("queued"), self.remote_queue.len());
}
let (tx, rx) = oneshot::channel();
tokio::spawn(async move {
let _ = tx.send(remote::prompt(&server, &id, &text).await.map(|_| String::new()));
@@ -932,6 +997,7 @@ impl App {
self.busy = false;
self.dialog = Dialog::None;
self.remote = Some(r);
self.remote_queue.clear();
self.pending_snapshot = None;
}
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
@@ -962,6 +1028,7 @@ impl App {
let head = self.items.first().filter(|i| matches!(i, Item::Info(s) if s.starts_with("server chat:"))).map(|i| if let Item::Info(s) = i { s.clone() } else { String::new() });
self.items = head.map(Item::Info).into_iter().chain(items).collect();
self.busy = snap.busy;
self.remote_queue = snap.queue.clone();
if snap.busy && !was_busy {
self.busy_since = Instant::now();
}
@@ -1700,10 +1767,37 @@ impl App {
let th = theme::get();
let area = f.area();
f.render_widget(Block::default().style(Style::default().bg(th.bg0).fg(th.fg1)), area);
let input_h = (self.editor.lines.len() as u16).clamp(1, 8) + 2;
// The input wraps at the width of the field (one column stays free for the cursor).
let wrap_w = (area.width.saturating_sub(3) as usize).max(1);
let layout = self.editor.layout(wrap_w);
let input_h = (layout.len() as u16).clamp(1, 8) + 2;
// Messages that wait for the agent are shown above the input.
let queued: Vec<String> = if self.remote.is_some() { self.remote_queue.clone() } else { self.queue.iter().cloned().collect() };
let mut queue_lines: Vec<Line> = Vec::new();
if !queued.is_empty() {
let w = (area.width as usize).saturating_sub(6).max(10);
let mut more = 0;
for (n, msg) in queued.iter().enumerate() {
let rows = wrap(msg, w);
if queue_lines.len() + rows.len() > 5 {
more = queued.len() - n;
break;
}
for (r, row) in rows.into_iter().enumerate() {
queue_lines.push(Line::from(vec![Span::styled(if r == 0 { " ↳ " } else { " " }, Style::default().fg(th.accent2)), Span::styled(row, Style::default().fg(th.fg2))]));
}
}
if more > 0 {
queue_lines.push(Line::from(Span::styled(format!(" … +{more}"), Style::default().fg(th.muted))));
}
if self.busy {
queue_lines.push(Line::from(Span::styled(format!(" {}", t("force_hint")), Style::default().fg(th.muted))));
}
}
let queue_h = queue_lines.len() as u16;
let todo_items: Vec<&Value> = self.todos.as_array().map(|a| a.iter().collect()).unwrap_or_default();
let todo_h = if todo_items.iter().any(|t| t["status"] != "completed") { (todo_items.len() as u16).min(6) } else { 0 };
let [head, hist, todos, act, input, status] = Layout::vertical([Constraint::Length(1), Constraint::Min(3), Constraint::Length(todo_h), Constraint::Length(1), Constraint::Length(input_h), Constraint::Length(1)]).areas(area);
let [head, hist, todos, act, queue_area, input, status] = Layout::vertical([Constraint::Length(1), Constraint::Min(3), Constraint::Length(todo_h), Constraint::Length(1), Constraint::Length(queue_h), Constraint::Length(input_h), Constraint::Length(1)]).areas(area);
// Header.
let cwd = self.session.cwd.replace(&crate::conf::home().display().to_string(), "~");
@@ -1769,12 +1863,15 @@ impl App {
Span::styled(format!(" {} ", SPINNER[self.tick % SPINNER.len()]), Style::default().fg(th.accent2)),
Span::styled(format!("{}…", t("working")), Style::default().fg(th.accent2)),
Span::styled(format!(" ({secs}s · ~{} tokens) · {}", self.step_chars / 4, t("interrupt")), Style::default().fg(th.muted)),
Span::styled(if self.queue.is_empty() { String::new() } else { format!(" · {} {}", self.queue.len(), t("queued")) }, Style::default().fg(th.muted)),
Span::styled({ let n = if self.remote.is_some() { self.remote_queue.len() } else { self.queue.len() }; if n == 0 { String::new() } else { format!(" · {} {}", n, t("queued")) } }, Style::default().fg(th.muted)),
])
} else {
Line::from(Span::styled(format!(" {}", self.status), Style::default().fg(th.muted)))
};
f.render_widget(Paragraph::new(activity), act);
if queue_h > 0 {
f.render_widget(Paragraph::new(queue_lines), queue_area);
}
// Input.
let mode_col = match self.session.mode.as_str() {
@@ -1793,16 +1890,17 @@ impl App {
let inner = block.inner(input);
f.render_widget(block, input);
let visible = inner.height as usize;
let first = self.editor.row.saturating_sub(visible.saturating_sub(1));
let text: Vec<Line> = if self.editor.is_empty() {
vec![Line::from(Span::styled(if self.busy { t("busy_placeholder") } else { t("placeholder") }, Style::default().fg(th.muted)))]
let (crow, ccol) = self.editor.cursor_in(&layout);
let first = crow.saturating_sub(visible.saturating_sub(1));
if self.editor.is_empty() {
let hint = Line::from(Span::styled(if self.busy { t("busy_placeholder") } else { t("placeholder") }, Style::default().fg(th.muted)));
f.render_widget(Paragraph::new(hint).wrap(Wrap { trim: false }), inner);
} else {
self.editor.lines[first..].iter().take(visible).map(|l| Line::from(Span::styled(l.clone(), Style::default().fg(th.fg0)))).collect()
};
let scroll_x = self.editor.cursor_x().saturating_sub(inner.width.saturating_sub(1) as usize) as u16;
f.render_widget(Paragraph::new(text).scroll((0, scroll_x)), inner);
let text: Vec<Line> = layout[first..].iter().take(visible).map(|r| Line::from(Span::styled(self.editor.row_text(*r), Style::default().fg(th.fg0)))).collect();
f.render_widget(Paragraph::new(text), inner);
}
if matches!(self.dialog, Dialog::None) {
f.set_cursor_position((inner.x + self.editor.cursor_x() as u16 - scroll_x, inner.y + (self.editor.row - first) as u16));
f.set_cursor_position((inner.x + (ccol as u16).min(inner.width.saturating_sub(1)), inner.y + (crow - first) as u16));
}
// Status line.
@@ -1882,14 +1980,39 @@ impl App {
}
Dialog::Question { questions, idx, sel, custom, .. } => {
let q = &questions[*idx];
let mut lines = vec![Line::from(Span::styled(q.question.clone(), Style::default().fg(th.fg0).add_modifier(Modifier::BOLD))), Line::default()];
// Everything wraps at the width of the box (it is 90 columns wide, less on small terminals).
let w = (90.min(area.width.saturating_sub(4)) as usize).saturating_sub(2).max(10);
let mut lines: Vec<Line> = wrap(&q.question, w).into_iter().map(|l| Line::from(Span::styled(l, Style::default().fg(th.fg0).add_modifier(Modifier::BOLD)))).collect();
lines.push(Line::default());
for (i, o) in q.options.iter().enumerate() {
let st = if i == *sel && custom.is_empty() { Style::default().fg(th.on_accent).bg(th.accent) } else { Style::default().fg(th.fg1) };
lines.push(Line::from(vec![Span::styled(format!(" {}. {} ", i + 1, o.label), st), Span::styled(format!(" {}", o.description), Style::default().fg(th.muted))]));
let on = i == *sel && custom.is_empty();
let prefix = format!(" {}. {} ", i + 1, o.label);
let full = if o.description.is_empty() { prefix.clone() } else { format!("{prefix} {}", o.description) };
for (r, row) in wrap(&full, w.saturating_sub(4)).into_iter().enumerate() {
let row = if r == 0 { row } else { format!(" {row}") };
if on {
lines.push(Line::from(Span::styled(row, Style::default().fg(th.on_accent).bg(th.accent))));
} else if r == 0 {
let cut = row.char_indices().nth(prefix.chars().count()).map(|(b, _)| b).unwrap_or(row.len());
lines.push(Line::from(vec![Span::styled(row[..cut].to_string(), Style::default().fg(th.fg1)), Span::styled(row[cut..].to_string(), Style::default().fg(th.muted))]));
} else {
lines.push(Line::from(Span::styled(row, Style::default().fg(th.muted))));
}
}
}
lines.push(Line::default());
lines.push(Line::from(Span::styled(format!("> {custom}_"), Style::default().fg(th.fg0))));
lines.push(Line::from(Span::styled(t("question_keys"), Style::default().fg(th.muted))));
// The own answer: wrapped as typed; only its last rows are shown when it gets long.
let typed = hard_wrap(&format!("> {custom}_"), w);
let skip = typed.len().saturating_sub(6);
if skip > 0 {
lines.push(Line::from(Span::styled(" …", Style::default().fg(th.muted))));
}
for row in typed.into_iter().skip(skip) {
lines.push(Line::from(Span::styled(row, Style::default().fg(th.fg0))));
}
for row in wrap(t("question_keys"), w) {
lines.push(Line::from(Span::styled(row, Style::default().fg(th.muted))));
}
let title = format!("{} {}/{}", t("question"), idx + 1, questions.len());
let inner = boxed(f, &title, 90, lines.len() as u16 + 2, th.blue);
f.render_widget(Paragraph::new(lines), inner);
@@ -2044,3 +2167,89 @@ impl App {
self.status = s;
}
}
#[cfg(test)]
mod wrap_tests {
use super::*;
#[test]
fn hard_wrap_keeps_every_character() {
let rows = hard_wrap("abc def ghi", 5);
assert_eq!(rows.join(""), "abc def ghi");
assert!(rows.iter().all(|r| UnicodeWidthStr::width(r.as_str()) <= 5));
}
#[test]
fn hard_wrap_counts_wide_characters() {
let rows = hard_wrap("日本語日本語", 4);
assert_eq!(rows, vec!["日本", "語日", "本語"]);
}
}
#[cfg(test)]
mod render_tests {
use super::*;
use crate::agent::Env;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
fn app() -> App {
let cfg: crate::conf::Config = serde_json::from_str("{}").expect("empty config");
let env = Env {
cfg,
server: None,
server_cfg: None,
catalog: Default::default(),
modes: crate::agent::builtin_modes(),
permissions: Default::default(),
base_prompt: String::new(),
auto_prompt: String::new(),
remote_tools: Vec::new(),
server_skills: Vec::new(),
memory: String::new(),
};
let session = LocalSession { id: "t".into(), title: String::new(), cwd: "/tmp".into(), model: String::new(), mode: "build".into(), permission_mode: "default".into(), created_at: 0, updated_at: 0, messages: Vec::new(), usage: Default::default(), cost: 0.0, todos: Value::Null, context_tokens: 0 };
let (tx, _rx) = mpsc::unbounded_channel();
App::new(Arc::new(env), session, tx)
}
fn screen(app: &mut App, w: u16, h: u16) -> String {
let mut term = Terminal::new(TestBackend::new(w, h)).unwrap();
term.draw(|f| app.draw(f)).unwrap();
let buf = term.backend().buffer().clone();
(0..h).map(|y| (0..w).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")
}
#[test]
fn queued_messages_show_above_the_input_and_wrap() {
let mut a = app();
a.busy = true;
a.queue.push_back("Das ist eine lange wartende Nachricht, die ueber mehrere Zeilen umbrechen muss weil sie so lang ist".into());
a.queue.push_back("zweite".into());
let s = screen(&mut a, 50, 20);
assert!(s.contains("↳ Das ist eine lange"), "{s}");
assert!(s.contains("↳ zweite"), "{s}");
assert!(s.contains("sofort zustellen") || s.contains("deliver now"), "{s}");
let q = s.lines().position(|l| l.contains("↳ Das")).unwrap();
let input = s.lines().position(|l| l.contains('╭') && l.contains("build")).unwrap();
assert!(q < input, "the queue is above the input\n{s}");
}
#[test]
fn long_question_and_options_wrap_instead_of_being_cut() {
let mut a = app();
let (tx, _rx) = oneshot::channel();
a.dialog = Dialog::Question {
questions: vec![Question { question: "Soll der Builder das Limit auf sechs Mebibyte anheben oder lieber einzelne Grammatiken weglassen, obwohl die Spec das verbietet?".into(), header: String::new(), options: vec![codecraft_core::types::QuestionOption { label: "Limit anheben".into(), description: "Das Archiv bleibt vollstaendig und waechst auf knapp fuenf Mebibyte an".into() }], multi_select: false }],
idx: 0,
sel: 0,
custom: "eine sehr lange eigene Antwort die in dem Feld nicht mehr in eine Zeile passt und deshalb umbrechen muss".into(),
answers: Default::default(),
reply: Some(tx),
};
let s = screen(&mut a, 60, 30);
for part in ["Mebibyte anheben", "weglassen", "knapp", "Antwort", "umbrechen muss"] {
assert!(s.contains(part), "missing {part}\n{s}");
}
}
}
+99 -5
View File
@@ -1,6 +1,6 @@
//! Multi-line input field with history.
use unicode_width::UnicodeWidthStr;
use unicode_width::UnicodeWidthChar;
#[derive(Default)]
pub struct Editor {
@@ -211,9 +211,103 @@ impl Editor {
self.col = start + with.chars().count();
}
/// Cursor position in display columns (for the terminal cursor).
pub fn cursor_x(&self) -> usize {
let line = &self.lines[self.row];
UnicodeWidthStr::width(&line[..byte_idx(line, self.col)])
/// The text as it is shown at `width` columns: every logical line is broken into rows, preferably after a
/// space, otherwise inside a long word. Each row is (line index, first char, end char).
pub fn layout(&self, width: usize) -> Vec<(usize, usize, usize)> {
let width = width.max(1);
let mut rows = Vec::new();
for (i, line) in self.lines.iter().enumerate() {
let chars: Vec<char> = line.chars().collect();
if chars.is_empty() {
rows.push((i, 0, 0));
continue;
}
let mut start = 0;
while start < chars.len() {
let mut w = 0;
let mut end = start;
let mut last_space = None;
while end < chars.len() {
let cw = UnicodeWidthChar::width(chars[end]).unwrap_or(0);
if w + cw > width && end > start {
break;
}
w += cw;
end += 1;
if chars[end - 1] == ' ' {
last_space = Some(end);
}
}
if end < chars.len() {
if let Some(sp) = last_space.filter(|sp| *sp > start) {
end = sp;
}
}
rows.push((i, start, end));
start = end;
}
}
rows
}
/// The text of one row of `layout`.
pub fn row_text(&self, (line, a, b): (usize, usize, usize)) -> String {
self.lines[line].chars().skip(a).take(b - a).collect()
}
/// Cursor in the wrapped view: (row index in `layout`, display column).
pub fn cursor_in(&self, layout: &[(usize, usize, usize)]) -> (usize, usize) {
for (n, &(line, a, b)) in layout.iter().enumerate() {
let last = layout.get(n + 1).is_none_or(|next| next.0 != line);
if line == self.row && self.col >= a && (self.col < b || (last && self.col <= b)) {
let w: usize = self.lines[line].chars().skip(a).take(self.col - a).map(|c| UnicodeWidthChar::width(c).unwrap_or(0)).sum();
return (n, w);
}
}
(layout.len().saturating_sub(1), 0)
}
}
#[cfg(test)]
mod tests {
use super::*;
fn editor(text: &str) -> Editor {
let mut e = Editor { lines: vec![String::new()], ..Default::default() };
e.set(text);
e
}
#[test]
fn long_line_wraps_at_spaces() {
let e = editor("aaa bbb ccc ddd");
let rows: Vec<String> = e.layout(8).into_iter().map(|r| e.row_text(r)).collect();
assert_eq!(rows, vec!["aaa bbb ", "ccc ddd"]);
}
#[test]
fn long_word_breaks_inside() {
let e = editor("abcdefghij");
let rows: Vec<String> = e.layout(4).into_iter().map(|r| e.row_text(r)).collect();
assert_eq!(rows, vec!["abcd", "efgh", "ij"]);
}
#[test]
fn empty_lines_keep_a_row_and_nothing_is_lost() {
let e = editor("one\n\ntwo words here");
let l = e.layout(6);
let joined: String = l.iter().map(|r| e.row_text(*r)).collect::<Vec<_>>().join("|");
assert_eq!(joined, "one||two |words |here");
}
#[test]
fn cursor_follows_the_wrap() {
let mut e = editor("aaa bbb ccc ddd");
let l = e.layout(8);
assert_eq!(e.cursor_in(&l), (1, 7)); // end of the text, second row
e.col = 8; // before "ccc"
assert_eq!(e.cursor_in(&l), (1, 0));
e.col = 3;
assert_eq!(e.cursor_in(&l), (0, 3));
}
}
+3 -1
View File
@@ -14,7 +14,7 @@ pub fn system_lang() -> String {
/// (key, English, German)
const TEXTS: &[(&str, &str, &str)] = &[
("placeholder", "Message… (/ commands, @ files, Shift+Enter new line)", "Nachricht… (/ Befehle, @ Dateien, Shift+Enter neue Zeile)"),
("placeholder", "Message… (/ commands, @ files, Shift+Enter or Ctrl+J new line)", "Nachricht… (/ Befehle, @ Dateien, Shift+Enter oder Strg+J neue Zeile)"),
("busy_placeholder", "Message is queued and sent after this turn…", "Nachricht wird nach diesem Schritt gesendet…"),
("permission", "Permission required", "Freigabe erforderlich"),
("perm_keys", "[y] allow once [a] always in this session [n] reject [f] reject with feedback", "[y] einmal erlauben [a] immer in dieser Session [n] ablehnen [f] ablehnen mit Hinweis"),
@@ -36,6 +36,8 @@ const TEXTS: &[(&str, &str, &str)] = &[
("choose_theme", "Choose a theme", "Theme wählen"),
("filter", "type to filter", "tippen zum Filtern"),
("queued", "queued", "in der Warteschlange"),
("force_hint", "Enter on the empty field: deliver now (interrupts the running step)", "Enter im leeren Feld: sofort zustellen (unterbricht den laufenden Schritt)"),
("forcing", "interrupting – the queued message is sent now", "unterbreche – die Nachricht wird jetzt gesendet"),
("welcome", "Welcome to CodeCraft", "Willkommen bei CodeCraft"),
("setup_title", "Set up CodeCraft", "CodeCraft einrichten"),
("setup_intro", "Where should the models come from? You can add more later with /setup.", "Woher sollen die Modelle kommen? Weitere kannst du später mit /setup hinzufügen."),
+17 -1
View File
@@ -32,6 +32,8 @@ pub struct Snapshot {
pub todos: Value,
/// Open permission and question requests of this chat (and its subagents).
pub pending: Vec<Value>,
/// Messages waiting for the agent (text of each).
pub queue: Vec<String>,
}
fn short(s: &str, n: usize) -> String {
@@ -80,7 +82,16 @@ pub async fn snapshot(server: &Server, id: &str) -> Result<Snapshot> {
.into_iter()
.filter(|e| e["session_id"].as_str() == Some(id) || e["root_session_id"].as_str() == Some(id))
.collect();
Ok(Snapshot { messages, busy: s["busy"].as_bool().unwrap_or(false), title: s["session"]["title"].as_str().unwrap_or("").to_string(), todos: s["session"]["todos"].clone(), pending })
let queue = s["queue"]
.as_array()
.map(|a| {
a.iter()
.filter(|i| i["source"].as_str() != Some("background"))
.map(|i| i["parts"].as_array().map(|p| p.iter().filter_map(|x| x["text"].as_str()).collect::<Vec<_>>().join(" ")).unwrap_or_default())
.collect()
})
.unwrap_or_default();
Ok(Snapshot { messages, busy: s["busy"].as_bool().unwrap_or(false), title: s["session"]["title"].as_str().unwrap_or("").to_string(), todos: s["session"]["todos"].clone(), pending, queue })
}
pub async fn open(server: &Server, id: &str) -> Result<Remote> {
@@ -118,6 +129,11 @@ pub async fn abort(server: &Server, id: &str) -> Result<()> {
server.post(&format!("/sessions/{id}/abort"), json!({})).await.map(|_| ())
}
/// Interrupt the running step and deliver the queued messages at once.
pub async fn force_queue(server: &Server, id: &str) -> Result<()> {
server.post(&format!("/sessions/{id}/queue/force"), json!({})).await.map(|_| ())
}
pub async fn compact(server: &Server, id: &str) -> Result<()> {
server.post(&format!("/sessions/{id}/compact"), json!({})).await.map(|_| ())
}
+4 -1
View File
@@ -18,6 +18,8 @@ services:
# Pin a version (e.g. :v202611-00001) or follow :latest.
image: git.familie-zink.org/zink/codecraft:${CODECRAFT_VERSION:-latest}
container_name: codecraft
# PID 1 reaps the children the agents leave behind (chromium, bwrap, npm …) instead of keeping them as zombies.
init: true
restart: unless-stopped
# Same UID/GID as the owner of your project files.
user: "${UID:-1000}:${GID:-1000}"
@@ -65,6 +67,7 @@ services:
image: git.familie-zink.org/zink/codecraft:${CODECRAFT_VERSION:-latest}
command: ["testrunner"]
container_name: codecraft-testrunner
init: true
restart: unless-stopped
user: "${UID:-1000}:${GID:-1000}"
# Group that owns /var/run/docker.sock on the host: stat -c %g /var/run/docker.sock
@@ -75,7 +78,7 @@ services:
RUNNER_FACTORY_DIR: /factory
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
RUNNER_CPUS: ${RUNNER_CPUS:-2}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-node:22-bookworm}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-git.familie-zink.org/zink/codecraft-testbase:latest}
HOME: /tmp
volumes:
- /var/run/docker.sock:/var/run/docker.sock
+4 -1
View File
@@ -14,6 +14,8 @@ services:
GIT_COMMIT: ${GIT_COMMIT:-}
image: codecraft:latest
container_name: codecraft
# PID 1 reaps the children the agents leave behind (chromium, bwrap, npm …) instead of keeping them as zombies.
init: true
restart: unless-stopped
# Same UID/GID as the owner of your project files.
user: "${UID:-1000}:${GID:-1000}"
@@ -61,6 +63,7 @@ services:
image: codecraft:latest
command: ["testrunner"]
container_name: codecraft-testrunner
init: true
restart: unless-stopped
user: "${UID:-1000}:${GID:-1000}"
# Group that owns /var/run/docker.sock on the host: stat -c %g /var/run/docker.sock
@@ -71,7 +74,7 @@ services:
RUNNER_FACTORY_DIR: /factory
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
RUNNER_CPUS: ${RUNNER_CPUS:-2}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-node:22-bookworm}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-git.familie-zink.org/zink/codecraft-testbase:latest}
HOME: /tmp
volumes:
- /var/run/docker.sock:/var/run/docker.sock
+14
View File
@@ -0,0 +1,14 @@
# Base image of the factory's throw-away acceptance containers (used when .factory/setup.json names no image).
# Node 24, Python 3, a C/C++ toolchain, the Chromium that Playwright needs, and the small tools
# that acceptance setups installed again and again (see the runner log "apt installed: ...").
FROM node:24-bookworm
ENV DEBIAN_FRONTEND=noninteractive PIP_BREAK_SYSTEM_PACKAGES=1 PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake pkg-config git curl wget ca-certificates unzip xz-utils zip \
e2fsprogs util-linux zsh sudo nano procps iproute2 netcat-openbsd jq sqlite3 \
python3 python3-pip python3-venv \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g playwright \
&& playwright install --with-deps chromium \
&& rm -rf /var/lib/apt/lists/* /root/.npm \
&& chmod -R a+rX /ms-playwright
+4
View File
@@ -94,6 +94,10 @@ if (( image )); then
run docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
--build-arg GIT_COMMIT="$(git rev-parse --short HEAD)" --build-arg CODECRAFT_VERSION="$version" \
"${tags[@]}" --push .
# Base image of the factory's acceptance containers (cached layers: cheap unless the Dockerfile changed).
step "Building and pushing ${REGISTRY}-testbase for $PLATFORMS"
run docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
-t "${REGISTRY}-testbase:latest" -t "${REGISTRY}-testbase:$tag" --push docker/testbase
fi
step "Creating the Gitea release $tag"
+28 -1
View File
@@ -113,6 +113,7 @@ pub fn router(app: AppState) -> Router {
.route("/sessions/{id}/shares", get(get_shares).put(put_shares))
.route("/sessions/{id}/queue", get(get_queue))
.route("/sessions/{id}/queue/flush", post(flush_queue))
.route("/sessions/{id}/queue/force", post(force_queue))
.route("/sessions/{id}/queue/{item}", delete(delete_queue_item))
.route("/permissions/{id}", post(reply_permission))
.route("/permissions/{id}/explain", post(explain_permission))
@@ -1359,6 +1360,12 @@ async fn flush_queue(Extension(user): Extension<User>, State(app): State<AppStat
Ok(Json(json!({"started": runner::flush_queue(app.clone(), &id)?})))
}
/// Interrupt the running step and deliver the queued messages at once.
async fn force_queue(Extension(user): Extension<User>, State(app): State<AppState>, Path(id): Path<String>) -> ApiResult {
writable(&app, &user, &id)?;
Ok(Json(json!({"forced": runner::force_queue(app.clone(), &id)?})))
}
pub(crate) async fn do_compact(app: AppState, id: String) {
let cancel = tokio_util::sync::CancellationToken::new();
app.with_runtime(&id, |r| r.cancel = Some(cancel.clone()));
@@ -3011,6 +3018,15 @@ async fn factory_close_issue(Extension(user): Extension<User>, State(app): State
return Err(ApiError(StatusCode::BAD_REQUEST, "only finished issues can be closed here".into()));
}
let bad = |e: anyhow::Error| ApiError(StatusCode::BAD_GATEWAY, format!("{e:#}"));
// Closing comes after the merge. A merge done on the forge itself counts too: ask the forge when we do not know yet.
if row["merged"].as_bool() != Some(true) {
let pr_n: u64 = row["pr_url"].as_str().unwrap_or("").trim_end_matches('/').rsplit('/').next().and_then(|n| n.parse().ok()).unwrap_or(0);
let merged = pr_n > 0 && g.pr(pr_n).await.map(|p| p["state"].as_str() == Some("merged")).unwrap_or(false);
if !merged {
return Err(ApiError(StatusCode::BAD_REQUEST, "merge the pull request first".into()));
}
app.store.factory_issue_set(&b.repo, b.number, &[("merged", json!(1))])?;
}
let text = if b.comment.trim().is_empty() { "Closed.".to_string() } else { b.comment.trim().to_string() };
g.comment(b.number as u64, &format!("{}\n**Closed** by {}: {text}", crate::factory::BOT, user.username)).await.map_err(bad)?;
g.close_issue(b.number as u64).await.map_err(bad)?;
@@ -3072,6 +3088,10 @@ struct MergePr {
/// Merge the pull request of an issue – only on the user's own click in the factory page.
async fn factory_pr_merge(Extension(user): Extension<User>, State(app): State<AppState>, headers: axum::http::HeaderMap, Json(b): Json<MergePr>) -> ApiResult {
let (g, row) = factory_issue_forge(&app, &user, &b.repo, b.number)?;
// Merging comes after a positive acceptance (the issue is "done").
if row["state"].as_str() != Some("done") {
return Err(ApiError(StatusCode::BAD_REQUEST, "the pull request can be merged once the acceptance has passed".into()));
}
let method = if b.method.is_empty() { "merge" } else { b.method.as_str() };
if !["merge", "squash", "rebase"].contains(&method) {
return Err(ApiError(StatusCode::BAD_REQUEST, "unknown merge method".into()));
@@ -3082,8 +3102,15 @@ async fn factory_pr_merge(Extension(user): Extension<User>, State(app): State<Ap
return Err(ApiError(StatusCode::BAD_REQUEST, "this is not the open pull request of the issue".into()));
}
g.merge_pr(b.pr, method).await.map_err(|e| ApiError(StatusCode::BAD_GATEWAY, format!("{e:#}")))?;
app.store.factory_issue_set(&b.repo, b.number, &[("pr_url", json!(pr["html_url"].as_str().unwrap_or("")))])?;
app.store.factory_issue_set(&b.repo, b.number, &[("pr_url", json!(pr["html_url"].as_str().unwrap_or(""))), ("merged", json!(1))])?;
app.audit(Some(&user), "factory.pr.merge", &format!("{}#{}", b.repo, b.number), &crate::auth::client_ip(&headers));
// Give the issue its version and tag right away instead of at the next poll.
if let Ok(cfg) = factory_repo_cfg(&app, &user, &b.repo) {
let (app2, user2) = (app.clone(), user.clone());
tokio::spawn(async move {
let _ = crate::factory::poll_repo(&app2, &user2, &cfg).await;
});
}
Ok(Json(json!({"ok": true})))
}
+3
View File
@@ -45,6 +45,9 @@ pub struct Runtime {
pub step: Option<Value>,
/// Reasoning effort chosen for the current turn (overrides the model's default).
pub effort: Option<String>,
/// The user interrupted the turn to deliver the queued messages at once: they start the next turn
/// even though the run was cancelled.
pub force_queue: bool,
}
pub struct App {
+4 -2
View File
@@ -1240,11 +1240,13 @@ impl TestEnv {
/// Start the app of `work` in a throw-away container when a test runner is configured
/// (`CODECRAFT_RUNNER_URL`) and `.factory/setup.json` says how. `Ok(None)` = run it the old way.
async fn start_test_env(work: &std::path::Path) -> Result<Option<TestEnv>> {
async fn start_test_env(work: &std::path::Path, repo_url: &str) -> Result<Option<TestEnv>> {
use crate::testrunner as tr;
let Some(client) = tr::Client::from_env() else { return Ok(None) };
let Some(mut req) = std::fs::read_to_string(work.join(".factory/setup.json")).ok().and_then(|t| tr::parse_setup(&t)) else { return Ok(None) };
req.work = work.display().to_string();
// One cache per project: tool caches, download directories and seeds survive between acceptance runs.
req.cache_id = slugify(repo_url.trim_end_matches(".git").rsplit("://").next().unwrap_or(repo_url)).chars().take(80).collect();
let started = client.start(&req).await?;
let (local, forward) = match tr::forward_local(req.port, client.host(), started.port).await {
Ok(x) => x,
@@ -1342,7 +1344,7 @@ async fn qa(app: Arc<App>, user: User, cfg: RepoCfg, issue: Value) {
}
}
// With a test runner the app starts in a throw-away container; without one the agent starts it itself.
let env = match start_test_env(&work).await {
let env = match start_test_env(&work, &cfg.url).await {
Ok(e) => e,
Err(e) => {
cleanup_worktree(&app, &user, &cfg, &work).await;
+2
View File
@@ -235,6 +235,8 @@ pub async fn version_pass(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<
if pr["state"].as_str() != Some("merged") {
continue;
}
// Remember it at once: if the version step below fails, the issue can still be closed by hand.
let _ = app.store.factory_issue_set(&cfg.url, n, &[("merged", json!(1))]);
let title = r["title"].as_str().unwrap_or("").to_string();
let others: Vec<String> = g.open_issue_titles().await?.into_iter().filter(|(num, _)| *num != n).map(|(_, t)| t).collect();
let dir = checkout(app, user, cfg).await?;
+21 -1
View File
@@ -112,7 +112,8 @@ pub fn submit(app: Arc<App>, session_id: String, parts: Vec<Part>, source: &str)
let leftover = app.with_runtime(&session_id, |r| {
r.cancel = None;
r.effort = None;
if cancel.is_cancelled() { Vec::new() } else { take_queue(&app, &session_id) }
let forced = std::mem::take(&mut r.force_queue);
if cancel.is_cancelled() && !forced { Vec::new() } else { take_queue(&app, &session_id) }
});
app.emit(Event::SessionStatus { session_id: session_id.clone(), busy: false });
if leftover.is_empty() && !cancel.is_cancelled() {
@@ -139,6 +140,25 @@ pub fn flush_queue(app: Arc<App>, session_id: &str) -> Result<bool> {
Ok(true)
}
/// Deliver the queued messages now: the running step is interrupted and the messages start the next turn
/// at once (instead of waiting for the agent's next step). Without a running turn this is `flush_queue`.
/// Returns false when nothing is queued.
pub fn force_queue(app: Arc<App>, session_id: &str) -> Result<bool> {
if app.store.queue_list(session_id).unwrap_or_default().is_empty() {
return Ok(false);
}
if !app.is_busy(session_id) {
return flush_queue(app, session_id);
}
app.with_runtime(session_id, |r| {
if let Some(c) = &r.cancel {
r.force_queue = true;
c.cancel();
}
});
Ok(true)
}
pub fn abort(app: &App, session_id: &str) {
app.with_runtime(session_id, |r| {
if let Some(c) = &r.cancel {
+5 -3
View File
@@ -51,6 +51,7 @@ impl Store {
);
CREATE INDEX IF NOT EXISTS usage_ts ON usage(ts);
CREATE INDEX IF NOT EXISTS usage_root ON usage(root_session_id);
CREATE INDEX IF NOT EXISTS usage_session ON usage(session_id);
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY,
username TEXT NOT NULL UNIQUE COLLATE NOCASE,
@@ -262,6 +263,7 @@ impl Store {
("images", "blob", "ALTER TABLE images ADD COLUMN blob TEXT"),
("usage", "allowance", "ALTER TABLE usage ADD COLUMN allowance REAL"),
("factory_issues", "version", "ALTER TABLE factory_issues ADD COLUMN version TEXT NOT NULL DEFAULT ''"),
("factory_issues", "merged", "ALTER TABLE factory_issues ADD COLUMN merged INTEGER NOT NULL DEFAULT 0"),
] {
let exists: bool = conn
.prepare(&format!("SELECT 1 FROM pragma_table_info('{table}') WHERE name = ?1"))?
@@ -1489,8 +1491,8 @@ impl Store {
pub fn factory_issue(&self, repo: &str, number: i64) -> Result<Option<Value>> {
let conn = self.conn.lock().unwrap();
Ok(conn
.query_row("SELECT title, author, state, attempts, rounds, last_comment, scenarios, branch, pr_url, note, created_at, updated_at, owner_id, version FROM factory_issues WHERE repo_url = ?1 AND number = ?2", params![repo, number], |r| {
Ok(json!({"repo": repo, "number": number, "title": r.get::<_, String>(0)?, "author": r.get::<_, String>(1)?, "state": r.get::<_, String>(2)?, "attempts": r.get::<_, i64>(3)?, "rounds": r.get::<_, i64>(4)?, "last_comment": r.get::<_, i64>(5)?, "scenarios": r.get::<_, String>(6)?, "branch": r.get::<_, String>(7)?, "pr_url": r.get::<_, String>(8)?, "note": r.get::<_, String>(9)?, "created_at": r.get::<_, i64>(10)?, "updated_at": r.get::<_, i64>(11)?, "owner_id": r.get::<_, String>(12)?, "version": r.get::<_, String>(13)?}))
.query_row("SELECT title, author, state, attempts, rounds, last_comment, scenarios, branch, pr_url, note, created_at, updated_at, owner_id, version, merged FROM factory_issues WHERE repo_url = ?1 AND number = ?2", params![repo, number], |r| {
Ok(json!({"repo": repo, "number": number, "title": r.get::<_, String>(0)?, "author": r.get::<_, String>(1)?, "state": r.get::<_, String>(2)?, "attempts": r.get::<_, i64>(3)?, "rounds": r.get::<_, i64>(4)?, "last_comment": r.get::<_, i64>(5)?, "scenarios": r.get::<_, String>(6)?, "branch": r.get::<_, String>(7)?, "pr_url": r.get::<_, String>(8)?, "note": r.get::<_, String>(9)?, "created_at": r.get::<_, i64>(10)?, "updated_at": r.get::<_, i64>(11)?, "owner_id": r.get::<_, String>(12)?, "version": r.get::<_, String>(13)?, "merged": r.get::<_, i64>(14)? != 0}))
})
.optional()?)
}
@@ -1512,7 +1514,7 @@ impl Store {
/// Update the given columns (whitelisted) of an issue.
pub fn factory_issue_set(&self, repo: &str, number: i64, fields: &[(&str, Value)]) -> Result<()> {
const COLS: [&str; 11] = ["title", "state", "attempts", "rounds", "last_comment", "scenarios", "branch", "pr_url", "note", "author", "version"];
const COLS: [&str; 12] = ["title", "state", "attempts", "rounds", "last_comment", "scenarios", "branch", "pr_url", "note", "author", "version", "merged"];
let conn = self.conn.lock().unwrap();
for (k, v) in fields {
if !COLS.contains(k) {
+3 -3
View File
@@ -130,7 +130,7 @@ impl Bot {
}
async fn call(&self, method: &str, body: Value) -> Result<Value> {
let resp = crate::provider::http_client().post(self.url(method)).timeout(Duration::from_secs(60)).json(&body).send().await.context("telegram request failed")?;
let resp = crate::provider::http_client().post(self.url(method)).timeout(Duration::from_secs(60)).json(&body).send().await.map_err(|e| e.without_url()).context("telegram request failed")?;
let status = resp.status();
let v: Value = resp.json().await.unwrap_or_else(|_| json!({}));
if v["ok"].as_bool() != Some(true) {
@@ -174,7 +174,7 @@ impl Bot {
if let Some(c) = caption {
form = form.text("caption", c.chars().take(1000).collect::<String>());
}
let v: Value = crate::provider::http_client().post(self.url("sendPhoto")).timeout(Duration::from_secs(120)).multipart(form).send().await?.json().await?;
let v: Value = crate::provider::http_client().post(self.url("sendPhoto")).timeout(Duration::from_secs(120)).multipart(form).send().await.map_err(|e| e.without_url())?.json().await.map_err(|e| e.without_url())?;
if v["ok"].as_bool() != Some(true) {
bail!("telegram sendPhoto: {}", v["description"].as_str().unwrap_or("error"));
}
@@ -186,7 +186,7 @@ impl Bot {
let f = self.call("getFile", json!({"file_id": file_id})).await?;
let path = f["file_path"].as_str().context("telegram file without path")?.to_string();
let url = format!("{}/file/bot{}/{path}", api_base(), self.token);
let bytes = crate::provider::http_client().get(url).timeout(Duration::from_secs(120)).send().await?.error_for_status()?.bytes().await?;
let bytes = crate::provider::http_client().get(url).timeout(Duration::from_secs(120)).send().await.map_err(|e| e.without_url())?.error_for_status().map_err(|e| e.without_url())?.bytes().await.map_err(|e| e.without_url())?;
Ok((bytes.to_vec(), path))
}
}
+214 -3
View File
@@ -30,6 +30,32 @@ use tokio::process::Command;
use tokio::task::JoinHandle;
const LABEL: &str = "codecraft.testrunner=1";
const CACHE_LABEL: &str = "codecraft.testrunner.cache=1";
/// What every environment container runs: link the shared directories, restore a matching seed, run
/// `install`, store a new seed (only after a successful install, so it is pristine), start the app.
const FALLBACK_IMAGE: &str = "node:24-bookworm";
const ENTRY_SCRIPT: &str = r#"cd /app
hit=0
if [ -d /cache ]; then
for d in $CC_CACHE_DIRS; do mkdir -p "/cache/dirs/$d" "$(dirname "$d")" && rm -rf "$d" && ln -s "/cache/dirs/$d" "$d"; done
if [ -d /usr/local/cargo ]; then for d in registry git; do mkdir -p "/cache/cargo/$d"; rm -rf "/usr/local/cargo/$d"; ln -s "/cache/cargo/$d" "/usr/local/cargo/$d"; done; fi
if [ -n "$CC_SEED_KEY" ]; then for p in $CC_SEED_PATHS; do if [ -e "/cache/seed/$CC_SEED_KEY/$p" ]; then mkdir -p "$(dirname "$p")" && cp -a "/cache/seed/$CC_SEED_KEY/$p" "$p" && hit=1 && echo "[runner] restored $p from the cache"; fi; done; fi
fi
if [ -n "$CC_SEED_KEY" ]; then if [ "$hit" = 1 ]; then echo "[runner] seed $CC_SEED_KEY: hit"; else echo "[runner] seed $CC_SEED_KEY: miss"; fi; fi
t0=$(date +%s); st=$(date -u '+%Y-%m-%d %H:%M:%S')
if [ -n "$CC_INSTALL" ]; then sh -c "$CC_INSTALL" || exit 1; fi
echo "[runner] install took $(( $(date +%s) - t0 )) s"
pk=$(awk -v s="$st" '$3=="install" && ($1" "$2)>=s {sub(/:.*/,"",$4); print $4}' /var/log/dpkg.log 2>/dev/null | sort -u | head -40 | tr '\n' ' ')
if [ -n "$pk" ]; then echo "[runner] apt installed: $pk"; fi
if [ -d /cache ] && [ -n "$CC_SEED_KEY" ] && [ ! -d "/cache/seed/$CC_SEED_KEY" ]; then
t="/cache/seed/.tmp-$$"; rm -rf "$t"; mkdir -p "$t"; ok=1
for p in $CC_SEED_PATHS; do if [ -e "$p" ]; then mkdir -p "$t/$(dirname "$p")" && cp -a "$p" "$t/$p" || ok=0; fi; done
if [ "$ok" = 1 ]; then mv "$t" "/cache/seed/$CC_SEED_KEY" && echo "[runner] stored the seed $CC_SEED_KEY"; else rm -rf "$t"; fi
ls -1t /cache/seed 2>/dev/null | grep -v '^\.tmp' | tail -n +4 | while read -r o; do rm -rf "/cache/seed/$o"; done
fi
exec sh -c "$CC_START""#;
// --- what a repository asks for (.factory/setup.json) ------------------------------------
@@ -41,6 +67,29 @@ pub struct Service {
pub env: BTreeMap<String, String>,
}
/// What stays between runs of one project (kept in a Docker volume of the runner).
///
/// * `dirs`: directories of the sources that persist and are shared by all runs (downloads, caches –
/// inputs only: whatever lands there is visible to the next run).
/// * `seed`: expensive *results* of `install` (e.g. a built disk image). They are stored after a successful
/// `install` under a key made from the image, the install command, the seed paths and the contents of the
/// `key` files/directories, and copied into fresh containers whenever that key matches – so a run never
/// sees changes of an earlier run, and a change of the listed sources builds the seed anew.
///
/// Tool caches (npm, yarn, pip, Go, Cargo registry and target directory) are always shared per project
/// unless `"cache": false`.
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
pub struct CacheCfg {
#[serde(default)]
pub disabled: bool,
#[serde(default)]
pub dirs: Vec<String>,
#[serde(default)]
pub seed_paths: Vec<String>,
#[serde(default)]
pub seed_key: Vec<String>,
}
/// The request to start an environment.
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
pub struct StartReq {
@@ -63,6 +112,11 @@ pub struct StartReq {
/// How long to wait until the port answers (seconds, default 300).
#[serde(default)]
pub ready_secs: u64,
/// Stable name of the project: its cache lives in the volume `cc-cache-<cache_id>`. Empty = no cache.
#[serde(default)]
pub cache_id: String,
#[serde(default)]
pub cache: CacheCfg,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -110,9 +164,19 @@ pub fn parse_setup(text: &str) -> Option<StartReq> {
env: strs("env"),
services,
ready_secs: v["ready_seconds"].as_u64().unwrap_or(0),
cache_id: String::new(),
cache: parse_cache(&v["cache"]),
})
}
fn parse_cache(v: &Value) -> CacheCfg {
let list = |x: &Value| -> Vec<String> { x.as_array().map(|a| a.iter().filter_map(|s| s.as_str().map(|s| s.trim().trim_end_matches('/').to_string())).filter(|s| !s.is_empty()).collect()).unwrap_or_default() };
if v.as_bool() == Some(false) {
return CacheCfg { disabled: true, ..Default::default() };
}
CacheCfg { disabled: false, dirs: list(&v["dirs"]), seed_paths: list(&v["seed"]["paths"]), seed_key: list(&v["seed"]["key"]) }
}
/// Port of `http://host:1234/path` (80/443 by scheme when missing).
pub fn port_of(url: &str) -> Option<u16> {
let (scheme, rest) = url.trim().split_once("://")?;
@@ -132,6 +196,61 @@ fn image_ok(s: &str) -> bool {
ident_ok(s, "._/:@-") && !s.starts_with('-')
}
/// A path inside the sources: relative, no `..`, only plain characters (it ends up in a shell loop).
fn rel_ok(p: &str) -> bool {
ident_ok(p, "._/-") && !p.starts_with('/') && !p.starts_with('-') && !p.split('/').any(|c| c.is_empty() || c == "..") && !p.split('/').any(|c| c == ".git")
}
/// Key of a seed: image, install command, seed paths and the contents of the key files (directories: recursively).
pub fn seed_key(work: &Path, image: &str, req: &StartReq) -> Option<String> {
use sha2::{Digest, Sha256};
let c = &req.cache;
if c.disabled || c.seed_paths.is_empty() {
return None;
}
fn walk(base: &Path, rel: &Path, out: &mut Vec<std::path::PathBuf>) {
let full = base.join(rel);
if full.is_dir() {
let mut kids: Vec<_> = std::fs::read_dir(&full).map(|d| d.filter_map(|e| e.ok()).map(|e| e.file_name()).collect()).unwrap_or_default();
kids.sort();
for k in kids {
if k == ".git" || k == "node_modules" {
continue;
}
walk(base, &rel.join(k), out);
}
} else if full.is_file() {
out.push(rel.to_path_buf());
}
}
let mut h = Sha256::new();
for part in [image, &req.install, &c.seed_paths.join("\n"), &req.dockerfile] {
h.update(part.as_bytes());
h.update([0]);
}
let mut files = Vec::new();
let mut keys = c.seed_key.clone();
keys.sort();
for k in &keys {
h.update(k.as_bytes());
h.update([1]);
walk(work, Path::new(k), &mut files);
}
let mut total = 0u64;
for f in files {
let data = std::fs::read(work.join(&f)).ok()?;
total += data.len() as u64;
if total > 200 << 20 {
return None;
}
h.update(f.to_string_lossy().as_bytes());
h.update([2]);
h.update(&data);
}
let d = h.finalize();
Some(d.iter().take(10).map(|b| format!("{b:02x}")).collect())
}
fn env_ok(m: &BTreeMap<String, String>) -> bool {
m.len() <= 64 && m.iter().all(|(k, v)| k.chars().next().is_some_and(|c| c.is_ascii_alphabetic() || c == '_') && ident_ok(k, "_") && v.len() <= 4096 && !v.contains('\0'))
}
@@ -158,6 +277,16 @@ fn validate(req: &StartReq, factory_dir: &Path) -> Result<PathBuf> {
if !env_ok(&req.env) {
bail!("invalid environment variable");
}
if !req.cache_id.is_empty() && !ident_ok(&req.cache_id, "-_.") {
bail!("invalid cache id");
}
let c = &req.cache;
if c.dirs.len() > 16 || c.seed_paths.len() > 8 || c.seed_key.len() > 32 || !c.dirs.iter().chain(&c.seed_paths).chain(&c.seed_key).all(|p| rel_ok(p)) {
bail!("invalid cache path (relative, letters, digits and ._-/ only)");
}
if !c.seed_paths.is_empty() && c.seed_key.is_empty() {
bail!("cache.seed needs a key (the sources the seed depends on)");
}
let root = factory_dir.canonicalize().with_context(|| format!("factory area {} is not mounted", factory_dir.display()))?;
let work = Path::new(&req.work).canonicalize().context("source directory not found")?;
if !work.starts_with(&root) || !work.is_dir() {
@@ -230,7 +359,7 @@ pub async fn serve() -> Result<()> {
ports: (lo, hi),
memory: std::env::var("RUNNER_MEMORY").unwrap_or_else(|_| "2g".into()),
cpus: std::env::var("RUNNER_CPUS").unwrap_or_else(|_| "2".into()),
default_image: std::env::var("RUNNER_DEFAULT_IMAGE").unwrap_or_else(|_| "node:22-bookworm".into()),
default_image: std::env::var("RUNNER_DEFAULT_IMAGE").unwrap_or_else(|_| "git.familie-zink.org/zink/codecraft-testbase:latest".into()),
max_age: Duration::from_secs(60 * std::env::var("RUNNER_MAX_MINUTES").ok().and_then(|s| s.parse().ok()).unwrap_or(90)),
me: std::env::var("RUNNER_SELF").or_else(|_| std::env::var("HOSTNAME")).unwrap_or_default(),
envs: Mutex::new(HashMap::new()),
@@ -254,6 +383,7 @@ pub async fn serve() -> Result<()> {
.route("/v1/envs", post(start_env))
.route("/v1/envs/{id}", delete(stop_env))
.route("/v1/envs/{id}/log", get(log_env))
.route("/v1/cache/{id}", delete(clear_cache))
.with_state(runner);
let bind = std::env::var("RUNNER_BIND").unwrap_or_else(|_| "0.0.0.0:8788".into());
let l = TcpListener::bind(&bind).await?;
@@ -312,6 +442,7 @@ async fn start_env(State(r): State<Arc<Runner>>, h: HeaderMap, Json(req): Json<S
}
async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Result<Started> {
let began = Instant::now();
let net = format!("cc-run-{id}");
let app = format!("cc-run-{id}");
// Register first, so a failure at any step is cleaned up by stop().
@@ -331,7 +462,7 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
r.envs.lock().unwrap().get_mut(id).unwrap().containers.push(cname);
}
let image = if req.dockerfile.is_empty() {
if req.image.is_empty() { r.default_image.clone() } else { req.image.clone() }
if req.image.is_empty() { default_image_or_fallback(&r.default_image).await } else { req.image.clone() }
} else {
let tag = format!("cc-run-{id}");
let df = work.join(&req.dockerfile);
@@ -350,12 +481,42 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
a.push("-e".into());
a.push(format!("{k}={v}"));
}
// Per-project cache volume: tool caches, shared download directories and seeds (see CacheCfg).
let cached = !req.cache_id.is_empty() && !req.cache.disabled;
if cached {
let vol = format!("cc-cache-{}", req.cache_id);
docker(&["volume", "create", "--label", CACHE_LABEL, &vol]).await.context("cache volume")?;
a.push("-v".into());
a.push(format!("{vol}:/cache"));
for (k, v) in [
("npm_config_cache", "/cache/npm"),
("YARN_CACHE_FOLDER", "/cache/yarn"),
("PIP_CACHE_DIR", "/cache/pip"),
("GOMODCACHE", "/cache/go/mod"),
("GOCACHE", "/cache/go/build"),
("CARGO_TARGET_DIR", "/cache/target"),
("XDG_CACHE_HOME", "/cache/xdg"),
] {
if !req.env.contains_key(k) {
a.push("-e".into());
a.push(format!("{k}={v}"));
}
}
a.push("-e".into());
a.push(format!("CC_CACHE_DIRS={}", req.cache.dirs.join(" ")));
if let Some(key) = seed_key(work, &image, req) {
a.push("-e".into());
a.push(format!("CC_SEED_KEY={key}"));
a.push("-e".into());
a.push(format!("CC_SEED_PATHS={}", req.cache.seed_paths.join(" ")));
}
}
a.push("-e".into());
a.push(format!("CC_INSTALL={}", req.install));
a.push("-e".into());
a.push(format!("CC_START={}", req.start));
a.push(image);
a.extend(["sh", "-c", r#"if [ -n "$CC_INSTALL" ]; then sh -c "$CC_INSTALL" || exit 1; fi; exec sh -c "$CC_START""#].map(String::from));
a.extend(["sh", "-c", ENTRY_SCRIPT].map(String::from));
let refs: Vec<&str> = a.iter().map(String::as_str).collect();
docker(&refs).await.context("docker create")?;
// Copy the sources in (without .git); the container never sees the host directory.
@@ -390,6 +551,11 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
}
tokio::time::sleep(Duration::from_millis(700)).await;
}
// Report what the cache brought: seed hit/miss, install time, total time until the app answered.
let facts: Vec<String> = logs(&app).await.lines().filter(|l| l.starts_with("[runner] seed ") || l.starts_with("[runner] install took") || l.starts_with("[runner] apt installed")).map(|l| l.trim_start_matches("[runner] ").to_string()).collect();
let took = began.elapsed().as_secs();
let cache = if cached { "on" } else { "off" };
tracing::info!("test env {id} ({}) ready after {took} s; cache {cache}{}{}", req.cache_id, if facts.is_empty() { "" } else { "; " }, facts.join("; "));
let (listener, port) = bind_forward(r).await?;
let (target, tport) = (ip, req.port);
let fwd = tokio::spawn(async move {
@@ -410,6 +576,15 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
Ok(Started { id: id.to_string(), port })
}
/// The shared base image; when it can neither be found nor pulled, fall back to plain Node so runs still work.
async fn default_image_or_fallback(img: &str) -> String {
if docker(&["image", "inspect", img]).await.is_ok() || docker(&["pull", "-q", img]).await.is_ok() {
return img.to_string();
}
tracing::warn!("test runner: base image {img} is not available, using {FALLBACK_IMAGE}");
FALLBACK_IMAGE.to_string()
}
async fn logs(container: &str) -> String {
match Command::new("docker").args(["logs", "--tail", "400", container]).output().await {
Ok(o) => format!("{}{}", String::from_utf8_lossy(&o.stdout), String::from_utf8_lossy(&o.stderr)),
@@ -443,6 +618,16 @@ async fn stop_env(State(r): State<Arc<Runner>>, h: HeaderMap, AxPath(id): AxPath
Ok(Json(json!({"ok": true})))
}
/// Forget the cache of a project (fails while an environment of it is running).
async fn clear_cache(State(r): State<Arc<Runner>>, h: HeaderMap, AxPath(id): AxPath<String>) -> Resp<Json<Value>> {
authed(&r, &h)?;
if !ident_ok(&id, "-_.") {
return Err((StatusCode::BAD_REQUEST, "invalid cache id".into()));
}
docker(&["volume", "rm", &format!("cc-cache-{id}")]).await.map_err(|e| (StatusCode::CONFLICT, format!("{e:#}")))?;
Ok(Json(json!({"ok": true})))
}
#[derive(Deserialize)]
struct LogQ {
tail: Option<usize>,
@@ -574,6 +759,32 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn cache_config_and_seed_key() {
let r = parse_setup(r#"{"start":"x","port":1,"cache":{"dirs":["build/downloads/"],"seed":{"paths":["data/ubuntu.ext4"],"key":["guest","package-lock.json"]}}}"#).unwrap();
assert_eq!(r.cache.dirs, vec!["build/downloads"]);
assert_eq!(r.cache.seed_key, vec!["guest", "package-lock.json"]);
assert!(parse_setup(r#"{"start":"x","port":1,"cache":false}"#).unwrap().cache.disabled);
assert!(!parse_setup(r#"{"start":"x","port":1}"#).unwrap().cache.disabled);
assert!(rel_ok("build/downloads") && !rel_ok("../x") && !rel_ok("/etc") && !rel_ok("a b") && !rel_ok("a/.git/b") && !rel_ok("a//b"));
// The key follows the contents of the key files, not of anything else.
let dir = std::env::temp_dir().join(format!("ccs-{}", std::process::id()));
std::fs::create_dir_all(dir.join("guest")).unwrap();
std::fs::write(dir.join("guest/a.c"), "one").unwrap();
std::fs::write(dir.join("other.txt"), "x").unwrap();
let mut req = r.clone();
req.install = "npm ci".into();
let k1 = seed_key(&dir, "node:24", &req).unwrap();
std::fs::write(dir.join("other.txt"), "changed").unwrap();
assert_eq!(seed_key(&dir, "node:24", &req).unwrap(), k1);
std::fs::write(dir.join("guest/a.c"), "two").unwrap();
assert_ne!(seed_key(&dir, "node:24", &req).unwrap(), k1);
assert_ne!(seed_key(&dir, "node:22", &req).unwrap(), seed_key(&dir, "node:24", &req).unwrap());
req.cache.seed_paths.clear();
assert!(seed_key(&dir, "node:24", &req).is_none());
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn tokens_compare() {
assert!(eq_const("abc", "abc"));
+976 -1
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -21,6 +21,7 @@
"@xterm/addon-fit": "^0.11.0",
"@xterm/addon-web-links": "^0.12.0",
"@xterm/xterm": "^6.0.0",
"antd": "^6.7.2",
"codemirror": "^6.0.2",
"occt-import-js": "^0.0.23",
"react": "^19.3.1",
+11 -12
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useState } from "react";
import { patch } from "../api";
import { toast } from "../dialogs";
@@ -38,8 +40,7 @@ export function ChatSkillsDialog({ sessionId, cwd, active, onClose }: { sessionI
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal draft-modal" role="dialog" aria-label={t("skills.chatTitle")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} className="draft-modal" role="dialog" aria-label={t("skills.chatTitle")}>
<h3>{t("skills.chatTitle")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>
{t("skills.chatHint")}
@@ -50,31 +51,29 @@ export function ChatSkillsDialog({ sessionId, cwd, active, onClose }: { sessionI
<div className="empty">{t("skills.empty")}</div>
) : (
<>
{all.length > 6 && <input autoFocus style={{ width: "100%" }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
{all.length > 6 && <Input autoFocus style={{ width: "100%" }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
<div className="issue-list">
{shown.map((s) => (
<label key={s.name} className="row" style={{ gap: 8, alignItems: "flex-start", padding: "2px 0" }}>
<input type="checkbox" checked={picked.includes(s.name)} onChange={() => toggle(s.name)} />
<Checkbox key={s.name} className="row" style={{ gap: 8, alignItems: "flex-start", padding: "2px 0" }} checked={picked.includes(s.name)} onChange={() => toggle(s.name)}>
<span>
<code>{s.name}</code>
{s.files.length > 0 && <span className="hint"> · {t("skills.files", { n: s.files.length })}</span>}
<div className="hint">{s.description}</div>
</span>
</label>
</Checkbox>
))}
</div>
{picked.length > 4 && <div className="notice">{t("skills.manyActive")}</div>}
</>
)}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
<button onClick={onClose} disabled={busy}>
<Button onClick={onClose} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={() => void save()} disabled={busy}>
</Button>
<Button type="primary" onClick={() => void save()} disabled={busy}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+13 -12
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
import { del, get, post, put } from "../api";
import { confirmDialog, toast } from "../dialogs";
@@ -132,30 +133,30 @@ export function ChatTabBar({ state }: { state: Tabs }) {
</button>
{terms.map((x, i) => (
<span key={x.id} className={`chat-tab ${tab === x.id ? "active" : ""} ${x.alive ? "" : "dead"}`}>
<button role="tab" aria-selected={tab === x.id} className="ghost" onClick={() => setTab(x.id)} title={x.cwd}>
<Button type="text" role="tab" aria-selected={tab === x.id} onClick={() => setTab(x.id)} title={x.cwd}>
<Icon name="terminal" /> {t("terminal.tab", { n: i + 1 })}
</button>
<button className="ghost close" onClick={() => void closeTerminal(x, i + 1)} aria-label={t("terminal.close")} title={t("terminal.close")}>
</Button>
<Button type="text" className="close" onClick={() => void closeTerminal(x, i + 1)} aria-label={t("terminal.close")} title={t("terminal.close")}>
<Icon name="close" size={12} />
</button>
</Button>
</span>
))}
{files.map((f) => (
<span key={f.id} className={`chat-tab ${tab === f.id ? "active" : ""}`}>
<button role="tab" aria-selected={tab === f.id} className="ghost" onClick={() => setTab(f.id)} title={f.dir}>
<Button type="text" role="tab" aria-selected={tab === f.id} onClick={() => setTab(f.id)} title={f.dir}>
<Icon name="folder" /> {basename(f.dir)}
</button>
<button className="ghost close" onClick={() => closeFiles(f.id)} aria-label={t("files.closeTab")} title={t("files.closeTab")}>
</Button>
<Button type="text" className="close" onClick={() => closeFiles(f.id)} aria-label={t("files.closeTab")} title={t("files.closeTab")}>
<Icon name="close" size={12} />
</button>
</Button>
</span>
))}
<button className="ghost chat-tab-add" onClick={() => void openTerminal()} title={t("terminal.new")} aria-label={t("terminal.new")}>
<Button type="text" className="chat-tab-add" onClick={() => void openTerminal()} title={t("terminal.new")} aria-label={t("terminal.new")}>
<Icon name="plus" /> <Icon name="terminal" />
</button>
<button className="ghost chat-tab-add" onClick={openFiles} title={t("files.newTab")} aria-label={t("files.newTab")}>
</Button>
<Button type="text" className="chat-tab-add" onClick={openFiles} title={t("files.newTab")} aria-label={t("files.newTab")}>
<Icon name="plus" /> <Icon name="folder" />
</button>
</Button>
</div>
);
}
+40 -38
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { DraftBar, IssueBar, isDraftChat, isIssueChat } from "./FactoryDraft";
import { takePrefill } from "../share";
import { Icon } from "./Icon";
@@ -201,21 +202,21 @@ function ChatSearch({ sessionId, onPick, onClose }: { sessionId: string; onPick:
<div className="chat-search" role="search">
<div className="row">
<Icon name="search" />
<input autoFocus value={q} placeholder={t("chat.searchPlaceholder")} onChange={(e) => setQ(e.target.value)} onKeyDown={(e) => e.key === "Escape" && onClose()} aria-label={t("chat.search")} />
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
<Input autoFocus value={q} placeholder={t("chat.searchPlaceholder")} onChange={(e) => setQ(e.target.value)} onKeyDown={(e) => e.key === "Escape" && onClose()} aria-label={t("chat.search")} />
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</Button>
</div>
{hits && (
<div className="chat-search-hits">
<div className="hint">{hits.length ? t("chat.searchHits", { n: hits.length }) : t("chat.searchNone")}</div>
{hits.map((h) => (
<button key={h.id} onClick={() => onPick(h.id)}>
<Button key={h.id} onClick={() => onPick(h.id)}>
<span className="who">
{t(h.role === "assistant" ? "chat.agent" : "chat.you")} · {new Date(h.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
</span>
<span className="snippet">{h.snippet}</span>
</button>
</Button>
))}
</div>
)}
@@ -535,9 +536,9 @@ function OlderLoader({ sessionId, afterSummary, scrollRef }: { sessionId: string
{loading ? (
<Spinner small />
) : (
<button className="small ghost" onClick={() => void load()}>
<Button type="text" size="small" onClick={() => void load()}>
<Icon name="arrow-up" /> {t(afterSummary ? "chat.showBeforeSummary" : "chat.loadOlder")}
</button>
</Button>
)}
</div>
);
@@ -719,6 +720,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
return () => ro.disconnect();
}, [hasSession, sessionId]);
// Before the early returns: a chat that is deleted while open must render the same hooks.
const [rewinding, setRewinding] = useState<Message>();
if (loadError) return <div className="empty">{loadError}</div>;
if (!session) return <div className="empty">{t("common.loading")}</div>;
@@ -762,7 +766,6 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
};
const [rewinding, setRewinding] = useState<Message>();
const rewind = (m: Message) => setRewinding(m);
rewindRef.current = rewind;
const rewindDone = async () => {
@@ -834,9 +837,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
return (
<ChatCtx.Provider value={{ sessionId, canFork: !session.parent_id && !readOnly && !busy, canReply: !readOnly }}>
<div className="topbar" data-color={session.color}>
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1 onDoubleClick={() => !readOnly && setEditingTitle(true)} title={readOnly ? undefined : t("chat.renameHint")}>
{session.parent_id && (
@@ -847,9 +850,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
{session.icon && <Icon name={session.icon} className="chat-icon" />}
{session.title || t("session.untitled")}
{!readOnly && (
<button className="ghost small title-edit" onClick={() => setEditingTitle(true)} title={t("rename.title")} aria-label={t("rename.title")}>
<Button type="text" size="small" className="title-edit" onClick={() => setEditingTitle(true)} title={t("rename.title")} aria-label={t("rename.title")}>
<Icon name="edit" />
</button>
</Button>
)}
</h1>
<div className="path">{session.cwd}</div>
@@ -886,27 +889,27 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
{!readOnly && (
<>
{!session.parent_id && (
<button className="small ghost hide-mobile" onClick={() => setSharing(true)} title={t("share.title")}>
<Button type="text" size="small" className="hide-mobile" onClick={() => setSharing(true)} title={t("share.title")}>
<Icon name="share" />
</button>
</Button>
)}
<button
className="small ghost hide-mobile"
<Button type="text" size="small"
className="hide-mobile"
onClick={() => void tabs.openTerminal()}
title={t("terminal.here")}
>
<Icon name="terminal" />
</button>
<button className={`small ghost ${searching ? "active" : ""}`} onClick={() => setSearching(!searching)} title={t("chat.search")} aria-label={t("chat.search")}>
</Button>
<Button type="text" size="small" className={searching ? "active" : ""} onClick={() => setSearching(!searching)} title={t("chat.search")} aria-label={t("chat.search")}>
<Icon name="search" />
</button>
<button className="small ghost hide-mobile" onClick={tabs.openFiles} title={t("files.newTab")}>
</Button>
<Button type="text" size="small" className="hide-mobile" onClick={tabs.openFiles} title={t("files.newTab")}>
<Icon name="folder" />
</button>
</Button>
{!session.parent_id && (
<button className="small ghost hide-mobile" onClick={forkSession} disabled={busy} title={t("chat.fork")}>
<Button type="text" size="small" className="hide-mobile" onClick={forkSession} disabled={busy} title={t("chat.fork")}>
<Icon name="fork" />
</button>
</Button>
)}
<details className="menu-pop">
<summary className="small ghost" title={t("chat.more")} aria-label={t("chat.more")}>
@@ -1021,18 +1024,18 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
)}
</div>
</details>
<button className="small ghost hide-mobile" onClick={() => post(`/sessions/${sessionId}/compact`).catch((e) => toast(e.message))} disabled={busy} title={t("command.compact")}>
<Button type="text" size="small" className="hide-mobile" onClick={() => post(`/sessions/${sessionId}/compact`).catch((e) => toast(e.message))} disabled={busy} title={t("command.compact")}>
<Icon name="compact" />
</button>
<button className="small ghost danger hide-mobile" onClick={remove} title={t("chat.delete")}>
</Button>
<Button type="text" danger size="small" className="hide-mobile" onClick={remove} title={t("chat.delete")}>
<Icon name="trash" />
</button>
</Button>
</>
)}
{onClosePane && (
<button className="small ghost" onClick={onClosePane} title={t("chat.closePane")} aria-label={t("chat.closePane")}>
<Button type="text" size="small" onClick={onClosePane} title={t("chat.closePane")} aria-label={t("chat.closePane")}>
<Icon name="close" />
</button>
</Button>
)}
</div>
{gallery && (
@@ -1124,33 +1127,32 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
{errors?.map((e) => (
<div key={e.id} className="error-box" role="alert">
<span>{e.message}</span>
<button className="small ghost" onClick={() => dismissError(sessionId, e.id)} aria-label={t("common.close")}>
<Button type="text" size="small" onClick={() => dismissError(sessionId, e.id)} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</Button>
</div>
))}
{session.agent === "plan" && !busy && lastIsAssistant && (
<div className="row" style={{ justifyContent: "center", margin: "12px 0" }}>
<button
className="primary"
<Button type="primary"
onClick={async () => {
await update({ agent: "build" });
await send(t("plan.implementPrompt"), []);
}}
>
{t("plan.implement")}
</button>
</Button>
</div>
)}
</div>
{(!following || scrolled) && (
<div className="jump-latest">
<button onClick={jumpPrevOwn} title={t("chat.jumpPrevOwn")} aria-label={t("chat.jumpPrevOwn")}>
<Button onClick={jumpPrevOwn} title={t("chat.jumpPrevOwn")} aria-label={t("chat.jumpPrevOwn")}>
<Icon name="arrow-up" />
</button>
{!following && <button className="primary" onClick={jumpToLatest} title={t("chat.jumpLatest")} aria-label={t("chat.jumpLatest")}>
</Button>
{!following && <Button type="primary" onClick={jumpToLatest} title={t("chat.jumpLatest")} aria-label={t("chat.jumpLatest")}>
<Icon name="arrow-down" />
</button>}
</Button>}
</div>
)}
</div>
+56 -29
View File
@@ -1,3 +1,5 @@
import { Button, Segmented } from "antd";
import { Select } from "../ui/Select";
import { TemplatePicker } from "./TemplatePicker";
import { Icon } from "./Icon";
import { formatSize, imageSrc } from "./FileFigure";
@@ -5,6 +7,8 @@ import { uploadBatch } from "../uploads";
import { useEffect, useMemo, useRef, useState } from "react";
import { useAgents, useFetch, useModels } from "../hooks";
import { useT, type Key } from "../i18n";
import { useStore } from "../store";
import { post } from "../api";
import type { ImageData, Session } from "../types";
import { ModelSelect } from "./ModelSelect";
import { EffortSelect } from "./Regenerate";
@@ -55,7 +59,7 @@ export function Composer({
busy: boolean;
text: string;
setText: (s: string) => void;
onSend: (text: string, images: ImageData[], effort?: string) => void;
onSend: (text: string, images: ImageData[], effort?: string) => void | Promise<void>;
onAbort: () => void;
onUpdate: (patch: Partial<Session>) => void;
}) {
@@ -145,11 +149,20 @@ export function Composer({
return [...mine, ...cmds].slice(0, 12);
}, [text, cmdData, snippets, t, mention, mentionHits]);
const send = () => {
// Messages waiting for the agent: a further Enter on the empty field (or Ctrl+Enter with text) delivers them at once.
const queued = useStore((s) => (s.queue[session.id] ?? []).length);
const force = () => post(`/sessions/${session.id}/queue/force`).catch((e) => toast(e.message));
const send = (thenForce = false) => {
if (!text.trim() && images.length === 0 && files.length === 0 && busy && queued > 0) {
void force();
return;
}
if ((!text.trim() && images.length === 0 && files.length === 0) || uploading > 0) return;
// Files are referenced by path; the agent reads them with its tools.
const refs = files.length ? `\n\n${t("composer.attachedFiles")}\n${files.map((f) => `- ${f.path} (${formatSize(f.size)})`).join("\n")}` : "";
onSend(`${text}${refs}`, images, effort);
const sent = onSend(`${text}${refs}`, images, effort);
if (thenForce && busy) void Promise.resolve(sent).then(force);
setEffort("");
setImages([]);
setFiles([]);
@@ -174,11 +187,22 @@ export function Composer({
return;
}
}
// Ctrl+J inserts a new line (like Shift+Enter, and like Ctrl+J / Shift+Enter in the terminal client).
if (e.key.toLowerCase() === "j" && e.ctrlKey && !e.altKey && !e.metaKey && !e.nativeEvent.isComposing) {
e.preventDefault();
const el = e.currentTarget as HTMLTextAreaElement;
const a = el.selectionStart ?? text.length;
const b = el.selectionEnd ?? a;
setText(`${text.slice(0, a)}\n${text.slice(b)}`);
requestAnimationFrame(() => ref.current?.setSelectionRange(a + 1, a + 1));
return;
}
// Enter sends on desktop; on touch devices Enter inserts a newline.
const touch = matchMedia("(pointer: coarse)").matches;
if (e.key === "Enter" && !e.shiftKey && !touch && !e.nativeEvent.isComposing) {
e.preventDefault();
send();
// Ctrl/Cmd+Enter while the agent works: queue the message and interrupt the step so it is read at once.
send(e.ctrlKey || e.metaKey);
}
if (e.key === "Escape" && busy) onAbort();
};
@@ -274,9 +298,9 @@ export function Composer({
<div className="att file" key={f.path} title={f.path}>
<span><Icon name="file" /> {f.name}</span>
<small>{formatSize(f.size)}</small>
<button onClick={() => removeFile(f.path)} aria-label={t("common.remove")}>
<Button onClick={() => removeFile(f.path)} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
</div>
))}
{uploading > 0 && (
@@ -287,9 +311,9 @@ export function Composer({
{images.map((img, i) => (
<div className="att" key={i}>
<img src={imageSrc(img)} alt="" />
<button onClick={() => setImages((cur) => cur.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Button onClick={() => setImages((cur) => cur.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
</div>
))}
</div>
@@ -330,7 +354,7 @@ export function Composer({
/>
<div className="composer-bar">
<div className="composer-options">
<select
<Select
className="mode-select"
value={session.agent}
onChange={(e) => onUpdate({ agent: e.target.value })}
@@ -343,18 +367,21 @@ export function Composer({
{a.name}
</option>
))}
</select>
</Select>
{session.agent === "craft" && (
<div className="mode-tabs" role="tablist" aria-label={t("craft.mode")} title={t("craft.modeHint")}>
<button className={session.clean_room !== false ? "active" : ""} onClick={() => onUpdate({ clean_room: true })}>
{t("craft.cleanRoom")}
</button>
<button className={session.clean_room === false ? "active deep" : ""} onClick={() => onUpdate({ clean_room: false })}>
{t("craft.deep")}
</button>
</div>
<Segmented
size="small"
aria-label={t("craft.mode")}
title={t("craft.modeHint")}
value={session.clean_room === false ? "deep" : "clean"}
onChange={(v) => onUpdate({ clean_room: v === "clean" })}
options={[
{ value: "clean", label: t("craft.cleanRoom") },
{ value: "deep", label: t("craft.deep") },
]}
/>
)}
<select
<Select
value={session.permission_mode}
onChange={(e) => onUpdate({ permission_mode: e.target.value as Session["permission_mode"] })}
title={t("composer.permissionMode")}
@@ -363,12 +390,12 @@ export function Composer({
<option value="default">{t("permissionMode.default")}</option>
<option value="accept_edits">{t("permissionMode.accept_edits")}</option>
<option value="bypass">{t("permissionMode.bypass")}</option>
</select>
</Select>
<ModelSelect value={session.model} onChange={(m) => onUpdate({ model: m })} title={t("composer.model")} />
{reasoning && <EffortSelect value={effort} onChange={setEffort} compact />}
<button className="ghost" style={{ padding: "3px 6px" }} onClick={() => setPicker(true)} title={t("templates.title")}>
<Button type="text" style={{ padding: "3px 6px" }} onClick={() => setPicker(true)} title={t("templates.title")}>
<Icon name="template" />
</button>
</Button>
{picker && (
<TemplatePicker
onClose={() => setPicker(false)}
@@ -379,15 +406,15 @@ export function Composer({
}}
/>
)}
<button
className={`ghost ${preview ? "active" : ""}`}
<Button
type="text" className={preview ? "active" : ""}
style={{ padding: "3px 6px" }}
onClick={() => setPreview(!preview)}
aria-pressed={preview}
title={t(preview ? "composer.previewEdit" : "composer.preview")}
>
<Icon name={preview ? "edit" : "eye"} />
</button>
</Button>
<VoiceButton onText={(d) => setText(text ? `${text.replace(/\s+$/, "")} ${d}` : d)} onInterim={setInterim} />
<label className="ghost" style={{ cursor: "pointer", padding: "3px 6px" }} title={t("composer.attach")}>
<Icon name="clip" />
@@ -396,13 +423,13 @@ export function Composer({
</div>
<div className="composer-actions">
{busy && (
<button className="danger" onClick={onAbort} title="Esc">
<Button danger onClick={onAbort} title="Esc">
<Icon name="stop" /> {t("composer.stop")}
</button>
</Button>
)}
<button className="primary" onClick={send} disabled={uploading > 0 || (!text.trim() && images.length === 0 && files.length === 0)}>
<Button type="primary" onClick={() => send()} disabled={uploading > 0 || (!text.trim() && images.length === 0 && files.length === 0)}>
{busy ? t("composer.queue") : t("composer.send")}
</button>
</Button>
</div>
</div>
</div>
+15 -13
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Select } from "../ui/Select";
import { useEffect, useState } from "react";
import { get } from "../api";
import { getLang, useT } from "../i18n";
@@ -132,44 +134,44 @@ export function CronBuilder({ value, onChange }: { value: string; onChange: (cro
<div className="cron-builder">
<div className="cron-modes" role="radiogroup" aria-label={t("cron.label")}>
{modes.map((m) => (
<button key={m} type="button" role="radio" aria-checked={s.mode === m} className={`chip-btn ${s.mode === m ? "active" : ""}`} onClick={() => set({ mode: m })}>
<Button key={m} role="radio" aria-checked={s.mode === m} size="small" shape="round" type={s.mode === m ? "primary" : "default"} onClick={() => set({ mode: m })}>
{t(`cron.mode.${m}` as const)}
</button>
</Button>
))}
</div>
<div className="cron-fields">
{s.mode === "minutes" && (
<label>
{t("cron.every")}
<select value={s.every} onChange={(e) => set({ every: Number(e.target.value) })}>
<Select value={s.every} onChange={(e) => set({ every: Number(e.target.value) })}>
{MINUTE_STEPS.map((n) => (
<option key={n} value={n}>
{n}
</option>
))}
</select>
</Select>
{t("cron.minutes")}
</label>
)}
{s.mode === "hourly" && (
<label>
{t("cron.atMinute")}
<input type="number" min={0} max={59} value={s.minute} onChange={(e) => set({ minute: Math.min(59, Math.max(0, Number(e.target.value) || 0)) })} />
<Input type="number" min={0} max={59} value={s.minute} onChange={(e) => set({ minute: Math.min(59, Math.max(0, Number(e.target.value) || 0)) })} />
</label>
)}
{s.mode === "weekly" && (
<div className="cron-days" role="group" aria-label={t("cron.days")}>
{WEEK.map((d) => (
<button
<Button
key={d}
type="button"
aria-pressed={s.days.includes(d)}
className={`chip-btn ${s.days.includes(d) ? "active" : ""}`}
size="small" shape="round" type={s.days.includes(d) ? "primary" : "default"}
title={dayName(d, "long")}
onClick={() => set({ days: s.days.includes(d) ? s.days.filter((x) => x !== d) : [...s.days, d] })}
>
{dayName(d, "short")}
</button>
</Button>
))}
<button type="button" className="link-btn" onClick={() => set({ days: [1, 2, 3, 4, 5] })}>
{t("cron.workdays")}
@@ -179,24 +181,24 @@ export function CronBuilder({ value, onChange }: { value: string; onChange: (cro
{s.mode === "monthly" && (
<label>
{t("cron.onDay")}
<select value={s.dom} onChange={(e) => set({ dom: Number(e.target.value) })}>
<Select value={s.dom} onChange={(e) => set({ dom: Number(e.target.value) })}>
{Array.from({ length: 31 }, (_, i) => i + 1).map((d) => (
<option key={d} value={d}>
{d}.
</option>
))}
</select>
</Select>
</label>
)}
{(s.mode === "daily" || s.mode === "weekly" || s.mode === "monthly") && (
<label>
{t("cron.at")}
<input type="time" value={s.time} onChange={(e) => e.target.value && set({ time: e.target.value })} />
<Input type="time" value={s.time} onChange={(e) => e.target.value && set({ time: e.target.value })} />
</label>
)}
{s.mode === "custom" && (
<label className="cron-custom">
<input className="mono" value={s.custom} placeholder="0 3 * * *" spellCheck={false} onChange={(e) => set({ custom: e.target.value })} />
<Input className="mono" value={s.custom} placeholder="0 3 * * *" spellCheck={false} onChange={(e) => set({ custom: e.target.value })} />
<small className="hint">{t("cron.customHint")}</small>
</label>
)}
+3 -3
View File
@@ -1,3 +1,4 @@
import { Checkbox } from "antd";
export function Diff({ diff }: { diff: string }) {
const lines = diff.replace(/\n+$/, "").split("\n");
return (
@@ -43,10 +44,9 @@ export function HunkDiff({ diff, selected, onToggle }: { diff: string; selected:
))}
{hunks.map((h, i) => (
<div key={i} className={`hunk-block ${selected[i] ? "" : "off"}`}>
<label className="hunk-head">
<input type="checkbox" checked={!!selected[i]} onChange={() => onToggle(i)} />
<Checkbox className="hunk-head" checked={!!selected[i]} onChange={() => onToggle(i)}>
<span>{h[0]}</span>
</label>
</Checkbox>
{h.slice(1).map((l, j) => (
<div key={j} className={l.startsWith("+") ? "add" : l.startsWith("-") ? "del" : ""}>
{l || " "}
+145 -108
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input, Segmented } from "antd";
import { Select } from "../ui/Select";
import { useEffect, useMemo, useState } from "react";
import { get, post, put } from "../api";
import { fmtCompact, fmtCost, fmtRelative, useT } from "../i18n";
@@ -78,6 +80,8 @@ interface Issue {
branch: string;
rounds: number;
/** Newest phase chat that still exists. */
/** The pull request is merged (merging comes after a positive acceptance, closing after the merge). */
merged?: boolean;
chat_session?: string;
chat_phase?: Phase;
created_at: number;
@@ -164,19 +168,17 @@ export function Factory({ onMenu, overlayId }: { onMenu: () => void; overlayId?:
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>{t("factory.title")}</h1>
</div>
<div className="segmented">
{(["overview", "settings"] as const).map((x) => (
<button key={x} className={tab === x ? "active" : ""} onClick={() => setTab(x)}>
{t(`factory.tab.${x}` as any)}
</button>
))}
</div>
<Segmented
value={tab}
onChange={(x) => setTab(x)}
options={(["overview", "settings"] as const).map((x) => ({ value: x, label: t(`factory.tab.${x}` as any) }))}
/>
</div>
<div className="page">
<div className="page-inner" style={{ maxWidth: tab === "overview" ? "none" : 1280 }}>
@@ -188,6 +190,20 @@ export function Factory({ onMenu, overlayId }: { onMenu: () => void; overlayId?:
);
}
/** A button inside an issue card (the card itself is a button, so this is a span with the button role). */
function CardAction({ children, onClick, title, primary, disabled }: { children: React.ReactNode; onClick: () => void; title?: string; primary?: boolean; disabled?: boolean }) {
const run = (e: React.SyntheticEvent) => {
e.stopPropagation();
e.preventDefault();
if (!disabled) onClick();
};
return (
<span role="button" tabIndex={disabled ? -1 : 0} aria-disabled={disabled} className={`factory-card-action ${primary ? "primary" : ""} ${disabled ? "disabled" : ""}`} title={title} onClick={run} onKeyDown={(e) => (e.key === "Enter" || e.key === " ") && run(e)}>
{children}
</span>
);
}
/** The factory's main switch, coloured by state: green = running, yellow = stopping, red = stopped. */
function PowerSwitch({ power, onToggle }: { power: Power; onToggle: (on: boolean) => void }) {
const t = useT();
@@ -357,13 +373,13 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
{recreate && <RecreateDialog onClose={() => setRecreate(false)} />}
<p>{t("factory.empty")}</p>
<div className="row" style={{ gap: 8, justifyContent: "center" }}>
<button className="primary" onClick={newProject} disabled={busy}>
<Button type="primary" onClick={newProject} disabled={busy}>
<Icon name="plus" /> {t("factory.newProject")}
</button>
<button onClick={() => setRecreate(true)} disabled={busy}>
</Button>
<Button onClick={() => setRecreate(true)} disabled={busy}>
<Icon name="search" /> {t("recreate.button")}
</button>
<button onClick={onSettings}>{t("factory.tab.settings")}</button>
</Button>
<Button onClick={onSettings}>{t("factory.tab.settings")}</Button>
</div>
</div>
);
@@ -402,20 +418,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const mergePr = async () => {
if (!selected || !pr) return;
if (!(await confirmDialog({ message: t("factory.mergeConfirm", { n: pr.number, method: t(`factory.merge.${prMethod}` as any) }) }))) return;
const prNo = (i: Issue) => Number(i.pr_url.replace(/\/$/, "").split("/").pop()) || 0;
/** Merge the pull request of an issue; only offered once the acceptance has passed. */
const mergeIssue = async (i: Issue, n = prNo(i)) => {
if (!n || i.state !== "done") return;
if (!(await confirmDialog({ message: t("factory.mergeConfirm", { n, method: t(`factory.merge.${prMethod}` as any) }) }))) return;
setBusy(true);
try {
await post("/factory/issues/pr/merge", { repo: selected.repo, number: selected.number, pr: pr.number, method: prMethod });
await post("/factory/issues/pr/merge", { repo: i.repo, number: i.number, pr: n, method: prMethod });
toast(t("factory.merged"));
await loadPr();
await reload();
} catch (e: any) {
toast(e.message);
} finally {
setBusy(false);
}
};
const mergePr = () => (selected && pr ? mergeIssue(selected, pr.number) : Promise.resolve());
const removeIssue = async () => {
if (!selected) return;
if (!(await confirmDialog({ message: t("factory.removeConfirm", { n: selected.number }), confirmLabel: t("factory.remove"), danger: true }))) return;
@@ -430,15 +450,16 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const closeIssue = async () => {
if (!selected) return;
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: selected.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
/** Close an issue; only offered once its pull request is merged. */
const closeIssueOf = async (i: Issue) => {
if (i.state !== "done" || !i.merged) return;
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: i.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
if (comment === null) return;
setBusy(true);
try {
await post("/factory/issues/close", { repo: selected.repo, number: selected.number, comment });
await post("/factory/issues/close", { repo: i.repo, number: i.number, comment });
toast(t("factory.closed"), "success");
setSel("");
if (selected && selected.number === i.number && selected.repo === i.repo) setSel("");
await reload();
} catch (e: any) {
toast(e.message);
@@ -446,6 +467,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const closeIssue = () => (selected ? closeIssueOf(selected) : Promise.resolve());
const phaseRunning = !!selected && ["review", "building", "testing"].includes(selected.state);
/** Master switch: a soft stop – no new agent starts, running ones finish their phase. */
const setPower = async (on: boolean) => {
@@ -493,7 +515,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
</div>
<div className="factory-repos">
<select className="factory-repo-select" value={repo} onChange={(e) => setRepo(e.target.value)} aria-label={t("factory.project")}>
<Select className="factory-repo-select" value={repo} onChange={(e) => setRepo(e.target.value)} aria-label={t("factory.project")}>
<option value="">
{t("factory.allRepos")} ({data.issues.length})
</option>
@@ -503,7 +525,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
{r.version ? ` · v${r.version}` : ""} ({data.issues.filter((i) => i.repo === r.url).length}){r.enabled ? "" : " – off"}
</option>
))}
</select>
</Select>
{(() => {
const r = data.repos.find((x) => x.url === repo);
if (!r) return null;
@@ -520,24 +542,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
</span>
);
})()}
<button className="small primary" onClick={newProject} disabled={busy}>
<Button type="primary" size="small" onClick={newProject} disabled={busy}>
<Icon name="plus" /> {t("factory.newProject")}
</button>
<button className="small" onClick={() => setRecreate(true)} disabled={busy} title={t("recreate.hint")}>
</Button>
<Button size="small" onClick={() => setRecreate(true)} disabled={busy} title={t("recreate.hint")}>
<Icon name="search" /> {t("recreate.button")}
</button>
<button className="small" onClick={() => issueChat("feature")} disabled={busy} title={t("issues.featureHint")}>
</Button>
<Button size="small" onClick={() => issueChat("feature")} disabled={busy} title={t("issues.featureHint")}>
<Icon name="sparkle" /> {t("issues.feature")}
</button>
<button className="small" onClick={() => issueChat("slice")} disabled={busy} title={t("issues.sliceHint")}>
</Button>
<Button size="small" onClick={() => issueChat("slice")} disabled={busy} title={t("issues.sliceHint")}>
<Icon name="sparkle" /> {t("issues.slice")}
</button>
<button className="small" onClick={startRelease} disabled={busy} title={t("release.hint")}>
</Button>
<Button size="small" onClick={startRelease} disabled={busy} title={t("release.hint")}>
<Icon name="download" /> {t("release.button")}
</button>
<button className="small" onClick={poll} disabled={busy} title={t("factory.pollNow")}>
</Button>
<Button size="small" onClick={poll} disabled={busy} title={t("factory.pollNow")}>
<Icon name="refresh" /> {t("factory.pollNow")}
</button>
</Button>
</div>
<div className="factory-board">
@@ -546,9 +568,9 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
{t("factory.col.backlog")} <span className="chip">{backlogShown.length}</span>
</h4>
{backlogShown.length > 1 && (
<button className="small" onClick={() => void enqueue(backlogShown.filter((i) => i.allowed))} disabled={busy || !backlogShown.some((i) => i.allowed)} title={t("factory.backlog.queueAllHint")}>
<Button size="small" onClick={() => void enqueue(backlogShown.filter((i) => i.allowed))} disabled={busy || !backlogShown.some((i) => i.allowed)} title={t("factory.backlog.queueAllHint")}>
<Icon name="plus" /> {t("factory.backlog.queueAll")}
</button>
</Button>
)}
{backlogShown.map((i) => (
<div key={`${i.repo}#${i.number}`} className="factory-card backlog">
@@ -558,9 +580,9 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
<a href={i.url || issueUrl(i.repo, i.number)} target="_blank" rel="noreferrer" title={i.title}>
<b>{i.title || `#${i.number}`}</b>
</a>
<button className="small" onClick={() => void enqueue([i])} disabled={busy || !i.allowed} title={i.allowed ? t("factory.backlog.queueHint") : t("factory.backlog.notAllowed", { user: i.author })}>
<Button size="small" onClick={() => void enqueue([i])} disabled={busy || !i.allowed} title={i.allowed ? t("factory.backlog.queueHint") : t("factory.backlog.notAllowed", { user: i.author })}>
<Icon name="plus" /> {t("factory.backlog.queue")}
</button>
</Button>
</div>
))}
{backlogShown.length === 0 && <span className="hint">{t("factory.backlog.empty")}</span>}
@@ -577,9 +599,11 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
const rs = runsOf(i);
const active = rs.find((r) => !r.ended_at);
const latest = active ?? rs[0];
// Claimed by a phase but no chat yet: checkout, and – for acceptance – installing and starting the app in its throw-away container.
const preparing = !active && ["review", "building", "testing"].includes(i.state);
const tokens = rs.reduce((a, r) => a + r.input_tokens + r.output_tokens, 0);
return (
<button key={`${i.repo}#${i.number}`} data-state={i.state} className={`factory-card ${sel === `${i.repo}#${i.number}` ? "active" : ""} ${active ? "running" : ""}`} onClick={() => setSel(sel === `${i.repo}#${i.number}` ? "" : `${i.repo}#${i.number}`)}>
<button key={`${i.repo}#${i.number}`} data-state={i.state} className={`factory-card ${sel === `${i.repo}#${i.number}` ? "active" : ""} ${active ? "running" : ""} ${preparing ? "preparing" : ""}`} onClick={() => setSel(sel === `${i.repo}#${i.number}` ? "" : `${i.repo}#${i.number}`)}>
<span className="factory-card-head">
<span className="hint">
{repoName(i.repo)} #{i.number}
@@ -608,13 +632,32 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
)}
</span>
<b>{i.title || `#${i.number}`}</b>
{latest && (
{preparing && (
<span className="hint" title={t("factory.preparing.hint")}>
<span className="factory-pulse prep" />
{i.state === "testing" ? t("factory.preparing.env") : t("factory.preparing.start")} · {fmtDuration(now - i.updated_at)}
</span>
)}
{latest && !preparing && (
<span className="hint">
{active && <span className="factory-pulse" />}
{t(`factory.phase.${latest.phase}` as any)} · {(latest.model || "").split("/").pop()} · {fmtDuration(runMs(latest, now))}
</span>
)}
{tokens > 0 && <span className="hint">{fmtCompact(tokens)} {t("factory.tokens")}</span>}
{i.state === "done" && (i.merged || prNo(i) > 0) && (
<span className="factory-card-actions">
{!i.merged ? (
<CardAction primary disabled={busy} title={t("factory.mergeHint")} onClick={() => void mergeIssue(i)}>
<Icon name="fork" /> {t("factory.mergeBtn")}
</CardAction>
) : (
<CardAction disabled={busy} title={t("factory.closeHint")} onClick={() => void closeIssueOf(i)}>
<Icon name="check" /> {t("factory.close")}
</CardAction>
)}
</span>
)}
</button>
);
})}
@@ -634,26 +677,26 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
{selected && !phaseRunning && (
<>
<span className="hint">{t("factory.restartAt")}</span>
<button className="small" onClick={() => restart("new")} disabled={busy}>
<Button size="small" onClick={() => restart("new")} disabled={busy}>
{t("factory.col.review")}
</button>
<button className="small" onClick={() => restart("approved")} disabled={busy}>
</Button>
<Button size="small" onClick={() => restart("approved")} disabled={busy}>
{t("factory.col.build")}
</button>
<button className="small" onClick={() => restart("qa")} disabled={busy || !selected.branch}>
</Button>
<Button size="small" onClick={() => restart("qa")} disabled={busy || !selected.branch}>
{t("factory.col.qa")}
</button>
</Button>
</>
)}
{selected && !["review", "building", "testing"].includes(selected.state) && (
<button className="small" onClick={removeIssue} disabled={busy} title={t("factory.removeHint")}>
<Button size="small" onClick={removeIssue} disabled={busy} title={t("factory.removeHint")}>
<Icon name="trash" /> {t("factory.remove")}
</button>
</Button>
)}
{selected && selected.state === "done" && (
<button className="small" onClick={closeIssue} disabled={busy}>
{selected && selected.state === "done" && selected.merged && (
<Button size="small" onClick={closeIssue} disabled={busy}>
<Icon name="check" /> {t("factory.close")}
</button>
</Button>
)}
{selected && (
<>
@@ -683,18 +726,18 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
</span>
)}
<span className="spacer" />
{pr.state === "open" && (
{pr.state === "open" && selected?.state === "done" && (
<>
<select value={prMethod} onChange={(e) => setPrMethod(e.target.value)} disabled={busy}>
<Select value={prMethod} onChange={(e) => setPrMethod(e.target.value)} disabled={busy}>
{["merge", "squash", "rebase"].map((m) => (
<option key={m} value={m}>
{t(`factory.merge.${m}` as any)}
</option>
))}
</select>
<button className="small primary" onClick={mergePr} disabled={busy || pr.mergeable === false}>
</Select>
<Button type="primary" size="small" onClick={mergePr} disabled={busy || pr.mergeable === false}>
{t("factory.mergeBtn")}
</button>
</Button>
</>
)}
</div>
@@ -742,9 +785,9 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
</td>
<td>{fmtCost(r.cost, "USD")}</td>
<td>
<button className="small" onClick={() => openFactoryChat(r.session_id)}>
<Button size="small" onClick={() => openFactoryChat(r.session_id)}>
<Icon name="eye" /> {t("factory.openChat")}
</button>
</Button>
</td>
</tr>
))}
@@ -782,14 +825,14 @@ function PhaseSkills({ value, onChange }: { value: string[]; onChange: (v: strin
</button>
))}
{rest.length > 0 && value.length < 10 && (
<select value="" onChange={(e) => e.target.value && onChange([...value, e.target.value])}>
<Select value="" onChange={(e) => e.target.value && onChange([...value, e.target.value])}>
<option value="">{t("factory.skillAdd")}</option>
{rest.map((s) => (
<option key={s.name} value={s.name} title={s.description}>
{s.name}
</option>
))}
</select>
</Select>
)}
</div>
<div className="hint">{t("factory.skillsHint")}</div>
@@ -808,33 +851,33 @@ function PhaseForm({ phase, value, onChange }: { phase: Phase; value: PhaseCfg;
</label>
<label>
<span>{t("factory.agent")}</span>
<select value={value.agent} onChange={(e) => onChange({ agent: e.target.value })}>
<Select value={value.agent} onChange={(e) => onChange({ agent: e.target.value })}>
<option value="codecraft">CodeCraft</option>
<option value="claude-code">Claude Code</option>
</select>
</Select>
</label>
<label>
<span>{t("factory.mode")}</span>
<select value={value.permission_mode} onChange={(e) => onChange({ permission_mode: e.target.value })}>
<Select value={value.permission_mode} onChange={(e) => onChange({ permission_mode: e.target.value })}>
{MODES.map((m) => (
<option key={m} value={m}>
{t(`permissionMode.${m}` as any)}
</option>
))}
</select>
</Select>
</label>
<label>
<span>{t("factory.timeout")}</span>
<input type="number" min={1} value={value.timeout_minutes} onChange={(e) => onChange({ timeout_minutes: Number(e.target.value) || 60 })} />
<Input type="number" min={1} value={value.timeout_minutes} onChange={(e) => onChange({ timeout_minutes: Number(e.target.value) || 60 })} />
</label>
<label>
<span>{t("factory.attempts")}</span>
<input type="number" min={1} max={10} value={value.max_attempts} title={t("factory.attemptsHint")} onChange={(e) => onChange({ max_attempts: Math.max(1, Number(e.target.value) || 1) })} />
<Input type="number" min={1} max={10} value={value.max_attempts} title={t("factory.attemptsHint")} onChange={(e) => onChange({ max_attempts: Math.max(1, Number(e.target.value) || 1) })} />
</label>
<PhaseSkills value={value.skills ?? []} onChange={(skills) => onChange({ skills })} />
<label>
<span>{t("factory.extraPrompt")}</span>
<textarea rows={3} value={value.extra_prompt} onChange={(e) => onChange({ extra_prompt: e.target.value })} />
<Input.TextArea rows={3} value={value.extra_prompt} onChange={(e) => onChange({ extra_prompt: e.target.value })} />
</label>
</div>
);
@@ -890,8 +933,7 @@ function FactorySettings() {
<div className="row" style={{ gap: 8, flexWrap: "wrap" }}>
<h3 style={{ margin: 0 }}>{c.name || KIND_NAME[c.kind]}</h3>
<span className="spacer" />
<button
className="small"
<Button size="small"
disabled={busy !== undefined}
onClick={() =>
act(`c${i}`, async () => {
@@ -904,9 +946,8 @@ function FactorySettings() {
}
>
{busy === `c${i}` ? <Spinner small /> : <Icon name="plug" />} {t("factory.testConn")}
</button>
<button
className="small"
</Button>
<Button size="small"
title={t("common.delete")}
aria-label={t("common.delete")}
onClick={async () => {
@@ -914,35 +955,35 @@ function FactorySettings() {
}}
>
<Icon name="trash" />
</button>
</Button>
</div>
<div className="factory-form">
<label>
<span>{t("factory.connName")}</span>
<input value={c.name} onChange={(e) => upConn(i, { name: e.target.value })} />
<Input value={c.name} onChange={(e) => upConn(i, { name: e.target.value })} />
</label>
<label>
<span>{t("factory.kind")}</span>
<select value={c.kind} onChange={(e) => upConn(i, { kind: e.target.value as Connection["kind"] })}>
<Select value={c.kind} onChange={(e) => upConn(i, { kind: e.target.value as Connection["kind"] })}>
{Object.entries(KIND_NAME).map(([k, n]) => (
<option key={k} value={k}>
{n}
</option>
))}
</select>
</Select>
</label>
<label>
<span>{t("factory.serviceUrl")}</span>
<input value={c.url} placeholder={URL_PLACEHOLDER[c.kind]} onChange={(e) => upConn(i, { url: e.target.value })} />
<Input value={c.url} placeholder={URL_PLACEHOLDER[c.kind]} onChange={(e) => upConn(i, { url: e.target.value })} />
</label>
<label>
<span>{t("factory.token")}</span>
<input type="password" autoComplete="new-password" value={c.token} placeholder={t("factory.tokenPlaceholder")} onChange={(e) => upConn(i, { token: e.target.value })} onFocus={(e) => c.token.startsWith("•") && e.currentTarget.select()} />
<Input.Password autoComplete="new-password" value={c.token} placeholder={t("factory.tokenPlaceholder")} onChange={(e) => upConn(i, { token: e.target.value })} onFocus={(e) => c.token.startsWith("•") && e.currentTarget.select()} />
<span className="hint">{c.token.startsWith("•") ? t("factory.tokenSet") : t(`factory.tokenHint.${c.kind}` as any)}</span>
</label>
<label>
<span>{t("factory.defaultOwner")}</span>
<input list={`orgs-${c.id}`} value={c.owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => upConn(i, { owner: e.target.value })} />
<Input list={`orgs-${c.id}`} value={c.owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => upConn(i, { owner: e.target.value })} />
<datalist id={`orgs-${c.id}`}>
{(orgs[c.id] ?? []).map((o) => (
<option key={o} value={o} />
@@ -952,9 +993,9 @@ function FactorySettings() {
</div>
</div>
))}
<button onClick={() => setConns([...conns, blankConn()])}>
<Button onClick={() => setConns([...conns, blankConn()])}>
<Icon name="plus" /> {t("factory.addConn")}
</button>
</Button>
<h3 className="factory-h">{t("factory.defaults")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>{t("factory.defaultsHint")}</div>
@@ -977,12 +1018,10 @@ function FactorySettings() {
<h3 style={{ margin: 0 }}>{r.url ? repoName(r.url) : t("factory.newRepo")}</h3>
<span className="chip">{KIND_NAME[conns.find((c) => c.id === r.connection)?.kind ?? r.kind] ?? r.kind}</span>
<span className="spacer" />
<label className="switch">
<input type="checkbox" checked={r.enabled} onChange={(e) => up(i, { enabled: e.target.checked })} />
<Checkbox className="switch" checked={r.enabled} onChange={(e) => up(i, { enabled: e.target.checked })}>
<span>{t(r.enabled ? "jobs.on" : "jobs.off")}</span>
</label>
<button
className="small"
</Checkbox>
<Button size="small"
disabled={busy !== undefined}
onClick={() =>
act(`t${i}`, async () => {
@@ -993,9 +1032,8 @@ function FactorySettings() {
}
>
{busy === `t${i}` ? <Spinner small /> : <Icon name="plug" />} {t("factory.test")}
</button>
<button
className="small"
</Button>
<Button size="small"
title={t("common.delete")}
aria-label={t("common.delete")}
onClick={async () => {
@@ -1003,12 +1041,12 @@ function FactorySettings() {
}}
>
<Icon name="trash" />
</button>
</Button>
</div>
<div className="factory-form">
<label>
<span>{t("factory.connection")}</span>
<select
<Select
value={r.connection}
onChange={(e) => up(i, { connection: e.target.value, kind: conns.find((c) => c.id === e.target.value)?.kind ?? r.kind })}
>
@@ -1020,44 +1058,44 @@ function FactorySettings() {
{c.name || KIND_NAME[c.kind]}
</option>
))}
</select>
</Select>
</label>
{!r.connection && (
<label>
<span>{t("factory.kind")}</span>
<select value={r.kind} onChange={(e) => up(i, { kind: e.target.value })}>
<Select value={r.kind} onChange={(e) => up(i, { kind: e.target.value })}>
{Object.entries(KIND_NAME).map(([k, n]) => (
<option key={k} value={k}>
{n}
</option>
))}
</select>
</Select>
</label>
)}
<label>
<span>{t("factory.url")}</span>
<input value={r.url} placeholder="https://host/owner/repo.git" onChange={(e) => up(i, { url: e.target.value })} />
<Input value={r.url} placeholder="https://host/owner/repo.git" onChange={(e) => up(i, { url: e.target.value })} />
</label>
<label>
<span>{t("factory.repoToken")}</span>
<input type="password" autoComplete="new-password" value={r.token} placeholder={t("factory.repoTokenPlaceholder")} onChange={(e) => up(i, { token: e.target.value })} onFocus={(e) => r.token.startsWith("•") && e.currentTarget.select()} />
<Input.Password autoComplete="new-password" value={r.token} placeholder={t("factory.repoTokenPlaceholder")} onChange={(e) => up(i, { token: e.target.value })} onFocus={(e) => r.token.startsWith("•") && e.currentTarget.select()} />
<span className="hint">{r.token.startsWith("•") ? t("factory.tokenSet") : t("factory.repoTokenHint")}</span>
</label>
<label>
<span>{t("factory.label")}</span>
<input value={r.label} onChange={(e) => up(i, { label: e.target.value })} />
<Input value={r.label} onChange={(e) => up(i, { label: e.target.value })} />
</label>
<label>
<span>{t("factory.parallel")}</span>
<input type="number" min={1} max={4} value={r.max_parallel} onChange={(e) => up(i, { max_parallel: Number(e.target.value) || 1 })} />
<Input type="number" min={1} max={4} value={r.max_parallel} onChange={(e) => up(i, { max_parallel: Number(e.target.value) || 1 })} />
</label>
<label>
<span>{t("factory.rework")}</span>
<input type="number" min={0} max={10} value={r.max_rework} title={t("factory.reworkHint")} onChange={(e) => up(i, { max_rework: Math.max(0, Number(e.target.value) || 0) })} />
<Input type="number" min={0} max={10} value={r.max_rework} title={t("factory.reworkHint")} onChange={(e) => up(i, { max_rework: Math.max(0, Number(e.target.value) || 0) })} />
</label>
<label>
<span>{t("factory.allowed")}</span>
<input value={r.allowed_users.join(", ")} placeholder={t("factory.allowedPlaceholder")} onChange={(e) => up(i, { allowed_users: e.target.value.split(",").map((u) => u.trim()).filter(Boolean) })} />
<Input value={r.allowed_users.join(", ")} placeholder={t("factory.allowedPlaceholder")} onChange={(e) => up(i, { allowed_users: e.target.value.split(",").map((u) => u.trim()).filter(Boolean) })} />
</label>
</div>
<div className="factory-phases">
@@ -1068,11 +1106,10 @@ function FactorySettings() {
</div>
))}
<div className="row" style={{ gap: 8, marginTop: 12 }}>
<button onClick={() => setRepos([...repos, blankRepo(conns.find((c) => c.id)?.id ?? "", conns.find((c) => c.id)?.kind ?? "gitea")])}>
<Button onClick={() => setRepos([...repos, blankRepo(conns.find((c) => c.id)?.id ?? "", conns.find((c) => c.id)?.kind ?? "gitea")])}>
<Icon name="plus" /> {t("factory.addRepo")}
</button>
<button
className="primary"
</Button>
<Button type="primary"
disabled={busy !== undefined}
onClick={() =>
act("save", async () => {
@@ -1082,7 +1119,7 @@ function FactorySettings() {
}
>
{busy === "save" ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
</button>
</Button>
</div>
</>
);
+6 -5
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect } from "react";
import { navigate } from "../router";
import { useT } from "../i18n";
@@ -20,7 +21,7 @@ export function ChatOverlay({ id }: { id: string }) {
// Esc closes – unless it is meant for a field, a dialog or the image viewer on top.
const el = document.activeElement;
const typing = el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement || el instanceof HTMLSelectElement;
if (e.key === "Escape" && !typing && !document.querySelector(".modal-backdrop, .viewer-overlay")) close();
if (e.key === "Escape" && !typing && !document.querySelector(".ant-modal-wrap, .modal-backdrop, .viewer-overlay")) close();
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
@@ -31,12 +32,12 @@ export function ChatOverlay({ id }: { id: string }) {
<div className="chat-overlay-bar">
<span className="hint">{t("factory.chatOverlay")}</span>
<span className="spacer" />
<button className="small" onClick={() => navigate(`/s/${id}`)} title={t("factory.openFullHint")}>
<Button size="small" onClick={() => navigate(`/s/${id}`)} title={t("factory.openFullHint")}>
<Icon name="external" /> {t("factory.openFull")}
</button>
<button className="small" onClick={close} aria-label={t("common.close")}>
</Button>
<Button size="small" onClick={close} aria-label={t("common.close")}>
<Icon name="close" /> {t("common.close")}
</button>
</Button>
</div>
<div className="chat-overlay-body">
<ChatView key={id} sessionId={id} onMenu={close} />
+44 -53
View File
@@ -1,3 +1,6 @@
import { Button, Checkbox, Input } from "antd";
import { Modal } from "../ui/Modal";
import { Select } from "../ui/Select";
import { useEffect, useState } from "react";
import { get, post } from "../api";
import { useT } from "../i18n";
@@ -38,9 +41,9 @@ export function DraftBar({ sessionId }: { sessionId: string }) {
<Icon name="scroll" />
<span>{t("draft.hint")}</span>
<span className="spacer" />
<button className="small primary" onClick={() => setOpen(true)}>
<Button type="primary" size="small" onClick={() => setOpen(true)}>
<Icon name="check" /> {t("draft.create")}
</button>
</Button>
</div>
{open && <CreateProjectDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
</>
@@ -77,11 +80,9 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
if (!draft)
return (
<div className="modal-backdrop">
<div className="modal">
<Modal >
<Spinner />
</div>
</div>
</Modal>
);
const conn = draft.connections.find((c) => c.id === connection);
@@ -102,8 +103,7 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
};
return (
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
<div className="modal draft-modal" role="dialog" aria-label={t("draft.create")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("draft.create")}>
<h3>{t("draft.create")}</h3>
{draft.connections.length === 0 ? (
<div className="notice err">
@@ -119,7 +119,7 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
<div className="factory-form">
<label>
<span>{t("draft.name")}</span>
<input
<Input
autoFocus
value={name}
onChange={(e) => {
@@ -130,7 +130,7 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
</label>
<label>
<span>{t("draft.slug")}</span>
<input
<Input
value={slug}
className="mono"
onChange={(e) => {
@@ -141,11 +141,11 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
</label>
<label style={{ gridColumn: "1 / -1" }}>
<span>{t("draft.description")}</span>
<input value={description} onChange={(e) => setDescription(e.target.value)} />
<Input value={description} onChange={(e) => setDescription(e.target.value)} />
</label>
<label>
<span>{t("draft.connection")}</span>
<select
<Select
value={connection}
onChange={(e) => {
setConnection(e.target.value);
@@ -157,11 +157,11 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
{c.name || c.kind} ({c.kind})
</option>
))}
</select>
</Select>
</label>
<label>
<span>{t("draft.owner")}</span>
<input value={owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => setOwner(e.target.value)} />
<Input value={owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => setOwner(e.target.value)} />
</label>
</div>
<div className="hint" style={{ margin: "6px 0" }}>
@@ -174,15 +174,14 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
</>
)}
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
<button onClick={onClose} disabled={busy}>
<Button onClick={onClose} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={create} disabled={!ready || busy}>
</Button>
<Button type="primary" onClick={create} disabled={!ready || busy}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("draft.createGo")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
@@ -209,9 +208,9 @@ export function IssueBar({ sessionId }: { sessionId: string }) {
<Icon name="scroll" />
<span>{t("issues.hint")}</span>
<span className="spacer" />
<button className="small primary" onClick={() => setOpen(true)}>
<Button type="primary" size="small" onClick={() => setOpen(true)}>
<Icon name="check" /> {t("issues.create")}
</button>
</Button>
</div>
{open && <CreateIssuesDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
</>
@@ -241,11 +240,9 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
if (!data)
return (
<div className="modal-backdrop">
<div className="modal">
<Modal >
<Spinner />
</div>
</div>
</Modal>
);
const chosen = items.filter((i) => i.on && i.title.trim());
@@ -268,8 +265,7 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
};
return (
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
<div className="modal draft-modal" role="dialog" aria-label={t("issues.create")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("issues.create")}>
<h3>{t("issues.create")}</h3>
{!data.proposal ? (
<div className="notice err">{t("issues.noProposal")}</div>
@@ -277,41 +273,38 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
<>
<label className="factory-form" style={{ display: "block" }}>
<span>{t("issues.spec")}</span>
<input className="mono" value={spec} onChange={(e) => setSpec(e.target.value)} />
<Input className="mono" value={spec} onChange={(e) => setSpec(e.target.value)} />
</label>
<div className="issue-list">
{items.map((i, k) => (
<div key={k} className="issue-item">
<label className="row" style={{ gap: 8 }}>
<input type="checkbox" checked={i.on} onChange={(e) => set(k, { on: e.target.checked })} />
<input style={{ flex: 1 }} value={i.title} onChange={(e) => set(k, { title: e.target.value })} />
</label>
<Checkbox className="row" style={{ gap: 8 }} checked={i.on} onChange={(e) => set(k, { on: e.target.checked })}>
<Input style={{ flex: 1 }} value={i.title} onChange={(e) => set(k, { title: e.target.value })} />
</Checkbox>
<div className="hint">{i.scope}</div>
{i.depends && i.depends.toLowerCase() !== "none" && <div className="hint">{t("issues.depends", { d: i.depends })}</div>}
<details>
<summary>{t("issues.description")}</summary>
<textarea rows={4} value={i.description} onChange={(e) => set(k, { description: e.target.value })} />
<Input.TextArea rows={4} value={i.description} onChange={(e) => set(k, { description: e.target.value })} />
</details>
</div>
))}
</div>
<label className="row" style={{ gap: 8, marginTop: 8 }}>
<input type="checkbox" checked={start} onChange={(e) => setStart(e.target.checked)} />
<Checkbox className="row" style={{ gap: 8, marginTop: 8 }} checked={start} onChange={(e) => setStart(e.target.checked)}>
<span>{t("issues.start")}</span>
</label>
</Checkbox>
<div className="hint">{t("issues.startHint")}</div>
</>
)}
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
<button onClick={onClose} disabled={busy}>
<Button onClick={onClose} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={create} disabled={!data.proposal || chosen.length === 0 || !spec.trim() || busy}>
</Button>
<Button type="primary" onClick={create} disabled={!data.proposal || chosen.length === 0 || !spec.trim() || busy}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("issues.createGo", { n: chosen.length })}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
@@ -339,14 +332,13 @@ export function RecreateDialog({ onClose }: { onClose: () => void }) {
};
return (
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
<div className="modal draft-modal" role="dialog" aria-label={t("recreate.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("recreate.title")}>
<h3>{t("recreate.title")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>{t("recreate.hint")}</div>
<div className="factory-form">
<label style={{ gridColumn: "1 / -1" }}>
<span>{t("recreate.source")}</span>
<input autoFocus value={source} placeholder="https://…" onChange={(e) => setSource(e.target.value)} />
<Input autoFocus value={source} placeholder="https://…" onChange={(e) => setSource(e.target.value)} />
</label>
<label style={{ gridColumn: "1 / -1" }}>
<span>{t("recreate.files")}</span>
@@ -354,18 +346,17 @@ export function RecreateDialog({ onClose }: { onClose: () => void }) {
</label>
<label style={{ gridColumn: "1 / -1" }}>
<span>{t("recreate.notes")}</span>
<textarea rows={4} value={notes} placeholder={t("recreate.notesPlaceholder")} onChange={(e) => setNotes(e.target.value)} />
<Input.TextArea rows={4} value={notes} placeholder={t("recreate.notesPlaceholder")} onChange={(e) => setNotes(e.target.value)} />
</label>
</div>
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
<button onClick={onClose} disabled={busy}>
<Button onClick={onClose} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={start} disabled={busy || (!source.trim() && files.length === 0)}>
</Button>
<Button type="primary" onClick={start} disabled={busy || (!source.trim() && files.length === 0)}>
{busy ? <Spinner small /> : <Icon name="search" />} {t("recreate.go")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+11 -13
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useState } from "react";
import { get, post } from "../api";
import { fmtRelative, useT } from "../i18n";
@@ -46,11 +48,9 @@ export function ReleaseDialog({ repo, onClose, onStarted }: { repo: string; onCl
if (!pv)
return (
<div className="modal-backdrop">
<div className="modal">
<Modal >
<Spinner />
</div>
</div>
</Modal>
);
const start = async () => {
@@ -67,15 +67,14 @@ export function ReleaseDialog({ repo, onClose, onStarted }: { repo: string; onCl
};
return (
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
<div className="modal draft-modal" role="dialog" aria-label={t("release.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("release.title")}>
<h3>
{t("release.title")} – {repoName(repo)}
</h3>
<div className="hint">{t("release.current", { v: pv.current })}</div>
<label className="factory-form" style={{ display: "block", margin: "8px 0" }}>
<span>{t("release.version")}</span>
<input className="mono" value={version} onChange={(e) => setVersion(e.target.value.trim().replace(/^v/, ""))} />
<Input className="mono" value={version} onChange={(e) => setVersion(e.target.value.trim().replace(/^v/, ""))} />
</label>
<div className="notice">{t("release.what")}</div>
{pv.spec ? (
@@ -89,15 +88,14 @@ export function ReleaseDialog({ repo, onClose, onStarted }: { repo: string; onCl
)}
{pv.running && <div className="notice err">{t("release.running")}</div>}
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
<button onClick={onClose} disabled={busy}>
<Button onClick={onClose} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={start} disabled={busy || pv.running || !/^\d+\.\d+\.\d+$/.test(version)}>
</Button>
<Button type="primary" onClick={start} disabled={busy || pv.running || !/^\d+\.\d+\.\d+$/.test(version)}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("release.go", { v: version })}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+11 -11
View File
@@ -1,3 +1,4 @@
import { Button, Segmented } from "antd";
import { lazy, Suspense, useEffect, useState } from "react";
import { get } from "../api";
import { useT } from "../i18n";
@@ -33,13 +34,13 @@ function PdfPreview({ path }: { path: string }) {
return (
<div className="pdf-preview">
<div className="row pdf-nav">
<button className="small" disabled={page <= 1} onClick={() => setPage(page - 1)}>
<Button size="small" disabled={page <= 1} onClick={() => setPage(page - 1)}>
‹
</button>
</Button>
<span>{t("preview.page", { n: page, total: pages ?? "…" })}</span>
<button className="small" disabled={!pages || page >= pages} onClick={() => setPage(page + 1)}>
<Button size="small" disabled={!pages || page >= pages} onClick={() => setPage(page + 1)}>
›
</button>
</Button>
<span className="spacer" />
<a className="button small" href={`/api/files/raw?${q(path)}`} target="_blank" rel="noreferrer">
{t("preview.openBrowser")}
@@ -74,13 +75,12 @@ function DocPreview({ path }: { path: string }) {
const s = data.sheets?.[sheet];
return (
<div className="pdf-preview">
<div className="mode-tabs sheet-tabs">
{data.sheets?.map((x, i) => (
<button key={x.name} className={i === sheet ? "active" : ""} onClick={() => setSheet(i)}>
{x.name}
</button>
))}
</div>
<Segmented
className="sheet-tabs seg-wrap"
value={sheet}
onChange={setSheet}
options={data.sheets?.map((x, i) => ({ value: i, label: x.name })) ?? []}
/>
<div className="pane-scroll">
{s && (
<table className="grid sheet">
+43 -42
View File
@@ -1,3 +1,5 @@
import { Button, Input, Segmented } from "antd";
import { Select } from "../ui/Select";
import { uploadBatch } from "../uploads";
import { Icon } from "./Icon";
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -260,39 +262,39 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
>
<div className="files-toolbar">
{roots.length > 1 && (
<select value={root?.path ?? ""} onChange={(e) => { const v = e.target.value; void confirmDiscard().then((ok): unknown => ok && load(v)); }} aria-label={t("images.folder")}>
<Select value={root?.path ?? ""} onChange={(e) => { const v = e.target.value; void confirmDiscard().then((ok): unknown => ok && load(v)); }} aria-label={t("images.folder")}>
{roots.map((r) => (
<option key={r.path} value={r.path}>
{r.name}
</option>
))}
</select>
</Select>
)}
<input className="files-search" placeholder={t("files.search")} value={search} onChange={(e) => setSearch(e.target.value)} />
<button className="small" title={t("files.newFile")} onClick={() => newEntry(false)}>
<Input className="files-search" placeholder={t("files.search")} value={search} onChange={(e) => setSearch(e.target.value)} />
<Button size="small" title={t("files.newFile")} onClick={() => newEntry(false)}>
<Icon name="plus" className="tiny" /> <Icon name="file" />
</button>
<button className="small" title={t("files.newFolder")} onClick={() => newEntry(true)}>
</Button>
<Button size="small" title={t("files.newFolder")} onClick={() => newEntry(true)}>
<Icon name="plus" className="tiny" /> <Icon name="folder" />
</button>
<button className="small" title={t("files.upload")} onClick={() => uploadRef.current?.click()}>
</Button>
<Button size="small" title={t("files.upload")} onClick={() => uploadRef.current?.click()}>
<Icon name="upload" />
</button>
</Button>
<input ref={uploadRef} type="file" multiple hidden onChange={(e) => e.target.files && upload(e.target.files)} />
<button className={`small ${hidden ? "active" : ""}`} title={t("files.showHidden")} onClick={() => setHidden(!hidden)}>
<Button size="small" className={hidden ? "active" : ""} title={t("files.showHidden")} onClick={() => setHidden(!hidden)}>
.*
</button>
</Button>
</div>
<div className="crumbs">
<button
className="small ghost crumbs-up"
<Button type="text" size="small"
className="crumbs-up"
disabled={!listing?.parent}
onClick={() => listing?.parent && void confirmDiscard().then((ok): unknown => ok && load(listing.parent!))}
title={t("files.up")}
aria-label={t("files.up")}
>
<Icon name="folder-up" />
</button>
</Button>
{crumbs.map((c, i) => {
const path = i === 0 ? c : `${crumbs[0]}/${crumbs.slice(1, i + 1).join("/")}`;
return (
@@ -341,18 +343,18 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
<summary aria-label={t("files.actions")}><Icon name="more" /></summary>
<div className="menu">
{e.is_dir && (
<button onClick={() => void chatHere(e)}>{t("files.chatHere")}</button>
<Button onClick={() => void chatHere(e)}>{t("files.chatHere")}</Button>
)}
<button onClick={() => rename(e)}>{t("files.rename")}</button>
<button onClick={() => duplicate(e)}>{t("files.duplicate")}</button>
<Button onClick={() => rename(e)}>{t("files.rename")}</Button>
<Button onClick={() => duplicate(e)}>{t("files.duplicate")}</Button>
{!e.is_dir && (
<a className="button" href={rawUrl(e.path, true)}>
{t("files.download")}
</a>
)}
<button className="danger" onClick={() => remove(e)}>
<Button danger onClick={() => remove(e)}>
{t("common.delete")}
</button>
</Button>
</div>
</details>
</div>
@@ -371,9 +373,9 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
return (
<div className="editor-pane">
<div className="editor-bar">
<button className="ghost small mobile-only" onClick={() => setMobileEditor(false)}>
<Button type="text" size="small" className="mobile-only" onClick={() => setMobileEditor(false)}>
<Icon name="arrow-left" />
</button>
</Button>
<b className="grow">{pane.title}</b>
</div>
<div className="pane-scroll">{pane.diff ? <Diff diff={pane.diff} /> : <div className="empty">{t("git.noDiff")}</div>}</div>
@@ -387,25 +389,25 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
return (
<div className="editor-pane">
<div className="editor-bar">
<button className="ghost small mobile-only" onClick={() => void confirmDiscard().then((ok): unknown => ok && setMobileEditor(false))}>
<Button type="text" size="small" className="mobile-only" onClick={() => void confirmDiscard().then((ok): unknown => ok && setMobileEditor(false))}>
<Icon name="arrow-left" />
</button>
</Button>
<b className="grow" title={f.path}>
{baseName(f.path)}
{dirty && <span className="dirty"> <Icon name="dot" className="tiny" /></span>}
</b>
{(isMd || isImage) && !f.preview && (
<button className="small" onClick={() => setPreview(!preview)}>
<Button size="small" onClick={() => setPreview(!preview)}>
{preview ? t("files.edit") : t("files.preview")}
</button>
</Button>
)}
<a className="button small" href={rawUrl(f.path, true)}>
<Icon name="download" />
</a>
{!f.binary && (
<button className="small primary" disabled={!dirty} onClick={() => save()}>
<Button type="primary" size="small" disabled={!dirty} onClick={() => save()}>
{t("common.save")}
</button>
</Button>
)}
</div>
{f.preview ? (
@@ -439,23 +441,23 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
<>
<div className={embed ? "files-embed-bar" : "topbar"}>
{!embed && (
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
)}
<div className="grow">
{!embed && <h1>{t("nav.files")}</h1>}
<div className="path">{listing?.path}</div>
</div>
{listing?.repo && (
<div className="mode-tabs" role="tablist">
<button className={tab === "files" ? "active" : ""} onClick={() => setTab("files")}>
{t("files.tabFiles")}
</button>
<button className={tab === "git" ? "active" : ""} onClick={() => setTab("git")}>
Git{git && git.files.length > 0 ? ` (${git.files.length})` : ""}
</button>
</div>
<Segmented
value={tab}
onChange={(v) => setTab(v)}
options={[
{ value: "files" as const, label: t("files.tabFiles") },
{ value: "git" as const, label: `Git${git && git.files.length > 0 ? ` (${git.files.length})` : ""}` },
]}
/>
)}
</div>
<div className={`files-layout ${mobileEditor ? "show-editor" : ""}`}>
@@ -473,11 +475,10 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
)}
{!listing?.repo && listing && (
<div className="git-init">
<button className="small" onClick={() => act(() => post("/git", { path: listing.path, action: "init" }))}>
<Button size="small" onClick={() => act(() => post("/git", { path: listing.path, action: "init" }))}>
{t("git.init")}
</button>
<button
className="small"
</Button>
<Button size="small"
onClick={async () => {
const url = await promptDialog({ message: t("git.cloneUrl"), placeholder: "https://…/repo.git" });
if (!url) return;
@@ -486,7 +487,7 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
}}
>
{t("git.clone")}
</button>
</Button>
</div>
)}
</div>
+38 -38
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input, Segmented } from "antd";
import { Select } from "../ui/Select";
import { Icon } from "./Icon";
import { useEffect, useState } from "react";
import { post } from "../api";
@@ -101,26 +103,26 @@ export function GitPanel({
return (
<div key={`${isStaged}-${f.path}`} className="git-file">
<span className={`git-mark m-${LABEL[code] ?? code}`}>{LABEL[code] ?? code}</span>
<button className="ghost git-name" onClick={() => diff(f, isStaged)} title={f.path}>
<Button type="text" className="git-name" onClick={() => diff(f, isStaged)} title={f.path}>
{f.path}
</button>
<button className="small ghost" title={t("git.openFile")} onClick={() => openFile(abs(f))}>
</Button>
<Button type="text" size="small" title={t("git.openFile")} onClick={() => openFile(abs(f))}>
<Icon name="external" />
</button>
</Button>
{isStaged ? (
<button className="small" title={t("git.unstage")} onClick={() => run("unstage", () => call("unstage", { files: [abs(f)] }))}>
<Button size="small" title={t("git.unstage")} onClick={() => run("unstage", () => call("unstage", { files: [abs(f)] }))}>
<Icon name="minus" />
</button>
</Button>
) : (
<>
{f.index !== "?" && (
<button className="small ghost danger" title={t("git.discard")} onClick={() => void confirmDialog({ message: t("git.discardConfirm", { file: f.path }), danger: true, confirmLabel: t("git.discard") }).then((ok): unknown => ok && run("discard", () => call("discard", { files: [abs(f)] })))}>
<Button type="text" danger size="small" title={t("git.discard")} onClick={() => void confirmDialog({ message: t("git.discardConfirm", { file: f.path }), danger: true, confirmLabel: t("git.discard") }).then((ok): unknown => ok && run("discard", () => call("discard", { files: [abs(f)] })))}>
<Icon name="refresh" />
</button>
</Button>
)}
<button className="small" title={t("git.stage")} onClick={() => run("stage", () => call("stage", { files: [abs(f)] }))}>
<Button size="small" title={t("git.stage")} onClick={() => run("stage", () => call("stage", { files: [abs(f)] }))}>
+
</button>
</Button>
</>
)}
</div>
@@ -130,7 +132,7 @@ export function GitPanel({
return (
<div className="git-panel">
<div className="git-branch">
<select
<Select
value={branches.find((b) => b.current)?.name ?? status.branch ?? ""}
onChange={(e) => run("checkout", () => call("checkout", { branch: e.target.value.replace(/^origin\//, "") }), true)}
aria-label={t("git.branch")}
@@ -141,9 +143,8 @@ export function GitPanel({
{b.name}
</option>
))}
</select>
<button
className="small"
</Select>
<Button size="small"
title={t("git.newBranch")}
onClick={async () => {
const name = await promptDialog({ message: t("git.newBranchName"), placeholder: "feature/…" });
@@ -151,7 +152,7 @@ export function GitPanel({
}}
>
+
</button>
</Button>
{status.upstream && (
<span className="chip" title={status.upstream}>
<Icon name="arrow-up" className="tiny" />{status.ahead} <Icon name="arrow-down" className="tiny" />{status.behind}
@@ -159,21 +160,22 @@ export function GitPanel({
)}
<span className="spacer" />
{(["fetch", "pull", "push"] as const).map((a) => (
<button key={a} className="small" disabled={!!busy} onClick={() => run(a, () => call(a), true)}>
<Button size="small" key={a} disabled={!!busy} onClick={() => run(a, () => call(a), true)}>
{busy === a ? <Spinner small /> : t(`git.${a}`)}
</button>
</Button>
))}
</div>
{output && <pre className={`git-output ${output.ok ? "" : "err"}`}>{output.text}</pre>}
<div className="mode-tabs" style={{ margin: "8px 0" }}>
<button className={view === "changes" ? "active" : ""} onClick={() => setView("changes")}>
{t("git.changes")} ({status.files.length})
</button>
<button className={view === "history" ? "active" : ""} onClick={() => setView("history")}>
{t("git.history")}
</button>
</div>
<Segmented
style={{ margin: "8px 0", alignSelf: "flex-start" }}
value={view}
onChange={(v) => setView(v)}
options={[
{ value: "changes" as const, label: `${t("git.changes")} (${status.files.length})` },
{ value: "history" as const, label: t("git.history") },
]}
/>
{view === "changes" ? (
<>
@@ -181,9 +183,9 @@ export function GitPanel({
<div className="git-head">
{t("git.staged")} ({staged.length})
{staged.length > 0 && (
<button className="small ghost" onClick={() => run("unstage", () => call("unstage", { files: staged.map(abs) }))}>
<Button type="text" size="small" onClick={() => run("unstage", () => call("unstage", { files: staged.map(abs) }))}>
{t("git.unstageAll")}
</button>
</Button>
)}
</div>
{staged.map((f) => fileRow(f, true))}
@@ -192,30 +194,28 @@ export function GitPanel({
<div className="git-head">
{t("git.unstaged")} ({unstaged.length})
{unstaged.length > 0 && (
<button className="small ghost" onClick={() => run("stage", () => call("stage", { files: unstaged.map(abs) }))}>
<Button type="text" size="small" onClick={() => run("stage", () => call("stage", { files: unstaged.map(abs) }))}>
{t("git.stageAll")}
</button>
</Button>
)}
</div>
{unstaged.map((f) => fileRow(f, false))}
{status.files.length === 0 && <div className="empty" style={{ padding: 12 }}>{t("git.clean")}</div>}
</div>
<div className="git-commit">
<textarea rows={3} placeholder={t("git.message")} value={message} onChange={(e) => setMessage(e.target.value)} />
<Input.TextArea rows={3} placeholder={t("git.message")} value={message} onChange={(e) => setMessage(e.target.value)} />
<div className="row">
<label style={{ fontSize: 12.5 }}>
<input type="checkbox" checked={amend} onChange={(e) => setAmend(e.target.checked)} /> {t("git.amend")}
</label>
<Checkbox style={{ fontSize: 12.5 }} checked={amend} onChange={(e) => setAmend(e.target.checked)}> {t("git.amend")}
</Checkbox>
<span className="spacer" />
<button
<Button
disabled={!!busy || staged.length === 0}
title={t("git.suggestHint")}
onClick={() => run("suggest", async () => setMessage((await call<{ message: string }>("suggest")).message))}
>
{busy === "suggest" ? <Spinner small /> : t("git.suggest")}
</button>
<button
className="primary"
</Button>
<Button type="primary"
disabled={!!busy || (!amend && (!message.trim() || staged.length === 0))}
onClick={() =>
run(
@@ -231,7 +231,7 @@ export function GitPanel({
}
>
{busy === "commit" ? <Spinner small /> : t("git.commit")}
</button>
</Button>
</div>
</div>
</>
+9 -8
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect, useRef, useState } from "react";
import { useT } from "../i18n";
import { toast } from "../dialogs";
@@ -135,25 +136,25 @@ export function ImageAnnotator({ src, name, onDone, onCancel }: { src: string; n
/>
<div className="annotator-tools" role="toolbar" aria-label={t("viewer.annotate")}>
{(["pen", "arrow", "rect"] as Tool[]).map((k) => (
<button key={k} className={`small ${tool === k ? "primary" : "ghost"}`} onClick={() => setTool(k)} aria-pressed={tool === k} title={t(`viewer.tool.${k}` as const)}>
<Button key={k} size="small" type={tool === k ? "primary" : "text"} onClick={() => setTool(k)} aria-pressed={tool === k} title={t(`viewer.tool.${k}` as const)}>
<Icon name={k === "pen" ? "edit" : k === "arrow" ? "arrow-right" : "box-off"} />
</button>
</Button>
))}
<span className="annotator-colors">
{COLORS.map((c) => (
<button key={c} className={`swatch ${c === color ? "on" : ""}`} style={{ background: c }} onClick={() => setColor(c)} aria-label={c} aria-pressed={c === color} />
))}
</span>
<button className="small ghost" onClick={() => setShapes((s) => s.slice(0, -1))} disabled={!shapes.length} title={t("viewer.undo")} aria-label={t("viewer.undo")}>
<Button type="text" size="small" onClick={() => setShapes((s) => s.slice(0, -1))} disabled={!shapes.length} title={t("viewer.undo")} aria-label={t("viewer.undo")}>
<Icon name="undo" />
</button>
</Button>
<span className="grow" />
<button className="small" onClick={onCancel}>
<Button size="small" onClick={onCancel}>
{t("common.cancel")}
</button>
<button className="small primary" onClick={finish} disabled={!ready}>
</Button>
<Button type="primary" size="small" onClick={finish} disabled={!ready}>
<Icon name="clip" /> {t("viewer.attach")}
</button>
</Button>
</div>
</div>
);
+7 -6
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useCallback, useEffect, useRef, useState } from "react";
import { Icon } from "./Icon";
import { ImageAnnotator } from "./ImageAnnotator";
@@ -139,12 +140,12 @@ export function ImageViewer() {
<span className="viewer-name">{cur.alt && !/^(image|SVG)$/i.test(cur.alt) ? cur.alt : ""}</span>
{sessionId && (
<>
<button className="small ghost" onClick={() => setMarking(true)} title={t("viewer.annotate")} aria-label={t("viewer.annotate")}>
<Button type="text" size="small" onClick={() => setMarking(true)} title={t("viewer.annotate")} aria-label={t("viewer.annotate")}>
<Icon name="edit" />
</button>
<button className="small ghost" onClick={() => void useInChat()} title={t("viewer.useInChat")} aria-label={t("viewer.useInChat")}>
</Button>
<Button type="text" size="small" onClick={() => void useInChat()} title={t("viewer.useInChat")} aria-label={t("viewer.useInChat")}>
<Icon name="reply" />
</button>
</Button>
</>
)}
<a className="button small ghost" href={cur.src} target="_blank" rel="noreferrer" title={t("viewer.open")} aria-label={t("viewer.open")}>
@@ -153,9 +154,9 @@ export function ImageViewer() {
<a className="button small ghost" href={cur.src} download title={t("viewer.download")} aria-label={t("viewer.download")}>
<Icon name="download" />
</a>
<button className="small ghost" onClick={close} aria-label={t("common.close")}>
<Button type="text" size="small" onClick={close} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</Button>
</div>
{marking && (
<ImageAnnotator
+22 -20
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Select } from "../ui/Select";
import { Icon } from "./Icon";
import { useEffect, useState } from "react";
import { del, post } from "../api";
@@ -63,9 +65,9 @@ export function Images({ onMenu }: { onMenu: () => void }) {
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>{t("nav.images")}</h1>
</div>
@@ -74,7 +76,7 @@ export function Images({ onMenu }: { onMenu: () => void }) {
<div className="page-inner">
{cfg && !cfg.enabled && <div className="notice">{t("images.disabled")}</div>}
<div className="panel">
<textarea
<Input.TextArea
style={{ width: "100%", minHeight: 90 }}
placeholder={t("images.promptPlaceholder")}
value={form.prompt}
@@ -82,42 +84,42 @@ export function Images({ onMenu }: { onMenu: () => void }) {
onKeyDown={(e) => e.key === "Enter" && (e.ctrlKey || e.metaKey) && form.prompt.trim() && generate()}
/>
<div className="row" style={{ marginTop: 8 }}>
<select value={form.model} onChange={(e) => setForm({ ...form, model: e.target.value })} aria-label={t("images.model")}>
<Select value={form.model} onChange={(e) => setForm({ ...form, model: e.target.value })} aria-label={t("images.model")}>
{cfg?.models.map((m) => (
<option key={m.id} value={m.id}>
{m.name}
</option>
))}
</select>
<select value={form.size} onChange={(e) => setForm({ ...form, size: e.target.value })} aria-label={t("images.size")}>
</Select>
<Select value={form.size} onChange={(e) => setForm({ ...form, size: e.target.value })} aria-label={t("images.size")}>
{cfg?.sizes.map((s) => (
<option key={s} value={s}>
{t(`images.size.${s}` as Key)}
</option>
))}
</select>
<select value={form.count} onChange={(e) => setForm({ ...form, count: Number(e.target.value) })} aria-label={t("images.count")}>
</Select>
<Select value={form.count} onChange={(e) => setForm({ ...form, count: Number(e.target.value) })} aria-label={t("images.count")}>
{[1, 2, 3, 4].map((n) => (
<option key={n} value={n}>
{t("images.countN", { n })}
</option>
))}
</select>
</Select>
{roots.length > 1 && (
<select value={form.root} onChange={(e) => setForm({ ...form, root: e.target.value })} aria-label={t("images.folder")}>
<Select value={form.root} onChange={(e) => setForm({ ...form, root: e.target.value })} aria-label={t("images.folder")}>
{roots.map((r) => (
<option key={r.path} value={r.path}>
{r.name}
</option>
))}
</select>
</Select>
)}
<input value={form.folder} onChange={(e) => setForm({ ...form, folder: e.target.value })} title={t("images.folder")} style={{ width: 140 }} />
<Input value={form.folder} onChange={(e) => setForm({ ...form, folder: e.target.value })} title={t("images.folder")} style={{ width: 140 }} />
<span className="spacer" />
{price ? <span className="chip">≈ {fmtCost(price * form.count, cfg!.currency)}</span> : null}
<button className="primary" disabled={busy || !form.prompt.trim() || !cfg?.enabled} onClick={generate}>
<Button type="primary" disabled={busy || !form.prompt.trim() || !cfg?.enabled} onClick={generate}>
{busy ? <Spinner small /> : null} {busy ? t("images.generating") : t("images.generate")}
</button>
</Button>
</div>
{error && <div className="notice err" style={{ marginTop: 8 }}>{error}</div>}
</div>
@@ -144,15 +146,15 @@ export function Images({ onMenu }: { onMenu: () => void }) {
<a className="button small" href={fileUrl(img.id)} download={img.path.split("/").pop()}>
<Icon name="download" />
</a>
<button className="small" title={t("images.reuse")} onClick={() => setForm({ ...form, prompt: img.prompt, model: img.model })}>
<Button size="small" title={t("images.reuse")} onClick={() => setForm({ ...form, prompt: img.prompt, model: img.model })}>
<Icon name="refresh" />
</button>
<button className="small" title={t("images.copyPath")} onClick={() => navigator.clipboard?.writeText(img.path)}>
</Button>
<Button size="small" title={t("images.copyPath")} onClick={() => navigator.clipboard?.writeText(img.path)}>
<Icon name="copy" />
</button>
<button className="small danger" title={t("common.delete")} onClick={() => void confirmDialog({ message: t("images.deleteConfirm"), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && del(`/images/${img.id}`).then(reload))}>
</Button>
<Button danger size="small" title={t("common.delete")} onClick={() => void confirmDialog({ message: t("images.deleteConfirm"), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && del(`/images/${img.id}`).then(reload))}>
<Icon name="trash" />
</button>
</Button>
</div>
</figcaption>
</figure>
+10 -10
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useState } from "react";
import { patch } from "../api";
import { useT } from "../i18n";
@@ -21,13 +23,12 @@ export function InstructionsDialog({ sessionId, value, onClose }: { sessionId: s
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal instructions-modal" role="dialog" aria-label={t("instructions.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} className="instructions-modal" role="dialog" aria-label={t("instructions.title")}>
<h3>{t("instructions.title")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>
{t("instructions.hint")}
</div>
<textarea
<Input.TextArea
autoFocus
rows={10}
style={{ width: "100%" }}
@@ -39,17 +40,16 @@ export function InstructionsDialog({ sessionId, value, onClose }: { sessionId: s
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
{value && (
<button className="danger" onClick={() => void save("")} disabled={busy}>
<Button danger onClick={() => void save("")} disabled={busy}>
{t("instructions.clear")}
</button>
</Button>
)}
<span className="spacer" />
<button onClick={onClose}>{t("common.cancel")}</button>
<button className="primary" onClick={() => void save(text)} disabled={busy || text.trim() === value.trim()}>
<Button onClick={onClose}>{t("common.cancel")}</Button>
<Button type="primary" onClick={() => void save(text)} disabled={busy || text.trim() === value.trim()}>
{t("common.save")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+18 -17
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { Icon } from "./Icon";
import { useState } from "react";
import { post } from "../api";
@@ -98,12 +99,12 @@ export function PermissionCard({ req, currentId }: { req: PermissionRequest; cur
<Icon name="sparkle" className="tiny" /> {explanation}
</div>
) : (
<button className="small ghost explain-btn" disabled={explaining} onClick={explain}>
<Button type="text" size="small" className="explain-btn" disabled={explaining} onClick={explain}>
<Icon name="sparkle" /> {explaining ? t("permission.explaining") : t("permission.explain")}
</button>
</Button>
)}
{explainError && <div className="hint">{explainError}</div>}
<input
<Input
style={{ width: "100%", marginTop: 8 }}
placeholder={t("permission.feedback")}
value={feedback}
@@ -111,20 +112,20 @@ export function PermissionCard({ req, currentId }: { req: PermissionRequest; cur
onKeyDown={(e) => e.key === "Enter" && reply("reject")}
/>
<div className="actions">
<button className="primary" disabled={busy || (hunkCount > 1 && chosen === 0)} onClick={() => reply("once")} autoFocus>
<Button type="primary" disabled={busy || (hunkCount > 1 && chosen === 0)} onClick={() => reply("once")} autoFocus>
{partial ? t("permission.applySelected", { k: chosen, n: hunkCount }) : t("permission.allowOnce")}
</button>
<button disabled={busy || partial} onClick={() => reply("always")}>
</Button>
<Button disabled={busy || partial} onClick={() => reply("always")}>
{alwaysLabel}
</button>
</Button>
{!dangerous && (
<button disabled={busy || partial} onClick={() => reply("project")} title={t("permission.projectHint")}>
<Button disabled={busy || partial} onClick={() => reply("project")} title={t("permission.projectHint")}>
{projectLabel}
</button>
</Button>
)}
<button className="danger" disabled={busy} onClick={() => reply("reject")}>
<Button danger disabled={busy} onClick={() => reply("reject")}>
{feedback ? t("permission.rejectWithFeedback") : t("permission.reject")}
</button>
</Button>
</div>
</div>
);
@@ -194,7 +195,7 @@ export function QuestionCard({ req, currentId }: { req: QuestionRequest; current
<Icon name={q.multi_select ? (isSel ? "box-on" : "box-off") : isSel ? "radio-on" : "radio-off"} />
<div style={{ flex: 1 }}>
{o.label === OTHER ? (
<input
<Input
style={{ width: "100%" }}
placeholder={t("question.other")}
value={other[qi] ?? ""}
@@ -214,7 +215,7 @@ export function QuestionCard({ req, currentId }: { req: QuestionRequest; current
})}
</div>
) : (
<textarea
<Input.TextArea
style={{ width: "100%", marginTop: 6 }}
placeholder={t("question.answer")}
value={other[qi] ?? ""}
@@ -224,12 +225,12 @@ export function QuestionCard({ req, currentId }: { req: QuestionRequest; current
</div>
))}
<div className="actions">
<button className="primary" disabled={busy || !complete} onClick={() => submit()}>
<Button type="primary" disabled={busy || !complete} onClick={() => submit()}>
{t("question.submit")}
</button>
<button disabled={busy} onClick={() => submit(true)}>
</Button>
<Button disabled={busy} onClick={() => submit(true)}>
{t("question.dismiss")}
</button>
</Button>
</div>
</div>
);
+40 -32
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input, Segmented } from "antd";
import { Select } from "../ui/Select";
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
import { ApiError, get, patch, post, put } from "../api";
import { confirmDialog, toast } from "../dialogs";
@@ -174,35 +176,42 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
<button className="small ghost" onClick={back} title={t("jobEditor.back")} aria-label={t("jobEditor.back")}>
</Button>
<Button type="text" size="small" onClick={back} title={t("jobEditor.back")} aria-label={t("jobEditor.back")}>
<Icon name="arrow-left" />
</button>
</Button>
<div className="grow">
<h1>{settings.name || t("nav.jobs")}</h1>
<div className="path mono">{job.path}</div>
</div>
<label className="switch" title={t(job.enabled ? "jobs.disable" : "jobs.enable")}>
<input type="checkbox" checked={job.enabled} onChange={(e) => void setEnabled(e.target.checked)} />
<Checkbox className="switch" title={t(job.enabled ? "jobs.disable" : "jobs.enable")} checked={job.enabled} onChange={(e) => void setEnabled(e.target.checked)}>
<span>{t(job.enabled ? "jobs.on" : "jobs.off")}</span>
</label>
<button className="small ghost" onClick={runNow} title={t("jobs.runNow")}>
</Checkbox>
<Button type="text" size="small" onClick={runNow} title={t("jobs.runNow")}>
<Icon name="play" /> <span className="hide-mobile">{t("jobs.runNow")}</span>
</button>
<button className="small primary" disabled={!dirty || saving} onClick={() => void save()}>
</Button>
<Button type="primary" size="small" disabled={!dirty || saving} onClick={() => void save()}>
{saving ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
</button>
</Button>
</div>
<div className="job-tabs" role="tablist">
{(["prompt", "settings", "assistant"] as Tab[]).map((x) => (
<button key={x} role="tab" aria-selected={tab === x} className={tab === x ? "active" : ""} onClick={() => setTab(x)}>
{t(`jobEditor.tab.${x}` as const)}
{x === "prompt" && fileDirty && " •"}
{x === "settings" && settingsDirty && " •"}
</button>
))}
<div className="job-tabs">
<Segmented<Tab>
block
value={tab}
onChange={setTab}
options={(["prompt", "settings", "assistant"] as Tab[]).map((x) => ({
value: x,
label: (
<>
{t(`jobEditor.tab.${x}` as const)}
{x === "prompt" && fileDirty && " •"}
{x === "settings" && settingsDirty && " •"}
</>
),
}))}
/>
</div>
<div className={`job-editor tab-${tab}`}>
<div className="job-editor-main">
@@ -210,7 +219,7 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
<div className="job-editor-row">
<label className="field" style={{ flex: 2 }}>
<span>{t("jobs.tplName")}</span>
<input value={settings.name} onChange={(e) => up({ name: e.target.value })} />
<Input value={settings.name} onChange={(e) => up({ name: e.target.value })} />
</label>
<div className="job-editor-status">
<span>
@@ -233,19 +242,19 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
<div className="job-editor-row">
<label className="field">
<span>{t("jobs.tplMode")}</span>
<select value={settings.agent} onChange={(e) => up({ agent: e.target.value })}>
<Select value={settings.agent} onChange={(e) => up({ agent: e.target.value })}>
<option value="build">build</option>
<option value="plan">plan</option>
</select>
</Select>
</label>
<label className="field">
<span>{t("jobs.permissionMode")}</span>
<select value={settings.permission_mode} title={t("jobs.permissionModeHint")} onChange={(e) => up({ permission_mode: e.target.value })}>
<Select value={settings.permission_mode} title={t("jobs.permissionModeHint")} onChange={(e) => up({ permission_mode: e.target.value })}>
<option value="default">{t("permissionMode.default")}</option>
<option value="auto">{t("permissionMode.auto")}</option>
<option value="accept_edits">{t("permissionMode.accept_edits")}</option>
<option value="bypass">{t("permissionMode.bypass")}</option>
</select>
</Select>
</label>
<label className="field">
<span>{t("composer.model")}</span>
@@ -253,13 +262,12 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
</label>
<label className="field" style={{ maxWidth: 140 }}>
<span>{t("jobEditor.timeout")}</span>
<input type="number" min={1} max={1440} value={settings.timeout_minutes} onChange={(e) => up({ timeout_minutes: Math.max(1, Number(e.target.value) || 60) })} />
<Input type="number" min={1} max={1440} value={settings.timeout_minutes} onChange={(e) => up({ timeout_minutes: Math.max(1, Number(e.target.value) || 60) })} />
</label>
</div>
<label className="row" style={{ gap: 6, alignItems: "center", marginTop: 6 }}>
<input type="checkbox" checked={settings.notify} onChange={(e) => up({ notify: e.target.checked })} />
<Checkbox className="row" style={{ gap: 6, alignItems: "center", marginTop: 6 }} checked={settings.notify} onChange={(e) => up({ notify: e.target.checked })}>
{t("jobEditor.notify")}
</label>
</Checkbox>
{settings.permission_mode !== "bypass" && <div className="hint">{t("jobEditor.bypassHint")}</div>}
</section>
<section className="job-editor-prompt">
@@ -270,9 +278,9 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
{changedOnDisk && (
<div className="notice">
{t("jobEditor.changedOnDisk")}{" "}
<button className="small" onClick={() => void loadFile(job.path)}>
<Button size="small" onClick={() => void loadFile(job.path)}>
{t("jobEditor.reload")}
</button>
</Button>
</div>
)}
{job.error && !job.error.includes("empty") && <div className="notice err">{job.error}</div>}
@@ -292,9 +300,9 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
<div className="job-assistant-start">
<Icon name="sparkle" />
<p>{t("jobEditor.assistantIntro")}</p>
<button className="primary" onClick={startAssistant}>
<Button type="primary" onClick={startAssistant}>
{t("jobEditor.assistantStart")}
</button>
</Button>
</div>
)}
</aside>
+20 -23
View File
@@ -1,3 +1,4 @@
import { Button, Checkbox, Input } from "antd";
import { useEffect, useState } from "react";
import { del, get, patch, post } from "../api";
import { fmtRelative, useT } from "../i18n";
@@ -56,9 +57,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>{t("nav.jobs")}</h1>
</div>
@@ -67,9 +68,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
<div className="page-inner" style={{ maxWidth: 980 }}>
<div className="notice">{t("jobs.intro")}</div>
<div className="row" style={{ margin: "12px 0" }}>
<button className="primary" onClick={() => setTemplates(true)}>
<Button type="primary" onClick={() => setTemplates(true)}>
<Icon name="plus" /> {t("jobs.new")}
</button>
</Button>
</div>
{templates && <NewJobDialog onClose={() => setTemplates(false)} />}
{!jobs && <div className="empty"><Spinner /></div>}
@@ -86,10 +87,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
</h3>
<div className="hint mono">{j.path}</div>
</div>
<label className="switch" title={t(j.enabled ? "jobs.disable" : "jobs.enable")}>
<input type="checkbox" checked={j.enabled} onChange={(e) => act(j.id, () => patch(`/jobs/${j.id}`, { enabled: e.target.checked }))} />
<Checkbox className="switch" title={t(j.enabled ? "jobs.disable" : "jobs.enable")} checked={j.enabled} onChange={(e) => act(j.id, () => patch(`/jobs/${j.id}`, { enabled: e.target.checked }))}>
<span>{t(j.enabled ? "jobs.on" : "jobs.off")}</span>
</label>
</Checkbox>
</div>
{j.error ? (
<div className="notice err">{j.error}</div>
@@ -126,8 +126,7 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
<span>
<Icon name="external" /> {t("jobs.webhook")}: {j.webhook ? t("jobs.on") : t("jobs.off")}
</span>
<button
className="small ghost"
<Button type="text" size="small"
onClick={() =>
act(j.id, async () => {
const r = await post<{ url?: string; secret?: string }>(`/jobs/${j.id}/webhook`, { enable: !j.webhook });
@@ -136,10 +135,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
}
>
{j.webhook ? t("jobs.webhookOff") : t("jobs.webhookOn")}
</button>
</Button>
{j.webhook && (
<button
className="small ghost"
<Button type="text" size="small"
onClick={() =>
act(j.id, async () => {
const r = await post<{ url: string; secret: string }>(`/jobs/${j.id}/webhook`, { enable: true });
@@ -148,7 +146,7 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
}
>
{t("jobs.webhookRenew")}
</button>
</Button>
)}
</div>
{hook?.id === j.id && (
@@ -161,24 +159,23 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
</div>
)}
<div className="row" style={{ gap: 8, marginTop: 10 }}>
<button className="small" disabled={busy === j.id || !!j.error} onClick={() => act(j.id, async () => {
<Button size="small" disabled={busy === j.id || !!j.error} onClick={() => act(j.id, async () => {
const r = await post<{ session_id: string }>(`/jobs/${j.id}/run`, {});
navigate(`/s/${r.session_id}`);
})}>
{busy === j.id ? <Spinner small /> : <Icon name="play" />} {t("jobs.runNow")}
</button>
<button className="small" onClick={() => navigate(`/jobs/${j.id}`)}>
</Button>
<Button size="small" onClick={() => navigate(`/jobs/${j.id}`)}>
<Icon name="edit" /> {t("jobs.edit")}
</button>
</Button>
<span className="grow" />
<button
className="small ghost danger"
<Button type="text" danger size="small"
onClick={async () => {
if (await confirmDialog({ message: t("jobs.deleteConfirm", { name: j.spec?.name ?? j.path }), danger: true })) void act(j.id, () => del(`/jobs/${j.id}`));
}}
>
<Icon name="trash" /> {t("jobs.remove")}
</button>
</Button>
</div>
</div>
))}
@@ -186,14 +183,14 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
<h3>{t("jobs.register")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>{t("jobs.registerHint")}</div>
<div className="row" style={{ gap: 8 }}>
<input className="mono" style={{ flex: 1, minWidth: 0 }} value={path} placeholder="/workspace/project/.codecraft/jobs/nightly.md" onChange={(e) => setPath(e.target.value)} />
<button disabled={!path.trim()} onClick={() => act("new", async () => {
<Input className="mono" style={{ flex: 1, minWidth: 0 }} value={path} placeholder="/workspace/project/.codecraft/jobs/nightly.md" onChange={(e) => setPath(e.target.value)} />
<Button disabled={!path.trim()} onClick={() => act("new", async () => {
const j = await post<JobInfo>("/jobs", { path: path.trim() });
setPath("");
navigate(`/jobs/${j.id}`);
})}>
{t("jobs.registerBtn")}
</button>
</Button>
</div>
</div>
</div>
+7 -6
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { useState } from "react";
import { post } from "../api";
import { useT } from "../i18n";
@@ -35,14 +36,14 @@ export function Login({ info, onSuccess }: { info: Info; onSuccess: () => void }
<img src="/icon.svg" alt="" />
<h2 style={{ margin: 0 }}>CodeCraft</h2>
<div style={{ color: "var(--fg3)" }}>{setup ? t("login.setupPrompt") : t("login.prompt")}</div>
{setup && <input autoFocus placeholder={t("login.setupCode")} value={form.code} onChange={set("code")} autoComplete="one-time-code" />}
<input autoFocus={!setup} placeholder={t("login.username")} value={form.username} onChange={set("username")} autoComplete="username" autoCapitalize="none" />
<input type="password" placeholder={t("login.password")} value={form.password} onChange={set("password")} autoComplete={setup ? "new-password" : "current-password"} />
{setup && <input type="password" placeholder={t("login.passwordRepeat")} value={form.password2} onChange={set("password2")} autoComplete="new-password" />}
{setup && <Input autoFocus placeholder={t("login.setupCode")} value={form.code} onChange={set("code")} autoComplete="one-time-code" />}
<Input autoFocus={!setup} placeholder={t("login.username")} value={form.username} onChange={set("username")} autoComplete="username" autoCapitalize="none" />
<Input.Password placeholder={t("login.password")} value={form.password} onChange={set("password")} autoComplete={setup ? "new-password" : "current-password"} />
{setup && <Input.Password placeholder={t("login.passwordRepeat")} value={form.password2} onChange={set("password2")} autoComplete="new-password" />}
{error && <div style={{ color: "var(--red)" }}>{error}</div>}
<button className="primary" type="submit" disabled={busy || !form.username || !form.password}>
<Button type="primary" htmlType="submit" disabled={busy || !form.username || !form.password}>
{setup ? t("login.createAdmin") : t("login.submit")}
</button>
</Button>
{!setup && info.oidc && (
<>
<div style={{ color: "var(--muted)", fontSize: 12 }}>{t("login.or")}</div>
+3 -2
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { Icon } from "./Icon";
import { memo, useState, type ReactNode } from "react";
import ReactMarkdown from "react-markdown";
@@ -36,9 +37,9 @@ export function SvgBlock({ code, children }: { code: string; children?: ReactNod
<FileFigure name="inline.svg" size={new Blob([code]).size} mime="image/svg+xml">
<img src={url} alt="SVG" />
</FileFigure>
<button className="small ghost" onClick={() => setShowCode(!showCode)}>
<Button type="text" size="small" onClick={() => setShowCode(!showCode)}>
<Icon name={showCode ? "chevron-down" : "chevron-right"} /> SVG
</button>
</Button>
{showCode && children}
</div>
);
+18 -18
View File
@@ -1,3 +1,5 @@
import { Button } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useState } from "react";
import { get } from "../api";
import { useT, type Key } from "../i18n";
@@ -58,22 +60,21 @@ export function MediaGallery({ sessionId, onClose, onJump }: { sessionId: string
}, [current, shown.length, onClose]);
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal media-gallery" role="dialog" aria-label={t("media.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} className="media-gallery" role="dialog" aria-label={t("media.title")}>
<div className="media-head">
<h3>
<Icon name="image" /> {t("media.title")}
</h3>
<div className="media-filters" role="radiogroup">
{(["all", "image", "video", "audio", "model"] as Filter[]).map((k) => (
<button key={k} role="radio" aria-checked={filter === k} className={`chip-btn ${filter === k ? "active" : ""}`} onClick={() => (setFilter(k), setOpen(undefined))} disabled={!!items && count(k) === 0 && k !== "all"}>
<Button key={k} role="radio" aria-checked={filter === k} size="small" shape="round" type={filter === k ? "primary" : "default"} onClick={() => (setFilter(k), setOpen(undefined))} disabled={!!items && count(k) === 0 && k !== "all"}>
{t(`media.filter.${k}` as Key)} {items && <small>{count(k)}</small>}
</button>
</Button>
))}
</div>
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</Button>
</div>
{error && <div className="notice err">{error}</div>}
{!items && !error && (
@@ -92,34 +93,34 @@ export function MediaGallery({ sessionId, onClose, onJump }: { sessionId: string
<div className="media-model">
{current.preview ? <img src={current.preview} alt={current.name} /> : <Icon name="cube" />}
{current.path && (
<button className="primary" onClick={() => open3d(current.path!)}>
<Button type="primary" onClick={() => open3d(current.path!)}>
<Icon name="cube" /> {t("tool.open3d")}
</button>
</Button>
)}
</div>
)}
</div>
<div className="media-bar">
<button className="small ghost" disabled={open === 0} onClick={() => setOpen((o) => (o ?? 1) - 1)} aria-label={t("media.prev")}>
<Button type="text" size="small" disabled={open === 0} onClick={() => setOpen((o) => (o ?? 1) - 1)} aria-label={t("media.prev")}>
<Icon name="arrow-left" />
</button>
</Button>
<span className="grow">
{current.name} · {t(`media.source.${current.source}` as Key)} · {new Date(current.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
</span>
{current.message_id && (
<button className="small" onClick={() => onJump(current.message_id!)}>
<Button size="small" onClick={() => onJump(current.message_id!)}>
{t("media.showInChat")}
</button>
</Button>
)}
<a className="small button" href={current.url} target="_blank" rel="noreferrer">
<Icon name="external" /> {t("media.open")}
</a>
<button className="small ghost" disabled={open === shown.length - 1} onClick={() => setOpen((o) => (o ?? 0) + 1)} aria-label={t("media.next")}>
<Button type="text" size="small" disabled={open === shown.length - 1} onClick={() => setOpen((o) => (o ?? 0) + 1)} aria-label={t("media.next")}>
<Icon name="arrow-right" />
</button>
<button className="small ghost" onClick={() => setOpen(undefined)} aria-label={t("media.back")}>
</Button>
<Button type="text" size="small" onClick={() => setOpen(undefined)} aria-label={t("media.back")}>
<Icon name="close" />
</button>
</Button>
</div>
</div>
) : (
@@ -149,7 +150,6 @@ export function MediaGallery({ sessionId, onClose, onJump }: { sessionId: string
))}
</div>
)}
</div>
</div>
</Modal>
);
}
+3 -2
View File
@@ -1,3 +1,4 @@
import { Select } from "../ui/Select";
import { useModels, modelOptions } from "../hooks";
/** Model picker; keeps unknown current values selectable. */
@@ -5,7 +6,7 @@ export function ModelSelect({ value, onChange, title, emptyLabel }: { value: str
const options = modelOptions(useModels());
const known = options.some((o) => o.value === value);
return (
<select value={value} onChange={(e) => onChange(e.target.value)} title={title}>
<Select value={value} onChange={(e) => onChange(e.target.value)} title={title}>
{emptyLabel !== undefined && <option value="">{emptyLabel}</option>}
{!known && value && <option value={value}>{value}</option>}
{options.map((o) => (
@@ -13,6 +14,6 @@ export function ModelSelect({ value, onChange, title, emptyLabel }: { value: str
{o.label}
</option>
))}
</select>
</Select>
);
}
+8 -8
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useState } from "react";
import { post } from "../api";
import { getLang, useT } from "../i18n";
@@ -82,12 +84,11 @@ export function NewJobDialog({ onClose }: { onClose: () => void }) {
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal job-tpl" role="dialog" aria-label={t("jobs.new")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} className="job-tpl" role="dialog" aria-label={t("jobs.new")}>
<h3>{t("jobs.new")}</h3>
<label className="field">
<span>{t("jobs.tplName")}</span>
<input autoFocus value={name} placeholder={t("jobs.namePlaceholder")} onChange={(e) => setName(e.target.value)} />
<Input autoFocus value={name} placeholder={t("jobs.namePlaceholder")} onChange={(e) => setName(e.target.value)} />
</label>
<div className="field">
<span>{t("jobs.tplProject")}</span>
@@ -117,12 +118,11 @@ export function NewJobDialog({ onClose }: { onClose: () => void }) {
</div>
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
<button onClick={onClose}>{t("common.cancel")}</button>
<button className="primary" disabled={busy || !cwd || !name.trim()} onClick={create}>
<Button onClick={onClose}>{t("common.cancel")}</Button>
<Button type="primary" disabled={busy || !cwd || !name.trim()} onClick={create}>
{t("jobs.createAndEdit")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+37 -36
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input, Segmented } from "antd";
import { Select } from "../ui/Select";
import { Icon } from "./Icon";
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { post } from "../api";
@@ -353,9 +355,9 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>{t("new.title")}</h1>
</div>
@@ -433,9 +435,9 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
<i style={{ width: `${Math.round(progress[f.name] * 100)}%` }} />
</span>
) : (
<button className="small ghost" onClick={() => setOriginals((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Button type="text" size="small" onClick={() => setOriginals((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
)}
</div>
))}
@@ -446,7 +448,7 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
<Step n={n++} title={t("wizard.sayWhat")}>
{needsUrl && (
<input
<Input
className="wiz-url"
type="url"
value={url}
@@ -462,7 +464,7 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
void addFiles(e.dataTransfer.files);
}}
>
<textarea
<Input.TextArea
value={text}
placeholder={t(task === "craft" ? (`wizard.placeholder.${target}` as Key) : task === "cad" ? "wizard.placeholder.cad" : task === "chat" ? "wizard.placeholder.chat" : "wizard.placeholder.task")}
onChange={(e) => setText(e.target.value)}
@@ -484,26 +486,26 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
{images.map((img, i) => (
<div className="att" key={`i${i}`}>
<img src={imageSrc(img)} alt="" />
<button onClick={() => setImages((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Button onClick={() => setImages((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
</div>
))}
{files.map((f, i) => (
<div className="att file" key={`f${i}`}>
<span><Icon name="file" /> {f.name}</span>
<small>{formatSize(f.size)}</small>
<button onClick={() => setFiles((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Button onClick={() => setFiles((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
</div>
))}
</div>
)}
<div className="wiz-input-foot">
<button type="button" className="ghost small" onClick={() => fileInput.current?.click()} title={t("wizard.attach")}>
<Button type="text" size="small" onClick={() => fileInput.current?.click()} title={t("wizard.attach")}>
{ICONS.clip}
</button>
</Button>
<span>{target === "software" && task === "craft" ? t("wizard.softwareHint") : t("wizard.enterHint")}</span>
<input ref={fileInput} type="file" multiple hidden onChange={(e) => e.target.files && void addFiles(e.target.files)} />
</div>
@@ -512,9 +514,9 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
<div className="wiz-ideas">
<span>{t("wizard.ideas")}</span>
{ideas.map((k) => (
<button key={k} type="button" className="chip-btn" onClick={() => setText(t(k))}>
<Button key={k} size="small" shape="round" onClick={() => setText(t(k))}>
{t(k)}
</button>
</Button>
))}
</div>
)}
@@ -536,7 +538,7 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
))}
</div>
{folderMode === "git" && (
<input className="wiz-url" value={repoUrl} placeholder="https://git.example.com/user/repo.git" onChange={(e) => setRepoUrl(e.target.value)} />
<Input className="wiz-url" value={repoUrl} placeholder="https://git.example.com/user/repo.git" onChange={(e) => setRepoUrl(e.target.value)} />
)}
{folderMode !== "existing" && (
<div className="wiz-folder">
@@ -544,18 +546,18 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
<span className="wiz-folder-text">
{t(folderMode === "git" ? "wizard.cloneInto" : "wizard.newFolderIn")}{" "}
{roots.length > 1 ? (
<select value={rootPath} onChange={(e) => setRootPath(e.target.value)}>
<Select value={rootPath} onChange={(e) => setRootPath(e.target.value)}>
{roots.map((r) => (
<option key={r.path} value={r.path}>
{r.name === "/" ? "workspace" : r.name}
</option>
))}
</select>
</Select>
) : (
<code>{!roots[0] || roots[0].name === "/" ? "workspace" : roots[0].name}</code>
)}
<span>/</span>
<input
<Input
className="wiz-folder-name"
value={folderName}
onChange={(e) => {
@@ -568,22 +570,21 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
)}
{folderMode === "existing" && <FolderPicker path={picked} onPick={setPicked} />}
{folderMode !== "new" && (
<label className="wiz-check-row">
<input type="checkbox" checked={isolated} onChange={(e) => setIsolated(e.target.checked)} />
<Checkbox className="wiz-check-row" checked={isolated} onChange={(e) => setIsolated(e.target.checked)}>
<span>
<b>{t("worktree.isolate")}</b>
<span className="hint"> – {t("worktree.isolateHint")}</span>
</span>
</label>
</Checkbox>
)}
</>
)}
{error && <div className="notice err">{error}</div>}
<div className="wiz-start-row">
<button className="primary wiz-start" disabled={!canStart} onClick={create}>
<Button type="primary" className="wiz-start" disabled={!canStart} onClick={create}>
{ICONS.start}
{creating ?? t("wizard.start")}
</button>
</Button>
</div>
</div>
</div>
@@ -624,37 +625,37 @@ export function FolderPicker({ path, onPick }: { path: string; onPick: (p: strin
return (
<div className="wiz-picker">
{roots.length > 1 && (
<div className="mode-tabs" style={{ marginBottom: 8, flexWrap: "wrap" }}>
{roots.map((r) => (
<button key={r.path} className={listing?.root === r.path ? "active" : ""} onClick={() => setBrowse(r.path)}>
{r.name}
</button>
))}
</div>
<Segmented
className="seg-wrap"
style={{ marginBottom: 8 }}
value={listing?.root ?? ""}
onChange={(path) => setBrowse(path)}
options={roots.map((r) => ({ value: r.path, label: r.name }))}
/>
)}
<div className="row" style={{ marginBottom: 8 }}>
<code className="grow" style={{ flex: 1 }}>
{rel}
</code>
{listing?.parent && (
<button className="small" onClick={() => setBrowse(listing.parent!)}>
<Button size="small" onClick={() => setBrowse(listing.parent!)}>
<Icon name="arrow-up" /> {t("new.up")}
</button>
</Button>
)}
{listing && (
<button className="small" onClick={() => void newFolder()}>
<Button size="small" onClick={() => void newFolder()}>
<Icon name="plus" /> {t("files.newFolder")}
</button>
</Button>
)}
</div>
<div className="dir-list">
{listing?.dirs.length === 0 && <div className="empty" style={{ padding: 16 }}>{t("new.noSubdirs")}</div>}
{listing?.dirs.map((d) => (
<button key={d.path} onClick={() => setBrowse(d.path)}>
<Button key={d.path} onClick={() => setBrowse(d.path)}>
{ICONS.folder}
<span style={{ flex: 1 }}>{d.name}</span>
{d.git && <span className="chip">git</span>}
</button>
</Button>
))}
</div>
</div>
+5 -4
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect } from "react";
import { useT } from "../i18n";
import { flushOutbox, removeFromOutbox, useOutbox } from "../outbox";
@@ -22,16 +23,16 @@ export function OutboxBar({ sessionId }: { sessionId: string }) {
<div className="outbox-head">
<Icon name="clock" className="tiny" /> {t("outbox.waiting", { n: items.length })}
<span className="grow" />
<button className="small" onClick={() => void flushOutbox(sessionId)}>
<Button size="small" onClick={() => void flushOutbox(sessionId)}>
{t("outbox.sendNow")}
</button>
</Button>
</div>
{items.map((i) => (
<div key={i.id} className="outbox-item">
<span>{i.text.length > 120 ? `${i.text.slice(0, 120)}…` : i.text}</span>
<button className="small ghost" onClick={() => removeFromOutbox(i.id)} aria-label={t("outbox.discard")} title={t("outbox.discard")}>
<Button type="text" size="small" onClick={() => removeFromOutbox(i.id)} aria-label={t("outbox.discard")} title={t("outbox.discard")}>
<Icon name="close" />
</button>
</Button>
</div>
))}
</div>
+5 -5
View File
@@ -1,3 +1,5 @@
import { Input } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useMemo, useState } from "react";
import { fmtRelative, useT, type Key } from "../i18n";
import { navigate } from "../router";
@@ -103,9 +105,8 @@ export function Palette() {
const close = () => setOpen(false);
return (
<div className="modal-backdrop palette-backdrop" onClick={close}>
<div className="modal palette" role="dialog" aria-label={t("palette.title")} onClick={(e) => e.stopPropagation()}>
<input
<Modal onClose={close} className="palette" role="dialog" aria-label={t("palette.title")}>
<Input
autoFocus
value={q}
placeholder={t("palette.placeholder")}
@@ -142,7 +143,6 @@ export function Palette() {
<span><kbd>Alt+<Icon name="arrow-up" className="tiny" /></kbd><kbd>Alt+<Icon name="arrow-down" className="tiny" /></kbd> {t("palette.prevNext")}</span>
<span><kbd>Esc</kbd> {t("palette.close")}</span>
</div>
</div>
</div>
</Modal>
);
}
+5 -4
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useMemo } from "react";
import { useFetch } from "../hooks";
import { fmtCost, fmtDate, fmtRelative, useT, type Key } from "../i18n";
@@ -54,18 +55,18 @@ export function ProjectPage({ cwd, onMenu }: { cwd: string; onMenu: () => void }
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>
<Icon name="folder" /> {basename(cwd) || "/"}
</h1>
<div className="path mono">{cwd}</div>
</div>
<button className="small primary" onClick={newChat}>
<Button type="primary" size="small" onClick={newChat}>
<Icon name="plus" /> {t("project.newChat")}
</button>
</Button>
</div>
<div className="chat-scroll">
<div className="chat project-page">
+7 -7
View File
@@ -1,3 +1,5 @@
import { Button } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useState } from "react";
import { api, get } from "../api";
import { useT } from "../i18n";
@@ -23,8 +25,7 @@ export function ProjectPermissions({ sessionId, cwd, onClose }: { sessionId: str
}
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal" role="dialog" aria-label={t("permProject.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} role="dialog" aria-label={t("permProject.title")}>
<h3>
<Icon name="lock" /> {t("permProject.title")}
</h3>
@@ -39,17 +40,16 @@ export function ProjectPermissions({ sessionId, cwd, onClose }: { sessionId: str
{keys.map((k) => (
<li key={k} className="row" style={{ justifyContent: "space-between" }}>
<code>{label(k)}</code>
<button className="small danger" onClick={() => void revoke(k)}>
<Button danger size="small" onClick={() => void revoke(k)}>
{t("permProject.revoke")}
</button>
</Button>
</li>
))}
</ul>
)}
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
<button onClick={onClose}>{t("common.close")}</button>
<Button onClick={onClose}>{t("common.close")}</Button>
</div>
</div>
</div>
</Modal>
);
}
+9 -8
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { Icon } from "./Icon";
import { del, post } from "../api";
import { useT } from "../i18n";
@@ -17,11 +18,12 @@ export function QueueList({ sessionId, busy }: { sessionId: string; busy: boolea
<div className="queue">
<div className="queue-head">
<span>{busy ? t("queue.pending", { n: items.length }) : t("queue.stopped", { n: items.length })}</span>
{!busy && (
<button className="small primary" onClick={() => post(`/sessions/${sessionId}/queue/flush`).catch((e) => toast(e.message))}>
{t("queue.sendNow")}
</button>
)}
<Button type="primary" size="small"
title={busy ? t("queue.forceHint") : undefined}
onClick={() => post(`/sessions/${sessionId}/queue/force`).catch((e) => toast(e.message))}
>
{busy ? t("queue.force") : t("queue.sendNow")}
</Button>
</div>
{items.map((it) => {
const text = it.parts.map((p) => (p.type === "text" ? p.text : "")).join(" ").trim();
@@ -34,14 +36,13 @@ export function QueueList({ sessionId, busy }: { sessionId: string; busy: boolea
<img key={i} src={imageSrc(p.image)} alt="" />
))}
{it.source !== "background" && (
<button
className="small ghost"
<Button type="text" size="small"
aria-label={t("queue.remove")}
title={t("queue.remove")}
onClick={() => del(`/sessions/${sessionId}/queue/${it.id}`).catch((e) => toast(e.message))}
>
<Icon name="close" />
</button>
</Button>
)}
</div>
);
+8 -6
View File
@@ -1,3 +1,5 @@
import { Button } from "antd";
import { Select } from "../ui/Select";
import { useState } from "react";
import { post } from "../api";
import { useT } from "../i18n";
@@ -11,14 +13,14 @@ export const EFFORTS = ["low", "medium", "high", "max"] as const;
export function EffortSelect({ value, onChange, compact }: { value: string; onChange: (v: string) => void; compact?: boolean }) {
const t = useT();
return (
<select className={compact ? "effort-select" : ""} value={value} onChange={(e) => onChange(e.target.value)} title={t("effort.title")} aria-label={t("effort.title")}>
<Select className={compact ? "effort-select" : ""} value={value} onChange={(e) => onChange(e.target.value)} title={t("effort.title")} aria-label={t("effort.title")}>
<option value="">{compact ? t("effort.autoShort") : t("effort.auto")}</option>
{EFFORTS.map((e) => (
<option key={e} value={e}>
{t(`effort.${e}` as any)}
</option>
))}
</select>
</Select>
);
}
@@ -42,18 +44,18 @@ export function RegenerateButton({ sessionId, messageId, model }: { sessionId: s
};
return (
<div className="regen">
<button className="small ghost" onClick={() => setOpen(!open)} title={t("regen.title")}>
<Button type="text" size="small" onClick={() => setOpen(!open)} title={t("regen.title")}>
<Icon name="refresh" /> {t("regen.button")}
</button>
</Button>
{open && (
<div className="regen-panel">
<div className="hint">{t("regen.hint")}</div>
<div className="row" style={{ gap: 6, flexWrap: "wrap" }}>
<ModelSelect value={m} onChange={setM} />
<EffortSelect value={effort} onChange={setEffort} />
<button className="small primary" disabled={busy} onClick={go}>
<Button type="primary" size="small" disabled={busy} onClick={go}>
<Icon name="refresh" /> {t("regen.go")}
</button>
</Button>
</div>
</div>
)}
+10 -10
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useState } from "react";
import { patch, post } from "../api";
import { useFetch } from "../hooks";
@@ -41,10 +43,9 @@ export function RenameDialog({ sessionId, title, onClose }: { sessionId: string;
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal" role="dialog" aria-label={t("rename.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} role="dialog" aria-label={t("rename.title")}>
<h3>{t("rename.title")}</h3>
<input
<Input
autoFocus
style={{ width: "100%" }}
value={value}
@@ -55,18 +56,17 @@ export function RenameDialog({ sessionId, title, onClose }: { sessionId: string;
<div className="rename-gen">
<span className="hint">{t("rename.generateWith")}</span>
<ModelSelect value={chosen} onChange={setModel} />
<button className="small" onClick={generate} disabled={!!busy}>
<Button size="small" onClick={generate} disabled={!!busy}>
{busy === "gen" ? <Spinner small /> : <Icon name="sparkle" />} {t("rename.generate")}
</button>
</Button>
</div>
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
<button onClick={onClose}>{t("common.cancel")}</button>
<button className="primary" onClick={save} disabled={!!busy}>
<Button onClick={onClose}>{t("common.cancel")}</Button>
<Button type="primary" onClick={save} disabled={!!busy}>
{t("common.save")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+9 -10
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useState } from "react";
import { get, post } from "../api";
import { useT } from "../i18n";
@@ -23,8 +25,7 @@ export function RewindDialog({ sessionId, messageId, onDone, onClose }: { sessio
}
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal" role="dialog" aria-label={t("chat.rewind")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} role="dialog" aria-label={t("chat.rewind")}>
<h3>{t("chat.rewind")}</h3>
<p style={{ fontSize: 13, color: "var(--fg3)" }}>{t("rewind.intro")}</p>
{files === undefined ? (
@@ -33,9 +34,8 @@ export function RewindDialog({ sessionId, messageId, onDone, onClose }: { sessio
<p style={{ fontSize: 13 }}>{t("rewind.noFiles")}</p>
) : (
<>
<label className="row" style={{ marginBottom: 6 }}>
<input type="checkbox" checked={restore} onChange={(e) => setRestore(e.target.checked)} /> {t("rewind.restore", { n: files.length })}
</label>
<Checkbox className="row" style={{ marginBottom: 6 }} checked={restore} onChange={(e) => setRestore(e.target.checked)}> {t("rewind.restore", { n: files.length })}
</Checkbox>
<ul className="rewind-files">
{files.map((f) => (
<li key={f.path}>
@@ -47,12 +47,11 @@ export function RewindDialog({ sessionId, messageId, onDone, onClose }: { sessio
</>
)}
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
<button onClick={onClose}>{t("common.cancel")}</button>
<button className="primary" disabled={busy || files === undefined} onClick={go}>
<Button onClick={onClose}>{t("common.cancel")}</Button>
<Button type="primary" disabled={busy || files === undefined} onClick={go}>
{t("rewind.confirm")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+146 -159
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input, Segmented, Tabs } from "antd";
import { Select } from "../ui/Select";
import { Icon } from "./Icon";
import { useEffect, useState, useSyncExternalStore } from "react";
import { get, patch as apiPatch, post, put } from "../api";
@@ -65,16 +67,16 @@ function InterfaceSettings() {
<h3>{t("settings.interface")}</h3>
<div className="form">
<label>{t("settings.language")}</label>
<select value={getLang()} onChange={(e) => setLang(e.target.value)}>
<Select value={getLang()} onChange={(e) => setLang(e.target.value)}>
{Object.entries(languages).map(([k, v]) => (
<option key={k} value={k}>
{v.name}
</option>
))}
</select>
</Select>
<label>{t("settings.theme")}</label>
<div className="stack">
<select
<Select
value={theme}
onChange={(e) => {
const v = e.target.value as Theme;
@@ -86,30 +88,23 @@ function InterfaceSettings() {
{th.name}
</option>
))}
</select>
</Select>
<div className="hint">{t("settings.themeSource", { source: themeInfo.source, license: themeInfo.license })}</div>
</div>
<label>{t("settings.themeMode")}</label>
<div className="segmented">
{THEME_MODES.map((m) => (
<button
key={m}
className={`small ${m === mode ? "active" : "ghost"}`}
onClick={() => {
applyTheme(theme, m);
}}
>
{t(m === "auto" ? "settings.themeAuto" : m === "light" ? "settings.themeLight" : "settings.themeDark")}
</button>
))}
</div>
<Segmented
className="theme-mode"
value={mode}
onChange={(m) => applyTheme(theme, m)}
options={THEME_MODES.map((m) => ({ value: m, label: t(m === "auto" ? "settings.themeAuto" : m === "light" ? "settings.themeLight" : "settings.themeDark") }))}
/>
<label>{t("settings.reasoningDisplay")}</label>
<select value={reasoning} onChange={(e) => setReasoningMode(e.target.value as ReasoningMode)}>
<Select value={reasoning} onChange={(e) => setReasoningMode(e.target.value as ReasoningMode)}>
<option value="collapsed">{t("settings.reasoningCollapsed")}</option>
<option value="hidden">{t("settings.reasoningHidden")}</option>
<option value="live">{t("settings.reasoningLive")}</option>
<option value="expanded">{t("settings.reasoningExpanded")}</option>
</select>
</Select>
<div className="hint">{t("settings.reasoningHint")}</div>
<label>{t("settings.notifications")}</label>
<PushControl />
@@ -130,9 +125,9 @@ function InstallControl() {
if (prompt)
return (
<div>
<button className="small primary" onClick={() => void promptInstall()}>
<Button type="primary" size="small" onClick={() => void promptInstall()}>
<Icon name="download" /> {t("install.button")}
</button>
</Button>
</div>
);
return <div className="hint">{t(`install.hint.${platformHint()}` as Key)}</div>;
@@ -156,33 +151,22 @@ function DigestToggle() {
if (on === undefined) return null;
return (
<div className="row" style={{ gap: 8, flexBasis: "100%", alignItems: "center", flexWrap: "wrap" }}>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
<input
type="checkbox"
checked={on}
onChange={(e) => {
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={on} onChange={(e) => {
const v = e.target.checked;
setOn(v);
put("/push/digest", { enabled: v }).catch((err) => (setOn(!v), toast(err.message)));
}}
/>
}}>
{t("settings.digest")}
</label>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
<input
type="checkbox"
checked={weekly}
onChange={(e) => {
</Checkbox>
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={weekly} onChange={(e) => {
const v = e.target.checked;
setWeekly(v);
put("/push/digest", { weekly: v }).catch((err) => (setWeekly(!v), toast(err.message)));
}}
/>
}}>
{t("settings.weeklyDigest")}
</label>
</Checkbox>
{weekly && (
<button
className="small ghost"
<Button type="text" size="small"
onClick={() =>
post<{ sent: number; errors: string[] }>("/push/digest?weekly=true")
.then((r) => toast(r.sent ? t("settings.pushTestSent") : r.errors.join("; ") || t("settings.pushTestNone"), r.sent ? "success" : "error"))
@@ -190,11 +174,10 @@ function DigestToggle() {
}
>
{t("settings.digestNow")}
</button>
</Button>
)}
{on && (
<button
className="small ghost"
<Button type="text" size="small"
onClick={() =>
post<{ sent: number; errors: string[] }>("/push/digest")
.then((r) => toast(r.sent ? t("settings.pushTestSent") : r.errors.join("; ") || t("settings.pushTestNone"), r.sent ? "success" : "error"))
@@ -202,7 +185,7 @@ function DigestToggle() {
}
>
{t("settings.digestNow")}
</button>
</Button>
)}
</div>
);
@@ -242,8 +225,7 @@ function PushControl() {
{state === "on" ? (
<>
<span className="chip">{t("settings.notificationsOn")}</span>
<button
className="small"
<Button size="small"
disabled={busy}
onClick={run(async () => {
const r = await testPush();
@@ -252,16 +234,16 @@ function PushControl() {
})}
>
{t("settings.pushTest")}
</button>
<button className="small ghost" disabled={busy} onClick={run(async () => (await disablePush(), setState("off")))}>
</Button>
<Button type="text" size="small" disabled={busy} onClick={run(async () => (await disablePush(), setState("off")))}>
{t("settings.pushDisable")}
</button>
</Button>
<DigestToggle />
</>
) : (
<button className="small" disabled={busy} onClick={run(async () => (await enablePush(), setState("on")))}>
<Button size="small" disabled={busy} onClick={run(async () => (await enablePush(), setState("on")))}>
{t("settings.notificationsEnable")}
</button>
</Button>
)}
</div>
);
@@ -338,35 +320,35 @@ function General({ cfg, reload }: { cfg: ConfigResponse; reload: () => void }) {
<ModelSelect value={form.plan_model} emptyLabel={t("settings.sameAsChat")} onChange={(v) => setForm({ ...form, plan_model: v })} />
<div className="hint">{t("settings.planModelHint")}</div>
<label>{t("settings.transcribeModel")}</label>
<input value={form.transcribe_model} placeholder="openai/whisper-1" onChange={(e) => setForm({ ...form, transcribe_model: e.target.value })} />
<Input value={form.transcribe_model} placeholder="openai/whisper-1" onChange={(e) => setForm({ ...form, transcribe_model: e.target.value })} />
<div className="hint">{t("settings.transcribeHint")}</div>
<label>{t("settings.currency")}</label>
<input value={form.currency} onChange={(e) => setForm({ ...form, currency: e.target.value.toUpperCase() })} maxLength={3} />
<Input value={form.currency} onChange={(e) => setForm({ ...form, currency: e.target.value.toUpperCase() })} maxLength={3} />
<label>{t("settings.autoCompact")}</label>
<input type="number" min={0} max={1} step={0.05} value={form.auto_compact_threshold} onChange={(e) => setForm({ ...form, auto_compact_threshold: e.target.value })} />
<Input type="number" min={0} max={1} step={0.05} value={form.auto_compact_threshold} onChange={(e) => setForm({ ...form, auto_compact_threshold: e.target.value })} />
<div className="hint">{t("settings.autoCompactHint")}</div>
<label>{t("settings.commitTrailer")}</label>
<input className="mono" value={form.commit_trailer} placeholder={t("settings.commitTrailerOff")} onChange={(e) => setForm({ ...form, commit_trailer: e.target.value })} />
<Input className="mono" value={form.commit_trailer} placeholder={t("settings.commitTrailerOff")} onChange={(e) => setForm({ ...form, commit_trailer: e.target.value })} />
<div className="hint">{t("settings.commitTrailerHint")}</div>
<label>{t("settings.monthlyBudgetTotal")}</label>
<input type="number" min={0} value={form.monthly_budget} onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
<Input type="number" min={0} value={form.monthly_budget} onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
<div className="hint">{t("settings.monthlyBudgetHint")}</div>
<label>{t("settings.budgetWarning")}</label>
<input type="number" min={0} max={1} step={0.05} value={form.budget_warning} onChange={(e) => setForm({ ...form, budget_warning: e.target.value })} />
<Input type="number" min={0} max={1} step={0.05} value={form.budget_warning} onChange={(e) => setForm({ ...form, budget_warning: e.target.value })} />
<label>{t("settings.budgetAction")}</label>
<select value={form.budget_action} onChange={(e) => setForm({ ...form, budget_action: e.target.value })}>
<Select value={form.budget_action} onChange={(e) => setForm({ ...form, budget_action: e.target.value })}>
<option value="warn">{t("settings.budgetWarn")}</option>
<option value="block">{t("settings.budgetBlock")}</option>
</select>
</Select>
<label>{t("settings.sandbox")}</label>
<select value={form.sandbox_mode} onChange={(e) => setForm({ ...form, sandbox_mode: e.target.value })}>
<Select value={form.sandbox_mode} onChange={(e) => setForm({ ...form, sandbox_mode: e.target.value })}>
<option value="auto">{t("settings.sandboxAuto")}</option>
<option value="always">{t("settings.sandboxAlways")}</option>
<option value="off">{t("settings.sandboxOff")}</option>
</select>
</Select>
<div className="hint">{t("settings.sandboxHint")}</div>
<label>{t("settings.maxParallelSubagents")}</label>
<input type="number" min={0} value={form.max_parallel_subagents} onChange={(e) => setForm({ ...form, max_parallel_subagents: e.target.value })} />
<Input type="number" min={0} value={form.max_parallel_subagents} onChange={(e) => setForm({ ...form, max_parallel_subagents: e.target.value })} />
<div className="hint">{t("settings.maxParallelSubagentsHint")}</div>
</div>
</div>
@@ -374,40 +356,40 @@ function General({ cfg, reload }: { cfg: ConfigResponse; reload: () => void }) {
<h3>{t("settings.craft")}</h3>
<div className="form">
<label>{t("settings.cleanRoom")}</label>
<input type="checkbox" checked={form.clean_room} onChange={(e) => setForm({ ...form, clean_room: e.target.checked })} style={{ justifySelf: "start" }} />
<Checkbox checked={form.clean_room} onChange={(e) => setForm({ ...form, clean_room: e.target.checked })} style={{ justifySelf: "start" }} />
<div className="hint">{t("settings.cleanRoomHint")}</div>
<label>{t("settings.chromium")}</label>
<input value={form.chromium} onChange={(e) => setForm({ ...form, chromium: e.target.value })} />
<Input value={form.chromium} onChange={(e) => setForm({ ...form, chromium: e.target.value })} />
<label>{t("settings.widths")}</label>
<input value={form.widths} onChange={(e) => setForm({ ...form, widths: e.target.value })} />
<Input value={form.widths} onChange={(e) => setForm({ ...form, widths: e.target.value })} />
</div>
</div>
<div className="panel">
<h3>{t("settings.images")}</h3>
<div className="form">
<label>{t("settings.imagesEnabled")}</label>
<input type="checkbox" checked={form.images_enabled} onChange={(e) => setForm({ ...form, images_enabled: e.target.checked })} style={{ justifySelf: "start" }} />
<Checkbox checked={form.images_enabled} onChange={(e) => setForm({ ...form, images_enabled: e.target.checked })} style={{ justifySelf: "start" }} />
<label>{t("settings.imagesKey")}</label>
<input type="password" value={form.images_key} placeholder={cfg.config.images?.api_key === MASK ? t("settings.apiKeyStored") : "fal.ai API key"} onChange={(e) => setForm({ ...form, images_key: e.target.value })} />
<Input.Password value={form.images_key} placeholder={cfg.config.images?.api_key === MASK ? t("settings.apiKeyStored") : "fal.ai API key"} onChange={(e) => setForm({ ...form, images_key: e.target.value })} />
<label>{t("settings.imagesDefault")}</label>
<select value={form.images_model} onChange={(e) => setForm({ ...form, images_model: e.target.value })}>
<Select value={form.images_model} onChange={(e) => setForm({ ...form, images_model: e.target.value })}>
{(cfg.config.images?.models ?? []).map((m: any) => (
<option key={m.id} value={m.id}>
{m.name ?? m.id}
</option>
))}
</select>
</Select>
<label>{t("settings.monthlyBudget")}</label>
<input type="number" min={0} value={form.images_budget} placeholder="–" onChange={(e) => setForm({ ...form, images_budget: e.target.value })} />
<Input type="number" min={0} value={form.images_budget} placeholder="–" onChange={(e) => setForm({ ...form, images_budget: e.target.value })} />
<label>{t("settings.imagesDir")}</label>
<input value={form.images_dir} onChange={(e) => setForm({ ...form, images_dir: e.target.value })} />
<Input value={form.images_dir} onChange={(e) => setForm({ ...form, images_dir: e.target.value })} />
<div className="hint">{t("settings.imagesHint")}</div>
</div>
</div>
{view}
<button className="primary" onClick={save}>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
</>
);
}
@@ -575,7 +557,7 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
return (
<div className="panel">
<h3>
<input type="checkbox" checked={!!form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} title={t("settings.enabled")} />
<Checkbox checked={!!form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} title={t("settings.enabled")} />
{name}
<span className="chip">{form.kind}</span>
<span className="chip">{t("settings.modelCount", { n: models.length || discovered.length })}</span>
@@ -589,66 +571,65 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
</span>
)}
<span className="spacer" />
<button className="small" onClick={() => setOpen(!open)}>
<Button size="small" onClick={() => setOpen(!open)}>
{open ? t("common.collapse") : t("common.edit")}
</button>
</Button>
</h3>
{open && (
<>
<div className="form">
<label>{t("settings.kind")}</label>
<select value={form.kind} onChange={(e) => setForm({ ...form, kind: e.target.value })}>
<Select value={form.kind} onChange={(e) => setForm({ ...form, kind: e.target.value })}>
<option value="anthropic">Anthropic Messages API</option>
<option value="openai">OpenAI-compatible</option>
</select>
</Select>
<label>{t("settings.baseUrl")}</label>
<input value={form.base_url} onChange={(e) => setForm({ ...form, base_url: e.target.value })} />
<Input value={form.base_url} onChange={(e) => setForm({ ...form, base_url: e.target.value })} />
<label>{t("settings.apiKey")}</label>
<input
type="password"
<Input.Password
value={form.api_key}
placeholder={p.api_key === MASK ? t("settings.apiKeyStored") : ""}
onChange={(e) => setForm({ ...form, api_key: e.target.value })}
/>
<div className="hint">{t("settings.apiKeyHint")}</div>
<label>{t("settings.authPrefix")}</label>
<input value={form.auth_prefix ?? ""} placeholder={form.kind === "openai" ? "Bearer " : ""} onChange={(e) => setForm({ ...form, auth_prefix: e.target.value })} />
<Input value={form.auth_prefix ?? ""} placeholder={form.kind === "openai" ? "Bearer " : ""} onChange={(e) => setForm({ ...form, auth_prefix: e.target.value })} />
<label>{t("settings.monthlyBudget")}</label>
<input type="number" min={0} step="1" value={form.monthly_budget ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
<Input type="number" min={0} step="1" value={form.monthly_budget ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
{/opencode\.ai\/(inference|zen)\/go/.test(form.base_url ?? "") && (
<>
<label>{t("settings.planLimit")}</label>
<input type="number" min={0} step="1" value={form.plan_limit ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, plan_limit: e.target.value })} />
<Input type="number" min={0} step="1" value={form.plan_limit ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, plan_limit: e.target.value })} />
<div className="hint">{t("settings.planLimitHint")}</div>
</>
)}
{form.kind === "anthropic" && (
<>
<label>{t("settings.adminKey")}</label>
<input type="password" value={form.admin_key} placeholder={p.admin_key === MASK ? t("settings.apiKeyStored") : "sk-ant-admin01-…"} onChange={(e) => setForm({ ...form, admin_key: e.target.value })} />
<Input.Password value={form.admin_key} placeholder={p.admin_key === MASK ? t("settings.apiKeyStored") : "sk-ant-admin01-…"} onChange={(e) => setForm({ ...form, admin_key: e.target.value })} />
<div className="hint">{t("settings.adminKeyHint")}</div>
</>
)}
<label>{t("settings.maxConcurrency")}</label>
<input type="number" min={1} value={form.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setForm({ ...form, max_concurrency: e.target.value })} />
<Input type="number" min={1} value={form.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setForm({ ...form, max_concurrency: e.target.value })} />
<div className="hint">{t("settings.maxConcurrencyHint")}</div>
</div>
<h3 style={{ marginTop: 16 }}>
{t("settings.models")}
<span className="spacer" />
{(form.base_url?.includes("openrouter.ai") || form.base_url?.includes("opencode.ai")) && (
<button className="small" onClick={fetchPrices}>
<Button size="small" onClick={fetchPrices}>
{t("settings.fetchPrices")}
</button>
</Button>
)}
{discovered.length > 0 && (
<button className="small" onClick={addDiscovered}>
<Button size="small" onClick={addDiscovered}>
{t("settings.addDiscovered", { n: discovered.length })}
</button>
</Button>
)}
<button className="small" onClick={() => setModels([...models, { id: "" }])}>
<Button size="small" onClick={() => setModels([...models, { id: "" }])}>
+ {t("settings.addModel")}
</button>
</Button>
</h3>
<div className="hint" style={{ marginBottom: 6, fontSize: 12, color: "var(--muted)" }}>
{t("settings.pricesHint")}
@@ -678,34 +659,34 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
{models.map((m, i) => (
<tr key={i}>
<td>
<input value={m.id} onChange={(e) => setModel(i, { id: e.target.value })} style={{ minWidth: 160 }} />
<Input value={m.id} onChange={(e) => setModel(i, { id: e.target.value })} style={{ minWidth: 160 }} />
</td>
<td>
<input type="number" value={m.context ?? ""} onChange={(e) => setModel(i, { context: num(e.target.value) })} />
<Input type="number" value={m.context ?? ""} onChange={(e) => setModel(i, { context: num(e.target.value) })} />
</td>
<td>
<input type="number" value={m.max_output ?? ""} onChange={(e) => setModel(i, { max_output: num(e.target.value) })} />
<Input type="number" value={m.max_output ?? ""} onChange={(e) => setModel(i, { max_output: num(e.target.value) })} />
</td>
<td>
<input type="number" value={m.max_input ?? ""} placeholder="–" onChange={(e) => setModel(i, { max_input: num(e.target.value) })} />
<Input type="number" value={m.max_input ?? ""} placeholder="–" onChange={(e) => setModel(i, { max_input: num(e.target.value) })} />
</td>
<td>
<input type="checkbox" checked={!!m.reasoning} onChange={(e) => setModel(i, { reasoning: e.target.checked })} />
<Checkbox checked={!!m.reasoning} onChange={(e) => setModel(i, { reasoning: e.target.checked })} />
</td>
<td>
<input type="checkbox" checked={!!m.vision} onChange={(e) => setModel(i, { vision: e.target.checked })} />
<Checkbox checked={!!m.vision} onChange={(e) => setModel(i, { vision: e.target.checked })} />
</td>
<td>
<select value={m.effort ?? ""} onChange={(e) => setModel(i, { effort: e.target.value || undefined })}>
<Select value={m.effort ?? ""} onChange={(e) => setModel(i, { effort: e.target.value || undefined })}>
<option value="">–</option>
{["low", "medium", "high", "xhigh", "max"].map((x) => (
<option key={x}>{x}</option>
))}
</select>
</Select>
</td>
{(["input_price", "output_price", "cache_read_price", "cache_write_price"] as const).map((k) => (
<td key={k}>
<input type="number" step="0.01" value={m[k] ?? ""} onChange={(e) => setModel(i, { [k]: num(e.target.value) })} />
<Input type="number" step="0.01" value={m[k] ?? ""} onChange={(e) => setModel(i, { [k]: num(e.target.value) })} />
{k === "cache_write_price" && priceExtras(m) && (
<span className="chip price-extra" title={priceExtras(m)}>
+{(m.price_tiers?.length ?? 0) + (m.price_multipliers?.length ?? 0)}
@@ -714,15 +695,15 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
</td>
))}
<td>
<input type="number" min={1} value={m.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setModel(i, { max_concurrency: num(e.target.value) })} />
<Input type="number" min={1} value={m.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setModel(i, { max_concurrency: num(e.target.value) })} />
</td>
<td>
<ModelSelect value={m.fallback ?? ""} onChange={(v) => setModel(i, { fallback: v || undefined })} emptyLabel="–" />
</td>
<td>
<button className="small ghost danger" onClick={() => setModels(models.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Button type="text" danger size="small" onClick={() => setModels(models.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
</td>
</tr>
))}
@@ -737,16 +718,16 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
</div>
)}
<div className="row" style={{ marginTop: 12 }}>
<button onClick={test} disabled={testing || !form.base_url}>
<Button onClick={test} disabled={testing || !form.base_url}>
<Icon name="plug" /> {testing ? t("settings.testing") : t("settings.testConnection")}
</button>
<button className="primary" onClick={save}>
</Button>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
<span className="spacer" />
<button className="danger" onClick={remove}>
<Button danger onClick={remove}>
{t("common.delete")}
</button>
</Button>
</div>
</>
)}
@@ -787,10 +768,10 @@ function Providers({ cfg, reload }: { cfg: ConfigResponse; reload: () => void })
return (
<>
<div className="row" style={{ marginBottom: 12 }}>
<button onClick={() => post("/providers/reload").then(reload)}>{t("settings.reloadProviders")}</button>
<button onClick={recheck} disabled={checking}>
<Button onClick={() => post("/providers/reload").then(reload)}>{t("settings.reloadProviders")}</Button>
<Button onClick={recheck} disabled={checking}>
{checking ? t("settings.providerChecking") : t("settings.providerCheck")}
</button>
</Button>
</div>
{Object.entries(providers).map(([n, p]) => (
<ProviderEditor key={n + JSON.stringify(p)} name={n} p={p} reload={reload} status={status[n]} />
@@ -798,15 +779,15 @@ function Providers({ cfg, reload }: { cfg: ConfigResponse; reload: () => void })
<div className="panel">
<h3>{t("settings.addProvider")}</h3>
<div className="row">
<select value={preset} onChange={(e) => setPreset(e.target.value)}>
<Select value={preset} onChange={(e) => setPreset(e.target.value)}>
{Object.keys(PRESETS).map((k) => (
<option key={k}>{k}</option>
))}
</select>
<input placeholder={t("settings.providerName")} value={name} onChange={(e) => setName(e.target.value)} />
<button className="primary" onClick={add}>
</Select>
<Input placeholder={t("settings.providerName")} value={name} onChange={(e) => setName(e.target.value)} />
<Button type="primary" onClick={add}>
+ {t("common.add")}
</button>
</Button>
</div>
{view}
</div>
@@ -883,9 +864,9 @@ function McpEditor({ name, m, reload, isNew }: { name: string; m: Json; reload:
{st?.state === "connected" && <span className="chip">{t("mcp.tools", { n: st.tools ?? 0 })}</span>}
<span className="spacer" />
{!isNew && (
<button className="small" onClick={() => setOpen(!open)}>
<Button size="small" onClick={() => setOpen(!open)}>
{open ? t("common.collapse") : t("common.edit")}
</button>
</Button>
)}
</h3>
{st?.state === "failed" && <div className="notice err">{st.error}</div>}
@@ -893,40 +874,40 @@ function McpEditor({ name, m, reload, isNew }: { name: string; m: Json; reload:
<>
<div className="form">
<label>{t("settings.name")}</label>
<input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
<Input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
<label>{t("settings.kind")}</label>
<select value={form.type} onChange={(e) => setForm({ ...form, type: e.target.value })}>
<Select value={form.type} onChange={(e) => setForm({ ...form, type: e.target.value })}>
<option value="stdio">stdio</option>
<option value="http">Streamable HTTP</option>
</select>
</Select>
{form.type === "stdio" ? (
<>
<label>{t("mcp.command")}</label>
<input value={form.command} onChange={(e) => setForm({ ...form, command: e.target.value })} placeholder="npx" />
<Input value={form.command} onChange={(e) => setForm({ ...form, command: e.target.value })} placeholder="npx" />
<label>{t("mcp.args")}</label>
<textarea rows={3} value={form.args} onChange={(e) => setForm({ ...form, args: e.target.value })} className="mono" />
<Input.TextArea rows={3} value={form.args} onChange={(e) => setForm({ ...form, args: e.target.value })} className="mono" />
<label>{t("mcp.env")}</label>
<textarea rows={2} value={form.env} onChange={(e) => setForm({ ...form, env: e.target.value })} className="mono" placeholder="KEY=${SECRET}" />
<Input.TextArea rows={2} value={form.env} onChange={(e) => setForm({ ...form, env: e.target.value })} className="mono" placeholder="KEY=${SECRET}" />
</>
) : (
<>
<label>URL</label>
<input value={form.url} onChange={(e) => setForm({ ...form, url: e.target.value })} placeholder="https://…/mcp" />
<Input value={form.url} onChange={(e) => setForm({ ...form, url: e.target.value })} placeholder="https://…/mcp" />
<label>{t("mcp.headers")}</label>
<textarea rows={2} value={form.headers} onChange={(e) => setForm({ ...form, headers: e.target.value })} className="mono" placeholder="Authorization: Bearer ${TOKEN}" />
<Input.TextArea rows={2} value={form.headers} onChange={(e) => setForm({ ...form, headers: e.target.value })} className="mono" placeholder="Authorization: Bearer ${TOKEN}" />
</>
)}
<label>{t("settings.enabled")}</label>
<input type="checkbox" checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} style={{ justifySelf: "start" }} />
<Checkbox checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} style={{ justifySelf: "start" }} />
<label>{t("mcp.load")}</label>
<select value={form.load} onChange={(e) => setForm({ ...form, load: e.target.value })}>
<Select value={form.load} onChange={(e) => setForm({ ...form, load: e.target.value })}>
<option value="auto">{t("mcp.loadAuto")}</option>
<option value="always">{t("mcp.loadAlways")}</option>
<option value="on_demand">{t("mcp.loadOnDemand")}</option>
</select>
</Select>
<div className="hint">{t("mcp.loadHint")}</div>
<label>{t("mcp.users")}</label>
<input value={form.users} onChange={(e) => setForm({ ...form, users: e.target.value })} placeholder={t("mcp.usersPlaceholder")} />
<Input value={form.users} onChange={(e) => setForm({ ...form, users: e.target.value })} placeholder={t("mcp.usersPlaceholder")} />
<div className="hint">{t("mcp.usersHint")}</div>
</div>
{status?.tools?.length ? (
@@ -943,14 +924,14 @@ function McpEditor({ name, m, reload, isNew }: { name: string; m: Json; reload:
) : null}
{view}
<div className="row" style={{ marginTop: 12 }}>
<button className="primary" onClick={save}>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
<span className="spacer" />
{!isNew && (
<button className="danger" onClick={() => void confirmDialog({ message: t("settings.deleteMcpConfirm", { name }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => savePatches([{ path: ["mcp", name], value: null }])))}>
<Button danger onClick={() => void confirmDialog({ message: t("settings.deleteMcpConfirm", { name }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => savePatches([{ path: ["mcp", name], value: null }])))}>
{t("common.delete")}
</button>
</Button>
)}
</div>
</>
@@ -965,7 +946,7 @@ function Mcp({ cfg, reload }: { cfg: ConfigResponse; reload: () => void }) {
return (
<>
<div className="row" style={{ marginBottom: 12 }}>
<button onClick={() => post("/mcp/reload")}>{t("mcp.reconnect")}</button>
<Button onClick={() => post("/mcp/reload")}>{t("mcp.reconnect")}</Button>
</div>
{Object.keys(servers).length === 0 && <div className="notice">{t("mcp.none")}</div>}
{Object.entries(servers).map(([n, m]) => (
@@ -993,29 +974,29 @@ function RuleTable({ rules, setRules, choices, keyLabel }: { rules: [string, str
{rules.map(([k, v], i) => (
<tr key={i}>
<td>
<input className="mono" value={k} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [e.target.value, r[1]] : r)))} />
<Input className="mono" value={k} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [e.target.value, r[1]] : r)))} />
</td>
<td>
<select value={v} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [r[0], e.target.value] : r)))}>
<Select value={v} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [r[0], e.target.value] : r)))}>
{choices.map((c) => (
<option key={c} value={c}>
{t(`permissions.${c}` as Key)}
</option>
))}
</select>
</Select>
</td>
<td>
<button className="small ghost danger" onClick={() => setRules(rules.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Button type="text" danger size="small" onClick={() => setRules(rules.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
<Icon name="close" />
</button>
</Button>
</td>
</tr>
))}
<tr>
<td colSpan={3}>
<button className="small" onClick={() => setRules([...rules, ["", choices[0]]])}>
<Button size="small" onClick={() => setRules([...rules, ["", choices[0]]])}>
+ {t("common.add")}
</button>
</Button>
</td>
</tr>
</tbody>
@@ -1055,9 +1036,9 @@ function Permissions({ cfg, reload }: { cfg: ConfigResponse; reload: () => void
</div>
</div>
{view}
<button className="primary" onClick={save}>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
</>
);
}
@@ -1075,13 +1056,13 @@ function Raw({ reload }: { reload: () => void }) {
return (
<>
<div className="notice">{t("settings.rawHint")}</div>
<textarea className="raw-editor" spellCheck={false} value={text} onChange={(e) => setText(e.target.value)} />
<Input.TextArea className="raw-editor" spellCheck={false} value={text} onChange={(e) => setText(e.target.value)} />
{view}
<div className="row" style={{ marginTop: 8 }}>
<button className="primary" onClick={() => run(() => put("/config/raw", { text }))}>
<Button type="primary" onClick={() => run(() => put("/config/raw", { text }))}>
{t("common.save")}
</button>
<button onClick={() => get<{ text: string }>("/config/raw").then((r) => setText(r.text))}>{t("settings.revert")}</button>
</Button>
<Button onClick={() => get<{ text: string }>("/config/raw").then((r) => setText(r.text))}>{t("settings.revert")}</Button>
</div>
</>
);
@@ -1118,23 +1099,29 @@ export function Settings({ tab, onMenu }: { tab?: string; onMenu: () => void })
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>{t("nav.settings")}</h1>
</div>
</div>
<div className="page">
<div className="page-inner">
<div className="tabs" role="tablist">
{TABS.map((x) => (
<button key={x} role="tab" aria-selected={active === x} className={active === x ? "active" : ""} onClick={() => navigate(`/settings/${x}`)}>
<Icon name={TAB_ICONS[x]} className="nav-icon" />
{t(`settings.tab.${x}` as Key)}
</button>
))}
</div>
<Tabs
className="settings-tabs"
activeKey={active}
onChange={(x) => navigate(`/settings/${x}`)}
items={TABS.map((x) => ({
key: x,
label: (
<span className="tab-label">
<Icon name={TAB_ICONS[x]} className="nav-icon" />
{t(`settings.tab.${x}` as Key)}
</span>
),
}))}
/>
{error && <div className="notice err">{error}</div>}
{isAdmin && !cfg && !error && <div className="empty">{t("common.loading")}</div>}
{!isAdmin && active === "general" && <InterfaceSettings />}
+17 -21
View File
@@ -1,3 +1,6 @@
import { Button, Checkbox, Input } from "antd";
import { Select } from "../ui/Select";
import { Modal } from "../ui/Modal";
import { useEffect, useState } from "react";
import { del, get, post, put } from "../api";
import { useT } from "../i18n";
@@ -39,21 +42,21 @@ function Links({ sessionId }: { sessionId: string }) {
<div className="hint">{t("link.hint")}</div>
{links.map((l) => (
<div key={l.token} className="row share-link">
<input readOnly value={l.url} onFocus={(e) => e.currentTarget.select()} aria-label={t("link.title")} />
<Input readOnly value={l.url} onFocus={(e) => e.currentTarget.select()} aria-label={t("link.title")} />
<span className="hint">{t("link.until", { date: fmtDate(l.expires_at, false) })}</span>
<button onClick={() => navigator.clipboard?.writeText(l.url).then(() => toast(t("link.copied"), "success"))}>{t("link.copy")}</button>
<button onClick={() => del(`/sessions/${sessionId}/links/${l.token}`).then(load).catch((e) => toast(e.message))}>{t("link.revoke")}</button>
<Button onClick={() => navigator.clipboard?.writeText(l.url).then(() => toast(t("link.copied"), "success"))}>{t("link.copy")}</Button>
<Button onClick={() => del(`/sessions/${sessionId}/links/${l.token}`).then(load).catch((e) => toast(e.message))}>{t("link.revoke")}</Button>
</div>
))}
<div className="row" style={{ marginTop: 6 }}>
<select value={days} onChange={(e) => setDays(Number(e.target.value))} aria-label={t("link.validity")}>
<Select value={days} onChange={(e) => setDays(Number(e.target.value))} aria-label={t("link.validity")}>
{[1, 7, 30, 90].map((d) => (
<option key={d} value={d}>
{t("link.days", { n: d })}
</option>
))}
</select>
<button onClick={create}>{t("link.create")}</button>
</Select>
<Button onClick={create}>{t("link.create")}</Button>
</div>
</div>
);
@@ -87,37 +90,30 @@ export function ShareDialog({ sessionId, onClose }: { sessionId: string; onClose
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal" role="dialog" aria-label={t("share.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} role="dialog" aria-label={t("share.title")}>
<h3>{t("share.title")}</h3>
<div style={{ fontSize: 13, color: "var(--muted)", marginBottom: 8 }}>{t("share.hint")}</div>
<div className="check-list">
{users.length === 0 && <div className="empty">{t("share.noUsers")}</div>}
{users.map((u) => (
<label key={u.id}>
<input
type="checkbox"
checked={selected.has(u.id)}
onChange={(e) => {
<Checkbox key={u.id} checked={selected.has(u.id)} onChange={(e) => {
const next = new Set(selected);
if (e.target.checked) next.add(u.id);
else next.delete(u.id);
setSelected(next);
}}
/>
}}>
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
</label>
</Checkbox>
))}
</div>
<Links sessionId={sessionId} />
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
<button onClick={onClose}>{t("common.cancel")}</button>
<button className="primary" onClick={save}>
<Button onClick={onClose}>{t("common.cancel")}</Button>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+10 -10
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useState } from "react";
import { fmtRelative, useT } from "../i18n";
import { navigate } from "../router";
@@ -28,32 +30,30 @@ export function ShareTarget({ shared, onClose }: { shared: string; onClose: () =
};
return (
<div className="modal-backdrop" onClick={cancel}>
<div className="modal share-target" role="dialog" aria-label={t("shareIn.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={cancel} className="share-target" role="dialog" aria-label={t("shareIn.title")}>
<h3>{t("shareIn.title")}</h3>
<textarea value={text} onChange={(e) => setText(e.target.value)} rows={4} />
<button className="primary share-new" onClick={() => done("new")} disabled={!text.trim()}>
<Input.TextArea value={text} onChange={(e) => setText(e.target.value)} rows={4} />
<Button type="primary" className="share-new" onClick={() => done("new")} disabled={!text.trim()}>
<Icon name="plus" /> {t("shareIn.newChat")}
</button>
</Button>
{sessions.length > 0 && (
<>
<div className="share-sep">{t("shareIn.appendTo")}</div>
<div className="share-list">
{sessions.map((s) => (
<button key={s.id} onClick={() => done(s.id)} disabled={!text.trim()}>
<Button key={s.id} onClick={() => done(s.id)} disabled={!text.trim()}>
<span className="share-title">{s.title || t("session.untitled")}</span>
<span className="share-meta">
{basename(s.cwd)} · {fmtRelative(s.updated_at)}
</span>
</button>
</Button>
))}
</div>
</>
)}
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
<button onClick={cancel}>{t("common.cancel")}</button>
<Button onClick={cancel}>{t("common.cancel")}</Button>
</div>
</div>
</div>
</Modal>
);
}
+22 -16
View File
@@ -1,3 +1,5 @@
import { Button, Segmented } from "antd";
import { Modal } from "../ui/Modal";
import { Icon } from "./Icon";
import { useEffect, useState } from "react";
import { get, post } from "../api";
@@ -44,37 +46,41 @@ export function ShellsChip({ sessionId, busy }: { sessionId: string; busy: boole
{running ? <Spinner small /> : <Icon name="terminal" />} {t("shells.chip", { n: running, total: shells.length })}
</button>
{open && (
<div className="modal-backdrop" onClick={() => setOpen(false)}>
<div className="modal wide" role="dialog" aria-label={t("shells.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={() => setOpen(false)} className="wide" role="dialog" aria-label={t("shells.title")}>
<div className="row" style={{ marginBottom: 8 }}>
<h3 style={{ margin: 0 }}>{t("shells.title")}</h3>
<span className="spacer" />
<button className="small ghost" onClick={() => setOpen(false)} aria-label={t("common.close")}>
<Button type="text" size="small" onClick={() => setOpen(false)} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</div>
<div className="mode-tabs" style={{ flexWrap: "wrap", marginBottom: 8 }}>
{shells.map((s) => (
<button key={s.id} className={s.id === current.id ? "active" : ""} onClick={() => setSelected(s.id)}>
<Icon name={s.running ? "dot" : "radio-off"} className={`tiny ${s.running ? "ok" : ""}`} />{" "}
{s.command.slice(0, 40)}
</button>
))}
</Button>
</div>
<Segmented
className="seg-wrap"
style={{ marginBottom: 8 }}
value={current.id}
onChange={setSelected}
options={shells.map((s) => ({
value: s.id,
label: (
<>
<Icon name={s.running ? "dot" : "radio-off"} className={`tiny ${s.running ? "ok" : ""}`} /> {s.command.slice(0, 40)}
</>
),
}))}
/>
<div className="row" style={{ fontSize: 12.5, color: "var(--muted)", marginBottom: 6 }}>
<code>{current.command}</code>
<span>· {fmtRelative(current.started_at)}</span>
<span>· {current.running ? t("shells.running") : t("shells.exited", { code: current.exit_code ?? "?" })}</span>
<span className="spacer" />
{current.running && (
<button className="small danger" onClick={() => post(`/sessions/${sessionId}/shells/${current.id}/kill`).catch(toast)}>
<Button danger size="small" onClick={() => post(`/sessions/${sessionId}/shells/${current.id}/kill`).catch(toast)}>
<Icon name="stop" /> {t("shells.stop")}
</button>
</Button>
)}
</div>
<pre className="shell-output">{current.output || t("shells.noOutput")}</pre>
</div>
</div>
</Modal>
)}
</>
);
+44 -44
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { deleteChat } from "../chatActions";
import { Icon } from "./Icon";
import { StatusLeds } from "./StatusLeds";
@@ -83,35 +84,34 @@ function SessionRow({ s, active, attention, busy, folders }: { s: Session; activ
{menu && (
<div className="session-menu" role="menu" onClick={(e) => e.stopPropagation()}>
{!s.archived && (
<button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { pinned: !s.pinned }))}>
<Button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { pinned: !s.pinned }))}>
<Icon name="pin" /> {t(s.pinned ? "sidebar.unpin" : "sidebar.pin")}
</button>
</Button>
)}
<button role="menuitem" className="hide-mobile" onClick={() => (setMenu(false), openBeside(s.id))}>
<Button role="menuitem" className="hide-mobile" onClick={() => (setMenu(false), openBeside(s.id))}>
<Icon name="external" /> {t("sidebar.openBeside")}
</button>
<button role="menuitem" onClick={() => (setMenu(false), void moveTo())}>
</Button>
<Button role="menuitem" onClick={() => (setMenu(false), void moveTo())}>
<Icon name="folder" /> {t("sidebar.moveTo")}
</button>
</Button>
{s.folder && (
<button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { folder: "" }))}>
<Button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { folder: "" }))}>
<Icon name="folder-up" /> {t("sidebar.removeFromFolder")}
</button>
</Button>
)}
<button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { archived: !s.archived }))}>
<Button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { archived: !s.archived }))}>
<Icon name="archive" /> {t(s.archived ? "sidebar.unarchive" : "sidebar.archiveOne")}
</button>
</Button>
{!s.shared && (
<button
<Button danger
role="menuitem"
className="danger"
onClick={async () => {
setMenu(false);
if ((await deleteChat(s)) && active) navigate("/new");
}}
>
<Icon name="trash" /> {t("chat.delete")}
</button>
</Button>
)}
</div>
)}
@@ -212,19 +212,19 @@ function GroupHeader({
{menu && (
<div className="session-menu" role="menu" onClick={(e) => e.stopPropagation()}>
{g.id.startsWith("project:") && (
<button role="menuitem" onClick={() => (setMenu(false), navigate(`/p/${encodeURIComponent(g.id.slice("project:".length))}`))}>
<Button role="menuitem" onClick={() => (setMenu(false), navigate(`/p/${encodeURIComponent(g.id.slice("project:".length))}`))}>
<Icon name="clock" /> {t("project.open")}
</button>
</Button>
)}
<button role="menuitem" onClick={() => (setMenu(false), onPin?.())}>
<Button role="menuitem" onClick={() => (setMenu(false), onPin?.())}>
<Icon name="pin" /> {t(pinned ? "sidebar.groupUnpin" : "sidebar.groupPin")}
</button>
<button role="menuitem" onClick={() => (setMenu(false), onMove?.(-1))}>
</Button>
<Button role="menuitem" onClick={() => (setMenu(false), onMove?.(-1))}>
<Icon name="arrow-up" /> {t("sidebar.groupUp")}
</button>
<button role="menuitem" onClick={() => (setMenu(false), onMove?.(1))}>
</Button>
<Button role="menuitem" onClick={() => (setMenu(false), onMove?.(1))}>
<Icon name="arrow-down" /> {t("sidebar.groupDown")}
</button>
</Button>
</div>
)}
</div>
@@ -398,12 +398,12 @@ export function Sidebar({ open, activeIds, section }: { open: boolean; activeIds
<StatusLeds />
</div>
<div style={{ padding: "0 12px 8px" }}>
<button className="primary" style={{ width: "100%" }} onClick={() => navigate("/new")}>
<Button type="primary" style={{ width: "100%" }} onClick={() => navigate("/new")}>
+ {t("sidebar.newSession")}
</button>
</Button>
</div>
<div className="session-search">
<input
<Input
type="search"
value={query}
placeholder={t("sidebar.search")}
@@ -433,10 +433,10 @@ export function Sidebar({ open, activeIds, section }: { open: boolean; activeIds
{!hits && sessions.length === 0 && <div className="empty">{t("sidebar.noSessions")}</div>}
{!hits && sessions.length > 0 && (
<div className="session-view">
<button className="ghost small" onClick={switchGroupBy} title={t("sidebar.groupByHint")}>
<Button type="text" size="small" onClick={switchGroupBy} title={t("sidebar.groupByHint")}>
<Icon name={groupBy === "time" ? "clock" : "folders"} className="tiny" />
{t(groupBy === "time" ? "sidebar.byTime" : "sidebar.byProject")}
</button>
</Button>
</div>
)}
{!hits &&
@@ -469,40 +469,40 @@ export function Sidebar({ open, activeIds, section }: { open: boolean; activeIds
{me?.role === "admin" && <span className="chip" style={{ marginLeft: 6 }}>admin</span>}
</span>
<ThemeModeButton />
<button className="small ghost" onClick={() => post("/auth/logout").then(() => location.reload())}>
<Button type="text" size="small" onClick={() => post("/auth/logout").then(() => location.reload())}>
<Icon name="logout" className="nav-icon" />
{t("nav.logout")}
</button>
</Button>
</div>
<div className="sidebar-foot">
<button className={`ghost ${section === "files" ? "active" : ""}`} onClick={() => navigate("/files")}>
<Button type="text" className={section === "files" ? "active" : ""} onClick={() => navigate("/files")}>
<Icon name="folder" className="nav-icon" />
{t("nav.files")}
</button>
<button className={`ghost ${section === "images" ? "active" : ""}`} onClick={() => navigate("/images")}>
</Button>
<Button type="text" className={section === "images" ? "active" : ""} onClick={() => navigate("/images")}>
<Icon name="image" className="nav-icon" />
{t("nav.images")}
</button>
<button className={`ghost ${section === "terminal" ? "active" : ""}`} onClick={() => navigate("/terminal")}>
</Button>
<Button type="text" className={section === "terminal" ? "active" : ""} onClick={() => navigate("/terminal")}>
<Icon name="terminal" className="nav-icon" />
{t("nav.terminal")}
</button>
<button className={`ghost ${section === "jobs" ? "active" : ""}`} onClick={() => navigate("/jobs")}>
</Button>
<Button type="text" className={section === "jobs" ? "active" : ""} onClick={() => navigate("/jobs")}>
<Icon name="clock" className="nav-icon" />
{t("nav.jobs")}
</button>
<button className={`ghost ${section === "factory" ? "active" : ""}`} onClick={() => navigate("/factory")}>
</Button>
<Button type="text" className={section === "factory" ? "active" : ""} onClick={() => navigate("/factory")}>
<Icon name="factory" className="nav-icon" />
{t("nav.factory")}
</button>
<button className={`ghost ${section === "stats" ? "active" : ""}`} onClick={() => navigate("/stats")}>
</Button>
<Button type="text" className={section === "stats" ? "active" : ""} onClick={() => navigate("/stats")}>
<Icon name="chart" className="nav-icon" />
{t("nav.stats")}
</button>
<button className={`ghost ${section === "settings" ? "active" : ""}`} onClick={() => navigate("/settings")}>
</Button>
<Button type="text" className={section === "settings" ? "active" : ""} onClick={() => navigate("/settings")}>
<Icon name="wrench" className="nav-icon" />
{t("nav.settings")}
</button>
</Button>
</div>
</aside>
);
@@ -515,8 +515,8 @@ function ThemeModeButton() {
const icon = <Icon name={mode === "auto" ? "theme-auto" : mode === "light" ? "sun" : "moon"} />;
const label = t(mode === "auto" ? "settings.themeAuto" : mode === "light" ? "settings.themeLight" : "settings.themeDark");
return (
<button className="small ghost theme-toggle" onClick={cycleThemeMode} title={`${t("settings.themeToggle")} – ${label}`} aria-label={t("settings.themeToggle")}>
<Button type="text" size="small" className="theme-toggle" onClick={cycleThemeMode} title={`${t("settings.themeToggle")} – ${label}`} aria-label={t("settings.themeToggle")}>
{icon}
</button>
</Button>
);
}
+20 -20
View File
@@ -1,3 +1,5 @@
import { Button, Segmented } from "antd";
import { Select } from "../ui/Select";
import { Icon } from "./Icon";
import { Fragment, useEffect, useMemo, useState } from "react";
import { useFetch } from "../hooks";
@@ -305,10 +307,10 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<div className="topbar stats-bar">
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow">
<h1>{t("nav.stats")}</h1>
{data && (
@@ -317,34 +319,32 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
</div>
)}
</div>
<div className="mode-tabs" role="tablist">
{RANGES.map((r) => (
<button key={r.key} className={range === r.key ? "active" : ""} onClick={() => setRange(r.key)}>
{t(r.label)}
</button>
))}
</div>
<Segmented
value={range}
onChange={(v) => setRange(v)}
options={RANGES.map((r) => ({ value: r.key, label: t(r.label) }))}
/>
{years.length > 1 && (
<select value={year ? range : ""} onChange={(e) => e.target.value && setRange(e.target.value)} aria-label={t("stats.year")} className={year ? "active" : ""}>
<Select value={year ? range : ""} onChange={(e) => e.target.value && setRange(e.target.value)} aria-label={t("stats.year")} className={year ? "active" : ""}>
<option value="">{t("stats.year")}</option>
{years.map((y) => (
<option key={y} value={`y${y}`}>
{y}
</option>
))}
</select>
</Select>
)}
{isAdmin && (
<select value={userFilter} onChange={(e) => setUserFilter(e.target.value)} aria-label={t("stats.user")}>
<Select value={userFilter} onChange={(e) => setUserFilter(e.target.value)} aria-label={t("stats.user")}>
<option value="">{t("stats.allUsers")}</option>
{users.map((u) => (
<option key={u.id} value={u.id}>
{u.username}
</option>
))}
</select>
</Select>
)}
<select value="" onChange={(e) => exportAs(e.target.value)} aria-label={t("stats.export")} title={t("stats.exportHint")}>
<Select value="" onChange={(e) => exportAs(e.target.value)} aria-label={t("stats.export")} title={t("stats.exportHint")}>
<option value="">{t("stats.export")}</option>
<option value="xlsx">{t("stats.exportXlsx")}</option>
{(["day", "month", "model", "provider", "agent", "user", "session"] as const).map((k) => (
@@ -352,10 +352,10 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
{t("stats.exportCsv", { table: t(`stats.table.${k}` as Key) })}
</option>
))}
</select>
<button className="small" onClick={() => setTableView(!tableView)}>
</Select>
<Button size="small" onClick={() => setTableView(!tableView)}>
{tableView ? t("stats.chartView") : t("stats.tableView")}
</button>
</Button>
</div>
<div className="page">
<div className="page-inner">
@@ -393,11 +393,11 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
</Fold>
<Fold id="heatmap" title={t("stats.heatmap")}>
<div className="row" style={{ justifyContent: "flex-end", marginBottom: 6 }}>
<select value={heat} onChange={(e) => setHeat(e.target.value as HeatMetric)} aria-label={t("stats.heatmap")}>
<Select value={heat} onChange={(e) => setHeat(e.target.value as HeatMetric)} aria-label={t("stats.heatmap")}>
<option value="requests">{t("stats.requests")}</option>
<option value="tokens">{t("stats.tokens")}</option>
<option value="cost">{t("stats.cost")}</option>
</select>
</Select>
</div>
<Heatmap cells={view.cells} rows={view.heatRows} format={heatFormat} />
</Fold>
+7 -6
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useCallback, useEffect, useRef, useState } from "react";
import { get, post } from "../api";
import { fmtCost, fmtPercent, useT, type Key } from "../i18n";
@@ -178,9 +179,9 @@ export function StatusLeds() {
<Led level={models} /> {t("status.models")}
<span className="spacer" />
{admin && (
<button className="small ghost" onClick={recheck} disabled={checking} title={t("status.recheck")}>
<Button type="text" size="small" onClick={recheck} disabled={checking} title={t("status.recheck")}>
<Icon name="refresh" size={13} />
</button>
</Button>
)}
</div>
{providers.length === 0 && <div className="status-row hint">{t("status.noProviders")}</div>}
@@ -228,12 +229,12 @@ export function StatusLeds() {
{admin && (
<div className="status-foot">
<button className="small ghost" onClick={() => go("providers")}>
<Button type="text" size="small" onClick={() => go("providers")}>
<Icon name="brain" size={13} /> {t("status.providerSettings")}
</button>
<button className="small ghost" onClick={() => go("mcp")}>
</Button>
<Button type="text" size="small" onClick={() => go("mcp")}>
<Icon name="plug" size={13} /> {t("status.mcpSettings")}
</button>
</Button>
</div>
)}
</div>
+12 -12
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Modal } from "../ui/Modal";
import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "../dialogs";
import { useT } from "../i18n";
@@ -43,14 +45,13 @@ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) =>
const ph = chosen ? placeholders(chosen.text) : [];
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal tpl-picker" role="dialog" aria-label={t("templates.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} className="tpl-picker" role="dialog" aria-label={t("templates.title")}>
{!chosen ? (
<>
<h3>
<Icon name="template" /> {t("templates.title")}
</h3>
<input
<Input
autoFocus
style={{ width: "100%" }}
value={q}
@@ -79,11 +80,11 @@ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) =>
))}
</div>
<div className="row" style={{ marginTop: 12 }}>
<button className="ghost small" onClick={() => (onClose(), navigate("/settings/templates"))}>
<Button type="text" size="small" onClick={() => (onClose(), navigate("/settings/templates"))}>
<Icon name="edit" /> {t("templates.manage")}
</button>
</Button>
<span className="grow" />
<button onClick={onClose}>{t("common.cancel")}</button>
<Button onClick={onClose}>{t("common.cancel")}</Button>
</div>
</>
) : (
@@ -108,16 +109,15 @@ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) =>
</label>
))}
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
<button type="button" onClick={() => setChosen(undefined)}>
<Button onClick={() => setChosen(undefined)}>
{t("common.back")}
</button>
<button type="submit" className="primary">
</Button>
<Button type="primary" htmlType="submit">
{t("templates.insert")}
</button>
</Button>
</div>
</form>
)}
</div>
</div>
</Modal>
);
}
+22 -21
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect, useRef, useState } from "react";
import { Terminal as XTerm, type ITheme } from "@xterm/xterm";
import { FitAddon } from "@xterm/addon-fit";
@@ -98,23 +99,23 @@ export function TerminalPage({ id, onMenu }: { id?: string; onMenu: () => void }
return (
<>
<div className="topbar">
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
<Icon name="menu" />
</button>
</Button>
<div className="grow term-tabs">
{list.map((x) => (
<span key={x.id} className={`term-tab ${x.id === id ? "active" : ""} ${x.alive ? "" : "dead"}`}>
<button className="ghost small" onClick={() => navigate(`/terminal/${x.id}`)} title={x.cwd}>
<Button type="text" size="small" onClick={() => navigate(`/terminal/${x.id}`)} title={x.cwd}>
<Icon name="terminal" /> {basename(x.cwd)}
</button>
<button className="ghost small" onClick={() => close(x.id)} aria-label={t("terminal.close")} title={t("terminal.close")}>
</Button>
<Button type="text" size="small" onClick={() => close(x.id)} aria-label={t("terminal.close")} title={t("terminal.close")}>
<Icon name="close" />
</button>
</Button>
</span>
))}
<button className="ghost small" onClick={open} title={t("terminal.new")} aria-label={t("terminal.new")}>
<Button type="text" size="small" onClick={open} title={t("terminal.new")} aria-label={t("terminal.new")}>
<Icon name="plus" />
</button>
</Button>
</div>
</div>
{error && <div className="notice err">{error}</div>}
@@ -123,9 +124,9 @@ export function TerminalPage({ id, onMenu }: { id?: string; onMenu: () => void }
) : (
<div className="empty">
{list.length === 0 && id !== "new" && (
<button className="primary" onClick={open}>
<Button type="primary" onClick={open}>
<Icon name="terminal" /> {t("terminal.new")}
</button>
</Button>
)}
</div>
)}
@@ -237,8 +238,8 @@ export function TermView({ info }: { info: TermInfo }) {
<div className="term-host" ref={host} />
{state !== "open" && <div className="term-state">{t(state === "connecting" ? "terminal.connecting" : "terminal.reconnecting")}</div>}
<div className="term-keys" aria-label={t("terminal.keys")}>
<button onClick={() => key("\x1b")}>Esc</button>
<button onClick={() => key("\t")}>Tab</button>
<Button onClick={() => key("\x1b")}>Esc</Button>
<Button onClick={() => key("\t")}>Tab</Button>
<button
className={ctrl ? "active" : ""}
onClick={() => {
@@ -249,19 +250,19 @@ export function TermView({ info }: { info: TermInfo }) {
>
Ctrl
</button>
<button onClick={() => key("\x03")}>^C</button>
<button onClick={() => key("\x1b[A")} aria-label="Up">
<Button onClick={() => key("\x03")}>^C</Button>
<Button onClick={() => key("\x1b[A")} aria-label="Up">
<Icon name="arrow-up" />
</button>
<button onClick={() => key("\x1b[B")} aria-label="Down">
</Button>
<Button onClick={() => key("\x1b[B")} aria-label="Down">
<Icon name="arrow-down" />
</button>
<button onClick={() => key("\x1b[D")} aria-label="Left">
</Button>
<Button onClick={() => key("\x1b[D")} aria-label="Left">
<Icon name="arrow-left" />
</button>
<button onClick={() => key("\x1b[C")} aria-label="Right">
</Button>
<Button onClick={() => key("\x1b[C")} aria-label="Right">
<Icon name="arrow-right" />
</button>
</Button>
</div>
</div>
);
+5 -5
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { Icon } from "./Icon";
import { FileFigure, imageSize, imageSrc } from "./FileFigure";
import { useState } from "react";
@@ -142,9 +143,9 @@ export function ToolCard({ call, result, running, baseDir }: { call: ToolCall; r
{call.name === "bash" && <pre className="mono">$ {call.input?.command}</pre>}
{(call.name === "edit" || call.name === "write") && meta?.diff && <Diff diff={meta.diff} />}
{call.name === "task" && meta?.session_id && (
<button className="small" onClick={() => navigate(`/s/${meta.session_id}`)}>
<Button size="small" onClick={() => navigate(`/s/${meta.session_id}`)}>
{t("tool.openSubagent")}
</button>
</Button>
)}
{!["bash", "edit", "write", "task"].includes(call.name) && (
<>
@@ -165,8 +166,7 @@ export function ToolCard({ call, result, running, baseDir }: { call: ToolCall; r
</>
)}
{typeof meta?.model_file === "string" && (
<button
className="small"
<Button size="small"
style={{ marginBottom: 8 }}
onClick={() => {
sessionStorage.setItem("codecraft.openFile", meta.model_file);
@@ -174,7 +174,7 @@ export function ToolCard({ call, result, running, baseDir }: { call: ToolCall; r
}}
>
<Icon name="cube" /> {t("tool.open3d")}
</button>
</Button>
)}
{Array.isArray(meta?.image_ids) ? (
<div className="gallery small">
+5 -4
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useState } from "react";
import { get } from "../api";
import { useT } from "../i18n";
@@ -51,9 +52,9 @@ export function TurnChanges({
return (
<div className="turn-changes">
<button className="small ghost" onClick={toggle} aria-expanded={open}>
<Button type="text" size="small" onClick={toggle} aria-expanded={open}>
<Icon name={open ? "chevron-down" : "chevron-right"} className="tiny" /> {t("turn.changes", { n: fileCount })}
</button>
</Button>
{open && (
<div className="turn-changes-body">
{error && <div className="notice err">{error}</div>}
@@ -74,9 +75,9 @@ export function TurnChanges({
</details>
))}
{userMessage && onRewind && changes && changes.length > 0 && (
<button className="small" onClick={() => onRewind(userMessage)}>
<Button size="small" onClick={() => onRewind(userMessage)}>
<Icon name="undo" /> {t("turn.rollback")}
</button>
</Button>
)}
</div>
)}
+3 -2
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useState } from "react";
import { post } from "../api";
import { toast } from "../dialogs";
@@ -32,9 +33,9 @@ export function TurnCheck({ sessionId, messageId, canSend }: { sessionId: string
<div className="turn-check-body">
<pre className="mono">{check.output || t("check.noOutput")}</pre>
{check.status !== "passed" && canSend && (
<button className="small primary" onClick={fix}>
<Button type="primary" size="small" onClick={fix}>
<Icon name="sparkle" /> {t("check.fix")}
</button>
</Button>
)}
</div>
)}
+3 -2
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useT } from "../i18n";
import { closeUploadBatch, useUploads } from "../uploads";
import { Icon } from "./Icon";
@@ -23,9 +24,9 @@ export function UploadPanel() {
<span className="hint">
{formatSize(sent)} / {formatSize(total)}
</span>
<button className="small ghost" onClick={() => closeUploadBatch(b.id)} aria-label={t("common.close")}>
<Button type="text" size="small" onClick={() => closeUploadBatch(b.id)} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</Button>
</div>
<div className="upload-bar total" title={`${pct(sent, total)} %`}>
<i style={{ width: `${pct(sent, total)}%` }} />
+6 -6
View File
@@ -1,3 +1,5 @@
import { Button } from "antd";
import { Modal } from "../ui/Modal";
import { Icon } from "./Icon";
import { useEffect } from "react";
import { useFetch, useModels } from "../hooks";
@@ -59,14 +61,13 @@ export function UsageOverlay({ session, onClose }: { session: Session; onClose:
const ctxTokens = u ? u.input_tokens + u.cache_read_tokens + u.cache_write_tokens + u.output_tokens : 0;
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal wide" role="dialog" aria-label={t("usage.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={onClose} className="wide" role="dialog" aria-label={t("usage.title")}>
<div className="row" style={{ marginBottom: 8 }}>
<h3 style={{ margin: 0 }}>{t("usage.title")}</h3>
<span className="spacer" />
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
<Icon name="close" />
</button>
</Button>
</div>
{!data ? (
<div className="empty">{t("common.loading")}</div>
@@ -194,7 +195,6 @@ export function UsageOverlay({ session, onClose }: { session: Session; onClose:
)}
</>
)}
</div>
</div>
</Modal>
);
}
+7 -6
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect, useRef, useState } from "react";
import { getLang, useT } from "../i18n";
import { toast } from "../dialogs";
@@ -75,9 +76,9 @@ function RecorderButton({ onText, onInterim }: { onText: (text: string) => void;
};
return (
<button
type="button"
className={`ghost small voice-btn ${state === "recording" ? "on" : ""}`}
<Button
type="text" size="small" className={`voice-btn ${state === "recording" ? "on" : ""}`}
disabled={state === "sending"}
onClick={() => void toggle()}
title={t(state === "recording" ? "voice.stop" : "voice.start")}
@@ -85,7 +86,7 @@ function RecorderButton({ onText, onInterim }: { onText: (text: string) => void;
aria-pressed={state === "recording"}
>
<Icon name="mic" />
</button>
</Button>
);
}
@@ -138,8 +139,8 @@ function BrowserVoiceButton({ onText, onInterim }: { onText: (text: string) => v
};
return (
<button type="button" className={`ghost small voice-btn ${listening ? "on" : ""}`} onClick={toggle} title={t(listening ? "voice.stop" : "voice.start")} aria-label={t(listening ? "voice.stop" : "voice.start")} aria-pressed={listening}>
<Button type="text" size="small" className={`voice-btn ${listening ? "on" : ""}`} onClick={toggle} title={t(listening ? "voice.stop" : "voice.start")} aria-label={t(listening ? "voice.stop" : "voice.start")} aria-pressed={listening}>
<Icon name="mic" />
</button>
</Button>
);
}
+6 -6
View File
@@ -1,3 +1,5 @@
import { Button } from "antd";
import { Modal } from "../ui/Modal";
import { useState } from "react";
import { getLang, useT } from "../i18n";
import { WHATS_NEW } from "../whatsnew";
@@ -25,8 +27,7 @@ export function WhatsNew({ version }: { version: string }) {
setOpen(false);
};
return (
<div className="modal-backdrop" onClick={close}>
<div className="modal" role="dialog" aria-label={t("whatsnew.title")} onClick={(e) => e.stopPropagation()}>
<Modal onClose={close} role="dialog" aria-label={t("whatsnew.title")}>
<h3>
<Icon name="sparkle" /> {t("whatsnew.title", { version })}
</h3>
@@ -36,11 +37,10 @@ export function WhatsNew({ version }: { version: string }) {
))}
</ul>
<div className="row" style={{ justifyContent: "flex-end" }}>
<button className="primary" onClick={close}>
<Button type="primary" onClick={close}>
{t("common.ok")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+5 -4
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect, useState } from "react";
import { get, post } from "../api";
import { useT } from "../i18n";
@@ -69,12 +70,12 @@ export function WorktreeChip({ session, busy }: { session: Session; busy: boolea
</>
)}
<div className="row" style={{ gap: 6, marginTop: 8 }}>
<button className="small primary" disabled={busy || !!working} onClick={() => act("merge")}>
<Button type="primary" size="small" disabled={busy || !!working} onClick={() => act("merge")}>
{working === "merge" ? <Spinner small /> : <Icon name="check" />} {t("worktree.merge", { base: wt.base })}
</button>
<button className="small danger" disabled={busy || !!working} onClick={() => act("remove")}>
</Button>
<Button danger size="small" disabled={busy || !!working} onClick={() => act("remove")}>
<Icon name="trash" /> {t("worktree.remove")}
</button>
</Button>
</div>
{busy && <div className="hint">{t("worktree.busy")}</div>}
</div>
+6 -5
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { useState } from "react";
import { post } from "../../api";
import { useT } from "../../i18n";
@@ -38,18 +39,18 @@ export function Account() {
{me?.has_password && (
<>
<label>{t("account.current")}</label>
<input type="password" value={form.current} onChange={(e) => setForm({ ...form, current: e.target.value })} autoComplete="current-password" />
<Input.Password value={form.current} onChange={(e) => setForm({ ...form, current: e.target.value })} autoComplete="current-password" />
</>
)}
<label>{t("account.new")}</label>
<input type="password" value={form.next} onChange={(e) => setForm({ ...form, next: e.target.value })} autoComplete="new-password" />
<Input.Password value={form.next} onChange={(e) => setForm({ ...form, next: e.target.value })} autoComplete="new-password" />
<label>{t("login.passwordRepeat")}</label>
<input type="password" value={form.repeat} onChange={(e) => setForm({ ...form, repeat: e.target.value })} autoComplete="new-password" />
<Input.Password value={form.repeat} onChange={(e) => setForm({ ...form, repeat: e.target.value })} autoComplete="new-password" />
</div>
{notice && <div className={`notice ${notice.ok ? "ok" : "err"}`} style={{ marginTop: 10 }}>{notice.text}</div>}
<button className="primary" style={{ marginTop: 12 }} disabled={!form.next} onClick={save}>
<Button type="primary" style={{ marginTop: 12 }} disabled={!form.next} onClick={save}>
{t("account.change")}
</button>
</Button>
<div style={{ fontSize: 12, color: "var(--muted)", marginTop: 8 }}>{t("account.hint")}</div>
</div>
<Memory />
+35 -38
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input } from "antd";
import { Select } from "../../ui/Select";
import { Icon } from "../Icon";
import { useState } from "react";
import { del, patch } from "../../api";
@@ -26,16 +28,14 @@ export function ToolPicker({ tools, value, onChange, readOnly }: { tools: ToolIn
<div className="hint">{value.length ? t("agents.toolsSome", { n: value.length }) : t("agents.toolsAll")}</div>
<div className="tool-grid">
{tools.map((x) => (
<label key={x.name} className={`tool-item ${readOnly && !x.read_only ? "disabled" : ""}`} title={x.description}>
<input type="checkbox" checked={value.includes(x.name)} disabled={readOnly && !x.read_only} onChange={() => toggle(x.name)} />
<Checkbox key={x.name} className={`tool-item ${readOnly && !x.read_only ? "disabled" : ""}`} title={x.description} checked={value.includes(x.name)} disabled={readOnly && !x.read_only} onChange={() => toggle(x.name)}>
<span className="mono">{x.name}</span>
</label>
</Checkbox>
))}
{extra.map((n) => (
<label key={n} className="tool-item">
<input type="checkbox" checked onChange={() => toggle(n)} />
<Checkbox key={n} className="tool-item" checked onChange={() => toggle(n)}>
<span className="mono">{n}</span>
</label>
</Checkbox>
))}
</div>
</div>
@@ -125,13 +125,13 @@ function AgentRow({ a, raw, tools, onSaved }: { a: AgentInfo; raw: any; tools: T
{a.read_only && <span className="chip">{t("agents.readOnly")}</span>}
<span className="spacer" />
{!builtin && (a.source === "config" || a.source === "file") && (
<button className="small ghost danger" onClick={a.source === "file" ? removeFile : reset} title={t("common.delete")} aria-label={t("common.delete")}>
<Button type="text" danger size="small" onClick={a.source === "file" ? removeFile : reset} title={t("common.delete")} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
</Button>
)}
<button className="small" onClick={() => setOpen(!open)}>
<Button size="small" onClick={() => setOpen(!open)}>
{open ? t("common.collapse") : t("common.edit")}
</button>
</Button>
</h3>
<div style={{ fontSize: 13, color: "var(--fg3)" }}>{a.description}</div>
<div className="row" style={{ marginTop: 8 }}>
@@ -149,75 +149,72 @@ function AgentRow({ a, raw, tools, onSaved }: { a: AgentInfo; raw: any; tools: T
{a.mode !== "primary" && (
<>
<label>{t("agents.maxParallel")}</label>
<input type="number" min={1} value={form.max_parallel} placeholder="∞" onChange={(e) => setForm({ ...form, max_parallel: e.target.value })} />
<Input type="number" min={1} value={form.max_parallel} placeholder="∞" onChange={(e) => setForm({ ...form, max_parallel: e.target.value })} />
</>
)}
{a.mode === "primary" && (
<>
<label>{t("agents.refineRounds")}</label>
<input type="number" min={0} max={10} value={form.refine_rounds} placeholder={t("agents.refineOff")} onChange={(e) => setForm({ ...form, refine_rounds: e.target.value })} />
<Input type="number" min={0} max={10} value={form.refine_rounds} placeholder={t("agents.refineOff")} onChange={(e) => setForm({ ...form, refine_rounds: e.target.value })} />
<label>{t("agents.refineModel")}</label>
<ModelSelect value={form.refine_model} onChange={(v) => setForm({ ...form, refine_model: v })} emptyLabel={t("agents.sessionModel")} />
<label>{t("agents.refineCriteria")}</label>
<textarea rows={3} value={form.refine_criteria} onChange={(e) => setForm({ ...form, refine_criteria: e.target.value })} />
<Input.TextArea rows={3} value={form.refine_criteria} onChange={(e) => setForm({ ...form, refine_criteria: e.target.value })} />
<div className="hint">{t("agents.refineCriteriaHint")}</div>
<label className="check">
<input type="checkbox" checked={form.refine_after_todos} onChange={(e) => setForm({ ...form, refine_after_todos: e.target.checked })} />
<Checkbox checked={form.refine_after_todos} onChange={(e) => setForm({ ...form, refine_after_todos: e.target.checked })}>
{t("agents.refineAfterTodos")}
</label>
</Checkbox>
<div className="hint">{t("agents.refineAfterTodosHint")}</div>
</>
)}
{a.name !== "craft" && (
<>
<label className="check">
<input type="checkbox" checked={form.reverse_tools} onChange={(e) => setForm({ ...form, reverse_tools: e.target.checked })} />
<Checkbox checked={form.reverse_tools} onChange={(e) => setForm({ ...form, reverse_tools: e.target.checked })}>
{t("agents.reverseTools")}
</label>
</Checkbox>
<div className="hint">{t("agents.reverseToolsHint")}</div>
</>
)}
<label>{t("agents.description")}</label>
<input value={form.description} placeholder={a.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
<Input value={form.description} placeholder={a.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
{a.mode !== "primary" && <div className="hint">{t("agents.descriptionHint")}</div>}
{!builtin && (
<>
<label>{t("agents.mode")}</label>
<select value={form.mode} onChange={(e) => setForm({ ...form, mode: e.target.value })}>
<Select value={form.mode} onChange={(e) => setForm({ ...form, mode: e.target.value })}>
<option value="subagent">{t("agents.modeSubagent")}</option>
<option value="primary">{t("agents.modePrimary")}</option>
</select>
</Select>
{form.mode === "primary" && (
<>
<label>{t("agents.style")}</label>
<select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
<Select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
<option value="coding">{t("agents.styleCoding")}</option>
<option value="chat">{t("agents.styleChat")}</option>
</select>
</Select>
<div className="hint">{t("agents.styleHint")}</div>
</>
)}
<label>{t("agents.readOnlyLabel")}</label>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
<input type="checkbox" checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })} />
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })}>
<span className="hint">{t("agents.readOnlyHint")}</span>
</label>
</Checkbox>
<label>{t("agents.tools")}</label>
<ToolPicker tools={tools} value={form.tools} onChange={(v) => setForm({ ...form, tools: v })} readOnly={form.read_only} />
<label>{t("agents.prompt")}</label>
<textarea rows={6} value={form.prompt} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
<Input.TextArea rows={6} value={form.prompt} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
</>
)}
</div>
<div className="row" style={{ marginTop: 12 }}>
<button className="primary" onClick={save}>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
<span className="spacer" />
{a.source === "config" && builtin && (
<button className="danger" onClick={reset}>
<Button danger onClick={reset}>
{t("agents.reset")}
</button>
</Button>
)}
</div>
</>
@@ -274,14 +271,14 @@ export function AgentsEditor({ rawAgents, reloadConfig }: { rawAgents: Record<st
<div className="panel">
<h3>{t("agents.add")}</h3>
<div className="row">
<input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} />
<button className="primary" onClick={() => add("mode")} disabled={!name.trim()}>
<Input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} />
<Button type="primary" onClick={() => add("mode")} disabled={!name.trim()}>
+ {t("agents.addMode")}
</button>
<button onClick={() => add("writer")}>+ {t("agents.addWriter")}</button>
<button onClick={() => add("blank")} disabled={!name.trim()}>
</Button>
<Button onClick={() => add("writer")}>+ {t("agents.addWriter")}</Button>
<Button onClick={() => add("blank")} disabled={!name.trim()}>
+ {t("agents.addBlank")}
</button>
</Button>
</div>
</div>
<div className="two-col">
+13 -13
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Select } from "../../ui/Select";
import { useEffect, useState } from "react";
import { del, get, post } from "../../api";
import { fmtRelative, useT } from "../../i18n";
@@ -52,12 +54,11 @@ export function ApiTokens() {
<div>{t("tokens.copyNow")}</div>
<div className="row" style={{ gap: 6, marginTop: 6 }}>
<code className="token-value">{created}</code>
<button
className="small"
<Button size="small"
onClick={() => navigator.clipboard.writeText(created).then(() => toast(t("tokens.copied"), "success"))}
>
<Icon name="copy" /> {t("tokens.copy")}
</button>
</Button>
</div>
<pre className="mono token-example">{`codecraft login ${location.origin}`}</pre>
</div>
@@ -83,8 +84,7 @@ export function ApiTokens() {
<td>{k.last_used ? fmtRelative(k.last_used) : "–"}</td>
<td>{k.expires_at ? new Date(k.expires_at).toLocaleDateString() : t("tokens.never")}</td>
<td>
<button
className="small ghost danger"
<Button type="text" danger size="small"
aria-label={t("tokens.revoke")}
title={t("tokens.revoke")}
onClick={async () => {
@@ -95,7 +95,7 @@ export function ApiTokens() {
}}
>
<Icon name="trash" />
</button>
</Button>
</td>
</tr>
))}
@@ -103,20 +103,20 @@ export function ApiTokens() {
</table>
)}
<div className="row" style={{ gap: 6, marginTop: 10, flexWrap: "wrap" }}>
<input style={{ flex: 1, minWidth: 160 }} placeholder={t("tokens.namePlaceholder")} value={name} onChange={(e) => setName(e.target.value)} />
<select value={scope} onChange={(e) => setScope(e.target.value as "full" | "read")}>
<Input style={{ flex: 1, minWidth: 160 }} placeholder={t("tokens.namePlaceholder")} value={name} onChange={(e) => setName(e.target.value)} />
<Select value={scope} onChange={(e) => setScope(e.target.value as "full" | "read")}>
<option value="full">{t("tokens.scopeFull")}</option>
<option value="read">{t("tokens.scopeRead")}</option>
</select>
<select value={days} onChange={(e) => setDays(e.target.value)}>
</Select>
<Select value={days} onChange={(e) => setDays(e.target.value)}>
<option value="">{t("tokens.noExpiry")}</option>
<option value="30">30 {t("tokens.days")}</option>
<option value="90">90 {t("tokens.days")}</option>
<option value="365">365 {t("tokens.days")}</option>
</select>
<button className="primary" disabled={!name.trim()} onClick={create}>
</Select>
<Button type="primary" disabled={!name.trim()} onClick={create}>
<Icon name="plus" /> {t("tokens.create")}
</button>
</Button>
</div>
</div>
);
+6 -4
View File
@@ -1,3 +1,5 @@
import { Button } from "antd";
import { Select } from "../../ui/Select";
import { useState } from "react";
import { useFetch } from "../../hooks";
import { fmtDate, useT } from "../../i18n";
@@ -24,17 +26,17 @@ export function Audit() {
<h3>
{t("audit.title")}
<span className="spacer" />
<select value={filter} onChange={(e) => setFilter(e.target.value)}>
<Select value={filter} onChange={(e) => setFilter(e.target.value)}>
<option value="">{t("audit.all")}</option>
{["login", "permission", "config", "user", "folder", "session", "git", "backup"].map((a) => (
<option key={a} value={a}>
{a}
</option>
))}
</select>
<button className="small" onClick={reload} aria-label={t("common.refresh")}>
</Select>
<Button size="small" onClick={reload} aria-label={t("common.refresh")}>
<Icon name="refresh" />
</button>
</Button>
</h3>
<div style={{ overflowX: "auto" }}>
<table className="grid">
+14 -15
View File
@@ -1,3 +1,4 @@
import { Button, Checkbox, Input } from "antd";
import { uploadBatch } from "../../uploads";
import { useEffect, useRef, useState } from "react";
import { api, get, patch, post } from "../../api";
@@ -142,9 +143,9 @@ export function Backups() {
<a className="button small" href="/api/backup">
<Icon name="download" /> {t("audit.download")}
</a>
<button className="small" onClick={() => fileInput.current?.click()} disabled={restoring}>
<Button size="small" onClick={() => fileInput.current?.click()} disabled={restoring}>
<Icon name="upload" /> {restoring ? t("backup.restoring") : t("backup.restoreFile")}
</button>
</Button>
<input
ref={fileInput}
type="file"
@@ -156,9 +157,9 @@ export function Backups() {
if (file) void restore({ file });
}}
/>
<button className="small primary" onClick={runNow} disabled={busy}>
<Button type="primary" size="small" onClick={runNow} disabled={busy}>
{busy ? t("backup.running") : t("backup.now")}
</button>
</Button>
</h3>
<div className="hint" style={{ marginBottom: 10 }}>
{t("audit.backupHint")}
@@ -166,18 +167,17 @@ export function Backups() {
{form && (
<>
<div className="row" style={{ gap: 12, flexWrap: "wrap", alignItems: "center" }}>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
<input type="checkbox" checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} />
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })}>
{t("backup.daily")}
</label>
</Checkbox>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
{t("backup.at")}
<input type="number" min={0} max={23} style={{ width: 64 }} value={form.hour} onChange={(e) => setForm({ ...form, hour: Number(e.target.value) })} />
<Input type="number" min={0} max={23} style={{ width: 64 }} value={form.hour} onChange={(e) => setForm({ ...form, hour: Number(e.target.value) })} />
{t("backup.oclock")}
</label>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
{t("backup.keep")}
<input type="number" min={1} style={{ width: 70 }} value={form.keep} onChange={(e) => setForm({ ...form, keep: Number(e.target.value) })} />
<Input type="number" min={1} style={{ width: 70 }} value={form.keep} onChange={(e) => setForm({ ...form, keep: Number(e.target.value) })} />
</label>
</div>
{data && <div className="hint mono" style={{ marginTop: 6 }}>{data.dir}</div>}
@@ -194,8 +194,7 @@ export function Backups() {
{s3("access_key", t("backup.accessKey"), "AKIA… or ${S3_ACCESS_KEY}")}
<label className="field">
<span>{t("backup.secretKey")}</span>
<input
type="password"
<Input.Password
value={secret}
autoComplete="new-password"
placeholder={form.s3.secret_key === MASK ? t("backup.secretStored") : form.s3.secret_key || "${S3_SECRET_KEY}"}
@@ -206,9 +205,9 @@ export function Backups() {
</div>
</details>
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end" }}>
<button className="primary" onClick={save}>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
</div>
</>
)}
@@ -225,9 +224,9 @@ export function Backups() {
<Icon name="file" />
<span className="grow">{f.name}</span>
<span className="hint">{formatSize(f.size)}</span>
<button className="small" title={t("backup.restore")} onClick={() => void restore({ name: f.name })} disabled={restoring}>
<Button size="small" title={t("backup.restore")} onClick={() => void restore({ name: f.name })} disabled={restoring}>
<Icon name="undo" />
</button>
</Button>
<a className="button small" title={t("audit.download")} href={`/api/backups/${encodeURIComponent(f.name)}`}>
<Icon name="download" />
</a>
+15 -15
View File
@@ -1,3 +1,4 @@
import { Button, Checkbox, Input } from "antd";
import { useEffect, useState } from "react";
import { api, get, post } from "../../api";
import { confirmDialog, toast } from "../../dialogs";
@@ -111,9 +112,9 @@ export function ClaudeCode() {
<Icon name="robot" /> {t("claude.title")}
<span className="spacer" />
{status?.logged_in && (
<button className="small ghost danger" onClick={logout}>
<Button type="text" danger size="small" onClick={logout}>
{t("claude.logout")}
</button>
</Button>
)}
</h3>
<div className="hint" style={{ marginBottom: 10 }}>{t("claude.intro")}</div>
@@ -126,9 +127,9 @@ export function ClaudeCode() {
<>
<span className="chip warn">{t("claude.updateAvailable", { version: status.latest ?? "" })}</span>
{isAdmin ? (
<button className="small primary" disabled={updating} onClick={update}>
<Button type="primary" size="small" disabled={updating} onClick={update}>
{updating ? <Spinner small /> : <Icon name="download" />} {updating ? t("claude.updating") : t("claude.update")}
</button>
</Button>
) : (
<span className="hint">{t("claude.updateAdmin")}</span>
)}
@@ -136,9 +137,9 @@ export function ClaudeCode() {
) : (
status.latest && <span className="chip">{t("claude.upToDate")}</span>
)}
<button className="small ghost" disabled={checking || updating} onClick={check} title={t("claude.checkNow")} aria-label={t("claude.checkNow")}>
<Button type="text" size="small" disabled={checking || updating} onClick={check} title={t("claude.checkNow")} aria-label={t("claude.checkNow")}>
{checking ? <Spinner small /> : <Icon name="refresh" />}
</button>
</Button>
</div>
)}
{updateLog && (
@@ -158,12 +159,11 @@ export function ClaudeCode() {
)}
{status?.installed && !status.logged_in && !url && (
<>
<label className="row" style={{ marginBottom: 8 }}>
<input type="checkbox" checked={console_} onChange={(e) => setConsole(e.target.checked)} /> {t("claude.console")}
</label>
<button className="primary" disabled={busy} onClick={start}>
<Checkbox className="row" style={{ marginBottom: 8 }} checked={console_} onChange={(e) => setConsole(e.target.checked)}> {t("claude.console")}
</Checkbox>
<Button type="primary" disabled={busy} onClick={start}>
{busy ? <Spinner small /> : <Icon name="lock" />} {t("claude.signIn")}
</button>
</Button>
</>
)}
{url && (
@@ -177,11 +177,11 @@ export function ClaudeCode() {
<li>
{t("claude.step2")}
<div className="row" style={{ marginTop: 6 }}>
<input style={{ flex: 1 }} value={code} placeholder={t("claude.codePlaceholder")} autoComplete="off" autoCapitalize="off" spellCheck={false} onChange={(e) => setCode(e.target.value)} onKeyDown={(e) => e.key === "Enter" && code.trim() && void submit()} />
<button className="primary" disabled={busy || !code.trim()} onClick={submit}>
<Input style={{ flex: 1 }} value={code} placeholder={t("claude.codePlaceholder")} autoComplete="off" autoCapitalize="off" spellCheck={false} onChange={(e) => setCode(e.target.value)} onKeyDown={(e) => e.key === "Enter" && code.trim() && void submit()} />
<Button type="primary" disabled={busy || !code.trim()} onClick={submit}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("claude.confirm")}
</button>
<button onClick={cancel}>{t("common.cancel")}</button>
</Button>
<Button onClick={cancel}>{t("common.cancel")}</Button>
</div>
</li>
</ol>
+5 -4
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useT } from "../../i18n";
import { toast } from "../../dialogs";
import { Icon } from "../Icon";
@@ -25,18 +26,18 @@ export function CliInstall() {
{t(prebuilt ? "cli.step1" : "cli.step1Source")}
<div className="row" style={{ gap: 6, marginTop: 4 }}>
<code className="token-value">{cmd}</code>
<button className="small" onClick={() => copy(cmd)}>
<Button size="small" onClick={() => copy(cmd)}>
<Icon name="copy" /> {t("tokens.copy")}
</button>
</Button>
</div>
</li>
<li>
{t("cli.step2")}
<div className="row" style={{ gap: 6, marginTop: 4 }}>
<code className="token-value">{`codecraft login ${location.origin}`}</code>
<button className="small" onClick={() => copy(`codecraft login ${location.origin}`)}>
<Button size="small" onClick={() => copy(`codecraft login ${location.origin}`)}>
<Icon name="copy" /> {t("tokens.copy")}
</button>
</Button>
</div>
</li>
<li>{t("cli.step3")}</li>
+8 -8
View File
@@ -1,3 +1,4 @@
import { Button, Checkbox, Input } from "antd";
import { useState } from "react";
import { del, post, put } from "../../api";
import { useFetch } from "../../hooks";
@@ -45,17 +46,16 @@ export function Folders() {
<h3>
📁 <code>{f.path.slice(ws.length) || "/"}</code>
<span className="spacer" />
<button className="small danger" onClick={() => void confirmDialog({ message: t("folders.removeConfirm"), danger: true, confirmLabel: t("folders.remove") }).then((ok): unknown => ok && run(() => del(`/folders/${f.id}`)))}>
<Button danger size="small" onClick={() => void confirmDialog({ message: t("folders.removeConfirm"), danger: true, confirmLabel: t("folders.remove") }).then((ok): unknown => ok && run(() => del(`/folders/${f.id}`)))}>
{t("folders.remove")}
</button>
</Button>
</h3>
<div className="check-list">
{users.length === 0 && <div style={{ color: "var(--muted)" }}>{t("folders.noUsers")}</div>}
{users.map((u) => (
<label key={u.id}>
<input type="checkbox" checked={f.users.includes(u.id)} onChange={() => toggle(f, u.id)} />
<Checkbox key={u.id} checked={f.users.includes(u.id)} onChange={() => toggle(f, u.id)}>
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
</label>
</Checkbox>
))}
</div>
</div>
@@ -64,10 +64,10 @@ export function Folders() {
<h3>{t("folders.add")}</h3>
<div className="row">
<code>{ws}/</code>
<input value={path} onChange={(e) => setPath(e.target.value)} placeholder="team/project" style={{ flex: 1, minWidth: 160 }} />
<button className="primary" disabled={!path.trim()} onClick={() => run(async () => (await post("/folders", { path }), setPath("")))}>
<Input value={path} onChange={(e) => setPath(e.target.value)} placeholder="team/project" style={{ flex: 1, minWidth: 160 }} />
<Button type="primary" disabled={!path.trim()} onClick={() => run(async () => (await post("/folders", { path }), setPath("")))}>
+ {t("common.add")}
</button>
</Button>
</div>
<div style={{ fontSize: 12, color: "var(--muted)", marginTop: 6 }}>{t("folders.addHint")}</div>
</div>
+12 -12
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { useEffect, useState } from "react";
import { get, put } from "../../api";
import { useT } from "../../i18n";
@@ -54,19 +55,18 @@ export function GitAccount() {
</div>
<div className="form">
<label>{t("gitcred.name")}</label>
<input value={s.name} onChange={(e) => setS({ ...s, name: e.target.value })} placeholder="Jane Doe" autoComplete="name" />
<Input value={s.name} onChange={(e) => setS({ ...s, name: e.target.value })} placeholder="Jane Doe" autoComplete="name" />
<label>{t("gitcred.email")}</label>
<input value={s.email} onChange={(e) => setS({ ...s, email: e.target.value })} placeholder="jane@example.com" autoComplete="email" />
<Input value={s.email} onChange={(e) => setS({ ...s, email: e.target.value })} placeholder="jane@example.com" autoComplete="email" />
</div>
<h4 style={{ margin: "16px 0 8px" }}>{t("gitcred.credentials")}</h4>
<div className="gitcred-list">
{s.credentials.length === 0 && <div className="empty" style={{ padding: 8 }}>{t("gitcred.none")}</div>}
{s.credentials.map((c, i) => (
<div key={i} className="gitcred-row">
<input value={c.host} placeholder="git.example.com" onChange={(e) => setCred(i, { host: e.target.value })} aria-label={t("gitcred.host")} />
<input value={c.username} placeholder={t("gitcred.user")} onChange={(e) => setCred(i, { username: e.target.value })} aria-label={t("gitcred.user")} autoComplete="off" />
<input
type="password"
<Input value={c.host} placeholder="git.example.com" onChange={(e) => setCred(i, { host: e.target.value })} aria-label={t("gitcred.host")} />
<Input value={c.username} placeholder={t("gitcred.user")} onChange={(e) => setCred(i, { username: e.target.value })} aria-label={t("gitcred.user")} autoComplete="off" />
<Input.Password
value={c.token}
placeholder={t("gitcred.token")}
onFocus={(e) => c.token.startsWith("•") && e.target.select()}
@@ -74,20 +74,20 @@ export function GitAccount() {
aria-label={t("gitcred.token")}
autoComplete="new-password"
/>
<button className="ghost small" onClick={() => setS({ ...s, credentials: s.credentials.filter((_, j) => j !== i) })} aria-label={t("common.remove")}>
<Button type="text" size="small" onClick={() => setS({ ...s, credentials: s.credentials.filter((_, j) => j !== i) })} aria-label={t("common.remove")}>
<Icon name="trash" />
</button>
</Button>
</div>
))}
</div>
<div className="row" style={{ marginTop: 10, gap: 8 }}>
<button className="small" onClick={() => setS({ ...s, credentials: [...s.credentials, { host: "", username: "", token: "" }] })}>
<Button size="small" onClick={() => setS({ ...s, credentials: [...s.credentials, { host: "", username: "", token: "" }] })}>
<Icon name="plus" /> {t("gitcred.add")}
</button>
</Button>
<span className="grow" />
<button className="primary" onClick={save} disabled={saving}>
<Button type="primary" onClick={save} disabled={saving}>
{t("common.save")}
</button>
</Button>
</div>
</div>
);
+4 -3
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { useEffect, useState } from "react";
import { get, put } from "../../api";
import { useT } from "../../i18n";
@@ -22,12 +23,12 @@ export function Memory() {
<div className="hint" style={{ marginBottom: 8 }}>
{t("memory.hint")}
</div>
<textarea rows={6} style={{ width: "100%" }} value={text} placeholder={t("memory.placeholder")} onChange={(e) => setText(e.target.value)} />
<Input.TextArea rows={6} style={{ width: "100%" }} value={text} placeholder={t("memory.placeholder")} onChange={(e) => setText(e.target.value)} />
<div className="row" style={{ marginTop: 8 }}>
<span className="grow" />
<button className="primary" onClick={() => put("/account/memory", { memory: text }).then(() => toast(t("settings.saved"), "success")).catch((e) => toast(e.message))}>
<Button type="primary" onClick={() => put("/account/memory", { memory: text }).then(() => toast(t("settings.saved"), "success")).catch((e) => toast(e.message))}>
{t("common.save")}
</button>
</Button>
</div>
</div>
);
+17 -16
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input } from "antd";
import { Select } from "../../ui/Select";
import { useEffect, useState } from "react";
import { get, put } from "../../api";
import { confirmDialog, toast } from "../../dialogs";
@@ -70,10 +72,10 @@ export function PersonalModes() {
<div className="panel">
<h3>{t("agents.addMode")}</h3>
<div className="row">
<input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && void add()} />
<button className="primary" onClick={() => void add()} disabled={!name.trim()}>
<Input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && void add()} />
<Button type="primary" onClick={() => void add()} disabled={!name.trim()}>
+ {t("agents.addMode")}
</button>
</Button>
</div>
</div>
</>
@@ -106,40 +108,39 @@ function ModeRow({ name, mode, tools, open, onToggle, onSave, onRemove }: { name
<span className="chip">{form.style === "chat" ? t("agents.styleChatShort") : t("agents.styleCodingShort")}</span>
{form.read_only && <span className="chip">{t("agents.readOnly")}</span>}
<span className="spacer" />
<button className="small ghost danger" onClick={onRemove} title={t("common.delete")} aria-label={t("common.delete")}>
<Button type="text" danger size="small" onClick={onRemove} title={t("common.delete")} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
<button className="small" onClick={onToggle}>
</Button>
<Button size="small" onClick={onToggle}>
{open ? t("common.collapse") : t("common.edit")}
</button>
</Button>
</h3>
{!open && mode.description && <div className="hint">{mode.description}</div>}
{open && (
<>
<div className="form">
<label>{t("agents.description")}</label>
<input value={form.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
<Input value={form.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
<label>{t("agents.style")}</label>
<select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
<Select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
<option value="coding">{t("agents.styleCoding")}</option>
<option value="chat">{t("agents.styleChat")}</option>
</select>
</Select>
<label>{t("agents.model")}</label>
<ModelSelect value={form.model} onChange={(v) => setForm({ ...form, model: v })} emptyLabel={t("agents.sessionModel")} />
<label>{t("agents.readOnlyLabel")}</label>
<label className="row" style={{ gap: 6, alignItems: "center" }}>
<input type="checkbox" checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })} />
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })}>
<span className="hint">{t("agents.readOnlyHint")}</span>
</label>
</Checkbox>
<label>{t("agents.tools")}</label>
<ToolPicker tools={tools} value={form.tools} onChange={(v) => setForm({ ...form, tools: v })} readOnly={form.read_only} />
<label>{t("agents.prompt")}</label>
<textarea rows={8} value={form.prompt} placeholder={t("modes.promptPlaceholder")} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
<Input.TextArea rows={8} value={form.prompt} placeholder={t("modes.promptPlaceholder")} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
</div>
<div className="row" style={{ marginTop: 12 }}>
<button className="primary" onClick={submit}>
<Button type="primary" onClick={submit}>
{t("common.save")}
</button>
</Button>
</div>
</>
)}
+41 -44
View File
@@ -1,3 +1,5 @@
import { Button, Checkbox, Input } from "antd";
import { Modal } from "../../ui/Modal";
import { useState } from "react";
import { del, get, post, put } from "../../api";
import { confirmDialog, promptDialog, toast } from "../../dialogs";
@@ -54,14 +56,14 @@ export function Skills() {
{t("skills.hint")}
</div>
<div className="row" style={{ gap: 6, marginBottom: 8 }}>
<button className="primary" onClick={() => setEditing({ name: "", isNew: true })}>
<Button type="primary" onClick={() => setEditing({ name: "", isNew: true })}>
<Icon name="plus" /> {t("skills.new")}
</button>
<button onClick={() => setImporting(true)}>
</Button>
<Button onClick={() => setImporting(true)}>
<Icon name="git" /> {t("skills.import")}
</button>
</Button>
<span className="spacer" />
{(data?.skills.length ?? 0) > 8 && <input placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
{(data?.skills.length ?? 0) > 8 && <Input placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
</div>
{!data ? (
<Spinner />
@@ -77,12 +79,12 @@ export function Skills() {
{s.description}
</div>
</div>
<button className="small" onClick={() => setEditing({ name: s.name, isNew: false })}>
<Button size="small" onClick={() => setEditing({ name: s.name, isNew: false })}>
<Icon name="edit" /> {t("common.edit")}
</button>
<button className="small danger" onClick={() => void remove(s)} aria-label={t("common.delete")}>
</Button>
<Button danger size="small" onClick={() => void remove(s)} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
</Button>
</div>
))
)}
@@ -152,8 +154,7 @@ function SkillEditor({ name: initial, isNew, onClose }: { name: string; isNew: b
};
return (
<div className="modal-backdrop">
<div className="modal draft-modal" role="dialog" aria-label={t("skills.edit")}>
<Modal className="draft-modal" role="dialog" aria-label={t("skills.edit")}>
<h3>{isNew ? t("skills.new") : t("skills.edit")}</h3>
{!loaded ? (
<Spinner />
@@ -161,38 +162,37 @@ function SkillEditor({ name: initial, isNew, onClose }: { name: string; isNew: b
<>
<label style={{ display: "block", marginBottom: 8 }}>
<span className="hint">{t("skills.name")}</span>
<input className="mono" style={{ width: "100%" }} value={name} disabled={!isNew} placeholder="frontend" onChange={(e) => setName(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, "-"))} />
<Input className="mono" style={{ width: "100%" }} value={name} disabled={!isNew} placeholder="frontend" onChange={(e) => setName(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, "-"))} />
</label>
<div className="row" style={{ gap: 4, flexWrap: "wrap", marginBottom: 6 }}>
{files.map((f) => (
<button key={f.path} className={`small ${f.path === file?.path ? "primary" : ""}`} onClick={() => setCurrent(f.path)}>
<Button key={f.path} size="small" type={f.path === file?.path ? "primary" : "default"} onClick={() => setCurrent(f.path)}>
{f.path}
</button>
</Button>
))}
<button className="small ghost" onClick={() => void addFile()}>
<Button type="text" size="small" onClick={() => void addFile()}>
<Icon name="plus" /> {t("skills.file")}
</button>
</Button>
{file && file.path !== "SKILL.md" && (
<button className="small danger" onClick={removeFile} aria-label={t("common.delete")}>
<Button danger size="small" onClick={removeFile} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
</Button>
)}
</div>
<textarea className="mono" rows={18} style={{ width: "100%" }} value={file?.content ?? ""} onChange={(e) => setContent(e.target.value)} spellCheck={false} />
<Input.TextArea className="mono" rows={18} style={{ width: "100%" }} value={file?.content ?? ""} onChange={(e) => setContent(e.target.value)} spellCheck={false} />
<div className="hint">{t("skills.fileHint")}</div>
</>
)}
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
<button onClick={() => onClose(false)} disabled={busy}>
<Button onClick={() => onClose(false)} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={() => void save()} disabled={busy || !loaded || !name.trim() || !files.some((f) => f.path === "SKILL.md")}>
</Button>
<Button type="primary" onClick={() => void save()} disabled={busy || !loaded || !name.trim() || !files.some((f) => f.path === "SKILL.md")}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
@@ -240,51 +240,48 @@ function ImportDialog({ onClose }: { onClose: (done: boolean) => void }) {
};
return (
<div className="modal-backdrop">
<div className="modal draft-modal" role="dialog" aria-label={t("skills.import")}>
<Modal className="draft-modal" role="dialog" aria-label={t("skills.import")}>
<h3>{t("skills.import")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>
{t("skills.importHint")}
</div>
<div className="row" style={{ gap: 6 }}>
<input className="mono" style={{ flex: 1 }} value={url} placeholder="https://github.com/owner/repo/tree/main/skills" onChange={(e) => setUrl(e.target.value)} onKeyDown={(e) => e.key === "Enter" && url.trim() && !busy && void scan()} />
<button onClick={() => void scan()} disabled={busy || !url.trim()}>
<Input className="mono" style={{ flex: 1 }} value={url} placeholder="https://github.com/owner/repo/tree/main/skills" onChange={(e) => setUrl(e.target.value)} onKeyDown={(e) => e.key === "Enter" && url.trim() && !busy && void scan()} />
<Button onClick={() => void scan()} disabled={busy || !url.trim()}>
{busy && !found ? <Spinner small /> : <Icon name="search" />} {t("skills.scan")}
</button>
</Button>
</div>
{found && found.length > 0 && (
<>
<div className="row" style={{ gap: 6, margin: "8px 0" }}>
<input style={{ flex: 1 }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />
<button className="small" onClick={() => setPicked(new Set([...picked, ...shown.map((s) => s.path)]))}>
<Input style={{ flex: 1 }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />
<Button size="small" onClick={() => setPicked(new Set([...picked, ...shown.map((s) => s.path)]))}>
{t("skills.selectShown", { n: shown.length })}
</button>
<button className="small ghost" onClick={() => setPicked(new Set())}>
</Button>
<Button type="text" size="small" onClick={() => setPicked(new Set())}>
{t("skills.selectNone")}
</button>
</Button>
</div>
<div className="issue-list">
{shown.map((s) => (
<label key={s.path} className="row" style={{ gap: 8, padding: "2px 0" }}>
<input type="checkbox" checked={picked.has(s.path)} onChange={() => toggle(s.path)} />
<Checkbox key={s.path} className="row" style={{ gap: 8, padding: "2px 0" }} checked={picked.has(s.path)} onChange={() => toggle(s.path)}>
<span>
<code>{s.name}</code> <span className="hint">{s.path} · {t("skills.files", { n: s.files })}</span>
</span>
</label>
</Checkbox>
))}
</div>
</>
)}
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
<button onClick={() => onClose(false)} disabled={busy}>
<Button onClick={() => onClose(false)} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={() => void run()} disabled={busy || picked.size === 0}>
</Button>
<Button type="primary" onClick={() => void run()} disabled={busy || picked.size === 0}>
{busy && found ? <Spinner small /> : <Icon name="check" />} {t("skills.importN", { n: picked.size })}
</button>
</Button>
</div>
</div>
</div>
</Modal>
);
}
+9 -8
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { useEffect, useState } from "react";
import { get, put } from "../../api";
import { useT } from "../../i18n";
@@ -39,22 +40,22 @@ export function Snippets() {
<div key={s.id ?? i} className="snippet-row">
<div className="row">
<span className="snippet-slash">/</span>
<input value={s.name} placeholder={t("snippets.name")} maxLength={40} onChange={(e) => set(i, { name: e.target.value })} aria-label={t("snippets.name")} />
<button title={t("common.delete")} aria-label={t("common.delete")} onClick={() => setItems(items.filter((_, j) => j !== i))}>
<Input value={s.name} placeholder={t("snippets.name")} maxLength={40} onChange={(e) => set(i, { name: e.target.value })} aria-label={t("snippets.name")} />
<Button title={t("common.delete")} aria-label={t("common.delete")} onClick={() => setItems(items.filter((_, j) => j !== i))}>
<Icon name="trash" />
</button>
</Button>
</div>
<textarea rows={2} value={s.text} placeholder={t("snippets.text")} onChange={(e) => set(i, { text: e.target.value })} aria-label={t("snippets.text")} />
<Input.TextArea rows={2} value={s.text} placeholder={t("snippets.text")} onChange={(e) => set(i, { text: e.target.value })} aria-label={t("snippets.text")} />
</div>
))}
<div className="row" style={{ marginTop: 8 }}>
<button onClick={() => setItems([...items, { name: "", text: "" }])}>
<Button onClick={() => setItems([...items, { name: "", text: "" }])}>
<Icon name="plus" /> {t("snippets.add")}
</button>
</Button>
<span className="grow" />
<button className="primary" onClick={save}>
<Button type="primary" onClick={save}>
{t("common.save")}
</button>
</Button>
</div>
</div>
);
+12 -13
View File
@@ -1,3 +1,4 @@
import { Button, Checkbox, Input } from "antd";
import { useEffect, useState } from "react";
import { del, get, post } from "../../api";
import { useT } from "../../i18n";
@@ -58,11 +59,10 @@ export function SshKeys() {
<b>{k.name}</b>
<span className="hint mono">{k.fingerprint}</span>
<span className="spacer" />
<button className="small" onClick={() => copy(k.public)}>
<Button size="small" onClick={() => copy(k.public)}>
<Icon name="copy" /> {t("ssh.copyPublic")}
</button>
<button
className="small"
</Button>
<Button size="small"
title={t("common.delete")}
aria-label={t("common.delete")}
onClick={async () => {
@@ -72,24 +72,23 @@ export function SshKeys() {
}}
>
<Icon name="trash" />
</button>
</Button>
</div>
<input readOnly value={k.public} onFocus={(e) => e.currentTarget.select()} aria-label={t("ssh.public")} className="mono" />
<Input readOnly value={k.public} onFocus={(e) => e.currentTarget.select()} aria-label={t("ssh.public")} className="mono" />
</div>
))}
<div className="row" style={{ marginTop: 10, flexWrap: "wrap" }}>
<input value={name} onChange={(e) => setName(e.target.value)} placeholder={t("ssh.name")} maxLength={60} aria-label={t("ssh.name")} style={{ flex: "1 1 160px" }} />
<button className="primary" disabled={busy || !name.trim() || (importing && !priv.trim())} onClick={add}>
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder={t("ssh.name")} maxLength={60} aria-label={t("ssh.name")} style={{ flex: "1 1 160px" }} />
<Button type="primary" disabled={busy || !name.trim() || (importing && !priv.trim())} onClick={add}>
{importing ? t("ssh.import") : t("ssh.generate")}
</button>
<label className="row" style={{ gap: 6 }}>
<input type="checkbox" checked={importing} onChange={(e) => setImporting(e.target.checked)} />
</Button>
<Checkbox className="row" style={{ gap: 6 }} checked={importing} onChange={(e) => setImporting(e.target.checked)}>
{t("ssh.importExisting")}
</label>
</Checkbox>
</div>
{importing && (
<>
<textarea rows={5} className="mono" value={priv} onChange={(e) => setPriv(e.target.value)} placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" aria-label={t("ssh.private")} style={{ width: "100%", marginTop: 8 }} spellCheck={false} autoComplete="off" />
<Input.TextArea rows={5} className="mono" value={priv} onChange={(e) => setPriv(e.target.value)} placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" aria-label={t("ssh.private")} style={{ width: "100%", marginTop: 8 }} spellCheck={false} autoComplete="off" />
<div className="hint">{t("ssh.importHint")}</div>
</>
)}
+12 -13
View File
@@ -1,3 +1,4 @@
import { Button, Checkbox, Input } from "antd";
import { useState } from "react";
import { del, put } from "../../api";
import { confirmDialog, toast } from "../../dialogs";
@@ -59,9 +60,9 @@ export function Telegram() {
<Icon name="share" /> {t("telegram.title")}
<span className="spacer" />
{data?.configured && (
<button className="small ghost danger" onClick={disconnect}>
<Button type="text" danger size="small" onClick={disconnect}>
{t("telegram.disconnect")}
</button>
</Button>
)}
</h3>
<div className="hint" style={{ marginBottom: 10 }}>
@@ -74,7 +75,7 @@ export function Telegram() {
<li>{t("telegram.step2")}</li>
</ol>
<div className="row" style={{ gap: 6 }}>
<input
<Input
type="text"
name="telegram-bot-token"
value={token}
@@ -85,9 +86,9 @@ export function Telegram() {
onChange={(e) => setToken(e.target.value)}
style={{ flex: 1 }}
/>
<button className="primary" onClick={() => void connect()} disabled={busy || !token.trim()}>
<Button type="primary" onClick={() => void connect()} disabled={busy || !token.trim()}>
{busy ? t("telegram.checking") : t("telegram.connect")}
</button>
</Button>
</div>
</>
)}
@@ -112,18 +113,16 @@ export function Telegram() {
{data.error && <div className="notice err" style={{ marginTop: 10 }}>{data.error}</div>}
{data.paired && <div className="hint" style={{ marginTop: 10 }}>{t("telegram.commands")}</div>}
<h4 style={{ margin: "16px 0 6px" }}>{t("telegram.notify")}</h4>
<label className="row" style={{ gap: 8, alignItems: "center" }}>
<input type="checkbox" checked={data.factory_alerts} onChange={(e) => void savePrefs({ factory_alerts: e.target.checked })} />
<Checkbox className="row" style={{ gap: 8, alignItems: "center" }} checked={data.factory_alerts} onChange={(e) => void savePrefs({ factory_alerts: e.target.checked })}>
<span>{t("telegram.factoryAlerts")}</span>
</label>
<label className="row" style={{ gap: 8, alignItems: "center", marginTop: 6 }}>
<input type="checkbox" checked={data.quiet} onChange={(e) => void savePrefs({ quiet: e.target.checked })} />
</Checkbox>
<Checkbox className="row" style={{ gap: 8, alignItems: "center", marginTop: 6 }} checked={data.quiet} onChange={(e) => void savePrefs({ quiet: e.target.checked })}>
<span>{t("telegram.quiet")}</span>
</label>
</Checkbox>
<div className="row" style={{ gap: 8, alignItems: "center", marginTop: 6, marginLeft: 24, flexWrap: "wrap", opacity: data.quiet ? 1 : 0.5 }}>
<input type="time" value={data.quiet_from} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_from: e.target.value })} />
<Input type="time" value={data.quiet_from} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_from: e.target.value })} />
<span>–</span>
<input type="time" value={data.quiet_to} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_to: e.target.value })} />
<Input type="time" value={data.quiet_to} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_to: e.target.value })} />
<span className="hint">{t("telegram.serverTime", { time: data.server_time })}{data.quiet_now ? ` · ${t("telegram.quietNow")}` : ""}</span>
</div>
<div className="hint" style={{ marginTop: 6 }}>{t("telegram.quietHint")}</div>
+9 -8
View File
@@ -1,3 +1,4 @@
import { Button, Input } from "antd";
import { useEffect, useState } from "react";
import { confirmDialog, toast } from "../../dialogs";
import { useT } from "../../i18n";
@@ -33,12 +34,12 @@ function List({ scope, initial }: { scope: "personal" | "global"; initial: Templ
{list.map((x, i) => (
<div key={x.id || `new${i}`} className="tpl-edit">
<div className="row">
<input className="grow" value={x.name} placeholder={t("templates.name")} onChange={(e) => set(i, { name: e.target.value })} />
<button className="ghost small" onClick={() => remove(i)} aria-label={t("common.delete")}>
<Input className="grow" value={x.name} placeholder={t("templates.name")} onChange={(e) => set(i, { name: e.target.value })} />
<Button type="text" size="small" onClick={() => remove(i)} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
</Button>
</div>
<textarea rows={4} value={x.text} placeholder={t("templates.textPlaceholder")} onChange={(e) => set(i, { text: e.target.value })} />
<Input.TextArea rows={4} value={x.text} placeholder={t("templates.textPlaceholder")} onChange={(e) => set(i, { text: e.target.value })} />
{placeholders(x.text).length > 0 && (
<div className="tpl-ph">
{placeholders(x.text).map((p) => (
@@ -51,13 +52,13 @@ function List({ scope, initial }: { scope: "personal" | "global"; initial: Templ
</div>
))}
<div className="row" style={{ marginTop: 8 }}>
<button onClick={() => (setList([...list, { id: "", name: "", text: "" }]), setDirty(true))}>
<Button onClick={() => (setList([...list, { id: "", name: "", text: "" }]), setDirty(true))}>
<Icon name="plus" /> {t("templates.add")}
</button>
</Button>
<span className="grow" />
<button className="primary" disabled={!dirty} onClick={save}>
<Button type="primary" disabled={!dirty} onClick={save}>
{t("common.save")}
</button>
</Button>
</div>
</div>
);
+3 -2
View File
@@ -1,3 +1,4 @@
import { Button } from "antd";
import { useEffect } from "react";
import { post } from "../../api";
import { useFetch } from "../../hooks";
@@ -32,9 +33,9 @@ export function Tools() {
<Spinner /> {t("tools.installing")}
</div>
) : (
<button className="primary" onClick={() => post("/tools/ghidra/install").then(reload).catch((e) => toast(e.message))}>
<Button type="primary" onClick={() => post("/tools/ghidra/install").then(reload).catch((e) => toast(e.message))}>
{g?.installed ? t("tools.reinstall") : t("tools.install")}
</button>
</Button>
)}
{g?.log && <pre className="git-output" style={{ marginTop: 10 }}>{g.log}</pre>}
</div>
+19 -19
View File
@@ -1,3 +1,5 @@
import { Button, Input } from "antd";
import { Select } from "../../ui/Select";
import { useState } from "react";
import { del, patch, post } from "../../api";
import { useFetch } from "../../hooks";
@@ -54,17 +56,16 @@ export function Users() {
</td>
<td>{u.display_name}</td>
<td>
<select value={u.role} onChange={(e) => run(() => patch(`/users/${u.id}`, { role: e.target.value }))}>
<Select value={u.role} onChange={(e) => run(() => patch(`/users/${u.id}`, { role: e.target.value }))}>
<option value="user">{t("users.roleUser")}</option>
<option value="admin">{t("users.roleAdmin")}</option>
</select>
</Select>
</td>
<td>
{u.has_password && <span className="chip">{t("users.password")}</span>} {u.oidc && <span className="chip">SSO</span>}
</td>
<td>
<button
className="small ghost"
<Button type="text" size="small"
title={t("users.quotaHint")}
onClick={async () => {
const v = await promptDialog({ message: t("users.quotaPrompt", { name: u.username }), defaultValue: u.monthly_quota != null ? String(u.monthly_quota) : "" });
@@ -73,21 +74,21 @@ export function Users() {
}}
>
{u.monthly_quota != null ? u.monthly_quota : "∞"}
</button>
</Button>
</td>
<td>{fmtDate(u.created_at, false)}</td>
<td>
<div className="row" style={{ flexWrap: "nowrap" }}>
<button className="small" onClick={() => resetPassword(u)}>
<Button size="small" onClick={() => resetPassword(u)}>
{t("users.setPassword")}
</button>
<button className="small" onClick={() => run(() => patch(`/users/${u.id}`, { disabled: !u.disabled }))}>
</Button>
<Button size="small" onClick={() => run(() => patch(`/users/${u.id}`, { disabled: !u.disabled }))}>
{u.disabled ? t("users.enable") : t("users.disable")}
</button>
</Button>
{u.id !== me?.id && (
<button className="small danger" onClick={() => void confirmDialog({ message: t("users.deleteConfirm", { name: u.username }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => del(`/users/${u.id}`)))}>
<Button danger size="small" onClick={() => void confirmDialog({ message: t("users.deleteConfirm", { name: u.username }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => del(`/users/${u.id}`)))}>
{t("common.delete")}
</button>
</Button>
)}
</div>
</td>
@@ -100,21 +101,20 @@ export function Users() {
<h3>{t("users.add")}</h3>
<div className="form">
<label>{t("users.username")}</label>
<input value={form.username} onChange={(e) => setForm({ ...form, username: e.target.value })} autoCapitalize="none" />
<Input value={form.username} onChange={(e) => setForm({ ...form, username: e.target.value })} autoCapitalize="none" />
<div className="hint">{t("users.usernameHint")}</div>
<label>{t("users.displayName")}</label>
<input value={form.display_name} onChange={(e) => setForm({ ...form, display_name: e.target.value })} />
<Input value={form.display_name} onChange={(e) => setForm({ ...form, display_name: e.target.value })} />
<label>{t("users.password")}</label>
<input type="password" value={form.password} onChange={(e) => setForm({ ...form, password: e.target.value })} autoComplete="new-password" />
<Input.Password value={form.password} onChange={(e) => setForm({ ...form, password: e.target.value })} autoComplete="new-password" />
<div className="hint">{t("users.passwordHint")}</div>
<label>{t("users.role")}</label>
<select value={form.role} onChange={(e) => setForm({ ...form, role: e.target.value })}>
<Select value={form.role} onChange={(e) => setForm({ ...form, role: e.target.value })}>
<option value="user">{t("users.roleUser")}</option>
<option value="admin">{t("users.roleAdmin")}</option>
</select>
</Select>
</div>
<button
className="primary"
<Button type="primary"
style={{ marginTop: 12 }}
disabled={!form.username.trim()}
onClick={() =>
@@ -125,7 +125,7 @@ export function Users() {
}
>
+ {t("common.add")}
</button>
</Button>
</div>
</>
);
+48 -59
View File
@@ -1,8 +1,9 @@
import { App, Button, Input, type InputRef } from "antd";
import { UploadPanel } from "./components/UploadPanel";
import { Icon } from "./components/Icon";
// In-app dialogs and toasts instead of the browser's alert/confirm/prompt.
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
import { t } from "./i18n";
import { Modal } from "./ui/Modal";
interface ConfirmOpts {
title?: string;
@@ -39,7 +40,9 @@ interface Toast {
}
let dialogs: Dialog[] = [];
let toasts: Toast[] = [];
/** Shows a notice; set by the DialogHost once it is mounted. */
let show: ((x: Toast) => void) | undefined;
const waiting: Toast[] = [];
let seq = 0;
const listeners = new Set<() => void>();
const emit = () => listeners.forEach((l) => l());
@@ -71,13 +74,9 @@ export function promptDialog(opts: PromptOpts | string): Promise<string | null>
export function toast(message: unknown, kind: Toast["kind"] = "error") {
const text = message instanceof Error ? message.message : typeof message === "string" ? message : String((message as any)?.message ?? message);
const id = ++seq;
toasts = [...toasts, { id, message: text, kind }];
emit();
setTimeout(() => {
toasts = toasts.filter((x) => x.id !== id);
emit();
}, kind === "error" ? 7000 : 3500);
const x = { id: ++seq, message: text, kind };
if (show) show(x);
else waiting.push(x);
}
function close(d: Dialog, value: any) {
@@ -88,86 +87,76 @@ function close(d: Dialog, value: any) {
function DialogView({ d }: { d: Dialog }) {
const [value, setValue] = useState(d.kind === "prompt" ? d.defaultValue ?? "" : "");
const input = useRef<HTMLInputElement>(null);
const input = useRef<InputRef>(null);
const ok = useRef<HTMLButtonElement>(null);
const cancelValue = d.kind === "confirm" ? false : null;
useEffect(() => {
if (d.kind === "prompt") {
input.current?.focus();
input.current?.select();
} else ok.current?.focus();
const h = (e: KeyboardEvent) => e.key === "Escape" && close(d, cancelValue);
window.addEventListener("keydown", h);
return () => window.removeEventListener("keydown", h);
// After the window has opened (it takes the focus itself first).
const timer = setTimeout(() => (d.kind === "prompt" ? input.current?.focus({ cursor: "all" }) : ok.current?.focus()), 60);
return () => clearTimeout(timer);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const submit = () => close(d, d.kind === "confirm" ? true : value);
const field = {
ref: input,
value,
placeholder: d.kind === "prompt" ? d.placeholder : undefined,
onChange: (e: React.ChangeEvent<HTMLInputElement>) => setValue(e.target.value),
};
return (
<div className="modal-backdrop" onClick={() => close(d, cancelValue)}>
<form
className="modal dialog"
role={d.kind === "confirm" ? "alertdialog" : "dialog"}
aria-label={d.title ?? d.message}
onClick={(e) => e.stopPropagation()}
onSubmit={(e) => (e.preventDefault(), submit())}
>
<Modal onClose={() => close(d, cancelValue)} className="dialog">
<form role={d.kind === "confirm" ? "alertdialog" : "dialog"} aria-label={d.title ?? d.message} onSubmit={(e) => (e.preventDefault(), submit())}>
{d.title && <h3>{d.title}</h3>}
<p className="dialog-message">{d.message}</p>
{d.kind === "prompt" && (
<input
ref={input}
type={d.password ? "password" : "text"}
value={value}
placeholder={d.placeholder}
onChange={(e) => setValue(e.target.value)}
autoComplete={d.password ? "new-password" : "off"}
style={{ width: "100%" }}
/>
)}
{d.kind === "prompt" && (d.password ? <Input.Password {...field} autoComplete="new-password" /> : <Input {...field} autoComplete="off" />)}
{d.kind === "choice" ? (
<div className="row dialog-actions dialog-choices">
<button type="button" onClick={() => close(d, null)}>
{t("common.cancel")}
</button>
{d.choices.map((c, i) => (
<button key={c.value} ref={i === d.choices.length - 1 ? ok : undefined} type="button" className={c.danger ? "danger-solid" : i === d.choices.length - 1 ? "primary" : undefined} onClick={() => close(d, c.value)}>
{c.label}
</button>
))}
<Button onClick={() => close(d, null)}>{t("common.cancel")}</Button>
{d.choices.map((c, i) => {
const last = i === d.choices.length - 1;
return (
<Button key={c.value} ref={last ? ok : undefined} type={c.danger || last ? "primary" : "default"} danger={c.danger} onClick={() => close(d, c.value)}>
{c.label}
</Button>
);
})}
</div>
) : (
<div className="row dialog-actions">
<button type="button" onClick={() => close(d, cancelValue)}>
{t("common.cancel")}
</button>
<button ref={ok} type="submit" className={d.kind === "confirm" && d.danger ? "danger-solid" : "primary"}>
<Button onClick={() => close(d, cancelValue)}>{t("common.cancel")}</Button>
<Button ref={ok} htmlType="submit" type="primary" danger={d.kind === "confirm" && d.danger}>
{d.confirmLabel ?? t("common.ok")}
</button>
</Button>
</div>
)}
</form>
</div>
</Modal>
);
}
/** Renders open dialogs and toasts; mounted once in App. */
export function DialogHost() {
const state = useSyncExternalStore(subscribe, () => dialogs);
const ts = useSyncExternalStore(subscribe, () => toasts);
const { message } = App.useApp();
useEffect(() => {
show = (x) =>
void message.open({
key: x.id,
type: x.kind,
// A click dismisses the notice.
content: <span onClick={() => message.destroy(x.id)}>{x.message}</span>,
duration: x.kind === "error" ? 7 : 3.5,
});
// Notices raised before the host was there.
waiting.splice(0).forEach(show);
return () => void (show = undefined);
}, [message]);
return (
<>
{state.map((d) => (
<DialogView key={d.id} d={d} />
))}
<UploadPanel />
<div className="toasts" role="status" aria-live="polite">
{ts.map((x) => (
<div key={x.id} className={`toast ${x.kind}`} onClick={() => ((toasts = toasts.filter((y) => y.id !== x.id)), emit())}>
{x.kind === "error" ? <Icon name="warning" /> : x.kind === "success" ? <Icon name="check" /> : null}
{x.message}
</div>
))}
</div>
</>
);
}
+10 -3
View File
@@ -69,9 +69,11 @@ export const de: Messages = {
"settings.pricesFetched": "Preise für {n} Modelle aktualisiert – zum Übernehmen speichern.",
"stats.perMillion": "pro 1 Mio. Tok.",
"stats.perMillionHint": "Effektive Kosten pro Million Tokens (Input inkl. Cache + Output)",
"queue.pending": "{n} Nachricht(en) in der Warteschlange – werden beim nächsten Schritt übergeben",
"queue.pending": "{n} Nachricht(en) in der Warteschlange – werden beim nächsten Schritt übergeben (Enter im leeren Feld erzwingt sofort)",
"queue.stopped": "{n} Nachricht(en) in der Warteschlange",
"queue.sendNow": "Jetzt senden",
"queue.force": "Jetzt erzwingen",
"queue.forceHint": "Unterbricht den laufenden Schritt, das Modell liest die Nachricht sofort (Enter im leeren Feld oder Strg+Enter)",
"queue.remove": "Aus der Warteschlange entfernen",
"queue.backgroundResult": "Ergebnis einer Hintergrundaufgabe",
"permissionMode.auto": "Automatisch (fragt einmal, Sicheres läuft)",
@@ -819,8 +821,8 @@ export const de: Messages = {
"chat.delete": "Session löschen",
"chat.deleteConfirm": "Diese Session inklusive Subagenten löschen? Die Statistik bleibt erhalten.",
"composer.placeholder": "Nachricht… (/ für Befehle, @ für Dateien, Dateien anhängen oder einfügen)",
"composer.placeholderBusy": "Nachricht wird eingereiht und beim nächsten Schritt gesendet…",
"composer.placeholder": "Nachricht… (/ für Befehle, @ für Dateien, Shift+Enter oder Strg+J für neue Zeile)",
"composer.placeholderBusy": "Nachricht wird eingereiht und beim nächsten Schritt gesendet… (Strg+Enter sendet sofort)",
"composer.send": "Senden",
"composer.queue": "Einreihen",
"composer.stop": "Stopp",
@@ -1243,6 +1245,11 @@ export const de: Messages = {
"factory.power.stopped": "Factory gestoppt",
"factory.power.stopHint": "Klicken zum Stoppen: keine neuen Agenten, laufende werden fertig",
"factory.power.startHint": "Klicken, um die Factory zu starten",
"factory.preparing.env": "Testumgebung wird vorbereitet",
"factory.preparing.start": "Lauf wird vorbereitet",
"factory.preparing.hint": "Der Agent-Chat startet, sobald der Checkout fertig ist und – bei der Abnahme – die App in ihrem Wegwerf-Container installiert ist und läuft",
"factory.mergeHint": "Pull Request mergen – die Abnahme war erfolgreich",
"factory.closeHint": "Issue schließen – der Pull Request ist gemerged",
"factory.col.review": "Prüfung",
"factory.col.question": "Rückfragen",
"factory.col.approved": "Freigegeben",
+10 -3
View File
@@ -68,9 +68,11 @@ export const en = {
"settings.pricesFetched": "Prices updated for {n} models – save to keep them.",
"stats.perMillion": "per 1M tok",
"stats.perMillionHint": "Effective cost per million tokens (input incl. cache + output)",
"queue.pending": "{n} message(s) waiting – delivered at the agent's next step",
"queue.pending": "{n} message(s) waiting – delivered at the agent's next step (Enter on an empty field forces it now)",
"queue.stopped": "{n} message(s) waiting",
"queue.sendNow": "Send now",
"queue.force": "Force now",
"queue.forceHint": "Interrupts the running step so the model reads the message at once (Enter on an empty field or Ctrl+Enter)",
"queue.remove": "Remove from queue",
"queue.backgroundResult": "Result of a background task",
"permissionMode.auto": "Automatic (asks once, safe steps run)",
@@ -818,8 +820,8 @@ export const en = {
"chat.delete": "Delete session",
"chat.deleteConfirm": "Delete this session including its subagents? Statistics are kept.",
"composer.placeholder": "Message… (/ for commands, @ for files, attach or paste files)",
"composer.placeholderBusy": "Message is queued and sent at the next step…",
"composer.placeholder": "Message… (/ for commands, @ for files, Shift+Enter or Ctrl+J for a new line)",
"composer.placeholderBusy": "Message is queued and sent at the next step… (Ctrl+Enter sends it now)",
"composer.send": "Send",
"composer.queue": "Queue",
"composer.stop": "Stop",
@@ -1242,6 +1244,11 @@ export const en = {
"factory.power.stopped": "Factory stopped",
"factory.power.stopHint": "Click to stop: no new agents start, running ones finish",
"factory.power.startHint": "Click to start the factory",
"factory.preparing.env": "Preparing the test environment",
"factory.preparing.start": "Preparing the run",
"factory.preparing.hint": "The agent chat starts when the checkout is done and – for acceptance – the app is installed and running in its throw-away container",
"factory.mergeHint": "Merge the pull request – the acceptance has passed",
"factory.closeHint": "Close the issue – the pull request is merged",
"factory.col.review": "Review",
"factory.col.question": "Questions",
"factory.col.approved": "Approved",
+4 -1
View File
@@ -6,6 +6,7 @@ import "./styles.css";
import { App } from "./App";
import { applyTheme } from "./theme";
import { captureShare } from "./share";
import { AntdProvider } from "./ui/AntdProvider";
applyTheme();
captureShare();
@@ -50,6 +51,8 @@ function undoKeyboardShift() {
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
<AntdProvider>
<App />
</AntdProvider>
</StrictMode>,
);
+235 -148
View File
@@ -31,61 +31,62 @@ pre,
font-size: 12.5px;
}
button,
input,
select,
textarea {
/* Plain elements (custom-shaped buttons, the message field); Ant Design components bring their own style. */
button:where(:not([class*="ant-"])),
input:where(:not([class*="ant-"])),
select:where(:not([class*="ant-"])),
textarea:where(:not([class*="ant-"])) {
font: inherit;
color: inherit;
}
button {
button:where(:not([class*="ant-"])) {
cursor: pointer;
border: 1px solid var(--bg3);
background: var(--bg2);
border-radius: 6px;
padding: 5px 12px;
}
button:hover:not(:disabled) {
button:where(:not([class*="ant-"])):hover:not(:disabled) {
border-color: var(--fg3);
}
button:disabled {
button:where(:not([class*="ant-"])):disabled {
opacity: 0.5;
cursor: default;
}
button.primary {
button:where(:not([class*="ant-"])).primary {
background: var(--accent);
border-color: var(--accent);
color: var(--on-accent);
font-weight: 600;
}
button.danger {
button:where(:not([class*="ant-"])).danger {
color: var(--red);
}
button.ghost {
button:where(:not([class*="ant-"])).ghost {
background: transparent;
border-color: transparent;
}
button.ghost:hover:not(:disabled) {
button:where(:not([class*="ant-"])).ghost:hover:not(:disabled) {
background: var(--bg2);
}
button.small {
button:where(:not([class*="ant-"])).small {
padding: 2px 8px;
font-size: 12px;
}
input,
select,
textarea {
input:where(:not([class*="ant-"])),
select:where(:not([class*="ant-"])),
textarea:where(:not([class*="ant-"])) {
background: var(--bg1);
border: 1px solid var(--bg3);
border-radius: 6px;
padding: 5px 8px;
outline: none;
}
input:focus,
select:focus,
textarea:focus {
input:where(:not([class*="ant-"])):focus,
select:where(:not([class*="ant-"])):focus,
textarea:where(:not([class*="ant-"])):focus {
border-color: var(--accent);
}
@@ -993,10 +994,9 @@ button.session-group:hover {
margin-top: 6px;
flex-wrap: wrap;
}
.composer-bar select {
max-width: 220px;
font-size: 12.5px;
padding: 3px 6px;
.composer-bar .ant-select {
max-width: 240px;
min-width: 0;
}
.composer-options {
display: flex;
@@ -1022,24 +1022,6 @@ button.session-group:hover {
overflow: hidden;
text-overflow: ellipsis;
}
.mode-tabs {
display: inline-flex;
border: 1px solid var(--bg3);
border-radius: 6px;
overflow: hidden;
}
.mode-tabs button {
border: none;
border-radius: 0;
background: transparent;
padding: 3px 10px;
font-size: 12.5px;
}
.mode-tabs button.active {
background: var(--accent);
color: var(--on-accent);
font-weight: 600;
}
.attachments {
display: flex;
gap: 6px;
@@ -1128,17 +1110,6 @@ button.session-group:hover {
margin-bottom: 16px;
flex-wrap: wrap;
}
.tabs button {
border: none;
border-bottom: 2px solid transparent;
border-radius: 0;
background: transparent;
padding: 8px 12px;
}
.tabs button.active {
border-bottom-color: var(--accent);
color: var(--fg0);
}
.form {
display: grid;
@@ -1455,8 +1426,8 @@ table.grid input[type="number"] {
.menu-pop-body .mobile-only {
display: block;
}
.topbar button.small {
padding: 2px 5px;
.topbar .ant-btn-sm {
padding-inline: 5px;
}
/* One scrollable row of options, actions stay visible. */
.composer-bar {
@@ -1470,7 +1441,8 @@ table.grid input[type="number"] {
.composer-options::-webkit-scrollbar {
display: none;
}
.composer-options select {
.composer-options .ant-select {
flex: none;
max-width: 150px;
}
/* Avoid iOS zoom on focus. */
@@ -2115,7 +2087,7 @@ button.entry {
align-items: center;
flex-wrap: wrap;
}
.git-branch select {
.git-branch .ant-select {
max-width: 160px;
}
.git-output {
@@ -2400,9 +2372,6 @@ a.button.primary {
font-weight: 600;
}
.mode-tabs button.active.deep {
background: var(--accent2);
}
.rewind-files {
max-height: 200px;
@@ -2432,34 +2401,6 @@ button.danger-solid {
color: var(--bg0);
font-weight: 600;
}
.toasts {
position: fixed;
right: 16px;
bottom: 16px;
display: grid;
gap: 8px;
z-index: 50;
max-width: min(420px, calc(100vw - 32px));
padding-bottom: env(safe-area-inset-bottom);
}
.toast {
background: var(--bg1);
border: 1px solid var(--bg3);
border-left: 4px solid var(--blue);
border-radius: var(--radius);
padding: 10px 14px;
box-shadow: var(--shadow);
font-size: 13px;
cursor: pointer;
animation: toast-in 0.18s ease-out;
word-break: break-word;
}
.toast.error {
border-left-color: var(--red);
}
.toast.success {
border-left-color: var(--green);
}
@keyframes toast-in {
from {
transform: translateY(8px);
@@ -2479,18 +2420,6 @@ button.danger-solid {
margin: 0;
}
.segmented {
display: inline-flex;
gap: 2px;
background: var(--bg1);
border-radius: 8px;
padding: 2px;
width: fit-content;
}
.segmented button.active {
background: var(--accent);
color: var(--on-accent);
}
.sidebar-user .theme-toggle {
margin-left: auto;
font-size: 15px;
@@ -2859,17 +2788,6 @@ button.danger-solid {
margin-top: 12px;
color: var(--fg2);
}
.chip-btn {
border: 1px solid var(--bg3);
border-radius: 8px;
background: var(--bg0);
color: var(--fg1);
padding: 6px 12px;
cursor: pointer;
}
.chip-btn:hover {
border-color: var(--accent);
}
.wiz-foot {
display: flex;
flex-direction: column;
@@ -3322,10 +3240,8 @@ button.danger-solid {
.job-grid > span:nth-child(odd) {
color: var(--fg3);
}
.job-grid select {
.job-grid .ant-select {
max-width: 100%;
font-size: 13px;
padding: 2px 6px;
}
.job-prompt {
margin-top: 10px;
@@ -3765,10 +3681,6 @@ button.danger-solid {
width: 100%;
resize: vertical;
}
.chip-btn.active {
border-color: var(--accent);
color: var(--accent);
}
.job-tpl-card.active {
outline: 2px solid var(--accent);
outline-offset: -2px;
@@ -3788,19 +3700,6 @@ button.danger-solid {
display: none;
border-bottom: 1px solid var(--bg2);
}
.job-tabs button {
flex: 1;
border: none;
border-radius: 0;
background: transparent;
padding: 8px 6px;
color: var(--muted);
border-bottom: 2px solid transparent;
}
.job-tabs button.active {
color: var(--fg0);
border-bottom-color: var(--accent);
}
.job-editor {
flex: 1;
min-height: 0;
@@ -3832,7 +3731,7 @@ button.danger-solid {
min-width: 150px;
margin: 0;
}
.job-editor-row select,
.job-editor-row .ant-select,
.job-editor-row input {
width: 100%;
}
@@ -3931,14 +3830,6 @@ button.danger-solid {
gap: 6px;
align-items: center;
}
.cron-modes .chip-btn,
.cron-days .chip-btn {
padding: 4px 10px;
font-size: 13px;
}
.cron-days .chip-btn {
min-width: 44px;
}
.cron-fields {
display: flex;
flex-wrap: wrap;
@@ -4196,7 +4087,7 @@ span.chat-tab > button {
padding-top: max(4px, env(safe-area-inset-top));
gap: 4px;
}
.topbar button.ghost {
.topbar .ant-btn {
padding: 4px 6px;
}
.chat {
@@ -4224,9 +4115,8 @@ span.chat-tab > button {
margin-top: 4px;
gap: 4px;
}
.composer-bar select {
max-width: 150px;
padding: 2px 4px;
.composer-bar .ant-select {
max-width: 124px;
}
.composer-actions button {
padding: 4px 10px;
@@ -4403,10 +4293,6 @@ span.chat-tab > button {
flex-wrap: wrap;
flex: 1;
}
.media-filters .chip-btn {
padding: 3px 10px;
font-size: 13px;
}
.media-filters small {
color: var(--muted);
margin-left: 2px;
@@ -5085,12 +4971,26 @@ td.fold-indent {
border-radius: var(--radius);
padding: 8px;
min-height: 120px;
/* Each column scrolls on its own; the board as a whole stays about one screen high. */
max-height: max(360px, calc(100dvh - 140px));
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
display: flex;
flex-direction: column;
gap: 6px;
}
.factory-col > * {
flex-shrink: 0;
}
.factory-col h4 {
margin: 0 0 2px;
/* The column title stays visible while its cards scroll. */
position: sticky;
top: -8px;
z-index: 1;
background: var(--bg1);
margin: -8px 0 -4px;
padding: 8px 0 6px;
font-size: 13px;
display: flex;
justify-content: space-between;
@@ -5263,6 +5163,10 @@ td.fold-indent {
background: var(--bg1);
border-bottom: 1px solid var(--bg2);
}
/* The sidebar is not reachable from the overlay: its menu button would only be confusing. */
.chat-overlay .menu-btn {
display: none !important;
}
.chat-overlay-body {
flex: 1;
min-height: 0;
@@ -5278,6 +5182,38 @@ td.fold-indent {
border: 0;
}
}
.factory-card-actions {
display: flex;
gap: 6px;
margin-top: 4px;
}
.factory-card-action {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 3px 9px;
font-size: 12.5px;
border-radius: 6px;
border: 1px solid var(--bg3);
background: var(--bg1);
color: var(--fg0);
cursor: pointer;
}
.factory-card-action:hover {
background: var(--bg2);
}
.factory-card-action.primary {
background: var(--accent);
border-color: var(--accent);
color: var(--on-accent, var(--bg0));
}
.factory-card-action.primary:hover {
filter: brightness(1.08);
}
.factory-card-action.disabled {
opacity: 0.5;
cursor: default;
}
.factory-card-head {
display: flex;
align-items: center;
@@ -5319,6 +5255,13 @@ td.fold-indent {
margin-right: 5px;
animation: factory-pulse 1.4s ease-in-out infinite;
}
/* Preparing (checkout, test environment): same lamp, other colour than an active chat. */
.factory-pulse.prep {
background: var(--prep, var(--blue, var(--accent2)));
}
.factory-card.preparing {
border-left: 3px solid var(--prep, var(--blue, var(--accent2)));
}
@keyframes factory-pulse {
50% {
opacity: 0.25;
@@ -5415,7 +5358,7 @@ td.fold-indent {
position: fixed;
left: 16px;
bottom: 16px;
z-index: 55;
z-index: 160;
display: grid;
gap: 8px;
width: min(380px, calc(100vw - 32px));
@@ -5486,3 +5429,147 @@ td.fold-indent {
.upload-file.error .upload-bar i {
background: var(--red, #e5484d);
}
/* --- Ant Design ------------------------------------------------------------- */
/* The dialog window is drawn by Ant Design; `.modal` only lays out its content. */
.ant-modal .modal {
background: none;
border: 0;
border-radius: 0;
box-shadow: none;
padding: 0;
width: auto;
max-height: calc(100dvh - 96px);
overflow-y: auto;
}
.ant-modal .modal.wide {
max-height: calc(100dvh - 64px);
}
.ant-modal .modal > h3:first-child,
.ant-modal .modal > form > h3:first-child {
margin-top: 0;
}
/* Buttons with an icon and a label keep the app's spacing; long labels may wrap. */
.ant-btn > svg + span,
.ant-btn > span + svg {
margin-inline-start: 0;
}
.dialog-actions .ant-btn,
.dialog-choices .ant-btn {
height: auto;
min-height: 32px;
white-space: normal;
}
/* Fields fill their form column like before; in a row they share the space. */
.form .ant-input,
.field .ant-input,
.modal label > .ant-input,
.modal label > .ant-input-password {
width: 100%;
}
.row > .ant-input,
.row > .ant-input-password {
width: auto;
}
.ant-checkbox-wrapper {
align-items: flex-start;
}
/* Touch screens: comfortable targets. */
@media (pointer: coarse) {
.ant-btn-sm {
min-height: 32px;
}
.ant-input,
.ant-select {
font-size: 16px;
}
}
.settings-tabs .tab-label {
display: inline-flex;
align-items: center;
gap: 6px;
}
.seg-wrap {
max-width: 100%;
}
.seg-wrap .ant-segmented-group {
flex-wrap: wrap;
}
.ant-segmented {
width: fit-content;
}
.ant-segmented.ant-segmented-block {
width: 100%;
}
.ant-segmented-item-selected {
font-weight: 600;
}
/* A toggled or current plain button (navigation, filters). */
.ant-btn.active {
background: var(--bg3);
color: var(--fg0);
}
.cron-days .ant-btn {
min-width: 44px;
}
.sidebar-foot .ant-btn {
flex: 1;
justify-content: flex-start;
}
/* Icons next to a label: the component already spaces them. */
.ant-btn .nav-icon,
.settings-tabs .nav-icon {
margin-right: 0;
}
.sidebar-foot .ant-btn {
min-width: 0;
padding-inline: 10px;
overflow: hidden;
}
/* All settings sections stay visible: the tab bar wraps instead of hiding tabs in a menu. */
.settings-tabs .ant-tabs-nav-wrap {
overflow: visible;
}
.settings-tabs .ant-tabs-nav-list {
flex-wrap: wrap;
transform: none !important;
}
.settings-tabs .ant-tabs-nav-operations,
.settings-tabs .ant-tabs-ink-bar {
display: none;
}
.settings-tabs .ant-tabs-tab {
border-bottom: 2px solid transparent;
padding-block: 8px;
margin-inline: 0 18px !important;
}
.settings-tabs .ant-tabs-tab-active {
border-bottom-color: var(--accent);
}
@media (max-width: 700px) {
.panel .row,
.card .row {
flex-wrap: wrap;
}
}
/* The app's own visibility classes also apply to Ant Design buttons. */
.ant-btn.mobile-only {
display: none;
}
.ant-btn.git-name {
justify-content: flex-start;
}
@media (max-width: 800px) {
.ant-btn.mobile-only {
display: inline-flex;
}
}
@media (max-width: 700px) {
.panel h3,
.card h3 {
flex-wrap: wrap;
}
.topbar.stats-bar {
flex-wrap: wrap;
}
}
+2
View File
@@ -25,6 +25,8 @@
--power-on: #8f9a5c;
--power-warn: #d9b45a;
--power-off: #c15c46;
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
--prep: var(--blue);
--aqua: #8aa89a;
--blue: #7c9aa1;
--purple: #b47e99;
+2
View File
@@ -25,6 +25,8 @@
--power-on: #5c6631;
--power-warn: #9a7413;
--power-off: #96392a;
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
--prep: var(--blue);
--aqua: #3d6b72;
--blue: #3d6b72;
--purple: #7c4a66;
+2
View File
@@ -25,6 +25,8 @@
--power-on: #a6e3a1;
--power-warn: #f9e2af;
--power-off: #f38ba8;
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
--prep: var(--power-warn);
--aqua: #94e2d5;
--blue: #89b4fa;
--purple: #f5c2e7;
+2
View File
@@ -25,6 +25,8 @@
--power-on: #40a02b;
--power-warn: #df8e1d;
--power-off: #d20f39;
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
--prep: var(--power-warn);
--aqua: #179299;
--blue: #1e66f5;
--purple: #ea76cb;
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff. Show more