-
Notifications
You must be signed in to change notification settings - Fork 839
improvement: add file limit, warning, and more performant file detection #7368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Breaking changes detected in the OpenAPI specification! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances workspace file scanning with performance optimizations and user experience improvements. It addresses issue #7317 by implementing a file limit (1000 files), displaying a warning when the limit is exceeded, and optimizing file detection to read only the first 512 bytes of files for faster scanning.
Key Changes
- Added MAX_FILES constant (1000) to limit workspace file scanning and prevent performance degradation in large workspaces
- Implemented header-based file detection that reads only the first 512 bytes for most files, with full file reading only for Python files containing PEP 723 script headers
- Added
hasMoreandfileCountfields to WorkspaceFilesResponse to communicate limit status to the frontend - Introduced async file scanning using
asyncio.to_thread()to prevent blocking the server during workspace scans
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| marimo/_server/file_router.py | Core changes: extracted is_marimo_app() function with optimized header-based detection, added count_files() helper, implemented MAX_FILES limit enforcement with file counting and early termination, expanded skip_dirs set with additional common directories |
| marimo/_server/models/home.py | Added has_more and file_count fields to WorkspaceFilesResponse model with default values |
| marimo/_server/api/endpoints/home.py | Updated workspace_files endpoint to use async file scanning, calculate file count, and populate new response fields |
| marimo/_utils/marimo_path.py | Added read_bytes() method to MarimoPath for binary file reading |
| frontend/src/components/pages/home-page.tsx | Added warning banner that displays when file limit is reached |
| packages/openapi/api.yaml | Updated WorkspaceFilesResponse schema with new fileCount and hasMore fields |
| packages/openapi/src/api.ts | Updated TypeScript interfaces to reflect API schema changes |
| tests/_utils/test_marimo_path.py | Added test coverage for new read_bytes() method |
| tests/_server/test_file_router.py | Added comprehensive tests for is_marimo_app() function, MAX_FILES enforcement, skip_dirs behavior, and count_files() helper |
| tests/_server/api/endpoints/test_home.py | Added assertions to verify new response fields are present and correct |
| pixi.lock | Version bump from 0.18.0 to 0.18.1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #7317
500bheader