Skip to content

Conversation

@Boy132
Copy link
Member

@Boy132 Boy132 commented Nov 4, 2025

Isn't really doing anything on it's own, but allows plugins to register their own alert banners for "special files".

@Boy132 Boy132 self-assigned this Nov 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 4, 2025

Warning

Rate limit exceeded

@Boy132 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1a4dc2e and 05bf98b.

📒 Files selected for processing (1)
  • app/Models/File.php (2 hunks)
📝 Walkthrough

Walkthrough

Refactors the handling of special files from a hard-coded check for .pelicanignore to a generalized, data-driven approach. Introduces registration and retrieval mechanisms in the File model to manage special files and their banner configurations dynamically.

Changes

Cohort / File(s) Summary
Special Files Registration
app/Models/File.php
Introduces registerSpecialFile() and getSpecialFiles() public static methods on the File model. Adds $customSpecialFiles protected static array for storing custom special file configurations. Defines default entry for .pelicanignore with translatable title and body. Imports Closure for type hints.
Special Files Alert Handling
app/Filament/Server/Resources/Files/Pages/EditFiles.php
Replaces hard-coded .pelicanignore file check in mount() with a generalized loop over File::getSpecialFiles(). For each special file, evaluates the registered check closure and sends an AlertBanner with dynamic file name and alert data if the check passes. Adds imports for App\Models\File and Closure.

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Allow to register "special file" alert banners' accurately and concisely describes the main change: introducing a registration mechanism for special file alert banners.
Description check ✅ Passed The description is directly related to the changeset, explaining that the change enables plugins to register custom alert banners for special files, which aligns with the code modifications.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/Models/File.php (1)

61-68: Consider guarding against overwriting default special files.

The method allows plugins to register files that could overwrite the default .pelicanignore entry when getSpecialFiles() merges the arrays. This may be intentional for flexibility, but could lead to unexpected behavior if plugins unintentionally use reserved filenames.

Consider adding a check to prevent overwriting built-in special files, or document this behavior:

 public static function registerSpecialFile(string $fileName, string|Closure $bannerTitle, string|Closure|null $bannerBody = null, ?Closure $nameCheck = null): void
 {
+    // Optional: Warn or prevent overwriting default special files
+    $defaults = ['.pelicanignore'];
+    if (in_array($fileName, $defaults)) {
+        throw new \InvalidArgumentException("Cannot override default special file: {$fileName}");
+    }
+
     static::$customSpecialFiles[$fileName] = [
         'title' => $bannerTitle,
         'body' => $bannerBody,
         'check' => $nameCheck ?? fn (string $path) => str($path)->endsWith($fileName),
     ];
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21f9f25 and 1a4dc2e.

📒 Files selected for processing (2)
  • app/Filament/Server/Resources/Files/Pages/EditFiles.php (2 hunks)
  • app/Models/File.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Server/Resources/Files/Pages/EditFiles.php (2)
app/Models/File.php (2)
  • File (30-241)
  • getSpecialFiles (70-81)
app/Livewire/AlertBanner.php (2)
  • AlertBanner (14-100)
  • closable (72-77)
🔇 Additional comments (3)
app/Filament/Server/Resources/Files/Pages/EditFiles.php (1)

10-10: LGTM!

The new imports are necessary for the refactored special file handling.

Also applies to: 16-16

app/Models/File.php (2)

8-8: LGTM!

The Closure import is required for the new type hints in the special file registration methods.


58-59: LGTM!

The static property correctly stores custom special files with a clear docblock describing its structure.

@Boy132 Boy132 merged commit 852f7be into main Nov 4, 2025
25 checks passed
@Boy132 Boy132 deleted the boy132/custom-special-files branch November 4, 2025 11:48
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants