From 1b27a0c9b1c8a6985f1b4cf3a800a46867367a31 Mon Sep 17 00:00:00 2001 From: "claude@clouddev1" Date: Fri, 8 May 2026 09:15:19 +0000 Subject: [PATCH] runtime: suppress silent-rebuild banner for empty projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A fresh-launch temp project enters run() with no .db, calls rebuild_from_text on an empty schema, and used to surface a "[ok] rebuild — 0 tables and 0 rows will be reconstructed" note that conveyed no information. Now we only emit the note when the project actually has tables. The explicit `rebuild` command still always reports its summary — the user asked. --- src/runtime.rs | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/runtime.rs b/src/runtime.rs index 7beed1b..7477b9f 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -133,13 +133,21 @@ pub async fn run(args: Args) -> Result<()> { match database.rebuild_from_text(project_path.clone(), None).await { Ok(()) => { // Surface the silent rebuild as a system note - // so the user sees that the .db was - // reconstructed rather than wondering whether - // anything happened. - let summary = summarize_project(&project_path).unwrap_or_else(|_| { - "rebuilt playground.db from project.yaml + data/".to_string() - }); - initial_events.push(AppEvent::RebuildSucceeded { summary }); + // *only* when there was something material to + // reconstruct. A fresh-launch temp project + // hits this branch with zero tables and zero + // rows — the rebuild ran, but nothing + // reconstructable existed, so there's nothing + // worth telling the user. The explicit + // `rebuild` command still always reports its + // summary (see spawn_rebuild) since the user + // asked. + if project_has_content(&project_path) { + let summary = summarize_project(&project_path).unwrap_or_else(|_| { + "rebuilt playground.db from project.yaml + data/".to_string() + }); + initial_events.push(AppEvent::RebuildSucceeded { summary }); + } } Err(e) => { // The terminal is still in cooked mode here @@ -813,6 +821,27 @@ fn spawn_prepare_rebuild( }); } +/// Does the project at `project_path` actually have any +/// schema or data? +/// +/// "Has content" means at least one table is declared in +/// `project.yaml` OR at least one CSV row exists under +/// `data/`. A brand-new auto-named temp project, having +/// neither, returns `false`. Errors reading the project +/// (corrupt YAML, missing dir) also return `false` — +/// suppressing a misleading "0 tables reconstructed" +/// message for a project we can't read is the right default. +fn project_has_content(project_path: &std::path::Path) -> bool { + let yaml_path = project_path.join(crate::project::PROJECT_YAML); + let Ok(yaml) = std::fs::read_to_string(&yaml_path) else { + return false; + }; + let Ok(snapshot) = crate::persistence::parse_schema(&yaml) else { + return false; + }; + !snapshot.tables.is_empty() +} + fn summarize_project(project_path: &std::path::Path) -> Result { let yaml_path = project_path.join(crate::project::PROJECT_YAML); let yaml = std::fs::read_to_string(&yaml_path).map_err(|e| e.to_string())?;