Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57607918ee | ||
|
|
25e4167f56 | ||
|
|
51a60ee75e | ||
|
|
96cb866d5c |
No files matched your search
@@ -3,6 +3,19 @@
|
|||||||
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-00069] – 2026-11-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Factory: backlog column.** All open issues of the configured repositories that are not in the factory yet appear in a new column on the far left. Each card has a *Queue* button (and the column *Queue all*, with a confirmation): the issue gets the factory label on the forge and the factory takes it up straight away. Issues whose author may not file factory issues are shown but cannot be queued. The list is read from the forge (cached for a minute) and follows the project dropdown.
|
||||||
|
- **Factory: cards are tinted by status** – a faint background and border colour per state (review, question, approved, build, acceptance, failed, done), taken from the theme's own colours.
|
||||||
|
|
||||||
|
## [v202611-00068] – 2026-11-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Test runner: `"isolated": false` in `.factory/setup.json`** for apps that cannot run in a container (a native window, a library) – acceptance starts them itself, as before. `ready_seconds` sets how long the runner waits for the port. Free text after the `url` (e.g. `http://localhost:8080 (trunk serve)`) no longer confuses the port detection.
|
||||||
|
|
||||||
## [v202611-00067] – 2026-11-20
|
## [v202611-00067] – 2026-11-20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Version v202611-00067" src="https://img.shields.io/badge/version-v202611--00067-d69e2e?style=flat-square">
|
<img alt="Version v202611-00069" src="https://img.shields.io/badge/version-v202611--00069-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">
|
||||||
@@ -332,6 +332,12 @@ phase the model, agent (CodeCraft or Claude Code), permission mode, timeout, tri
|
|||||||
technical failures, the skills that are switched on for it, plus the number of rework rounds (default 2). Failed or rejected issues
|
technical failures, the skills that are switched on for it, plus the number of rework rounds (default 2). Failed or rejected issues
|
||||||
can be restarted from the board, finished ones are closed with a comment.
|
can be restarted from the board, finished ones are closed with a comment.
|
||||||
|
|
||||||
|
**Backlog.** The first column of the board lists every open issue of the configured
|
||||||
|
repositories that is not in the factory yet. *Queue* gives an issue the factory label on the
|
||||||
|
forge (so it enters the review at once); *Queue all* does it for the whole list. Issues of authors
|
||||||
|
who are not allowed to file factory issues are shown but cannot be queued. Cards are tinted by
|
||||||
|
status.
|
||||||
|
|
||||||
**Files in the repository** (all optional, kept in `.factory/`):
|
**Files in the repository** (all optional, kept in `.factory/`):
|
||||||
|
|
||||||
| File | Purpose |
|
| File | Purpose |
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ pub fn router(app: AppState) -> Router {
|
|||||||
.route("/account/factory", get(get_factory).put(put_factory))
|
.route("/account/factory", get(get_factory).put(put_factory))
|
||||||
.route("/account/factory/test", post(test_factory))
|
.route("/account/factory/test", post(test_factory))
|
||||||
.route("/factory/overview", get(factory_overview))
|
.route("/factory/overview", get(factory_overview))
|
||||||
|
.route("/factory/backlog", get(factory_backlog))
|
||||||
|
.route("/factory/backlog/enqueue", post(factory_enqueue))
|
||||||
.route("/factory/poll", post(factory_poll))
|
.route("/factory/poll", post(factory_poll))
|
||||||
.route("/factory/issues/restart", post(factory_restart))
|
.route("/factory/issues/restart", post(factory_restart))
|
||||||
.route("/factory/issue-chats", post(factory_new_issue_chat))
|
.route("/factory/issue-chats", post(factory_new_issue_chat))
|
||||||
@@ -2754,6 +2756,92 @@ async fn factory_overview(Extension(user): Extension<User>, State(app): State<Ap
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Open issues per repository as the forge lists them; cached for a minute so that the board can ask often.
|
||||||
|
static BACKLOG_CACHE: std::sync::OnceLock<std::sync::Mutex<std::collections::HashMap<String, (std::time::Instant, Vec<Value>)>>> = std::sync::OnceLock::new();
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct BacklogQuery {
|
||||||
|
#[serde(default)]
|
||||||
|
refresh: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The backlog: open issues of the configured repositories that are not in the factory yet.
|
||||||
|
async fn factory_backlog(Extension(user): Extension<User>, State(app): State<AppState>, Query(q): Query<BacklogQuery>) -> ApiResult {
|
||||||
|
let s: crate::factory::FactorySettings = app.store.user_setting(&user.id, "factory")?;
|
||||||
|
let cache = BACKLOG_CACHE.get_or_init(Default::default);
|
||||||
|
let tracked_all = app.store.factory_issues(&user.id)?;
|
||||||
|
let (mut issues, mut errors) = (Vec::new(), Vec::new());
|
||||||
|
for cfg in s.repos.iter().filter(|r| r.enabled).map(|r| s.resolve(r)).filter(|r| !r.token.is_empty()) {
|
||||||
|
let key = format!("{}|{}", user.id, cfg.url);
|
||||||
|
let cached = cache.lock().unwrap().get(&key).filter(|(t, _)| !q.refresh && t.elapsed().as_secs() < 60).map(|(_, v)| v.clone());
|
||||||
|
let result = async {
|
||||||
|
let g = crate::factory::Forge::new(&cfg)?;
|
||||||
|
let open = match cached {
|
||||||
|
Some(v) => v,
|
||||||
|
None => {
|
||||||
|
let v = g.open_issues().await?;
|
||||||
|
cache.lock().unwrap().insert(key.clone(), (std::time::Instant::now(), v.clone()));
|
||||||
|
v
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let allowed = crate::factory::allowed_authors(&g, &cfg).await?;
|
||||||
|
let tracked: Vec<i64> = tracked_all.iter().filter(|r| r["repo"].as_str() == Some(cfg.url.as_str())).map(|r| r["number"].as_i64().unwrap_or(0)).collect();
|
||||||
|
anyhow::Ok(crate::factory::backlog_of(&cfg, &open, &tracked, &allowed))
|
||||||
|
}
|
||||||
|
.await;
|
||||||
|
match result {
|
||||||
|
Ok(v) => issues.extend(v),
|
||||||
|
Err(e) => errors.push(format!("{}: {e:#}", cfg.url)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Json(json!({"issues": issues, "errors": errors})))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Enqueue {
|
||||||
|
repo: String,
|
||||||
|
numbers: Vec<i64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Put backlog issues into the process: give them the factory label, the next poll picks them up.
|
||||||
|
async fn factory_enqueue(Extension(user): Extension<User>, State(app): State<AppState>, headers: axum::http::HeaderMap, Json(b): Json<Enqueue>) -> ApiResult {
|
||||||
|
let cfg = factory_repo_cfg(&app, &user, &b.repo)?;
|
||||||
|
if b.numbers.is_empty() || b.numbers.len() > 100 {
|
||||||
|
return Err(ApiError(StatusCode::BAD_REQUEST, "1 to 100 issues".into()));
|
||||||
|
}
|
||||||
|
let bad = |e: anyhow::Error| ApiError(StatusCode::BAD_GATEWAY, format!("{e:#}"));
|
||||||
|
let g = crate::factory::Forge::new(&cfg).map_err(bad)?;
|
||||||
|
let allowed = crate::factory::allowed_authors(&g, &cfg).await.map_err(bad)?;
|
||||||
|
let open = g.open_issues().await.map_err(bad)?;
|
||||||
|
g.ensure_labels().await.map_err(bad)?;
|
||||||
|
let (mut queued, mut errors) = (Vec::new(), Vec::new());
|
||||||
|
for n in b.numbers {
|
||||||
|
let Some(issue) = open.iter().find(|i| crate::factory::issue_no(i) == n) else {
|
||||||
|
errors.push(json!({"number": n, "error": "not an open issue of this repository"}));
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let author = issue["user"]["login"].as_str().unwrap_or("");
|
||||||
|
if !allowed.iter().any(|a| a.eq_ignore_ascii_case(author)) {
|
||||||
|
errors.push(json!({"number": n, "error": format!("the author {author} is not allowed to file factory issues (see the repository settings)")}));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match g.add_label(n as u64, &cfg.label).await {
|
||||||
|
Ok(()) => queued.push(n),
|
||||||
|
Err(e) => errors.push(json!({"number": n, "error": format!("{e:#}")})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BACKLOG_CACHE.get_or_init(Default::default).lock().unwrap().remove(&format!("{}|{}", user.id, cfg.url));
|
||||||
|
app.audit(Some(&user), "factory.backlog.enqueue", &format!("{} {:?}", b.repo, queued), &crate::auth::client_ip(&headers));
|
||||||
|
// Take the issues up right away instead of waiting for the next poll.
|
||||||
|
if !queued.is_empty() {
|
||||||
|
let (app2, user2) = (app.clone(), user.clone());
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = crate::factory::poll_repo(&app2, &user2, &cfg).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(Json(json!({"queued": queued, "errors": errors})))
|
||||||
|
}
|
||||||
|
|
||||||
/// Look for new issues right now instead of waiting for the next poll.
|
/// Look for new issues right now instead of waiting for the next poll.
|
||||||
async fn factory_poll(Extension(user): Extension<User>, State(app): State<AppState>) -> ApiResult {
|
async fn factory_poll(Extension(user): Extension<User>, State(app): State<AppState>) -> ApiResult {
|
||||||
let s: crate::factory::FactorySettings = app.store.user_setting(&user.id, "factory")?;
|
let s: crate::factory::FactorySettings = app.store.user_setting(&user.id, "factory")?;
|
||||||
|
|||||||
+90
-2
@@ -556,6 +556,49 @@ impl Forge {
|
|||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// All open issues (pull requests excluded), up to 200, in the shape of `issues()`.
|
||||||
|
pub async fn open_issues(&self) -> Result<Vec<Value>> {
|
||||||
|
let mut out = Vec::new();
|
||||||
|
for page in 1..=4 {
|
||||||
|
let url = match self.kind {
|
||||||
|
Kind::Gitea => self.rp(&format!("/issues?state=open&type=issues&limit=50&page={page}")),
|
||||||
|
Kind::Github => self.rp(&format!("/issues?state=open&per_page=50&page={page}")),
|
||||||
|
Kind::Gitlab => self.rp(&format!("/issues?state=opened&per_page=50&page={page}")),
|
||||||
|
};
|
||||||
|
let v = self.call(reqwest::Method::GET, url, None).await?;
|
||||||
|
let a = v.as_array().cloned().unwrap_or_default();
|
||||||
|
let n = a.len();
|
||||||
|
for i in a {
|
||||||
|
if !i.get("pull_request").map_or(true, |p| p.is_null()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.push(if self.kind == Kind::Gitlab { norm_gitlab_issue(&i) } else { i });
|
||||||
|
}
|
||||||
|
if n < 50 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add one label to an issue without touching its other labels.
|
||||||
|
pub async fn add_label(&self, issue: u64, name: &str) -> Result<()> {
|
||||||
|
match self.kind {
|
||||||
|
Kind::Gitea => {
|
||||||
|
let all = self.label_names().await?;
|
||||||
|
let id = all.iter().find(|l| l["name"].as_str() == Some(name)).map(|l| l["id"].clone()).with_context(|| format!("label {name} does not exist"))?;
|
||||||
|
self.call(reqwest::Method::POST, self.rp(&format!("/issues/{issue}/labels")), Some(json!({"labels": [id]}))).await?;
|
||||||
|
}
|
||||||
|
Kind::Github => {
|
||||||
|
self.call(reqwest::Method::POST, self.rp(&format!("/issues/{issue}/labels")), Some(json!({"labels": [name]}))).await?;
|
||||||
|
}
|
||||||
|
Kind::Gitlab => {
|
||||||
|
self.call(reqwest::Method::PUT, self.rp(&format!("/issues/{issue}")), Some(json!({"add_labels": name}))).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Is the issue still open on the forge?
|
/// Is the issue still open on the forge?
|
||||||
pub async fn issue_is_open(&self, number: u64) -> Result<bool> {
|
pub async fn issue_is_open(&self, number: u64) -> Result<bool> {
|
||||||
let v = self.call(reqwest::Method::GET, self.rp(&format!("/issues/{number}")), None).await?;
|
let v = self.call(reqwest::Method::GET, self.rp(&format!("/issues/{number}")), None).await?;
|
||||||
@@ -738,7 +781,12 @@ impl Forge {
|
|||||||
|
|
||||||
/// GitLab issue → {number, title, body, user.login, html_url}.
|
/// GitLab issue → {number, title, body, user.login, html_url}.
|
||||||
fn norm_gitlab_issue(i: &Value) -> Value {
|
fn norm_gitlab_issue(i: &Value) -> Value {
|
||||||
json!({"number": i["iid"], "title": i["title"], "body": i["description"], "user": {"login": i["author"]["username"]}, "html_url": i["web_url"]})
|
json!({"number": i["iid"], "title": i["title"], "body": i["description"], "user": {"login": i["author"]["username"]}, "html_url": i["web_url"], "labels": i["labels"]})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Label names of an issue (Gitea/GitHub: objects with a name, GitLab: plain strings).
|
||||||
|
pub fn issue_labels(i: &Value) -> Vec<String> {
|
||||||
|
i["labels"].as_array().map(|a| a.iter().filter_map(|l| l["name"].as_str().or_else(|| l.as_str()).map(String::from)).collect()).unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn urlenc(s: &str) -> String {
|
fn urlenc(s: &str) -> String {
|
||||||
@@ -1396,6 +1444,33 @@ pub(crate) async fn alert(app: &App, repo: &str, n: i64, what: &str, detail: &st
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// One pass over a repository: take up new issues, restart reviews after answers.
|
/// One pass over a repository: take up new issues, restart reviews after answers.
|
||||||
|
/// Who may file issues for the factory: the configured users, by default the token's owner.
|
||||||
|
pub async fn allowed_authors(g: &Forge, cfg: &RepoCfg) -> Result<Vec<String>> {
|
||||||
|
let mut allowed = cfg.allowed_users.clone();
|
||||||
|
if allowed.is_empty() {
|
||||||
|
allowed.push(g.login().await?);
|
||||||
|
}
|
||||||
|
Ok(allowed)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Open issues of the forge that are not in the factory (yet): the backlog.
|
||||||
|
/// `open` is the forge's list of open issues, `tracked` the issue numbers the factory already knows.
|
||||||
|
pub fn backlog_of(cfg: &RepoCfg, open: &[Value], tracked: &[i64], allowed: &[String]) -> Vec<Value> {
|
||||||
|
open.iter()
|
||||||
|
.filter_map(|i| {
|
||||||
|
let n = issue_no(i);
|
||||||
|
let author = i["user"]["login"].as_str().unwrap_or("");
|
||||||
|
let ok = allowed.iter().any(|a| a.eq_ignore_ascii_case(author));
|
||||||
|
let labelled = issue_labels(i).iter().any(|l| l == &cfg.label);
|
||||||
|
// Labelled issues of allowed authors are taken up by the next poll anyway.
|
||||||
|
if n == 0 || tracked.contains(&n) || (labelled && ok) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(json!({"repo": cfg.url, "number": n, "title": i["title"], "author": author, "url": i["html_url"], "allowed": ok, "labels": issue_labels(i)}))
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn poll_repo(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<()> {
|
pub async fn poll_repo(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<()> {
|
||||||
let g = Forge::new(cfg)?;
|
let g = Forge::new(cfg)?;
|
||||||
let mut allowed = cfg.allowed_users.clone();
|
let mut allowed = cfg.allowed_users.clone();
|
||||||
@@ -1642,7 +1717,7 @@ How to work:
|
|||||||
5. Also keep the file `setup.json` in your working directory: it tells the acceptance stage how to start the finished app, so the app can be checked by looking at it. Once the tech stack is settled write it, and update it when the stack changes. Format (one JSON object, all values strings, no comments):
|
5. Also keep the file `setup.json` in your working directory: it tells the acceptance stage how to start the finished app, so the app can be checked by looking at it. Once the tech stack is settled write it, and update it when the stack changes. Format (one JSON object, all values strings, no comments):
|
||||||
`{"install": "optional one-off setup command, e.g. npm ci", "start": "command that runs the app in the foreground", "url": "where it listens, e.g. http://localhost:8080"}`
|
`{"install": "optional one-off setup command, e.g. npm ci", "start": "command that runs the app in the foreground", "url": "where it listens, e.g. http://localhost:8080"}`
|
||||||
Ask the user for the port and commands if the spec leaves them open. A static site may use e.g. `"start": "python3 -m http.server 8080"`. Without a start command acceptance has to guess, so do not skip this file for anything that runs.
|
Ask the user for the port and commands if the spec leaves them open. A static site may use e.g. `"start": "python3 -m http.server 8080"`. Without a start command acceptance has to guess, so do not skip this file for anything that runs.
|
||||||
Acceptance may run the app in a fresh throw-away container: then add `"image"` (a Docker image that has the toolchain for install/start, e.g. `node:22-bookworm`, `python:3.12`, `golang:1.23`) and, if the app needs a database or similar, `"services": {"db": {"image": "postgres:16", "env": {"POSTGRES_PASSWORD": "app"}}}` (reachable under the name `db`). Never write secrets there.
|
Acceptance may run the app in a fresh throw-away container: then add `"image"` (a Docker image that has the toolchain for install/start, e.g. `node:22-bookworm`, `python:3.12`, `golang:1.23`) and, if the app needs a database or similar, `"services": {"db": {"image": "postgres:16", "env": {"POSTGRES_PASSWORD": "app"}}}` (reachable under the name `db`). Use `"ready_seconds"` for apps that need long to install and start. The app must listen on 0.0.0.0, not only 127.0.0.1. For something that cannot run in a container (a native desktop window, a library) set `"isolated": false`. Never write secrets there.
|
||||||
6. When the user says the spec is done, propose a short project name and a repository slug (lowercase, digits and dashes) and end your message with exactly one fenced json block and nothing after it:
|
6. When the user says the spec is done, propose a short project name and a repository slug (lowercase, digits and dashes) and end your message with exactly one fenced json block and nothing after it:
|
||||||
```json
|
```json
|
||||||
{"decision": "ready", "name": "Project name", "slug": "project-name", "description": "one sentence"}
|
{"decision": "ready", "name": "Project name", "slug": "project-name", "description": "one sentence"}
|
||||||
@@ -1832,6 +1907,19 @@ pub async fn create_project(app: &Arc<App>, user: &User, settings: &mut FactoryS
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn backlog_skips_tracked_and_queued_issues() {
|
||||||
|
let cfg = repo("https://git.example.org/o/r.git");
|
||||||
|
let issue = |n: i64, author: &str, labels: &[&str]| json!({"number": n, "title": format!("t{n}"), "user": {"login": author}, "html_url": "u", "labels": labels.iter().map(|l| json!({"name": l})).collect::<Vec<_>>()});
|
||||||
|
let open = vec![issue(1, "me", &[]), issue(2, "me", &[&cfg.label]), issue(3, "me", &["bug"]), issue(4, "stranger", &[&cfg.label]), issue(5, "me", &[])];
|
||||||
|
let b = backlog_of(&cfg, &open, &[5], &["ME".to_string()]);
|
||||||
|
let nums: Vec<i64> = b.iter().map(|i| i["number"].as_i64().unwrap()).collect();
|
||||||
|
// 2 is labelled by an allowed author (the poll takes it), 5 is tracked; 4 stays visible but not allowed.
|
||||||
|
assert_eq!(nums, vec![1, 3, 4]);
|
||||||
|
assert_eq!(b[2]["allowed"], false);
|
||||||
|
assert_eq!(issue_labels(&json!({"labels": ["a", {"name": "b"}]})), vec!["a", "b"]);
|
||||||
|
}
|
||||||
|
|
||||||
fn repo(url: &str) -> RepoCfg {
|
fn repo(url: &str) -> RepoCfg {
|
||||||
serde_json::from_value(json!({"url": url, "token": "tok"})).unwrap()
|
serde_json::from_value(json!({"url": url, "token": "tok"})).unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ pub struct Started {
|
|||||||
/// Parse `.factory/setup.json` into a request (without `work`). `None` when there is nothing to start.
|
/// Parse `.factory/setup.json` into a request (without `work`). `None` when there is nothing to start.
|
||||||
pub fn parse_setup(text: &str) -> Option<StartReq> {
|
pub fn parse_setup(text: &str) -> Option<StartReq> {
|
||||||
let v: Value = serde_json::from_str(text).ok()?;
|
let v: Value = serde_json::from_str(text).ok()?;
|
||||||
|
// `"isolated": false`: the app cannot run in a container (e.g. a native window); acceptance starts it itself.
|
||||||
|
if v["isolated"].as_bool() == Some(false) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let start = v["start"].as_str()?.trim().to_string();
|
let start = v["start"].as_str()?.trim().to_string();
|
||||||
if start.is_empty() {
|
if start.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
@@ -111,8 +115,9 @@ pub fn parse_setup(text: &str) -> Option<StartReq> {
|
|||||||
|
|
||||||
/// 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.split_once("://")?;
|
let (scheme, rest) = url.trim().split_once("://")?;
|
||||||
let host = rest.split('/').next()?;
|
// Free text after the URL ("http://localhost:8080 (trunk serve)") is ignored.
|
||||||
|
let host = rest.split(|c: char| c == '/' || c.is_whitespace()).next()?;
|
||||||
match host.rsplit_once(':') {
|
match host.rsplit_once(':') {
|
||||||
Some((_, p)) if p.chars().all(|c| c.is_ascii_digit()) && !p.is_empty() => p.parse().ok(),
|
Some((_, p)) if p.chars().all(|c| c.is_ascii_digit()) && !p.is_empty() => p.parse().ok(),
|
||||||
_ => Some(if scheme == "https" { 443 } else { 80 }),
|
_ => Some(if scheme == "https" { 443 } else { 80 }),
|
||||||
@@ -548,6 +553,8 @@ mod tests {
|
|||||||
assert_eq!(port_of("http://localhost"), Some(80));
|
assert_eq!(port_of("http://localhost"), Some(80));
|
||||||
assert_eq!(port_of("https://x/y"), Some(443));
|
assert_eq!(port_of("https://x/y"), Some(443));
|
||||||
assert_eq!(port_of("nonsense"), None);
|
assert_eq!(port_of("nonsense"), None);
|
||||||
|
assert_eq!(port_of("http://localhost:8080 (web build: trunk serve)"), Some(8080));
|
||||||
|
assert!(parse_setup(r#"{"start":"x","port":1,"isolated":false}"#).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -79,6 +79,15 @@ interface Issue {
|
|||||||
created_at: number;
|
created_at: number;
|
||||||
updated_at: number;
|
updated_at: number;
|
||||||
}
|
}
|
||||||
|
interface BacklogIssue {
|
||||||
|
repo: string;
|
||||||
|
number: number;
|
||||||
|
title: string;
|
||||||
|
author: string;
|
||||||
|
url: string;
|
||||||
|
allowed: boolean;
|
||||||
|
labels: string[];
|
||||||
|
}
|
||||||
interface Run {
|
interface Run {
|
||||||
id: string;
|
id: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
@@ -188,10 +197,21 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [recreate, setRecreate] = useState(false);
|
const [recreate, setRecreate] = useState(false);
|
||||||
|
|
||||||
const reload = () =>
|
const [backlog, setBacklog] = useState<BacklogIssue[]>([]);
|
||||||
get<Overview>("/factory/overview")
|
const [backlogErrors, setBacklogErrors] = useState<string[]>([]);
|
||||||
|
const loadBacklog = (refresh = false) =>
|
||||||
|
get<{ issues: BacklogIssue[]; errors: string[] }>(`/factory/backlog${refresh ? "?refresh=1" : ""}`)
|
||||||
|
.then((r) => {
|
||||||
|
setBacklog(r.issues);
|
||||||
|
setBacklogErrors(r.errors);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
const reload = () => {
|
||||||
|
void loadBacklog();
|
||||||
|
return get<Overview>("/factory/overview")
|
||||||
.then(setData)
|
.then(setData)
|
||||||
.catch((e) => toast(e.message));
|
.catch((e) => toast(e.message));
|
||||||
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void reload();
|
void reload();
|
||||||
const h = setInterval(() => {
|
const h = setInterval(() => {
|
||||||
@@ -263,6 +283,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const issues = useMemo(() => (data?.issues ?? []).filter((i) => !repo || i.repo === repo), [data, repo]);
|
const issues = useMemo(() => (data?.issues ?? []).filter((i) => !repo || i.repo === repo), [data, repo]);
|
||||||
|
const backlogShown = useMemo(() => backlog.filter((i) => !repo || i.repo === repo), [backlog, repo]);
|
||||||
|
/** Put backlog issues into the process (they get the factory label on the forge). */
|
||||||
|
const enqueue = async (items: BacklogIssue[]) => {
|
||||||
|
if (items.length === 0) return;
|
||||||
|
if (items.length > 1 && !(await confirmDialog({ message: t("factory.backlog.allConfirm", { n: items.length }), confirmLabel: t("factory.backlog.queueAll") }))) return;
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
for (const r of [...new Set(items.map((i) => i.repo))]) {
|
||||||
|
const res = await post<{ queued: number[]; errors: { number: number; error: string }[] }>("/factory/backlog/enqueue", { repo: r, numbers: items.filter((i) => i.repo === r).map((i) => i.number) });
|
||||||
|
for (const e of res.errors) toast(`#${e.number}: ${e.error}`);
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
toast(e.message);
|
||||||
|
}
|
||||||
|
setBusy(false);
|
||||||
|
await loadBacklog(true);
|
||||||
|
await reload();
|
||||||
|
};
|
||||||
const runs = useMemo(() => (data?.runs ?? []).filter((r) => !repo || r.repo === repo), [data, repo]);
|
const runs = useMemo(() => (data?.runs ?? []).filter((r) => !repo || r.repo === repo), [data, repo]);
|
||||||
const selected = issues.find((i) => `${i.repo}#${i.number}` === sel);
|
const selected = issues.find((i) => `${i.repo}#${i.number}` === sel);
|
||||||
const [pr, setPr] = useState<PrInfo | null>(null);
|
const [pr, setPr] = useState<PrInfo | null>(null);
|
||||||
@@ -462,6 +500,31 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="factory-board">
|
<div className="factory-board">
|
||||||
|
<div className="factory-col backlog">
|
||||||
|
<h4>
|
||||||
|
{t("factory.col.backlog")} <span className="chip">{backlogShown.length}</span>
|
||||||
|
</h4>
|
||||||
|
{backlogShown.length > 1 && (
|
||||||
|
<button className="small" onClick={() => void enqueue(backlogShown.filter((i) => i.allowed))} disabled={busy || !backlogShown.some((i) => i.allowed)} title={t("factory.backlog.queueAllHint")}>
|
||||||
|
<Icon name="plus" /> {t("factory.backlog.queueAll")}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{backlogShown.map((i) => (
|
||||||
|
<div key={`${i.repo}#${i.number}`} className="factory-card backlog">
|
||||||
|
<span className="hint">
|
||||||
|
{repoName(i.repo)} #{i.number} · {i.author}
|
||||||
|
</span>
|
||||||
|
<a href={i.url || issueUrl(i.repo, i.number)} target="_blank" rel="noreferrer">
|
||||||
|
<b>{i.title || `#${i.number}`}</b>
|
||||||
|
</a>
|
||||||
|
<button className="small" onClick={() => void enqueue([i])} disabled={busy || !i.allowed} title={i.allowed ? t("factory.backlog.queueHint") : t("factory.backlog.notAllowed", { user: i.author })}>
|
||||||
|
<Icon name="plus" /> {t("factory.backlog.queue")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{backlogShown.length === 0 && <span className="hint">{t("factory.backlog.empty")}</span>}
|
||||||
|
{backlogErrors.length > 0 && <span className="hint" title={backlogErrors.join("\n")}>{t("factory.backlog.error")}</span>}
|
||||||
|
</div>
|
||||||
{COLUMNS.map((c) => {
|
{COLUMNS.map((c) => {
|
||||||
const cards = issues.filter((i) => c.states.includes(i.state));
|
const cards = issues.filter((i) => c.states.includes(i.state));
|
||||||
return (
|
return (
|
||||||
@@ -475,7 +538,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
const latest = active ?? rs[0];
|
const latest = active ?? rs[0];
|
||||||
const tokens = rs.reduce((a, r) => a + r.input_tokens + r.output_tokens, 0);
|
const tokens = rs.reduce((a, r) => a + r.input_tokens + r.output_tokens, 0);
|
||||||
return (
|
return (
|
||||||
<button key={`${i.repo}#${i.number}`} className={`factory-card ${sel === `${i.repo}#${i.number}` ? "active" : ""} ${active ? "running" : ""}`} onClick={() => setSel(sel === `${i.repo}#${i.number}` ? "" : `${i.repo}#${i.number}`)}>
|
<button key={`${i.repo}#${i.number}`} data-state={i.state} className={`factory-card ${sel === `${i.repo}#${i.number}` ? "active" : ""} ${active ? "running" : ""}`} onClick={() => setSel(sel === `${i.repo}#${i.number}` ? "" : `${i.repo}#${i.number}`)}>
|
||||||
<span className="hint">
|
<span className="hint">
|
||||||
{repoName(i.repo)} #{i.number}
|
{repoName(i.repo)} #{i.number}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1226,6 +1226,15 @@ export const de: Messages = {
|
|||||||
"factory.repoLine": "{n} Issues · {run} laufen",
|
"factory.repoLine": "{n} Issues · {run} laufen",
|
||||||
"factory.noToken": "kein Token",
|
"factory.noToken": "kein Token",
|
||||||
"factory.pollNow": "Jetzt prüfen",
|
"factory.pollNow": "Jetzt prüfen",
|
||||||
|
"factory.backlog.queue": "Einreihen",
|
||||||
|
"factory.backlog.queueAll": "Alle einreihen",
|
||||||
|
"factory.backlog.queueHint": "Dem Issue das Factory-Label geben, damit es in den Prozess kommt",
|
||||||
|
"factory.backlog.queueAllHint": "Alle Issues dieser Liste einreihen",
|
||||||
|
"factory.backlog.allConfirm": "{n} Issues einreihen? Sie bekommen das Factory-Label im Forge und werden nacheinander geprüft.",
|
||||||
|
"factory.backlog.notAllowed": "{user} darf keine Factory-Issues anlegen (Repository-Einstellungen → erlaubte Nutzer)",
|
||||||
|
"factory.backlog.empty": "Keine offenen Issues außerhalb der Factory",
|
||||||
|
"factory.backlog.error": "Der Forge konnte für einige Projekte nicht gelesen werden",
|
||||||
|
"factory.col.backlog": "Backlog",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1225,6 +1225,15 @@ export const en = {
|
|||||||
"factory.repoLine": "{n} issues · {run} running",
|
"factory.repoLine": "{n} issues · {run} running",
|
||||||
"factory.noToken": "no token",
|
"factory.noToken": "no token",
|
||||||
"factory.pollNow": "Check now",
|
"factory.pollNow": "Check now",
|
||||||
|
"factory.backlog.queue": "Queue",
|
||||||
|
"factory.backlog.queueAll": "Queue all",
|
||||||
|
"factory.backlog.queueHint": "Give the issue the factory label so that it enters the process",
|
||||||
|
"factory.backlog.queueAllHint": "Queue all issues of this list",
|
||||||
|
"factory.backlog.allConfirm": "Queue {n} issues? They get the factory label on the forge and are reviewed one after another.",
|
||||||
|
"factory.backlog.notAllowed": "{user} is not allowed to file factory issues (repository settings → allowed users)",
|
||||||
|
"factory.backlog.empty": "No open issues outside the factory",
|
||||||
|
"factory.backlog.error": "The forge could not be read for some projects",
|
||||||
|
"factory.col.backlog": "Backlog",
|
||||||
"factory.col.review": "Review",
|
"factory.col.review": "Review",
|
||||||
"factory.col.question": "Questions",
|
"factory.col.question": "Questions",
|
||||||
"factory.col.approved": "Approved",
|
"factory.col.approved": "Approved",
|
||||||
|
|||||||
@@ -5107,6 +5107,46 @@ td.fold-indent {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
}
|
}
|
||||||
|
/* A faint tint by status, also on the border; --tone is set per state. */
|
||||||
|
.factory-card[data-state] {
|
||||||
|
--tone: var(--muted);
|
||||||
|
border-color: color-mix(in srgb, var(--tone) 50%, var(--bg2));
|
||||||
|
background: color-mix(in srgb, var(--tone) 7%, var(--bg0));
|
||||||
|
}
|
||||||
|
.factory-card[data-state="new"],
|
||||||
|
.factory-card[data-state="review"] {
|
||||||
|
--tone: var(--aqua);
|
||||||
|
}
|
||||||
|
.factory-card[data-state="question"] {
|
||||||
|
--tone: var(--accent);
|
||||||
|
}
|
||||||
|
.factory-card[data-state="approved"] {
|
||||||
|
--tone: var(--blue);
|
||||||
|
}
|
||||||
|
.factory-card[data-state="building"],
|
||||||
|
.factory-card[data-state="rework"] {
|
||||||
|
--tone: var(--purple);
|
||||||
|
}
|
||||||
|
.factory-card[data-state="qa"],
|
||||||
|
.factory-card[data-state="testing"] {
|
||||||
|
--tone: var(--accent2);
|
||||||
|
}
|
||||||
|
.factory-card[data-state="failed"],
|
||||||
|
.factory-card[data-state="rejected"] {
|
||||||
|
--tone: var(--red);
|
||||||
|
}
|
||||||
|
.factory-card[data-state="done"] {
|
||||||
|
--tone: var(--green);
|
||||||
|
}
|
||||||
|
.factory-card.backlog {
|
||||||
|
gap: 4px;
|
||||||
|
border-style: dashed;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
.factory-card.backlog a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
.factory-card.active {
|
.factory-card.active {
|
||||||
border-color: var(--accent);
|
border-color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
* 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-00069": {
|
||||||
|
en: ["Factory: backlog column with all open issues of the forge – queue them into the process with one click", "Factory: issue cards are faintly tinted by status, including the border"],
|
||||||
|
de: ["Factory: Backlog-Spalte mit allen offenen Issues des Forges – mit einem Klick in den Prozess einreihen", "Factory: Issue-Karten sind dezent nach Status eingefärbt, auch der Rahmen"],
|
||||||
|
},
|
||||||
|
"202611-00068": {
|
||||||
|
en: ["Test runner: \"isolated\": false in .factory/setup.json for apps that cannot run in a container"],
|
||||||
|
de: ["Test-Runner: \"isolated\": false in .factory/setup.json für Apps, die nicht im Container laufen können"],
|
||||||
|
},
|
||||||
"202611-00067": {
|
"202611-00067": {
|
||||||
en: ["Factory: acceptance runs can use throw-away containers (optional test runner service) for the app and helper services such as a database"],
|
en: ["Factory: acceptance runs can use throw-away containers (optional test runner service) for the app and helper services such as a database"],
|
||||||
de: ["Factory: Abnahmeläufe können Wegwerf-Container nutzen (optionaler Test-Runner-Dienst) für die App und Hilfsdienste wie eine Datenbank"],
|
de: ["Factory: Abnahmeläufe können Wegwerf-Container nutzen (optionaler Test-Runner-Dienst) für die App und Hilfsdienste wie eine Datenbank"],
|
||||||
|
|||||||
Reference in new issue
Block a user