feat(app): image preview in file tabs#218
Closed
shuv1337 wants to merge 4 commits intofix/file-viewer-add-img-supportfrom
Closed
feat(app): image preview in file tabs#218shuv1337 wants to merge 4 commits intofix/file-viewer-add-img-supportfrom
shuv1337 wants to merge 4 commits intofix/file-viewer-add-img-supportfrom
Conversation
packages/app/src/pages/session.tsx
Outdated
| ) | ||
| const path = tab.startsWith("file://") ? tab.replace("file://", "") : undefined | ||
| // Trigger the file load | ||
| if (path) local.file.init(path) |
There was a problem hiding this comment.
style: redundant call to init() - FileTabContent already calls local.file.node() which internally calls init()
Suggested change
| if (path) local.file.init(path) | |
| // File will be loaded by FileTabContent's createResource |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app/src/pages/session.tsx
Line: 946:946
Comment:
**style:** redundant call to `init()` - `FileTabContent` already calls `local.file.node()` which internally calls `init()`
```suggestion
// File will be loaded by FileTabContent's createResource
```
How can I resolve this? If you propose a fix, please make it concise.| if (parent) { | ||
| await list(parent) | ||
| } | ||
| await list(parent) |
There was a problem hiding this comment.
style: verify list("") handles empty path correctly for root-level files
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app/src/context/local.tsx
Line: 367:367
Comment:
**style:** verify `list("")` handles empty path correctly for root-level files
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
list()for parent directory in file fetch (removes unnecessary conditional)Changes
packages/app/src/context/local.tsx: Remove conditional check beforelist(parent)packages/app/src/pages/session.tsx: NewFileTabContentcomponent for rendering images and code with SVG toggleProof
Before:
Before.mp4
After:
After.mp4
Greptile Summary
Added image preview functionality to file tabs with special handling for SVG files. Users can now view images directly in tabs, and SVG files get a toggle to switch between rendered preview and source code view.
FileTabContentcomponent detects base64-encoded images by mimeType and renders them with proper stylinglist(parent)regardless of parent pathFileTabContentcomponent for better separation of concernsMinor optimization opportunity: redundant
local.file.init()call on line 946 sinceFileTabContentalready handles initialization throughlocal.file.node().Confidence Score: 4/5
Important Files Changed
list(parent)- now always calls even when parent is empty stringFileTabContentcomponent with image preview and SVG toggle functionality, refactored tab content renderingSequence Diagram
sequenceDiagram participant User participant FileTabContent participant LocalContext participant SDK User->>FileTabContent: Opens file tab FileTabContent->>LocalContext: createResource(() => local.file.node(path)) LocalContext->>LocalContext: init(path) LocalContext->>LocalContext: fetch(path) LocalContext->>LocalContext: Calculate parent directory LocalContext->>SDK: list(parent + "/") SDK-->>LocalContext: Return parent directory contents LocalContext->>SDK: read file content SDK-->>LocalContext: Return file with content & mimeType LocalContext-->>FileTabContent: Return file node alt Image file (base64 encoded) alt SVG file FileTabContent->>User: Show image with "View code" toggle User->>FileTabContent: Click "View code" FileTabContent->>FileTabContent: setShowCode(true) FileTabContent->>User: Show decoded SVG source with "View image" toggle else Non-SVG image FileTabContent->>User: Show image preview end else Text file FileTabContent->>User: Show code editor end