bookokrat icon indicating copy to clipboard operation
bookokrat copied to clipboard

issue with tmux

Open PepeRoConde opened this issue 7 months ago • 4 comments

if i open a pdf file with your app on a tmux pane, and in another pane i open another... it breaks. it can only stay one open at the time. even more, if in the pane A i open the file foo, and in the pane B i open bar, if i switch to pane A, i see bar's content!

PepeRoConde avatar Apr 19 '26 04:04 PepeRoConde

@PepeRoConde hi! Which terminal are you running this in ? In kitty terminal i don't have issues with tmux and 2 bookokrats. but in ghostty i do observe the same issue as you describe.

bugzmanov avatar Apr 25 '26 21:04 bugzmanov

AI confirms:

 Smoking gun confirmed.

  src/terminal/kitty/graphics_storage.zig:416 in Ghostty main:

  if (entry.key_ptr.image_id >= v.first or entry.key_ptr.image_id <= v.last) {

  That's or where it should be and. The intent is "id ∈ [first, last]" (since first <= last is enforced two lines above). With or, the predicate is true for
  every u32 — so every d=R/d=r deletes all placements on the surface, not just the requested range.

  This perfectly explains everything you're seeing:

  - We send d=R,x=base_B+1,y=base_B+258047 thinking it's scoped to Process B's namespace.
  - Ghostty's buggy or turns it into "delete everything on the surface".
  - In native Ghostty splits, each pane is its own surface, so a delete only kills the calling pane's images. Invisible bug.
  - In tmux, all panes share one surface, so Process B's range-delete (probe, cache-window shrink, mode switch, shutdown — anything that calls
  delete_all_images or delete_images_by_range) wipes Process A's images too. Process A then gets ENOENT and re-uploads, and the dance continues.
  - Kitty's reference implementation has the correct and, which is why your A/B test came out clean there.

  Origin: introduced in PR #5957 (the "fix" for issue #5937, merged Feb 24, 2025). Nobody has filed the typo since — search came back empty.

bugzmanov avatar Apr 25 '26 21:04 bugzmanov

Opened ghostty discussion: https://github.com/ghostty-org/ghostty/discussions/12472

bugzmanov avatar Apr 26 '26 09:04 bugzmanov

@bugzmanov thanks for your time! we'll hope the ghostty community brings some ligth. I shall leave the issue open while this isn't solved, as a reminder.

PepeRoConde avatar Apr 26 '26 13:04 PepeRoConde