Due to a combo of fish and vscode shell integration scripts for fish, any terminal where antigravity has “injected” a cd when the llm passes a differend cwd param, will cause a complete deadlock of the pty instance.
The issue lies in the vscode shell integration script not properly emitting the esc sequences in the correct order.
Ive fixed the shell integration script, and also taken the time to de-bloat the microsoft/vscode one. It solves all issues and the terminals now behave as expected.
Fix:
# ---------------------------------------------------------------------------------------------
# VS Code shell integration for fish
# ---------------------------------------------------------------------------------------------
status is-interactive
and string match --quiet "$TERM_PROGRAM" "vscode"
and ! set --query VSCODE_SHELL_INTEGRATION
or exit
set -g VSCODE_SHELL_INTEGRATION 1
if set -q VSCODE_PATH_PREFIX
set -gx PATH "$VSCODE_PATH_PREFIX$PATH"
set -e VSCODE_PATH_PREFIX
end
if test -n "$VSCODE_ENV_REPLACE"
for B in (string split : $VSCODE_ENV_REPLACE)
set -l split (string split -m1 = $B)
set -gx "$split[1]" (echo -e "$split[2]")
end
set -e VSCODE_ENV_REPLACE
end
if test -n "$VSCODE_ENV_PREPEND"
for B in (string split : $VSCODE_ENV_PREPEND)
set -l split (string split -m1 = $B)
set -gx "$split[1]" (echo -e "$split[2]")"$$split[1]"
end
set -e VSCODE_ENV_PREPEND
end
if test -n "$VSCODE_ENV_APPEND"
for B in (string split : $VSCODE_ENV_APPEND)
set -l split (string split -m1 = $B)
set -gx "$split[1]" "$$split[1]"(echo -e "$split[2]")
end
set -e VSCODE_ENV_APPEND
end
# Python virtual environment activation
if not set -q VSCODE_PYTHON_AUTOACTIVATE_GUARD
set -gx VSCODE_PYTHON_AUTOACTIVATE_GUARD 1
if test -n "$VSCODE_PYTHON_FISH_ACTIVATE"
eval $VSCODE_PYTHON_FISH_ACTIVATE
end
end
# Store nonce for command verification
if set -q VSCODE_NONCE
set -g __vsc_nonce $VSCODE_NONCE
set -e VSCODE_NONCE
end
# --- cd override ---
# Fixes the deadlock from the cd ran by AG when llm runs a command with a cwd
# not matching the current pwd of the shell.
function cd --description "VS Code cd override"
# Silently change directory
builtin cd $argv > /dev/null 2>&1
set -l cd_status $status
# Report the new working directory and signal command completion
# To make sure theres no deadlocks
__vsc_esc P Cwd=(__vsc_escape_value "$PWD")
__vsc_esc D $cd_status
__vsc_esc A
__vsc_esc B
# Flush the PTY
commandline -f repaint 2>/dev/null
end
# --- 633 escape sequence helpers ---
function __vsc_esc
builtin printf "\e]633;%s\a" (string join ";" -- $argv)
end
function __vsc_escape_value
echo $argv \
| string replace --all '\\' '\\\\' \
| string replace --all ';' '\\x3b'
end
# --- Command lifecycle hooks ---
# Preexec: report the command and mark output start
function __vsc_preexec --on-event fish_preexec
__vsc_esc E (__vsc_escape_value "$argv") $__vsc_nonce
__vsc_esc C
end
# Posteexec: report exit status and signal ready
function __vsc_postexec --on-event fish_postexec
set -g __vsc_last_status $status
__vsc_esc D $__vsc_last_status
__vsc_esc A
__vsc_esc B
end
# Save the original prompt
functions --copy fish_prompt __vsc_original_prompt
function fish_prompt
__vsc_esc A # prompt start
__vsc_esc P Cwd=(__vsc_escape_value "$PWD") # report working directory
__vsc_original_prompt # render the user's prompt
__vsc_esc B # ready for input
end
__vsc_esc P HasRichCommandDetection=True
Edit: Fixed the broken codeblock..