拼图候选图改为增加而非替换

This commit is contained in:
2026-04-25 22:03:41 +08:00
parent 1ca799c3e5
commit 7d6963980f
6 changed files with 80 additions and 17 deletions

View File

@@ -468,6 +468,7 @@ pub async fn execute_puzzle_agent_action(
.filter(|value| !value.trim().is_empty())
.unwrap_or_else(|| draft.summary.clone());
let candidate_count = payload.candidate_count.unwrap_or(2).clamp(1, 2);
let candidate_start_index = draft.candidates.len();
let candidates = generate_puzzle_image_candidates(
&state,
owner_user_id.as_str(),
@@ -475,6 +476,7 @@ pub async fn execute_puzzle_agent_action(
&draft.level_name,
&prompt,
candidate_count,
candidate_start_index,
)
.await
.map_err(SpacetimeClientError::Runtime);
@@ -1474,6 +1476,7 @@ async fn compile_puzzle_draft_with_initial_cover(
&draft.level_name,
&draft.summary,
2,
draft.candidates.len(),
)
.await
.map_err(SpacetimeClientError::Runtime)?;
@@ -1616,6 +1619,7 @@ async fn generate_puzzle_image_candidates(
level_name: &str,
prompt: &str,
candidate_count: u32,
candidate_start_index: usize,
) -> Result<Vec<PuzzleGeneratedImageCandidateRecord>, String> {
let count = candidate_count.clamp(1, 2);
let settings =
@@ -1635,7 +1639,7 @@ async fn generate_puzzle_image_candidates(
let mut items = Vec::with_capacity(generated.images.len());
for (index, image) in generated.images.into_iter().enumerate() {
let candidate_id = format!("{session_id}-candidate-{}", index + 1);
let candidate_id = format!("{session_id}-candidate-{}", candidate_start_index + index + 1);
let asset = persist_puzzle_generated_asset(
state,
owner_user_id,
@@ -1655,7 +1659,7 @@ async fn generate_puzzle_image_candidates(
prompt: prompt.to_string(),
actual_prompt: Some(prompt.to_string()),
source_type: "generated".to_string(),
selected: index == 0,
selected: candidate_start_index == 0 && index == 0,
});
}
@@ -1729,6 +1733,7 @@ async fn build_local_next_puzzle_run(
&draft.level_name,
&draft.summary,
2,
draft.candidates.len(),
)
.await
.map_err(|message| {