From 16388963efd77497a6ecde8582c50a2e5fb02649 Mon Sep 17 00:00:00 2001 From: ai-anant Date: Fri, 28 Aug 2026 08:06:09 +0530 Subject: [PATCH] fix: rewrite in-container /workspace to host path in synced transcripts Agent tools (claude, codex, etc.) record absolute paths from inside the container where the repo is bind-mounted at /workspace. sync-sessions copied those transcripts verbatim, leaving host logs full of /workspace/... paths that do not exist on the host OS. Rewrite the in-container mount root to the real host workspace path in synced .jsonl/.json transcripts so the logs reference paths that actually exist. Closes #22 --- lib/aidc.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/aidc.sh b/lib/aidc.sh index c526fd5..e98cf37 100644 --- a/lib/aidc.sh +++ b/lib/aidc.sh @@ -838,6 +838,20 @@ aidc::sync_session_tool() { mkdir -p "$host_dst" aidc::compose "$workspace" exec -T workspace tar -C "$container_src" -cf - . \ | tar -C "$host_dst" --no-same-owner --no-same-permissions -xf - + + # Agent transcripts record absolute paths from inside the container, where + # the repo is bind-mounted at /workspace (see compose.yaml.tmpl). Copying + # them verbatim leaves `/workspace/...` paths that do not exist on the host. + # Rewrite that in-container mount root to the real host workspace path so the + # synced logs/transcripts reference paths that actually exist in the OS. + if [[ -n "$workspace" && "$workspace" != "/workspace" ]]; then + local esc_ws f + esc_ws="$(printf '%s' "$workspace" | sed 's/[&|\\]/\\&/g')" + while IFS= read -r f; do + { sed "s|/workspace|${esc_ws}|g" "$f" > "$f.aidc-tmp" && mv "$f.aidc-tmp" "$f"; } \ + || rm -f "$f.aidc-tmp" + done < <(find "$host_dst" -type f \( -name '*.jsonl' -o -name '*.json' \) 2>/dev/null) + fi aidc::log "synced $tool sessions to $host_dst" }