fix: 7 项 E2E Bug 修复 — Dashboard 404 / 记忆去重 / 记忆注入 / invoice_id / Prompt 版本
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
P0: - BUG-H1: Dashboard 路由 /api/v1/stats/dashboard → /api/v1/admin/dashboard P1: - BUG-H2: viking_add 预检查 content_hash 去重,返回 "deduped" 状态;SqliteStorage 启动时回填已有条目 content_hash - BUG-M5: saas-relay-client 发送前调用 viking_inject_prompt 注入跨会话记忆 P2: - BUG-M1: PaymentResult 添加 invoice_id 字段,query_payment_status 返回 invoice_id - BUG-M2: UpdatePromptRequest 添加内容字段,更新时自动创建新版本并递增 current_version - BUG-M3: viking_find scope 参数文档化(设计行为,调用方需传 agent scope) - BUG-M4: Dashboard 路由缺失已修复,handler 层 require_admin 已正确返回 403 P3 (确认已修复/非代码问题): - BUG-L1: pain_seed_categories 已统一,无 pain_seeds 残留 - BUG-L2: pipeline_create 参数格式正确,E2E 测试方法问题
This commit is contained in:
@@ -68,7 +68,7 @@ pub async fn get_prompt(
|
||||
Ok(Json(service::get_template_by_name(&state.db, &name).await?))
|
||||
}
|
||||
|
||||
/// PUT /api/v1/prompts/{name} — 更新模板元数据
|
||||
/// PUT /api/v1/prompts/{name} — 更新模板元数据 + 可选自动创建新版本
|
||||
pub async fn update_prompt(
|
||||
State(state): State<AppState>,
|
||||
Extension(ctx): Extension<AuthContext>,
|
||||
@@ -82,6 +82,11 @@ pub async fn update_prompt(
|
||||
&state.db, &tmpl.id,
|
||||
req.description.as_deref(),
|
||||
req.status.as_deref(),
|
||||
req.system_prompt.as_deref(),
|
||||
req.user_prompt_template.as_deref(),
|
||||
req.variables.clone(),
|
||||
req.changelog.as_deref(),
|
||||
req.min_app_version.as_deref(),
|
||||
).await?;
|
||||
|
||||
log_operation(&state.db, &ctx.account_id, "prompt.update", "prompt", &tmpl.id,
|
||||
@@ -99,7 +104,7 @@ pub async fn archive_prompt(
|
||||
check_permission(&ctx, "prompt:admin")?;
|
||||
|
||||
let tmpl = service::get_template_by_name(&state.db, &name).await?;
|
||||
let result = service::update_template(&state.db, &tmpl.id, None, Some("archived")).await?;
|
||||
let result = service::update_template(&state.db, &tmpl.id, None, Some("archived"), None, None, None, None, None).await?;
|
||||
|
||||
log_operation(&state.db, &ctx.account_id, "prompt.archive", "prompt", &tmpl.id, None, ctx.client_ip.as_deref()).await?;
|
||||
|
||||
|
||||
@@ -108,12 +108,20 @@ pub async fn list_templates(
|
||||
Ok(PaginatedResponse { items, total, page, page_size })
|
||||
}
|
||||
|
||||
/// 更新模板元数据(不修改内容)
|
||||
/// 更新模板元数据 + 可选自动创建新版本
|
||||
///
|
||||
/// 当传入 `system_prompt` 时,自动创建新版本并递增 `current_version`。
|
||||
/// 仅更新 `description`/`status` 时不会递增版本号。
|
||||
pub async fn update_template(
|
||||
db: &PgPool,
|
||||
id: &str,
|
||||
description: Option<&str>,
|
||||
status: Option<&str>,
|
||||
system_prompt: Option<&str>,
|
||||
user_prompt_template: Option<&str>,
|
||||
variables: Option<serde_json::Value>,
|
||||
changelog: Option<&str>,
|
||||
min_app_version: Option<&str>,
|
||||
) -> SaasResult<PromptTemplateInfo> {
|
||||
let now = chrono::Utc::now();
|
||||
|
||||
@@ -130,6 +138,11 @@ pub async fn update_template(
|
||||
.bind(st).bind(&now).bind(id).execute(db).await?;
|
||||
}
|
||||
|
||||
// Auto-create version when content is provided
|
||||
if let Some(sp) = system_prompt {
|
||||
create_version(db, id, sp, user_prompt_template, variables, changelog, min_app_version).await?;
|
||||
}
|
||||
|
||||
get_template(db, id).await
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,12 @@ pub struct CreatePromptRequest {
|
||||
pub struct UpdatePromptRequest {
|
||||
pub description: Option<String>,
|
||||
pub status: Option<String>,
|
||||
/// If provided, auto-creates a new version with this content
|
||||
pub system_prompt: Option<String>,
|
||||
pub user_prompt_template: Option<String>,
|
||||
pub variables: Option<serde_json::Value>,
|
||||
pub changelog: Option<String>,
|
||||
pub min_app_version: Option<String>,
|
||||
}
|
||||
|
||||
// --- Prompt Version ---
|
||||
|
||||
Reference in New Issue
Block a user