Skip to content

Conversation

@lodewiges
Copy link
Contributor

@lodewiges lodewiges commented Jan 17, 2026

A pdf is now generated and able to be downloaded however the css did work properly and the document was a 170 pages

Summary by CodeRabbit

  • Bug Fixes

    • Simplified PDF generation CSS handling for improved reliability.
  • Chores

    • Optimized Docker image size by adding cleanup steps and dependencies.
    • Streamlined build process by consolidating PDF stylesheet compilation.
    • Configured PDF generation for enhanced performance in production environments.

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

Copilot AI review requested due to automatic review settings January 17, 2026 20:03
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

This PR consolidates PDF handling by removing separate PDF stylesheet compilation, simplifying CSS discovery to use a single application.css file, and adding environment-specific Grover configuration. It also updates the Dockerfile with an additional dependency and cleanup commands to reduce image size.

Changes

Cohort / File(s) Summary
Build & Docker Configuration
Dockerfile, package.json
Dockerfile: Added libyaml-dev dependency and apt cleanup (rm -rf /var/lib/apt/lists/*). Build script: Removed pdf.scss compilation from build:css step, now outputs only application.css
PDF Asset Handling
app/assets/stylesheets/pdf.scss, app/views/layouts/pdf.html.erb
Removed pdf.scss comment. Simplified pdf.html.erb CSS discovery: now checks only for application.css in app/assets/builds/ instead of searching multiple paths and applying error handling/logging
Grover Configuration
config/initializers/grover.rb
Added environment-based conditional setup: non-development environments now set executable_path to /usr/bin/chromium and add launch_args (--no-sandbox, --disable-setuid-sandbox, --disable-dev-shm-usage)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • csvalpha/sofia#1208: Modifies identical lines in Dockerfile apt-install/cleanup and config/initializers/grover.rb environment-dependent configuration—likely a duplicate or related effort.

Poem

🐰 One stylesheet to rule them all, no more PDF fray,
Chromium's chains are tightened safe in production's way,
Docker images lean and clean, the cleanup spree complete,
Build scripts sing a simpler song—sweet consolidation feat!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and does not follow the repository template. It lacks structured sections, a proper summary, the required checklist, and details about testing or related issues. Add the required checklist sections, provide a detailed summary of CSS/PDF generation changes, include database migration information if applicable, and mention any related issues using 'fixes #xyz' format.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Hotfix for pdf css generation' clearly summarizes the main change across multiple files focused on fixing PDF CSS generation and simplifying stylesheet handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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
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

This PR fixes PDF generation issues where CSS was causing documents to balloon to 170 pages. The fix simplifies CSS loading by using only the main application.css file instead of attempting to load all CSS files, and removes the separate pdf.scss file that was not being properly utilized.

Changes:

  • Simplified build process to only generate application.css, removing pdf.css compilation
  • Streamlined CSS loading in PDF layout to read only application.css instead of globbing all CSS files
  • Added Chromium-specific configuration for non-development environments in Grover initializer
  • Enhanced Docker image with fonts-liberation package and improved cleanup

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
package.json Removed pdf.css from build:css script, now only builds application.css
config/initializers/grover.rb Refactored options handling and added conditional Chromium executable path and launch args for non-dev environments
app/views/layouts/pdf.html.erb Simplified CSS loading to read only application.css instead of globbing all CSS files
app/assets/stylesheets/pdf.scss Deleted unused PDF-specific stylesheet file
Dockerfile Added fonts-liberation package and cleanup commands to reduce image size

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

end
end.join("\n") %>
<% app_css_path = Rails.root.join('app', 'assets', 'builds', 'application.css') %>
<% css = File.exist?(app_css_path) ? File.read(app_css_path) : '' %>
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The File.read operation is not wrapped in error handling. If the file exists but cannot be read due to permissions or I/O errors, this will raise an exception and break PDF generation. Consider adding a rescue block similar to the error handling that was present in the previous implementation to gracefully handle read failures.

Suggested change
<% css = File.exist?(app_css_path) ? File.read(app_css_path) : '' %>
<% css =
if File.exist?(app_css_path)
begin
File.read(app_css_path)
rescue StandardError
''
end
else
''
end
%>

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.08%. Comparing base (fb90056) to head (bdc6b4d).
⚠️ Report is 1 commits behind head on staging.

Additional details and impacted files
@@           Coverage Diff            @@
##           staging    #1209   +/-   ##
========================================
  Coverage    77.08%   77.08%           
========================================
  Files           54       54           
  Lines         1370     1370           
========================================
  Hits          1056     1056           
  Misses         314      314           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants