From 7a1fc9b45cdbfa8a818a2caa1dc627c7bf4bb035 Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:26:36 -0400 Subject: [PATCH] feat(app): present a readable terminal startup panel --- prototype/channel-server/src/app.rs | 33 +++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/prototype/channel-server/src/app.rs b/prototype/channel-server/src/app.rs index 79bba4896..d6bc96cb3 100644 --- a/prototype/channel-server/src/app.rs +++ b/prototype/channel-server/src/app.rs @@ -69,6 +69,33 @@ const PACKAGE_TARGET: &str = match option_env!("PIIK_BUILD_TARGET") { None => "", }; +fn startup_panel(version: &str, revision: &str, port: u16) -> String { + let revision = if revision.len() == 40 && revision.bytes().all(|byte| byte.is_ascii_hexdigit()) + { + &revision[..7] + } else { + revision + }; + // The shared terminal TV's static wink needs neither ANSI nor a redraw loop. + format!( + r#" + \ / + .----v----. Piik App + | o - | {version} + '---------' Build {revision} + / \ + + App launcher / App 启动页 + http://127.0.0.1:{port}/client + + Share and chat in your browser. + 在浏览器中分享和聊天。 + + Ctrl+C to quit / 按 Ctrl+C 正常退出 +"# + ) +} + pub struct Config { pub data_root: PathBuf, pub assets: PathBuf, @@ -360,9 +387,11 @@ pub async fn serve( .layer(DefaultBodyLimit::max(MAX_REQUEST_BYTES)) .layer(middleware::from_fn_with_state(app.clone(), access)) .with_state(app.clone()); - eprintln!("Piik App {BUILD_VERSION}\nBuild {BUILD_REVISION}"); + eprint!( + "{}", + startup_panel(BUILD_VERSION, BUILD_REVISION, address.port()) + ); eprintln!("App room socket listening on {address}"); - eprintln!("Open Piik App: {entry}"); if let Some(ready) = ready { let _ = ready.send(entry.clone()); }