grok-build-upstream-mirror/crates/codegen/xai-grok-pager/src/startup.rs
grokkybara[bot] a5727c5960 Synced from monorepo
Changes:
- Non-blocking coding-data sharing upsell banner
- Consolidate remediation in Doctor
- Auto mode defers fail-closed gate asks to the classifier
- Coalesce marketplace list fetches
- Allow removing a marketplace source by name
- Contain hung git marketplace sources (timeouts, non-blocking refresh, unbrick modal)
- Label failed workspace RPCs with error_kind
- Drop redundant explicit tonic/prost deps from xai-grok-shell
- Report real exit codes for completed background shells
- Narrow the date-rollover reminder to date-bearing templates
- Wire toolOverrides through the session and agent
- Security: Bash(git:*) allowlist matches whole command chain by prefix
- Split prompt-trigger telemetry and record classifier provenance
- Raise connectors-manager timeout to 60s
- Auto classifier honors recorded approvals for repeat actions
- Apply doctor fixes in the TUI
- Auto-mode classifier timeouts prompt instead of silently denying
- Scope subagent completion drains to the owning session
- Add the toolOverrides wire types
- Set client_identifier=grok-agent-sdk
- Accept both spellings of the workspace-teleport kill switch
- Persist one-shot occurrence journal
- Stop turns that poll the exact same tool call 16x in a row
- Copy compaction checkpoint files when forking sessions
- Auto-focus permission prompt from scrollback
- Esc cancels the running turn in non-vim and minimal modes
- List Ctrl+Z undo and redo in keyboard shortcuts
- Out-of-process macOS mic capture
- Show active auth mode on session-info
- Install the npm binary under $GROK_HOME
- Remove hover/click dead zones between dashboard items
- Route startup warnings to doctor
- Document [feedback.user] author identity config
- Extend bang command timeout
- Close combine-queued edit-hold race
- Integrate relocation recovery
- Expose privacy notice rollout flag
- Break harness discovery ref cycle so connections can idle-evict
- Shift/Alt+Enter inserts newline when editing a queued prompt
- Gate project Claude permissions on folder trust
- Echo response.create.event_id on response.created
- Toast when session creation fails from disk full
- Add shared test process lifecycle
- Enable dynamic workflows by default
- Add relocation transaction state machine
- Add shared test sandbox
- Surface auth failures on model-switch compact
- Persist durable scheduler expiry
- Confirm before removing extensions-modal items
- Re-run compact and prompt after login when compact hit expired auth
- Recap sends hosted tools under backend search
2026-07-22 19:22:27 +01:00

144 lines
4.9 KiB
Rust

//! Generic startup warnings displayed on the welcome screen.
//!
//! Any subsystem (terminal diagnostics, auth, config migration, etc.) can
//! produce [`StartupWarning`]s.
pub(crate) const DOCTOR_ACTION: &str = "Run /doctor for details and fixes.";
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ActionableStartupWarning {
warning: StartupWarning,
ids: Vec<crate::diagnostics::DiagnosticId>,
}
impl ActionableStartupWarning {
pub(crate) fn new(
severity: WarningSeverity,
message: impl Into<String>,
ids: impl IntoIterator<Item = crate::diagnostics::DiagnosticId>,
) -> Self {
let ids = ids.into_iter().collect::<Vec<_>>();
assert!(
!ids.is_empty(),
"doctor-linked startup notice requires an ID"
);
Self {
warning: StartupWarning {
severity,
message: message.into(),
action: Some(DOCTOR_ACTION.to_owned()),
},
ids,
}
}
#[cfg(test)]
pub(crate) fn ids(&self) -> &[crate::diagnostics::DiagnosticId] {
&self.ids
}
pub(crate) fn into_warning(self) -> StartupWarning {
self.warning
}
}
/// A non-fatal startup warning from any subsystem.
///
/// This is a **display contract only** -- the subsystem formats the message
/// and optional action hint. Actionable diagnostic notices link to `/doctor`,
/// which owns detailed evidence and remediation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StartupWarning {
/// Severity controls rendering color (yellow for warnings, dim for info).
pub severity: WarningSeverity,
/// Short, user-facing message (fits in ~60 columns).
pub message: String,
/// Optional action hint (e.g. "Run /doctor for details and fixes.").
pub action: Option<String>,
}
/// Severity level for startup warnings.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WarningSeverity {
/// Rendered in warning color (yellow). Something is misconfigured.
Warning,
/// Rendered in dim/gray. Informational, not actionable.
Info,
}
/// Pick the warning the single-slot welcome banner shows: the first
/// `Warning`-severity entry, else the last entry.
///
/// `startup_warnings` is appended to at runtime while the user sits on the
/// welcome screen (session-start failures, Claude import results), so a plain
/// `first()` lets an early entry mask that later feedback — e.g. an import
/// Info result at index 0 hides a session-start Warning pushed behind it.
/// Severity decides first (a real Warning always beats an Info; among
/// Warnings, assemble order stays authoritative); a Warning-less list falls
/// back to the **last** entry because later Info pushes are direct
/// user-action feedback that must not be masked by an older Info. Every
/// banner surface (height calc + render) must pick through here so they
/// cannot disagree.
pub fn banner_warning(warnings: &[StartupWarning]) -> Option<&StartupWarning> {
warnings
.iter()
.find(|w| w.severity == WarningSeverity::Warning)
.or_else(|| warnings.last())
}
#[cfg(test)]
mod tests {
use super::*;
fn entry(severity: WarningSeverity, message: &str) -> StartupWarning {
StartupWarning {
severity,
message: message.to_owned(),
action: None,
}
}
#[test]
fn banner_warning_empty_is_none() {
assert!(banner_warning(&[]).is_none());
}
#[test]
fn banner_warning_lone_info_shows() {
let list = [entry(WarningSeverity::Info, "info note")];
assert_eq!(banner_warning(&list).unwrap().message, "info note");
}
#[test]
fn banner_warning_runtime_pushed_warning_displaces_info() {
// An Info entry holds index 0 (e.g. a Claude import result). A
// Warning pushed later (e.g. "Not inside a git repository") must
// still win the single banner slot.
let list = [
entry(WarningSeverity::Info, "info note"),
entry(WarningSeverity::Warning, "real problem"),
];
assert_eq!(banner_warning(&list).unwrap().message, "real problem");
}
#[test]
fn banner_warning_runtime_pushed_info_displaces_earlier_info() {
// Warning-less list: a later Info push is direct user-action
// feedback (e.g. a Claude import result) and wins over an older Info.
let list = [
entry(WarningSeverity::Info, "info note"),
entry(WarningSeverity::Info, "import result"),
];
assert_eq!(banner_warning(&list).unwrap().message, "import result");
}
#[test]
fn banner_warning_first_warning_wins_among_warnings() {
let list = [
entry(WarningSeverity::Warning, "first"),
entry(WarningSeverity::Warning, "second"),
entry(WarningSeverity::Info, "info note"),
];
assert_eq!(banner_warning(&list).unwrap().message, "first");
}
}