From 59c19cace9936ddb6d5bc483f0e562c15319064c Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 24 Aug 2026 15:29:55 +0200 Subject: [PATCH] acme-ollie-ensure: use PWD (acme sets it), tag fallback for HOME Confirmed acme calls threadspawnd with window dir. Added tag-based fallback when PWD is HOME (top-level window). --- data/scripts/acme/acme-ollie-ensure | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/data/scripts/acme/acme-ollie-ensure b/data/scripts/acme/acme-ollie-ensure index f1dc141..45c8ccc 100755 --- a/data/scripts/acme/acme-ollie-ensure +++ b/data/scripts/acme/acme-ollie-ensure @@ -9,21 +9,20 @@ set -euo pipefail -# Get cwd from the acme window's directory context -if [[ -n "${winid:-}" ]]; then - wname=$(9p read acme/$winid/tag | awk '{print $1}') +# Acme sets $PWD to the window's directory for executed commands. +# Fall back to tag parsing if $winid is set (e.g. for pipe commands). +cwd="$PWD" +if [[ -n "${winid:-}" ]] && [[ "$cwd" == "$HOME" || "$cwd" == "$HOME/" ]]; then + # PWD is $HOME — likely the top-level window. Try tag-based detection. + wname=$(9p read "acme/$winid/tag" | awk '{print $1}') if [[ -d "$wname" ]]; then cwd="$wname" elif [[ -f "$wname" ]]; then cwd=$(dirname "$wname") - else - cwd="$HOME" fi -else - cwd="$PWD" fi -# Discover project root: git worktree root > git root > cwd +# Discover project root: git worktree root > cwd project_root="$cwd" if wt_root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null); then project_root="$wt_root" @@ -37,9 +36,6 @@ AGENT="assistant" # Ensure session exists (with project root as cwd) if ! ollie-9p read "session/$SESSION/env" >/dev/null 2>&1; then printf 'name=%s\ncwd=%s\n' "$SESSION" "$project_root" | ollie-9p write "session/new" 2>/dev/null || true -else - # Update cwd in case project root changed - printf 'cwd=%s\n' "$project_root" | ollie-9p write "session/$SESSION/cfg" 2>/dev/null || true fi # Ensure agent exists