mirror of
https://github.com/openai/codex.git
synced 2026-05-02 12:21:26 +03:00
Revamp status UI with rate limit reset times
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use ratatui::text::Line;
|
||||
|
||||
use crate::markdown_stream::AnimatedLineStreamer;
|
||||
use crate::markdown_stream::MarkdownStreamCollector;
|
||||
pub(crate) mod controller;
|
||||
|
||||
pub(crate) struct StreamState {
|
||||
pub(crate) collector: MarkdownStreamCollector,
|
||||
queued_lines: VecDeque<Line<'static>>,
|
||||
pub(crate) streamer: AnimatedLineStreamer,
|
||||
pub(crate) has_seen_delta: bool,
|
||||
}
|
||||
|
||||
@@ -15,25 +12,25 @@ impl StreamState {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self {
|
||||
collector: MarkdownStreamCollector::new(),
|
||||
queued_lines: VecDeque::new(),
|
||||
streamer: AnimatedLineStreamer::new(),
|
||||
has_seen_delta: false,
|
||||
}
|
||||
}
|
||||
pub(crate) fn clear(&mut self) {
|
||||
self.collector.clear();
|
||||
self.queued_lines.clear();
|
||||
self.streamer.clear();
|
||||
self.has_seen_delta = false;
|
||||
}
|
||||
pub(crate) fn step(&mut self) -> Vec<Line<'static>> {
|
||||
self.queued_lines.pop_front().into_iter().collect()
|
||||
pub(crate) fn step(&mut self) -> crate::markdown_stream::StepResult {
|
||||
self.streamer.step()
|
||||
}
|
||||
pub(crate) fn drain_all(&mut self) -> Vec<Line<'static>> {
|
||||
self.queued_lines.drain(..).collect()
|
||||
pub(crate) fn drain_all(&mut self) -> crate::markdown_stream::StepResult {
|
||||
self.streamer.drain_all()
|
||||
}
|
||||
pub(crate) fn is_idle(&self) -> bool {
|
||||
self.queued_lines.is_empty()
|
||||
self.streamer.is_idle()
|
||||
}
|
||||
pub(crate) fn enqueue(&mut self, lines: Vec<Line<'static>>) {
|
||||
self.queued_lines.extend(lines);
|
||||
pub(crate) fn enqueue(&mut self, lines: Vec<ratatui::text::Line<'static>>) {
|
||||
self.streamer.enqueue(lines)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user