Add support for previewing images in room scrollback #431

Closed
opened 2025-10-14 15:48:52 -06:00 by navan · 0 comments
Owner

Originally created by @benjajaja on 5/20/2023

An image says more than a thousand words:
image

There has been some work to get some small change into ratatui that allows for "skipping" of rendering some cells (characters). This in turn allowed to make a crate ratatui-image that provides a image widgets for ratatui, taking care of the terminal's graphics protocol automatically. Currently the supported "protocols" are sixels, kitty, and unicode-halfblocks. iTerm2's protocol should be easy to add, I just don't have access to a mac.

This PR uses ratatui-image widget's render() method to render images in the ScrollBack widget, in the chat lines. This seems hacky, but this kind of usage was actually intended and recommended for these kind of use cases in the discussion on the ratatui PR.

Currently, the download and image processing happens in one spawned tokio task per attachment. I also have a branch where only one "worker" is created, but I don't actually know if that is an actual improvement. I mainly made that branch/version to learn a bit more about tokio/tasks/threads in rust.

*Originally created by @benjajaja on 5/20/2023* An image says more than a thousand words: ![image](https://github.com/ulyssa/iamb/assets/310215/2d2b352c-429d-44b7-9983-86da932b0741) There has been some work to get some small change into ratatui that allows for "skipping" of rendering some cells (characters). This in turn allowed to make a crate [ratatui-image](https://github.com/benjajaja/ratatui-image) that provides a image widgets for ratatui, taking care of the terminal's graphics protocol automatically. Currently the supported "protocols" are sixels, kitty, and unicode-halfblocks. iTerm2's protocol should be easy to add, I just don't have access to a mac. This PR uses ratatui-image widget's `render()` method to render images in the `ScrollBack` widget, in the chat lines. This seems hacky, but this kind of usage was actually intended and recommended for these kind of use cases in the discussion on the ratatui PR. Currently, the download and image processing happens in one spawned tokio task per attachment. I also have a branch where only one "worker" is created, but I don't actually know if that is an actual improvement. I mainly made that branch/version to learn a bit more about tokio/tasks/threads in rust.
navan closed this issue 2025-10-14 15:48:53 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/iamb#431
No description provided.