feat(history): add unified MCP execution history
This commit is contained in:
39 files changed
+1261
-87
No files matched your search
@@ -1304,6 +1304,12 @@ async fn serve() {
|
||||
get(routes::app_settings::load_history_retention_limit)
|
||||
.put(routes::app_settings::save_history_retention_limit),
|
||||
)
|
||||
.route(
|
||||
"/app-settings/mcp-history-retention-limit",
|
||||
get(routes::app_settings::load_mcp_history_retention_limit)
|
||||
.put(routes::app_settings::save_mcp_history_retention_limit),
|
||||
)
|
||||
.route("/app-settings/mcp-history-retention-cleanup", post(routes::app_settings::cleanup_mcp_history_retention))
|
||||
.route(
|
||||
"/app-settings/max-retries",
|
||||
get(routes::app_settings::load_max_retries).put(routes::app_settings::save_max_retries),
|
||||
|
||||
@@ -154,6 +154,23 @@ pub async fn save_history_retention_limit(
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
pub async fn load_mcp_history_retention_limit(State(state): State<Arc<WebState>>) -> Result<Json<u32>, AppError> {
|
||||
state.app.storage.load_mcp_history_retention_limit().await.map(Json).map_err(AppError::from)
|
||||
}
|
||||
|
||||
pub async fn save_mcp_history_retention_limit(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(body): Json<SaveHistoryRetentionLimitRequest>,
|
||||
) -> Result<Json<()>, AppError> {
|
||||
dbx_core::history::validate_history_retention_limit(body.limit).map_err(AppError::bad_request)?;
|
||||
state.app.storage.save_mcp_history_retention_limit(body.limit).await.map_err(AppError::from)?;
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
pub async fn cleanup_mcp_history_retention(State(state): State<Arc<WebState>>) -> Result<Json<u64>, AppError> {
|
||||
state.app.storage.cleanup_mcp_history_retention().await.map(Json).map_err(AppError::from)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SaveMaxRetriesRequest {
|
||||
|
||||
@@ -15,6 +15,11 @@ pub struct HistoryQuery {
|
||||
pub activity_kind: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct HistoryClearQuery {
|
||||
pub source: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SaveHistoryRequest {
|
||||
@@ -53,8 +58,15 @@ pub async fn load_history_connection_options(
|
||||
state.app.storage.load_history_connection_options().await.map(Json).map_err(AppError::from)
|
||||
}
|
||||
|
||||
pub async fn clear_history(State(state): State<Arc<WebState>>) -> Result<Json<()>, AppError> {
|
||||
state.app.storage.clear_history().await.map_err(AppError::from)?;
|
||||
pub async fn clear_history(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Query(query): Query<HistoryClearQuery>,
|
||||
) -> Result<Json<()>, AppError> {
|
||||
if let Some(source) = query.source.as_deref().filter(|source| !source.trim().is_empty()) {
|
||||
state.app.storage.clear_history_by_source(source).await.map_err(AppError::from)?;
|
||||
} else {
|
||||
state.app.storage.clear_history().await.map_err(AppError::from)?;
|
||||
}
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user