Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
306befa1c1 | ||
|
|
d6b95d22f0 | ||
|
|
3fda4ab127 | ||
|
|
6734cab382 | ||
|
|
d6aabcfe93 | ||
|
|
5ef6a8b683 | ||
|
|
a477bc47f8 | ||
|
|
d14d79ce3b | ||
|
|
5804e986ce | ||
|
|
02dcf4d028 | ||
|
|
c6d9f59c4d | ||
|
|
59054b1f57 | ||
|
|
377229ab6d | ||
|
|
029a8b51a3 | ||
|
|
094b317a83 | ||
|
|
bb2a031135 | ||
|
|
eb61660d35 | ||
|
|
ac7923e01f | ||
|
|
daa6a59324 | ||
|
|
3130e56cfb | ||
|
|
7c9954ceec | ||
|
|
49a0a0d15f |
42 changed files with 2153 additions and 1518 deletions
|
|
@ -8,6 +8,12 @@ jobs:
|
||||||
check:
|
check:
|
||||||
name: nix flake check
|
name: nix flake check
|
||||||
runs-on: [hive-ci]
|
runs-on: [hive-ci]
|
||||||
|
# Bound the job so a wedged build fails in minutes instead of
|
||||||
|
# hanging until the runner's 3h cap (or, when the runner itself
|
||||||
|
# deadlocks, never). 30 min is well above a cold-cache rebuild
|
||||||
|
# (~15 min observed) and well under the 3h hard cap — tune if a
|
||||||
|
# legit cold build ever trips it.
|
||||||
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: check
|
- name: check
|
||||||
|
|
@ -15,3 +21,19 @@ jobs:
|
||||||
# cargo clippy, and module evaluation. No --no-build: the checks
|
# cargo clippy, and module evaluation. No --no-build: the checks
|
||||||
# derivations are the canonical source of truth.
|
# derivations are the canonical source of truth.
|
||||||
run: nix flake check
|
run: nix flake check
|
||||||
|
|
||||||
|
tracker-tags:
|
||||||
|
name: tracker-tag lint
|
||||||
|
runs-on: [hive-ci]
|
||||||
|
# Pure git+grep — seconds normally; a few minutes is already a hang.
|
||||||
|
timeout-minutes: 5
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: lint
|
||||||
|
# Flags hash-number tracker tags in source (hive convention is
|
||||||
|
# prose, not tags — /knowledge/hive-rules.md). Runs as its own
|
||||||
|
# job, kept out of the required checks while the legacy backlog
|
||||||
|
# is cleaned up: a hit fails this check (red) without blocking
|
||||||
|
# merge. Promote to a required check once the tree is clean.
|
||||||
|
# See scripts/check-issue-refs.sh.
|
||||||
|
run: sh scripts/check-issue-refs.sh
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ zero-sized impl (`AgentSurface`) wrapping:
|
||||||
|
|
||||||
- One async method per wire op: `ack_turn`, `requeue_inflight`,
|
- One async method per wire op: `ack_turn`, `requeue_inflight`,
|
||||||
`inbox_unread`, `post_turn_counts`, `send_to_parent`,
|
`inbox_unread`, `post_turn_counts`, `send_to_parent`,
|
||||||
`self_wake`, `recv_next`, `wake_external`.
|
`recv_next`, `wake_external`.
|
||||||
|
|
||||||
`main()` calls `serve_main::<AgentSurface>` for all roles. The turn
|
`main()` calls `serve_main::<AgentSurface>` for all roles. The turn
|
||||||
loop (`serve_loop` / `handle_turn` / `wake`) has no per-role branches.
|
loop (`serve_loop` / `handle_turn` / `wake`) has no per-role branches.
|
||||||
|
|
@ -117,9 +117,19 @@ and the manager fall through to operator).
|
||||||
|
|
||||||
After the outcome handler, the stats sink records a row and the
|
After the outcome handler, the stats sink records a row and the
|
||||||
`hyperhive-continue` sentinel (dropped by the `request_next_turn`
|
`hyperhive-continue` sentinel (dropped by the `request_next_turn`
|
||||||
MCP tool) is consumed if present, firing `self_wake` so the next
|
MCP tool) is consumed if present. `handle_turn` reports the result
|
||||||
turn starts with `{ from: "self", body: "continue" }` even if the
|
to `serve_loop` via `TurnControl { auth_failed, continue_requested,
|
||||||
inbox is empty.
|
pending }`. When a continue was requested, the turn did not
|
||||||
|
auth-fail, and the inbox is empty (`pending == 0`), `serve_loop`
|
||||||
|
drives the next turn in-process with a synthetic
|
||||||
|
`{ from: "self", body: "continue" }` message (`synthetic_continue`)
|
||||||
|
— it never goes through the broker, so the self-continue doesn't
|
||||||
|
persist to sqlite or show up as a recv'able inbox message. If real
|
||||||
|
messages are already pending the continue is dropped: those messages
|
||||||
|
drive the next turn(s) via `recv_next`, so an explicit self-wake
|
||||||
|
isn't needed (this is the `request_next_turn` contract — "no effect
|
||||||
|
if a new inbox message arrives before this turn ends"). The
|
||||||
|
`should_self_continue` predicate encodes exactly that decision.
|
||||||
|
|
||||||
## The claude invocation
|
## The claude invocation
|
||||||
|
|
||||||
|
|
|
||||||
27
flake.nix
27
flake.nix
|
|
@ -4,7 +4,7 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
||||||
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
# Crane (replaces naersk #538). Stateless — no nixpkgs input to
|
# Crane (replaces the former naersk-based build). Stateless — no nixpkgs input to
|
||||||
# follow; `crane.mkLib pkgs` returns the lib at whatever pkgs we
|
# follow; `crane.mkLib pkgs` returns the lib at whatever pkgs we
|
||||||
# pass it (we use the project's pinned nixpkgs).
|
# pass it (we use the project's pinned nixpkgs).
|
||||||
crane.url = "github:ipetkov/crane";
|
crane.url = "github:ipetkov/crane";
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
# cares about" filter (Cargo.toml/Cargo.lock + *.rs). All
|
# cares about" filter (Cargo.toml/Cargo.lock + *.rs). All
|
||||||
# non-rust runtime assets — branding + the claude system
|
# non-rust runtime assets — branding + the claude system
|
||||||
# prompt template + claude-settings.json — live in the
|
# prompt template + claude-settings.json — live in the
|
||||||
# separate `hyperhive-assets` derivation (#555) and are
|
# separate `hyperhive-assets` derivation and are
|
||||||
# loaded by the binaries at runtime from `$HIVE_ASSETS_DIR`.
|
# loaded by the binaries at runtime from `$HIVE_ASSETS_DIR`.
|
||||||
# The unit tests in `hive-ag3nt::prompt` read the same
|
# The unit tests in `hive-ag3nt::prompt` read the same
|
||||||
# `prompts/system.md` directly from the workspace tree at
|
# `prompts/system.md` directly from the workspace tree at
|
||||||
|
|
@ -91,10 +91,10 @@
|
||||||
# sandbox.
|
# sandbox.
|
||||||
# `librsvg` used to live here for `hive-c0re/build.rs`'s
|
# `librsvg` used to live here for `hive-c0re/build.rs`'s
|
||||||
# rsvg-convert call — that whole codepath moved into the
|
# rsvg-convert call — that whole codepath moved into the
|
||||||
# `hyperhive-assets` derivation in #555, so the rust
|
# `hyperhive-assets` derivation, so the rust
|
||||||
# derivation no longer needs the dependency.
|
# derivation no longer needs the dependency.
|
||||||
# `sqlite` required by matrix-sdk's `sqlite` feature
|
# `sqlite` required by matrix-sdk's `sqlite` feature
|
||||||
# (`hive-matrix-mcp` workspace member, #548 phase 3) — the
|
# (`hive-matrix-mcp` workspace member) — the
|
||||||
# matrix-sdk-sqlite + rusqlite stack links against system
|
# matrix-sdk-sqlite + rusqlite stack links against system
|
||||||
# libsqlite3 by default.
|
# libsqlite3 by default.
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
# prompt::tests` reads the production prompt template at test
|
# prompt::tests` reads the production prompt template at test
|
||||||
# runtime through `$HIVE_ASSETS_DIR`, so wiring the env var
|
# runtime through `$HIVE_ASSETS_DIR`, so wiring the env var
|
||||||
# into the build phase here would make the prompt's hash a
|
# into the build phase here would make the prompt's hash a
|
||||||
# build input of `default` (defeats #555's cache goal: a
|
# build input of `default` (defeats the asset-split cache goal: a
|
||||||
# prompt edit would still bust the binary derivation, even
|
# prompt edit would still bust the binary derivation, even
|
||||||
# though no .rs file changed). Keeping tests in a separate
|
# though no .rs file changed). Keeping tests in a separate
|
||||||
# check derivation localises the asset-rebuild blast radius
|
# check derivation localises the asset-rebuild blast radius
|
||||||
|
|
@ -144,12 +144,12 @@
|
||||||
};
|
};
|
||||||
# Bundled browser assets — see ./nix/frontend.nix. Output is
|
# Bundled browser assets — see ./nix/frontend.nix. Output is
|
||||||
# $out/{dashboard,agent}/ which the Rust binaries serve via
|
# $out/{dashboard,agent}/ which the Rust binaries serve via
|
||||||
# tower_http::ServeDir (wired up in Phase 4 of #273).
|
# tower_http::ServeDir.
|
||||||
frontend = pkgs.callPackage ./nix/frontend.nix {
|
frontend = pkgs.callPackage ./nix/frontend.nix {
|
||||||
branding-svg = ./branding/hyperhive.svg;
|
branding-svg = ./branding/hyperhive.svg;
|
||||||
};
|
};
|
||||||
# Static runtime assets the rust binaries read via
|
# Static runtime assets the rust binaries read via
|
||||||
# `hive_sh4re::assets::*` (#555): branding/* + prompts/*,
|
# `hive_sh4re::assets::*`: branding/* + prompts/*,
|
||||||
# plus the rendered agent-configs.png. Split out of the
|
# plus the rendered agent-configs.png. Split out of the
|
||||||
# rust derivation so a tweak to e.g. system.md doesn't bust
|
# rust derivation so a tweak to e.g. system.md doesn't bust
|
||||||
# the cargo cache. Build input of the `cargo-test` check but
|
# the cargo cache. Build input of the `cargo-test` check but
|
||||||
|
|
@ -164,7 +164,6 @@
|
||||||
# spawn dramatically because the heavy lifting (nixpkgs +
|
# spawn dramatically because the heavy lifting (nixpkgs +
|
||||||
# claude-code + hive-ag3nt binary) is already in the store
|
# claude-code + hive-ag3nt binary) is already in the store
|
||||||
# when the meta evaluator goes to build the container.
|
# when the meta evaluator goes to build the container.
|
||||||
# Closes #97.
|
|
||||||
#
|
#
|
||||||
# nixosConfigurations are pinned to x86_64-linux (nixos-
|
# nixosConfigurations are pinned to x86_64-linux (nixos-
|
||||||
# containers only run native arch), so these toplevels are
|
# containers only run native arch), so these toplevels are
|
||||||
|
|
@ -175,7 +174,7 @@
|
||||||
agent-base-toplevel = self.nixosConfigurations.agent-base.config.system.build.toplevel;
|
agent-base-toplevel = self.nixosConfigurations.agent-base.config.system.build.toplevel;
|
||||||
ruth-toplevel = self.nixosConfigurations.ruth.config.system.build.toplevel;
|
ruth-toplevel = self.nixosConfigurations.ruth.config.system.build.toplevel;
|
||||||
|
|
||||||
# Auto-generated nix options reference for hyperhive (#616).
|
# Auto-generated nix options reference for hyperhive.
|
||||||
# `docs` bundles host + agent pages into one tree; the split
|
# `docs` bundles host + agent pages into one tree; the split
|
||||||
# outputs are useful when consumers only want one surface.
|
# outputs are useful when consumers only want one surface.
|
||||||
# All three are pure markdown — no rust or frontend deps in
|
# All three are pure markdown — no rust or frontend deps in
|
||||||
|
|
@ -196,7 +195,7 @@
|
||||||
# is applied (manager + agent containers both apply it via
|
# is applied (manager + agent containers both apply it via
|
||||||
# `mkContainer` further down).
|
# `mkContainer` further down).
|
||||||
hyperhive-frontend = self.packages.${prev.stdenv.hostPlatform.system}.frontend;
|
hyperhive-frontend = self.packages.${prev.stdenv.hostPlatform.system}.frontend;
|
||||||
# Static runtime assets (#555). Exposed alongside the binary
|
# Static runtime assets. Exposed alongside the binary
|
||||||
# so the harness module can wire $HIVE_ASSETS_DIR straight
|
# so the harness module can wire $HIVE_ASSETS_DIR straight
|
||||||
# to `${pkgs.hyperhive-assets}/share/hyperhive`.
|
# to `${pkgs.hyperhive-assets}/share/hyperhive`.
|
||||||
hyperhive-assets = self.packages.${prev.stdenv.hostPlatform.system}.assets;
|
hyperhive-assets = self.packages.${prev.stdenv.hostPlatform.system}.assets;
|
||||||
|
|
@ -243,7 +242,7 @@
|
||||||
hyperhiveNixpkgsUnstable = "path:${nixpkgs-unstable}";
|
hyperhiveNixpkgsUnstable = "path:${nixpkgs-unstable}";
|
||||||
# Per-container toplevels — wired into `system.extraDependencies`
|
# Per-container toplevels — wired into `system.extraDependencies`
|
||||||
# when `services.hyperhive.c0re.preBuildAgentTemplates` is on so the
|
# when `services.hyperhive.c0re.preBuildAgentTemplates` is on so the
|
||||||
# host system closure pre-fetches the heavy build inputs (#97).
|
# host system closure pre-fetches the heavy build inputs.
|
||||||
# Defined only for x86_64-linux because nixosConfigurations are
|
# Defined only for x86_64-linux because nixosConfigurations are
|
||||||
# hardcoded to that system; the option's default keeps the
|
# hardcoded to that system; the option's default keeps the
|
||||||
# extra deps gated so aarch64 hosts don't accidentally pull
|
# extra deps gated so aarch64 hosts don't accidentally pull
|
||||||
|
|
@ -292,7 +291,7 @@
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
cargo
|
cargo
|
||||||
clippy
|
clippy
|
||||||
librsvg # rsvg-convert — hive-c0re/build.rs invokes it (#424)
|
librsvg # rsvg-convert — hive-c0re/build.rs invokes it
|
||||||
pkg-config
|
pkg-config
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
rustc
|
rustc
|
||||||
|
|
@ -331,7 +330,7 @@
|
||||||
# group from that gate: pedantic is the "extra, opinionated"
|
# group from that gate: pedantic is the "extra, opinionated"
|
||||||
# group the clippy team grows freely, so denying it means
|
# group the clippy team grows freely, so denying it means
|
||||||
# every toolchain bump that adds a new pedantic lint breaks CI
|
# every toolchain bump that adds a new pedantic lint breaks CI
|
||||||
# with zero code changes (#1368). The `pedantic = warn`
|
# with zero code changes. The `pedantic = warn`
|
||||||
# workspace lint (Cargo.toml) keeps it as advisory signal in
|
# workspace lint (Cargo.toml) keeps it as advisory signal in
|
||||||
# local `cargo clippy` — it just no longer blocks the build.
|
# local `cargo clippy` — it just no longer blocks the build.
|
||||||
# (`-A` rather than `-W` here: `-W clippy::pedantic` would
|
# (`-A` rather than `-W` here: `-W clippy::pedantic` would
|
||||||
|
|
@ -361,7 +360,7 @@
|
||||||
cargoTestExtraArgs = "--workspace";
|
cargoTestExtraArgs = "--workspace";
|
||||||
HIVE_ASSETS_DIR = "${self.packages.${system}.assets}/share/hyperhive";
|
HIVE_ASSETS_DIR = "${self.packages.${system}.assets}/share/hyperhive";
|
||||||
};
|
};
|
||||||
# Nix options docs evaluation (#616). Cheap: pulls in
|
# Nix options docs evaluation. Cheap: pulls in
|
||||||
# `nixosOptionsDoc` + the host module's stub eval, no rust or
|
# `nixosOptionsDoc` + the host module's stub eval, no rust or
|
||||||
# frontend deps. CI fails fast if a module change breaks
|
# frontend deps. CI fails fast if a module change breaks
|
||||||
# option declarations or the doc rendering. Reuses the
|
# option declarations or the doc rendering. Reuses the
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
@import "@hive/shared/base.css";
|
@import "@hive/shared/base.css";
|
||||||
@import "@hive/shared/terminal.css";
|
@import "@hive/shared/terminal.css";
|
||||||
@import "@hive/shared/tabs.css";
|
@import "@hive/shared/tabs.css";
|
||||||
|
@import "@hive/shared/chrome.css";
|
||||||
|
|
||||||
/* ─── global typography ─────────────────────────────────────────────
|
/* ─── global typography ─────────────────────────────────────────────
|
||||||
Element-level rules shared across all three pages (index, flow,
|
Element-level rules shared across all three pages (index, flow,
|
||||||
|
|
@ -220,38 +221,9 @@ code {
|
||||||
color: var(--fg);
|
color: var(--fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ─── page chrome: header + back link (flow + logs pages) ───────────
|
/* page chrome (.page-header / .page-back / .page-title — the standalone
|
||||||
.logs-header / .logs-back / .logs-title are used by both
|
pages' sticky back-link bar) moved to @hive/shared/chrome.css, imported
|
||||||
/flow.html and /logs.html — the same frosted sticky bar pattern. */
|
at the top of this file. */
|
||||||
.logs-header {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 25;
|
|
||||||
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
|
||||||
-webkit-backdrop-filter: blur(8px) saturate(120%);
|
|
||||||
backdrop-filter: blur(8px) saturate(120%);
|
|
||||||
border-bottom: 1px solid var(--purple-dim);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1.5em;
|
|
||||||
padding: 0.5em 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logs-back {
|
|
||||||
color: var(--purple);
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: 0.88em;
|
|
||||||
white-space: nowrap;
|
|
||||||
flex: none;
|
|
||||||
}
|
|
||||||
.logs-back:hover { text-decoration: underline; }
|
|
||||||
|
|
||||||
.logs-title {
|
|
||||||
color: var(--subtext0);
|
|
||||||
font-size: 0.85em;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
flex: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ─── operator inbox + message rows ────────────────────────────────
|
/* ─── operator inbox + message rows ────────────────────────────────
|
||||||
.inbox and .msg-* are rendered by common.js (renderInbox) and
|
.inbox and .msg-* are rendered by common.js (renderInbox) and
|
||||||
|
|
@ -553,14 +525,17 @@ body.side-panel-resizing * { cursor: ew-resize !important; }
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
||||||
|
/* Tint composited over the opaque elevated-surface grey (not transparent):
|
||||||
|
the bar is `position: sticky`, so a see-through background would let
|
||||||
|
page content scroll through behind it. */
|
||||||
.server-warn-warn {
|
.server-warn-warn {
|
||||||
color: var(--amber);
|
color: var(--amber);
|
||||||
background: color-mix(in srgb, var(--amber) 16%, transparent);
|
background: color-mix(in srgb, var(--amber) 16%, var(--bg-elev));
|
||||||
border-bottom: 1px solid var(--amber);
|
border-bottom: 1px solid var(--amber);
|
||||||
}
|
}
|
||||||
.server-warn-crit {
|
.server-warn-crit {
|
||||||
color: var(--red);
|
color: var(--red);
|
||||||
background: color-mix(in srgb, var(--red) 18%, transparent);
|
background: color-mix(in srgb, var(--red) 18%, var(--bg-elev));
|
||||||
border-bottom: 1px solid var(--red);
|
border-bottom: 1px solid var(--red);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,11 @@ export const form = (action, btnClass, btnLabel, confirmMsg, extra = {}, opts =
|
||||||
return f;
|
return f;
|
||||||
};
|
};
|
||||||
|
|
||||||
// `truncate`, `fmtAgo`, `fmtElapsed`, `fmtDuration` stay in tabs.js
|
// `truncate`, `fmtAgo`, `fmtElapsed`, `fmtDuration` + the `paintAtomic`
|
||||||
// for now — each has display-specific phrasing ("X running", "X ago")
|
// render helper live in the dashboard-internal `./util.js`, not here —
|
||||||
// tied to its caller, so they don't generalise cleanly. We can lift
|
// their phrasing ("X running", "X ago") is dashboard-specific, so they
|
||||||
// them when a second consumer needs the same shape.
|
// stay out of the cross-page `common.js` but are shared across the
|
||||||
|
// dashboard's own tab modules.
|
||||||
|
|
||||||
// ─── shared-worker SSE pipe ─────────────────────────────────────────────
|
// ─── shared-worker SSE pipe ─────────────────────────────────────────────
|
||||||
// Returns an EventSource-shaped facade backed by a SharedWorker that
|
// Returns an EventSource-shaped facade backed by a SharedWorker that
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,12 @@ body.dashboard-shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-chrome {
|
.dashboard-chrome {
|
||||||
|
/* Home back-link + tab strip share one row (flex). The chrome owns the
|
||||||
|
horizontal gutter and the single full-width bottom divider; its
|
||||||
|
children drop their own side padding / border so they sit inline. */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75em;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 25;
|
z-index: 25;
|
||||||
|
|
@ -28,19 +34,19 @@ body.dashboard-shell {
|
||||||
-webkit-backdrop-filter: blur(8px) saturate(120%);
|
-webkit-backdrop-filter: blur(8px) saturate(120%);
|
||||||
backdrop-filter: blur(8px) saturate(120%);
|
backdrop-filter: blur(8px) saturate(120%);
|
||||||
border-bottom: 1px solid var(--purple-dim);
|
border-bottom: 1px solid var(--purple-dim);
|
||||||
padding: 0.4em 0 0;
|
padding: 0.3em 1em;
|
||||||
margin: 0 0 1em;
|
margin: 0 0 1em;
|
||||||
}
|
}
|
||||||
/* ← home back-link to the H0M3 hub. Small purple link top-left of the
|
/* ← home back-link to the H0M3 hub. Small purple link top-left of the
|
||||||
chrome, mirroring the .logs-back treatment the sub-pages use so the
|
chrome, mirroring the .page-back treatment the standalone pages use
|
||||||
navigation reads consistently. Full chrome unification (a shared,
|
(now shared from @hive/shared/chrome.css) so the navigation reads
|
||||||
reusable tab/back-link component) is a later step. */
|
consistently. The dashboard keeps this richer sticky chrome of its
|
||||||
|
own rather than folding into the simple page header. */
|
||||||
.dash-home-back {
|
.dash-home-back {
|
||||||
display: inline-block;
|
flex: none;
|
||||||
color: var(--purple);
|
color: var(--purple);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 0.82em;
|
font-size: 0.82em;
|
||||||
padding: 0.1em 1em 0;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.dash-home-back:hover { text-decoration: underline; }
|
.dash-home-back:hover { text-decoration: underline; }
|
||||||
|
|
@ -61,38 +67,36 @@ body.dashboard-shell {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.2em;
|
gap: 0.2em;
|
||||||
padding: 0.5em 1em 0;
|
/* On one row with the home link now; the chrome owns the gutter +
|
||||||
border-bottom: 1px solid var(--purple-dim);
|
the bottom divider, so no outer padding / border here. */
|
||||||
}
|
}
|
||||||
|
/* Shares the flat-pill aesthetic of the shared `.hive-tab` (sub-tabs on
|
||||||
|
the standalone pages) so the chrome reads as one family. Kept a touch
|
||||||
|
weightier than bare `.hive-tab` — larger font, bold labels, count
|
||||||
|
pills — since this is the dashboard's primary nav, not a sub-strip. */
|
||||||
.tabbar .tab {
|
.tabbar .tab {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 0.55em 1em 0.45em;
|
padding: 0.4em 0.95em;
|
||||||
margin-bottom: -1px; /* overlap the tabbar bottom border */
|
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
font-size: 0.92em;
|
font-size: 0.92em;
|
||||||
letter-spacing: 0.08em;
|
letter-spacing: 0.06em;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border: 1px solid transparent;
|
border: 0;
|
||||||
border-bottom: 0;
|
border-radius: 4px;
|
||||||
border-radius: 4px 4px 0 0;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
|
transition: color 0.15s ease, background 0.15s ease;
|
||||||
}
|
}
|
||||||
.tabbar .tab:hover {
|
.tabbar .tab:hover {
|
||||||
color: var(--purple);
|
color: var(--fg);
|
||||||
background: color-mix(in srgb, var(--purple) 6%, transparent);
|
background: var(--border);
|
||||||
}
|
}
|
||||||
.tabbar .tab.hive-tab--active {
|
.tabbar .tab.hive-tab--active {
|
||||||
color: var(--purple);
|
color: var(--purple);
|
||||||
border-color: var(--purple-dim);
|
background: var(--border);
|
||||||
background: var(--bg);
|
|
||||||
/* Lift the active tab visually — the bottom border of the tabbar
|
|
||||||
yields under it via the -1px margin above. */
|
|
||||||
box-shadow: 0 -2px 12px -4px color-mix(in srgb, var(--purple) 40%, transparent);
|
|
||||||
}
|
}
|
||||||
.tab-label { font-weight: bold; white-space: nowrap; }
|
.tab-label { font-weight: bold; white-space: nowrap; }
|
||||||
.tab-count {
|
.tab-count {
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
No full tabbar — the flow page is a dedicated full-viewport
|
No full tabbar — the flow page is a dedicated full-viewport
|
||||||
terminal surface; navigating back to the menu is the only chrome
|
terminal surface; navigating back to the menu is the only chrome
|
||||||
needed. Pages link back to H0M3, not the dashboard. -->
|
needed. Pages link back to H0M3, not the dashboard. -->
|
||||||
<header class="logs-header">
|
<header class="page-header">
|
||||||
<a class="logs-back" href="/">← home</a>
|
<a class="page-back" href="/">← home</a>
|
||||||
<span class="logs-title">FL0W</span>
|
<span class="page-title">FL0W</span>
|
||||||
<select id="flow-agent-filter" class="flow-filter" title="filter timeline by agent" aria-label="filter timeline by agent">
|
<select id="flow-agent-filter" class="flow-filter" title="filter timeline by agent" aria-label="filter timeline by agent">
|
||||||
<option value="">all agents</option>
|
<option value="">all agents</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,19 @@ body.home-shell {
|
||||||
box-shadow: 0 -2px 14px -6px color-mix(in srgb, var(--purple) 50%, transparent);
|
box-shadow: 0 -2px 14px -6px color-mix(in srgb, var(--purple) 50%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Icon + label share the top row of each tile; the description sits
|
||||||
|
below. The icon is decorative (aria-hidden) — the label carries the
|
||||||
|
accessible name. */
|
||||||
|
.home-tile-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.55em;
|
||||||
|
}
|
||||||
|
.home-tile-icon {
|
||||||
|
font-size: 1.25em;
|
||||||
|
line-height: 1;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
.home-tile-label {
|
.home-tile-label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
letter-spacing: 0.08em;
|
letter-spacing: 0.08em;
|
||||||
|
|
|
||||||
|
|
@ -29,27 +29,42 @@
|
||||||
<nav class="home-menu" aria-label="hyperhive surfaces">
|
<nav class="home-menu" aria-label="hyperhive surfaces">
|
||||||
|
|
||||||
<a class="home-tile" href="/dashboard.html">
|
<a class="home-tile" href="/dashboard.html">
|
||||||
<span class="home-tile-label">Dashboard</span>
|
<span class="home-tile-head">
|
||||||
|
<span class="home-tile-icon" aria-hidden="true">🖥</span>
|
||||||
|
<span class="home-tile-label">Dashboard</span>
|
||||||
|
</span>
|
||||||
<span class="home-tile-desc">containers · approvals · permissions · schedules · system</span>
|
<span class="home-tile-desc">containers · approvals · permissions · schedules · system</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="home-tile" href="/flow.html">
|
<a class="home-tile" href="/flow.html">
|
||||||
<span class="home-tile-label">Flow</span>
|
<span class="home-tile-head">
|
||||||
|
<span class="home-tile-icon" aria-hidden="true">📡</span>
|
||||||
|
<span class="home-tile-label">Flow</span>
|
||||||
|
</span>
|
||||||
<span class="home-tile-desc">live all-agents message firehose</span>
|
<span class="home-tile-desc">live all-agents message firehose</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="home-tile" href="/logs.html">
|
<a class="home-tile" href="/logs.html">
|
||||||
<span class="home-tile-label">Logs</span>
|
<span class="home-tile-head">
|
||||||
|
<span class="home-tile-icon" aria-hidden="true">📜</span>
|
||||||
|
<span class="home-tile-label">Logs</span>
|
||||||
|
</span>
|
||||||
<span class="home-tile-desc">build · agent · system logs</span>
|
<span class="home-tile-desc">build · agent · system logs</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="home-tile" href="/stats.html">
|
<a class="home-tile" href="/stats.html">
|
||||||
<span class="home-tile-label">Stats</span>
|
<span class="home-tile-head">
|
||||||
|
<span class="home-tile-icon" aria-hidden="true">📊</span>
|
||||||
|
<span class="home-tile-label">Stats</span>
|
||||||
|
</span>
|
||||||
<span class="home-tile-desc">hive-wide turn stats · cost · model mix</span>
|
<span class="home-tile-desc">hive-wide turn stats · cost · model mix</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="home-tile" href="/settings.html">
|
<a class="home-tile" href="/settings.html">
|
||||||
<span class="home-tile-label">Settings</span>
|
<span class="home-tile-head">
|
||||||
|
<span class="home-tile-icon" aria-hidden="true">⚙</span>
|
||||||
|
<span class="home-tile-label">Settings</span>
|
||||||
|
</span>
|
||||||
<span class="home-tile-desc">operator-local prefs · browser notifications</span>
|
<span class="home-tile-desc">operator-local prefs · browser notifications</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
@ -57,7 +72,10 @@
|
||||||
enabled (state.matrix_gui_enabled), mirroring the dashboard
|
enabled (state.matrix_gui_enabled), mirroring the dashboard
|
||||||
tab gating so operators without it don't see a dead link. -->
|
tab gating so operators without it don't see a dead link. -->
|
||||||
<a class="home-tile" id="home-tile-matrix" href="/matrix/" hidden>
|
<a class="home-tile" id="home-tile-matrix" href="/matrix/" hidden>
|
||||||
<span class="home-tile-label">Matrix</span>
|
<span class="home-tile-head">
|
||||||
|
<span class="home-tile-icon" aria-hidden="true">💬</span>
|
||||||
|
<span class="home-tile-label">Matrix</span>
|
||||||
|
</span>
|
||||||
<span class="home-tile-desc">matrix chat client</span>
|
<span class="home-tile-desc">matrix chat client</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
<!-- Minimal chrome: back link + sub-tab strip.
|
<!-- Minimal chrome: back link + sub-tab strip.
|
||||||
Same pattern as flow.html — no full dashboard tabbar. Back link
|
Same pattern as flow.html — no full dashboard tabbar. Back link
|
||||||
points to the H0M3 hub (served at /), not the dashboard. -->
|
points to the H0M3 hub (served at /), not the dashboard. -->
|
||||||
<header class="logs-header">
|
<header class="page-header">
|
||||||
<a class="logs-back" href="/">← home</a>
|
<a class="page-back" href="/">← home</a>
|
||||||
<nav class="hive-tabbar logs-tabbar" id="logs-tabbar" role="tablist">
|
<nav class="hive-tabbar logs-tabbar" id="logs-tabbar" role="tablist">
|
||||||
<a class="hive-tab" id="logs-tab-build" href="#build" role="tab"
|
<a class="hive-tab" id="logs-tab-build" href="#build" role="tab"
|
||||||
aria-controls="logs-pane-build" data-tab="build">
|
aria-controls="logs-pane-build" data-tab="build">
|
||||||
|
|
|
||||||
270
frontend/packages/dashboard/src/permissions.js
Normal file
270
frontend/packages/dashboard/src/permissions.js
Normal file
|
|
@ -0,0 +1,270 @@
|
||||||
|
// Dashboard P3RM1SS10NS tab — the per-agent capabilities + tool-groups
|
||||||
|
// matrices.
|
||||||
|
//
|
||||||
|
// Both tables are fetched on tab activation (`GET /api/capabilities`,
|
||||||
|
// `GET /api/tool-groups`) and after each save. Columns (caps / groups)
|
||||||
|
// come from the backend so the UI needs no change when a new one is
|
||||||
|
// added. Live updates arrive via the `capabilities_changed` /
|
||||||
|
// `tool_groups_changed` dashboard events (fired after the rebuild-queue
|
||||||
|
// worker commits the perm JSON file), wired into the entry's mutation
|
||||||
|
// dispatch table.
|
||||||
|
//
|
||||||
|
// Stateless at module scope: each render builds fresh from the fetched
|
||||||
|
// payload. The agent roster (`containersState`) is the only shared state
|
||||||
|
// it reads — to union live containers with agents already named in the
|
||||||
|
// assignments map.
|
||||||
|
|
||||||
|
import { $, el } from './common.js';
|
||||||
|
import { containersState } from './state.js';
|
||||||
|
|
||||||
|
export function applyCapabilitiesChanged(ev) {
|
||||||
|
const root = $('capabilities-section');
|
||||||
|
if (!root) return;
|
||||||
|
// Skip re-render while operator has a checkbox focused in this
|
||||||
|
// section — the tab-activation re-fetch is the recovery path.
|
||||||
|
if (root.contains(document.activeElement)) return;
|
||||||
|
renderCapabilities(root, ev);
|
||||||
|
}
|
||||||
|
export function applyToolGroupsChanged(ev) {
|
||||||
|
const root = $('tool-groups-section');
|
||||||
|
if (!root) return;
|
||||||
|
if (root.contains(document.activeElement)) return;
|
||||||
|
renderToolGroups(root, ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAndRenderCapabilities() {
|
||||||
|
const root = $('capabilities-section');
|
||||||
|
if (!root) return;
|
||||||
|
root.replaceChildren();
|
||||||
|
root.append(el('p', { class: 'meta' }, 'loading…'));
|
||||||
|
try {
|
||||||
|
const resp = await fetch('/api/capabilities');
|
||||||
|
if (!resp.ok) throw new Error('http ' + resp.status);
|
||||||
|
const data = await resp.json();
|
||||||
|
renderCapabilities(root, data);
|
||||||
|
} catch (err) {
|
||||||
|
root.replaceChildren();
|
||||||
|
root.append(el('p', { class: 'meta' }, 'fetch failed: ' + err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderCapabilities(root, data) {
|
||||||
|
root.replaceChildren();
|
||||||
|
const { caps, descriptions = {}, assignments } = data;
|
||||||
|
if (!caps || !caps.length) {
|
||||||
|
root.append(el('p', { class: 'meta' }, '(no capabilities defined)'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agent names: union of live containers + keys already in assignments.
|
||||||
|
const agentNames = [...new Set([
|
||||||
|
...Array.from(containersState.keys()),
|
||||||
|
...Object.keys(assignments),
|
||||||
|
])].sort();
|
||||||
|
|
||||||
|
if (!agentNames.length) {
|
||||||
|
root.append(el('p', { class: 'meta' }, '(no agents)'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrap = el('div', { class: 'cap-table-wrap' });
|
||||||
|
const table = el('table', { class: 'cap-table' });
|
||||||
|
|
||||||
|
// Header row.
|
||||||
|
const thead = el('thead');
|
||||||
|
const hrow = el('tr');
|
||||||
|
hrow.append(el('th', { class: 'cap-agent-col' }, 'agent'));
|
||||||
|
for (const c of caps) {
|
||||||
|
hrow.append(el('th', { class: 'cap-col', title: descriptions[c] || c }, c));
|
||||||
|
}
|
||||||
|
hrow.append(el('th', { class: 'cap-save-col' }, ''));
|
||||||
|
thead.append(hrow);
|
||||||
|
table.append(thead);
|
||||||
|
|
||||||
|
const tbody = el('tbody');
|
||||||
|
for (const name of agentNames) {
|
||||||
|
const assigned = assignments[name] || [];
|
||||||
|
const tr = el('tr', { class: 'cap-row' });
|
||||||
|
|
||||||
|
// Agent name cell.
|
||||||
|
tr.append(el('td', { class: 'cap-agent-col' },
|
||||||
|
el('span', { class: 'cap-agent-name' }, name)));
|
||||||
|
|
||||||
|
// One checkbox per capability.
|
||||||
|
const checkboxes = [];
|
||||||
|
for (const c of caps) {
|
||||||
|
const checked = assigned.includes(c);
|
||||||
|
const td = el('td', { class: 'cap-col' });
|
||||||
|
const cb = el('input', {
|
||||||
|
type: 'checkbox',
|
||||||
|
class: 'cap-cb',
|
||||||
|
'data-cap': c,
|
||||||
|
'aria-label': c,
|
||||||
|
});
|
||||||
|
cb.checked = checked;
|
||||||
|
td.append(cb);
|
||||||
|
tr.append(td);
|
||||||
|
checkboxes.push(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save button cell.
|
||||||
|
const saveTd = el('td', { class: 'cap-save-col' });
|
||||||
|
const saveBtn = el('button', { type: 'button', class: 'btn cap-save-btn' }, 'save');
|
||||||
|
saveBtn.addEventListener('click', async () => {
|
||||||
|
const selectedCaps = checkboxes
|
||||||
|
.filter((cb) => cb.checked)
|
||||||
|
.map((cb) => cb.dataset.cap);
|
||||||
|
saveBtn.disabled = true;
|
||||||
|
saveBtn.textContent = '…';
|
||||||
|
try {
|
||||||
|
const r = await fetch('/api/capabilities/' + encodeURIComponent(name), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ caps: selectedCaps }),
|
||||||
|
});
|
||||||
|
if (!r.ok) {
|
||||||
|
const txt = await r.text();
|
||||||
|
saveBtn.textContent = 'err';
|
||||||
|
saveBtn.title = txt;
|
||||||
|
} else {
|
||||||
|
saveBtn.textContent = '✓';
|
||||||
|
setTimeout(fetchAndRenderCapabilities, 800);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
saveBtn.textContent = 'err';
|
||||||
|
saveBtn.title = String(err);
|
||||||
|
} finally {
|
||||||
|
saveBtn.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
saveTd.append(saveBtn);
|
||||||
|
tr.append(saveTd);
|
||||||
|
|
||||||
|
tbody.append(tr);
|
||||||
|
}
|
||||||
|
table.append(tbody);
|
||||||
|
wrap.append(table);
|
||||||
|
root.append(wrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAndRenderToolGroups() {
|
||||||
|
const root = $('tool-groups-section');
|
||||||
|
if (!root) return;
|
||||||
|
root.replaceChildren();
|
||||||
|
root.append(el('p', { class: 'meta' }, 'loading…'));
|
||||||
|
try {
|
||||||
|
const resp = await fetch('/api/tool-groups');
|
||||||
|
if (!resp.ok) throw new Error('http ' + resp.status);
|
||||||
|
const data = await resp.json();
|
||||||
|
renderToolGroups(root, data);
|
||||||
|
} catch (err) {
|
||||||
|
root.replaceChildren();
|
||||||
|
root.append(el('p', { class: 'meta' }, 'fetch failed: ' + err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderToolGroups(root, data) {
|
||||||
|
root.replaceChildren();
|
||||||
|
const { groups, descriptions = {}, assignments } = data;
|
||||||
|
if (!groups || !groups.length) {
|
||||||
|
root.append(el('p', { class: 'meta' }, '(no tool groups defined)'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agent names: union of live containers + keys already in assignments,
|
||||||
|
// sorted alphabetically.
|
||||||
|
const agentNames = [...new Set([
|
||||||
|
...Array.from(containersState.keys()),
|
||||||
|
...Object.keys(assignments),
|
||||||
|
])].sort();
|
||||||
|
|
||||||
|
if (!agentNames.length) {
|
||||||
|
root.append(el('p', { class: 'meta' }, '(no agents)'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrap = el('div', { class: 'tg-table-wrap' });
|
||||||
|
const table = el('table', { class: 'tg-table' });
|
||||||
|
|
||||||
|
// Header row.
|
||||||
|
const thead = el('thead');
|
||||||
|
const hrow = el('tr');
|
||||||
|
hrow.append(el('th', { class: 'tg-agent-col' }, 'agent'));
|
||||||
|
for (const g of groups) {
|
||||||
|
hrow.append(el('th', { class: 'tg-group-col', title: descriptions[g] || g }, g));
|
||||||
|
}
|
||||||
|
hrow.append(el('th', { class: 'tg-save-col' }, ''));
|
||||||
|
thead.append(hrow);
|
||||||
|
table.append(thead);
|
||||||
|
|
||||||
|
const tbody = el('tbody');
|
||||||
|
for (const name of agentNames) {
|
||||||
|
// Explicit assignment or empty = using role default.
|
||||||
|
const assigned = assignments[name] || [];
|
||||||
|
const hasExplicit = Object.prototype.hasOwnProperty.call(assignments, name);
|
||||||
|
const tr = el('tr', { class: 'tg-row' });
|
||||||
|
|
||||||
|
// Agent name cell.
|
||||||
|
const nameTd = el('td', { class: 'tg-agent-col' });
|
||||||
|
nameTd.append(el('span', { class: 'tg-agent-name' }, name));
|
||||||
|
if (!hasExplicit) {
|
||||||
|
nameTd.append(el('span', { class: 'meta tg-default-label' }, '(default)'));
|
||||||
|
}
|
||||||
|
tr.append(nameTd);
|
||||||
|
|
||||||
|
// One checkbox per group.
|
||||||
|
const checkboxes = [];
|
||||||
|
for (const g of groups) {
|
||||||
|
const checked = assigned.includes(g);
|
||||||
|
const td = el('td', { class: 'tg-group-col' });
|
||||||
|
const cb = el('input', {
|
||||||
|
type: 'checkbox',
|
||||||
|
class: 'tg-cb',
|
||||||
|
'data-group': g,
|
||||||
|
'aria-label': g,
|
||||||
|
});
|
||||||
|
cb.checked = checked;
|
||||||
|
td.append(cb);
|
||||||
|
tr.append(td);
|
||||||
|
checkboxes.push(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save button cell.
|
||||||
|
const saveTd = el('td', { class: 'tg-save-col' });
|
||||||
|
const saveBtn = el('button', { type: 'button', class: 'btn tg-save-btn' }, 'save');
|
||||||
|
saveBtn.addEventListener('click', async () => {
|
||||||
|
const selectedGroups = checkboxes
|
||||||
|
.filter((cb) => cb.checked)
|
||||||
|
.map((cb) => cb.dataset.group);
|
||||||
|
saveBtn.disabled = true;
|
||||||
|
saveBtn.textContent = '…';
|
||||||
|
try {
|
||||||
|
const r = await fetch('/api/tool-groups/' + encodeURIComponent(name), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ groups: selectedGroups }),
|
||||||
|
});
|
||||||
|
if (!r.ok) {
|
||||||
|
const txt = await r.text();
|
||||||
|
saveBtn.textContent = 'err';
|
||||||
|
saveBtn.title = txt;
|
||||||
|
} else {
|
||||||
|
saveBtn.textContent = '✓';
|
||||||
|
setTimeout(fetchAndRenderToolGroups, 800);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
saveBtn.textContent = 'err';
|
||||||
|
saveBtn.title = String(err);
|
||||||
|
} finally {
|
||||||
|
saveBtn.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
saveTd.append(saveBtn);
|
||||||
|
tr.append(saveTd);
|
||||||
|
|
||||||
|
tbody.append(tr);
|
||||||
|
}
|
||||||
|
table.append(tbody);
|
||||||
|
wrap.append(table);
|
||||||
|
root.append(wrap);
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
/* ─── /settings.html — operator-local preferences ──────────────────
|
/* ─── /settings.html — operator-local preferences ──────────────────
|
||||||
Extracted from the dashboard S3TT1NGS tab. Same
|
Extracted from the dashboard S3TT1NGS tab. Same
|
||||||
minimal-chrome pattern as /flow.html and /logs.html: the back-link
|
minimal-chrome pattern as /flow.html and /logs.html: the back-link
|
||||||
header + title (.logs-header / .logs-back / .logs-title) live in
|
header + title (.page-header / .page-back / .page-title) live in
|
||||||
common.css; only the page body padding + the notif-toggle row are
|
@hive/shared/chrome.css; only the page body padding + the notif-toggle
|
||||||
page-specific and live here. */
|
row are page-specific and live here. */
|
||||||
|
|
||||||
body.settings-shell {
|
body.settings-shell {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
<!-- Minimal chrome: back link + title. Same pattern as flow.html /
|
<!-- Minimal chrome: back link + title. Same pattern as flow.html /
|
||||||
logs.html — no full dashboard tabbar. Back link points to the
|
logs.html — no full dashboard tabbar. Back link points to the
|
||||||
H0M3 hub (served at /), not the dashboard. -->
|
H0M3 hub (served at /), not the dashboard. -->
|
||||||
<header class="logs-header">
|
<header class="page-header">
|
||||||
<a class="logs-back" href="/">← home</a>
|
<a class="page-back" href="/">← home</a>
|
||||||
<span class="logs-title">S3TT1NGS</span>
|
<span class="page-title">S3TT1NGS</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="settings-main">
|
<main class="settings-main">
|
||||||
|
|
|
||||||
25
frontend/packages/dashboard/src/state.js
Normal file
25
frontend/packages/dashboard/src/state.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Shared dashboard state — the one piece of cross-domain state in the
|
||||||
|
// dashboard SPA: the live agent roster.
|
||||||
|
//
|
||||||
|
// The roster is read by nearly every tab (the container tree, the
|
||||||
|
// capabilities + tool-group matrices, the schedule target-chips, the
|
||||||
|
// container-load poll, the selection bar, and the operator inbox), so
|
||||||
|
// it lives here as a single source of truth that each domain module
|
||||||
|
// imports rather than threading through call signatures. Everything
|
||||||
|
// else in the dashboard is domain-local and lives with its own module.
|
||||||
|
//
|
||||||
|
// `containersState` is keyed by `ContainerView.name` so a lifecycle
|
||||||
|
// form's POST → 200 → matching SSE event can flip a single row without
|
||||||
|
// a full snapshot refetch. Mutated in place (`set` / `delete` / `clear`)
|
||||||
|
// by the container apply-handlers; consumers read it by reference, so
|
||||||
|
// the imported binding always reflects the latest roster.
|
||||||
|
|
||||||
|
export const containersState = new Map();
|
||||||
|
|
||||||
|
// Replace the whole roster from a fresh `/api/state` snapshot. Called by
|
||||||
|
// the entry's `refreshState` on cold load and after async-form submits;
|
||||||
|
// live single-row updates go through the container apply-handlers.
|
||||||
|
export function syncContainersFromSnapshot(s) {
|
||||||
|
containersState.clear();
|
||||||
|
for (const c of s.containers || []) containersState.set(c.name, c);
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
/* ─── /stats.html — hive-wide turn-stats rollup ────────────────────
|
/* ─── /stats.html — hive-wide turn-stats rollup ────────────────────
|
||||||
Extracted from the dashboard ST4TS tab. Same minimal-
|
Extracted from the dashboard ST4TS tab. Same minimal-
|
||||||
chrome pattern as /flow.html and /logs.html: the back-link header +
|
chrome pattern as /flow.html and /logs.html: the back-link header +
|
||||||
title (.logs-header / .logs-back / .logs-title) live in common.css.
|
title (.page-header / .page-back / .page-title) live in
|
||||||
|
@hive/shared/chrome.css.
|
||||||
`.hive-stats-table` also lives in common.css — it's shared with the
|
`.hive-stats-table` also lives in common.css — it's shared with the
|
||||||
dashboard SYST3M › C0NT41N3R L04D table. Only the ST4TS-specific
|
dashboard SYST3M › C0NT41N3R L04D table. Only the ST4TS-specific
|
||||||
window selector, summary chips, and bars are page-specific. */
|
window selector, summary chips, and bars are page-specific. */
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
<!-- Minimal chrome: back link + title. Same pattern as flow.html /
|
<!-- Minimal chrome: back link + title. Same pattern as flow.html /
|
||||||
logs.html — no full dashboard tabbar. Back link points to the
|
logs.html — no full dashboard tabbar. Back link points to the
|
||||||
H0M3 hub (served at /), not the dashboard. -->
|
H0M3 hub (served at /), not the dashboard. -->
|
||||||
<header class="logs-header">
|
<header class="page-header">
|
||||||
<a class="logs-back" href="/">← home</a>
|
<a class="page-back" href="/">← home</a>
|
||||||
<span class="logs-title">ST4TS</span>
|
<span class="page-title">ST4TS</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="stats-main">
|
<main class="stats-main">
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@ import {
|
||||||
openStream, renderServerWarnings,
|
openStream, renderServerWarnings,
|
||||||
} from './common.js';
|
} from './common.js';
|
||||||
import { createTabStrip } from '@hive/shared/tabs.js';
|
import { createTabStrip } from '@hive/shared/tabs.js';
|
||||||
|
import { containersState, syncContainersFromSnapshot } from './state.js';
|
||||||
|
import { paintAtomic, fmtAgo, truncate, fmtElapsed, fmtDuration } from './util.js';
|
||||||
|
import {
|
||||||
|
applyCapabilitiesChanged, applyToolGroupsChanged,
|
||||||
|
fetchAndRenderCapabilities, fetchAndRenderToolGroups,
|
||||||
|
} from './permissions.js';
|
||||||
|
|
||||||
// mdNode (in common.js) reads `window.marked` for the markdown side
|
// mdNode (in common.js) reads `window.marked` for the markdown side
|
||||||
// panel preview path. Set it here on the dashboard entry so file
|
// panel preview path. Set it here on the dashboard entry so file
|
||||||
|
|
@ -38,16 +44,6 @@ window.marked = marked;
|
||||||
const CTX_WARN_TOKENS = 150_000; // fallback red threshold (≈ 75% of 200k)
|
const CTX_WARN_TOKENS = 150_000; // fallback red threshold (≈ 75% of 200k)
|
||||||
const CTX_CAUTION_TOKENS = 100_000; // fallback yellow threshold (≈ 50% of 200k)
|
const CTX_CAUTION_TOKENS = 100_000; // fallback yellow threshold (≈ 50% of 200k)
|
||||||
|
|
||||||
// Atomic-swap render helper: build into a DocumentFragment off-DOM,
|
|
||||||
// commit with one `replaceChildren`. See docs/web-ui.md::Atomic
|
|
||||||
// section repaint for why (no intermediate empty-state flash on
|
|
||||||
// poll cycles even when the builder allocates a lot of `el()`).
|
|
||||||
function paintAtomic(liveRoot, build) {
|
|
||||||
const buf = document.createDocumentFragment();
|
|
||||||
build(buf);
|
|
||||||
liveRoot.replaceChildren(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Track which items we've already notified about so a re-render
|
// Track which items we've already notified about so a re-render
|
||||||
// doesn't re-fire for the same row. Keyed by stable ids; reset only
|
// doesn't re-fire for the same row. Keyed by stable ids; reset only
|
||||||
// when the page reloads.
|
// when the page reloads.
|
||||||
|
|
@ -149,23 +145,18 @@ window.marked = marked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Derived container state — cold-loaded from /api/state.containers,
|
// The live agent roster (`containersState`) + its snapshot-sync now
|
||||||
// then mutated live by `container_state_changed` (upsert by name)
|
// live in `./state.js` — it's the one piece of cross-domain state, read
|
||||||
// and `container_removed` (drop by name). The coordinator's rescan
|
// by nearly every tab. It's still mutated live by `container_state_changed`
|
||||||
// helper fires these after every mutation site + on a periodic poll
|
// (upsert by name) and `container_removed` (drop by name) via the apply
|
||||||
// in crash_watch. Keyed by ContainerView.name so the lifecycle
|
// handlers just below; the imported binding reflects those in place.
|
||||||
// forms' POST → 200 → matching event flips the row without a
|
//
|
||||||
// snapshot refetch.
|
|
||||||
const containersState = new Map();
|
|
||||||
// Keyed container row cache. Maps agent name → { el: <li>, fingerprint }.
|
// Keyed container row cache. Maps agent name → { el: <li>, fingerprint }.
|
||||||
// Allows renderContainers to skip rebuilding rows whose displayed state
|
// Allows renderContainers to skip rebuilding rows whose displayed state
|
||||||
// hasn't changed — prevents full-wipe flicker + avoids redundant async
|
// hasn't changed — prevents full-wipe flicker + avoids redundant async
|
||||||
// dashboard-state fetches on every SSE event.
|
// dashboard-state fetches on every SSE event. Container-domain only,
|
||||||
|
// so it stays here (not in state.js).
|
||||||
const containerRowCache = new Map();
|
const containerRowCache = new Map();
|
||||||
function syncContainersFromSnapshot(s) {
|
|
||||||
containersState.clear();
|
|
||||||
for (const c of s.containers || []) containersState.set(c.name, c);
|
|
||||||
}
|
|
||||||
function applyContainerStateChanged(ev) {
|
function applyContainerStateChanged(ev) {
|
||||||
if (!ev.container || !ev.container.name) return;
|
if (!ev.container || !ev.container.name) return;
|
||||||
containersState.set(ev.container.name, ev.container);
|
containersState.set(ev.container.name, ev.container);
|
||||||
|
|
@ -1351,264 +1342,6 @@ window.marked = marked;
|
||||||
root.append(ul);
|
root.append(ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── tool-groups (permissions) table ─────────────────────────────────────
|
|
||||||
// Fetched from GET /api/tool-groups on system tab activation and after
|
|
||||||
// each save. Groups (columns) come from the backend so the UI doesn't
|
|
||||||
// need updating when a new group is added. Live updates via
|
|
||||||
// `capabilities_changed` / `tool_groups_changed` SSE events fired
|
|
||||||
// after the rebuild-queue worker commits the perm JSON file.
|
|
||||||
function applyCapabilitiesChanged(ev) {
|
|
||||||
const root = $('capabilities-section');
|
|
||||||
if (!root) return;
|
|
||||||
// Skip re-render while operator has a checkbox focused in this
|
|
||||||
// section — the tab-activation re-fetch is the recovery path.
|
|
||||||
if (root.contains(document.activeElement)) return;
|
|
||||||
renderCapabilities(root, ev);
|
|
||||||
}
|
|
||||||
function applyToolGroupsChanged(ev) {
|
|
||||||
const root = $('tool-groups-section');
|
|
||||||
if (!root) return;
|
|
||||||
if (root.contains(document.activeElement)) return;
|
|
||||||
renderToolGroups(root, ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchAndRenderCapabilities() {
|
|
||||||
const root = $('capabilities-section');
|
|
||||||
if (!root) return;
|
|
||||||
root.replaceChildren();
|
|
||||||
root.append(el('p', { class: 'meta' }, 'loading…'));
|
|
||||||
try {
|
|
||||||
const resp = await fetch('/api/capabilities');
|
|
||||||
if (!resp.ok) throw new Error('http ' + resp.status);
|
|
||||||
const data = await resp.json();
|
|
||||||
renderCapabilities(root, data);
|
|
||||||
} catch (err) {
|
|
||||||
root.replaceChildren();
|
|
||||||
root.append(el('p', { class: 'meta' }, 'fetch failed: ' + err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderCapabilities(root, data) {
|
|
||||||
root.replaceChildren();
|
|
||||||
const { caps, descriptions = {}, assignments } = data;
|
|
||||||
if (!caps || !caps.length) {
|
|
||||||
root.append(el('p', { class: 'meta' }, '(no capabilities defined)'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Agent names: union of live containers + keys already in assignments.
|
|
||||||
const agentNames = [...new Set([
|
|
||||||
...Array.from(containersState.keys()),
|
|
||||||
...Object.keys(assignments),
|
|
||||||
])].sort();
|
|
||||||
|
|
||||||
if (!agentNames.length) {
|
|
||||||
root.append(el('p', { class: 'meta' }, '(no agents)'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrap = el('div', { class: 'cap-table-wrap' });
|
|
||||||
const table = el('table', { class: 'cap-table' });
|
|
||||||
|
|
||||||
// Header row.
|
|
||||||
const thead = el('thead');
|
|
||||||
const hrow = el('tr');
|
|
||||||
hrow.append(el('th', { class: 'cap-agent-col' }, 'agent'));
|
|
||||||
for (const c of caps) {
|
|
||||||
hrow.append(el('th', { class: 'cap-col', title: descriptions[c] || c }, c));
|
|
||||||
}
|
|
||||||
hrow.append(el('th', { class: 'cap-save-col' }, ''));
|
|
||||||
thead.append(hrow);
|
|
||||||
table.append(thead);
|
|
||||||
|
|
||||||
const tbody = el('tbody');
|
|
||||||
for (const name of agentNames) {
|
|
||||||
const assigned = assignments[name] || [];
|
|
||||||
const tr = el('tr', { class: 'cap-row' });
|
|
||||||
|
|
||||||
// Agent name cell.
|
|
||||||
tr.append(el('td', { class: 'cap-agent-col' },
|
|
||||||
el('span', { class: 'cap-agent-name' }, name)));
|
|
||||||
|
|
||||||
// One checkbox per capability.
|
|
||||||
const checkboxes = [];
|
|
||||||
for (const c of caps) {
|
|
||||||
const checked = assigned.includes(c);
|
|
||||||
const td = el('td', { class: 'cap-col' });
|
|
||||||
const cb = el('input', {
|
|
||||||
type: 'checkbox',
|
|
||||||
class: 'cap-cb',
|
|
||||||
'data-cap': c,
|
|
||||||
'aria-label': c,
|
|
||||||
});
|
|
||||||
cb.checked = checked;
|
|
||||||
td.append(cb);
|
|
||||||
tr.append(td);
|
|
||||||
checkboxes.push(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save button cell.
|
|
||||||
const saveTd = el('td', { class: 'cap-save-col' });
|
|
||||||
const saveBtn = el('button', { type: 'button', class: 'btn cap-save-btn' }, 'save');
|
|
||||||
saveBtn.addEventListener('click', async () => {
|
|
||||||
const selectedCaps = checkboxes
|
|
||||||
.filter((cb) => cb.checked)
|
|
||||||
.map((cb) => cb.dataset.cap);
|
|
||||||
saveBtn.disabled = true;
|
|
||||||
saveBtn.textContent = '…';
|
|
||||||
try {
|
|
||||||
const r = await fetch('/api/capabilities/' + encodeURIComponent(name), {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ caps: selectedCaps }),
|
|
||||||
});
|
|
||||||
if (!r.ok) {
|
|
||||||
const txt = await r.text();
|
|
||||||
saveBtn.textContent = 'err';
|
|
||||||
saveBtn.title = txt;
|
|
||||||
} else {
|
|
||||||
saveBtn.textContent = '✓';
|
|
||||||
setTimeout(fetchAndRenderCapabilities, 800);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
saveBtn.textContent = 'err';
|
|
||||||
saveBtn.title = String(err);
|
|
||||||
} finally {
|
|
||||||
saveBtn.disabled = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
saveTd.append(saveBtn);
|
|
||||||
tr.append(saveTd);
|
|
||||||
|
|
||||||
tbody.append(tr);
|
|
||||||
}
|
|
||||||
table.append(tbody);
|
|
||||||
wrap.append(table);
|
|
||||||
root.append(wrap);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchAndRenderToolGroups() {
|
|
||||||
const root = $('tool-groups-section');
|
|
||||||
if (!root) return;
|
|
||||||
root.replaceChildren();
|
|
||||||
root.append(el('p', { class: 'meta' }, 'loading…'));
|
|
||||||
try {
|
|
||||||
const resp = await fetch('/api/tool-groups');
|
|
||||||
if (!resp.ok) throw new Error('http ' + resp.status);
|
|
||||||
const data = await resp.json();
|
|
||||||
renderToolGroups(root, data);
|
|
||||||
} catch (err) {
|
|
||||||
root.replaceChildren();
|
|
||||||
root.append(el('p', { class: 'meta' }, 'fetch failed: ' + err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderToolGroups(root, data) {
|
|
||||||
root.replaceChildren();
|
|
||||||
const { groups, descriptions = {}, assignments } = data;
|
|
||||||
if (!groups || !groups.length) {
|
|
||||||
root.append(el('p', { class: 'meta' }, '(no tool groups defined)'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Agent names: union of live containers + keys already in assignments,
|
|
||||||
// sorted alphabetically.
|
|
||||||
const agentNames = [...new Set([
|
|
||||||
...Array.from(containersState.keys()),
|
|
||||||
...Object.keys(assignments),
|
|
||||||
])].sort();
|
|
||||||
|
|
||||||
if (!agentNames.length) {
|
|
||||||
root.append(el('p', { class: 'meta' }, '(no agents)'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrap = el('div', { class: 'tg-table-wrap' });
|
|
||||||
const table = el('table', { class: 'tg-table' });
|
|
||||||
|
|
||||||
// Header row.
|
|
||||||
const thead = el('thead');
|
|
||||||
const hrow = el('tr');
|
|
||||||
hrow.append(el('th', { class: 'tg-agent-col' }, 'agent'));
|
|
||||||
for (const g of groups) {
|
|
||||||
hrow.append(el('th', { class: 'tg-group-col', title: descriptions[g] || g }, g));
|
|
||||||
}
|
|
||||||
hrow.append(el('th', { class: 'tg-save-col' }, ''));
|
|
||||||
thead.append(hrow);
|
|
||||||
table.append(thead);
|
|
||||||
|
|
||||||
const tbody = el('tbody');
|
|
||||||
for (const name of agentNames) {
|
|
||||||
// Explicit assignment or empty = using role default.
|
|
||||||
const assigned = assignments[name] || [];
|
|
||||||
const hasExplicit = Object.prototype.hasOwnProperty.call(assignments, name);
|
|
||||||
const tr = el('tr', { class: 'tg-row' });
|
|
||||||
|
|
||||||
// Agent name cell.
|
|
||||||
const nameTd = el('td', { class: 'tg-agent-col' });
|
|
||||||
nameTd.append(el('span', { class: 'tg-agent-name' }, name));
|
|
||||||
if (!hasExplicit) {
|
|
||||||
nameTd.append(el('span', { class: 'meta tg-default-label' }, '(default)'));
|
|
||||||
}
|
|
||||||
tr.append(nameTd);
|
|
||||||
|
|
||||||
// One checkbox per group.
|
|
||||||
const checkboxes = [];
|
|
||||||
for (const g of groups) {
|
|
||||||
const checked = assigned.includes(g);
|
|
||||||
const td = el('td', { class: 'tg-group-col' });
|
|
||||||
const cb = el('input', {
|
|
||||||
type: 'checkbox',
|
|
||||||
class: 'tg-cb',
|
|
||||||
'data-group': g,
|
|
||||||
'aria-label': g,
|
|
||||||
});
|
|
||||||
cb.checked = checked;
|
|
||||||
td.append(cb);
|
|
||||||
tr.append(td);
|
|
||||||
checkboxes.push(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save button cell.
|
|
||||||
const saveTd = el('td', { class: 'tg-save-col' });
|
|
||||||
const saveBtn = el('button', { type: 'button', class: 'btn tg-save-btn' }, 'save');
|
|
||||||
saveBtn.addEventListener('click', async () => {
|
|
||||||
const selectedGroups = checkboxes
|
|
||||||
.filter((cb) => cb.checked)
|
|
||||||
.map((cb) => cb.dataset.group);
|
|
||||||
saveBtn.disabled = true;
|
|
||||||
saveBtn.textContent = '…';
|
|
||||||
try {
|
|
||||||
const r = await fetch('/api/tool-groups/' + encodeURIComponent(name), {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ groups: selectedGroups }),
|
|
||||||
});
|
|
||||||
if (!r.ok) {
|
|
||||||
const txt = await r.text();
|
|
||||||
saveBtn.textContent = 'err';
|
|
||||||
saveBtn.title = txt;
|
|
||||||
} else {
|
|
||||||
saveBtn.textContent = '✓';
|
|
||||||
setTimeout(fetchAndRenderToolGroups, 800);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
saveBtn.textContent = 'err';
|
|
||||||
saveBtn.title = String(err);
|
|
||||||
} finally {
|
|
||||||
saveBtn.disabled = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
saveTd.append(saveBtn);
|
|
||||||
tr.append(saveTd);
|
|
||||||
|
|
||||||
tbody.append(tr);
|
|
||||||
}
|
|
||||||
table.append(tbody);
|
|
||||||
wrap.append(table);
|
|
||||||
root.append(wrap);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Derived question state — cold-loaded from /api/state, then mutated
|
// Derived question state — cold-loaded from /api/state, then mutated
|
||||||
// live by `question_added` / `question_resolved` dashboard events.
|
// live by `question_added` / `question_resolved` dashboard events.
|
||||||
const QUESTION_HISTORY_LIMIT = 20;
|
const QUESTION_HISTORY_LIMIT = 20;
|
||||||
|
|
@ -2368,17 +2101,6 @@ window.marked = marked;
|
||||||
root.append(ul);
|
root.append(ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relative time, anchored to now. resolved_at is unix seconds (server-
|
|
||||||
// authored), so we don't have to worry about client/server clock skew
|
|
||||||
// for sub-minute precision.
|
|
||||||
function fmtAgo(unixSecs) {
|
|
||||||
const ageSec = Math.max(0, Math.floor(Date.now() / 1000 - unixSecs));
|
|
||||||
if (ageSec < 60) return ageSec + 's ago';
|
|
||||||
if (ageSec < 3600) return Math.floor(ageSec / 60) + 'm ago';
|
|
||||||
if (ageSec < 86400) return Math.floor(ageSec / 3600) + 'h ago';
|
|
||||||
return Math.floor(ageSec / 86400) + 'd ago';
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderMetaInputs(s) {
|
function renderMetaInputs(s) {
|
||||||
const root = $('meta-inputs-section');
|
const root = $('meta-inputs-section');
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
|
|
@ -2488,10 +2210,6 @@ window.marked = marked;
|
||||||
root.append(form);
|
root.append(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate(s, n) {
|
|
||||||
return s.length <= n ? s : s.slice(0, n - 1) + '…';
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── rebuild queue ──────────────────────────────────────────────────────
|
// ─── rebuild queue ──────────────────────────────────────────────────────
|
||||||
// Keyed row cache for the rebuild-queue list. Maps entry.id → { el, fingerprint }.
|
// Keyed row cache for the rebuild-queue list. Maps entry.id → { el, fingerprint }.
|
||||||
// Same pattern as containerRowCache: reuse <li> nodes whose state hasn't
|
// Same pattern as containerRowCache: reuse <li> nodes whose state hasn't
|
||||||
|
|
@ -2719,12 +2437,6 @@ window.marked = marked;
|
||||||
return li;
|
return li;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtElapsed(secs) {
|
|
||||||
if (secs < 60) return secs + 's running';
|
|
||||||
if (secs < 3600) return Math.floor(secs / 60) + 'm ' + (secs % 60) + 's running';
|
|
||||||
return Math.floor(secs / 3600) + 'h ' + Math.floor((secs % 3600) / 60) + 'm running';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tick once per second to refresh "running Xs" badges in place
|
// Tick once per second to refresh "running Xs" badges in place
|
||||||
// (mirrors the question-TTL ticker pattern above).
|
// (mirrors the question-TTL ticker pattern above).
|
||||||
// Tick rebuild-queue elapsed-time badges once per second.
|
// Tick rebuild-queue elapsed-time badges once per second.
|
||||||
|
|
@ -2863,13 +2575,6 @@ window.marked = marked;
|
||||||
root.append(ul);
|
root.append(ul);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function fmtDuration(secs) {
|
|
||||||
if (secs < 60) return secs + 's';
|
|
||||||
if (secs < 3600) return Math.floor(secs / 60) + 'm ' + (secs % 60) + 's';
|
|
||||||
if (secs < 86400) return Math.floor(secs / 3600) + 'h ' + Math.floor((secs % 3600) / 60) + 'm';
|
|
||||||
return Math.floor(secs / 86400) + 'd ' + Math.floor((secs % 86400) / 3600) + 'h';
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── scheduled prompts ─────────────────────────────────────────────────
|
// ─── scheduled prompts ─────────────────────────────────────────────────
|
||||||
// Backend exposes `/api/schedules` (snapshot), `/api/schedules`
|
// Backend exposes `/api/schedules` (snapshot), `/api/schedules`
|
||||||
// (POST, operator-direct submit), `/api/schedules/{id}/cancel`
|
// (POST, operator-direct submit), `/api/schedules/{id}/cancel`
|
||||||
|
|
|
||||||
49
frontend/packages/dashboard/src/util.js
Normal file
49
frontend/packages/dashboard/src/util.js
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Shared dashboard render + format helpers.
|
||||||
|
//
|
||||||
|
// Small pure utilities used across most dashboard tabs (the container
|
||||||
|
// tree, the rebuild queue, questions / approvals, schedules + reminders):
|
||||||
|
// an atomic-swap render helper and a handful of relative-time / duration
|
||||||
|
// formatters. They live here — a dashboard-internal module — rather than
|
||||||
|
// in the cross-page `common.js`, because they're specific to the
|
||||||
|
// dashboard's render style and not needed by the stand-alone pages.
|
||||||
|
//
|
||||||
|
// All pure: no DOM/module state captured, so any tab module can import
|
||||||
|
// them freely without ordering concerns.
|
||||||
|
|
||||||
|
// Atomic-swap render: build into an off-DOM DocumentFragment, then commit
|
||||||
|
// with a single `replaceChildren`. Avoids an intermediate empty-state
|
||||||
|
// flash on poll cycles even when the builder allocates a lot of nodes.
|
||||||
|
export function paintAtomic(liveRoot, build) {
|
||||||
|
const buf = document.createDocumentFragment();
|
||||||
|
build(buf);
|
||||||
|
liveRoot.replaceChildren(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relative age of a unix timestamp, coarsened to one unit ("5m ago").
|
||||||
|
export function fmtAgo(unixSecs) {
|
||||||
|
const ageSec = Math.max(0, Math.floor(Date.now() / 1000 - unixSecs));
|
||||||
|
if (ageSec < 60) return ageSec + 's ago';
|
||||||
|
if (ageSec < 3600) return Math.floor(ageSec / 60) + 'm ago';
|
||||||
|
if (ageSec < 86400) return Math.floor(ageSec / 3600) + 'h ago';
|
||||||
|
return Math.floor(ageSec / 86400) + 'd ago';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate a string to `n` chars, appending an ellipsis when clipped.
|
||||||
|
export function truncate(s, n) {
|
||||||
|
return s.length <= n ? s : s.slice(0, n - 1) + '…';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Running-duration label for in-flight items ("3m 12s running").
|
||||||
|
export function fmtElapsed(secs) {
|
||||||
|
if (secs < 60) return secs + 's running';
|
||||||
|
if (secs < 3600) return Math.floor(secs / 60) + 'm ' + (secs % 60) + 's running';
|
||||||
|
return Math.floor(secs / 3600) + 'h ' + Math.floor((secs % 3600) / 60) + 'm running';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compact duration label, two units deep ("1h 5m", "2d 3h").
|
||||||
|
export function fmtDuration(secs) {
|
||||||
|
if (secs < 60) return secs + 's';
|
||||||
|
if (secs < 3600) return Math.floor(secs / 60) + 'm ' + (secs % 60) + 's';
|
||||||
|
if (secs < 86400) return Math.floor(secs / 3600) + 'h ' + Math.floor((secs % 3600) / 60) + 'm';
|
||||||
|
return Math.floor(secs / 86400) + 'd ' + Math.floor((secs % 86400) / 3600) + 'h';
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,8 @@
|
||||||
"./colors.css": "./src/colors.css",
|
"./colors.css": "./src/colors.css",
|
||||||
"./theme.css": "./src/theme.css",
|
"./theme.css": "./src/theme.css",
|
||||||
"./base.css": "./src/base.css",
|
"./base.css": "./src/base.css",
|
||||||
"./terminal.css": "./src/terminal.css"
|
"./terminal.css": "./src/terminal.css",
|
||||||
|
"./chrome.css": "./src/chrome.css"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/"
|
"src/"
|
||||||
|
|
|
||||||
45
frontend/packages/shared/src/chrome.css
Normal file
45
frontend/packages/shared/src/chrome.css
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/* ─── page chrome: back-link header ────────────────────────────────
|
||||||
|
The minimal sticky "frosted bar" header used by every standalone page
|
||||||
|
reached from the H0M3 hub — /flow, /logs, /stats, /settings. A back
|
||||||
|
link to H0M3 on the left, then either a page title or (on /logs) a
|
||||||
|
createTabStrip sub-tab nav. The operator dashboard uses its own richer
|
||||||
|
sticky chrome (`.dashboard-chrome`); these classes cover the simple
|
||||||
|
pages.
|
||||||
|
|
||||||
|
Shared across packages via @hive/shared so a new page only links the
|
||||||
|
stylesheet + writes the three-element header markup:
|
||||||
|
|
||||||
|
<header class="page-header">
|
||||||
|
<a class="page-back" href="/">← home</a>
|
||||||
|
<span class="page-title">TITLE</span>
|
||||||
|
</header>
|
||||||
|
*/
|
||||||
|
.page-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 25;
|
||||||
|
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
||||||
|
-webkit-backdrop-filter: blur(8px) saturate(120%);
|
||||||
|
backdrop-filter: blur(8px) saturate(120%);
|
||||||
|
border-bottom: 1px solid var(--purple-dim);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.5em;
|
||||||
|
padding: 0.5em 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-back {
|
||||||
|
color: var(--purple);
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 0.88em;
|
||||||
|
white-space: nowrap;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
.page-back:hover { text-decoration: underline; }
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
color: var(--subtext0);
|
||||||
|
font-size: 0.85em;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue