Revert "Standardize Session Name Attribute" (#5250)

This commit is contained in:
Michael Neale
2025-10-19 03:44:30 +11:00
committed by GitHub
parent 9b4c8726f1
commit 890393bb68
29 changed files with 237 additions and 1193 deletions
+2 -2
View File
@@ -355,7 +355,7 @@ derive_utoipa!(Icon as IconSchema);
super::routes::session::list_sessions,
super::routes::session::get_session,
super::routes::session::get_session_insights,
super::routes::session::update_session_name,
super::routes::session::update_session_description,
super::routes::session::delete_session,
super::routes::session::export_session,
super::routes::session::import_session,
@@ -398,7 +398,7 @@ derive_utoipa!(Icon as IconSchema);
super::routes::context::ContextManageResponse,
super::routes::session::ImportSessionRequest,
super::routes::session::SessionListResponse,
super::routes::session::UpdateSessionNameRequest,
super::routes::session::UpdateSessionDescriptionRequest,
super::routes::session::UpdateSessionUserRecipeValuesRequest,
Message,
MessageContent,
+2 -2
View File
@@ -139,9 +139,9 @@ async fn start_agent(
}
let counter = state.session_counter.fetch_add(1, Ordering::SeqCst) + 1;
let name = format!("New session {}", counter);
let description = format!("New session {}", counter);
let mut session = SessionManager::create_session(PathBuf::from(&working_dir), name)
let mut session = SessionManager::create_session(PathBuf::from(&working_dir), description)
.await
.map_err(|err| {
error!("Failed to create session: {}", err);
+5 -5
View File
@@ -68,10 +68,10 @@ fn default_limit() -> u32 {
#[derive(Serialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct SessionDisplayInfo {
id: String,
name: String,
created_at: String,
working_dir: String,
id: String, // Derived from session_name (filename)
name: String, // From metadata.description
created_at: String, // Derived from session_name, in ISO 8601 format
working_dir: String, // from metadata.working_dir (as String)
schedule_id: Option<String>,
message_count: usize,
total_tokens: Option<i32>,
@@ -325,7 +325,7 @@ async fn sessions_handler(
for (session_name, session) in session_tuples {
display_infos.push(SessionDisplayInfo {
id: session_name.clone(),
name: session.name,
name: session.description,
created_at: parse_session_name_to_iso(&session_name),
working_dir: session.working_dir.to_string_lossy().into_owned(),
schedule_id: session.schedule_id,
+16 -17
View File
@@ -22,9 +22,9 @@ pub struct SessionListResponse {
#[derive(Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSessionNameRequest {
/// Updated name for the session (max 200 characters)
name: String,
pub struct UpdateSessionDescriptionRequest {
/// Updated description (name) for the session (max 200 characters)
description: String,
}
#[derive(Deserialize, ToSchema)]
@@ -40,7 +40,7 @@ pub struct ImportSessionRequest {
json: String,
}
const MAX_NAME_LENGTH: usize = 200;
const MAX_DESCRIPTION_LENGTH: usize = 200;
#[utoipa::path(
get,
@@ -109,14 +109,14 @@ async fn get_session_insights() -> Result<Json<SessionInsights>, StatusCode> {
#[utoipa::path(
put,
path = "/sessions/{session_id}/name",
request_body = UpdateSessionNameRequest,
path = "/sessions/{session_id}/description",
request_body = UpdateSessionDescriptionRequest,
params(
("session_id" = String, Path, description = "Unique identifier for the session")
),
responses(
(status = 200, description = "Session name updated successfully"),
(status = 400, description = "Bad request - Name too long (max 200 characters)"),
(status = 200, description = "Session description updated successfully"),
(status = 400, description = "Bad request - Description too long (max 200 characters)"),
(status = 401, description = "Unauthorized - Invalid or missing API key"),
(status = 404, description = "Session not found"),
(status = 500, description = "Internal server error")
@@ -126,20 +126,16 @@ async fn get_session_insights() -> Result<Json<SessionInsights>, StatusCode> {
),
tag = "Session Management"
)]
async fn update_session_name(
async fn update_session_description(
Path(session_id): Path<String>,
Json(request): Json<UpdateSessionNameRequest>,
Json(request): Json<UpdateSessionDescriptionRequest>,
) -> Result<StatusCode, StatusCode> {
let name = request.name.trim();
if name.is_empty() {
return Err(StatusCode::BAD_REQUEST);
}
if name.len() > MAX_NAME_LENGTH {
if request.description.len() > MAX_DESCRIPTION_LENGTH {
return Err(StatusCode::BAD_REQUEST);
}
SessionManager::update_session(&session_id)
.user_provided_name(name.to_string())
.description(request.description)
.apply()
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
@@ -268,7 +264,10 @@ pub fn routes(state: Arc<AppState>) -> Router {
.route("/sessions/{session_id}/export", get(export_session))
.route("/sessions/import", post(import_session))
.route("/sessions/insights", get(get_session_insights))
.route("/sessions/{session_id}/name", put(update_session_name))
.route(
"/sessions/{session_id}/description",
put(update_session_description),
)
.route(
"/sessions/{session_id}/user_recipe_values",
put(update_session_user_recipe_values),