Skip to content

terminal/kitty: abort incomplete graphics loads - #13893

Merged
mitchellh merged 1 commit into
mainfrom
kitty-loading-delete
Aug 18, 2026
Merged

mitchellh merged 1 commit into
mainfrom
kitty-loading-delete

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

Previously, delete left partial bytes alive for the next upload, while failed or incomplete retransmissions kept stale placements visible.

Abort incomplete chunked image uploads on delete commands and remove an existing image and its placements when retransmission of an explicit ID begins.

Previously, delete left partial bytes alive for the next upload, while
failed or incomplete retransmissions kept stale placements visible.

Abort incomplete chunked image uploads on delete commands and remove an
existing image and its placements when retransmission of an explicit ID
begins.
@mitchellh mitchellh added this to the 1.4.0 milestone Aug 18, 2026
@mitchellh
mitchellh requested a review from a team as a code owner August 18, 2026 17:57
@mitchellh

Copy link
Copy Markdown
Contributor Author

Verification:

#!/bin/sh
set -eu

# Run this directly inside Kitty or Ghostty (not through tmux/screen).
# It uses 1x1 RGB pixels scaled to visible cell rectangles.

id_abort=8008
id_fresh=8009
id_replace=8010

kgp() {
    printf '\033_G%s\033\\' "$1"
}

delete_id() {
    kgp "a=d,d=I,i=$1,q=2"
}

cleanup() {
    delete_id "$id_abort"
    delete_id "$id_fresh"
    delete_id "$id_replace"
}

pause() {
    printf '\nPress Return to continue... '
    IFS= read -r _
}

move_to() {
    printf '\033[%s;%sH' "$1" "$2"
}

clear_below() {
    move_to "$1" 1
    printf '\033[J'
}

trap cleanup EXIT HUP INT TERM
cleanup
printf '\033[2J\033[H'

printf '%s\n' 'KGP-08 test 1: a delete aborts an incomplete upload.'
printf '%s\n\n' 'Expected: a GREEN rectangle appears below.'
move_to 4 1

# Begin a complete red pixel but claim another chunk is coming. The image is
# not displayed. Any delete command must discard this partial upload.
kgp "a=t,f=24,s=1,v=1,i=$id_abort,m=1,q=2;/wAA"
kgp 'a=d,q=2'

# A fresh two-command upload should now work and display a green pixel scaled
# to 12 columns by 2 rows. The last chunk is intentionally empty.
kgp "a=T,f=24,s=1,v=1,i=$id_fresh,c=12,r=2,C=1,m=1,q=2;AP8A"
kgp 'm=0,q=2;'
clear_below 7
printf '%s\n' 'PASS if the green rectangle is visible; FAIL if this area stayed blank.'
pause

cleanup
printf '\033[2J\033[H'
printf '%s\n' 'KGP-08 test 2: retransmission invalidates the old placement immediately.'
printf '%s\n\n' 'A RED rectangle should initially be visible below.'
move_to 4 1

# Display the old red image and keep the cursor outside its rectangle.
kgp "a=T,f=24,s=1,v=1,i=$id_replace,c=12,r=2,C=1,q=2;/wAA"
clear_below 7
printf '%s\n' 'Confirm the red rectangle is visible.'
pause

# Start, but do not finish, a green replacement using the same explicit ID.
# The old red placement must disappear as soon as this first chunk arrives.
kgp "a=t,f=24,s=1,v=1,i=$id_replace,m=1,q=2;AP8A"
clear_below 7
printf '%s\n' 'PASS if the red rectangle vanished; FAIL if it is still visible.'
printf '%s\n' 'The replacement is incomplete, so no green rectangle should appear yet.'
pause

# Complete the transmit-only replacement, then place it to prove it loaded.
kgp 'm=0,q=2;'
move_to 4 1
kgp "a=p,i=$id_replace,c=12,r=2,C=1,q=2"
clear_below 7
printf '%s\n' 'The replacement is complete. A GREEN rectangle should be visible.'
printf '%s\n' 'Done. Both terminals should show the same three PASS states.'
pause

@mitchellh
mitchellh merged commit 55dac8f into main Aug 18, 2026
115 checks passed
@mitchellh
mitchellh deleted the kitty-loading-delete branch August 18, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant