Skip to content

Codex CLI pet flickers on animation frame changes inside tmux in Ghostty #63705

Backlog

Description

@raghav-rama

What happens

The pet appears in /pets and animates, but visibly flickers when the image changes. The same pet animates smoothly when I run Codex directly in Ghostty. I need to keep using tmux.

Environment

  • macOS
  • Codex CLI 0.171.0
  • Ghostty 1.4.0
  • tmux 3.8

Steps to reproduce

  1. Open a fresh Ghostty tab and start an isolated tmux server with no user config:
    tmux -L pet-test -f /dev/null new-session
  2. Inside that session, run tmux set -g allow-passthrough all.
  3. Launch Codex with codex -c tui.fullscreen_transcript=true -c 'tui.alternate_screen="always"'.
  4. Open /pets, select a pet, and watch several animation frames.

Expected: The pet animates smoothly, as it does directly in Ghostty.

Actual: The pet flickers on frame changes. This reproduces both in my regular tmux session and in the isolated session above.

Additional context

My regular tmux client reports the sync terminal feature. Static images display successfully through tmux with Chafa. I haven’t isolated which component causes the animation flicker.

Activity

  1. added
    bug
    CLI
    TUI
    on Nov 24, 2026
  2. r266-tech commented on Nov 24, 2026

    @r266-tech

    I captured the outer PTY byte stream from tmux 3.8 with a two-frame probe modeled on the 0.171.0 pet renderer. The delete and replacement upload both reached the client outside synchronized output, even though the pane application wrapped the entire frame in DEC mode 2026. I saw the same ordering on two runs.

    The probe used a fresh tmux server, an attached PTY client with TERM=xterm-256color, terminal-features including sync:RGB, and allow-passthrough all. For each frame it sent a Kitty delete-by-ID and a virtual-placement PNG upload for the same ID via tmux passthrough, then wrote one Unicode placeholder through the pane. On the second frame the outer stream contained these events in order:

    byte 1169  synchronized output ends
    byte 1177  Kitty delete
    byte 1267  Kitty transmit
    byte 1475  synchronized output begins
    byte 1515  placeholder cell
    byte 1600  synchronized output ends
    

    That gives the terminal a window in which the old image has been removed before the replacement is available. The capture establishes the ordering. Whether Ghostty actually presents a blank frame in that window still needs a visual check. A focused A/B would upload the next frame under a second ID while the first remains visible, switch the placeholder to the new ID, and retire the old image after the switch reaches the client.

    Both the picker and ambient pet share this delete-before-upload path. 0.171.0 renderer · Virtual placement and placeholder writes

  3. akhil9tiet commented on Nov 24, 2026

    @akhil9tiet

    I'm interested in working on this — please assign it to me.

  4. akhil9tiet commented on Nov 24, 2026

    @akhil9tiet

    Root cause (verified against code at HEAD 5a2cb73):

    render_pet_image() in codex-rs/tui/src/pets/mod.rs deletes the previous Kitty image id and then transmits the new frame under the SAME id — a delete-before-upload sequence. Commenter r266-tech's outer-PTY probe on tmux 3.8 shows both the delete and the replacement upload landing outside DEC 2026 synchronized output, so the old image is removed before the replacement is available, which is the flicker window.

    Proposed fix: double-buffer the Kitty image id — upload each new frame under a fresh/alternate id, switch the placeholder to the new id, and only then delete the old id. The change should be localized to render_pet_image + PetImageRenderState.

    Note: there is no Rust toolchain on this VM, so I cannot build/test the fix here, and the blank-frame visual check is still pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLITUIbugpets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions