mirror of
https://github.com/openai/codex.git
synced 2026-05-02 12:21:26 +03:00
simplify StreamController (#3928)
no intended functional change, just simplifying the code.
This commit is contained in:
@@ -34,41 +34,3 @@ impl StreamState {
|
||||
self.streamer.enqueue(lines)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct HeaderEmitter {
|
||||
emitted_this_turn: bool,
|
||||
emitted_in_stream: bool,
|
||||
}
|
||||
|
||||
impl HeaderEmitter {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self {
|
||||
emitted_this_turn: false,
|
||||
emitted_in_stream: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn reset_for_new_turn(&mut self) {
|
||||
self.emitted_this_turn = false;
|
||||
self.emitted_in_stream = false;
|
||||
}
|
||||
|
||||
pub(crate) fn reset_for_stream(&mut self) {
|
||||
self.emitted_in_stream = false;
|
||||
}
|
||||
|
||||
/// Allow emitting the header again within the current turn after a finalize.
|
||||
pub(crate) fn allow_reemit_in_turn(&mut self) {
|
||||
self.emitted_this_turn = false;
|
||||
}
|
||||
|
||||
pub(crate) fn maybe_emit_header(&mut self) -> bool {
|
||||
if !self.emitted_in_stream && !self.emitted_this_turn {
|
||||
self.emitted_in_stream = true;
|
||||
self.emitted_this_turn = true;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user