T24f Agent: control and cost
HumanInputRequest asks a question with answers to pick and a line to write one; CostBreakdown totals a session and splits it by part. InterruptButton, TokenUsageChart, TraceViewer and EvalResultTable point to chat::stop_button, a stacked BarChart, TimelineProfiler and DataTable. UsageBar shows amounts as its owner writes them. MemoryPanel and HumanInputRequest share agent::line::send_line; the chapter's bool callbacks take forms::OnFlag. DataTable scrolls columns wider than its box sideways, pinned or not, and leaves a plain wheel to the page; sortable headers are Tab stops. TimelineProfiler fits its ruler to its lane, its spans are Tab stops, and a picked span takes accent.
This commit is contained in:
1 parent
061be8a0ff
commit
37e53a5ecb
20 files changed
+934
-180
No files matched your search
@@ -10,6 +10,7 @@ use crate::{
|
||||
buttons::{Button, ButtonVariant},
|
||||
chat::file_icon,
|
||||
collab::Decision,
|
||||
forms::OnFlag,
|
||||
git::{DiffStat, DiffViewer, stat},
|
||||
primitives::{Disclosure, FocusRing, Icon, IconName},
|
||||
theme::{ActiveTheme, ControlSize, IconSize, Radius, TextSize},
|
||||
@@ -33,16 +34,10 @@ pub struct FileChange {
|
||||
pub state: ChangeState,
|
||||
}
|
||||
|
||||
type OnVerdict = Rc<dyn Fn(bool, &mut Window, &mut App)>;
|
||||
type OnDecision = Rc<dyn Fn(Decision, &mut Window, &mut App)>;
|
||||
|
||||
/// Reject and Accept while the change is proposed; after, a quiet word for how it ended.
|
||||
fn verdict(
|
||||
id: &ElementId,
|
||||
state: ChangeState,
|
||||
on_decide: Option<OnVerdict>,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
fn verdict(id: &ElementId, state: ChangeState, on_decide: Option<OnFlag>, cx: &App) -> AnyElement {
|
||||
let colors = &cx.theme().colors;
|
||||
let said = |icon: IconName, word: &'static str, color| {
|
||||
div()
|
||||
@@ -87,7 +82,7 @@ fn verdict(
|
||||
pub struct FileChangeCard {
|
||||
id: ElementId,
|
||||
change: FileChange,
|
||||
on_decide: Option<OnVerdict>,
|
||||
on_decide: Option<OnFlag>,
|
||||
}
|
||||
|
||||
impl FileChangeCard {
|
||||
@@ -113,7 +108,7 @@ impl RenderOnce for FileChangeCard {
|
||||
let (open, unfolded) = (*state.read(cx), folds.read(cx).clone());
|
||||
let (added, removed) = stat(&self.change.old, &self.change.new);
|
||||
let path = self.change.path.clone();
|
||||
let decide = self.on_decide.map(|decide| -> OnVerdict {
|
||||
let decide = self.on_decide.map(|decide| -> OnFlag {
|
||||
Rc::new(move |accepted, window, cx| {
|
||||
log::info!(
|
||||
"file change {path}: {}",
|
||||
|
||||
Reference in new issue
Block a user