mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
71e4c6fa17
## Summary - rename the core codex module root to session/mod.rs without using #[path] - move the codex module directory and tests under core/src/session - remove session/mod.rs reexports so call sites use explicit child module paths ## Testing - cargo test -p codex-core --lib - cargo check -p codex-core --tests - just fmt - just fix -p codex-core - git diff --check
48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
use std::sync::Arc;
|
|
|
|
use super::SessionTask;
|
|
use super::SessionTaskContext;
|
|
use crate::session::turn_context::TurnContext;
|
|
use crate::state::TaskKind;
|
|
use codex_protocol::user_input::UserInput;
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
#[derive(Clone, Copy, Default)]
|
|
pub(crate) struct CompactTask;
|
|
|
|
impl SessionTask for CompactTask {
|
|
fn kind(&self) -> TaskKind {
|
|
TaskKind::Compact
|
|
}
|
|
|
|
fn span_name(&self) -> &'static str {
|
|
"session_task.compact"
|
|
}
|
|
|
|
async fn run(
|
|
self: Arc<Self>,
|
|
session: Arc<SessionTaskContext>,
|
|
ctx: Arc<TurnContext>,
|
|
input: Vec<UserInput>,
|
|
_cancellation_token: CancellationToken,
|
|
) -> Option<String> {
|
|
let session = session.clone_session();
|
|
let _ = if crate::compact::should_use_remote_compact_task(ctx.provider.info()) {
|
|
session.services.session_telemetry.counter(
|
|
"codex.task.compact",
|
|
/*inc*/ 1,
|
|
&[("type", "remote")],
|
|
);
|
|
crate::compact_remote::run_remote_compact_task(session.clone(), ctx).await
|
|
} else {
|
|
session.services.session_telemetry.counter(
|
|
"codex.task.compact",
|
|
/*inc*/ 1,
|
|
&[("type", "local")],
|
|
);
|
|
crate::compact::run_compact_task(session.clone(), ctx, input).await
|
|
};
|
|
None
|
|
}
|
|
}
|