Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 139 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ Already installed? Open **Settings → Check for Updates** to upgrade in-app.

Then open `http://localhost:7070` in your local browser. Keep the SSH session running while you use HarnessKit.

> <sub>**Tip:** Managing several remote nodes? Start each with `hk serve --name <label>` (e.g. `--name my-macbook`). The label shows in the sidebar and the browser tab title, so multiple tabs are easy to tell apart. Defaults to the machine hostname.</sub>

<details>
<summary><strong>Manual download</strong> — if you prefer not to use the install script, or your machine doesn't have <code>curl</code></summary>

Expand Down
2 changes: 2 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ HarnessKit Web UI running at http://127.0.0.1:7070

然后在本地浏览器打开 `http://localhost:7070`。使用 HarnessKit 期间请保持该 SSH 会话开启。

> <sub>**提示:** 管理多个远程节点时,用 `hk serve --name <标签>` 启动(如 `--name my-macbook`)。标签会显示在侧边栏和浏览器标签页标题里,多个 tab 一眼就能区分。默认取机器主机名。</sub>

<details>
<summary><strong>手动下载</strong> —— 如果你不想用安装脚本,或机器上没有 <code>curl</code></summary>

Expand Down
8 changes: 7 additions & 1 deletion crates/hk-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ enum Commands {
/// Access token (auto-generated for non-localhost binds if omitted)
#[arg(long)]
token: Option<String>,

/// Node label shown in the web UI (defaults to the machine hostname).
/// Useful when opening multiple tabs against different remote nodes.
#[arg(long)]
name: Option<String>,
},
}

fn main() -> Result<()> {
let cli = Cli::parse();

if let Commands::Serve { port, host, token } = cli.command {
if let Commands::Serve { port, host, token, name } = cli.command {
let effective_token = if host != "127.0.0.1" {
Some(token.unwrap_or_else(|| {
use rand::Rng;
Expand All @@ -111,6 +116,7 @@ fn main() -> Result<()> {
port,
host,
token: effective_token,
name,
}))?;
return Ok(());
}
Expand Down
2 changes: 2 additions & 0 deletions crates/hk-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ rand = "0.9"
tempfile = "3"
mime_guess = "2"
uuid.workspace = true
gethostname = "1"
local-ip-address = "0.6"

[dev-dependencies]
tokio = { version = "1", features = ["full", "test-util"] }
Expand Down
1 change: 1 addition & 0 deletions crates/hk-web/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod install;
pub mod kits;
pub mod marketplace;
pub mod projects;
pub mod server;
pub mod settings;

use hk_core::store::Store;
Expand Down
18 changes: 18 additions & 0 deletions crates/hk-web/src/handlers/server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use axum::extract::State;
use axum::Json;
use serde::Serialize;

use crate::state::WebState;

/// Identity of the node serving this UI. Lets the frontend distinguish multiple
/// browser tabs that each point at a different remote `hk serve` instance.
#[derive(Serialize)]
pub struct ServerInfo {
pub node_name: String,
}

pub async fn server_info(State(state): State<WebState>) -> Json<ServerInfo> {
Json(ServerInfo {
node_name: state.node_name.clone(),
})
}
Loading
Loading