Audit/simplify dead code#14
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93d572df44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (file.size > checksumLimit) { | ||
| return undefined; |
There was a problem hiding this comment.
Preserve checksum verification for large uploads
For uploads larger than the checksum limit (20 MiB with the default 10 MiB chunks), this returns undefined, so uploadChunk omits the final X-Checksum header and the backend skips its only content-integrity check because assembleChunks verifies checksums only when a value is provided. Large uploads can therefore be assembled and accepted without detecting a corrupted/mismatched chunk, regressing the documented chunked-upload checksum verification path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR removes deprecated frontend/demo surface area, centralizes a few configuration/constants, and tightens upload/session validation in the Go backend while refreshing project/docs metadata to match the current codebase.
Changes:
- Removed legacy/demo UI routes/components and updated docs/context to reflect their removal.
- Improved backend streaming upload validation (max upload size enforcement, chunk-size/body validation, session metadata mismatch handling).
- Added local wallpaper persistence + “saving” UX improvements (progress button, local IndexedDB wallpaper storage, richer file-type handling).
Reviewed changes
Copilot reviewed 57 out of 57 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/styles/global.css | Removes unused feature-card hover styling. |
| website/src/lib/docs.ts | Simplifies docs nav metadata handling. |
| website/src/layouts/DocsLayout.astro | Removes unused icon import. |
| website/src/components/FeaturesBento.astro | Removes unused icon import. |
| website/src/components/FeatureCard.astro | Deletes unused website component. |
| website/src/components/AppInterfaceDemo.astro | Scroll animation update for the website demo UI. |
| scripts/local-test.ts | Simplifies port selection logic by removing ss-based check. |
| PROJECT_CONTEXT.md | Updates project context to remove stale frontend references. |
| frontend/src/routes/test/+page.svelte | Deletes deprecated /test demo route. |
| frontend/src/routes/settings/+page.svelte | Adds save progress UX + local wallpaper persistence/cleanup logic. |
| frontend/src/routes/browse/+page.svelte | Updates Sidebar props and enables hidden-path suggestions in Toolbar. |
| frontend/src/routes/+layout.svelte | Removes /test from public routes and switches to resolved wallpaper URL store. |
| frontend/src/lib/utils/wallpaperStorage.ts | New IndexedDB-backed local wallpaper storage utilities. |
| frontend/src/lib/utils/wallpaper.ts | Adds progress reporting to readFileAsDataUrl. |
| frontend/src/lib/utils/upload.ts | Limits checksum calculation for large files and removes UploadManager. |
| frontend/src/lib/utils/fileTypes.ts | Improves dotfile/special-filename detection, icons, and Monaco language mapping. |
| frontend/src/lib/stores/websocket.ts | Moves websocket backoff/ping timings into CONFIG. |
| frontend/src/lib/stores/settings.ts | Adds local wallpaper migration + derived resolved wallpaper URL store. |
| frontend/src/lib/stores/jobs.ts | Removes unused store helpers/exports. |
| frontend/src/lib/stores/files.ts | Removes unused query/selection helpers and uses CONFIG for default page size. |
| frontend/src/lib/components/UploadDropzone.svelte | Deletes unused upload dropzone component. |
| frontend/src/lib/components/ui/Toast.svelte | Refactors icon rendering and adjusts layout classes. |
| frontend/src/lib/components/ui/Select.svelte | Adds chevron icon + wrapper for custom select styling. |
| frontend/src/lib/components/ui/ProgressButton.svelte | New button component supporting busy/progress states. |
| frontend/src/lib/components/ui/index.ts | Exports ProgressButton; removes Card export. |
| frontend/src/lib/components/ui/ContextMenu.svelte | Minor cleanup/formatting and event handler formatting. |
| frontend/src/lib/components/ui/Card.svelte | Deletes unused Card component. |
| frontend/src/lib/components/Toolbar.svelte | Adds editable path input + folder suggestion/autocomplete logic. |
| frontend/src/lib/components/Sidebar.svelte | Removes unused roots prop/type import. |
| frontend/src/lib/components/settings/wallpaper/WallpaperSettings.svelte | Uses normalized background checks and passes frostedGlass into modal. |
| frontend/src/lib/components/settings/wallpaper/WallpaperPickerModal.svelte | Adds local wallpaper upload progress UI and frosted-glass preview styling. |
| frontend/src/lib/components/settings/SettingsSection.svelte | Deletes unused settings section component. |
| frontend/src/lib/components/settings/SettingsRow.svelte | Deletes unused settings row component. |
| frontend/src/lib/components/settings/index.ts | Deletes unused settings barrel exports. |
| frontend/src/lib/components/preview/VideoPreview.svelte | Adds accessible label/title including optional file size. |
| frontend/src/lib/components/preview/OfficePreview.svelte | Adds lint suppression for required DOM manipulation; optimizes sheet header loop. |
| frontend/src/lib/components/preview/CodePreview.svelte | Improves Monaco typing and model-language update safety. |
| frontend/src/lib/components/PicoLogo.svelte | Deletes unused branding component. |
| frontend/src/lib/components/JobMonitor.svelte | Deletes unused job monitor component. |
| frontend/src/lib/components/DriveCard.svelte | Deletes unused drive card component. |
| frontend/src/lib/components/Breadcrumb.svelte | Deletes unused breadcrumb component. |
| backend/internal/service/job.go | Removes unused fields; uses config constants for workers/queue sizing. |
| backend/internal/service/auth.go | Removes unused credentials struct; uses config constants for token expiries. |
| backend/internal/pkg/validator/path.go | Removes unused helpers; formatting/cleanup. |
| backend/internal/pkg/filesystem/fs.go | Removes unused constructors/helpers and copy helpers. |
| backend/internal/model/job.go | Removes unused JobError struct. |
| backend/internal/model/error.go | Removes unused ErrorResponse helper constructors. |
| backend/internal/model/config.go | Removes unused default config/helpers. |
| backend/internal/middleware/auth.go | Removes unused context helper. |
| backend/internal/handler/stream.go | Enforces max upload size, validates chunk/body sizes, checks session metadata match. |
| backend/internal/handler/stream_property_test.go | Adds tests for new upload validation and fixes chunk-count logic. |
| backend/internal/handler/response.go | Uses canonical model.ErrorResponse and removes redundant helpers. |
| backend/internal/handler/file.go | Centralizes filename validation via validator.IsValidFileName. |
| backend/internal/handler/errors.go | Removes deprecated HandleServiceErrorWithLog. |
| backend/internal/config/constants.go | Adds DefaultMaxUploadMB constant. |
| backend/internal/config/config.go | Uses DefaultMaxUploadMB in config defaults. |
| backend/cmd/server/main.go | Simplifies init/shutdown wiring; uses config constants for worker count and shutdown timeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let page = 1; | ||
| let loadedCount = 0; | ||
| let totalCount = Number.POSITIVE_INFINITY; | ||
| const directories: Array<{ name: string }> = []; | ||
|
|
||
| while (loadedCount < totalCount) { | ||
| const response = await listDirectory(parentPath, { | ||
| page, | ||
| pageSize: suggestionPageSize, | ||
| sortBy: 'name', | ||
| sortDir: 'asc', | ||
| includeHidden: includeHiddenSuggestions || prefix.startsWith('.'), | ||
| filter: prefix || undefined | ||
| }); | ||
|
|
||
| directories.push(...response.items.filter((item) => item.isDir)); | ||
| loadedCount += response.items.length; | ||
| totalCount = response.totalCount; | ||
|
|
||
| if (response.items.length === 0) break; | ||
| page += 1; | ||
| } | ||
|
|
||
| return filterSuggestions(directories, parentPath, prefix); |
| let suggestionTimer: ReturnType<typeof setTimeout> | undefined; | ||
| let blurTimer: ReturnType<typeof setTimeout> | undefined; | ||
| let suggestionRequestId = 0; |
| aria-label="Location" | ||
| aria-autocomplete="list" | ||
| /> |
| export async function calculateChecksumStreaming( | ||
| file: File, | ||
| chunkSize: number = DEFAULT_CHUNK_SIZE | ||
| ): Promise<string> { | ||
| // For smaller files, use the simple method | ||
| if (file.size <= chunkSize * 2) { | ||
| return calculateChecksum(file); | ||
| ): Promise<string | undefined> { | ||
| const checksumLimit = Math.max(chunkSize * 2, MAX_CHECKSUM_BYTES); | ||
| if (file.size > checksumLimit) { |
| // Checksum is optional but required on final chunk for verification | ||
| checksum := r.Header.Get("X-Checksum") |
| - Design tokens are defined in `src/routes/layout.css`. | ||
| - `src/lib/components/ui/` exists with base components including `Button`, `Input`, `Select`, `Toggle`, `Card`, `Modal`, `Spinner`, `Badge`, `ProgressBar`, `ContextMenu`, `Toast`, and `InlineRename`. | ||
| - `src/lib/components/ui/` exists with base components including `Button`, `Input`, `Select`, `Toggle`, `Modal`, `Spinner`, `Badge`, `ProgressBar`, `ContextMenu`, `Toast`, and `InlineRename`. | ||
| - No `<style>` blocks were found under `frontend/src` during this audit. |
This pull request contains several updates to both backend and documentation, focusing on backend handler refactoring, improved upload validation, and project documentation cleanup. The most significant changes include stricter file upload and naming validation, removal of deprecated frontend references, and simplification of error handling in the backend.
Backend improvements and refactoring:
StreamHandlernow enforces the configured maximum upload size, validates chunk sizes, and returns appropriate HTTP status codes for oversized uploads or mismatched session metadata. This includes usinghttp.MaxBytesReaderto strictly limit chunk size and returning413 Request Entity Too Largewhere appropriate. [1] [2] [3]FileHandleris now delegated to a sharedvalidator.IsValidFileNamefunction, ensuring consistent and centralized checks.handler/response.go, with responses now using the canonical struct frommodel. [1] [2]HandleServiceErrorWithLogfunction is removed from the backend error handler.Frontend and documentation cleanup:
/testdemo route and its components are removed from the project context documentation, reflecting its deletion from the codebase. [1] [2] [3] [4]UploadManagerhelper class is removed, and documentation is updated to clarify that upload queue management is now handled inupload.svelte.ts. [1] [2]These changes collectively improve backend robustness and maintainability, while ensuring the documentation accurately describes the current state of the project.