feat: make image preview support inline image protocol#1069
feat: make image preview support inline image protocol#1069
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Gates Failed
Enforce critical code health rules
(1 file with Bumpy Road Ahead)
Gates Passed
2 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Enforce critical code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| image_preview.go | 1 critical rule | 9.10 → 8.85 | Suppress |
Quality Gate Profile: The Bare Minimum
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
| // ImagePreview generates a preview of an image file | ||
| func (p *ImagePreviewer) ImagePreview(path string, maxWidth int, maxHeight int, | ||
| defaultBGColor string, sideAreaWidth int) (string, error) { | ||
| defaultBGColor string, sideAreaWidth int) (string, error, ImageRenderer) { |
There was a problem hiding this comment.
❌ New issue: Bumpy Road Ahead
ImagePreview has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function
| func (p *ImagePreviewer) ClearAllImages() string { | ||
| var result strings.Builder | ||
|
|
||
| // Clear Kitty protocol images if supported | ||
| if p.IsKittyCapable() { | ||
| if clearCmd := p.ClearKittyImages(); clearCmd != "" { | ||
| result.WriteString(clearCmd) | ||
| } | ||
| } | ||
|
|
||
| // Clear inline protocol images if supported | ||
| if p.IsInlineCapable() { | ||
| if clearCmd := p.ClearInlineImage(); clearCmd != "" { | ||
| result.WriteString(clearCmd) | ||
| } | ||
| } | ||
|
|
||
| return result.String() | ||
| } |
There was a problem hiding this comment.
❌ New issue: Bumpy Road Ahead
ClearAllImages has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function
src/pkg/file_preview/inline.go
Outdated
| return "" // No need to clear if terminal doesn't support inline protocol | ||
| } | ||
|
|
||
| return strings.Repeat(" ", 9999) |
There was a problem hiding this comment.
Let's precompute this. Store it in a predefined variable InlineImageCleanupString or something. Will save a bit of processing, and will make code more readable.
|
The current issue is that the inline image protocol doesn’t seem to support removing images, so we need to handle this through bubbletea instead. However, during this process, I found that bubbletea recognizes an image as a single line of text, which prevents the subsequent content from being re-rendered. So I used this workaround to handle the issue, but it’s admittedly a bit of a hack. I’m still considering whether there’s a cleaner solution, or if it might be better to simply force bubbletea to re-render. |
|
I see. I will try to take a stab at the issue if possible. |
8da7a7f to
1790cd4
Compare
Deploying superfile with
|
| Latest commit: |
aa49bd6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5238a227.superfile.pages.dev |
| Branch Preview URL: | https://feat-inline-image-protocol.superfile.pages.dev |
|
Rebased |
4c41607 to
fea4eee
Compare
|
in kitty we added Cursor now moves back to start. and bubblea fills everything with empty bg character. But, since kitty is not inline, its image is not affected. For inline, its not simple. Moving cursor back to start will overwrite everything. |
|
We will use |
|
|
The code of image preview is not very modular. Need to create a common interface. May use same pattern as we have in thumbnail generators. We need to pass the style info to ANSI/Kitty/Inilne renderers and have them pass the final block, without us doing any thing else. |
|
Currently, it's working very well, with no aspect ratio issues and images rendering correctly. The only problem is that old images sometimes freeze and aren't cleared. |
|
@yorukot Yes, Images don't get cleared 2026-01-13.23-30-52.mov |














No description provided.