Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90b9ab6670 | ||
|
|
e64328aa98 | ||
|
|
679151defc | ||
|
|
abdf7d3925 | ||
|
|
9addac8c91 | ||
|
|
cee45bb962 | ||
|
|
5ccb524366 | ||
|
|
c05e2cb6ef | ||
|
|
f8b85beb70 | ||
|
|
3623896464 | ||
|
|
d0e7cea117 | ||
|
|
23fbc6f302 | ||
|
|
6804139be7 | ||
|
|
87eafb3108 | ||
|
|
537aac820d | ||
|
|
836377ac38 | ||
|
|
391db43949 | ||
|
|
0e54714436 | ||
|
|
b9df00422a |
No files matched your search
+1
-1
@@ -38,4 +38,4 @@ CODECRAFT_LOG_FORMAT=
|
|||||||
# Optional limits per environment and the image used when .factory/setup.json names none:
|
# Optional limits per environment and the image used when .factory/setup.json names none:
|
||||||
#RUNNER_MEMORY=2g
|
#RUNNER_MEMORY=2g
|
||||||
#RUNNER_CPUS=2
|
#RUNNER_CPUS=2
|
||||||
#RUNNER_DEFAULT_IMAGE=node:22-bookworm
|
#RUNNER_DEFAULT_IMAGE=git.familie-zink.org/zink/codecraft-testbase:latest
|
||||||
@@ -3,6 +3,67 @@
|
|||||||
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
|
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
|
||||||
until 1.0, minor versions may contain breaking changes.
|
until 1.0, minor versions may contain breaking changes.
|
||||||
|
|
||||||
|
## [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
|
## [v202611-00072] – 2026-11-20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ members = ["core", "server", "cli"]
|
|||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 3
|
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.
|
# The command line client is small and self-contained.
|
||||||
[profile.release.package.codecraft-cli]
|
[profile.release.package.codecraft-cli]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Version v202611-00072" src="https://img.shields.io/badge/version-v202611--00072-d69e2e?style=flat-square">
|
<img alt="Version v202611-00081" src="https://img.shields.io/badge/version-v202611--00081-d69e2e?style=flat-square">
|
||||||
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-689d6a?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="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">
|
<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
|
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*).
|
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
|
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.
|
`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.
|
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
|
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
|
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
|
host. Without the runner, or without a `setup.json`, nothing changes. Note that the runner holds
|
||||||
|
|||||||
+227
-18
@@ -15,7 +15,7 @@ use ratatui::Frame;
|
|||||||
use ratatui::layout::{Constraint, Layout, Rect};
|
use ratatui::layout::{Constraint, Layout, Rect};
|
||||||
use ratatui::style::{Modifier, Style};
|
use ratatui::style::{Modifier, Style};
|
||||||
use ratatui::text::{Line, Span};
|
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 serde_json::Value;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -115,6 +115,10 @@ pub struct App {
|
|||||||
busy_since: Instant,
|
busy_since: Instant,
|
||||||
cancel: Option<CancellationToken>,
|
cancel: Option<CancellationToken>,
|
||||||
queue: VecDeque<String>,
|
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,
|
dialog: Dialog,
|
||||||
session: LocalSession,
|
session: LocalSession,
|
||||||
effort: Option<String>,
|
effort: Option<String>,
|
||||||
@@ -211,6 +215,28 @@ fn wrap(text: &str, width: usize) -> Vec<String> {
|
|||||||
out
|
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**.
|
/// Inline markdown: `code` and **bold**.
|
||||||
fn inline(text: &str, th: &Theme, base: Style) -> Vec<Span<'static>> {
|
fn inline(text: &str, th: &Theme, base: Style) -> Vec<Span<'static>> {
|
||||||
let mut spans = Vec::new();
|
let mut spans = Vec::new();
|
||||||
@@ -340,6 +366,8 @@ impl App {
|
|||||||
busy_since: Instant::now(),
|
busy_since: Instant::now(),
|
||||||
cancel: None,
|
cancel: None,
|
||||||
queue: VecDeque::new(),
|
queue: VecDeque::new(),
|
||||||
|
remote_queue: Vec::new(),
|
||||||
|
forcing: false,
|
||||||
dialog: Dialog::None,
|
dialog: Dialog::None,
|
||||||
todos: session.todos.clone(),
|
todos: session.todos.clone(),
|
||||||
context: session.context_tokens,
|
context: session.context_tokens,
|
||||||
@@ -408,7 +436,14 @@ impl App {
|
|||||||
self.busy_since = Instant::now();
|
self.busy_since = Instant::now();
|
||||||
} else {
|
} else {
|
||||||
self.cancel = None;
|
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);
|
self.send(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -488,6 +523,10 @@ impl App {
|
|||||||
let text = self.editor.take();
|
let text = self.editor.take();
|
||||||
let trimmed = text.trim().to_string();
|
let trimmed = text.trim().to_string();
|
||||||
if trimmed.is_empty() && self.images.is_empty() {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if trimmed.starts_with('/') && self.slash(&trimmed) {
|
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.
|
/// Custom commands (server, project, built-in): "/name args" -> prompt.
|
||||||
fn expand_command(&mut self, text: &str) -> Option<String> {
|
fn expand_command(&mut self, text: &str) -> Option<String> {
|
||||||
let rest = text.strip_prefix('/')?;
|
let rest = text.strip_prefix('/')?;
|
||||||
@@ -849,6 +909,7 @@ impl App {
|
|||||||
|
|
||||||
fn leave_remote(&mut self) {
|
fn leave_remote(&mut self) {
|
||||||
if self.remote.take().is_some() {
|
if self.remote.take().is_some() {
|
||||||
|
self.remote_queue.clear();
|
||||||
self.items.clear();
|
self.items.clear();
|
||||||
self.todos = Value::Null;
|
self.todos = Value::Null;
|
||||||
self.busy = false;
|
self.busy = false;
|
||||||
@@ -860,6 +921,10 @@ impl App {
|
|||||||
fn send_remote(&mut self, text: String) {
|
fn send_remote(&mut self, text: String) {
|
||||||
let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) else { return };
|
let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) else { return };
|
||||||
let id = r.id.clone();
|
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();
|
let (tx, rx) = oneshot::channel();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let _ = tx.send(remote::prompt(&server, &id, &text).await.map(|_| String::new()));
|
let _ = tx.send(remote::prompt(&server, &id, &text).await.map(|_| String::new()));
|
||||||
@@ -932,6 +997,7 @@ impl App {
|
|||||||
self.busy = false;
|
self.busy = false;
|
||||||
self.dialog = Dialog::None;
|
self.dialog = Dialog::None;
|
||||||
self.remote = Some(r);
|
self.remote = Some(r);
|
||||||
|
self.remote_queue.clear();
|
||||||
self.pending_snapshot = None;
|
self.pending_snapshot = None;
|
||||||
}
|
}
|
||||||
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
|
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() });
|
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.items = head.map(Item::Info).into_iter().chain(items).collect();
|
||||||
self.busy = snap.busy;
|
self.busy = snap.busy;
|
||||||
|
self.remote_queue = snap.queue.clone();
|
||||||
if snap.busy && !was_busy {
|
if snap.busy && !was_busy {
|
||||||
self.busy_since = Instant::now();
|
self.busy_since = Instant::now();
|
||||||
}
|
}
|
||||||
@@ -1700,10 +1767,37 @@ impl App {
|
|||||||
let th = theme::get();
|
let th = theme::get();
|
||||||
let area = f.area();
|
let area = f.area();
|
||||||
f.render_widget(Block::default().style(Style::default().bg(th.bg0).fg(th.fg1)), 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_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 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.
|
// Header.
|
||||||
let cwd = self.session.cwd.replace(&crate::conf::home().display().to_string(), "~");
|
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!(" {} ", SPINNER[self.tick % SPINNER.len()]), Style::default().fg(th.accent2)),
|
||||||
Span::styled(format!("{}…", t("working")), 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(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 {
|
} else {
|
||||||
Line::from(Span::styled(format!(" {}", self.status), Style::default().fg(th.muted)))
|
Line::from(Span::styled(format!(" {}", self.status), Style::default().fg(th.muted)))
|
||||||
};
|
};
|
||||||
f.render_widget(Paragraph::new(activity), act);
|
f.render_widget(Paragraph::new(activity), act);
|
||||||
|
if queue_h > 0 {
|
||||||
|
f.render_widget(Paragraph::new(queue_lines), queue_area);
|
||||||
|
}
|
||||||
|
|
||||||
// Input.
|
// Input.
|
||||||
let mode_col = match self.session.mode.as_str() {
|
let mode_col = match self.session.mode.as_str() {
|
||||||
@@ -1793,16 +1890,17 @@ impl App {
|
|||||||
let inner = block.inner(input);
|
let inner = block.inner(input);
|
||||||
f.render_widget(block, input);
|
f.render_widget(block, input);
|
||||||
let visible = inner.height as usize;
|
let visible = inner.height as usize;
|
||||||
let first = self.editor.row.saturating_sub(visible.saturating_sub(1));
|
let (crow, ccol) = self.editor.cursor_in(&layout);
|
||||||
let text: Vec<Line> = if self.editor.is_empty() {
|
let first = crow.saturating_sub(visible.saturating_sub(1));
|
||||||
vec![Line::from(Span::styled(if self.busy { t("busy_placeholder") } else { t("placeholder") }, Style::default().fg(th.muted)))]
|
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 {
|
} else {
|
||||||
self.editor.lines[first..].iter().take(visible).map(|l| Line::from(Span::styled(l.clone(), Style::default().fg(th.fg0)))).collect()
|
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);
|
||||||
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);
|
|
||||||
if matches!(self.dialog, Dialog::None) {
|
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.
|
// Status line.
|
||||||
@@ -1882,14 +1980,39 @@ impl App {
|
|||||||
}
|
}
|
||||||
Dialog::Question { questions, idx, sel, custom, .. } => {
|
Dialog::Question { questions, idx, sel, custom, .. } => {
|
||||||
let q = &questions[*idx];
|
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() {
|
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) };
|
let on = i == *sel && custom.is_empty();
|
||||||
lines.push(Line::from(vec![Span::styled(format!(" {}. {} ", i + 1, o.label), st), Span::styled(format!(" {}", o.description), Style::default().fg(th.muted))]));
|
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::default());
|
||||||
lines.push(Line::from(Span::styled(format!("> {custom}_"), Style::default().fg(th.fg0))));
|
// The own answer: wrapped as typed; only its last rows are shown when it gets long.
|
||||||
lines.push(Line::from(Span::styled(t("question_keys"), Style::default().fg(th.muted))));
|
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 title = format!("{} {}/{}", t("question"), idx + 1, questions.len());
|
||||||
let inner = boxed(f, &title, 90, lines.len() as u16 + 2, th.blue);
|
let inner = boxed(f, &title, 90, lines.len() as u16 + 2, th.blue);
|
||||||
f.render_widget(Paragraph::new(lines), inner);
|
f.render_widget(Paragraph::new(lines), inner);
|
||||||
@@ -2044,3 +2167,89 @@ impl App {
|
|||||||
self.status = s;
|
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
@@ -1,6 +1,6 @@
|
|||||||
//! Multi-line input field with history.
|
//! Multi-line input field with history.
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthChar;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Editor {
|
pub struct Editor {
|
||||||
@@ -211,9 +211,103 @@ impl Editor {
|
|||||||
self.col = start + with.chars().count();
|
self.col = start + with.chars().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cursor position in display columns (for the terminal cursor).
|
/// The text as it is shown at `width` columns: every logical line is broken into rows, preferably after a
|
||||||
pub fn cursor_x(&self) -> usize {
|
/// space, otherwise inside a long word. Each row is (line index, first char, end char).
|
||||||
let line = &self.lines[self.row];
|
pub fn layout(&self, width: usize) -> Vec<(usize, usize, usize)> {
|
||||||
UnicodeWidthStr::width(&line[..byte_idx(line, self.col)])
|
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
@@ -14,7 +14,7 @@ pub fn system_lang() -> String {
|
|||||||
|
|
||||||
/// (key, English, German)
|
/// (key, English, German)
|
||||||
const TEXTS: &[(&str, &str, &str)] = &[
|
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…"),
|
("busy_placeholder", "Message is queued and sent after this turn…", "Nachricht wird nach diesem Schritt gesendet…"),
|
||||||
("permission", "Permission required", "Freigabe erforderlich"),
|
("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"),
|
("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"),
|
("choose_theme", "Choose a theme", "Theme wählen"),
|
||||||
("filter", "type to filter", "tippen zum Filtern"),
|
("filter", "type to filter", "tippen zum Filtern"),
|
||||||
("queued", "queued", "in der Warteschlange"),
|
("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"),
|
("welcome", "Welcome to CodeCraft", "Willkommen bei CodeCraft"),
|
||||||
("setup_title", "Set up CodeCraft", "CodeCraft einrichten"),
|
("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."),
|
("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
@@ -32,6 +32,8 @@ pub struct Snapshot {
|
|||||||
pub todos: Value,
|
pub todos: Value,
|
||||||
/// Open permission and question requests of this chat (and its subagents).
|
/// Open permission and question requests of this chat (and its subagents).
|
||||||
pub pending: Vec<Value>,
|
pub pending: Vec<Value>,
|
||||||
|
/// Messages waiting for the agent (text of each).
|
||||||
|
pub queue: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn short(s: &str, n: usize) -> String {
|
fn short(s: &str, n: usize) -> String {
|
||||||
@@ -80,7 +82,16 @@ pub async fn snapshot(server: &Server, id: &str) -> Result<Snapshot> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|e| e["session_id"].as_str() == Some(id) || e["root_session_id"].as_str() == Some(id))
|
.filter(|e| e["session_id"].as_str() == Some(id) || e["root_session_id"].as_str() == Some(id))
|
||||||
.collect();
|
.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> {
|
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(|_| ())
|
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<()> {
|
pub async fn compact(server: &Server, id: &str) -> Result<()> {
|
||||||
server.post(&format!("/sessions/{id}/compact"), json!({})).await.map(|_| ())
|
server.post(&format!("/sessions/{id}/compact"), json!({})).await.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ services:
|
|||||||
# Pin a version (e.g. :v202611-00001) or follow :latest.
|
# Pin a version (e.g. :v202611-00001) or follow :latest.
|
||||||
image: git.familie-zink.org/zink/codecraft:${CODECRAFT_VERSION:-latest}
|
image: git.familie-zink.org/zink/codecraft:${CODECRAFT_VERSION:-latest}
|
||||||
container_name: codecraft
|
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
|
restart: unless-stopped
|
||||||
# Same UID/GID as the owner of your project files.
|
# Same UID/GID as the owner of your project files.
|
||||||
user: "${UID:-1000}:${GID:-1000}"
|
user: "${UID:-1000}:${GID:-1000}"
|
||||||
@@ -65,6 +67,7 @@ services:
|
|||||||
image: git.familie-zink.org/zink/codecraft:${CODECRAFT_VERSION:-latest}
|
image: git.familie-zink.org/zink/codecraft:${CODECRAFT_VERSION:-latest}
|
||||||
command: ["testrunner"]
|
command: ["testrunner"]
|
||||||
container_name: codecraft-testrunner
|
container_name: codecraft-testrunner
|
||||||
|
init: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
user: "${UID:-1000}:${GID:-1000}"
|
user: "${UID:-1000}:${GID:-1000}"
|
||||||
# Group that owns /var/run/docker.sock on the host: stat -c %g /var/run/docker.sock
|
# 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_FACTORY_DIR: /factory
|
||||||
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
|
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
|
||||||
RUNNER_CPUS: ${RUNNER_CPUS:-2}
|
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
|
HOME: /tmp
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|||||||
+4
-1
@@ -14,6 +14,8 @@ services:
|
|||||||
GIT_COMMIT: ${GIT_COMMIT:-}
|
GIT_COMMIT: ${GIT_COMMIT:-}
|
||||||
image: codecraft:latest
|
image: codecraft:latest
|
||||||
container_name: codecraft
|
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
|
restart: unless-stopped
|
||||||
# Same UID/GID as the owner of your project files.
|
# Same UID/GID as the owner of your project files.
|
||||||
user: "${UID:-1000}:${GID:-1000}"
|
user: "${UID:-1000}:${GID:-1000}"
|
||||||
@@ -61,6 +63,7 @@ services:
|
|||||||
image: codecraft:latest
|
image: codecraft:latest
|
||||||
command: ["testrunner"]
|
command: ["testrunner"]
|
||||||
container_name: codecraft-testrunner
|
container_name: codecraft-testrunner
|
||||||
|
init: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
user: "${UID:-1000}:${GID:-1000}"
|
user: "${UID:-1000}:${GID:-1000}"
|
||||||
# Group that owns /var/run/docker.sock on the host: stat -c %g /var/run/docker.sock
|
# 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_FACTORY_DIR: /factory
|
||||||
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
|
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
|
||||||
RUNNER_CPUS: ${RUNNER_CPUS:-2}
|
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
|
HOME: /tmp
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -94,6 +94,10 @@ if (( image )); then
|
|||||||
run docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
|
run docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
|
||||||
--build-arg GIT_COMMIT="$(git rev-parse --short HEAD)" --build-arg CODECRAFT_VERSION="$version" \
|
--build-arg GIT_COMMIT="$(git rev-parse --short HEAD)" --build-arg CODECRAFT_VERSION="$version" \
|
||||||
"${tags[@]}" --push .
|
"${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
|
fi
|
||||||
|
|
||||||
step "Creating the Gitea release $tag"
|
step "Creating the Gitea release $tag"
|
||||||
|
|||||||
+28
-1
@@ -113,6 +113,7 @@ pub fn router(app: AppState) -> Router {
|
|||||||
.route("/sessions/{id}/shares", get(get_shares).put(put_shares))
|
.route("/sessions/{id}/shares", get(get_shares).put(put_shares))
|
||||||
.route("/sessions/{id}/queue", get(get_queue))
|
.route("/sessions/{id}/queue", get(get_queue))
|
||||||
.route("/sessions/{id}/queue/flush", post(flush_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("/sessions/{id}/queue/{item}", delete(delete_queue_item))
|
||||||
.route("/permissions/{id}", post(reply_permission))
|
.route("/permissions/{id}", post(reply_permission))
|
||||||
.route("/permissions/{id}/explain", post(explain_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)?})))
|
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) {
|
pub(crate) async fn do_compact(app: AppState, id: String) {
|
||||||
let cancel = tokio_util::sync::CancellationToken::new();
|
let cancel = tokio_util::sync::CancellationToken::new();
|
||||||
app.with_runtime(&id, |r| r.cancel = Some(cancel.clone()));
|
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()));
|
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:#}"));
|
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() };
|
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.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)?;
|
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.
|
/// 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 {
|
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)?;
|
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() };
|
let method = if b.method.is_empty() { "merge" } else { b.method.as_str() };
|
||||||
if !["merge", "squash", "rebase"].contains(&method) {
|
if !["merge", "squash", "rebase"].contains(&method) {
|
||||||
return Err(ApiError(StatusCode::BAD_REQUEST, "unknown merge method".into()));
|
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()));
|
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:#}")))?;
|
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));
|
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})))
|
Ok(Json(json!({"ok": true})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ pub struct Runtime {
|
|||||||
pub step: Option<Value>,
|
pub step: Option<Value>,
|
||||||
/// Reasoning effort chosen for the current turn (overrides the model's default).
|
/// Reasoning effort chosen for the current turn (overrides the model's default).
|
||||||
pub effort: Option<String>,
|
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 {
|
pub struct App {
|
||||||
|
|||||||
@@ -1240,11 +1240,13 @@ impl TestEnv {
|
|||||||
|
|
||||||
/// Start the app of `work` in a throw-away container when a test runner is configured
|
/// 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.
|
/// (`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;
|
use crate::testrunner as tr;
|
||||||
let Some(client) = tr::Client::from_env() else { return Ok(None) };
|
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) };
|
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();
|
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 started = client.start(&req).await?;
|
||||||
let (local, forward) = match tr::forward_local(req.port, client.host(), started.port).await {
|
let (local, forward) = match tr::forward_local(req.port, client.host(), started.port).await {
|
||||||
Ok(x) => x,
|
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.
|
// 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,
|
Ok(e) => e,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
cleanup_worktree(&app, &user, &cfg, &work).await;
|
cleanup_worktree(&app, &user, &cfg, &work).await;
|
||||||
|
|||||||
@@ -235,6 +235,8 @@ pub async fn version_pass(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<
|
|||||||
if pr["state"].as_str() != Some("merged") {
|
if pr["state"].as_str() != Some("merged") {
|
||||||
continue;
|
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 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 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?;
|
let dir = checkout(app, user, cfg).await?;
|
||||||
|
|||||||
+21
-1
@@ -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| {
|
let leftover = app.with_runtime(&session_id, |r| {
|
||||||
r.cancel = None;
|
r.cancel = None;
|
||||||
r.effort = 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 });
|
app.emit(Event::SessionStatus { session_id: session_id.clone(), busy: false });
|
||||||
if leftover.is_empty() && !cancel.is_cancelled() {
|
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)
|
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) {
|
pub fn abort(app: &App, session_id: &str) {
|
||||||
app.with_runtime(session_id, |r| {
|
app.with_runtime(session_id, |r| {
|
||||||
if let Some(c) = &r.cancel {
|
if let Some(c) = &r.cancel {
|
||||||
|
|||||||
+5
-3
@@ -51,6 +51,7 @@ impl Store {
|
|||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS usage_ts ON usage(ts);
|
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_root ON usage(root_session_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS usage_session ON usage(session_id);
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
username TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
username TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
||||||
@@ -262,6 +263,7 @@ impl Store {
|
|||||||
("images", "blob", "ALTER TABLE images ADD COLUMN blob TEXT"),
|
("images", "blob", "ALTER TABLE images ADD COLUMN blob TEXT"),
|
||||||
("usage", "allowance", "ALTER TABLE usage ADD COLUMN allowance REAL"),
|
("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", "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
|
let exists: bool = conn
|
||||||
.prepare(&format!("SELECT 1 FROM pragma_table_info('{table}') WHERE name = ?1"))?
|
.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>> {
|
pub fn factory_issue(&self, repo: &str, number: i64) -> Result<Option<Value>> {
|
||||||
let conn = self.conn.lock().unwrap();
|
let conn = self.conn.lock().unwrap();
|
||||||
Ok(conn
|
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| {
|
.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)?}))
|
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()?)
|
.optional()?)
|
||||||
}
|
}
|
||||||
@@ -1512,7 +1514,7 @@ impl Store {
|
|||||||
|
|
||||||
/// Update the given columns (whitelisted) of an issue.
|
/// Update the given columns (whitelisted) of an issue.
|
||||||
pub fn factory_issue_set(&self, repo: &str, number: i64, fields: &[(&str, Value)]) -> Result<()> {
|
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();
|
let conn = self.conn.lock().unwrap();
|
||||||
for (k, v) in fields {
|
for (k, v) in fields {
|
||||||
if !COLS.contains(k) {
|
if !COLS.contains(k) {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn call(&self, method: &str, body: Value) -> Result<Value> {
|
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 status = resp.status();
|
||||||
let v: Value = resp.json().await.unwrap_or_else(|_| json!({}));
|
let v: Value = resp.json().await.unwrap_or_else(|_| json!({}));
|
||||||
if v["ok"].as_bool() != Some(true) {
|
if v["ok"].as_bool() != Some(true) {
|
||||||
@@ -174,7 +174,7 @@ impl Bot {
|
|||||||
if let Some(c) = caption {
|
if let Some(c) = caption {
|
||||||
form = form.text("caption", c.chars().take(1000).collect::<String>());
|
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) {
|
if v["ok"].as_bool() != Some(true) {
|
||||||
bail!("telegram sendPhoto: {}", v["description"].as_str().unwrap_or("error"));
|
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 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 path = f["file_path"].as_str().context("telegram file without path")?.to_string();
|
||||||
let url = format!("{}/file/bot{}/{path}", api_base(), self.token);
|
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))
|
Ok((bytes.to_vec(), path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+214
-3
@@ -30,6 +30,32 @@ use tokio::process::Command;
|
|||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
const LABEL: &str = "codecraft.testrunner=1";
|
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) ------------------------------------
|
// --- what a repository asks for (.factory/setup.json) ------------------------------------
|
||||||
|
|
||||||
@@ -41,6 +67,29 @@ pub struct Service {
|
|||||||
pub env: BTreeMap<String, String>,
|
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.
|
/// The request to start an environment.
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct StartReq {
|
pub struct StartReq {
|
||||||
@@ -63,6 +112,11 @@ pub struct StartReq {
|
|||||||
/// How long to wait until the port answers (seconds, default 300).
|
/// How long to wait until the port answers (seconds, default 300).
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub ready_secs: u64,
|
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)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -110,9 +164,19 @@ pub fn parse_setup(text: &str) -> Option<StartReq> {
|
|||||||
env: strs("env"),
|
env: strs("env"),
|
||||||
services,
|
services,
|
||||||
ready_secs: v["ready_seconds"].as_u64().unwrap_or(0),
|
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).
|
/// Port of `http://host:1234/path` (80/443 by scheme when missing).
|
||||||
pub fn port_of(url: &str) -> Option<u16> {
|
pub fn port_of(url: &str) -> Option<u16> {
|
||||||
let (scheme, rest) = url.trim().split_once("://")?;
|
let (scheme, rest) = url.trim().split_once("://")?;
|
||||||
@@ -132,6 +196,61 @@ fn image_ok(s: &str) -> bool {
|
|||||||
ident_ok(s, "._/:@-") && !s.starts_with('-')
|
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 {
|
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'))
|
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) {
|
if !env_ok(&req.env) {
|
||||||
bail!("invalid environment variable");
|
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 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")?;
|
let work = Path::new(&req.work).canonicalize().context("source directory not found")?;
|
||||||
if !work.starts_with(&root) || !work.is_dir() {
|
if !work.starts_with(&root) || !work.is_dir() {
|
||||||
@@ -230,7 +359,7 @@ pub async fn serve() -> Result<()> {
|
|||||||
ports: (lo, hi),
|
ports: (lo, hi),
|
||||||
memory: std::env::var("RUNNER_MEMORY").unwrap_or_else(|_| "2g".into()),
|
memory: std::env::var("RUNNER_MEMORY").unwrap_or_else(|_| "2g".into()),
|
||||||
cpus: std::env::var("RUNNER_CPUS").unwrap_or_else(|_| "2".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)),
|
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(),
|
me: std::env::var("RUNNER_SELF").or_else(|_| std::env::var("HOSTNAME")).unwrap_or_default(),
|
||||||
envs: Mutex::new(HashMap::new()),
|
envs: Mutex::new(HashMap::new()),
|
||||||
@@ -254,6 +383,7 @@ pub async fn serve() -> Result<()> {
|
|||||||
.route("/v1/envs", post(start_env))
|
.route("/v1/envs", post(start_env))
|
||||||
.route("/v1/envs/{id}", delete(stop_env))
|
.route("/v1/envs/{id}", delete(stop_env))
|
||||||
.route("/v1/envs/{id}/log", get(log_env))
|
.route("/v1/envs/{id}/log", get(log_env))
|
||||||
|
.route("/v1/cache/{id}", delete(clear_cache))
|
||||||
.with_state(runner);
|
.with_state(runner);
|
||||||
let bind = std::env::var("RUNNER_BIND").unwrap_or_else(|_| "0.0.0.0:8788".into());
|
let bind = std::env::var("RUNNER_BIND").unwrap_or_else(|_| "0.0.0.0:8788".into());
|
||||||
let l = TcpListener::bind(&bind).await?;
|
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> {
|
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 net = format!("cc-run-{id}");
|
||||||
let app = format!("cc-run-{id}");
|
let app = format!("cc-run-{id}");
|
||||||
// Register first, so a failure at any step is cleaned up by stop().
|
// 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);
|
r.envs.lock().unwrap().get_mut(id).unwrap().containers.push(cname);
|
||||||
}
|
}
|
||||||
let image = if req.dockerfile.is_empty() {
|
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 {
|
} else {
|
||||||
let tag = format!("cc-run-{id}");
|
let tag = format!("cc-run-{id}");
|
||||||
let df = work.join(&req.dockerfile);
|
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("-e".into());
|
||||||
a.push(format!("{k}={v}"));
|
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("-e".into());
|
||||||
a.push(format!("CC_INSTALL={}", req.install));
|
a.push(format!("CC_INSTALL={}", req.install));
|
||||||
a.push("-e".into());
|
a.push("-e".into());
|
||||||
a.push(format!("CC_START={}", req.start));
|
a.push(format!("CC_START={}", req.start));
|
||||||
a.push(image);
|
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();
|
let refs: Vec<&str> = a.iter().map(String::as_str).collect();
|
||||||
docker(&refs).await.context("docker create")?;
|
docker(&refs).await.context("docker create")?;
|
||||||
// Copy the sources in (without .git); the container never sees the host directory.
|
// 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;
|
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 (listener, port) = bind_forward(r).await?;
|
||||||
let (target, tport) = (ip, req.port);
|
let (target, tport) = (ip, req.port);
|
||||||
let fwd = tokio::spawn(async move {
|
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 })
|
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 {
|
async fn logs(container: &str) -> String {
|
||||||
match Command::new("docker").args(["logs", "--tail", "400", container]).output().await {
|
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)),
|
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})))
|
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)]
|
#[derive(Deserialize)]
|
||||||
struct LogQ {
|
struct LogQ {
|
||||||
tail: Option<usize>,
|
tail: Option<usize>,
|
||||||
@@ -574,6 +759,32 @@ mod tests {
|
|||||||
let _ = std::fs::remove_dir_all(&dir);
|
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]
|
#[test]
|
||||||
fn tokens_compare() {
|
fn tokens_compare() {
|
||||||
assert!(eq_const("abc", "abc"));
|
assert!(eq_const("abc", "abc"));
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { uploadBatch } from "../uploads";
|
|||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useAgents, useFetch, useModels } from "../hooks";
|
import { useAgents, useFetch, useModels } from "../hooks";
|
||||||
import { useT, type Key } from "../i18n";
|
import { useT, type Key } from "../i18n";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import { post } from "../api";
|
||||||
import type { ImageData, Session } from "../types";
|
import type { ImageData, Session } from "../types";
|
||||||
import { ModelSelect } from "./ModelSelect";
|
import { ModelSelect } from "./ModelSelect";
|
||||||
import { EffortSelect } from "./Regenerate";
|
import { EffortSelect } from "./Regenerate";
|
||||||
@@ -55,7 +57,7 @@ export function Composer({
|
|||||||
busy: boolean;
|
busy: boolean;
|
||||||
text: string;
|
text: string;
|
||||||
setText: (s: string) => void;
|
setText: (s: string) => void;
|
||||||
onSend: (text: string, images: ImageData[], effort?: string) => void;
|
onSend: (text: string, images: ImageData[], effort?: string) => void | Promise<void>;
|
||||||
onAbort: () => void;
|
onAbort: () => void;
|
||||||
onUpdate: (patch: Partial<Session>) => void;
|
onUpdate: (patch: Partial<Session>) => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -145,11 +147,20 @@ export function Composer({
|
|||||||
return [...mine, ...cmds].slice(0, 12);
|
return [...mine, ...cmds].slice(0, 12);
|
||||||
}, [text, cmdData, snippets, t, mention, mentionHits]);
|
}, [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;
|
if ((!text.trim() && images.length === 0 && files.length === 0) || uploading > 0) return;
|
||||||
// Files are referenced by path; the agent reads them with its tools.
|
// 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")}` : "";
|
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("");
|
setEffort("");
|
||||||
setImages([]);
|
setImages([]);
|
||||||
setFiles([]);
|
setFiles([]);
|
||||||
@@ -174,11 +185,22 @@ export function Composer({
|
|||||||
return;
|
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.
|
// Enter sends on desktop; on touch devices Enter inserts a newline.
|
||||||
const touch = matchMedia("(pointer: coarse)").matches;
|
const touch = matchMedia("(pointer: coarse)").matches;
|
||||||
if (e.key === "Enter" && !e.shiftKey && !touch && !e.nativeEvent.isComposing) {
|
if (e.key === "Enter" && !e.shiftKey && !touch && !e.nativeEvent.isComposing) {
|
||||||
e.preventDefault();
|
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();
|
if (e.key === "Escape" && busy) onAbort();
|
||||||
};
|
};
|
||||||
@@ -400,7 +422,7 @@ export function Composer({
|
|||||||
<Icon name="stop" /> {t("composer.stop")}
|
<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 className="primary" onClick={() => send()} disabled={uploading > 0 || (!text.trim() && images.length === 0 && files.length === 0)}>
|
||||||
{busy ? t("composer.queue") : t("composer.send")}
|
{busy ? t("composer.queue") : t("composer.send")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ interface Issue {
|
|||||||
branch: string;
|
branch: string;
|
||||||
rounds: number;
|
rounds: number;
|
||||||
/** Newest phase chat that still exists. */
|
/** 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_session?: string;
|
||||||
chat_phase?: Phase;
|
chat_phase?: Phase;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
@@ -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. */
|
/** The factory's main switch, coloured by state: green = running, yellow = stopping, red = stopped. */
|
||||||
function PowerSwitch({ power, onToggle }: { power: Power; onToggle: (on: boolean) => void }) {
|
function PowerSwitch({ power, onToggle }: { power: Power; onToggle: (on: boolean) => void }) {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
@@ -402,20 +418,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const mergePr = async () => {
|
const prNo = (i: Issue) => Number(i.pr_url.replace(/\/$/, "").split("/").pop()) || 0;
|
||||||
if (!selected || !pr) return;
|
/** Merge the pull request of an issue; only offered once the acceptance has passed. */
|
||||||
if (!(await confirmDialog({ message: t("factory.mergeConfirm", { n: pr.number, method: t(`factory.merge.${prMethod}` as any) }) }))) return;
|
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);
|
setBusy(true);
|
||||||
try {
|
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"));
|
toast(t("factory.merged"));
|
||||||
await loadPr();
|
await loadPr();
|
||||||
|
await reload();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(e.message);
|
toast(e.message);
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const mergePr = () => (selected && pr ? mergeIssue(selected, pr.number) : Promise.resolve());
|
||||||
const removeIssue = async () => {
|
const removeIssue = async () => {
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
if (!(await confirmDialog({ message: t("factory.removeConfirm", { n: selected.number }), confirmLabel: t("factory.remove"), danger: true }))) 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);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const closeIssue = async () => {
|
/** Close an issue; only offered once its pull request is merged. */
|
||||||
if (!selected) return;
|
const closeIssueOf = async (i: Issue) => {
|
||||||
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: selected.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
|
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;
|
if (comment === null) return;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
try {
|
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");
|
toast(t("factory.closed"), "success");
|
||||||
setSel("");
|
if (selected && selected.number === i.number && selected.repo === i.repo) setSel("");
|
||||||
await reload();
|
await reload();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(e.message);
|
toast(e.message);
|
||||||
@@ -446,6 +467,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const closeIssue = () => (selected ? closeIssueOf(selected) : Promise.resolve());
|
||||||
const phaseRunning = !!selected && ["review", "building", "testing"].includes(selected.state);
|
const phaseRunning = !!selected && ["review", "building", "testing"].includes(selected.state);
|
||||||
/** Master switch: a soft stop – no new agent starts, running ones finish their phase. */
|
/** Master switch: a soft stop – no new agent starts, running ones finish their phase. */
|
||||||
const setPower = async (on: boolean) => {
|
const setPower = async (on: boolean) => {
|
||||||
@@ -623,6 +645,19 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{tokens > 0 && <span className="hint">{fmtCompact(tokens)} {t("factory.tokens")}</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>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -658,7 +693,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
<Icon name="trash" /> {t("factory.remove")}
|
<Icon name="trash" /> {t("factory.remove")}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{selected && selected.state === "done" && (
|
{selected && selected.state === "done" && selected.merged && (
|
||||||
<button className="small" onClick={closeIssue} disabled={busy}>
|
<button className="small" onClick={closeIssue} disabled={busy}>
|
||||||
<Icon name="check" /> {t("factory.close")}
|
<Icon name="check" /> {t("factory.close")}
|
||||||
</button>
|
</button>
|
||||||
@@ -691,7 +726,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span className="spacer" />
|
<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) => (
|
{["merge", "squash", "rebase"].map((m) => (
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ export function QueueList({ sessionId, busy }: { sessionId: string; busy: boolea
|
|||||||
<div className="queue">
|
<div className="queue">
|
||||||
<div className="queue-head">
|
<div className="queue-head">
|
||||||
<span>{busy ? t("queue.pending", { n: items.length }) : t("queue.stopped", { n: items.length })}</span>
|
<span>{busy ? t("queue.pending", { n: items.length }) : t("queue.stopped", { n: items.length })}</span>
|
||||||
{!busy && (
|
<button
|
||||||
<button className="small primary" onClick={() => post(`/sessions/${sessionId}/queue/flush`).catch((e) => toast(e.message))}>
|
className="small primary"
|
||||||
{t("queue.sendNow")}
|
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>
|
</button>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{items.map((it) => {
|
{items.map((it) => {
|
||||||
const text = it.parts.map((p) => (p.type === "text" ? p.text : "")).join(" ").trim();
|
const text = it.parts.map((p) => (p.type === "text" ? p.text : "")).join(" ").trim();
|
||||||
|
|||||||
+7
-3
@@ -69,9 +69,11 @@ export const de: Messages = {
|
|||||||
"settings.pricesFetched": "Preise für {n} Modelle aktualisiert – zum Übernehmen speichern.",
|
"settings.pricesFetched": "Preise für {n} Modelle aktualisiert – zum Übernehmen speichern.",
|
||||||
"stats.perMillion": "pro 1 Mio. Tok.",
|
"stats.perMillion": "pro 1 Mio. Tok.",
|
||||||
"stats.perMillionHint": "Effektive Kosten pro Million Tokens (Input inkl. Cache + Output)",
|
"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.stopped": "{n} Nachricht(en) in der Warteschlange",
|
||||||
"queue.sendNow": "Jetzt senden",
|
"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.remove": "Aus der Warteschlange entfernen",
|
||||||
"queue.backgroundResult": "Ergebnis einer Hintergrundaufgabe",
|
"queue.backgroundResult": "Ergebnis einer Hintergrundaufgabe",
|
||||||
"permissionMode.auto": "Automatisch (fragt einmal, Sicheres läuft)",
|
"permissionMode.auto": "Automatisch (fragt einmal, Sicheres läuft)",
|
||||||
@@ -819,8 +821,8 @@ export const de: Messages = {
|
|||||||
"chat.delete": "Session löschen",
|
"chat.delete": "Session löschen",
|
||||||
"chat.deleteConfirm": "Diese Session inklusive Subagenten löschen? Die Statistik bleibt erhalten.",
|
"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.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…",
|
"composer.placeholderBusy": "Nachricht wird eingereiht und beim nächsten Schritt gesendet… (Strg+Enter sendet sofort)",
|
||||||
"composer.send": "Senden",
|
"composer.send": "Senden",
|
||||||
"composer.queue": "Einreihen",
|
"composer.queue": "Einreihen",
|
||||||
"composer.stop": "Stopp",
|
"composer.stop": "Stopp",
|
||||||
@@ -1246,6 +1248,8 @@ export const de: Messages = {
|
|||||||
"factory.preparing.env": "Testumgebung wird vorbereitet",
|
"factory.preparing.env": "Testumgebung wird vorbereitet",
|
||||||
"factory.preparing.start": "Lauf 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.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.review": "Prüfung",
|
||||||
"factory.col.question": "Rückfragen",
|
"factory.col.question": "Rückfragen",
|
||||||
"factory.col.approved": "Freigegeben",
|
"factory.col.approved": "Freigegeben",
|
||||||
|
|||||||
+7
-3
@@ -68,9 +68,11 @@ export const en = {
|
|||||||
"settings.pricesFetched": "Prices updated for {n} models – save to keep them.",
|
"settings.pricesFetched": "Prices updated for {n} models – save to keep them.",
|
||||||
"stats.perMillion": "per 1M tok",
|
"stats.perMillion": "per 1M tok",
|
||||||
"stats.perMillionHint": "Effective cost per million tokens (input incl. cache + output)",
|
"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.stopped": "{n} message(s) waiting",
|
||||||
"queue.sendNow": "Send now",
|
"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.remove": "Remove from queue",
|
||||||
"queue.backgroundResult": "Result of a background task",
|
"queue.backgroundResult": "Result of a background task",
|
||||||
"permissionMode.auto": "Automatic (asks once, safe steps run)",
|
"permissionMode.auto": "Automatic (asks once, safe steps run)",
|
||||||
@@ -818,8 +820,8 @@ export const en = {
|
|||||||
"chat.delete": "Delete session",
|
"chat.delete": "Delete session",
|
||||||
"chat.deleteConfirm": "Delete this session including its subagents? Statistics are kept.",
|
"chat.deleteConfirm": "Delete this session including its subagents? Statistics are kept.",
|
||||||
|
|
||||||
"composer.placeholder": "Message… (/ for commands, @ for files, attach or paste files)",
|
"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…",
|
"composer.placeholderBusy": "Message is queued and sent at the next step… (Ctrl+Enter sends it now)",
|
||||||
"composer.send": "Send",
|
"composer.send": "Send",
|
||||||
"composer.queue": "Queue",
|
"composer.queue": "Queue",
|
||||||
"composer.stop": "Stop",
|
"composer.stop": "Stop",
|
||||||
@@ -1245,6 +1247,8 @@ export const en = {
|
|||||||
"factory.preparing.env": "Preparing the test environment",
|
"factory.preparing.env": "Preparing the test environment",
|
||||||
"factory.preparing.start": "Preparing the run",
|
"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.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.review": "Review",
|
||||||
"factory.col.question": "Questions",
|
"factory.col.question": "Questions",
|
||||||
"factory.col.approved": "Approved",
|
"factory.col.approved": "Approved",
|
||||||
|
|||||||
+38
-2
@@ -5263,6 +5263,10 @@ td.fold-indent {
|
|||||||
background: var(--bg1);
|
background: var(--bg1);
|
||||||
border-bottom: 1px solid var(--bg2);
|
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 {
|
.chat-overlay-body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
@@ -5278,6 +5282,38 @@ td.fold-indent {
|
|||||||
border: 0;
|
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 {
|
.factory-card-head {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -5321,10 +5357,10 @@ td.fold-indent {
|
|||||||
}
|
}
|
||||||
/* Preparing (checkout, test environment): same lamp, other colour than an active chat. */
|
/* Preparing (checkout, test environment): same lamp, other colour than an active chat. */
|
||||||
.factory-pulse.prep {
|
.factory-pulse.prep {
|
||||||
background: var(--blue, var(--accent2));
|
background: var(--prep, var(--blue, var(--accent2)));
|
||||||
}
|
}
|
||||||
.factory-card.preparing {
|
.factory-card.preparing {
|
||||||
border-left: 3px solid var(--blue, var(--accent2));
|
border-left: 3px solid var(--prep, var(--blue, var(--accent2)));
|
||||||
}
|
}
|
||||||
@keyframes factory-pulse {
|
@keyframes factory-pulse {
|
||||||
50% {
|
50% {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #8f9a5c;
|
--power-on: #8f9a5c;
|
||||||
--power-warn: #d9b45a;
|
--power-warn: #d9b45a;
|
||||||
--power-off: #c15c46;
|
--power-off: #c15c46;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #8aa89a;
|
--aqua: #8aa89a;
|
||||||
--blue: #7c9aa1;
|
--blue: #7c9aa1;
|
||||||
--purple: #b47e99;
|
--purple: #b47e99;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #5c6631;
|
--power-on: #5c6631;
|
||||||
--power-warn: #9a7413;
|
--power-warn: #9a7413;
|
||||||
--power-off: #96392a;
|
--power-off: #96392a;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #3d6b72;
|
--aqua: #3d6b72;
|
||||||
--blue: #3d6b72;
|
--blue: #3d6b72;
|
||||||
--purple: #7c4a66;
|
--purple: #7c4a66;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #a6e3a1;
|
--power-on: #a6e3a1;
|
||||||
--power-warn: #f9e2af;
|
--power-warn: #f9e2af;
|
||||||
--power-off: #f38ba8;
|
--power-off: #f38ba8;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #94e2d5;
|
--aqua: #94e2d5;
|
||||||
--blue: #89b4fa;
|
--blue: #89b4fa;
|
||||||
--purple: #f5c2e7;
|
--purple: #f5c2e7;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #40a02b;
|
--power-on: #40a02b;
|
||||||
--power-warn: #df8e1d;
|
--power-warn: #df8e1d;
|
||||||
--power-off: #d20f39;
|
--power-off: #d20f39;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #179299;
|
--aqua: #179299;
|
||||||
--blue: #1e66f5;
|
--blue: #1e66f5;
|
||||||
--purple: #ea76cb;
|
--purple: #ea76cb;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #a9b86a;
|
--power-on: #a9b86a;
|
||||||
--power-warn: #e8c36a;
|
--power-warn: #e8c36a;
|
||||||
--power-off: #d4694f;
|
--power-off: #d4694f;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #9fb8a8;
|
--aqua: #9fb8a8;
|
||||||
--blue: #a3b4c7;
|
--blue: #a3b4c7;
|
||||||
--purple: #cf90a2;
|
--purple: #cf90a2;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #4f6b00;
|
--power-on: #4f6b00;
|
||||||
--power-warn: #a8780a;
|
--power-warn: #a8780a;
|
||||||
--power-off: #a93a2e;
|
--power-off: #a93a2e;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--aqua);
|
||||||
--aqua: #3f6b5e;
|
--aqua: #3f6b5e;
|
||||||
--blue: #8e2d53;
|
--blue: #8e2d53;
|
||||||
--purple: #7a003b;
|
--purple: #7a003b;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #50fa7b;
|
--power-on: #50fa7b;
|
||||||
--power-warn: #f1fa8c;
|
--power-warn: #f1fa8c;
|
||||||
--power-off: #ff5555;
|
--power-off: #ff5555;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #8be9fd;
|
--aqua: #8be9fd;
|
||||||
--blue: #8be9fd;
|
--blue: #8be9fd;
|
||||||
--purple: #ff79c6;
|
--purple: #ff79c6;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #14710a;
|
--power-on: #14710a;
|
||||||
--power-warn: #846e15;
|
--power-warn: #846e15;
|
||||||
--power-off: #cb3a2a;
|
--power-off: #cb3a2a;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #036a96;
|
--aqua: #036a96;
|
||||||
--blue: #036a96;
|
--blue: #036a96;
|
||||||
--purple: #a3144d;
|
--purple: #a3144d;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #a7c080;
|
--power-on: #a7c080;
|
||||||
--power-warn: #dbbc7f;
|
--power-warn: #dbbc7f;
|
||||||
--power-off: #e67e80;
|
--power-off: #e67e80;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--purple);
|
||||||
--aqua: #83c092;
|
--aqua: #83c092;
|
||||||
--blue: #7fbbb3;
|
--blue: #7fbbb3;
|
||||||
--purple: #d699b6;
|
--purple: #d699b6;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #8da101;
|
--power-on: #8da101;
|
||||||
--power-warn: #dfa000;
|
--power-warn: #dfa000;
|
||||||
--power-off: #f85552;
|
--power-off: #f85552;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #35a77c;
|
--aqua: #35a77c;
|
||||||
--blue: #3a94c5;
|
--blue: #3a94c5;
|
||||||
--purple: #df69ba;
|
--purple: #df69ba;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #3fb950;
|
--power-on: #3fb950;
|
||||||
--power-warn: #d29922;
|
--power-warn: #d29922;
|
||||||
--power-off: #f85149;
|
--power-off: #f85149;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #39c5cf;
|
--aqua: #39c5cf;
|
||||||
--blue: #58a6ff;
|
--blue: #58a6ff;
|
||||||
--purple: #bc8cff;
|
--purple: #bc8cff;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #1a7f37;
|
--power-on: #1a7f37;
|
||||||
--power-warn: #9a6700;
|
--power-warn: #9a6700;
|
||||||
--power-off: #d1242f;
|
--power-off: #d1242f;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #1b7c83;
|
--aqua: #1b7c83;
|
||||||
--blue: #0969da;
|
--blue: #0969da;
|
||||||
--purple: #8250df;
|
--purple: #8250df;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
--power-on: #b8bb26;
|
--power-on: #b8bb26;
|
||||||
--power-warn: #fabd2f;
|
--power-warn: #fabd2f;
|
||||||
--power-off: #fb4934;
|
--power-off: #fb4934;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #8ec07c;
|
--aqua: #8ec07c;
|
||||||
--blue: #83a598;
|
--blue: #83a598;
|
||||||
--purple: #d3869b;
|
--purple: #d3869b;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #79740e;
|
--power-on: #79740e;
|
||||||
--power-warn: #b57614;
|
--power-warn: #b57614;
|
||||||
--power-off: #9d0006;
|
--power-off: #9d0006;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #427b58;
|
--aqua: #427b58;
|
||||||
--blue: #076678;
|
--blue: #076678;
|
||||||
--purple: #8f3f71;
|
--purple: #8f3f71;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #8fae72;
|
--power-on: #8fae72;
|
||||||
--power-warn: #e0b350;
|
--power-warn: #e0b350;
|
||||||
--power-off: #f44336;
|
--power-off: #f44336;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--blue);
|
||||||
--aqua: #8a9ba6;
|
--aqua: #8a9ba6;
|
||||||
--blue: #77838a;
|
--blue: #77838a;
|
||||||
--purple: #e58980;
|
--purple: #e58980;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #5a7a43;
|
--power-on: #5a7a43;
|
||||||
--power-warn: #a87b1a;
|
--power-warn: #a87b1a;
|
||||||
--power-off: #b14752;
|
--power-off: #b14752;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #3d727d;
|
--aqua: #3d727d;
|
||||||
--blue: #4c6c94;
|
--blue: #4c6c94;
|
||||||
--purple: #8a5b81;
|
--purple: #8a5b81;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #98bb6c;
|
--power-on: #98bb6c;
|
||||||
--power-warn: #e6c384;
|
--power-warn: #e6c384;
|
||||||
--power-off: #e46876;
|
--power-off: #e46876;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #7aa89f;
|
--aqua: #7aa89f;
|
||||||
--blue: #7fb4ca;
|
--blue: #7fb4ca;
|
||||||
--purple: #957fb8;
|
--purple: #957fb8;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #6f894e;
|
--power-on: #6f894e;
|
||||||
--power-warn: #b07a00;
|
--power-warn: #b07a00;
|
||||||
--power-off: #c84053;
|
--power-off: #c84053;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #597b75;
|
--aqua: #597b75;
|
||||||
--blue: #4d699b;
|
--blue: #4d699b;
|
||||||
--purple: #624c83;
|
--purple: #624c83;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #a3be8c;
|
--power-on: #a3be8c;
|
||||||
--power-warn: #ebcb8b;
|
--power-warn: #ebcb8b;
|
||||||
--power-off: #bf616a;
|
--power-off: #bf616a;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #8fbcbb;
|
--aqua: #8fbcbb;
|
||||||
--blue: #81a1c1;
|
--blue: #81a1c1;
|
||||||
--purple: #b48ead;
|
--purple: #b48ead;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #5f7d48;
|
--power-on: #5f7d48;
|
||||||
--power-warn: #9a7b2f;
|
--power-warn: #9a7b2f;
|
||||||
--power-off: #a9434d;
|
--power-off: #a9434d;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #4d8a89;
|
--aqua: #4d8a89;
|
||||||
--blue: #5e81ac;
|
--blue: #5e81ac;
|
||||||
--purple: #8f6a8a;
|
--purple: #8f6a8a;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #98c379;
|
--power-on: #98c379;
|
||||||
--power-warn: #e5c07b;
|
--power-warn: #e5c07b;
|
||||||
--power-off: #e06c75;
|
--power-off: #e06c75;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #56b6c2;
|
--aqua: #56b6c2;
|
||||||
--blue: #61afef;
|
--blue: #61afef;
|
||||||
--purple: #c678dd;
|
--purple: #c678dd;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #50a14f;
|
--power-on: #50a14f;
|
||||||
--power-warn: #c18401;
|
--power-warn: #c18401;
|
||||||
--power-off: #e45649;
|
--power-off: #e45649;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #0184bc;
|
--aqua: #0184bc;
|
||||||
--blue: #4078f2;
|
--blue: #4078f2;
|
||||||
--purple: #a626a4;
|
--purple: #a626a4;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #95b88f;
|
--power-on: #95b88f;
|
||||||
--power-warn: #f6c177;
|
--power-warn: #f6c177;
|
||||||
--power-off: #eb6f92;
|
--power-off: #eb6f92;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #9ccfd8;
|
--aqua: #9ccfd8;
|
||||||
--blue: #31748f;
|
--blue: #31748f;
|
||||||
--purple: #c4a7e7;
|
--purple: #c4a7e7;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #5e8f60;
|
--power-on: #5e8f60;
|
||||||
--power-warn: #c98a1b;
|
--power-warn: #c98a1b;
|
||||||
--power-off: #b4637a;
|
--power-off: #b4637a;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #56949f;
|
--aqua: #56949f;
|
||||||
--blue: #286983;
|
--blue: #286983;
|
||||||
--purple: #907aa9;
|
--purple: #907aa9;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #859900;
|
--power-on: #859900;
|
||||||
--power-warn: #b58900;
|
--power-warn: #b58900;
|
||||||
--power-off: #dc322f;
|
--power-off: #dc322f;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--purple);
|
||||||
--aqua: #2aa198;
|
--aqua: #2aa198;
|
||||||
--blue: #268bd2;
|
--blue: #268bd2;
|
||||||
--purple: #6c71c4;
|
--purple: #6c71c4;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #859900;
|
--power-on: #859900;
|
||||||
--power-warn: #b58900;
|
--power-warn: #b58900;
|
||||||
--power-off: #dc322f;
|
--power-off: #dc322f;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--purple);
|
||||||
--aqua: #2aa198;
|
--aqua: #2aa198;
|
||||||
--blue: #268bd2;
|
--blue: #268bd2;
|
||||||
--purple: #6c71c4;
|
--purple: #6c71c4;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #8fb98a;
|
--power-on: #8fb98a;
|
||||||
--power-warn: #e0b860;
|
--power-warn: #e0b860;
|
||||||
--power-off: #d47a6a;
|
--power-off: #d47a6a;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #96b4bc;
|
--aqua: #96b4bc;
|
||||||
--blue: #7aa0cc;
|
--blue: #7aa0cc;
|
||||||
--purple: #c896b2;
|
--purple: #c896b2;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #4a6b3a;
|
--power-on: #4a6b3a;
|
||||||
--power-warn: #9a7218;
|
--power-warn: #9a7218;
|
||||||
--power-off: #8a3028;
|
--power-off: #8a3028;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #3a5a6a;
|
--aqua: #3a5a6a;
|
||||||
--blue: #3a5a8a;
|
--blue: #3a5a8a;
|
||||||
--purple: #5a4a72;
|
--purple: #5a4a72;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #9ece6a;
|
--power-on: #9ece6a;
|
||||||
--power-warn: #e0af68;
|
--power-warn: #e0af68;
|
||||||
--power-off: #f7768e;
|
--power-off: #f7768e;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #73daca;
|
--aqua: #73daca;
|
||||||
--blue: #7aa2f7;
|
--blue: #7aa2f7;
|
||||||
--purple: #bb9af7;
|
--purple: #bb9af7;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #587539;
|
--power-on: #587539;
|
||||||
--power-warn: #8c6c3e;
|
--power-warn: #8c6c3e;
|
||||||
--power-off: #f52a65;
|
--power-off: #f52a65;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #118c74;
|
--aqua: #118c74;
|
||||||
--blue: #2e7de9;
|
--blue: #2e7de9;
|
||||||
--purple: #9854f1;
|
--purple: #9854f1;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #89d185;
|
--power-on: #89d185;
|
||||||
--power-warn: #cca700;
|
--power-warn: #cca700;
|
||||||
--power-off: #f14c4c;
|
--power-off: #f14c4c;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #4ec9b0;
|
--aqua: #4ec9b0;
|
||||||
--blue: #3794ff;
|
--blue: #3794ff;
|
||||||
--purple: #c586c0;
|
--purple: #c586c0;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
--power-on: #388a34;
|
--power-on: #388a34;
|
||||||
--power-warn: #bf8803;
|
--power-warn: #bf8803;
|
||||||
--power-off: #cd3131;
|
--power-off: #cd3131;
|
||||||
|
/* Lamp of a phase that is still being prepared: a colour that differs from --accent */
|
||||||
|
--prep: var(--power-warn);
|
||||||
--aqua: #267f99;
|
--aqua: #267f99;
|
||||||
--blue: #005fb8;
|
--blue: #005fb8;
|
||||||
--purple: #af00db;
|
--purple: #af00db;
|
||||||
|
|||||||
@@ -3,6 +3,38 @@
|
|||||||
* under "unreleased"; scripts/release.sh renames the key to the release version.
|
* under "unreleased"; scripts/release.sh renames the key to the release version.
|
||||||
*/
|
*/
|
||||||
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
|
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
|
||||||
|
"202611-00081": {
|
||||||
|
en: ["Queued messages can be forced: Enter on the empty input, Ctrl+Enter with text or the \"Force now\" button interrupts the running step so the model reads the message at once (also in the terminal client)", "Terminal client: long input and long questions wrap instead of being cut off; queued messages are shown above the input"],
|
||||||
|
de: ["Eingereihte Nachrichten lassen sich erzwingen: Enter im leeren Feld, Strg+Enter mit Text oder der Button „Jetzt erzwingen“ unterbricht den laufenden Schritt, sodass das Modell die Nachricht sofort liest (auch im Terminal-Client)", "Terminal-Client: lange Eingaben und lange Fragen werden umbrochen statt abgeschnitten; wartende Nachrichten stehen über dem Eingabefeld"],
|
||||||
|
},
|
||||||
|
"202611-00080": {
|
||||||
|
en: ["Fixed: the Factory page no longer makes the server stall (504 errors, high CPU)"],
|
||||||
|
de: ["Behoben: die Factory-Seite lässt den Server nicht mehr hängen (504-Fehler, hohe CPU-Last)"],
|
||||||
|
},
|
||||||
|
"202611-00079": {
|
||||||
|
en: ["The server binary keeps its symbols (for diagnosing a high CPU load); no change in behaviour"],
|
||||||
|
de: ["Das Server-Binary behält seine Symbole (zur Diagnose einer hohen CPU-Last); keine Änderung im Verhalten"],
|
||||||
|
},
|
||||||
|
"202611-00078": {
|
||||||
|
en: ["Fixed: leftover zombie processes in the container; the Telegram bot token no longer appears in error logs"],
|
||||||
|
de: ["Behoben: übrig gebliebene Zombie-Prozesse im Container; der Telegram-Bot-Token taucht nicht mehr in Fehlerlogs auf"],
|
||||||
|
},
|
||||||
|
"202611-00077": {
|
||||||
|
en: ["Factory test runner: shared base image (Node 24, Python, gcc, Chromium/Playwright) for acceptance containers; logs start time, cache hits and installed packages"],
|
||||||
|
de: ["Factory-Test-Runner: gemeinsames Basis-Image (Node 24, Python, gcc, Chromium/Playwright) für Abnahme-Container; protokolliert Startzeit, Cache-Treffer und installierte Pakete"],
|
||||||
|
},
|
||||||
|
"202611-00076": {
|
||||||
|
en: ["Factory test runner: logs how long an environment took to start and whether the cache seed was a hit"],
|
||||||
|
de: ["Factory-Test-Runner: protokolliert, wie lange eine Umgebung zum Start brauchte und ob der Cache-Seed getroffen hat"],
|
||||||
|
},
|
||||||
|
"202611-00075": {
|
||||||
|
en: ["Factory: the lamp of a phase being prepared now differs in colour from the accent in every theme"],
|
||||||
|
de: ["Factory: die Lampe einer Phase in Vorbereitung unterscheidet sich in jedem Theme farblich vom Akzent"],
|
||||||
|
},
|
||||||
|
"202611-00074": {
|
||||||
|
en: ["Factory: Merge and Close buttons on the issue card – merge after a positive acceptance, close after the merge", "Factory test runner: caches between acceptance runs (npm, Cargo, pip, Go and optional seeds of the install step) – the test environment starts much faster"],
|
||||||
|
de: ["Factory: Merge- und Schließen-Knopf auf der Issue-Karte – Merge nach erfolgreicher Abnahme, Schließen nach dem Merge", "Factory-Test-Runner: Caches zwischen Abnahmeläufen (npm, Cargo, pip, Go und optionale Seeds des Install-Schritts) – die Testumgebung startet deutlich schneller"],
|
||||||
|
},
|
||||||
"202611-00072": {
|
"202611-00072": {
|
||||||
en: ["Factory: a blinking blue lamp shows that a phase is being prepared (checkout, test environment) before its chat starts"],
|
en: ["Factory: a blinking blue lamp shows that a phase is being prepared (checkout, test environment) before its chat starts"],
|
||||||
de: ["Factory: eine blinkende blaue Lampe zeigt, dass eine Phase vorbereitet wird (Checkout, Testumgebung), bevor der Chat startet"],
|
de: ["Factory: eine blinkende blaue Lampe zeigt, dass eine Phase vorbereitet wird (Checkout, Testumgebung), bevor der Chat startet"],
|
||||||
|
|||||||
Reference in new issue
Block a user