Skip to content

refactor(defcon): add 2x support and code updates#409

Merged
tavdog merged 6 commits intomainfrom
defcon-2x
Mar 16, 2026
Merged

refactor(defcon): add 2x support and code updates#409
tavdog merged 6 commits intomainfrom
defcon-2x

Conversation

@gabe565
Copy link
Collaborator

@gabe565 gabe565 commented Mar 16, 2026

Adds 2x support to defcon.star and simplifies rendering and HTML parsing logic.

@rjison Since you created this app, do my changes look good to you?

@gabe565 gabe565 requested a review from tavdog as a code owner March 16, 2026 04:27
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the defcon app by introducing comprehensive support for 2x displays and improving the underlying code structure. The changes simplify how DEFCON levels are extracted from HTML content and modernize the rendering pipeline, making the application more adaptable to different display resolutions and easier to maintain.

Highlights

  • 2x Display Support: Implemented support for 2x displays, allowing the app to render at higher resolutions with appropriate scaling for fonts and elements.
  • Simplified HTML Parsing: Refactored the HTML parsing logic by leveraging the html.star module, which significantly simplifies the extraction of the DEFCON level from the webpage.
  • Rendering Logic Refinement: Streamlined the rendering functions (main, render_defcon_display, get_defcon_display) to improve code readability, maintainability, and to properly accommodate 2x scaling.
Changelog
  • apps/defcon/defcon.star
    • Imported html and canvas modules to facilitate HTML parsing and 2x display detection.
    • Updated CACHE_TTL_SECONDS to a more explicit calculation for clarity.
    • Introduced SCALE and dynamically selected FONT based on canvas.is2x() for responsive rendering.
    • Removed deprecated trim_left, trim_right, and extract_defcon_level utility functions.
    • Consolidated HTTP request and HTML parsing into a new get_defcon_level function using html.star.
    • Modified the main function to utilize the new get_defcon_level and updated the root rendering structure to support dynamic sizing and spacing.
    • Added a new helper function render_box to encapsulate box rendering logic with 2x scaling considerations.
    • Rewrote get_defcon_display to use render_box and implement a more robust rendering strategy for the DEFCON level indicators, including handling animation and static display.
    • Adjusted display_instructions to dynamically set width and font based on 2x support and updated marquee delays.
  • apps/defcon/manifest.yaml
    • Added supports2x: true to the manifest, indicating compatibility with 2x displays.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds 2x support and refactors HTML parsing. However, there is a rendering issue in the instructions screen due to incorrect marquee offset calculations and missing font properties. A comment with a suggested fix has been added. Additionally, the app is missing the required preview images (defcon.webp and defcon@2x.webp) as specified in the repository's style guide (lines 22-24).

@tavdog tavdog merged commit 76edf26 into main Mar 16, 2026
7 checks passed
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