Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e66574b529 | ||
|
|
df02556132 | ||
|
|
fcbc052f8e | ||
|
|
fa6173d224 |
No files matched your search
@@ -3,6 +3,25 @@
|
||||
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
|
||||
until 1.0, minor versions may contain breaking changes.
|
||||
|
||||
## [v202611-00051] – 2026-11-16
|
||||
|
||||
### Added
|
||||
|
||||
- **Factory: close finished issues.** A finished issue has a "Close issue" button: you write a comment, it is
|
||||
posted on the issue on the forge, the issue is closed there, and only then it leaves the "Done" column.
|
||||
Issues that are closed on the forge by other means (or by the version pass after the merge) leave "Done" too.
|
||||
|
||||
### Changed
|
||||
|
||||
- The "Done" column is now the rightmost column of the factory board.
|
||||
|
||||
## [v202611-00050] – 2026-11-16
|
||||
|
||||
### Fixed
|
||||
|
||||
- The factory's planning chats (spec chat, "Plan a feature", "Cut a milestone") no longer run the review loop
|
||||
of the agent mode (the "refine" rounds of build mode), which checked their answers as if they were code.
|
||||
|
||||
## [v202611-00049] – 2026-11-16
|
||||
|
||||
### Added
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img alt="Version v202611-00049" src="https://img.shields.io/badge/version-v202611--00049-d69e2e?style=flat-square">
|
||||
<img alt="Version v202611-00051" src="https://img.shields.io/badge/version-v202611--00051-d69e2e?style=flat-square">
|
||||
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-689d6a?style=flat-square">
|
||||
<img alt="Rust backend" src="https://img.shields.io/badge/backend-Rust-b7410e?style=flat-square&logo=rust">
|
||||
<img alt="React PWA" src="https://img.shields.io/badge/frontend-React%20PWA-2d81ff?style=flat-square&logo=react">
|
||||
|
||||
@@ -169,6 +169,7 @@ pub fn router(app: AppState) -> Router {
|
||||
.route("/factory/issue-chats/{id}/create", post(factory_create_issues))
|
||||
.route("/factory/release/preview", get(factory_release_preview))
|
||||
.route("/factory/release", post(factory_release))
|
||||
.route("/factory/issues/close", post(factory_close_issue))
|
||||
.route("/factory/issues/pr", get(factory_pr))
|
||||
.route("/factory/issues/pr/merge", post(factory_pr_merge))
|
||||
.route("/account/factory/connection/test", post(test_factory_connection))
|
||||
@@ -2752,6 +2753,29 @@ async fn factory_create_issues(Extension(user): Extension<User>, State(app): Sta
|
||||
Ok(Json(json!({"created": created})))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct CloseIssue {
|
||||
repo: String,
|
||||
number: i64,
|
||||
#[serde(default)]
|
||||
comment: String,
|
||||
}
|
||||
|
||||
/// Close a finished issue: a comment, then the issue on the forge; only then it leaves "done".
|
||||
async fn factory_close_issue(Extension(user): Extension<User>, State(app): State<AppState>, headers: axum::http::HeaderMap, Json(b): Json<CloseIssue>) -> ApiResult {
|
||||
let (g, row) = factory_issue_forge(&app, &user, &b.repo, b.number)?;
|
||||
if row["state"].as_str() != Some("done") {
|
||||
return Err(ApiError(StatusCode::BAD_REQUEST, "only finished issues can be closed here".into()));
|
||||
}
|
||||
let bad = |e: anyhow::Error| ApiError(StatusCode::BAD_GATEWAY, format!("{e:#}"));
|
||||
let text = if b.comment.trim().is_empty() { "Closed.".to_string() } else { b.comment.trim().to_string() };
|
||||
g.comment(b.number as u64, &format!("{}\n**Closed** by {}: {text}", crate::factory::BOT, user.username)).await.map_err(bad)?;
|
||||
g.close_issue(b.number as u64).await.map_err(bad)?;
|
||||
app.store.factory_issue_set(&b.repo, b.number, &[("state", json!("closed"))])?;
|
||||
app.audit(Some(&user), "factory.issue.close", &format!("{}#{}", b.repo, b.number), &crate::auth::client_ip(&headers));
|
||||
Ok(Json(json!({"ok": true})))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct PrQuery {
|
||||
repo: String,
|
||||
|
||||
+35
-1
@@ -552,6 +552,12 @@ impl Forge {
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Is the issue still open on the forge?
|
||||
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?;
|
||||
Ok(!matches!(v["state"].as_str(), Some("closed")))
|
||||
}
|
||||
|
||||
pub async fn close_issue(&self, number: u64) -> Result<()> {
|
||||
match self.kind {
|
||||
Kind::Gitlab => self.call(reqwest::Method::PUT, self.rp(&format!("/issues/{number}")), Some(json!({"state_event": "close"}))).await.map(|_| ()),
|
||||
@@ -730,7 +736,7 @@ fn urlenc(s: &str) -> String {
|
||||
// --- engine -----------------------------------------------------------------------
|
||||
|
||||
/// The marker with which every bot comment starts (the poller ignores these when it looks for answers).
|
||||
const BOT: &str = "<!-- codecraft-factory -->";
|
||||
pub(crate) const BOT: &str = "<!-- codecraft-factory -->";
|
||||
|
||||
/// Machine-readable result at the end of a phase: the last fenced ```json block, else the last
|
||||
/// top-level object in the text. Needs a "decision" field.
|
||||
@@ -1334,6 +1340,14 @@ pub async fn poll_repo(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<()>
|
||||
app.store.factory_issue_set(&cfg.url, n, &[("title", json!(title)), ("state", json!("review"))])?;
|
||||
tokio::spawn(review(app.clone(), user.clone(), cfg.clone(), issue, comments));
|
||||
}
|
||||
// Accepted issues that were closed on the forge (by hand or by the factory) leave the "done" column.
|
||||
let open: Vec<i64> = g.issues(&cfg.label).await.unwrap_or_default().iter().map(issue_no).collect();
|
||||
for row in app.store.factory_issues(&user.id)?.into_iter().filter(|r| r["repo"].as_str() == Some(cfg.url.as_str()) && r["state"].as_str() == Some("done")) {
|
||||
let n = issue_no(&row);
|
||||
if !open.contains(&n) && !g.issue_is_open(n as u64).await.unwrap_or(true) {
|
||||
app.store.factory_issue_set(&cfg.url, n, &[("state", json!("closed"))])?;
|
||||
}
|
||||
}
|
||||
// Merged issues get their version and tag.
|
||||
if let Err(e) = crate::factory_version::version_pass(app, user, cfg).await {
|
||||
tracing::warn!("factory {}: versions: {e:#}", cfg.url);
|
||||
@@ -1529,6 +1543,16 @@ pub fn draft_of(app: &App, user: &User, session: &crate::types::Session) -> Opti
|
||||
(session.owner_id.as_deref() == Some(&user.id) && cwd.starts_with(&home) && cwd != home).then_some(cwd)
|
||||
}
|
||||
|
||||
/// Is this a planning chat of the factory (spec chat in `_drafts`, issue chat in `_issues`)? They produce
|
||||
/// text, not code, so the review loop of the agent mode is switched off for them.
|
||||
pub fn is_planning_chat(app: &App, session: &crate::types::Session) -> bool {
|
||||
app.factory_dir().is_some_and(|dir| is_planning_path(&dir, std::path::Path::new(&session.cwd)))
|
||||
}
|
||||
|
||||
fn is_planning_path(factory: &std::path::Path, cwd: &std::path::Path) -> bool {
|
||||
cwd.strip_prefix(factory).map(|rel| rel.components().any(|c| c.as_os_str() == "_drafts" || c.as_os_str() == "_issues")).unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Start a spec chat with the given model.
|
||||
pub fn start_spec_chat(app: &Arc<App>, user: &User, model: &str) -> Result<crate::types::Session> {
|
||||
let id = crate::types::new_id();
|
||||
@@ -1804,6 +1828,16 @@ mod tests {
|
||||
assert!(parse_result(t).is_some_and(|v| v["decision"] == "issues"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn planning_chats_are_recognised_by_their_folder() {
|
||||
let f = std::path::Path::new("/factory");
|
||||
assert!(is_planning_path(f, std::path::Path::new("/factory/zink/_drafts/abc")));
|
||||
assert!(is_planning_path(f, std::path::Path::new("/factory/zink/_issues/abc")));
|
||||
assert!(!is_planning_path(f, std::path::Path::new("/factory/zink/zink/dunkelfeld")));
|
||||
assert!(!is_planning_path(f, std::path::Path::new("/factory/zink/zink/_work/dunkelfeld-1")));
|
||||
assert!(!is_planning_path(f, std::path::Path::new("/workspace/_drafts/x")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encodes_labels() {
|
||||
assert_eq!(urlenc("factory:qa"), "factory%3Aqa");
|
||||
|
||||
@@ -195,11 +195,11 @@ fn pr_number(url: &str) -> u64 {
|
||||
pub async fn version_pass(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<()> {
|
||||
let Some(_guard) = busy(&cfg.url) else { return Ok(()) };
|
||||
let rows: Vec<Value> = app.store.factory_issues(&user.id)?.into_iter().filter(|r| r["repo"].as_str() == Some(cfg.url.as_str())).collect();
|
||||
let pending = |r: &&Value| r["state"].as_str() == Some("done") && r["version"].as_str() == Some("");
|
||||
let pending = |r: &&Value| matches!(r["state"].as_str(), Some("done") | Some("closed")) && r["version"].as_str() == Some("") && !r["pr_url"].as_str().unwrap_or("").is_empty();
|
||||
if app.store.factory_version(&cfg.url)?.is_none() {
|
||||
let dir = checkout(app, user, cfg).await?;
|
||||
let cur = tags_version(cfg, &dir).await;
|
||||
for r in rows.iter().filter(pending) {
|
||||
for r in rows.iter().filter(|r| matches!(r["state"].as_str(), Some("done") | Some("closed")) && r["version"].as_str() == Some("")) {
|
||||
app.store.factory_issue_set(&cfg.url, issue_no(r), &[("version", json!("-"))])?;
|
||||
}
|
||||
app.store.factory_version_set(&cfg.url, &fmt(cur))?;
|
||||
@@ -251,7 +251,7 @@ pub async fn version_pass(app: &Arc<App>, user: &User, cfg: &RepoCfg) -> Result<
|
||||
}
|
||||
};
|
||||
let _ = checkout(app, user, cfg).await; // pulls the merge and the VERSION commit
|
||||
app.store.factory_issue_set(&cfg.url, n, &[("version", json!(new.clone()))])?;
|
||||
app.store.factory_issue_set(&cfg.url, n, &[("version", json!(new.clone())), ("state", json!("closed"))])?;
|
||||
app.store.factory_version_set(&cfg.url, &new)?;
|
||||
let _ = g.close_issue(n as u64).await;
|
||||
let why = if bump == Bump::Minor && milestone_of(&title).is_some() { " – the milestone is complete" } else { "" };
|
||||
|
||||
@@ -293,6 +293,10 @@ pub async fn run_session(app: Arc<App>, session_id: &str, cancel: CancellationTo
|
||||
let roots = app.user_roots(session.owner_id.as_deref());
|
||||
let root = app.root_for(session.owner_id.as_deref(), &cwd);
|
||||
let mut agent = prompts::find_agent_for(&app, &root, &cwd, &session.agent, session.owner_id.as_deref());
|
||||
// Chats that plan (spec chat, issue chat) write no code: the mode's review of the work does not apply.
|
||||
if crate::factory::is_planning_chat(&app, &session) {
|
||||
agent.refine = None;
|
||||
}
|
||||
let clean_room = session.clean_room(app.config().craft.clean_room);
|
||||
// The craft prompt follows the session's clean room / deep switch.
|
||||
if agent.name == "craft" && agent.source == "builtin" {
|
||||
|
||||
@@ -118,8 +118,8 @@ const COLUMNS: { id: string; states: string[] }[] = [
|
||||
{ id: "approved", states: ["approved"] },
|
||||
{ id: "build", states: ["building", "rework"] },
|
||||
{ id: "qa", states: ["qa", "testing"] },
|
||||
{ id: "done", states: ["done"] },
|
||||
{ id: "failed", states: ["failed", "rejected"] },
|
||||
{ id: "done", states: ["done"] },
|
||||
];
|
||||
|
||||
const KIND_NAME: Record<string, string> = { gitea: "Gitea", github: "GitHub", gitlab: "GitLab" };
|
||||
@@ -324,6 +324,22 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
const closeIssue = async () => {
|
||||
if (!selected) return;
|
||||
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: selected.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
|
||||
if (comment === null) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await post("/factory/issues/close", { repo: selected.repo, number: selected.number, comment });
|
||||
toast(t("factory.closed"), "success");
|
||||
setSel("");
|
||||
await reload();
|
||||
} catch (e: any) {
|
||||
toast(e.message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
const phaseRunning = !!selected && ["review", "building", "testing"].includes(selected.state);
|
||||
|
||||
return (
|
||||
@@ -452,6 +468,11 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{selected && selected.state === "done" && (
|
||||
<button className="small" onClick={closeIssue} disabled={busy}>
|
||||
<Icon name="check" /> {t("factory.close")}
|
||||
</button>
|
||||
)}
|
||||
{selected && (
|
||||
<>
|
||||
<a className="small ghost button-link" href={issueUrl(selected.repo, selected.number)} target="_blank" rel="noreferrer">
|
||||
|
||||
@@ -1261,6 +1261,11 @@ export const de: Messages = {
|
||||
"release.state.running": "läuft",
|
||||
"release.state.done": "fertig",
|
||||
"release.state.failed": "fehlgeschlagen",
|
||||
"factory.close": "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.closeDefault": "Erledigt und abgenommen.",
|
||||
"factory.closed": "Issue geschlossen",
|
||||
"factory.pr": "Pull Request",
|
||||
"factory.round": "Runde {n}",
|
||||
"factory.openChat": "Chat öffnen",
|
||||
|
||||
@@ -1260,6 +1260,11 @@ export const en = {
|
||||
"release.state.running": "running",
|
||||
"release.state.done": "done",
|
||||
"release.state.failed": "failed",
|
||||
"factory.close": "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.closeDefault": "Done and accepted.",
|
||||
"factory.closed": "Issue closed",
|
||||
"factory.pr": "Pull request",
|
||||
"factory.round": "round {n}",
|
||||
"factory.openChat": "Open chat",
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
* under "unreleased"; scripts/release.sh renames the key to the release version.
|
||||
*/
|
||||
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
|
||||
"202611-00051": {
|
||||
en: ["Factory: close finished issues with a comment; the Done column moved to the right"],
|
||||
de: ["Factory: fertige Issues mit Kommentar schließen; die Spalte Fertig steht jetzt ganz rechts"],
|
||||
},
|
||||
"202611-00049": {
|
||||
en: ["Factory: every merged issue gets a version and a git tag (patch per issue, minor per finished milestone)", "Factory: start a release with Docker image (amd64 + arm64), downloads and a release on the forge", "Factory: set the number of rework rounds and tries per phase"],
|
||||
de: ["Factory: jedes gemergte Issue bekommt eine Version und einen Git-Tag (Patch je Issue, Minor je abgeschlossenem Meilenstein)", "Factory: Release mit Docker-Image (amd64 + arm64), Downloads und Release auf der Forge anstoßen", "Factory: Anzahl der Nachbesserungsrunden und Versuche je Phase einstellbar"],
|
||||
|
||||
Reference in new issue
Block a user