fix(ui): make per-view help accurate and keymap-aware
The on-screen help line drifted from actual behavior and hardcoded default keys, so it misled operators (especially with a customized keymap). - Help key hints are now derived from the active keymap (`Keymap::hint`), so they reflect remapped bindings instead of hardcoded defaults. - Table pane: removed the bogus `ctrl+d/u page` (paging is detail-only; `ctrl+d` is delete here) and `gg` (table uses a single `g`); added the bindings that were missing — namespace cycle, sort, reverse, events, help toggle, clear-filter. - Detail/Logs panes: advertise `t table` and `esc close` (both worked, unlisted); clarified `gg/G`, `ctrl+d/u half-page`, `n/N match`, `/ search`. - Docs reconciled: operator-guide navigation + commands (incl. `:api` / dynamic resource browse), README scope note for dynamic discovery. Tests: keymap hint rendering (default + remapped), and per-pane help accuracy (table excludes paging/gg and includes namespace/sort/delete; detail includes close/table/edit). Validation: fmt, check, test (80 passed / 4 ignored), release build all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
04633d2883
commit
8b1c78f025
6 files changed
+193
-52
No files matched your search
@@ -73,8 +73,9 @@ krust --readonly
|
||||
|
||||
Available now:
|
||||
- Multi-context workflow with fast context switching and namespace scoping (`all` namespace supported)
|
||||
- Kubernetes resource browser for:
|
||||
- Kubernetes resource browser for curated kinds:
|
||||
pods, deployments, replicasets, statefulsets, daemonsets, services, ingresses, configmaps, secrets, jobs, cronjobs, pvc/pv, nodes, namespaces, events, serviceaccounts, roles/rolebindings/clusterroles/clusterrolebindings, networkpolicies, hpa, pdb
|
||||
- Dynamic discovery: list and describe **any** other resource or CRD on the cluster (read-only) via `:api` and `:<resource>`
|
||||
- Describe/detail pane with YAML/JSON toggle, syntax highlighting, vim-style search, and wrap/horizontal scroll modes
|
||||
- Logs pane with stream, tail, pause, source filtering, container selection, and multi-pod fan-in for deployment/replicaset views
|
||||
- Secret decode view in YAML, with edit/apply support and automatic re-encode on apply
|
||||
|
||||
@@ -173,6 +173,12 @@ Root problem: full object JSON kept for every entity.
|
||||
---
|
||||
|
||||
## Phase 5 — Hardening & release
|
||||
- [~] **5.0 UX consistency (labels/keybindings/help)** — ongoing pass to keep each view's help,
|
||||
labels, and key hints accurate. Done so far: per-pane help corrected (table no longer claims
|
||||
detail-only `ctrl+d/u` paging or `gg`; added namespace/sort/reverse/events/help/close hints);
|
||||
help is now **keymap-aware** (`Keymap::hint`, reflects remapped bindings); operator-guide +
|
||||
README reconciled (incl. `:api`/dynamic browse). Tests: keymap hint + per-pane help accuracy.
|
||||
Remaining: revisit when new views/commands land (e.g. interactive dynamic-list overlay).
|
||||
- [ ] **5.1 Soak test** — 20 ctx × 10k pods × churn for hours; watch RSS / fd / tokio-task growth.
|
||||
- [ ] **5.2 Reconnect-storm & mixed-RBAC soak** — verify bounded backoff, no leaks, 403 stays terminal.
|
||||
- [ ] **5.3 Config defaults for large fleets** — review fps_limit / delta_channel_capacity /
|
||||
|
||||
+12
-4
@@ -50,11 +50,17 @@ krust --all-contexts
|
||||
## Core Navigation
|
||||
|
||||
- `tab` / `shift+tab`: switch context tabs
|
||||
- `j` / `k` (or arrows): move selection and scroll
|
||||
- `j` / `k` (or arrows): move selection (table) / scroll (detail, logs)
|
||||
- `g` / `G`: top / bottom (in detail panes use `gg` for top)
|
||||
- `Enter`: select namespace in namespace view; otherwise open describe
|
||||
- `d`: describe selected resource
|
||||
- `ctrl+d`: delete (guarded)
|
||||
- `esc`: clear active filter/search prompt
|
||||
- `d`: describe selected resource (toggles back to table)
|
||||
- `v`: view YAML; `t`: back to table; `E`: events pane; `l`: logs
|
||||
- `n`: cycle namespace; `s`: cycle sort column; `r`: reverse sort order
|
||||
- `ctrl+d`: delete (guarded, table only); `ctrl+k`: kill (delete)
|
||||
- `?`: toggle help (table) / search (detail panes)
|
||||
- `esc`: clear filter (table) / close view (detail) / cancel pending action
|
||||
|
||||
All of the above are remappable via `keymap.toml`; the on-screen help line reflects your active bindings.
|
||||
|
||||
## Logs and Runtime Inspect
|
||||
|
||||
@@ -83,6 +89,8 @@ Common command mode entries:
|
||||
- `:ctx` contexts
|
||||
- `:ns` namespaces
|
||||
- `:po`, `:deploy`, `:svc`, `:ing`, `:cm`, `:sec`, etc.
|
||||
- `:api [filter]` list all API resources/CRDs discovered on the context
|
||||
- `:<resource>` browse any discovered resource/CRD (e.g. `:endpoints`, `:widgets`); `:<resource> <name>` describes one
|
||||
- `:fmt yaml|json`
|
||||
- `:edit [yaml|json]`
|
||||
|
||||
|
||||
+70
-5
@@ -46,8 +46,8 @@ impl Keymap {
|
||||
Self::try_from(raw)
|
||||
}
|
||||
|
||||
pub fn is(&self, action: Action, key: &KeyEvent) -> bool {
|
||||
let binding = match action {
|
||||
fn binding(&self, action: Action) -> &Binding {
|
||||
match action {
|
||||
Action::Quit => &self.quit,
|
||||
Action::NextContext => &self.next_context,
|
||||
Action::PrevContext => &self.prev_context,
|
||||
@@ -69,8 +69,17 @@ impl Keymap {
|
||||
Action::Delete => &self.delete,
|
||||
Action::Confirm => &self.confirm,
|
||||
Action::Cancel => &self.cancel,
|
||||
};
|
||||
binding.matches(key)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is(&self, action: Action, key: &KeyEvent) -> bool {
|
||||
self.binding(action).matches(key)
|
||||
}
|
||||
|
||||
/// Human-readable key hint for an action, reflecting the active (possibly remapped) binding.
|
||||
/// Used to keep on-screen help accurate when the keymap is customized.
|
||||
pub fn hint(&self, action: Action) -> String {
|
||||
self.binding(action).display()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +181,37 @@ impl Binding {
|
||||
let normalized = normalize_event(*key);
|
||||
self.code == normalized.code && self.modifiers == normalized.modifiers
|
||||
}
|
||||
|
||||
/// Render the binding as a short hint, e.g. `j`, `G`, `ctrl+d`, `shift+tab`, `up`.
|
||||
fn display(&self) -> String {
|
||||
if self.code == KeyCode::BackTab {
|
||||
return "shift+tab".to_string();
|
||||
}
|
||||
let code = match self.code {
|
||||
KeyCode::Char(c) if self.modifiers.contains(KeyModifiers::SHIFT) => {
|
||||
c.to_ascii_uppercase().to_string()
|
||||
}
|
||||
KeyCode::Char(' ') => "space".to_string(),
|
||||
KeyCode::Char(c) => c.to_string(),
|
||||
KeyCode::Tab => "tab".to_string(),
|
||||
KeyCode::Enter => "enter".to_string(),
|
||||
KeyCode::Esc => "esc".to_string(),
|
||||
KeyCode::Up => "up".to_string(),
|
||||
KeyCode::Down => "down".to_string(),
|
||||
KeyCode::Left => "left".to_string(),
|
||||
KeyCode::Right => "right".to_string(),
|
||||
KeyCode::Backspace => "backspace".to_string(),
|
||||
other => format!("{other:?}").to_lowercase(),
|
||||
};
|
||||
let mut prefix = String::new();
|
||||
if self.modifiers.contains(KeyModifiers::CONTROL) {
|
||||
prefix.push_str("ctrl+");
|
||||
}
|
||||
if self.modifiers.contains(KeyModifiers::ALT) {
|
||||
prefix.push_str("alt+");
|
||||
}
|
||||
format!("{prefix}{code}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -326,7 +366,7 @@ impl fmt::Display for Action {
|
||||
mod tests {
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||
|
||||
use super::{Action, Keymap};
|
||||
use super::{Action, Keymap, RawKeymap};
|
||||
|
||||
fn key(code: KeyCode, modifiers: KeyModifiers) -> KeyEvent {
|
||||
KeyEvent::new(code, modifiers)
|
||||
@@ -378,6 +418,31 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hints_reflect_bindings_for_on_screen_help() {
|
||||
let keymap = Keymap::default();
|
||||
assert_eq!(keymap.hint(Action::Quit), "ctrl+c");
|
||||
assert_eq!(keymap.hint(Action::MoveDown), "j");
|
||||
assert_eq!(keymap.hint(Action::MoveUp), "k");
|
||||
assert_eq!(keymap.hint(Action::GotoTop), "g");
|
||||
assert_eq!(keymap.hint(Action::GotoBottom), "G");
|
||||
assert_eq!(keymap.hint(Action::PrevContext), "shift+tab");
|
||||
assert_eq!(keymap.hint(Action::NextContext), "tab");
|
||||
assert_eq!(keymap.hint(Action::Delete), "ctrl+d");
|
||||
assert_eq!(keymap.hint(Action::Cancel), "esc");
|
||||
assert_eq!(keymap.hint(Action::ToEvents), "E");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hints_follow_a_remapped_binding() {
|
||||
let raw = RawKeymap {
|
||||
move_down: "down".to_string(),
|
||||
..RawKeymap::default()
|
||||
};
|
||||
let keymap = Keymap::try_from(raw).expect("valid keymap");
|
||||
assert_eq!(keymap.hint(Action::MoveDown), "down");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_keymap_keeps_describe_and_delete_separate() {
|
||||
let keymap = Keymap::default();
|
||||
|
||||
@@ -2868,6 +2868,35 @@ mod tests {
|
||||
assert!(!app.browse_dynamic("definitely-not-a-resource", None).await);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_help_matches_actual_table_bindings() {
|
||||
let app = test_app();
|
||||
let tab = app.current_tab().clone();
|
||||
let help = app.context_help_text(&tab);
|
||||
// present + correct
|
||||
assert!(help.contains("g/G top/bot"), "{help}");
|
||||
assert!(help.contains("n namespace"), "{help}");
|
||||
assert!(help.contains("s sort"), "{help}");
|
||||
assert!(help.contains("r reverse"), "{help}");
|
||||
assert!(help.contains("E events"), "{help}");
|
||||
assert!(help.contains("ctrl+d delete"), "{help}");
|
||||
// paging is detail-only; must NOT be advertised in the table (ctrl+d is delete here)
|
||||
assert!(!help.contains("half-page"), "{help}");
|
||||
assert!(!help.contains("gg/G"), "{help}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detail_help_advertises_close_table_and_edit() {
|
||||
let mut app = test_app();
|
||||
app.current_tab_mut().pane = Pane::Describe;
|
||||
let tab = app.current_tab().clone();
|
||||
let help = app.context_help_text(&tab);
|
||||
assert!(help.contains("esc close"), "{help}");
|
||||
assert!(help.contains("t table"), "{help}");
|
||||
assert!(help.contains("e edit"), "{help}");
|
||||
assert!(help.contains("gg/G top/bottom"), "{help}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_describe_pane_has_viewer_state_line() {
|
||||
let mut app = test_app();
|
||||
|
||||
+74
-42
@@ -908,7 +908,7 @@ impl App {
|
||||
);
|
||||
}
|
||||
|
||||
fn context_help_text(&self, active: &ContextTabState) -> String {
|
||||
pub(super) fn context_help_text(&self, active: &ContextTabState) -> String {
|
||||
if let Some(input) = &self.command_input {
|
||||
return match input.mode {
|
||||
CommandMode::Command => [
|
||||
@@ -972,64 +972,96 @@ impl App {
|
||||
};
|
||||
}
|
||||
|
||||
let mut items = vec![
|
||||
"ctrl+c quit",
|
||||
": command",
|
||||
"/ search/filter",
|
||||
"tab switch-ctx",
|
||||
"[ ] history",
|
||||
"- repeat",
|
||||
"ctrl+a aliases",
|
||||
// Key hints are derived from the active keymap so they stay correct when remapped.
|
||||
let k = &self.keymap;
|
||||
let lit = |s: &str| s.to_string();
|
||||
let mut items: Vec<String> = vec![
|
||||
format!("{} quit", k.hint(Action::Quit)),
|
||||
lit(": command"),
|
||||
format!(
|
||||
"{}/{} ctx",
|
||||
k.hint(Action::NextContext),
|
||||
k.hint(Action::PrevContext)
|
||||
),
|
||||
lit("[ ]/- history"),
|
||||
lit("ctrl+a aliases :api"),
|
||||
];
|
||||
|
||||
match active.pane {
|
||||
Pane::Table => {
|
||||
items.extend([
|
||||
"j/k move",
|
||||
"gg/G top/bottom",
|
||||
"ctrl+d/u page",
|
||||
"Enter describe/select-ns",
|
||||
"d describe",
|
||||
"l logs",
|
||||
"c containers",
|
||||
"ctrl+d delete",
|
||||
"ctrl+k kill",
|
||||
format!(
|
||||
"{}/{} move",
|
||||
k.hint(Action::MoveDown),
|
||||
k.hint(Action::MoveUp)
|
||||
),
|
||||
format!(
|
||||
"{}/{} top/bot",
|
||||
k.hint(Action::GotoTop),
|
||||
k.hint(Action::GotoBottom)
|
||||
),
|
||||
format!("{} filter", k.hint(Action::FilterMode)),
|
||||
lit("Enter open/select-ns"),
|
||||
format!("{} describe", k.hint(Action::ToggleDescribe)),
|
||||
format!("{} logs", k.hint(Action::ToLogs)),
|
||||
format!("{} events", k.hint(Action::ToEvents)),
|
||||
lit("c containers"),
|
||||
format!("{} namespace", k.hint(Action::CycleNamespace)),
|
||||
format!("{} sort", k.hint(Action::CycleSort)),
|
||||
format!("{} reverse", k.hint(Action::ToggleDesc)),
|
||||
format!("{} help", k.hint(Action::ToggleHelp)),
|
||||
format!("{} delete", k.hint(Action::Delete)),
|
||||
format!("{} clear-filter", k.hint(Action::Cancel)),
|
||||
]);
|
||||
}
|
||||
Pane::Describe | Pane::SecretDecode | Pane::Events => {
|
||||
items.extend([
|
||||
"j/k scroll",
|
||||
"gg/G top/bottom",
|
||||
"ctrl+d/u page",
|
||||
"n/N next/prev",
|
||||
"w wrap",
|
||||
"left/right h-scroll",
|
||||
"y copy",
|
||||
"d table/describe toggle",
|
||||
format!(
|
||||
"{}/{} scroll",
|
||||
k.hint(Action::MoveDown),
|
||||
k.hint(Action::MoveUp)
|
||||
),
|
||||
lit("gg/G top/bottom"),
|
||||
lit("ctrl+d/u half-page"),
|
||||
lit("n/N match"),
|
||||
lit("/ search"),
|
||||
lit("w wrap"),
|
||||
lit("left/right h-scroll"),
|
||||
lit("y copy"),
|
||||
format!("{} describe-toggle", k.hint(Action::ToggleDescribe)),
|
||||
]);
|
||||
if matches!(active.pane, Pane::Describe | Pane::SecretDecode) {
|
||||
items.extend(["e edit", ":fmt yaml|json"]);
|
||||
items.extend([lit("e edit"), lit(":fmt yaml|json")]);
|
||||
}
|
||||
if active.kind() == ResourceKind::Secrets {
|
||||
items.push("x decode toggle");
|
||||
items.push(lit("x decode toggle"));
|
||||
}
|
||||
items.push("l logs");
|
||||
items.push(format!("{} logs", k.hint(Action::ToLogs)));
|
||||
items.push(format!("{} table", k.hint(Action::ToTable)));
|
||||
items.push(format!("{} close", k.hint(Action::Cancel)));
|
||||
}
|
||||
Pane::Logs => {
|
||||
items.extend([
|
||||
"j/k scroll",
|
||||
"gg/G top/bottom",
|
||||
"ctrl+d/u page",
|
||||
"n/N next/prev",
|
||||
"w wrap",
|
||||
"left/right h-scroll",
|
||||
"y copy",
|
||||
"s tail on/off",
|
||||
"p pause/resume",
|
||||
"S sources",
|
||||
"L latest",
|
||||
"c containers",
|
||||
"d describe",
|
||||
format!(
|
||||
"{}/{} scroll",
|
||||
k.hint(Action::MoveDown),
|
||||
k.hint(Action::MoveUp)
|
||||
),
|
||||
lit("gg/G top/bottom"),
|
||||
lit("ctrl+d/u half-page"),
|
||||
lit("n/N match"),
|
||||
lit("/ search"),
|
||||
lit("w wrap"),
|
||||
lit("left/right h-scroll"),
|
||||
lit("y copy"),
|
||||
format!("{} tail", k.hint(Action::CycleSort)),
|
||||
lit("p pause"),
|
||||
lit("S sources"),
|
||||
lit("L latest"),
|
||||
lit("c containers"),
|
||||
format!("{} describe", k.hint(Action::ToggleDescribe)),
|
||||
format!("{} table", k.hint(Action::ToTable)),
|
||||
format!("{} close", k.hint(Action::Cancel)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user