fix: copy images to agent_working_dir when set (#1752)

* fix: copy images to agent_working_dir when set

When agent_working_dir is configured, copy images to
<workspace>/<agent_working_dir>/.vibe-images/ instead of
<workspace>/.vibe-images/ so that relative paths work
correctly for the AI agent.

Closes #1727

Signed-off-by: majiayu000 <1835304752@qq.com>

* optionally append agent working directory in other image routes

---------

Signed-off-by: majiayu000 <1835304752@qq.com>
Co-authored-by: Gabriel Gordon-Hall <ggordonhall@gmail.com>
This commit is contained in:
lif
2026-01-08 20:14:02 +08:00
committed by GitHub
parent cefb4fb0a2
commit dcaa8b8769
3 changed files with 28 additions and 6 deletions

View File

@@ -166,9 +166,16 @@ impl ImageService {
&self,
worktree_path: &Path,
task_id: Uuid,
agent_working_dir: Option<&str>,
) -> Result<(), ImageError> {
let images = Image::find_by_task_id(&self.pool, task_id).await?;
self.copy_images(worktree_path, images)
// When agent_working_dir is set, copy images to that subdirectory
// so relative paths like .vibe-images/xxx.png work correctly
let target_path = match agent_working_dir {
Some(dir) if !dir.is_empty() => worktree_path.join(dir),
_ => worktree_path.to_path_buf(),
};
self.copy_images(&target_path, images)
}
pub async fn copy_images_by_ids_to_worktree(