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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*.ico binary
*.gif binary
*.webp binary
*.pdf binary
*.woff binary
*.woff2 binary
*.exe binary
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ and listed with their assets on the

### Added

- **A tray icon on Windows, Linux and macOS** (ADR-0060, #1). The hub
starts `devstack tray`: the dashboard's mark in the notification area
(Windows), as a StatusNotifierItem (Linux: KDE, Xfce, GNOME with the
AppIndicator extension; the binary stays static) or in the menu bar
(macOS, from the menu bar client contributed in #248). Green when
something runs, amber while a stack starts or stops, red when something
needs attention, grey when nothing runs. Its menu opens the dashboard,
lists every stack with what needs attention (a click opens that service
in the dashboard), and starts, stops or opens a stack's folder. It is a
client of the hub, which says what it shows (`GET /hub/summary`, the same
as what notifies); quitting it stops nothing. `devstack hub tray off`
keeps it off, `on` brings it back; `DEVSTACK_NO_TRAY` too.
- **A profile can leave out containers, whole Compose groups and services**
(ADR-0058, #244). `[profiles.<name>] skip = ["compose.search",
"compose.app.scanner", "indexer"]` makes a light profile for daily work:
Expand Down
5 changes: 5 additions & 0 deletions Cargo.lock

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

35 changes: 34 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,37 @@ jiff = "0.2"
libc = "0.2"
# Mach host and time calls on macOS that libc marks deprecated (ADR-0054).
mach2 = "0.7"
# The tray's status item on macOS (ADR-0060), linked on macOS only.
objc2 = "0.6"
objc2-app-kit = { version = "0.3.2", default-features = false, features = [
"std",
"NSApplication",
"NSButton",
"NSColor",
"NSControl",
"NSEvent",
"NSGraphicsContext",
"NSImage",
"NSMenu",
"NSMenuItem",
"NSResponder",
"NSRunningApplication",
"NSStatusBar",
"NSStatusBarButton",
"NSStatusItem",
"NSView",
"objc2-core-foundation",
] }
objc2-foundation = { version = "0.3.2", default-features = false, features = [
"std",
"NSData",
"NSDate",
"NSGeometry",
"NSObject",
"NSRunLoop",
"NSString",
"NSTimer",
] }
notify = "8"
rand = "0.10"
raw-window-handle = "0.6"
Expand Down Expand Up @@ -63,9 +94,10 @@ tar = "0.4"
# WinRT toasts (ADR-0045); windows-sys has no WinRT.
windows = { version = "0.62", features = ["Data_Xml_Dom", "Foundation", "UI_Notifications"] }
# Desktop notifications on Linux over the session bus, pure Rust (ADR-0045).
zbus = { version = "6", default-features = false, features = ["tokio", "proxy"] }
zbus = { version = "6", default-features = false, features = ["tokio", "proxy", "service"] }
windows-sys = { version = "0.61", features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_NetworkManagement_IpHelper",
"Win32_Security",
"Win32_Storage_FileSystem",
Expand All @@ -76,6 +108,7 @@ windows-sys = { version = "0.61", features = [
"Win32_System_Console",
"Win32_System_Diagnostics_ToolHelp",
"Win32_System_JobObjects",
"Win32_System_LibraryLoader",
"Win32_System_Threading",
"Win32_UI_Input_KeyboardAndMouse",
"Win32_UI_Shell",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Every command and flag: `devstack --help`, `devstack <command> --help`.
| `devstack lane list\|start\|stop\|reset\|prune\|move\|share` | the lanes (worktrees), see above; `reset` throws a stopped lane's data away, `prune` removes what gone lanes left behind |
| `devstack ui [--lane <name>] [--browser <name\|path>] [--link\|--print]` | open and pair the dashboard, on this stack (in a worktree on its lane, or on `--lane`); the browser is `--browser`, else `DEVSTACK_BROWSER`, else `BROWSER`, else the system's default. `--link` prints the lasting links to the stack or lane instead (the page, and the `devstack://open` link that pairs first); `--print` the one-time pairing link. `status`, `up` and `lane start` end with the page as `dashboard: <url>` |
| `devstack hub [status\|stop\|start\|install\|uninstall]` | the hub that serves the dashboard: without an action in the foreground; `stop` leaves the stacks running; `install` registers it at logon and the `devstack://` link (`--no-autostart`: the link only), `uninstall` removes both, and `devstack up` then leaves them alone |
| `devstack hub tray [on\|off]` | the tray icon ([ADR-0060](docs/adr/0060-the-tray-is-a-client-of-the-hub.md)): the state of every stack in the icon's colour, a menu to open the dashboard, start or stop a stack and open its folder. The hub starts it (`devstack tray`); `off` ends it and keeps it off, `on` brings it back. Windows, Linux (a StatusNotifierItem: KDE, Xfce, GNOME with the AppIndicator extension) and macOS |
| `devstack skills install [--dir] [--force]`, `skills check` | write the agent skills; check that they match this devstack and stack file (exits 1 when not) |
| `devstack mcp` | the MCP server (above) |
| `devstack join <url> --fingerprint <fp> [--name] [--pool] [--telemetry] [--no-wait]` | ask a pool to admit this machine ([pool.md](docs/pool.md#join-a-pool)) |
Expand Down Expand Up @@ -254,6 +255,7 @@ dashboard ─────┘ one per repo, └── services: main slot (f
| `DEVSTACK_HUB_PORT` | the hub's port (default 4250) |
| `DEVSTACK_NO_HUB` | `devstack up` does not start the dashboard hub |
| `DEVSTACK_NO_HUB_INTEGRATION` | the installer registers no hub at logon and no `devstack://` link (and records that); `devstack up` registers neither while it is set |
| `DEVSTACK_NO_TRAY` | the hub does not start the tray icon (`devstack hub tray off` keeps it off for good) |
| `DEVSTACK_NO_NOTIFY` | the hub shows no desktop notifications (they are set per kind with `devstack hub notify` or the bell in the dashboard) |
| `DEVSTACK_NO_UPDATE_CHECK` | no check for a newer release |
| `DEVSTACK_OTLP_ENDPOINT` | devstack's own diagnostic log also to this OTLP/HTTP collector |
Expand Down
8 changes: 7 additions & 1 deletion crates/devstack-desktop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "devstack-desktop"
description = "The desktop devstack runs on, one module per operating system: the hub at logon, the devstack:// link, notifications, the folder dialog, browsers and programs, starting Docker, how devstack was installed (ADR-0054)"
description = "The desktop devstack runs on, one module per operating system: the hub at logon, the devstack:// link, notifications, the tray, the folder dialog, browsers and programs, starting Docker, how devstack was installed (ADR-0054)"
version.workspace = true
license.workspace = true
edition.workspace = true
Expand All @@ -22,12 +22,18 @@ windows-sys.workspace = true
# uses osascript there.
[target.'cfg(target_os = "linux")'.dependencies]
rfd.workspace = true
serde.workspace = true
tokio-stream.workspace = true
zbus.workspace = true

[target.'cfg(unix)'.dependencies]
libc.workspace = true

[target.'cfg(target_os = "macos")'.dependencies]
objc2.workspace = true
objc2-app-kit.workspace = true
objc2-foundation.workspace = true

[dev-dependencies]
tempfile.workspace = true

Expand Down
1 change: 1 addition & 0 deletions crates/devstack-desktop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod channel;
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
mod mac;
pub mod notify;
pub mod tray;

#[cfg(target_os = "linux")]
mod linux;
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions crates/devstack-desktop/src/tray/assets/devstack-template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
172 changes: 172 additions & 0 deletions crates/devstack-desktop/src/tray/icon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
//! The tray's icon on Windows and Linux: the dashboard's mark (`ui/public/
//! favicon.svg`, three strokes and a dot on a dark rounded square), drawn
//! at the size the platform asks for, with the middle stroke and the dot in
//! the state's colour and both larger than in the favicon, so the state
//! shows at 16 pixels. macOS takes a template image instead (`macos.rs`).

use super::Tone;

/// In the favicon's 512-unit square.
const BACKGROUND: [u8; 3] = [0x0f, 0x11, 0x15];
const BLUE: [u8; 3] = [0x5b, 0x8c, 0xff];

fn colour(tone: Tone) -> [u8; 3] {
match tone {
Tone::Ok => [0x3e, 0xcf, 0x8e],
Tone::Busy => [0xf5, 0xa5, 0x24],
Tone::Attention => [0xf0, 0x52, 0x4f],
Tone::Idle => [0x8b, 0x92, 0x9e],
}
}

/// One shape: how much of the point `(x, y)` (512 units) it covers.
enum Shape {
/// A rounded square over the whole icon, corner radius.
Square(f32),
/// A line from `x0` to `x1` at `y`, with round caps of radius `r`.
Stroke {
x0: f32,
x1: f32,
y: f32,
r: f32,
},
Dot {
x: f32,
y: f32,
r: f32,
},
}

impl Shape {
fn inside(&self, x: f32, y: f32) -> bool {
match *self {
Shape::Square(r) => {
let cx = x.clamp(r, 512.0 - r);
let cy = y.clamp(r, 512.0 - r);
(x - cx).powi(2) + (y - cy).powi(2) <= r * r
}
Shape::Stroke { x0, x1, y: sy, r } => {
let cx = x.clamp(x0, x1);
(x - cx).powi(2) + (y - sy).powi(2) <= r * r
}
Shape::Dot { x: dx, y: dy, r } => (x - dx).powi(2) + (y - dy).powi(2) <= r * r,
}
}
}

/// The icon as `size`×`size` pixels, RGBA with straight alpha, rows from
/// the top.
pub fn rgba(size: u32, tone: Tone) -> Vec<u8> {
let state = colour(tone);
// Painted in order, each over the last: (shape, colour, opacity).
let shapes = [
(Shape::Square(112.0), BACKGROUND, 1.0),
(
Shape::Stroke {
x0: 120.0,
x1: 392.0,
y: 150.0,
r: 30.0,
},
BLUE,
1.0,
),
(
Shape::Stroke {
x0: 120.0,
x1: 248.0,
y: 256.0,
r: 30.0,
},
state,
1.0,
),
(
Shape::Stroke {
x0: 120.0,
x1: 392.0,
y: 362.0,
r: 30.0,
},
BLUE,
0.55,
),
(
Shape::Dot {
x: 352.0,
y: 256.0,
r: 62.0,
},
state,
1.0,
),
];
const SAMPLES: u32 = 4;
let unit = 512.0 / size as f32;
let mut out = Vec::with_capacity((size * size * 4) as usize);
for py in 0..size {
for px in 0..size {
// Straight colour and alpha, composited per sample, averaged.
let (mut r, mut g, mut b, mut a) = (0.0f32, 0.0f32, 0.0f32, 0.0f32);
for sy in 0..SAMPLES {
for sx in 0..SAMPLES {
let x = (px as f32 + (sx as f32 + 0.5) / SAMPLES as f32) * unit;
let y = (py as f32 + (sy as f32 + 0.5) / SAMPLES as f32) * unit;
let mut c = [0.0f32; 3];
let mut alpha = 0.0f32;
for (shape, col, op) in &shapes {
if shape.inside(x, y) {
let k = *op;
for (ci, &cc) in c.iter_mut().zip(col) {
*ci = *ci * (1.0 - k) + cc as f32 * k;
}
alpha = alpha * (1.0 - k) + k;
}
}
// Premultiplied while summing, so edges do not darken.
r += c[0] * alpha;
g += c[1] * alpha;
b += c[2] * alpha;
a += alpha;
}
}
let n = (SAMPLES * SAMPLES) as f32;
if a > 0.0 {
out.extend([
(r / a).round() as u8,
(g / a).round() as u8,
(b / a).round() as u8,
(a / n * 255.0).round() as u8,
]);
} else {
out.extend([0, 0, 0, 0]);
}
}
}
out
}

#[cfg(test)]
mod tests {
use super::*;

fn pixel(img: &[u8], size: u32, x: u32, y: u32) -> [u8; 4] {
let i = ((y * size + x) * 4) as usize;
[img[i], img[i + 1], img[i + 2], img[i + 3]]
}

#[test]
fn the_dot_has_the_states_colour_and_the_corners_are_clear() {
for size in [16, 22, 32, 48] {
for tone in [Tone::Idle, Tone::Ok, Tone::Busy, Tone::Attention] {
let img = rgba(size, tone);
assert_eq!(img.len(), (size * size * 4) as usize);
assert_eq!(pixel(&img, size, 0, 0)[3], 0, "corner at {size}");
// The dot's centre, (352, 256) of 512.
let p = pixel(&img, size, size * 352 / 512, size / 2);
assert_eq!(p[..3], colour(tone), "{tone:?} at {size}");
assert_eq!(p[3], 255);
}
}
}
}
Loading
Loading