on main help sign in
refactor: now make cli more consistent
commit2ef40113352aba6f71541a74fbb6ba0359a4e83e authorrobcholz <84130577+robcholz@users.noreply.github.com> dateSat 7 Feb 2026, 18:15 (8 months ago) parentdf08e45
4 files changed+89−22
docs/tasks.md+2−1 src/bin/vibebox-cli.rs+57−11 src/bin/vibebox-supervisor.rs+21−7 src/instance.rs+9−3
docs/tasks.md+2−1
@@ -48,7 +48,8 @@
4848 3. [x] add an actual config file.
4949 4. [x] set up the cli.
50509. [ ] fix ui overlap, and consistency issue.
51−10. [ ] intensive integration test.
51+10. [ ] `clean_cache` to cleanup the cache.
52+11. [ ] intensive integration test.
5253
5354## Publish
5455
src/bin/vibebox-cli.rs+57−11
@@ -11,7 +11,8 @@ use color_eyre::Result;
1111use dialoguer::Confirm;
1212use time::OffsetDateTime;
1313use time::format_description::well_known::Rfc3339;
14−use tracing_subscriber::EnvFilter;
14+use tracing_subscriber::filter::LevelFilter;
15+use tracing_subscriber::{EnvFilter, fmt, prelude::*};
1516
1617use vibebox::tui::{AppState, VmInfo};
1718use vibebox::{
@@ -39,11 +40,11 @@ enum Command {
3940}
4041
4142fn main() -> Result<()> {
42− init_tracing();
4343 color_eyre::install()?;
44+ let cwd = env::current_dir().map_err(|err| color_eyre::eyre::eyre!(err.to_string()))?;
45+ init_tracing(&cwd);
4446
4547 let cli = Cli::parse();
46− let cwd = env::current_dir().map_err(|err| color_eyre::eyre::eyre!(err.to_string()))?;
4748 tracing::info!(cwd = %cwd.display(), "starting vibebox cli");
4849 if let Some(command) = cli.command {
4950 return handle_command(command, &cwd, cli.config.as_deref());
@@ -249,13 +250,58 @@ fn format_last_active(value: Option<&str>) -> String {
249250 format!("{} day{} ago", days, if days == 1 { "" } else { "s" })
250251}
251252
252−fn init_tracing() {
253+fn init_tracing(cwd: &Path) {
253254 let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
254− let ansi = std::io::stderr().is_terminal() && env::var("VIBEBOX_LOG_NO_COLOR").is_err();
255− let _ = tracing_subscriber::fmt()
256− .with_env_filter(filter)
257− .with_target(false)
258− .with_ansi(ansi)
259− .with_writer(std::io::stderr)
260− .try_init();
255+ let stderr_is_tty = std::io::stderr().is_terminal();
256+ let ansi = stderr_is_tty && env::var("VIBEBOX_LOG_NO_COLOR").is_err();
257+ let file = instance::ensure_instance_dir(cwd)
258+ .ok()
259+ .and_then(|instance_dir| {
260+ let log_path = instance_dir.join("cli.log");
261+ std::fs::OpenOptions::new()
262+ .create(true)
263+ .write(true)
264+ .truncate(true)
265+ .open(log_path)
266+ .ok()
267+ });
268+
269+ if stderr_is_tty {
270+ let stderr_layer = fmt::layer()
271+ .with_target(false)
272+ .with_ansi(ansi)
273+ .without_time()
274+ .with_writer(std::io::stderr)
275+ .with_filter(LevelFilter::INFO);
276+ let subscriber = tracing_subscriber::registry()
277+ .with(filter)
278+ .with(stderr_layer);
279+ if let Some(file) = file {
280+ let file_layer = fmt::layer()
281+ .with_target(false)
282+ .with_ansi(false)
283+ .with_writer(file);
284+ let _ = subscriber.with(file_layer).try_init();
285+ } else {
286+ let _ = subscriber.try_init();
287+ }
288+ } else {
289+ let stderr_layer = fmt::layer()
290+ .with_target(false)
291+ .with_ansi(ansi)
292+ .with_writer(std::io::stderr)
293+ .with_filter(LevelFilter::INFO);
294+ let subscriber = tracing_subscriber::registry()
295+ .with(filter)
296+ .with(stderr_layer);
297+ if let Some(file) = file {
298+ let file_layer = fmt::layer()
299+ .with_target(false)
300+ .with_ansi(false)
301+ .with_writer(file);
302+ let _ = subscriber.with(file_layer).try_init();
303+ } else {
304+ let _ = subscriber.try_init();
305+ }
306+ }
261307}
src/bin/vibebox-supervisor.rs+21−7
@@ -5,6 +5,9 @@ use std::{
55
66use color_eyre::Result;
77use tracing_subscriber::EnvFilter;
8+use tracing_subscriber::filter::LevelFilter;
9+use tracing_subscriber::fmt;
10+use tracing_subscriber::prelude::*;
811
912use vibebox::{config, instance, vm, vm_manager};
1013
@@ -40,11 +43,22 @@ fn main() -> Result<()> {
4043
4144fn init_tracing() {
4245 let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
43− let ansi = std::io::stderr().is_terminal() && env::var("VIBEBOX_LOG_NO_COLOR").is_err();
44− let _ = tracing_subscriber::fmt()
45− .with_env_filter(filter)
46− .with_target(false)
47− .with_ansi(ansi)
48− .with_writer(io::stderr)
49− .try_init();
46+ let stderr_is_tty = std::io::stderr().is_terminal();
47+ let ansi = stderr_is_tty && env::var("VIBEBOX_LOG_NO_COLOR").is_err();
48+ if stderr_is_tty {
49+ let stderr_layer = fmt::layer()
50+ .with_target(false)
51+ .with_ansi(ansi)
52+ .without_time()
53+ .with_writer(io::stderr)
54+ .with_filter(LevelFilter::INFO);
55+ let _ = tracing_subscriber::registry().with(stderr_layer).try_init();
56+ } else {
57+ let stderr_layer = fmt::layer()
58+ .with_target(false)
59+ .with_ansi(ansi)
60+ .with_writer(io::stderr)
61+ .with_filter(filter);
62+ let _ = tracing_subscriber::registry().with(stderr_layer).try_init();
63+ }
5064}
src/instance.rs+9−3
@@ -72,7 +72,6 @@ pub fn run_with_ssh(manager_conn: UnixStream) -> Result<(), Box<dyn std::error::
7272 tracing::debug!(ssh_user = %ssh_user, "loaded instance config");
7373
7474 let _manager_conn = manager_conn;
75− tracing::debug!("waiting for vm ipv4");
7675 wait_for_vm_ipv4(&instance_dir, Duration::from_secs(120))?;
7776
7877 let ip = load_or_create_instance_config(&instance_dir)?
@@ -247,7 +246,8 @@ fn wait_for_vm_ipv4(
247246) -> Result<(), Box<dyn std::error::Error>> {
248247 let start = Instant::now();
249248 let mut next_log_at = start + Duration::from_secs(10);
250− tracing::debug!("waiting for vm ipv4");
249+ tracing::info!("waiting for vm ipv4");
250+ let mut once_hint = false;
251251 loop {
252252 let config = load_or_create_instance_config(instance_dir)?;
253253 if config.vm_ipv4.is_some() {
@@ -258,7 +258,13 @@ fn wait_for_vm_ipv4(
258258 }
259259 if Instant::now() >= next_log_at {
260260 let waited = start.elapsed();
261− tracing::debug!("still waiting for vm ipv4, {}s elapsed", waited.as_secs(),);
261+ if waited.as_secs() > 15 && !once_hint {
262+ tracing::info!(
263+ "if vibebox is just initialized in this directory, it might take up to 1 minutes depending on your machine, and then you can enjoy the speed vibecoding! go pack!"
264+ );
265+ once_hint = true;
266+ }
267+ tracing::info!("still waiting for vm ipv4, {}s elapsed", waited.as_secs(),);
262268 next_log_at += Duration::from_secs(10);
263269 }
264270 thread::sleep(Duration::from_millis(200));