Skip to content

Commit 5450611

Browse files
committed
feat: add desktop feature flag for headless builds
Make the desktop GUI (eframe/egui) optional via a `desktop` feature flag (enabled by default). Build with --no-default-features for headless server/Docker/CI environments where winit cannot compile.
1 parent 97cc609 commit 5450611

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ keywords = ["ai", "assistant", "llm", "memory", "local"]
1212
categories = ["command-line-utilities", "text-processing"]
1313

1414
[features]
15-
default = []
15+
default = ["desktop"]
16+
# Desktop GUI (eframe/egui). Disable for headless/server/Docker builds.
17+
desktop = ["eframe"]
1618
# GGUF embedding model support via llama.cpp (requires C++ compiler)
1719
gguf = ["llama-cpp-2"]
1820

@@ -81,8 +83,8 @@ regex = "1"
8183
once_cell = "1"
8284
fs2 = "0.4"
8385

84-
# Desktop GUI
85-
eframe = { version = "0.30", default-features = false, features = [
86+
# Desktop GUI (optional — disable with --no-default-features for headless builds)
87+
eframe = { version = "0.30", optional = true, default-features = false, features = [
8688
"default_fonts",
8789
"glow",
8890
"persistence",

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ A local device focused AI assistant built in Rust — persistent memory, autonom
1818
## Install
1919

2020
```bash
21+
# Full install (includes desktop GUI)
2122
cargo install localgpt
23+
24+
# Headless (no desktop GUI — for servers, Docker, CI)
25+
cargo install localgpt --no-default-features
2226
```
2327

2428
## Quick Start

src/cli/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub mod ask;
22
pub mod chat;
33
pub mod config;
44
pub mod daemon;
5+
#[cfg(feature = "desktop")]
56
pub mod desktop;
67
pub mod memory;
78

@@ -43,6 +44,7 @@ pub enum Commands {
4344
Ask(ask::AskArgs),
4445

4546
/// Launch the desktop GUI
47+
#[cfg(feature = "desktop")]
4648
Desktop(desktop::DesktopArgs),
4749

4850
/// Manage the daemon

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
pub mod agent;
1111
pub mod concurrency;
1212
pub mod config;
13+
#[cfg(feature = "desktop")]
1314
pub mod desktop;
1415
pub mod heartbeat;
1516
pub mod memory;

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async fn async_main(cli: Cli) -> Result<()> {
4545
match cli.command {
4646
Commands::Chat(args) => cli::chat::run(args, &cli.agent).await,
4747
Commands::Ask(args) => cli::ask::run(args, &cli.agent).await,
48+
#[cfg(feature = "desktop")]
4849
Commands::Desktop(args) => cli::desktop::run(args, &cli.agent),
4950
Commands::Daemon(args) => cli::daemon::run(args, &cli.agent).await,
5051
Commands::Memory(args) => cli::memory::run(args, &cli.agent).await,

0 commit comments

Comments
 (0)