Panics · P24 Agent: stale checkpoints and frames mark none; progress and memory past their totals fill
This commit is contained in:
1 parent
2e080b83de
commit
e69b96c9e3
8 files changed
+89
-36
No files matched your search
@@ -99,7 +99,10 @@ impl SandboxStatus {
|
|||||||
|
|
||||||
/// Memory in use and its limit, in bytes.
|
/// Memory in use and its limit, in bytes.
|
||||||
pub fn memory(mut self, used: u64, limit: u64) -> Self {
|
pub fn memory(mut self, used: u64, limit: u64) -> Self {
|
||||||
assert!(limit > 0 && used <= limit, "memory {used} of {limit}");
|
assert!(limit > 0, "memory {used} of no limit");
|
||||||
|
if used > limit {
|
||||||
|
log::error!("environment: memory {used} past its limit {limit}; the meter fills");
|
||||||
|
}
|
||||||
self.memory = Some((used, limit));
|
self.memory = Some((used, limit));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -173,7 +176,7 @@ impl RenderOnce for SandboxStatus {
|
|||||||
Meter::new(
|
Meter::new(
|
||||||
(self.id.clone(), "memory"),
|
(self.id.clone(), "memory"),
|
||||||
"Memory",
|
"Memory",
|
||||||
used as f32 / limit as f32,
|
used.min(limit) as f32 / limit as f32,
|
||||||
)
|
)
|
||||||
.detail(format!(
|
.detail(format!(
|
||||||
"{} of {}",
|
"{} of {}",
|
||||||
|
|||||||
+12
-10
@@ -166,7 +166,7 @@ pub struct Checkpoint {
|
|||||||
pub struct CheckpointList {
|
pub struct CheckpointList {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
checkpoints: Vec<Checkpoint>,
|
checkpoints: Vec<Checkpoint>,
|
||||||
current: usize,
|
current: Option<usize>,
|
||||||
on_rewind: Option<Pick>,
|
on_rewind: Option<Pick>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,15 +178,17 @@ impl CheckpointList {
|
|||||||
current: usize,
|
current: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let checkpoints: Vec<Checkpoint> = checkpoints.into_iter().collect();
|
let checkpoints: Vec<Checkpoint> = checkpoints.into_iter().collect();
|
||||||
assert!(
|
let held = current < checkpoints.len();
|
||||||
current < checkpoints.len(),
|
if !held {
|
||||||
"checkpoint {current} of {}",
|
log::error!(
|
||||||
checkpoints.len()
|
"checkpoints: checkpoint {current} of {}; none current",
|
||||||
);
|
checkpoints.len()
|
||||||
|
);
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
checkpoints,
|
checkpoints,
|
||||||
current,
|
current: held.then_some(current),
|
||||||
on_rewind: None,
|
on_rewind: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,7 +212,7 @@ impl RenderOnce for CheckpointList {
|
|||||||
let rewind = self
|
let rewind = self
|
||||||
.on_rewind
|
.on_rewind
|
||||||
.clone()
|
.clone()
|
||||||
.filter(|_| ix != current)
|
.filter(|_| current != Some(ix))
|
||||||
.map(|rewind| {
|
.map(|rewind| {
|
||||||
Button::new((self.id.clone(), format!("rewind-{ix}")), "Rewind to here")
|
Button::new((self.id.clone(), format!("rewind-{ix}")), "Rewind to here")
|
||||||
.variant(ButtonVariant::Ghost)
|
.variant(ButtonVariant::Ghost)
|
||||||
@@ -233,12 +235,12 @@ impl RenderOnce for CheckpointList {
|
|||||||
.items_center()
|
.items_center()
|
||||||
.gap_x_2()
|
.gap_x_2()
|
||||||
.child(plural(point.files as u64, "file", "files"))
|
.child(plural(point.files as u64, "file", "files"))
|
||||||
.when(ix == current, |meta| {
|
.when(current == Some(ix), |meta| {
|
||||||
meta.child(div().text_color(colors.accent).child("Here now"))
|
meta.child(div().text_color(colors.accent).child("Here now"))
|
||||||
})
|
})
|
||||||
.children(rewind),
|
.children(rewind),
|
||||||
);
|
);
|
||||||
timeline.item(if ix == current {
|
timeline.item(if current == Some(ix) {
|
||||||
item.tone(Tone::Accent)
|
item.tone(Tone::Accent)
|
||||||
} else {
|
} else {
|
||||||
item
|
item
|
||||||
|
|||||||
+12
-6
@@ -71,7 +71,7 @@ pub struct BrowserPreview {
|
|||||||
id: ElementId,
|
id: ElementId,
|
||||||
url: SharedString,
|
url: SharedString,
|
||||||
frames: Vec<SharedString>,
|
frames: Vec<SharedString>,
|
||||||
shown: usize,
|
shown: Option<usize>,
|
||||||
ratio: f32,
|
ratio: f32,
|
||||||
loading: bool,
|
loading: bool,
|
||||||
on_show: Option<Pick>,
|
on_show: Option<Pick>,
|
||||||
@@ -86,12 +86,18 @@ impl BrowserPreview {
|
|||||||
shown: usize,
|
shown: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let frames: Vec<SharedString> = frames.into_iter().map(Into::into).collect();
|
let frames: Vec<SharedString> = frames.into_iter().map(Into::into).collect();
|
||||||
assert!(shown < frames.len(), "frame {shown} of {}", frames.len());
|
let held = shown < frames.len();
|
||||||
|
if !held {
|
||||||
|
log::error!(
|
||||||
|
"browser preview: frame {shown} of {}; none shown",
|
||||||
|
frames.len()
|
||||||
|
);
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
url: url.into(),
|
url: url.into(),
|
||||||
frames,
|
frames,
|
||||||
shown,
|
shown: held.then_some(shown),
|
||||||
ratio: FRAME,
|
ratio: FRAME,
|
||||||
loading: false,
|
loading: false,
|
||||||
on_show: None,
|
on_show: None,
|
||||||
@@ -170,7 +176,7 @@ impl RenderOnce for BrowserPreview {
|
|||||||
.h(thumb)
|
.h(thumb)
|
||||||
.rounded(theme.radius(Radius::Sm))
|
.rounded(theme.radius(Radius::Sm))
|
||||||
.border_1()
|
.border_1()
|
||||||
.border_color(if ix == shown {
|
.border_color(if shown == Some(ix) {
|
||||||
colors.accent
|
colors.accent
|
||||||
} else {
|
} else {
|
||||||
colors.border
|
colors.border
|
||||||
@@ -205,7 +211,7 @@ impl RenderOnce for BrowserPreview {
|
|||||||
.when(strip.is_none(), |frame| {
|
.when(strip.is_none(), |frame| {
|
||||||
frame.rounded_b(theme.radius(Radius::Lg))
|
frame.rounded_b(theme.radius(Radius::Lg))
|
||||||
})
|
})
|
||||||
.child({
|
.children(shown.map(|shown| {
|
||||||
let image =
|
let image =
|
||||||
Image::new((self.id.clone(), "frame"), source(&self.frames[shown]))
|
Image::new((self.id.clone(), "frame"), source(&self.frames[shown]))
|
||||||
.size_full();
|
.size_full();
|
||||||
@@ -214,7 +220,7 @@ impl RenderOnce for BrowserPreview {
|
|||||||
} else {
|
} else {
|
||||||
image
|
image
|
||||||
}
|
}
|
||||||
}),
|
})),
|
||||||
)
|
)
|
||||||
.children(strip)
|
.children(strip)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,10 @@ impl AgentProgress {
|
|||||||
done: usize,
|
done: usize,
|
||||||
total: usize,
|
total: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
assert!(total > 0 && done <= total, "progress of {done} in {total}");
|
assert!(total > 0, "progress of {done} in none");
|
||||||
|
if done > total {
|
||||||
|
log::error!("agent progress: {done} done of {total}; the bar fills");
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
current: current.into(),
|
current: current.into(),
|
||||||
@@ -308,7 +311,10 @@ impl RenderOnce for AgentProgress {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.child({
|
.child({
|
||||||
let bar = ProgressBar::new((self.id, "bar"), self.done as f32 / self.total as f32);
|
let bar = ProgressBar::new(
|
||||||
|
(self.id, "bar"),
|
||||||
|
self.done.min(self.total) as f32 / self.total as f32,
|
||||||
|
);
|
||||||
if self.total >= 2 {
|
if self.total >= 2 {
|
||||||
bar.segments(self.total)
|
bar.segments(self.total)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -163,10 +163,29 @@ fn every_checkpoint_but_the_current_rewinds(cx: &mut TestAppContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
/// A sandbox past its memory limit and checkpoints whose current one left.
|
||||||
#[should_panic(expected = "memory 5 of 4")]
|
struct Overrun;
|
||||||
fn memory_past_its_limit_fails_loud() {
|
|
||||||
let _ = SandboxStatus::new("box", "python", SandboxState::Ready).memory(5, 4);
|
impl Render for Overrun {
|
||||||
|
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
let point = Checkpoint {
|
||||||
|
key: "one".into(),
|
||||||
|
label: "One".into(),
|
||||||
|
at: Timestamp::UNIX_EPOCH,
|
||||||
|
files: 1,
|
||||||
|
};
|
||||||
|
div()
|
||||||
|
.w(px(360.0))
|
||||||
|
.child(SandboxStatus::new("box", "python", SandboxState::Ready).memory(5, 4))
|
||||||
|
.child(CheckpointList::new("points", [point], 4))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
fn memory_past_its_limit_and_a_gone_checkpoint_draw(cx: &mut TestAppContext) {
|
||||||
|
setup(cx);
|
||||||
|
let (_, cx) = cx.add_window_view(|_, _| Overrun);
|
||||||
|
settle(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -129,13 +129,7 @@ fn the_prompt_walks_deny_always_then_once(cx: &mut TestAppContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
/// A progress bar for a task of one step, `done` or not; live counts may run past it.
|
||||||
#[should_panic(expected = "progress of 6 in 5")]
|
|
||||||
fn progress_past_its_total_fails_loud() {
|
|
||||||
let _ = AgentProgress::new("progress", "Writing", 6, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A progress bar for a task of one step, `done` or not.
|
|
||||||
struct Single {
|
struct Single {
|
||||||
done: usize,
|
done: usize,
|
||||||
}
|
}
|
||||||
@@ -148,6 +142,13 @@ impl Render for Single {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
fn progress_past_its_total_fills_the_bar(cx: &mut TestAppContext) {
|
||||||
|
cx.update(Theme::init);
|
||||||
|
let (_, cx) = cx.add_window_view(|_, _| Single { done: 6 });
|
||||||
|
settle(cx);
|
||||||
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn a_task_of_one_step_draws_before_and_after(cx: &mut TestAppContext) {
|
fn a_task_of_one_step_draws_before_and_after(cx: &mut TestAppContext) {
|
||||||
cx.update(Theme::init);
|
cx.update(Theme::init);
|
||||||
|
|||||||
@@ -52,10 +52,25 @@ fn a_frame_shows_from_the_keyboard(cx: &mut TestAppContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
/// A browser asked to show a frame it no longer holds.
|
||||||
#[should_panic(expected = "frame 3 of 3")]
|
struct Past;
|
||||||
fn a_frame_past_the_last_fails_loud() {
|
|
||||||
let _ = BrowserPreview::new("browser", "localhost", ["a.png", "b.png", "c.png"], 3);
|
impl Render for Past {
|
||||||
|
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
div().w(px(480.0)).child(BrowserPreview::new(
|
||||||
|
"browser",
|
||||||
|
"localhost",
|
||||||
|
["a.png", "b.png", "c.png"],
|
||||||
|
3,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
fn a_frame_past_the_last_shows_none(cx: &mut TestAppContext) {
|
||||||
|
setup(cx);
|
||||||
|
let (_, cx) = cx.add_window_view(|_, _| Past);
|
||||||
|
settle(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,7 @@ Each item reads every site in its folders, fixes what the rules name, updates ca
|
|||||||
- [x] P21 Documents — `src/documents`
|
- [x] P21 Documents — `src/documents`
|
||||||
- [x] P22 Collaboration — `src/collab`
|
- [x] P22 Collaboration — `src/collab`
|
||||||
- [x] P23 AI Chat — `src/chat`
|
- [x] P23 AI Chat — `src/chat`
|
||||||
- [ ] P24 Agent — `src/agent`
|
- [x] P24 Agent — `src/agent`
|
||||||
- [ ] P25 Generative — `src/generative`
|
- [ ] P25 Generative — `src/generative`
|
||||||
- [ ] P26 Media — `src/media`
|
- [ ] P26 Media — `src/media`
|
||||||
- [ ] P27 Files — `src/files`
|
- [ ] P27 Files — `src/files`
|
||||||
@@ -89,3 +89,4 @@ One line per item: what changed, what stayed and why, review rounds.
|
|||||||
- P21: block editor listeners painted for a block, field, cell or kind since gone log and change nothing, a dropped picture drag leaves undo alone; a visual block press or edit over text the owner replaced is dropped; nested images parse; a version or find hit past its list selects none. Review: 4 rounds.
|
- P21: block editor listeners painted for a block, field, cell or kind since gone log and change nothing, a dropped picture drag leaves undo alone; a visual block press or edit over text the owner replaced is dropped; nested images parse; a version or find hit past its list selects none. Review: 4 rounds.
|
||||||
- P22: annotations and suggestions outside their text log and stay out, picks and decisions keeping the owner's index; `accept` returns `Option`; a gone pick, active thread or followed peer logs; yours at no count comes off; a masked field clamps a stale offset, so remote cursors and selections draw. Kept: a thread's comments, presence max, one list's order, empty marks, constant role and mode tables. Review: 3 rounds.
|
- P22: annotations and suggestions outside their text log and stay out, picks and decisions keeping the owner's index; `accept` returns `Option`; a gone pick, active thread or followed peer logs; yours at no count comes off; a masked field clamps a stale offset, so remote cursors and selections draw. Kept: a thread's comments, presence max, one list's order, empty marks, constant role and mode tables. Review: 3 rounds.
|
||||||
- P23: a branch version past its total logs and shows a dash, its arrows off; a parameter outside its range logs and pegs; a passage's matches outside it log and stay out. Kept: one-value contracts (progress, scores, shapes, peaks, levels, limits, prices, capacity, format, hour), the composer's trigger rows and stream reveal by construction; `places` skips zero, so `decimals` meets no zero step. Review: 2 rounds.
|
- P23: a branch version past its total logs and shows a dash, its arrows off; a parameter outside its range logs and pegs; a passage's matches outside it log and stay out. Kept: one-value contracts (progress, scores, shapes, peaks, levels, limits, prices, capacity, format, hour), the composer's trigger rows and stream reveal by construction; `places` skips zero, so `decimals` meets no zero step. Review: 2 rounds.
|
||||||
|
- P24: a checkpoint or browser frame past its list logs and marks none; progress past its total and memory past its limit log and fill their bars, the text keeping the real counts; three `should_panic` tests became render tests. Kept: the artifact's preview-or-source builder check, one-value contracts (cost, cpu, pointer, totals and limits above zero), registry lookups over a constant table. Review: 1 round.
|
||||||
Reference in new issue
Block a user