Method::NotifyとEvent::Notificationが紛らわしい問題
This commit is contained in:
+20
-20
@@ -1,4 +1,4 @@
|
||||
use protocol::{Event, Method, NotificationLevel, NotificationSource, RunResult};
|
||||
use protocol::{Event, Method, AlertLevel, AlertSource, RunResult};
|
||||
|
||||
use crate::block::{Block, CompactEvent, ToolCallBlock, ToolCallState};
|
||||
use crate::cache::FileCache;
|
||||
@@ -81,9 +81,9 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn push_error(&mut self, message: impl Into<String>) {
|
||||
self.blocks.push(Block::Notification {
|
||||
level: NotificationLevel::Error,
|
||||
source: NotificationSource::Pod,
|
||||
self.blocks.push(Block::Alert {
|
||||
level: AlertLevel::Error,
|
||||
source: AlertSource::Pod,
|
||||
message: message.into(),
|
||||
});
|
||||
}
|
||||
@@ -194,16 +194,16 @@ impl App {
|
||||
apply_cache_update(&mut self.cache, &name, args.as_deref(), output.as_deref());
|
||||
}
|
||||
} else {
|
||||
// Result for an unknown tool call. Surface it as a
|
||||
// notification so it isn't silently dropped.
|
||||
// Result for an unknown tool call. Surface it as an
|
||||
// alert so it isn't silently dropped.
|
||||
let level = if is_error {
|
||||
NotificationLevel::Error
|
||||
AlertLevel::Error
|
||||
} else {
|
||||
NotificationLevel::Warn
|
||||
AlertLevel::Warn
|
||||
};
|
||||
self.blocks.push(Block::Notification {
|
||||
self.blocks.push(Block::Alert {
|
||||
level,
|
||||
source: NotificationSource::Pod,
|
||||
source: AlertSource::Pod,
|
||||
message: format!("orphan tool result ({id}): {summary}"),
|
||||
});
|
||||
}
|
||||
@@ -243,11 +243,11 @@ impl App {
|
||||
self.blocks
|
||||
.push(Block::Compact(CompactEvent::Failed { error }));
|
||||
}
|
||||
Event::Notification(notification) => {
|
||||
self.blocks.push(Block::Notification {
|
||||
level: notification.level,
|
||||
source: notification.source,
|
||||
message: notification.message,
|
||||
Event::Alert(alert) => {
|
||||
self.blocks.push(Block::Alert {
|
||||
level: alert.level,
|
||||
source: alert.source,
|
||||
message: alert.message,
|
||||
});
|
||||
}
|
||||
Event::History { items, greeting } => {
|
||||
@@ -488,12 +488,12 @@ fn strip_cat_n_prefix(formatted: &str) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
pub fn notification_source_label(source: NotificationSource) -> &'static str {
|
||||
pub fn alert_source_label(source: AlertSource) -> &'static str {
|
||||
match source {
|
||||
NotificationSource::Pod => "pod",
|
||||
NotificationSource::Worker => "worker",
|
||||
NotificationSource::Compactor => "compactor",
|
||||
NotificationSource::AgentsMd => "AGENTS.md",
|
||||
AlertSource::Pod => "pod",
|
||||
AlertSource::Worker => "worker",
|
||||
AlertSource::Compactor => "compactor",
|
||||
AlertSource::AgentsMd => "AGENTS.md",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#![allow(dead_code)] // Phase 5 will consume `output` in detail mode.
|
||||
|
||||
use protocol::{Greeting, NotificationLevel, NotificationSource};
|
||||
use protocol::{Greeting, AlertLevel, AlertSource};
|
||||
|
||||
pub enum Block {
|
||||
Greeting(Greeting),
|
||||
@@ -21,9 +21,9 @@ pub enum Block {
|
||||
text: String,
|
||||
},
|
||||
ToolCall(ToolCallBlock),
|
||||
Notification {
|
||||
level: NotificationLevel,
|
||||
source: NotificationSource,
|
||||
Alert {
|
||||
level: AlertLevel,
|
||||
source: AlertSource,
|
||||
message: String,
|
||||
},
|
||||
Compact(CompactEvent),
|
||||
|
||||
@@ -20,9 +20,9 @@ use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block as UiBlock, BorderType, Borders, Padding, Paragraph, Widget, Wrap};
|
||||
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
||||
|
||||
use protocol::{Greeting, NotificationLevel};
|
||||
use protocol::{Greeting, AlertLevel};
|
||||
|
||||
use crate::app::{App, fmt_tokens, notification_source_label};
|
||||
use crate::app::{App, fmt_tokens, alert_source_label};
|
||||
use crate::block::{Block, CompactEvent};
|
||||
|
||||
/// Display density for the history view.
|
||||
@@ -313,20 +313,20 @@ fn render_block_into(
|
||||
// ToolCall is dispatched in `compute_history` via `tool::render_tool`
|
||||
// so it can consume multiple adjacent blocks (Read aggregation).
|
||||
Block::ToolCall(_) => unreachable!("ToolCall handled by compute_history"),
|
||||
Block::Notification {
|
||||
Block::Alert {
|
||||
level,
|
||||
source,
|
||||
message,
|
||||
} => {
|
||||
let kind = match level {
|
||||
NotificationLevel::Warn => MessageKind::NoticeWarn,
|
||||
NotificationLevel::Error => MessageKind::NoticeError,
|
||||
AlertLevel::Warn => MessageKind::NoticeWarn,
|
||||
AlertLevel::Error => MessageKind::NoticeError,
|
||||
};
|
||||
let prefix = match level {
|
||||
NotificationLevel::Warn => "[notice]",
|
||||
NotificationLevel::Error => "[notice error]",
|
||||
AlertLevel::Warn => "[notice]",
|
||||
AlertLevel::Error => "[notice error]",
|
||||
};
|
||||
let label = notification_source_label(*source);
|
||||
let label = alert_source_label(*source);
|
||||
let text = format!("{prefix} {label}: {message}");
|
||||
match mode {
|
||||
Mode::Overview => push_overview_line(lines, &text, width, kind, ""),
|
||||
|
||||
Reference in New Issue
Block a user