mirror of
https://github.com/openai/codex.git
synced 2026-10-29 08:07:53 +00:00
Today `sub_id` is an ID of a single incoming Codex Op submition. We then associate all events triggered by this operation using the same `sub_id`. At the same time we are also creating a TurnContext per submission and we'd like to start associating some events (item added/item completed) with an entire turn instead of just the operation that started it. Using turn context when sending events give us flexibility to change notification scheme.
39 lines
1004 B
Rust
39 lines
1004 B
Rust
use std::sync::Arc;
|
|
|
|
use async_trait::async_trait;
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
use crate::codex::TurnContext;
|
|
use crate::codex::exit_review_mode;
|
|
use crate::codex::run_task;
|
|
use crate::state::TaskKind;
|
|
use codex_protocol::user_input::UserInput;
|
|
|
|
use super::SessionTask;
|
|
use super::SessionTaskContext;
|
|
|
|
#[derive(Clone, Copy, Default)]
|
|
pub(crate) struct ReviewTask;
|
|
|
|
#[async_trait]
|
|
impl SessionTask for ReviewTask {
|
|
fn kind(&self) -> TaskKind {
|
|
TaskKind::Review
|
|
}
|
|
|
|
async fn run(
|
|
self: Arc<Self>,
|
|
session: Arc<SessionTaskContext>,
|
|
ctx: Arc<TurnContext>,
|
|
input: Vec<UserInput>,
|
|
cancellation_token: CancellationToken,
|
|
) -> Option<String> {
|
|
let sess = session.clone_session();
|
|
run_task(sess, ctx, input, TaskKind::Review, cancellation_token).await
|
|
}
|
|
|
|
async fn abort(&self, session: Arc<SessionTaskContext>, ctx: Arc<TurnContext>) {
|
|
exit_review_mode(session.clone_session(), ctx, None).await;
|
|
}
|
|
}
|