Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: Dimension validations#1224

Merged
lazysegtree merged 7 commits into
developyorukot/superfile:developfrom
dimension-validationsyorukot/superfile:dimension-validationsCopy head branch name to clipboard
Dec 22, 2025
Merged

feat: Dimension validations#1224
lazysegtree merged 7 commits into
developyorukot/superfile:developfrom
dimension-validationsyorukot/superfile:dimension-validationsCopy head branch name to clipboard

Conversation

@lazysegtree

@lazysegtree lazysegtree commented Dec 22, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added comprehensive layout and render validation to improve reliability and consistency.
  • Improvements

    • Optimized layout calculations and width computations for better UI rendering.
    • Enhanced debug logging and validation checks for improved stability.
    • Streamlined file preview rendering in the main panel.
  • Chores

    • Renamed internal UI constants for consistency.
    • Refactored validation logic and layout handling.
    • Enabled debug mode for enhanced diagnostics.

✏️ Tip: You can customize this high-level summary in your review settings.

- Resolved TODO: Added width validation checks
- Added search bar width validation (matches panel width minus padding)
- Added focus panel index validation (within valid range)
- Added overlay panel dimension validation (help menu, prompt modal)
- Added minimum dimension constants (MinMainWidth, MinMainHeight, MinFilePanelWidth)
- Validates width calculation consistency across all panels
- Validates preview panel dimensions when open
- Ensures all file panels have consistent dimensions
…t issues

- Add validateRender function to check ANSI-stripped output dimensions and borders
- Add validateComponentRender to validate all UI components rendering
- Account for sidebar border padding in width/height calculations
- Log validation errors for debugging without breaking functionality
@coderabbitai

coderabbitai Bot commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR refactors UI constants across filepanel and filemodel packages by renaming constants (FilePanelMinWidth → MinWidth, FilePanelMinHeight → MinHeight) and removing the exported MinWidthForRename from common constants. It updates model rendering logic to use the renamed constants, consolidates footer rendering, and adds comprehensive validation functions in a new validation.go module while removing old validation from type_utils.go.

Changes

Cohort / File(s) Summary
Constants Refactoring
src/internal/common/ui_consts.go, src/internal/ui/filepanel/consts.go, src/internal/ui/filemodel/consts.go
Removed exported MinWidthForRename constant from common UI constants; renamed filepanel constants (FilePanelMinWidthMinWidth, FilePanelMinHeightMinHeight, FilePanelContentPaddingContentPadding); updated filemodel constants to reference renamed filepanel constants with explanatory header comment.
File Panel Dimensions & Model
src/internal/ui/filepanel/dimension.go, src/internal/ui/filepanel/model.go, src/internal/ui/filemodel/dimensions.go
Updated dimension validation and calculations to use renamed constants (MinWidth, MinHeight, ContentPadding); changed MaxFilePanel calculation to use filepanel.MinWidth instead of FilePanelMinWidth.
Model Rendering Refactoring
src/internal/model.go, src/internal/model_render.go
Refactored View() method to switch threshold to filepanel.MinWidth, consolidate footer rendering, and add debug validation blocks; removed filePreviewPanelRender() method; introduced getClipboardWidth() helper function for clipboard width computation.
File Model Render Updates
src/internal/ui/filemodel/render.go
Increased allocated slice size from PanelCount() to PanelCount() + 1 and conditionally populate extra slot with file preview content when FilePreview is open.
Validation Refactoring
src/internal/type_utils.go, src/internal/validation.go
Removed validateLayout() method and related imports from type_utils.go; added comprehensive new internal validation module (validation.go) with functions for layout, render, component placement, and composite rendering validation including detailed error messages and constraint enforcement.
Configuration
src/superfile_config/config.toml
Changed Debug mode setting from false to true.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Refactored View() method in src/internal/model.go: Complex rendering logic changes with multiple debug validation blocks and consolidated footer handling require careful verification of control flow and layout calculations.
  • New comprehensive validation module (src/internal/validation.go): Dense logic with multiple validation functions, detailed error messages, and constraint enforcement logic that needs thorough review.
  • Constant renaming cascading effects: While repetitive, the widespread renaming of filepanel constants across multiple packages (filepanel, filemodel) requires verification that all references are updated consistently.
  • File preview rendering changes in src/internal/ui/filemodel/render.go: The shift from conditional preview rendering to slice allocation with conditional population requires understanding the new preview handling logic.
  • Removal of old validation from src/internal/type_utils.go: Verify that functionality removed from validateLayout() is properly replaced by new validation functions.

Possibly related PRs

Suggested reviewers

  • yorukot
  • codescene-delta-analysis

Poem

🐰 The constants dance with cleaner names,
MinWidth, MinHeight—no more rename games!
Validation blooms in fresh new code,
While previews render down the road.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Dimension validations' is directly related to the main change—adding comprehensive dimension and render validations throughout the codebase.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lazysegtree lazysegtree changed the title Dimension validations feat: Dimension validations Dec 22, 2025
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 22, 2025

Copy link
Copy Markdown

Deploying superfile with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1f504a6
Status: ✅  Deploy successful!
Preview URL: https://6ba189a3.superfile.pages.dev
Branch Preview URL: https://dimension-validations.superfile.pages.dev

View logs

@lazysegtree

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Dec 22, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/internal/model_render.go (1)

62-67: Consider adding a comment to explain the width adjustment logic.

The function adjusts the width when fullWidth is not divisible by 3, adding the remainder and BorderPadding. While this appears intentional for proper footer alignment, a brief comment explaining why this adjustment is necessary would improve code maintainability.

💡 Suggested comment
 func (m *model) getClipboardWidth() int {
 	if m.fullWidth%3 == 0 {
 		return utils.FooterWidth(m.fullWidth)
 	}
+	// Round up to nearest multiple of 3 and add border padding to ensure
+	// proper alignment with other footer components
 	return utils.FooterWidth(m.fullWidth + m.fullWidth%common.FooterGroupCols + common.BorderPadding)
 }
src/internal/validation.go (1)

284-290: Column range validation assumes uniform line widths.

Line 288 validates the column range against lines[0] width only. If lines have varying widths, this could produce false positives/negatives. Since validateRender already ensures all lines have consistent width, this should be fine in practice, but consider adding a comment to document this assumption.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 875a6a6 and 85ac7d2.

📒 Files selected for processing (12)
  • src/internal/common/ui_consts.go
  • src/internal/model.go
  • src/internal/model_render.go
  • src/internal/type_utils.go
  • src/internal/ui/filemodel/consts.go
  • src/internal/ui/filemodel/dimensions.go
  • src/internal/ui/filemodel/render.go
  • src/internal/ui/filepanel/consts.go
  • src/internal/ui/filepanel/dimension.go
  • src/internal/ui/filepanel/model.go
  • src/internal/validation.go
  • src/superfile_config/config.toml
💤 Files with no reviewable changes (2)
  • src/internal/common/ui_consts.go
  • src/internal/type_utils.go
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 0
File: :0-0
Timestamp: 2025-04-12T12:00:32.688Z
Learning: In PR #767 for yorukot/superfile, the focus is on moving code (especially sidebar-related functionality) to a more organized structure without changing functionality. Pre-existing issues should be ignored since the purpose is code reorganization, not fixing existing problems.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 781
File: src/internal/ui/sidebar/render.go:46-48
Timestamp: 2025-04-28T03:48:46.327Z
Learning: The user (lazysegtree) prefers to keep PRs focused and manageable in size, sometimes intentionally leaving TODO comments to track minor issues for later PRs rather than addressing everything at once.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 730
File: src/internal/model_render.go:653-654
Timestamp: 2025-03-29T10:02:04.260Z
Learning: A panel validation function should be implemented to ensure panel.cursor doesn't become negative or go out of bounds, but this should be addressed in a separate PR - not as part of the PR fixing crashes when opening files with the editor on an empty panel.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, lazysegtree reported image preview crashes and rename test failures after refactoring FilePreviewPanel to a separate preview package. The crashes were likely caused by: 1) imagePreviewer initialization differences between old global variable and new per-instance creation, 2) method name changes from SetContextWithRenderText to SetContentWithRenderText, and 3) batCmd initialization moving from global to per-instance without preserving the original configuration.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1013
File: src/internal/utils/file_utils.go:252-275
Timestamp: 2025-08-24T03:25:10.117Z
Learning: In PR #1013 for yorukot/superfile, when reviewing the ReadFileContent utility function, lazysegtree chose to implement only the parameter renaming fix (filepath → filePath) to avoid shadowing and declined buffer size increases and optional truncation enhancements, preferring to keep the utility function scope focused and avoid over-engineering when the additional features aren't immediately needed.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, the preview panel refactoring created duplicate ImagePreviewer instances (one in defaultModelConfig and another in preview.New()), which caused image preview crashes. The refactoring also renamed SetContextWithRenderText to SetContentWithRenderText, and moved global batCmd to per-instance batCmd initialization, all contributing to crashes during image preview and test failures.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 0
File: :0-0
Timestamp: 2025-04-12T12:25:06.352Z
Learning: PR #770 "Sidebar code separation" is a refactoring and code reorganization effort with no new features. It involves moving code, updating import paths, renaming functions to follow PascalCase convention, and consolidating sidebar-related functionality into a dedicated package.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 963
File: src/internal/default_config.go:16-16
Timestamp: 2025-07-27T07:40:51.938Z
Learning: lazysegtree prefers simpler implementation approaches when the alternatives are significantly more complex, even if the alternatives might be architecturally cleaner, prioritizing maintainability and avoiding over-engineering.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 963
File: src/internal/default_config.go:16-16
Timestamp: 2025-07-27T07:40:51.938Z
Learning: lazysegtree prefers simpler implementation approaches when the alternatives are significantly more complex, even if the alternatives might be architecturally cleaner, prioritizing maintainability and avoiding over-engineering.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 969
File: src/internal/key_function.go:40-40
Timestamp: 2025-08-03T09:34:55.721Z
Learning: lazysegtree emphasizes proper dependency direction in software architecture, preferring that low-level components (like modal handlers) should not depend on high-level components (like the main model object). He also prioritizes performance considerations, noting that creating objects on every keypress in hot code paths like key handling is inefficient and should be avoided.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1013
File: src/internal/model_render.go:329-341
Timestamp: 2025-08-29T14:11:21.380Z
Learning: lazysegtree prefers to defer help menu rendering optimizations and other technical debt improvements to separate GitHub issues when the current PR scope has grown too large, maintaining focus on the primary refactoring objectives while tracking performance improvements for future work.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 985
File: src/internal/model.go:0-0
Timestamp: 2025-08-11T01:49:30.040Z
Learning: lazysegtree prefers maintaining code correctness through proper design and invariants rather than adding defensive bounds checks at every slice access point, viewing such defensive programming as "duct taping" that can mask actual bugs instead of fixing them at their source.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 973
File: src/internal/ui/processbar/model_update.go:7-27
Timestamp: 2025-08-03T14:49:31.221Z
Learning: lazysegtree prefers to keep test-only code simple without adding production-level concerns like goroutine synchronization, cancellation contexts, or complex lifecycle management, even when such patterns might prevent potential issues, since the complexity isn't justified for test utilities.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1044
File: src/internal/utils/file_utils.go:149-149
Timestamp: 2025-09-09T13:29:11.771Z
Learning: lazysegtree prefers to keep PR scope focused on the primary objectives and considers pre-existing technical debt issues as out of scope for migration/refactoring PRs, preferring to defer such issues to separate GitHub issues rather than expanding the current PR scope.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 950
File: src/internal/ui/metadata/README.md:7-7
Timestamp: 2025-07-24T03:46:29.516Z
Learning: lazysegtree prefers to defer comprehensive unit testing to separate PRs when the current PR has grown too large, maintaining focus on the primary refactoring objectives while tracking testing requirements in dedicated GitHub issues.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 967
File: src/internal/key_function.go:45-47
Timestamp: 2025-08-02T11:47:07.713Z
Learning: lazysegtree prefers to track technical debt and architectural improvements in dedicated GitHub issues when they are identified during PR reviews but are beyond the scope of the current PR, particularly for complex refactoring needs like input handling architecture that would require significant changes.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 963
File: src/internal/handle_file_operations.go:567-570
Timestamp: 2025-07-27T08:49:09.687Z
Learning: lazysegtree prefers to defer technical debt issues like model mutation concerns to later PRs when the current PR has already grown too large, maintaining focus on the primary objectives while acknowledging the need to track such issues for future work.
📚 Learning: 2025-08-03T15:07:56.341Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 973
File: src/internal/ui/processbar/model.go:118-120
Timestamp: 2025-08-03T15:07:56.341Z
Learning: In the processbar package (src/internal/ui/processbar/model.go), the Progress.Width field is modified temporarily during rendering on a copy of the process data, and this modification is intentionally not persisted to the stored process data since it's only needed for display purposes during the render call.

Applied to files:

  • src/internal/ui/filemodel/dimensions.go
  • src/internal/ui/filepanel/model.go
  • src/internal/ui/filemodel/consts.go
  • src/internal/model_render.go
  • src/internal/model.go
📚 Learning: 2025-04-28T04:02:28.747Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 781
File: src/internal/ui/rendering/border.go:104-114
Timestamp: 2025-04-28T04:02:28.747Z
Learning: The BorderConfig.GetBorder method in src/internal/ui/rendering/border.go already protects against negative availWidth values through the condition `actualWidth >= cnt*4` which ensures that availWidth is at least 1.

Applied to files:

  • src/internal/ui/filemodel/dimensions.go
  • src/internal/validation.go
  • src/internal/model_render.go
📚 Learning: 2025-05-22T04:42:07.369Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 825
File: src/internal/ui/rendering/renderer_core.go:95-108
Timestamp: 2025-05-22T04:42:07.369Z
Learning: In src/internal/ui/rendering/renderer_core.go, when truncating rendered output that exceeds the maximum height, we should drop all remaining lines after reaching totalHeight without adding an ellipsis or other truncation indicator, as the goal is to have exactly totalHeight lines.

Applied to files:

  • src/internal/validation.go
  • src/internal/model_render.go
📚 Learning: 2025-04-12T13:51:24.691Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 770
File: src/internal/ui/sidebar/render.go:0-0
Timestamp: 2025-04-12T13:51:24.691Z
Learning: In the sidebar component of yorukot/superfile, the partial list rendering in render.go is intentional. The sidebar implements scrolling functionality where ListUp/ListDown methods in navigation.go update cursor position and renderIndex to show the appropriate portion of the directory list based on available space.

Applied to files:

  • src/internal/validation.go
  • src/internal/model.go
  • src/internal/ui/filemodel/render.go
📚 Learning: 2025-04-12T14:02:46.575Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 770
File: src/internal/ui/sidebar/consts.go:16-16
Timestamp: 2025-04-12T14:02:46.575Z
Learning: In Go packages, constants and variables should only be exported (capitalized) if they need to be accessed from outside their package. In the sidebar package, constants like `sideBarInitialHeight` should remain unexported as they're only used within the package.

Applied to files:

  • src/internal/ui/filepanel/consts.go
  • src/internal/ui/filemodel/consts.go
  • src/internal/ui/filepanel/dimension.go
📚 Learning: 2025-08-27T11:32:17.326Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, the preview panel refactoring created duplicate ImagePreviewer instances (one in defaultModelConfig and another in preview.New()), which caused image preview crashes. The refactoring also renamed SetContextWithRenderText to SetContentWithRenderText, and moved global batCmd to per-instance batCmd initialization, all contributing to crashes during image preview and test failures.

Applied to files:

  • src/internal/model_render.go
  • src/internal/model.go
  • src/internal/ui/filemodel/render.go
📚 Learning: 2025-04-03T16:05:49.630Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 752
File: src/internal/common/load_config.go:27-37
Timestamp: 2025-04-03T16:05:49.630Z
Learning: In the superfile project, configuration struct fields use PascalCase (e.g., "ShellCloseOnSuccess") while their corresponding TOML field names use snake_case (e.g., "shell_close_on_success") as defined in the struct tags. Boolean configuration fields typically don't require explicit validation in the LoadConfigFile function, unlike numeric fields which have range validations.

Applied to files:

  • src/superfile_config/config.toml
📚 Learning: 2025-08-24T03:24:50.857Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1013
File: src/internal/utils/file_utils.go:18-21
Timestamp: 2025-08-24T03:24:50.857Z
Learning: The superfile project uses github.com/charmbracelet/x/ansi as the standardized ANSI package and deprecates github.com/charmbracelet/x/exp/term/ansi to avoid binary bloat and potential incompatibilities.

Applied to files:

  • src/internal/model.go
📚 Learning: 2025-08-27T11:32:17.326Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, lazysegtree reported image preview crashes and rename test failures after refactoring FilePreviewPanel to a separate preview package. The crashes were likely caused by: 1) imagePreviewer initialization differences between old global variable and new per-instance creation, 2) method name changes from SetContextWithRenderText to SetContentWithRenderText, and 3) batCmd initialization moving from global to per-instance without preserving the original configuration.

Applied to files:

  • src/internal/ui/filemodel/render.go
📚 Learning: 2025-08-27T11:32:17.326Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, the image preview crashes and test failures were caused by duplicate ImagePreviewer initialization - one in defaultModelConfig() and another in preview.New(). This created two separate instances that conflicted in terminal state management, causing crashes during image preview operations and test execution.

Applied to files:

  • src/internal/ui/filemodel/render.go
📚 Learning: 2025-08-27T11:32:17.326Z
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, the tests were actually passing despite lazysegtree reporting crashes. The real issue was that production image preview crashes occurred during actual application usage due to duplicate ImagePreviewer instances (one in defaultModelConfig and one in preview.New()), while the test environment didn't stress the image preview system enough to expose the conflicts.

Applied to files:

  • src/internal/ui/filemodel/render.go
🧬 Code graph analysis (6)
src/internal/ui/filemodel/dimensions.go (1)
src/internal/ui/filepanel/consts.go (1)
  • MinWidth (8-8)
src/internal/ui/filepanel/model.go (1)
src/internal/ui/filepanel/consts.go (2)
  • MinWidth (8-8)
  • MinHeight (7-7)
src/internal/ui/filepanel/consts.go (1)
src/internal/common/ui_consts.go (1)
  • BorderPadding (11-11)
src/internal/ui/filemodel/consts.go (1)
src/internal/ui/filepanel/consts.go (2)
  • MinHeight (7-7)
  • MinWidth (8-8)
src/internal/model_render.go (3)
src/internal/ui/spf_renderers.go (1)
  • ClipboardRenderer (147-151)
src/internal/common/ui_consts.go (2)
  • BorderPadding (11-11)
  • FooterGroupCols (13-13)
src/internal/utils/ui_utils.go (1)
  • FooterWidth (12-14)
src/internal/model.go (1)
src/internal/ui/filepanel/consts.go (1)
  • MinWidth (8-8)
🪛 GitHub Actions: Go CI
src/internal/validation.go

[error] 123-123: cognitive complexity 29 of func validateRender is high (> 20) (gocognit)

🪛 GitHub Check: Build and Test (macos-latest)
src/internal/validation.go

[failure] 128-128:
directive //nolint:gocognit // cumilation of validations is unused for linter "gocognit" (nolintlint)


[failure] 123-123:
cognitive complexity 29 of func validateRender is high (> 20) (gocognit)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (15)
src/superfile_config/config.toml (1)

76-76: LGTM! Debug mode enabled for validation testing.

Enabling debug mode is appropriate for a PR focused on dimension validations and render checks. This will help surface validation errors during testing.

src/internal/ui/filemodel/dimensions.go (1)

71-71: LGTM! Constant rename applied correctly.

The update to use filepanel.MinWidth (previously FilePanelMinWidth) is consistent with the constant rename across the codebase.

src/internal/ui/filepanel/model.go (1)

58-59: LGTM! Default dimensions updated with renamed constants.

The initialization now uses MinWidth and MinHeight (previously FilePanelMinWidth and FilePanelMinHeight), consistent with the constant renames in filepanel/consts.go.

src/internal/ui/filepanel/dimension.go (1)

11-12: LGTM! Dimension methods updated with renamed constants.

All dimension methods now use the renamed constants (MinWidth, MinHeight, ContentPadding) consistently. The logic remains unchanged.

Also applies to: 19-20, 45-45

src/internal/ui/filemodel/render.go (1)

6-12: LGTM! Preview panel rendering integrated cleanly.

The slice is now sized to accommodate the file preview panel alongside the file panels. When the preview is open, the extra slot is populated with the preview content. When closed, the empty string is safely handled by lipgloss.JoinHorizontal.

src/internal/ui/filemodel/consts.go (1)

9-14: LGTM! Good documentation of constant derivation.

The comment clearly explains that while FileModelMinHeight and FileModelMinWidth currently derive from the same source as the filepanel constants, they have different semantic meanings and may diverge in the future. This is good architectural documentation.

src/internal/model_render.go (1)

34-35: LGTM! Clipboard width calculation extracted to helper.

The inline width calculation has been properly extracted to the getClipboardWidth() helper method, improving code organization.

src/internal/ui/filepanel/consts.go (1)

6-8: LGTM! Constant renames and calculations are correct.

The constant renames simplify the naming (removing the FilePanel prefix) while maintaining clarity within the package context. The MinHeight calculation (ContentPadding + common.BorderPadding + 1 = 6) is correct, and these changes are consistently applied across all dependent files.

src/internal/validation.go (2)

198-236: LGTM!

The component render validation properly gates sidebar checks on non-zero width and footer validation on toggle state. Good coverage of all major UI components.


238-265: LGTM!

The final render validation correctly handles the sidebar offset and validates file panel placements using the component extraction utility.

src/internal/model.go (5)

15-15: LGTM!

Import added to access the renamed filepanel.MinWidth constant.


523-529: LGTM!

Enhanced debug logging provides useful layout diagnostics. The access to FilePanels[0] is safe here since validateLayout already ensures PanelCount() > 0.


539-553: LGTM!

Clean simplification of the rendering path. The layout guard now uses filepanel.MinWidth consistently with the renamed constant, and the main/footer panel composition is more streamlined.


565-579: LGTM!

Debug-only validation is a good approach - it catches layout/render bugs during development without impacting production performance. The non-fatal logging ensures the application remains functional even when validation issues are detected.


639-643: LGTM!

Function signature updated to match the simplified rendering path where file preview is now part of the file model render.

Comment on lines +84 to +88
// Validate search bar width matches panel width minus padding
if panel.SearchBar.Value() != "" && panel.SearchBar.Width != m.fileModel.Width-common.InnerPadding {
return fmt.Errorf("file panel %v search bar width mismatch: expected %v, got %v",
i, m.fileModel.Width-common.InnerPadding, panel.SearchBar.Width)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, find all SearchBar.Width related code
rg -n "SearchBar.Width" --type=go -B 5 -A 5

Repository: yorukot/superfile

Length of output: 2450


🏁 Script executed:

#!/bin/bash
# Check for panel dimension methods
rg -n "func.*GetWidth|func.*GetHeight|func.*Width|GetWidth|GetHeight" src/internal/ui/filepanel/ --type=go -A 3 | head -100

Repository: yorukot/superfile

Length of output: 1009


🏁 Script executed:

#!/bin/bash
# Check the model structure and width fields
rg -n "SinglePanelWidth|type.*fileModel|Width.*int" src/internal/ --type=go -B 2 -A 2 | head -150

Repository: yorukot/superfile

Length of output: 8633


🏁 Script executed:

#!/bin/bash
# Let's look at how FileModel.Width and SinglePanelWidth are calculated
rg -n "m.Width\s*=" src/internal/ui/filemodel/ --type=go -B 3 -A 3

Repository: yorukot/superfile

Length of output: 475


🏁 Script executed:

#!/bin/bash
# Check UpdateChildComponentWidth to understand how individual panels are sized
rg -n "UpdateChildComponentWidth|panelWidth\s*:=" src/internal/ui/filemodel/dimensions.go --type=go -B 2 -A 10

Repository: yorukot/superfile

Length of output: 1036


🏁 Script executed:

#!/bin/bash
# Let's see the full validation.go file section around the SearchBar validation
cat -n src/internal/validation.go | sed -n '75,95p'

Repository: yorukot/superfile

Length of output: 1024


🏁 Script executed:

#!/bin/bash
# Check if SearchBar.Width is modified anywhere else after initial setup
rg -n "SearchBar.Width\s*=" src/internal/ --type=go -B 2 -A 2

Repository: yorukot/superfile

Length of output: 665


🏁 Script executed:

#!/bin/bash
# Confirm: when SetWidth is called on panels, that updates SearchBar.Width
# Let's trace through a scenario with 2 panels
cat -n src/internal/ui/filemodel/dimensions.go | sed -n '37,72p'

Repository: yorukot/superfile

Length of output: 1314


Fix search bar width validation to check individual panel width.

The validation on line 85 checks panel.SearchBar.Width against m.fileModel.Width - common.InnerPadding, but SearchBar.Width is set to each individual panel's width (via SetWidth() which does m.width - common.InnerPadding). Since panels can have different widths—especially when multiple panels are open or a preview panel is active—the validation should compare against panel.GetWidth() - common.InnerPadding instead.

🤖 Prompt for AI Agents
In src/internal/validation.go around lines 84 to 88, the search bar width
validation incorrectly compares panel.SearchBar.Width to m.fileModel.Width -
common.InnerPadding; update the check to compare against the individual panel
width by using panel.GetWidth() - common.InnerPadding instead, so the condition
and error message reflect per-panel width expectations (replace
m.fileModel.Width with panel.GetWidth() in the comparison and expected value).

Comment thread src/internal/validation.go Outdated
Comment on lines +152 to +154
if len(lines) < minLinesForBorder {
return fmt.Errorf("too many lines for border : %v", len(lines))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Incorrect error message.

The check len(lines) < minLinesForBorder validates that there are too few lines, but the error message says "too many lines for border".

🔎 Proposed fix
 	if len(lines) < minLinesForBorder {
-		return fmt.Errorf("too many lines for border : %v", len(lines))
+		return fmt.Errorf("too few lines for border: expected at least %v, got %v", minLinesForBorder, len(lines))
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if len(lines) < minLinesForBorder {
return fmt.Errorf("too many lines for border : %v", len(lines))
}
if len(lines) < minLinesForBorder {
return fmt.Errorf("too few lines for border: expected at least %v, got %v", minLinesForBorder, len(lines))
}
🤖 Prompt for AI Agents
In src/internal/validation.go around lines 152-154, the error message for the
condition len(lines) < minLinesForBorder is incorrect (it currently says "too
many lines for border"); update the fmt.Errorf call to accurately reflect the
failing condition, e.g. return fmt.Errorf("too few lines for border: %v",
len(lines)) or return fmt.Errorf("not enough lines for border: %v", len(lines)),
preserving the existing formatting and variable.

@lazysegtree
lazysegtree merged commit feb440f into develop Dec 22, 2025
7 of 8 checks passed
@lazysegtree
lazysegtree deleted the dimension-validations branch January 1, 2026 18:21
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 17, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [yorukot/superfile](https://github.com/yorukot/superfile) | minor | `v1.4.0` → `v1.5.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>yorukot/superfile (yorukot/superfile)</summary>

### [`v1.5.0`](https://github.com/yorukot/superfile/releases/tag/v1.5.0)

[Compare Source](yorukot/superfile@v1.4.0...v1.5.0)

This release brings major new features, including video and PDF preview support, multi-column file panels, and configurable navigation, alongside significant code refactoring and comprehensive bug fixes.

#### Install:

[**Click me to know how to install**](https://github.com/yorukot/superfile?tab=readme-ov-file#installation)

#### Highlights

- Added video and PDF preview support via loading the first frame/page as an image. Thanks [@&#8203;Yassen-Higazi](https://github.com/Yassen-Higazi) for the implementation

<details><summary>Screenshots</summary>
<p>

<img width="951" height="596" alt="image" src="https://github.com/user-attachments/assets/6edfa9c2-ebcd-4622-a115-f71fa533b3e1" />

<img width="949" height="594" alt="image" src="https://github.com/user-attachments/assets/8d15fa46-5178-422d-8eea-455cac31fdd0" />

</p>
</details>

- Multi-column file panel view with date/size/permission columns. Thanks [@&#8203;xelavopelk](https://github.com/xelavopelk) for the implementation

<details><summary>Screenshots</summary>
<p>

<img width="420" height="264" alt="image" src="https://github.com/user-attachments/assets/e172f1e8-c2a5-42d2-8eeb-62e721f61a4f" />

</p>
</details>

- Configurable fast navigation in the Filepanel. See this MR for more details: [#&#8203;1220](yorukot/superfile#1220)
- You can now configure `spf` to open files with specific extensions with your choice of editor application. Thanks  [@&#8203;litvinov-git](https://github.com/litvinov-git) for the implementation See this MR for more details: [#&#8203;1197](yorukot/superfile#1197)
- Terminal stdout support for shell commands
- Allow launching with the filename. `spf /a/b/c.txt` will launch in `/a/b` with `c.txt` as the selected file.
- Various bug fixes, including modal confirmations, layout issues, and race conditions. See 'Detailed Change Summary'

##### Internal Updates

- Separated FilePanel and FileModel into a dedicated package for better code organization
- Comprehensive end-to-end testing with layout fixes
- Enhanced dimension validation and sidebar fixes
- Updated multiple dependencies including Astro, Go toolchain, and linters
- Added gosec linter and MND linter with magic number cleanup

#### Detailed Change Summary

<details><summary>Details</summary>
<p>

##### Update
- allow hover to file [`#1177`](yorukot/superfile#1177) by @&#8203;lazysegtree
- show count selected items in select mode [`#1187`](yorukot/superfile#1187) by @&#8203;xelavopelk
- Add icon alias for kts to kt [`#1153`](yorukot/superfile#1153) by @&#8203;nicolaic
- link icon and metadata [`#1171`](yorukot/superfile#1171) by @&#8203;xelavopelk
- user configuration of editors by file extension [`#1197`](yorukot/superfile#1197) by @&#8203;litvinov-git
- add video preview support [`#1178`](yorukot/superfile#1178) by @&#8203;Yassen-Higazi
- Add pdf preview support [`#1198`](yorukot/superfile#1198) by @&#8203;Yassen-Higazi
- Add icons in pinned directories [`#1215`](yorukot/superfile#1215) by @&#8203;lazysegtree
- Enable fast configurable navigation [`#1220`](yorukot/superfile#1220) by @&#8203;lazysegtree
- add Trash bin to default directories for Linux [`#1236`](yorukot/superfile#1236) by @&#8203;lazysegtree
- add terminal stdout support for shell commands [`#1250`](yorukot/superfile#1250) by @&#8203;majiayu000
- More columns in file panel (MVP) [`#1268`](yorukot/superfile#1268) by @&#8203;xelavopelk

##### Bug Fix
- only calculate checksum on files [`#1119`](yorukot/superfile#1119) by @&#8203;nikero41
- Linter issue with PrintfAndExit [`#1133`](yorukot/superfile#1133) by @&#8203;xelavopelk
- Remove repeated os.ReadDir calls [`#1155`](yorukot/superfile#1155) by @&#8203;lazysegtree
- Disable COPYFILE in macOS [`#1194`](yorukot/superfile#1194) by @&#8203;lazysegtree
- add missing hotkeys to help menu [`#1192`](yorukot/superfile#1192) by @&#8203;lazysegtree
- Fetch latest version automatically [`#1127`](yorukot/superfile#1127) by @&#8203;lazysegtree
- Use async methods to prevent test race conditions [`#1201`](yorukot/superfile#1201) by @&#8203;lazysegtree
- update metadata and process bar sizes when toggling footer [`#1218`](yorukot/superfile#1218) by @&#8203;lazysegtree
- File panel dimension management [`#1222`](yorukot/superfile#1222) by @&#8203;lazysegtree
- Layout fixes with full end-to-end tests [`#1227`](yorukot/superfile#1227) by @&#8203;lazysegtree
- Fix flaky tests [`#1233`](yorukot/superfile#1233) by @&#8203;lazysegtree
- modal confirmation bug with arrow keys [`#1243`](yorukot/superfile#1243) by @&#8203;lazysegtree
- small file panel optimization [`#1241`](yorukot/superfile#1241) by @&#8203;xelavopelk
- use ExtractOperationMsg for extraction [`#1248`](yorukot/superfile#1248) by @&#8203;lazysegtree
- skip open_with from missing field validation [`#1251`](yorukot/superfile#1251) by @&#8203;lazysegtree
- border height validation fixes [`#1267`](yorukot/superfile#1267) by @&#8203;lazysegtree
- fix case with two active panes [`#1271`](yorukot/superfile#1271) by @&#8203;xelavopelk
- help model formatting [`#1277`](yorukot/superfile#1277) by @&#8203;booth-w

##### Optimization
- simplify renameIfDuplicate logic [`#1100`](yorukot/superfile#1100) by @&#8203;sarff
- separate FilePanel into dedicated package [`#1195`](yorukot/superfile#1195) by @&#8203;lazysegtree
- File model separation [`#1223`](yorukot/superfile#1223) by @&#8203;lazysegtree
- Dimension validations [`#1224`](yorukot/superfile#1224) by @&#8203;lazysegtree
- layout validation and sidebar dimension fixes [`#1228`](yorukot/superfile#1228) by @&#8203;lazysegtree
- user rendering package and removal of unused preview code [`#1245`](yorukot/superfile#1245) by @&#8203;lazysegtree
- user rendering package for file preview [`#1249`](yorukot/superfile#1249) by @&#8203;lazysegtree

##### Documentation
- update Fish shell setup docs [`#1142`](yorukot/superfile#1142) by @&#8203;wleoncio
- fix macOS typo [`#1212`](yorukot/superfile#1212) by @&#8203;wcbing
- stylistic and linguistic cleanup of config documentation [`#1184`](yorukot/superfile#1184) by @&#8203;ninetailedtori

##### Dependencies
- update astro monorepo [`#1010`](yorukot/superfile#1010) by @&#8203;renovate[bot]
- update starlight-giscus [`#1020`](yorukot/superfile#1020) by @&#8203;renovate[bot]
- bump astro versions [`#1138`](yorukot/superfile#1138), [`#1157`](yorukot/superfile#1157), [`#1158`](yorukot/superfile#1158) by @&#8203;dependabot[bot], @&#8203;renovate[bot]
- bump vite [`#1134`](yorukot/superfile#1134) by @&#8203;dependabot[bot]
- update setup-go action [`#1038`](yorukot/superfile#1038) by @&#8203;renovate[bot]
- update expressive-code plugins [`#1189`](yorukot/superfile#1189), [`#1246`](yorukot/superfile#1246) by @&#8203;renovate[bot]
- update sharp [`#1256`](yorukot/superfile#1256) by @&#8203;renovate[bot]
- update fontsource monorepo [`#1257`](yorukot/superfile#1257) by @&#8203;renovate[bot]
- update urfave/cli [`#1136`](yorukot/superfile#1136), [`#1190`](yorukot/superfile#1190) by @&#8203;renovate[bot]
- update astro / starlight / ansi / toolchain deps [`#1275`](yorukot/superfile#1275), [`#1278`](yorukot/superfile#1278), [`#1280`](yorukot/superfile#1280) by @&#8203;renovate[bot]
- update python and go versions [`#1276`](yorukot/superfile#1276), [`#1191`](yorukot/superfile#1191) by @&#8203;renovate[bot]
- update golangci-lint action [`#1286`](yorukot/superfile#1286) by @&#8203;renovate[bot]

##### Misc
- update CI input names [`#1120`](yorukot/superfile#1120) by @&#8203;nikero41
- Everforest Dark Hard theme [`#1114`](yorukot/superfile#1114) by @&#8203;fzahner
- migrate tutorial demo assets to local [`#1140`](yorukot/superfile#1140) by @&#8203;yorukot
- new logo asset [`#1145`](yorukot/superfile#1145) by @&#8203;nonepork
- mirror repository to codeberg [`#1141`](yorukot/superfile#1141) by @&#8203;yorukot
- sync package lock [`#1143`](yorukot/superfile#1143) by @&#8203;yorukot
- bump golangci-lint version [`#1135`](yorukot/superfile#1135) by @&#8203;lazysegtree
- add gosec linter [`#1185`](yorukot/superfile#1185) by @&#8203;lazysegtree
- enable MND linter and clean magic numbers [`#1180`](yorukot/superfile#1180) by @&#8203;lazysegtree
- skip permission tests when running as root [`#1186`](yorukot/superfile#1186) by @&#8203;lazysegtree
- release v1.4.1-rc [`#1203`](yorukot/superfile#1203) by @&#8203;lazysegtree
- 1.5.0-rc1 housekeeping changes [`#1264`](yorukot/superfile#1264) by @&#8203;lazysegtree

</p>
</details> 

#### New Contributors
* @&#8203;fzahner made their first contribution in yorukot/superfile#1114
* @&#8203;sarff made their first contribution in yorukot/superfile#1100
* @&#8203;nicolaic made their first contribution in yorukot/superfile#1153
* @&#8203;Yassen-Higazi made their first contribution in yorukot/superfile#1178
* @&#8203;ninetailedtori made their first contribution in yorukot/superfile#1184
* @&#8203;litvinov-git made their first contribution in yorukot/superfile#1197
* @&#8203;wcbing made their first contribution in yorukot/superfile#1212
* @&#8203;majiayu000 made their first contribution in yorukot/superfile#1250

**Full Changelog**: <yorukot/superfile@v1.4.0...v1.5.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MC4xIiwidXBkYXRlZEluVmVyIjoiNDIuODAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.