diff --git a/scripts/Oi b/scripts/Oi index 2f49b70..4b99339 100644 --- a/scripts/Oi +++ b/scripts/Oi @@ -85,9 +85,10 @@ else fi # Wait for agent to finish, then print response -while [ "$(cat "$NAV_PATH/statewait")" = "idle" ]; do :; done -while [ "$(cat "$NAV_PATH/statewait")" != "idle" ]; do :; done +waitstate() { cat "$NAV_PATH/statewait" 2>/dev/null || { ollie-remount && cat "$NAV_PATH/statewait"; } || die "mount lost"; } +while [ "$(waitstate)" = "idle" ]; do :; done +while [ "$(waitstate)" != "idle" ]; do :; done sleep 0.1 -offset=$(cat "$NAV_PATH/offset") -tail -c +$((offset + 1)) "$NAV_PATH/chat" +offset=$(try cat "$NAV_PATH/offset") || die "cannot read offset" +try tail -c +$((offset + 1)) "$NAV_PATH/chat" printf '\n%s\n' "$NAV_NAME" diff --git a/scripts/Wtf b/scripts/Wtf index a2e10ac..2525f67 100755 --- a/scripts/Wtf +++ b/scripts/Wtf @@ -79,8 +79,9 @@ fi printf '%b' "$context\n\nWhat does this code do?" | try tee "$NAV_PATH/prompt" >/dev/null # Wait for agent to finish, then print response -while [ "$(cat "$NAV_PATH/statewait")" = "idle" ]; do :; done -while [ "$(cat "$NAV_PATH/statewait")" != "idle" ]; do :; done +waitstate() { cat "$NAV_PATH/statewait" 2>/dev/null || { ollie-remount && cat "$NAV_PATH/statewait"; } || die "mount lost"; } +while [ "$(waitstate)" = "idle" ]; do :; done +while [ "$(waitstate)" != "idle" ]; do :; done sleep 0.1 offset=$(cat "$NAV_PATH/offset") tail -c +$((offset + 1)) "$NAV_PATH/chat"