Skip to content

feat: long file scrollable & pdf view#1381

Open
RenzoMXD wants to merge 1 commit intoeigent-ai:mainfrom
RenzoMXD:feat-long-file-scrollable
Open

feat: long file scrollable & pdf view#1381
RenzoMXD wants to merge 1 commit intoeigent-ai:mainfrom
RenzoMXD:feat-long-file-scrollable

Conversation

@RenzoMXD
Copy link

@RenzoMXD RenzoMXD commented Feb 26, 2026

Related Issue

Closes #1374

Description

Long files (.md, .docx, etc.) in the Agent Folder view were not scrollable — content was clipped with no way to reach the rest of the document. This was caused by two CSS issues working together:

Additionally, PDF preview was broken (grey rectangle) because Electron does not include Chromium's built-in PDF viewer plugin — the <iframe src="data:application/pdf;base64,..."> approach cannot work in Electron.

Screenshorts

Previous:

Screencast.from.2026-02-26.15-54-24.webm

After:

Screencast.from.2026-02-26.16-09-11.webm

Testing Evidence (REQUIRED)

  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

Contribution Guidelines Acknowledgement

@RenzoMXD
Copy link
Author

@Wendong-Fan @Pakchoioioi Please review my PR. Thanks.

@4pmtong
Copy link
Collaborator

4pmtong commented Feb 27, 2026

Thanks @RenzoMXD for contribution, I'll review it ASAP.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Agent Folder preview usability by ensuring long document content can scroll and restores PDF preview in Electron by replacing the non-functional <iframe> approach with a react-pdf-based renderer.

Changes:

  • Adjust Folder preview layout/CSS to allow long files (e.g., markdown) to scroll instead of being clipped.
  • Replace PDF <iframe> preview with a new PdfViewer component built on react-pdf/PDF.js.
  • Add/update unit tests around long-file scrolling and mock PdfViewer in existing Folder tests to avoid jsdom incompatibilities.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/Folder/index.tsx Makes the file viewer area scrollable for non-HTML previews and swaps PDF rendering to PdfViewer.
src/components/Folder/PdfViewer.tsx Introduces a react-pdf viewer with worker configuration and responsive sizing.
src/components/ChatBox/MessageItem/MarkDown.tsx Removes overflow-hidden from .markdown-body to prevent clipping long markdown content.
test/unit/components/Folder/LongFileScroll.test.tsx Adds a regression test intended to protect long-file scrolling behavior.
test/unit/components/Folder/FileTree.test.tsx Mocks PdfViewer to prevent pdfjs-dist/jsdom environment issues during unit tests.
package.json Adds react-pdf dependency for PDF rendering support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RenzoMXD
Copy link
Author

RenzoMXD commented Mar 3, 2026

@4pmtong @a7m-1st Can you review my PR please? Thanks.

@RenzoMXD RenzoMXD requested a review from 4pmtong March 9, 2026 16:05
@RenzoMXD
Copy link
Author

@4pmtong @a7m-1st Please review my PR again.

@RenzoMXD
Copy link
Author

@4pmtong @a7m-1st Can you review my PR again?.

- Replace broken <iframe> PDF preview with a react-pdf PdfViewer component
  that renders pages lazily via IntersectionObserver, so large PDFs don't
  block the renderer process.  ResizeObserver for container width uses
  useRef + useEffect so it is always properly cleaned up on unmount.
  An onLoadError handler shows a friendly error message instead of a blank
  screen.  The component is React.lazy()-loaded so the ~464 kB pdfjs-dist
  bundle is only fetched when the user actually opens a PDF file.

- Fix long-file scrolling in the Agent Folder view: the outer content
  container now uses 'scrollbar overflow-y-auto' (not overflow-hidden),
  letting content grow naturally and trigger the scrollbar.  The inner
  wrapper carries h-full only for the HTML iframe case.  The markdown prose
  wrapper gets its own overflow-hidden so the global MarkDown component
  (used elsewhere) is not affected.

- Replace scrollbar-always-visible with scrollbar in the Folder content
  container so the scrollbar follows the project-wide hover-to-show
  behaviour and does not look odd on macOS overlay-scrollbar systems.

- Rewrite LongFileScroll tests: the previous tests hardcoded their own
  JSX that never contained the production classes being checked, so they
  always passed regardless of regressions.  The new tests mirror the exact
  className expressions from Folder/index.tsx so any future regression
  breaks them.  FileTree mock comment updated to reflect lazy-loading.

Closes eigent-ai#1374
@RenzoMXD RenzoMXD force-pushed the feat-long-file-scrollable branch from 0a48349 to 7deb579 Compare March 18, 2026 18:26
@RenzoMXD RenzoMXD requested a review from 4pmtong March 18, 2026 18:29
@RenzoMXD
Copy link
Author

@4pmtong I've fixed code based on your suggestions. Please take an another look on this. Thanks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Long files in Agent Folder are not scrollable

3 participants