1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -4142,7 +4142,13 @@ fn upsert_world_foundation_card(
|
||||
draft_profile: &JsonMap<String, JsonValue>,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<(), String> {
|
||||
let card_id = "world-foundation".to_string();
|
||||
let card_id = build_world_foundation_card_id(session_id);
|
||||
let existing_card = ctx
|
||||
.db
|
||||
.custom_world_draft_card()
|
||||
.card_id()
|
||||
.find(&card_id)
|
||||
.filter(|row| row.session_id == session_id);
|
||||
let title = read_optional_text_field(draft_profile, &["name", "title"])
|
||||
.unwrap_or_else(|| "世界底稿".to_string());
|
||||
let subtitle = read_optional_text_field(draft_profile, &["subtitle"]).unwrap_or_default();
|
||||
@@ -4164,13 +4170,7 @@ fn upsert_world_foundation_card(
|
||||
"warningMessages": [],
|
||||
}))?;
|
||||
|
||||
if let Some(existing) = ctx
|
||||
.db
|
||||
.custom_world_draft_card()
|
||||
.card_id()
|
||||
.find(&card_id)
|
||||
.filter(|row| row.session_id == session_id)
|
||||
{
|
||||
if let Some(existing) = existing_card {
|
||||
replace_custom_world_draft_card(
|
||||
ctx,
|
||||
&existing,
|
||||
@@ -4221,6 +4221,11 @@ fn upsert_world_foundation_card(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn build_world_foundation_card_id(session_id: &str) -> String {
|
||||
// `custom_world_draft_card.card_id` 是全局主键,世界底稿卡必须带上会话维度,避免多会话写入时触发唯一键冲突。
|
||||
format!("custom-world:{session_id}:world-foundation")
|
||||
}
|
||||
|
||||
fn sync_session_draft_profile_from_card_update(
|
||||
session: &CustomWorldAgentSession,
|
||||
card: &CustomWorldDraftCard,
|
||||
|
||||
Reference in New Issue
Block a user