Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d896356cac | ||
|
|
73684253ce | ||
|
|
6eb29ca19d | ||
|
|
707c9fc4cd | ||
|
|
5e2454ae3d | ||
|
|
9913a202ec | ||
|
|
738b39584d | ||
|
|
ccad2c1f6e | ||
|
|
45503de195 | ||
|
|
486c49d50b |
No files matched your search
@@ -3,6 +3,35 @@
|
|||||||
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-00066] – 2026-11-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Terminal client: steer the server.** `/projects` lists your chats on the server and opens one in the terminal – the agent keeps running on the server; you read along, send messages, answer permissions and questions, interrupt and compact. `/factory` shows the factory board and lets you merge pull requests, close, restart or remove issues and open the chat of any run; `/factory check` polls for new issues. `/local` returns to the local chat.
|
||||||
|
|
||||||
|
## [v202611-00065] – 2026-11-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Terminal client for Linux riscv64** – built with every release alongside x86_64 and aarch64; `install.sh` and `codecraft update` pick it up (`/cli/download/linux-riscv64`).
|
||||||
|
|
||||||
|
## [v202611-00064] – 2026-11-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Factory: Telegram message when an issue needs you** – a question from the review (with the questions) or a failure (build blocked, build/acceptance failed, rework limit reached) is sent to the paired Telegram chat, in the language of your web UI, with a link to the issue. Nothing is sent without a paired bot. (v202611-00063 was tagged but never built; this ships with the next release.)
|
||||||
|
- **Telegram notification settings** (Settings → Telegram): a switch for the factory alerts and a **night mode** (default 22:00–06:00, adjustable, server time) in which nothing is sent on CodeCraft's own initiative – no factory alerts and no approvals/questions from other chats; the chat you are talking to in Telegram keeps answering. Held-back messages are not repeated later.
|
||||||
|
|
||||||
|
## [v202611-00062] – 2026-11-18
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Factory: remove issues from the board** – a "Remove from board" button for issues that are not running, and issues deleted on the forge (404) disappear from the board by themselves at the next poll.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Factory: the "parallel" limit was exceeded** – phases were counted by their run rows, which appear only after the checkout, so one poll could start more phases than allowed (2 allowed, 4 running). They are now counted by issue state, which is set before a phase starts.
|
||||||
|
|
||||||
## [v202611-00061] – 2026-11-18
|
## [v202611-00061] – 2026-11-18
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
+5
-3
@@ -52,7 +52,7 @@ RUN touch core/src/lib.rs server/src/main.rs \
|
|||||||
&& cargo zigbuild --release -p codecraft --target "$(cat /target).2.36" \
|
&& cargo zigbuild --release -p codecraft --target "$(cat /target).2.36" \
|
||||||
&& cp "target/$(cat /target)/release/codecraft" /codecraft
|
&& cp "target/$(cat /target)/release/codecraft" /codecraft
|
||||||
|
|
||||||
# --- terminal client (static Linux binaries for x86_64 and aarch64) -----------
|
# --- terminal client (static Linux binaries for x86_64, aarch64 and riscv64) -----------
|
||||||
# Served by the server for download (/cli/install.sh, codecraft update).
|
# Served by the server for download (/cli/install.sh, codecraft update).
|
||||||
FROM toolchain AS cli
|
FROM toolchain AS cli
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
@@ -62,10 +62,12 @@ COPY server/resources ./server/resources
|
|||||||
COPY cli ./cli
|
COPY cli ./cli
|
||||||
ARG CODECRAFT_VERSION=""
|
ARG CODECRAFT_VERSION=""
|
||||||
ENV CODECRAFT_VERSION=${CODECRAFT_VERSION}
|
ENV CODECRAFT_VERSION=${CODECRAFT_VERSION}
|
||||||
|
RUN rustup target add riscv64gc-unknown-linux-musl
|
||||||
RUN mkdir -p server/src && echo 'fn main(){}' > server/src/main.rs \
|
RUN mkdir -p server/src && echo 'fn main(){}' > server/src/main.rs \
|
||||||
&& cargo zigbuild --release -p codecraft-cli --target x86_64-unknown-linux-musl --target aarch64-unknown-linux-musl \
|
&& cargo zigbuild --release -p codecraft-cli --target x86_64-unknown-linux-musl --target aarch64-unknown-linux-musl --target riscv64gc-unknown-linux-musl \
|
||||||
&& mkdir -p /out && cp target/x86_64-unknown-linux-musl/release/codecraft /out/codecraft-linux-x86_64 \
|
&& mkdir -p /out && cp target/x86_64-unknown-linux-musl/release/codecraft /out/codecraft-linux-x86_64 \
|
||||||
&& cp target/aarch64-unknown-linux-musl/release/codecraft /out/codecraft-linux-aarch64
|
&& cp target/aarch64-unknown-linux-musl/release/codecraft /out/codecraft-linux-aarch64 \
|
||||||
|
&& cp target/riscv64gc-unknown-linux-musl/release/codecraft /out/codecraft-linux-riscv64
|
||||||
|
|
||||||
# --- Docker CLI (static client; the daemon is the host's via the mounted socket) --
|
# --- Docker CLI (static client; the daemon is the host's via the mounted socket) --
|
||||||
FROM toolchain AS dockercli
|
FROM toolchain AS dockercli
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Version v202611-00061" src="https://img.shields.io/badge/version-v202611--00061-d69e2e?style=flat-square">
|
<img alt="Version v202611-00066" src="https://img.shields.io/badge/version-v202611--00066-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">
|
||||||
@@ -205,12 +205,21 @@ Anthropic, OpenAI, Gemini, OpenRouter, opencode or a local model server (Ollama,
|
|||||||
llama.cpp, vLLM – detected automatically); both can be mixed.
|
llama.cpp, vLLM – detected automatically); both can be mixed.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fsSL https://<your-codecraft-server>/cli/install.sh | sh # Linux x86_64 / aarch64
|
curl -fsSL https://<your-codecraft-server>/cli/install.sh | sh # Linux x86_64 / aarch64 / riscv64
|
||||||
codecraft login # server URL, user name, password → creates an API token
|
codecraft login # server URL, user name, password → creates an API token
|
||||||
codecraft # start in the current folder; /help lists the commands
|
codecraft # start in the current folder; /help lists the commands
|
||||||
```
|
```
|
||||||
|
|
||||||
The Docker image ships static binaries for Linux x86_64 and aarch64; the server offers them
|
Signed in to a server, the terminal also steers the server itself:
|
||||||
|
|
||||||
|
- `/projects` lists your chats on the server; open one and follow it – the agent keeps running **on the
|
||||||
|
server**, in the server's folder – and answer its permission requests and questions, send messages, interrupt
|
||||||
|
it (<kbd>Esc</kbd>) and `/compact` it. `/local` returns to a local chat. The view refreshes every second or two.
|
||||||
|
- `/factory` shows the factory board (issues by phase with their latest run, totals and cost) and offers per
|
||||||
|
issue: open the chat of a run, merge the pull request (merge, squash or rebase), close the issue, restart it at
|
||||||
|
the review, build or acceptance, or remove it from the board. `/factory check` looks for new issues right away.
|
||||||
|
|
||||||
|
The Docker image ships static binaries for Linux x86_64, aarch64 and riscv64; the server offers them
|
||||||
for download (*Settings → Account*) and `codecraft update` fetches new versions from it. Other
|
for download (*Settings → Account*) and `codecraft update` fetches new versions from it. Other
|
||||||
platforms: `cargo install --locked --git https://git.familie-zink.org/zink/codecraft codecraft-cli`.
|
platforms: `cargo install --locked --git https://git.familie-zink.org/zink/codecraft codecraft-cli`.
|
||||||
|
|
||||||
|
|||||||
+306
-7
@@ -3,6 +3,7 @@
|
|||||||
use crate::agent::{Env, Reply, UiEvent};
|
use crate::agent::{Env, Reply, UiEvent};
|
||||||
use crate::editor::Editor;
|
use crate::editor::Editor;
|
||||||
use crate::i18n::t;
|
use crate::i18n::t;
|
||||||
|
use crate::remote::{self, Remote, Snapshot};
|
||||||
use crate::session::LocalSession;
|
use crate::session::LocalSession;
|
||||||
use crate::theme::{self, Theme};
|
use crate::theme::{self, Theme};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@@ -61,6 +62,11 @@ enum PickKind {
|
|||||||
Permission,
|
Permission,
|
||||||
Effort,
|
Effort,
|
||||||
Lang,
|
Lang,
|
||||||
|
/// Chats of the server.
|
||||||
|
Remote,
|
||||||
|
/// Issues of the factory board / the actions for one issue.
|
||||||
|
FactoryIssue,
|
||||||
|
FactoryAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Picker {
|
struct Picker {
|
||||||
@@ -129,6 +135,14 @@ pub struct App {
|
|||||||
/// Running setup action (login / provider test): Ok(message) or error.
|
/// Running setup action (login / provider test): Ok(message) or error.
|
||||||
pending_setup: Option<oneshot::Receiver<Result<String>>>,
|
pending_setup: Option<oneshot::Receiver<Result<String>>>,
|
||||||
pending_env: Option<oneshot::Receiver<Result<Env>>>,
|
pending_env: Option<oneshot::Receiver<Result<Env>>>,
|
||||||
|
/// A chat of the server that this terminal follows (instead of the local session).
|
||||||
|
remote: Option<Remote>,
|
||||||
|
pending_snapshot: Option<oneshot::Receiver<Result<Snapshot>>>,
|
||||||
|
pending_open: Option<oneshot::Receiver<Result<Remote>>>,
|
||||||
|
pending_pick: Option<oneshot::Receiver<Result<(PickKind, String, Vec<(String, String, String)>)>>>,
|
||||||
|
pending_note: Option<oneshot::Receiver<Result<String>>>,
|
||||||
|
/// The factory issue ("repo#number") whose actions are open.
|
||||||
|
factory_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
const SPINNER: &[&str] = &["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
const SPINNER: &[&str] = &["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
||||||
@@ -317,6 +331,12 @@ impl App {
|
|||||||
pending_detect: None,
|
pending_detect: None,
|
||||||
pending_setup: None,
|
pending_setup: None,
|
||||||
pending_env: None,
|
pending_env: None,
|
||||||
|
remote: None,
|
||||||
|
pending_snapshot: None,
|
||||||
|
pending_open: None,
|
||||||
|
pending_pick: None,
|
||||||
|
pending_note: None,
|
||||||
|
factory_key: String::new(),
|
||||||
};
|
};
|
||||||
app.rebuild_items();
|
app.rebuild_items();
|
||||||
app
|
app
|
||||||
@@ -446,6 +466,10 @@ impl App {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let text = self.expand_command(&trimmed).unwrap_or(trimmed);
|
let text = self.expand_command(&trimmed).unwrap_or(trimmed);
|
||||||
|
if self.remote.is_some() {
|
||||||
|
self.send_remote(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if self.busy {
|
if self.busy {
|
||||||
self.queue.push_back(text);
|
self.queue.push_back(text);
|
||||||
self.status = format!("{} ({})", t("queued"), self.queue.len());
|
self.status = format!("{} ({})", t("queued"), self.queue.len());
|
||||||
@@ -527,6 +551,9 @@ impl App {
|
|||||||
("setup", "add model providers or sign in to a server"),
|
("setup", "add model providers or sign in to a server"),
|
||||||
("memory", "show the project memory"),
|
("memory", "show the project memory"),
|
||||||
("jobs", "automations on the server"),
|
("jobs", "automations on the server"),
|
||||||
|
("projects", "chats on the server: open and steer them"),
|
||||||
|
("factory", "software factory of the server: board and actions"),
|
||||||
|
("local", "back to a local chat"),
|
||||||
("quit", "exit"),
|
("quit", "exit"),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -545,6 +572,21 @@ impl App {
|
|||||||
}
|
}
|
||||||
self.dialog = Dialog::Text { title: t("help").into(), body };
|
self.dialog = Dialog::Text { title: t("help").into(), body };
|
||||||
}
|
}
|
||||||
|
"projects" | "server" => self.fetch_pick(PickKind::Remote),
|
||||||
|
"factory" if arg == "check" => {
|
||||||
|
if let Some(server) = self.env.server.clone() {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::factory_poll(&server).await);
|
||||||
|
});
|
||||||
|
self.pending_note = Some(rx);
|
||||||
|
} else {
|
||||||
|
self.items.push(Item::Error("not signed in to a server".into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"factory" => self.fetch_pick(PickKind::FactoryIssue),
|
||||||
|
"local" => self.leave_remote(),
|
||||||
|
"model" | "mode" | "permissions" | "effort" if self.remote.is_some() => self.items.push(Item::Info("this chat runs on the server – change this in the web interface (/local returns to a local chat)".into())),
|
||||||
"model" => self.open_picker(PickKind::Model),
|
"model" => self.open_picker(PickKind::Model),
|
||||||
"mode" => {
|
"mode" => {
|
||||||
if arg.is_empty() {
|
if arg.is_empty() {
|
||||||
@@ -558,7 +600,18 @@ impl App {
|
|||||||
"theme" => self.open_picker(PickKind::Theme),
|
"theme" => self.open_picker(PickKind::Theme),
|
||||||
"lang" => self.open_picker(PickKind::Lang),
|
"lang" => self.open_picker(PickKind::Lang),
|
||||||
"resume" | "sessions" => self.open_picker(PickKind::Session),
|
"resume" | "sessions" => self.open_picker(PickKind::Session),
|
||||||
|
"compact" if self.remote.is_some() => {
|
||||||
|
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::compact(&server, &id).await.map(|_| "compacting on the server…".to_string()));
|
||||||
|
});
|
||||||
|
self.pending_note = Some(rx);
|
||||||
|
}
|
||||||
|
}
|
||||||
"new" | "clear" => {
|
"new" | "clear" => {
|
||||||
|
self.remote = None;
|
||||||
let _ = self.cmd.send(Cmd::New);
|
let _ = self.cmd.send(Cmd::New);
|
||||||
self.session = LocalSession::new(&self.session.cwd, &self.session.model, &self.session.mode, &self.session.permission_mode);
|
self.session = LocalSession::new(&self.session.cwd, &self.session.model, &self.session.mode, &self.session.permission_mode);
|
||||||
self.items.clear();
|
self.items.clear();
|
||||||
@@ -638,6 +691,7 @@ impl App {
|
|||||||
PickKind::Effort => ("Effort".into(), ["low", "medium", "high", "max"].iter().map(|e| (e.to_string(), e.to_string(), "next message only".into())).collect()),
|
PickKind::Effort => ("Effort".into(), ["low", "medium", "high", "max"].iter().map(|e| (e.to_string(), e.to_string(), "next message only".into())).collect()),
|
||||||
PickKind::Theme => (t("choose_theme").into(), theme::names().into_iter().flat_map(|n| ["auto", "dark", "light"].map(|m| (format!("{n}:{m}"), format!("{n} ({m})"), String::new()))).collect()),
|
PickKind::Theme => (t("choose_theme").into(), theme::names().into_iter().flat_map(|n| ["auto", "dark", "light"].map(|m| (format!("{n}:{m}"), format!("{n} ({m})"), String::new()))).collect()),
|
||||||
PickKind::Lang => ("Language".into(), vec![("en".into(), "English".into(), String::new()), ("de".into(), "Deutsch".into(), String::new())]),
|
PickKind::Lang => ("Language".into(), vec![("en".into(), "English".into(), String::new()), ("de".into(), "Deutsch".into(), String::new())]),
|
||||||
|
PickKind::Remote | PickKind::FactoryIssue | PickKind::FactoryAction => return,
|
||||||
PickKind::Session => (
|
PickKind::Session => (
|
||||||
t("choose_session").into(),
|
t("choose_session").into(),
|
||||||
crate::session::list(None)
|
crate::session::list(None)
|
||||||
@@ -682,6 +736,12 @@ impl App {
|
|||||||
cfg.lang = Some(key);
|
cfg.lang = Some(key);
|
||||||
let _ = cfg.save();
|
let _ = cfg.save();
|
||||||
}
|
}
|
||||||
|
PickKind::Remote => self.open_remote(&key),
|
||||||
|
PickKind::FactoryIssue => {
|
||||||
|
self.factory_key = key.clone();
|
||||||
|
self.fetch_actions(&key);
|
||||||
|
}
|
||||||
|
PickKind::FactoryAction => self.factory_action(&key),
|
||||||
PickKind::Session => {
|
PickKind::Session => {
|
||||||
if let Ok(s) = LocalSession::load(&key) {
|
if let Ok(s) = LocalSession::load(&key) {
|
||||||
self.session = s.clone();
|
self.session = s.clone();
|
||||||
@@ -694,6 +754,245 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- server: remote chats and the factory ----------------------------------------------
|
||||||
|
|
||||||
|
fn abort_current(&mut self) {
|
||||||
|
if let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) {
|
||||||
|
let id = r.id.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = remote::abort(&server, &id).await;
|
||||||
|
});
|
||||||
|
} else if let Some(c) = &self.cancel {
|
||||||
|
c.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch the entries of a server picker in the background; the picker opens when they arrive.
|
||||||
|
fn fetch_pick(&mut self, kind: PickKind) {
|
||||||
|
let Some(server) = self.env.server.clone() else {
|
||||||
|
self.items.push(Item::Error("not signed in to a server – run: codecraft login".into()));
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
self.status = "loading…".into();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let res = match kind {
|
||||||
|
PickKind::Remote => remote::sessions(&server).await.map(|items| (kind, "Chats on the server".to_string(), items)),
|
||||||
|
_ => remote::factory_board(&server).await.map(|(summary, items)| (kind, summary, items)),
|
||||||
|
};
|
||||||
|
let _ = tx.send(res);
|
||||||
|
});
|
||||||
|
self.pending_pick = Some(rx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fetch_actions(&mut self, key: &str) {
|
||||||
|
let Some(server) = self.env.server.clone() else { return };
|
||||||
|
let key = key.to_string();
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::factory_actions(&server, &key).await.map(|(title, acts)| (PickKind::FactoryAction, title, acts)));
|
||||||
|
});
|
||||||
|
self.pending_pick = Some(rx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn factory_action(&mut self, action: &str) {
|
||||||
|
if let Some(id) = action.strip_prefix("chat:") {
|
||||||
|
self.open_remote(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let Some(server) = self.env.server.clone() else { return };
|
||||||
|
let (key, action) = (self.factory_key.clone(), action.to_string());
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::factory_do(&server, &key, &action).await);
|
||||||
|
});
|
||||||
|
self.pending_note = Some(rx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn open_remote(&mut self, id: &str) {
|
||||||
|
let Some(server) = self.env.server.clone() else { return };
|
||||||
|
let id = id.to_string();
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::open(&server, &id).await);
|
||||||
|
});
|
||||||
|
self.pending_open = Some(rx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn leave_remote(&mut self) {
|
||||||
|
if self.remote.take().is_some() {
|
||||||
|
self.items.clear();
|
||||||
|
self.todos = Value::Null;
|
||||||
|
self.busy = false;
|
||||||
|
self.rebuild_items();
|
||||||
|
self.status = "local chat".into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_remote(&mut self, text: String) {
|
||||||
|
let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) else { return };
|
||||||
|
let id = r.id.clone();
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::prompt(&server, &id, &text).await.map(|_| String::new()));
|
||||||
|
});
|
||||||
|
self.pending_note = Some(rx);
|
||||||
|
self.busy = true;
|
||||||
|
self.busy_since = Instant::now();
|
||||||
|
self.scroll = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Items of messages (shared by the local and the remote view).
|
||||||
|
fn items_of(messages: &[codecraft_core::types::Message], open: &std::collections::HashSet<String>) -> Vec<Item> {
|
||||||
|
let mut items = Vec::new();
|
||||||
|
for m in messages {
|
||||||
|
for p in &m.parts {
|
||||||
|
match (&m.role, p) {
|
||||||
|
(Role::User, Part::Text { text }) => items.push(Item::User(text.clone(), 0)),
|
||||||
|
(Role::User, Part::Summary { .. }) => items.push(Item::Info("— conversation compacted —".into())),
|
||||||
|
(_, Part::Text { text }) => items.push(Item::Assistant(text.clone())),
|
||||||
|
(_, Part::Reasoning { text, .. }) if !text.trim().is_empty() => items.push(Item::Thinking(text.clone(), false)),
|
||||||
|
(_, Part::ToolCall { id, name, input, .. }) => items.push(Item::Tool { id: id.clone(), name: name.clone(), title: tool_title(name, input), state: ToolState::Running, output: String::new(), diff: None, open: open.contains(id) }),
|
||||||
|
(_, Part::ToolResult { call_id, content, is_error, meta, .. }) => {
|
||||||
|
if let Some(Item::Tool { state, output, diff, .. }) = items.iter_mut().rev().find(|i| matches!(i, Item::Tool { id, .. } if id == call_id)) {
|
||||||
|
*state = if *is_error { ToolState::Err } else { ToolState::Ok };
|
||||||
|
*output = content.clone();
|
||||||
|
*diff = meta.as_ref().and_then(|m| m["diff"].as_str().map(String::from));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Poll the followed server chat every ~1.5 s and take up the results of background requests.
|
||||||
|
fn poll_remote(&mut self) {
|
||||||
|
if let Some(rx) = &mut self.pending_pick {
|
||||||
|
if let Ok(res) = rx.try_recv() {
|
||||||
|
self.pending_pick = None;
|
||||||
|
self.status.clear();
|
||||||
|
match res {
|
||||||
|
Ok((kind, title, items)) if items.is_empty() => {
|
||||||
|
let _ = kind;
|
||||||
|
self.items.push(Item::Info(format!("{title}: nothing to show")));
|
||||||
|
}
|
||||||
|
Ok((kind, title, items)) => self.dialog = Dialog::Picker(Picker { kind, title, items, filter: String::new(), sel: 0 }),
|
||||||
|
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(rx) = &mut self.pending_note {
|
||||||
|
if let Ok(res) = rx.try_recv() {
|
||||||
|
self.pending_note = None;
|
||||||
|
match res {
|
||||||
|
Ok(msg) if !msg.is_empty() => self.items.push(Item::Info(msg)),
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(rx) = &mut self.pending_open {
|
||||||
|
if let Ok(res) = rx.try_recv() {
|
||||||
|
self.pending_open = None;
|
||||||
|
match res {
|
||||||
|
Ok(r) => {
|
||||||
|
self.items.clear();
|
||||||
|
self.items.push(Item::Info(format!("server chat: {} · {} · {} · {} – /local returns", r.title, r.agent, r.model, r.cwd)));
|
||||||
|
self.todos = Value::Null;
|
||||||
|
self.busy = false;
|
||||||
|
self.dialog = Dialog::None;
|
||||||
|
self.remote = Some(r);
|
||||||
|
self.pending_snapshot = None;
|
||||||
|
}
|
||||||
|
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let Some(server) = self.env.server.clone() else { return };
|
||||||
|
let Some(r) = &mut self.remote else { return };
|
||||||
|
if let Some(rx) = &mut self.pending_snapshot {
|
||||||
|
if let Ok(res) = rx.try_recv() {
|
||||||
|
self.pending_snapshot = None;
|
||||||
|
match res {
|
||||||
|
Ok(snap) => {
|
||||||
|
let open: std::collections::HashSet<String> = self.items.iter().filter_map(|i| if let Item::Tool { id, open: true, .. } = i { Some(id.clone()) } else { None }).collect();
|
||||||
|
let was_busy = self.busy;
|
||||||
|
let at_end = self.scroll == 0;
|
||||||
|
let mut items = Self::items_of(&snap.messages, &open);
|
||||||
|
// Tool calls without a result are still running only while the chat is busy.
|
||||||
|
if !snap.busy {
|
||||||
|
for i in items.iter_mut() {
|
||||||
|
if let Item::Tool { state, .. } = i {
|
||||||
|
if matches!(state, ToolState::Running) {
|
||||||
|
*state = ToolState::Err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let head = self.items.first().filter(|i| matches!(i, Item::Info(s) if s.starts_with("server chat:"))).map(|i| if let Item::Info(s) = i { s.clone() } else { String::new() });
|
||||||
|
self.items = head.map(Item::Info).into_iter().chain(items).collect();
|
||||||
|
self.busy = snap.busy;
|
||||||
|
if snap.busy && !was_busy {
|
||||||
|
self.busy_since = Instant::now();
|
||||||
|
}
|
||||||
|
self.todos = snap.todos.clone();
|
||||||
|
if !snap.title.is_empty() {
|
||||||
|
r.title = snap.title.clone();
|
||||||
|
}
|
||||||
|
if at_end {
|
||||||
|
self.scroll = 0;
|
||||||
|
}
|
||||||
|
// Requests that wait for an answer (permissions and questions of this chat).
|
||||||
|
if matches!(self.dialog, Dialog::None) {
|
||||||
|
if let Some(ev) = snap.pending.iter().find(|e| e["id"].as_str().is_some_and(|id| !r.answered.contains(id))) {
|
||||||
|
let id = ev["id"].as_str().unwrap_or("").to_string();
|
||||||
|
r.answered.insert(id.clone());
|
||||||
|
if ev["type"] == "permission_request" {
|
||||||
|
let (tx, rx) = oneshot::channel::<Reply>();
|
||||||
|
let srv = server.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Ok(reply) = rx.await {
|
||||||
|
let (kind, msg) = match reply {
|
||||||
|
Reply::Once => ("once", None),
|
||||||
|
Reply::Always => ("always", None),
|
||||||
|
Reply::Reject(m) => ("reject", m),
|
||||||
|
};
|
||||||
|
let _ = remote::reply_permission(&srv, &id, kind, msg).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.dialog = Dialog::Permission { tool: ev["tool"].as_str().unwrap_or("").into(), title: ev["title"].as_str().unwrap_or("").into(), diff: ev["diff"].as_str().map(String::from), input: ev["input"].clone(), reply: Some(tx), feedback: None };
|
||||||
|
} else if ev["type"] == "question_request" {
|
||||||
|
let questions: Vec<Question> = serde_json::from_value(ev["questions"].clone()).unwrap_or_default();
|
||||||
|
if !questions.is_empty() {
|
||||||
|
let (tx, rx) = oneshot::channel::<Option<serde_json::Map<String, Value>>>();
|
||||||
|
let srv = server.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Ok(answers) = rx.await {
|
||||||
|
let _ = remote::answer_question(&srv, &id, answers).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.dialog = Dialog::Question { questions, idx: 0, sel: 0, custom: String::new(), answers: Default::default(), reply: Some(tx) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => self.status = format!("server: {e:#}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if r.last_poll.elapsed() >= Duration::from_millis(1500) {
|
||||||
|
r.last_poll = Instant::now();
|
||||||
|
let id = r.id.clone();
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::snapshot(&server, &id).await);
|
||||||
|
});
|
||||||
|
self.pending_snapshot = Some(rx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- setup wizard ---------------------------------------------------------------
|
// --- setup wizard ---------------------------------------------------------------
|
||||||
|
|
||||||
fn open_setup(&mut self) {
|
fn open_setup(&mut self) {
|
||||||
@@ -771,9 +1070,7 @@ impl App {
|
|||||||
match (k.code, ctrl) {
|
match (k.code, ctrl) {
|
||||||
(KeyCode::Char('c'), true) => {
|
(KeyCode::Char('c'), true) => {
|
||||||
if self.busy {
|
if self.busy {
|
||||||
if let Some(c) = &self.cancel {
|
self.abort_current();
|
||||||
c.cancel();
|
|
||||||
}
|
|
||||||
self.items.push(Item::Info(t("aborted").into()));
|
self.items.push(Item::Info(t("aborted").into()));
|
||||||
} else if !self.editor.is_empty() {
|
} else if !self.editor.is_empty() {
|
||||||
self.editor.clear();
|
self.editor.clear();
|
||||||
@@ -787,9 +1084,7 @@ impl App {
|
|||||||
(KeyCode::Char('d'), true) if self.editor.is_empty() => self.quit = true,
|
(KeyCode::Char('d'), true) if self.editor.is_empty() => self.quit = true,
|
||||||
(KeyCode::Esc, _) => {
|
(KeyCode::Esc, _) => {
|
||||||
if self.busy {
|
if self.busy {
|
||||||
if let Some(c) = &self.cancel {
|
self.abort_current();
|
||||||
c.cancel();
|
|
||||||
}
|
|
||||||
self.queue.clear();
|
self.queue.clear();
|
||||||
self.items.push(Item::Info(t("aborted").into()));
|
self.items.push(Item::Info(t("aborted").into()));
|
||||||
}
|
}
|
||||||
@@ -1147,6 +1442,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn poll_pending(&mut self) {
|
fn poll_pending(&mut self) {
|
||||||
|
self.poll_remote();
|
||||||
if let Some(rx) = &mut self.pending_detect {
|
if let Some(rx) = &mut self.pending_detect {
|
||||||
if let Ok(found) = rx.try_recv() {
|
if let Ok(found) = rx.try_recv() {
|
||||||
self.pending_detect = None;
|
self.pending_detect = None;
|
||||||
@@ -1398,7 +1694,10 @@ impl App {
|
|||||||
// Status line.
|
// Status line.
|
||||||
let ctx_pct = self.env.catalog.find(&self.session.model).and_then(|m| m.config.context).filter(|c| *c > 0).map(|c| format!("{} {}%", t("context"), self.context * 100 / c)).unwrap_or_default();
|
let ctx_pct = self.env.catalog.find(&self.session.model).and_then(|m| m.config.context).filter(|c| *c > 0).map(|c| format!("{} {}%", t("context"), self.context * 100 / c)).unwrap_or_default();
|
||||||
let cost = if self.session.cost > 0.0 { format!(" · {:.3} {}", self.session.cost, self.env.catalog.currency) } else { String::new() };
|
let cost = if self.session.cost > 0.0 { format!(" · {:.3} {}", self.session.cost, self.env.catalog.currency) } else { String::new() };
|
||||||
let left = format!(" {} · {} ", self.model_label(), self.session.permission_mode);
|
let left = match &self.remote {
|
||||||
|
Some(r) => format!(" server · {} · {} ", r.model, r.agent),
|
||||||
|
None => format!(" {} · {} ", self.model_label(), self.session.permission_mode),
|
||||||
|
};
|
||||||
let right = format!("{ctx_pct}{cost} · Shift+Tab {} · /help ", t("mode"));
|
let right = format!("{ctx_pct}{cost} · Shift+Tab {} · /help ", t("mode"));
|
||||||
let pad = (area.width as usize).saturating_sub(left.chars().count() + right.chars().count());
|
let pad = (area.width as usize).saturating_sub(left.chars().count() + right.chars().count());
|
||||||
f.render_widget(Paragraph::new(Line::from(vec![Span::styled(left, Style::default().fg(th.fg3)), Span::raw(" ".repeat(pad)), Span::styled(right, Style::default().fg(th.muted))])).style(Style::default().bg(th.bg1)), status);
|
f.render_widget(Paragraph::new(Line::from(vec![Span::styled(left, Style::default().fg(th.fg3)), Span::raw(" ".repeat(pad)), Span::styled(right, Style::default().fg(th.muted))])).style(Style::default().bg(th.bg1)), status);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ mod conf;
|
|||||||
mod editor;
|
mod editor;
|
||||||
mod i18n;
|
mod i18n;
|
||||||
mod models;
|
mod models;
|
||||||
|
mod remote;
|
||||||
mod server;
|
mod server;
|
||||||
mod session;
|
mod session;
|
||||||
mod stats;
|
mod stats;
|
||||||
|
|||||||
@@ -0,0 +1,278 @@
|
|||||||
|
//! Remote control of the server: chats that run on the CodeCraft server (`/projects`) and the
|
||||||
|
//! software factory board (`/factory`). Everything goes through the server's REST API with the
|
||||||
|
//! login's token; the chat view polls every second or two instead of holding a socket open.
|
||||||
|
|
||||||
|
use crate::server::Server;
|
||||||
|
use anyhow::{Context, Result, bail};
|
||||||
|
use codecraft_core::types::Message;
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
|
/// How many messages of a remote chat are loaded (its end; older ones stay on the server).
|
||||||
|
const WINDOW: usize = 300;
|
||||||
|
|
||||||
|
/// A chat of the server that this terminal follows.
|
||||||
|
pub struct Remote {
|
||||||
|
pub id: String,
|
||||||
|
pub title: String,
|
||||||
|
pub cwd: String,
|
||||||
|
pub agent: String,
|
||||||
|
pub model: String,
|
||||||
|
pub last_poll: Instant,
|
||||||
|
/// Requests already answered here (the server confirms them with the next poll).
|
||||||
|
pub answered: HashSet<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// State of a remote chat at one moment.
|
||||||
|
pub struct Snapshot {
|
||||||
|
pub messages: Vec<Message>,
|
||||||
|
pub busy: bool,
|
||||||
|
pub title: String,
|
||||||
|
pub todos: Value,
|
||||||
|
/// Open permission and question requests of this chat (and its subagents).
|
||||||
|
pub pending: Vec<Value>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn short(s: &str, n: usize) -> String {
|
||||||
|
let t: String = s.chars().take(n).collect();
|
||||||
|
if s.chars().count() > n { format!("{t}…") } else { t }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ago(ms: i64) -> String {
|
||||||
|
let d = (chrono::Utc::now().timestamp_millis() - ms).max(0) / 1000;
|
||||||
|
match d {
|
||||||
|
0..=89 => "now".into(),
|
||||||
|
90..=5399 => format!("{} min ago", d / 60),
|
||||||
|
5400..=129_599 => format!("{} h ago", d / 3600),
|
||||||
|
_ => format!("{} d ago", d / 86_400),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The user's chats on the server as picker entries: (id, title, description). Busy chats first.
|
||||||
|
pub async fn sessions(server: &Server) -> Result<Vec<(String, String, String)>> {
|
||||||
|
let v = server.get("/sessions").await?;
|
||||||
|
let mut list: Vec<Value> = v.as_array().cloned().unwrap_or_default().into_iter().filter(|s| s["parent_id"].is_null() && s["archived"] != true).collect();
|
||||||
|
list.sort_by_key(|s| (!s["busy"].as_bool().unwrap_or(false), std::cmp::Reverse(s["updated_at"].as_i64().unwrap_or(0))));
|
||||||
|
Ok(list
|
||||||
|
.into_iter()
|
||||||
|
.take(200)
|
||||||
|
.map(|s| {
|
||||||
|
let title = s["title"].as_str().filter(|t| !t.is_empty()).unwrap_or("(untitled)").to_string();
|
||||||
|
let folder = s["folder"].as_str().filter(|f| !f.is_empty()).map(|f| format!("[{f}] ")).unwrap_or_default();
|
||||||
|
let cwd = s["cwd"].as_str().unwrap_or("").rsplit('/').next().unwrap_or("").to_string();
|
||||||
|
let state = if s["busy"].as_bool().unwrap_or(false) { "working · " } else { "" };
|
||||||
|
(s["id"].as_str().unwrap_or("").to_string(), format!("{folder}{title}"), format!("{state}{cwd} · {} · {}", s["agent"].as_str().unwrap_or(""), ago(s["updated_at"].as_i64().unwrap_or(0))))
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Load a chat: its end, whether it is working, its task list and what waits for an answer.
|
||||||
|
pub async fn snapshot(server: &Server, id: &str) -> Result<Snapshot> {
|
||||||
|
let path = format!("/sessions/{id}?limit={WINDOW}");
|
||||||
|
let (s, pending) = tokio::join!(server.get(&path), server.get("/pending"));
|
||||||
|
let s = s?;
|
||||||
|
let messages: Vec<Message> = serde_json::from_value(s["messages"].clone()).unwrap_or_default();
|
||||||
|
let pending = pending
|
||||||
|
.ok()
|
||||||
|
.and_then(|p| p.as_array().cloned())
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into_iter()
|
||||||
|
.filter(|e| e["session_id"].as_str() == Some(id) || e["root_session_id"].as_str() == Some(id))
|
||||||
|
.collect();
|
||||||
|
Ok(Snapshot { messages, busy: s["busy"].as_bool().unwrap_or(false), title: s["session"]["title"].as_str().unwrap_or("").to_string(), todos: s["session"]["todos"].clone(), pending })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn open(server: &Server, id: &str) -> Result<Remote> {
|
||||||
|
let s = server.get(&format!("/sessions/{id}?limit=1")).await?;
|
||||||
|
let s = &s["session"];
|
||||||
|
if s["id"].as_str().is_none() {
|
||||||
|
bail!("unknown chat");
|
||||||
|
}
|
||||||
|
Ok(Remote {
|
||||||
|
id: id.to_string(),
|
||||||
|
title: s["title"].as_str().unwrap_or("").to_string(),
|
||||||
|
cwd: s["cwd"].as_str().unwrap_or("").to_string(),
|
||||||
|
agent: s["agent"].as_str().unwrap_or("").to_string(),
|
||||||
|
model: s["model"].as_str().unwrap_or("").to_string(),
|
||||||
|
last_poll: Instant::now(),
|
||||||
|
answered: HashSet::new(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn prompt(server: &Server, id: &str, text: &str) -> Result<()> {
|
||||||
|
server.post(&format!("/sessions/{id}/prompt"), json!({"text": text})).await.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn abort(server: &Server, id: &str) -> Result<()> {
|
||||||
|
server.post(&format!("/sessions/{id}/abort"), json!({})).await.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn compact(server: &Server, id: &str) -> Result<()> {
|
||||||
|
server.post(&format!("/sessions/{id}/compact"), json!({})).await.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Answer a permission request. reply: once, always, project, reject.
|
||||||
|
pub async fn reply_permission(server: &Server, id: &str, reply: &str, message: Option<String>) -> Result<()> {
|
||||||
|
server.post(&format!("/permissions/{id}"), json!({"reply": reply, "message": message})).await.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn answer_question(server: &Server, id: &str, answers: Option<serde_json::Map<String, Value>>) -> Result<()> {
|
||||||
|
server.post(&format!("/questions/{id}"), json!({"answers": answers})).await.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- software factory ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// Column of the board for an issue state.
|
||||||
|
pub fn column(state: &str) -> &'static str {
|
||||||
|
match state {
|
||||||
|
"new" | "review" => "Review",
|
||||||
|
"question" => "Question",
|
||||||
|
"approved" => "Approved",
|
||||||
|
"building" | "rework" => "Build",
|
||||||
|
"qa" | "testing" => "Acceptance",
|
||||||
|
"failed" | "rejected" => "Failed",
|
||||||
|
"done" => "Done",
|
||||||
|
"closed" => "Closed",
|
||||||
|
_ => "Other",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn repo_name(url: &str) -> String {
|
||||||
|
url.trim_end_matches(".git").rsplit('/').take(2).collect::<Vec<_>>().into_iter().rev().collect::<Vec<_>>().join("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The board as picker entries (key "repo#number") and a summary line for the title.
|
||||||
|
pub async fn factory_board(server: &Server) -> Result<(String, Vec<(String, String, String)>)> {
|
||||||
|
let v = server.get("/factory/overview").await?;
|
||||||
|
let issues = v["issues"].as_array().cloned().unwrap_or_default();
|
||||||
|
let runs = v["runs"].as_array().cloned().unwrap_or_default();
|
||||||
|
let running = issues.iter().filter(|i| matches!(i["state"].as_str(), Some("review" | "building" | "testing"))).count();
|
||||||
|
let done = issues.iter().filter(|i| i["state"] == "done").count();
|
||||||
|
let cost: f64 = runs.iter().map(|r| r["cost"].as_f64().unwrap_or(0.0)).sum();
|
||||||
|
let summary = format!("Factory · {} issues · {running} running · {done} done · {} runs · ${cost:.2}", issues.iter().filter(|i| i["state"] != "closed").count(), runs.len());
|
||||||
|
let order = ["Question", "Failed", "Build", "Acceptance", "Review", "Approved", "Done"];
|
||||||
|
let mut rows: Vec<(usize, String, String, String)> = issues
|
||||||
|
.iter()
|
||||||
|
.filter(|i| i["state"] != "closed")
|
||||||
|
.map(|i| {
|
||||||
|
let state = i["state"].as_str().unwrap_or("");
|
||||||
|
let col = column(state);
|
||||||
|
let key = format!("{}#{}", i["repo"].as_str().unwrap_or(""), i["number"].as_i64().unwrap_or(0));
|
||||||
|
let latest = runs.iter().find(|r| r["repo"] == i["repo"] && r["issue"] == i["number"]);
|
||||||
|
let run = latest.map(|r| format!(" · {} {}", r["phase"].as_str().unwrap_or(""), if r["ended_at"].is_null() { "running" } else { r["status"].as_str().unwrap_or("") })).unwrap_or_default();
|
||||||
|
let ver = i["version"].as_str().filter(|v| !v.is_empty()).map(|v| format!(" v{v}")).unwrap_or_default();
|
||||||
|
(
|
||||||
|
order.iter().position(|c| *c == col).unwrap_or(order.len()),
|
||||||
|
key,
|
||||||
|
format!("{col:<10} {} #{} {}", repo_name(i["repo"].as_str().unwrap_or("")), i["number"].as_i64().unwrap_or(0), short(i["title"].as_str().unwrap_or(""), 60)),
|
||||||
|
format!("{}{run}{ver}", short(i["note"].as_str().unwrap_or("").replace('\n', " ").as_str(), 80)),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
rows.sort_by_key(|r| r.0);
|
||||||
|
Ok((summary, rows.into_iter().map(|(_, k, l, d)| (k, l, d)).collect()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Split a board key "repo#number".
|
||||||
|
pub fn split_key(key: &str) -> Result<(String, i64)> {
|
||||||
|
let (repo, n) = key.rsplit_once('#').context("invalid issue")?;
|
||||||
|
Ok((repo.to_string(), n.parse()?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What can be done with an issue in this state: (action key, label, description).
|
||||||
|
pub async fn factory_actions(server: &Server, key: &str) -> Result<(String, Vec<(String, String, String)>)> {
|
||||||
|
let (repo, n) = split_key(key)?;
|
||||||
|
let v = server.get("/factory/overview").await?;
|
||||||
|
let issue = v["issues"].as_array().and_then(|a| a.iter().find(|i| i["number"] == n && i["repo"] == repo)).cloned().context("the issue is gone")?;
|
||||||
|
let state = issue["state"].as_str().unwrap_or("").to_string();
|
||||||
|
let busy = matches!(state.as_str(), "review" | "building" | "testing");
|
||||||
|
let title = format!("{} #{n} – {} [{}]", repo_name(&repo), short(issue["title"].as_str().unwrap_or(""), 50), column(&state));
|
||||||
|
let mut acts: Vec<(String, String, String)> = Vec::new();
|
||||||
|
// The chats of its runs.
|
||||||
|
for r in v["runs"].as_array().into_iter().flatten().filter(|r| r["issue"] == n && (r["repo"] == repo)).take(6) {
|
||||||
|
acts.push((format!("chat:{}", r["session_id"].as_str().unwrap_or("")), format!("Open the {} chat", r["phase"].as_str().unwrap_or("")), format!("{} · {}", r["model"].as_str().unwrap_or(""), if r["ended_at"].is_null() { "running".to_string() } else { r["status"].as_str().unwrap_or("").to_string() })));
|
||||||
|
}
|
||||||
|
if state == "done" {
|
||||||
|
if let Ok(p) = server.get(&format!("/factory/issues/pr?repo={}&number={n}", urlenc(&repo))).await {
|
||||||
|
if let Some(pr) = p["pr"].as_object() {
|
||||||
|
if pr.get("state").and_then(|s| s.as_str()) == Some("open") {
|
||||||
|
let num = pr.get("number").and_then(|x| x.as_i64()).unwrap_or(0);
|
||||||
|
for (m, d) in [("merge", "merge commit"), ("squash", "squash into one commit"), ("rebase", "rebase onto the base branch")] {
|
||||||
|
acts.push((format!("merge:{num}:{m}"), format!("Merge pull request #{num} ({m})"), d.to_string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
acts.push(("close".into(), "Close the issue".into(), "comments and closes it on the forge".into()));
|
||||||
|
}
|
||||||
|
if !busy {
|
||||||
|
for (to, label) in [("new", "Restart at the review"), ("approved", "Restart at the build"), ("qa", "Restart at the acceptance")] {
|
||||||
|
acts.push((format!("restart:{to}"), label.into(), String::new()));
|
||||||
|
}
|
||||||
|
acts.push(("remove".into(), "Remove from the board".into(), "the issue on the forge stays as it is".into()));
|
||||||
|
}
|
||||||
|
Ok((title, acts))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn urlenc(s: &str) -> String {
|
||||||
|
s.bytes().map(|b| if b.is_ascii_alphanumeric() || b"-_.~".contains(&b) { (b as char).to_string() } else { format!("%{b:02X}") }).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Run an action chosen in `factory_actions` (everything except opening a chat). Returns a message.
|
||||||
|
pub async fn factory_do(server: &Server, key: &str, action: &str) -> Result<String> {
|
||||||
|
let (repo, number) = split_key(key)?;
|
||||||
|
let (verb, arg) = action.split_once(':').unwrap_or((action, ""));
|
||||||
|
match verb {
|
||||||
|
"restart" => {
|
||||||
|
server.post("/factory/issues/restart", json!({"repo": repo, "number": number, "to": arg})).await?;
|
||||||
|
Ok(format!("#{number} restarted"))
|
||||||
|
}
|
||||||
|
"remove" => {
|
||||||
|
server.post("/factory/issues/remove", json!({"repo": repo, "number": number})).await?;
|
||||||
|
Ok(format!("#{number} removed from the board"))
|
||||||
|
}
|
||||||
|
"close" => {
|
||||||
|
server.post("/factory/issues/close", json!({"repo": repo, "number": number, "comment": "Closed from the terminal."})).await?;
|
||||||
|
Ok(format!("#{number} closed"))
|
||||||
|
}
|
||||||
|
"merge" => {
|
||||||
|
let (pr, method) = arg.split_once(':').context("invalid merge")?;
|
||||||
|
server.post("/factory/issues/pr/merge", json!({"repo": repo, "number": number, "pr": pr.parse::<i64>()?, "method": method})).await?;
|
||||||
|
Ok(format!("pull request #{pr} merged ({method})"))
|
||||||
|
}
|
||||||
|
_ => bail!("unknown action"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn factory_poll(server: &Server) -> Result<String> {
|
||||||
|
let v = server.post("/factory/poll", json!({})).await?;
|
||||||
|
let errs = v["errors"].as_array().map(|a| a.len()).unwrap_or(0);
|
||||||
|
Ok(if errs == 0 { "checked for new issues".into() } else { format!("checked – {errs} repository error(s)") })
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn board_columns_and_keys() {
|
||||||
|
assert_eq!(column("rework"), "Build");
|
||||||
|
assert_eq!(column("testing"), "Acceptance");
|
||||||
|
assert_eq!(column("rejected"), "Failed");
|
||||||
|
assert_eq!(repo_name("https://git.example.org/acme/demo-shop.git"), "acme/demo-shop");
|
||||||
|
let (repo, n) = split_key("https://git.example.org/acme/demo-shop.git#12").unwrap();
|
||||||
|
assert_eq!((repo.as_str(), n), ("https://git.example.org/acme/demo-shop.git", 12));
|
||||||
|
assert!(split_key("nonsense").is_err());
|
||||||
|
assert_eq!(urlenc("https://a/b c"), "https%3A%2F%2Fa%2Fb%20c");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn relative_times() {
|
||||||
|
let now = chrono::Utc::now().timestamp_millis();
|
||||||
|
assert_eq!(ago(now), "now");
|
||||||
|
assert_eq!(ago(now - 10 * 60_000), "10 min ago");
|
||||||
|
assert_eq!(ago(now - 5 * 3_600_000), "5 h ago");
|
||||||
|
assert_eq!(ago(now - 3 * 86_400_000), "3 d ago");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ arch=$(uname -m)
|
|||||||
case "$arch" in
|
case "$arch" in
|
||||||
x86_64|amd64) arch=x86_64 ;;
|
x86_64|amd64) arch=x86_64 ;;
|
||||||
aarch64|arm64) arch=aarch64 ;;
|
aarch64|arm64) arch=aarch64 ;;
|
||||||
|
riscv64) arch=riscv64 ;;
|
||||||
*) echo "codecraft: unsupported architecture $arch" >&2; exit 1 ;;
|
*) echo "codecraft: unsupported architecture $arch" >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
case "$os" in
|
case "$os" in
|
||||||
|
|||||||
+57
-2
@@ -176,6 +176,7 @@ pub fn router(app: AppState) -> Router {
|
|||||||
.route("/factory/release/preview", get(factory_release_preview))
|
.route("/factory/release/preview", get(factory_release_preview))
|
||||||
.route("/factory/release", post(factory_release))
|
.route("/factory/release", post(factory_release))
|
||||||
.route("/factory/issues/close", post(factory_close_issue))
|
.route("/factory/issues/close", post(factory_close_issue))
|
||||||
|
.route("/factory/issues/remove", post(factory_remove_issue))
|
||||||
.route("/factory/issues/pr", get(factory_pr))
|
.route("/factory/issues/pr", get(factory_pr))
|
||||||
.route("/factory/issues/pr/merge", post(factory_pr_merge))
|
.route("/factory/issues/pr/merge", post(factory_pr_merge))
|
||||||
.route("/account/factory/connection/test", post(test_factory_connection))
|
.route("/account/factory/connection/test", post(test_factory_connection))
|
||||||
@@ -190,6 +191,7 @@ pub fn router(app: AppState) -> Router {
|
|||||||
.route("/account/memory", get(crate::cli_api::get_memory).put(crate::cli_api::put_memory))
|
.route("/account/memory", get(crate::cli_api::get_memory).put(crate::cli_api::put_memory))
|
||||||
.route("/account/modes", get(get_personal_modes).put(put_personal_modes))
|
.route("/account/modes", get(get_personal_modes).put(put_personal_modes))
|
||||||
.route("/account/telegram", get(get_telegram).put(put_telegram).delete(delete_telegram))
|
.route("/account/telegram", get(get_telegram).put(put_telegram).delete(delete_telegram))
|
||||||
|
.route("/account/telegram/prefs", put(put_telegram_prefs))
|
||||||
.route("/templates", get(crate::cli_api::get_templates))
|
.route("/templates", get(crate::cli_api::get_templates))
|
||||||
.route("/templates/{scope}", put(crate::cli_api::put_templates))
|
.route("/templates/{scope}", put(crate::cli_api::put_templates))
|
||||||
.route("/cli/config", get(crate::cli_api::config))
|
.route("/cli/config", get(crate::cli_api::config))
|
||||||
@@ -434,12 +436,52 @@ async fn get_telegram(Extension(user): Extension<User>, State(app): State<AppSta
|
|||||||
"configured": !s.token.is_empty(),
|
"configured": !s.token.is_empty(),
|
||||||
"bot": s.bot,
|
"bot": s.bot,
|
||||||
"paired": s.chat_id.is_some(),
|
"paired": s.chat_id.is_some(),
|
||||||
"pair_code": if s.chat_id.is_none() { s.pair_code } else { String::new() },
|
"pair_code": if s.chat_id.is_none() { s.pair_code.clone() } else { String::new() },
|
||||||
"running": running,
|
"running": running,
|
||||||
"error": error,
|
"error": error,
|
||||||
|
"factory_alerts": !s.factory_alerts_off,
|
||||||
|
"quiet": s.quiet,
|
||||||
|
"quiet_from": if s.quiet_from.is_empty() { "22:00".to_string() } else { s.quiet_from.clone() },
|
||||||
|
"quiet_to": if s.quiet_to.is_empty() { "06:00".to_string() } else { s.quiet_to.clone() },
|
||||||
|
"quiet_now": s.quiet_now(),
|
||||||
|
"server_time": chrono::Local::now().format("%H:%M").to_string(),
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct TelegramPrefs {
|
||||||
|
factory_alerts: Option<bool>,
|
||||||
|
quiet: Option<bool>,
|
||||||
|
quiet_from: Option<String>,
|
||||||
|
quiet_to: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Notification preferences: factory alerts on/off and the night mode.
|
||||||
|
async fn put_telegram_prefs(Extension(user): Extension<User>, State(app): State<AppState>, Json(b): Json<TelegramPrefs>) -> ApiResult {
|
||||||
|
let mut s = crate::telegram::load(&app, &user.id);
|
||||||
|
for (v, what) in [(&b.quiet_from, "from"), (&b.quiet_to, "to")] {
|
||||||
|
if let Some(t) = v {
|
||||||
|
if crate::telegram::parse_hhmm(t).is_none() {
|
||||||
|
return Err(ApiError(StatusCode::BAD_REQUEST, format!("invalid time ({what}) – use HH:MM")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(v) = b.factory_alerts {
|
||||||
|
s.factory_alerts_off = !v;
|
||||||
|
}
|
||||||
|
if let Some(v) = b.quiet {
|
||||||
|
s.quiet = v;
|
||||||
|
}
|
||||||
|
if let Some(v) = b.quiet_from {
|
||||||
|
s.quiet_from = v.trim().to_string();
|
||||||
|
}
|
||||||
|
if let Some(v) = b.quiet_to {
|
||||||
|
s.quiet_to = v.trim().to_string();
|
||||||
|
}
|
||||||
|
app.store.set_user_setting(&user.id, "telegram", &s)?;
|
||||||
|
get_telegram(Extension(user), State(app)).await
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct TelegramBody {
|
struct TelegramBody {
|
||||||
token: String,
|
token: String,
|
||||||
@@ -450,7 +492,9 @@ async fn put_telegram(Extension(user): Extension<User>, State(app): State<AppSta
|
|||||||
let token = crate::telegram::extract_token(&b.token)
|
let token = crate::telegram::extract_token(&b.token)
|
||||||
.ok_or_else(|| ApiError(StatusCode::BAD_REQUEST, "that is not a bot token – it looks like 123456789:AAH… (paste only the token from @BotFather)".into()))?;
|
.ok_or_else(|| ApiError(StatusCode::BAD_REQUEST, "that is not a bot token – it looks like 123456789:AAH… (paste only the token from @BotFather)".into()))?;
|
||||||
let bot = crate::telegram::check_token(&token).await.map_err(|e| ApiError(StatusCode::BAD_REQUEST, format!("token rejected by Telegram: {e:#}")))?;
|
let bot = crate::telegram::check_token(&token).await.map_err(|e| ApiError(StatusCode::BAD_REQUEST, format!("token rejected by Telegram: {e:#}")))?;
|
||||||
let s = crate::telegram::Settings { token, bot, pair_code: crate::telegram::new_pair_code(), ..Default::default() };
|
let old = crate::telegram::load(&app, &user.id);
|
||||||
|
// Notification preferences survive a new bot.
|
||||||
|
let s = crate::telegram::Settings { token, bot, pair_code: crate::telegram::new_pair_code(), factory_alerts_off: old.factory_alerts_off, quiet: old.quiet, quiet_from: old.quiet_from, quiet_to: old.quiet_to, ..Default::default() };
|
||||||
app.store.set_user_setting(&user.id, "telegram", &s)?;
|
app.store.set_user_setting(&user.id, "telegram", &s)?;
|
||||||
crate::telegram::restart(&app, &user.id);
|
crate::telegram::restart(&app, &user.id);
|
||||||
app.audit(Some(&user), "telegram.connect", &s.bot, "");
|
app.audit(Some(&user), "telegram.connect", &s.bot, "");
|
||||||
@@ -2836,6 +2880,17 @@ async fn factory_close_issue(Extension(user): Extension<User>, State(app): State
|
|||||||
Ok(Json(json!({"ok": true})))
|
Ok(Json(json!({"ok": true})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Take an issue off the factory board (the issue on the forge is not touched). Not while a phase runs.
|
||||||
|
async fn factory_remove_issue(Extension(user): Extension<User>, State(app): State<AppState>, headers: axum::http::HeaderMap, Json(b): Json<CloseIssue>) -> ApiResult {
|
||||||
|
let (_, row) = factory_issue_forge(&app, &user, &b.repo, b.number)?;
|
||||||
|
if matches!(row["state"].as_str(), Some("review" | "building" | "testing")) {
|
||||||
|
return Err(ApiError(StatusCode::BAD_REQUEST, "a phase is running – wait for it to end or stop it first".into()));
|
||||||
|
}
|
||||||
|
app.store.factory_issue_delete(&b.repo, b.number)?;
|
||||||
|
app.audit(Some(&user), "factory.issue.remove", &format!("{}#{}", b.repo, b.number), &crate::auth::client_ip(&headers));
|
||||||
|
Ok(Json(json!({"ok": true})))
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct PrQuery {
|
struct PrQuery {
|
||||||
repo: String,
|
repo: String,
|
||||||
|
|||||||
@@ -562,6 +562,14 @@ impl Forge {
|
|||||||
Ok(!matches!(v["state"].as_str(), Some("closed")))
|
Ok(!matches!(v["state"].as_str(), Some("closed")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Has the issue been deleted on the forge (404)? Other errors (network, token) count as "still there".
|
||||||
|
pub async fn issue_gone(&self, number: u64) -> bool {
|
||||||
|
match self.call(reqwest::Method::GET, self.rp(&format!("/issues/{number}")), None).await {
|
||||||
|
Err(e) => e.to_string().contains("404"),
|
||||||
|
Ok(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn close_issue(&self, number: u64) -> Result<()> {
|
pub async fn close_issue(&self, number: u64) -> Result<()> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Kind::Gitlab => self.call(reqwest::Method::PUT, self.rp(&format!("/issues/{number}")), Some(json!({"state_event": "close"}))).await.map(|_| ()),
|
Kind::Gitlab => self.call(reqwest::Method::PUT, self.rp(&format!("/issues/{number}")), Some(json!({"state_event": "close"}))).await.map(|_| ()),
|
||||||
@@ -966,6 +974,7 @@ async fn review(app: Arc<App>, user: User, cfg: RepoCfg, issue: Value, comments:
|
|||||||
let qs: Vec<String> = res["questions"].as_array().map(|a| a.iter().filter_map(|q| q.as_str().map(|q| format!("- {q}"))).collect()).unwrap_or_default();
|
let qs: Vec<String> = res["questions"].as_array().map(|a| a.iter().filter_map(|q| q.as_str().map(|q| format!("- {q}"))).collect()).unwrap_or_default();
|
||||||
set(&[("state", json!("question")), ("note", json!(summary))]);
|
set(&[("state", json!("question")), ("note", json!(summary))]);
|
||||||
let _ = g.set_labels(n as u64, &status_labels(&cfg, "question")).await;
|
let _ = g.set_labels(n as u64, &status_labels(&cfg, "question")).await;
|
||||||
|
alert(&app, &cfg.url, n, "question", &if qs.is_empty() { summary.clone() } else { qs.join("\n") }).await;
|
||||||
bot_comment(&g, n as u64, &format!("**Review: questions before this can be built.** {summary}\n\n{}\n\nAnswer in a comment; the review starts again automatically.", qs.join("\n"))).await;
|
bot_comment(&g, n as u64, &format!("**Review: questions before this can be built.** {summary}\n\n{}\n\nAnswer in a comment; the review starts again automatically.", qs.join("\n"))).await;
|
||||||
// Remember the newest comment (including this one) so only later answers count.
|
// Remember the newest comment (including this one) so only later answers count.
|
||||||
if let Ok(all) = g.comments(n as u64).await {
|
if let Ok(all) = g.comments(n as u64).await {
|
||||||
@@ -1059,6 +1068,7 @@ async fn build_fail(app: &Arc<App>, g: &Forge, cfg: &RepoCfg, n: i64, why: &str)
|
|||||||
if attempts >= cfg.build.max_attempts {
|
if attempts >= cfg.build.max_attempts {
|
||||||
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("failed")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("failed")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
||||||
let _ = g.set_labels(n as u64, &status_labels(cfg, "failed")).await;
|
let _ = g.set_labels(n as u64, &status_labels(cfg, "failed")).await;
|
||||||
|
alert(&app, &cfg.url, n, "failed", &why).await;
|
||||||
bot_comment(g, n as u64, &format!("**Build failed:** {why}.")).await;
|
bot_comment(g, n as u64, &format!("**Build failed:** {why}.")).await;
|
||||||
} else {
|
} else {
|
||||||
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("approved")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("approved")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
||||||
@@ -1103,6 +1113,7 @@ async fn build(app: Arc<App>, user: User, cfg: RepoCfg, issue: Value, comments:
|
|||||||
let reason = res["reason"].as_str().unwrap_or(&summary).trim().to_string();
|
let reason = res["reason"].as_str().unwrap_or(&summary).trim().to_string();
|
||||||
set(&[("state", json!("failed")), ("note", json!(reason))]);
|
set(&[("state", json!("failed")), ("note", json!(reason))]);
|
||||||
let _ = g.set_labels(n as u64, &status_labels(&cfg, "failed")).await;
|
let _ = g.set_labels(n as u64, &status_labels(&cfg, "failed")).await;
|
||||||
|
alert(&app, &cfg.url, n, "failed", &reason).await;
|
||||||
bot_comment(&g, n as u64, &format!("**Build: cannot be built as specified.** {reason}")).await;
|
bot_comment(&g, n as u64, &format!("**Build: cannot be built as specified.** {reason}")).await;
|
||||||
notify(&app, &user, &format!("Factory #{n}"), &format!("build blocked – {reason}"), n).await;
|
notify(&app, &user, &format!("Factory #{n}"), &format!("build blocked – {reason}"), n).await;
|
||||||
return;
|
return;
|
||||||
@@ -1169,6 +1180,7 @@ async fn qa_fail(app: &Arc<App>, g: &Forge, cfg: &RepoCfg, n: i64, why: &str) {
|
|||||||
if attempts >= cfg.qa.max_attempts {
|
if attempts >= cfg.qa.max_attempts {
|
||||||
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("failed")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("failed")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
||||||
let _ = g.set_labels(n as u64, &status_labels(cfg, "failed")).await;
|
let _ = g.set_labels(n as u64, &status_labels(cfg, "failed")).await;
|
||||||
|
alert(&app, &cfg.url, n, "failed", &why).await;
|
||||||
bot_comment(g, n as u64, &format!("**Acceptance failed to run:** {why}.")).await;
|
bot_comment(g, n as u64, &format!("**Acceptance failed to run:** {why}.")).await;
|
||||||
} else {
|
} else {
|
||||||
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("qa")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("qa")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
||||||
@@ -1243,6 +1255,7 @@ async fn qa(app: Arc<App>, user: User, cfg: RepoCfg, issue: Value) {
|
|||||||
if round >= cfg.max_rework {
|
if round >= cfg.max_rework {
|
||||||
set(&[("state", json!("failed")), ("note", json!(findings.clone()))]);
|
set(&[("state", json!("failed")), ("note", json!(findings.clone()))]);
|
||||||
let _ = g.set_labels(n as u64, &status_labels(&cfg, "failed")).await;
|
let _ = g.set_labels(n as u64, &status_labels(&cfg, "failed")).await;
|
||||||
|
alert(&app, &cfg.url, n, "failed", &findings.clone()).await;
|
||||||
bot_comment(&g, n as u64, &format!("**Acceptance failed after {} rework rounds.** {summary}\n\n{table}\n{findings}", cfg.max_rework)).await;
|
bot_comment(&g, n as u64, &format!("**Acceptance failed after {} rework rounds.** {summary}\n\n{table}\n{findings}", cfg.max_rework)).await;
|
||||||
notify(&app, &user, &format!("Factory #{n}"), "acceptance failed, rework limit reached", n).await;
|
notify(&app, &user, &format!("Factory #{n}"), "acceptance failed, rework limit reached", n).await;
|
||||||
} else {
|
} else {
|
||||||
@@ -1279,6 +1292,7 @@ async fn fail_or_retry(app: &Arc<App>, g: &Forge, cfg: &RepoCfg, n: i64, why: &s
|
|||||||
if attempts >= cfg.review.max_attempts {
|
if attempts >= cfg.review.max_attempts {
|
||||||
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("failed")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("failed")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
||||||
let _ = g.set_labels(n as u64, &status_labels(cfg, "failed")).await;
|
let _ = g.set_labels(n as u64, &status_labels(cfg, "failed")).await;
|
||||||
|
alert(&app, &cfg.url, n, "failed", &why).await;
|
||||||
bot_comment(g, n as u64, &format!("**Failed:** {why}.")).await;
|
bot_comment(g, n as u64, &format!("**Failed:** {why}.")).await;
|
||||||
} else {
|
} else {
|
||||||
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("new")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
let _ = app.store.factory_issue_set(&cfg.url, n, &[("state", json!("new")), ("attempts", json!(attempts)), ("note", json!(why))]);
|
||||||
@@ -1290,6 +1304,23 @@ pub(crate) async fn notify(app: &App, user: &User, title: &str, body: &str, issu
|
|||||||
let _ = crate::push::send_to_user(app, &user.id, &payload).await;
|
let _ = crate::push::send_to_user(app, &user.id, &payload).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tell the user on Telegram (if paired) that an issue needs them: a question to answer or a failure.
|
||||||
|
pub(crate) async fn alert(app: &App, repo: &str, n: i64, what: &str, detail: &str) {
|
||||||
|
let Ok(Some(row)) = app.store.factory_issue(repo, n) else { return };
|
||||||
|
let Some(owner) = row["owner_id"].as_str() else { return };
|
||||||
|
let de = crate::telegram::german(app, owner);
|
||||||
|
let name = repo.trim_end_matches(".git").rsplit('/').next().unwrap_or(repo);
|
||||||
|
let head = match (what, de) {
|
||||||
|
("question", true) => "❓ Frage zu",
|
||||||
|
("question", false) => "❓ Question on",
|
||||||
|
(_, true) => "❌ Fehlgeschlagen:",
|
||||||
|
(_, false) => "❌ Failed:",
|
||||||
|
};
|
||||||
|
let detail: String = detail.trim().chars().take(600).collect();
|
||||||
|
let text = format!("{head} {name} #{n} – {}\n\n{detail}\n\n{}/issues/{n}", row["title"].as_str().unwrap_or(""), repo.trim_end_matches(".git"));
|
||||||
|
crate::telegram::notify_user(app, owner, &text).await;
|
||||||
|
}
|
||||||
|
|
||||||
/// 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.
|
||||||
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)?;
|
||||||
@@ -1353,6 +1384,14 @@ pub async fn poll_repo(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<()>
|
|||||||
app.store.factory_issue_set(&cfg.url, n, &[("state", json!("closed"))])?;
|
app.store.factory_issue_set(&cfg.url, n, &[("state", json!("closed"))])?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Issues deleted on the forge leave the board (closed ones stay: they still exist there).
|
||||||
|
for row in app.store.factory_issues(&user.id)?.into_iter().filter(|r| r["repo"].as_str() == Some(cfg.url.as_str()) && !matches!(r["state"].as_str(), Some("review" | "building" | "testing"))) {
|
||||||
|
let n = issue_no(&row);
|
||||||
|
if n > 0 && !open.contains(&n) && g.issue_gone(n as u64).await {
|
||||||
|
tracing::info!("factory {}: #{n} was deleted on the forge – removed from the board", cfg.url);
|
||||||
|
app.store.factory_issue_delete(&cfg.url, n)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Merged issues get their version and tag.
|
// Merged issues get their version and tag.
|
||||||
if let Err(e) = crate::factory_version::version_pass(app, user, cfg).await {
|
if let Err(e) = crate::factory_version::version_pass(app, user, cfg).await {
|
||||||
tracing::warn!("factory {}: versions: {e:#}", cfg.url);
|
tracing::warn!("factory {}: versions: {e:#}", cfg.url);
|
||||||
|
|||||||
+9
-1
@@ -1497,6 +1497,12 @@ impl Store {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove an issue from the factory board (runs and cost statistics stay).
|
||||||
|
pub fn factory_issue_delete(&self, repo: &str, number: i64) -> Result<()> {
|
||||||
|
self.conn.lock().unwrap().execute("DELETE FROM factory_issues WHERE repo_url = ?1 AND number = ?2", params![repo, number])?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// 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; 11] = ["title", "state", "attempts", "rounds", "last_comment", "scenarios", "branch", "pr_url", "note", "author", "version"];
|
||||||
@@ -1586,7 +1592,9 @@ impl Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn factory_running(&self, repo: &str) -> Result<i64> {
|
pub fn factory_running(&self, repo: &str) -> Result<i64> {
|
||||||
Ok(self.conn.lock().unwrap().query_row("SELECT COUNT(*) FROM factory_runs WHERE repo_url = ?1 AND status = 'running'", [repo], |r| r.get(0))?)
|
// Counted by issue state, not by run rows: the state is set before the phase is spawned, the run row
|
||||||
|
// only once its checkout is done – counting runs let a single poll start more phases than allowed.
|
||||||
|
Ok(self.conn.lock().unwrap().query_row("SELECT COUNT(*) FROM factory_issues WHERE repo_url = ?1 AND state IN ('review', 'building', 'testing')", [repo], |r| r.get(0))?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs with token and cost totals (joined from the usage table).
|
/// Runs with token and cost totals (joined from the usage table).
|
||||||
|
|||||||
@@ -51,6 +51,48 @@ pub struct Settings {
|
|||||||
/// Reasoning effort for the next messages (/effort).
|
/// Reasoning effort for the next messages (/effort).
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub effort: Option<String>,
|
pub effort: Option<String>,
|
||||||
|
/// No factory alerts (question / failed) on Telegram. Inverted so that the default is "on".
|
||||||
|
#[serde(default)]
|
||||||
|
pub factory_alerts_off: bool,
|
||||||
|
/// Night mode: no unsolicited messages between `quiet_from` and `quiet_to` (server time).
|
||||||
|
#[serde(default)]
|
||||||
|
pub quiet: bool,
|
||||||
|
/// "HH:MM"; empty = 22:00.
|
||||||
|
#[serde(default)]
|
||||||
|
pub quiet_from: String,
|
||||||
|
/// "HH:MM"; empty = 06:00.
|
||||||
|
#[serde(default)]
|
||||||
|
pub quiet_to: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Minutes since midnight of an "HH:MM" string.
|
||||||
|
pub fn parse_hhmm(s: &str) -> Option<u32> {
|
||||||
|
let (h, m) = s.trim().split_once(':')?;
|
||||||
|
let (h, m): (u32, u32) = (h.parse().ok()?, m.parse().ok()?);
|
||||||
|
(h < 24 && m < 60).then_some(h * 60 + m)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Is `now` (minutes since midnight) inside the quiet window? The window may span midnight.
|
||||||
|
pub fn in_quiet_window(from: u32, to: u32, now: u32) -> bool {
|
||||||
|
match from.cmp(&to) {
|
||||||
|
std::cmp::Ordering::Equal => false,
|
||||||
|
std::cmp::Ordering::Less => now >= from && now < to,
|
||||||
|
std::cmp::Ordering::Greater => now >= from || now < to,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Settings {
|
||||||
|
/// Night mode is on and it is night now.
|
||||||
|
pub fn quiet_now(&self) -> bool {
|
||||||
|
use chrono::Timelike;
|
||||||
|
if !self.quiet {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let from = parse_hhmm(if self.quiet_from.is_empty() { "22:00" } else { &self.quiet_from }).unwrap_or(22 * 60);
|
||||||
|
let to = parse_hhmm(if self.quiet_to.is_empty() { "06:00" } else { &self.quiet_to }).unwrap_or(6 * 60);
|
||||||
|
let t = chrono::Local::now();
|
||||||
|
in_quiet_window(from, to, t.hour() * 60 + t.minute())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn api_base() -> String {
|
fn api_base() -> String {
|
||||||
@@ -260,6 +302,18 @@ fn user(app: &App, user_id: &str) -> Result<User> {
|
|||||||
app.store.user(user_id)?.filter(|u| !u.disabled).ok_or_else(|| anyhow!("account disabled"))
|
app.store.user(user_id)?.filter(|u| !u.disabled).ok_or_else(|| anyhow!("account disabled"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send a message (HTML-escaped) to the user's paired Telegram chat; silent when there is none.
|
||||||
|
pub async fn notify_user(app: &App, user_id: &str, text: &str) {
|
||||||
|
let s = load(app, user_id);
|
||||||
|
let (true, Some(chat)) = (!s.token.is_empty(), s.chat_id) else { return };
|
||||||
|
if s.factory_alerts_off || s.quiet_now() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if let Err(e) = (Bot { token: s.token }).send(chat, &esc(text), None).await {
|
||||||
|
tracing::warn!("telegram: notification not sent: {e:#}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The user reads German (language preference of the web UI).
|
/// The user reads German (language preference of the web UI).
|
||||||
pub fn german(app: &App, user_id: &str) -> bool {
|
pub fn german(app: &App, user_id: &str) -> bool {
|
||||||
let prefs: Value = app.store.user_setting(user_id, "prefs").unwrap_or_default();
|
let prefs: Value = app.store.user_setting(user_id, "prefs").unwrap_or_default();
|
||||||
@@ -875,6 +929,10 @@ async fn listen(app: Arc<App>) {
|
|||||||
let Some(chat) = st.chat_id else { continue };
|
let Some(chat) = st.chat_id else { continue };
|
||||||
let de = german(&app, &owner);
|
let de = german(&app, &owner);
|
||||||
let is_current = st.session.as_deref() == Some(session_id.as_str());
|
let is_current = st.session.as_deref() == Some(session_id.as_str());
|
||||||
|
// Night mode: only the chat the user is talking to in Telegram still reports.
|
||||||
|
if !is_current && st.quiet_now() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Chats with "not to Telegram": their approvals and questions stay in the web UI
|
// Chats with "not to Telegram": their approvals and questions stay in the web UI
|
||||||
// (subagents follow their top-level chat; the chat open in Telegram always reports).
|
// (subagents follow their top-level chat; the chat open in Telegram always reports).
|
||||||
if !is_current && matches!(ev, Event::PermissionRequest { .. } | Event::QuestionRequest { .. }) {
|
if !is_current && matches!(ev, Event::PermissionRequest { .. } | Event::QuestionRequest { .. }) {
|
||||||
@@ -1204,3 +1262,30 @@ mod tests {
|
|||||||
assert_eq!(step_line("todo_write", &json!({})), "todo_write");
|
assert_eq!(step_line("todo_write", &json!({})), "todo_write");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod quiet_tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn quiet_window_spans_midnight() {
|
||||||
|
let (from, to) = (parse_hhmm("22:00").unwrap(), parse_hhmm("06:00").unwrap());
|
||||||
|
assert!(in_quiet_window(from, to, 23 * 60));
|
||||||
|
assert!(in_quiet_window(from, to, 0));
|
||||||
|
assert!(in_quiet_window(from, to, 5 * 60 + 59));
|
||||||
|
assert!(!in_quiet_window(from, to, 6 * 60));
|
||||||
|
assert!(!in_quiet_window(from, to, 12 * 60));
|
||||||
|
assert!(!in_quiet_window(from, to, 21 * 60 + 59));
|
||||||
|
assert!(in_quiet_window(from, to, 22 * 60));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn quiet_window_within_a_day_and_degenerate() {
|
||||||
|
assert!(in_quiet_window(13 * 60, 14 * 60, 13 * 60 + 30));
|
||||||
|
assert!(!in_quiet_window(13 * 60, 14 * 60, 15 * 60));
|
||||||
|
assert!(!in_quiet_window(600, 600, 600));
|
||||||
|
assert_eq!(parse_hhmm("7:05"), Some(425));
|
||||||
|
assert_eq!(parse_hhmm("24:00"), None);
|
||||||
|
assert_eq!(parse_hhmm("x"), None);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -348,6 +348,20 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const removeIssue = async () => {
|
||||||
|
if (!selected) return;
|
||||||
|
if (!(await confirmDialog({ message: t("factory.removeConfirm", { n: selected.number }), confirmLabel: t("factory.remove"), danger: true }))) return;
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
await post("/factory/issues/remove", { repo: selected.repo, number: selected.number });
|
||||||
|
setSel("");
|
||||||
|
await reload();
|
||||||
|
} catch (e: any) {
|
||||||
|
toast(e.message);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
const closeIssue = async () => {
|
const closeIssue = async () => {
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: selected.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
|
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: selected.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
|
||||||
@@ -503,6 +517,11 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{selected && !["review", "building", "testing"].includes(selected.state) && (
|
||||||
|
<button className="small" onClick={removeIssue} disabled={busy} title={t("factory.removeHint")}>
|
||||||
|
<Icon name="trash" /> {t("factory.remove")}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
{selected && selected.state === "done" && (
|
{selected && selected.state === "done" && (
|
||||||
<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")}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function CliInstall() {
|
|||||||
</ol>
|
</ol>
|
||||||
{prebuilt && (
|
{prebuilt && (
|
||||||
<div className="hint">
|
<div className="hint">
|
||||||
{t("cli.downloads")} <a href="/cli/download/linux-x86_64">Linux x86_64</a> · <a href="/cli/download/linux-aarch64">Linux arm64</a>
|
{t("cli.downloads")} <a href="/cli/download/linux-x86_64">Linux x86_64</a> · <a href="/cli/download/linux-aarch64">Linux arm64</a> · <a href="/cli/download/linux-riscv64">Linux riscv64</a>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ interface Status {
|
|||||||
pair_code: string;
|
pair_code: string;
|
||||||
running: boolean;
|
running: boolean;
|
||||||
error?: string | null;
|
error?: string | null;
|
||||||
|
factory_alerts: boolean;
|
||||||
|
quiet: boolean;
|
||||||
|
quiet_from: string;
|
||||||
|
quiet_to: string;
|
||||||
|
quiet_now: boolean;
|
||||||
|
server_time: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Connect a personal Telegram bot as a chat interface. */
|
/** Connect a personal Telegram bot as a chat interface. */
|
||||||
@@ -33,6 +39,14 @@ export function Telegram() {
|
|||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const savePrefs = async (patch: Partial<Pick<Status, "factory_alerts" | "quiet" | "quiet_from" | "quiet_to">>) => {
|
||||||
|
try {
|
||||||
|
await put("/account/telegram/prefs", patch);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
toast(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
const disconnect = async () => {
|
const disconnect = async () => {
|
||||||
if (!(await confirmDialog({ message: t("telegram.disconnectConfirm"), danger: true, confirmLabel: t("telegram.disconnect") }))) return;
|
if (!(await confirmDialog({ message: t("telegram.disconnectConfirm"), danger: true, confirmLabel: t("telegram.disconnect") }))) return;
|
||||||
await del("/account/telegram").catch((e) => toast(e));
|
await del("/account/telegram").catch((e) => toast(e));
|
||||||
@@ -97,6 +111,22 @@ export function Telegram() {
|
|||||||
)}
|
)}
|
||||||
{data.error && <div className="notice err" style={{ marginTop: 10 }}>{data.error}</div>}
|
{data.error && <div className="notice err" style={{ marginTop: 10 }}>{data.error}</div>}
|
||||||
{data.paired && <div className="hint" style={{ marginTop: 10 }}>{t("telegram.commands")}</div>}
|
{data.paired && <div className="hint" style={{ marginTop: 10 }}>{t("telegram.commands")}</div>}
|
||||||
|
<h4 style={{ margin: "16px 0 6px" }}>{t("telegram.notify")}</h4>
|
||||||
|
<label className="row" style={{ gap: 8, alignItems: "center" }}>
|
||||||
|
<input type="checkbox" checked={data.factory_alerts} onChange={(e) => void savePrefs({ factory_alerts: e.target.checked })} />
|
||||||
|
<span>{t("telegram.factoryAlerts")}</span>
|
||||||
|
</label>
|
||||||
|
<label className="row" style={{ gap: 8, alignItems: "center", marginTop: 6 }}>
|
||||||
|
<input type="checkbox" checked={data.quiet} onChange={(e) => void savePrefs({ quiet: e.target.checked })} />
|
||||||
|
<span>{t("telegram.quiet")}</span>
|
||||||
|
</label>
|
||||||
|
<div className="row" style={{ gap: 8, alignItems: "center", marginTop: 6, marginLeft: 24, flexWrap: "wrap", opacity: data.quiet ? 1 : 0.5 }}>
|
||||||
|
<input type="time" value={data.quiet_from} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_from: e.target.value })} />
|
||||||
|
<span>–</span>
|
||||||
|
<input type="time" value={data.quiet_to} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_to: e.target.value })} />
|
||||||
|
<span className="hint">{t("telegram.serverTime", { time: data.server_time })}{data.quiet_now ? ` · ${t("telegram.quietNow")}` : ""}</span>
|
||||||
|
</div>
|
||||||
|
<div className="hint" style={{ marginTop: 6 }}>{t("telegram.quietHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -539,6 +539,12 @@ export const de: Messages = {
|
|||||||
"telegram.intro": "CodeCraft über Telegram mit deinem eigenen Bot nutzen: Nachrichten gehen an deine aktuelle Sitzung, Befehle wechseln Sitzungen, Modi und Modelle, Freigaben und Rückfragen kommen mit Knöpfen. Nur dein Telegram-Konto kann den Bot nutzen.",
|
"telegram.intro": "CodeCraft über Telegram mit deinem eigenen Bot nutzen: Nachrichten gehen an deine aktuelle Sitzung, Befehle wechseln Sitzungen, Modi und Modelle, Freigaben und Rückfragen kommen mit Knöpfen. Nur dein Telegram-Konto kann den Bot nutzen.",
|
||||||
"telegram.step1": "In Telegram @BotFather öffnen, /newbot senden und den Schritten folgen.",
|
"telegram.step1": "In Telegram @BotFather öffnen, /newbot senden und den Schritten folgen.",
|
||||||
"telegram.step2": "Das Token von BotFather hier einfügen.",
|
"telegram.step2": "Das Token von BotFather hier einfügen.",
|
||||||
|
"telegram.notify": "Benachrichtigungen",
|
||||||
|
"telegram.factoryAlerts": "Factory: Nachricht, wenn ein Issue eine Frage hat oder fehlschlägt",
|
||||||
|
"telegram.quiet": "Nachtmodus: keine ungefragten Nachrichten",
|
||||||
|
"telegram.serverTime": "Serverzeit {time}",
|
||||||
|
"telegram.quietNow": "gerade ruhig",
|
||||||
|
"telegram.quietHint": "Im Nachtmodus wird nichts von sich aus gesendet: keine Factory-Meldungen, keine Freigaben oder Fragen aus anderen Chats. Der Chat, in dem du gerade per Telegram schreibst, antwortet weiter. Zurückgehaltene Nachrichten werden nicht nachgeholt – sie bleiben in der Weboberfläche sichtbar.",
|
||||||
"telegram.connect": "Verbinden",
|
"telegram.connect": "Verbinden",
|
||||||
"telegram.checking": "Prüfe…",
|
"telegram.checking": "Prüfe…",
|
||||||
"telegram.running": "läuft",
|
"telegram.running": "läuft",
|
||||||
@@ -1294,6 +1300,9 @@ export const de: Messages = {
|
|||||||
"factory.closeTitle": "Issue schließen",
|
"factory.closeTitle": "Issue schließen",
|
||||||
"factory.closeMsg": "Kommentar zum Schließen von Issue #{n}. Er wird im Issue veröffentlicht, danach wird das Issue geschlossen.",
|
"factory.closeMsg": "Kommentar zum Schließen von Issue #{n}. Er wird im Issue veröffentlicht, danach wird das Issue geschlossen.",
|
||||||
"factory.closeDefault": "Erledigt und abgenommen.",
|
"factory.closeDefault": "Erledigt und abgenommen.",
|
||||||
|
"factory.remove": "Vom Board entfernen",
|
||||||
|
"factory.removeHint": "Nimmt das Issue vom Factory-Board; das Issue im Forge bleibt unberührt. Gelöschte Issues verschwinden von selbst.",
|
||||||
|
"factory.removeConfirm": "#{n} vom Factory-Board entfernen? Das Issue im Forge bleibt unverändert.",
|
||||||
"factory.closed": "Issue geschlossen",
|
"factory.closed": "Issue geschlossen",
|
||||||
"factory.skills": "Skills",
|
"factory.skills": "Skills",
|
||||||
"factory.skillAdd": "Skill hinzufügen…",
|
"factory.skillAdd": "Skill hinzufügen…",
|
||||||
|
|||||||
@@ -538,6 +538,12 @@ export const en = {
|
|||||||
"telegram.intro": "Use CodeCraft from Telegram with your own bot: messages go to your current session, commands switch sessions, modes and models, approvals and questions come with buttons. Only your Telegram account can use the bot.",
|
"telegram.intro": "Use CodeCraft from Telegram with your own bot: messages go to your current session, commands switch sessions, modes and models, approvals and questions come with buttons. Only your Telegram account can use the bot.",
|
||||||
"telegram.step1": "In Telegram, open @BotFather, send /newbot and follow the steps.",
|
"telegram.step1": "In Telegram, open @BotFather, send /newbot and follow the steps.",
|
||||||
"telegram.step2": "Paste the token BotFather gives you here.",
|
"telegram.step2": "Paste the token BotFather gives you here.",
|
||||||
|
"telegram.notify": "Notifications",
|
||||||
|
"telegram.factoryAlerts": "Factory: message when an issue gets a question or fails",
|
||||||
|
"telegram.quiet": "Night mode: no unsolicited messages",
|
||||||
|
"telegram.serverTime": "Server time {time}",
|
||||||
|
"telegram.quietNow": "quiet right now",
|
||||||
|
"telegram.quietHint": "During the night mode nothing is sent on your own initiative: no factory alerts, no approvals or questions from other chats. The chat you are talking to in Telegram keeps answering. Messages that are held back are not sent later – they stay visible in the web interface.",
|
||||||
"telegram.connect": "Connect",
|
"telegram.connect": "Connect",
|
||||||
"telegram.checking": "Checking…",
|
"telegram.checking": "Checking…",
|
||||||
"telegram.running": "running",
|
"telegram.running": "running",
|
||||||
@@ -1293,6 +1299,9 @@ export const en = {
|
|||||||
"factory.closeTitle": "Close issue",
|
"factory.closeTitle": "Close issue",
|
||||||
"factory.closeMsg": "Comment for closing issue #{n}. It is posted on the issue, then the issue is closed.",
|
"factory.closeMsg": "Comment for closing issue #{n}. It is posted on the issue, then the issue is closed.",
|
||||||
"factory.closeDefault": "Done and accepted.",
|
"factory.closeDefault": "Done and accepted.",
|
||||||
|
"factory.remove": "Remove from board",
|
||||||
|
"factory.removeHint": "Take the issue off the factory board; the issue on the forge is not touched. Deleted issues disappear by themselves.",
|
||||||
|
"factory.removeConfirm": "Remove #{n} from the factory board? The issue on the forge stays as it is.",
|
||||||
"factory.closed": "Issue closed",
|
"factory.closed": "Issue closed",
|
||||||
"factory.skills": "Skills",
|
"factory.skills": "Skills",
|
||||||
"factory.skillAdd": "Add skill…",
|
"factory.skillAdd": "Add skill…",
|
||||||
|
|||||||
@@ -3,6 +3,22 @@
|
|||||||
* 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-00066": {
|
||||||
|
en: ["Terminal client: /projects steers chats on the server, /factory manages the factory board"],
|
||||||
|
de: ["Terminal-Client: /projects steuert Chats auf dem Server, /factory verwaltet das Factory-Board"],
|
||||||
|
},
|
||||||
|
"202611-00065": {
|
||||||
|
en: ["Terminal client now also for Linux riscv64"],
|
||||||
|
de: ["Terminal-Client jetzt auch für Linux riscv64"],
|
||||||
|
},
|
||||||
|
"202611-00064": {
|
||||||
|
en: ["Factory: Telegram message when an issue gets a question or fails (can be switched off)", "Telegram: night mode (22:00–06:00, adjustable) without unsolicited messages"],
|
||||||
|
de: ["Factory: Telegram-Nachricht, wenn ein Issue eine Frage hat oder fehlschlägt (abschaltbar)", "Telegram: Nachtmodus (22:00–06:00, einstellbar) ohne ungefragte Nachrichten"],
|
||||||
|
},
|
||||||
|
"202611-00062": {
|
||||||
|
en: ["Factory: the parallel limit per project is now respected exactly", "Factory: remove issues from the board; issues deleted on the forge disappear by themselves"],
|
||||||
|
de: ["Factory: das Parallel-Limit pro Projekt wird jetzt genau eingehalten", "Factory: Issues vom Board entfernen; im Forge gelöschte Issues verschwinden von selbst"],
|
||||||
|
},
|
||||||
"202611-00061": {
|
"202611-00061": {
|
||||||
en: ["Factory: projects are chosen from a dropdown (all projects or a single one)"],
|
en: ["Factory: projects are chosen from a dropdown (all projects or a single one)"],
|
||||||
de: ["Factory: Projekte werden per Dropdown gewählt (alle oder nur eins)"],
|
de: ["Factory: Projekte werden per Dropdown gewählt (alle oder nur eins)"],
|
||||||
|
|||||||
Reference in new issue
Block a user