Skip to content

feat: System Theme Preference Support #1945#1953

Open
desireddymohithreddy0925 wants to merge 3 commits into
S3DFX-CYBER:mainfrom
desireddymohithreddy0925:feature/system-theme-preference
Open

feat: System Theme Preference Support #1945#1953
desireddymohithreddy0925 wants to merge 3 commits into
S3DFX-CYBER:mainfrom
desireddymohithreddy0925:feature/system-theme-preference

Conversation

@desireddymohithreddy0925

@desireddymohithreddy0925 desireddymohithreddy0925 commented Jun 24, 2026

Copy link
Copy Markdown

✨ Feature Description

Added support to automatically detect and respect the user's operating system theme preference (dark/light mode).

🤔 Problem It Solves

Currently, users must manually click the theme toggle button to switch to dark mode, and this preference is saved in localStorage. Users whose operating systems automatically switch themes based on the time of day (or manual OS toggles) have a disconnected experience where the website does not adapt automatically, forcing them to manually toggle it.

💡 Proposed Solution

  • Used window.matchMedia('(prefers-color-scheme: dark)') to check the system's preferred theme on initial load in index.html and app.js, using it as the default if localStorage has no saved preference.
  • Added an event listener to matchMedia to dynamically switch the theme if the system preference changes during the session.
  • Prevented FOUC (Flash of Unstyled Content) by adding the fallback check early in the scripts.

✅ Acceptance Criteria Verified

  • If no localStorage preference is set, the site loads in the OS's preferred color scheme.
  • If the OS theme changes while the site is open, the site updates its theme automatically.
  • If the user manually clicks the theme toggle, it overrides the system preference and saves to localStorage.

🌱 Contributor Checklist

  • I am participating via GSSoC
  • I have read the contribution guidelines
  • I checked for existing issues before creating this

Review in cubic

program: gssoc

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the s3dfx-cyber's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

💬 Faster Reviews & Assignments

Hi @desireddymohithreddy0925, for faster coordination and smoother communication, consider joining our Discord community:

👉 https://discord.gg/MmZGG2ee

Useful Channels

  • #issue-links-for-assignment → Share issue links for assignment help
  • #pr-links-for-review → Share PR links for mentor/maintainer review

Please avoid spamming channels or repeatedly pinging mentors/maintainers.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Sign-off Verified

Hi @desireddymohithreddy0925 👋

All commits in this PR contain valid Signed-off-by lines.

Thank you for following the DCO requirements 🚀

@github-actions github-actions Bot added dco-missing size/s gssoc26 GirlScript Summer of Code 2026 labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for opening a PR, @desireddymohithreddy0925!

Your PR has entered the 🚦 PR Review Pipeline.

🟢 GSSOC PR detected — your PR will be routed through the GSSOC mentor review pipeline.


🔄 Review Flow

Stage Reviewer Purpose
Stage 1 🤖 Automation Validation · Duplicate Detection · AI/Slop Checks · Formatting · PR Analysis
Stage 2 🧑‍🏫 GSSOC Mentor Code Review · Scope Validation · Quality Check
Stage 3 🔑 Project Admin / Maintainer Final Approval & Merge Decision

The automated PR analysis system will verify issue linkage, PR relevance, and contribution quality.

A pipeline status comment may appear automatically as your PR progresses.


✅ Contributor Checklist

  • Sign commits using git commit -s
  • Link a valid issue (Closes #123)
  • Keep changes focused and relevant
  • Do not include unrelated modifications
  • Ensure workflows/build/tests are passing
  • Read the appropriate contributor guide:

⚠️ Important Notes

  • Low-quality, spammy, or AI-generated PRs may be closed
  • PRs without linked issues may fail automated checks
  • Large unrelated PRs are likely to be rejected
  • Review times may vary depending on mentor/reviewer availability

Happy contributing 🚀

This message is posted automatically and only once.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ PR Validation Issues

Hi @desireddymohithreddy0925, your PR requires fixes before review.

Critical Issues

  • ❌ Missing linked issue. Add Closes #issue-number to the PR body.

Warnings

  • ⚠️ Missing PR template section: related issue
  • ⚠️ Missing PR template section: type of change

⚠️ PRs without linked issues may be automatically closed after 48 hours if unresolved.

Please push fixes after updating the PR.

@github-project-automation github-project-automation Bot moved this to Todo in GSSOC 26 Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@desireddymohithreddy0925, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 23 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 475cb3c6-6f51-47b8-9dab-663b19fe251d

📥 Commits

Reviewing files that changed from the base of the PR and between 452fbf5 and 1613538.

📒 Files selected for processing (3)
  • .github/workflows/program-classification-validator.yml
  • index.html
  • src/js/app.js
📝 Walkthrough

Walkthrough

The PR adds system-preference-aware theme initialization in both index.html and src/js/app.js, supporting three modes: explicitly saved dark, explicitly saved light, or system default via prefers-color-scheme: dark with a live media-query listener. It also expands PR classification detection patterns in a GitHub Actions workflow and adds error tolerance to TENET workflow execution.

Changes

Three-mode theme initialization with system preference support

Layer / File(s) Summary
Early IIFE theme restoration and initTheme three-branch logic
index.html, src/js/app.js
The IIFE in index.html (lines 78–83) and initTheme() in app.js (lines 112–122) both branch on localStorage.theme values dark/light and fall back to window.matchMedia('(prefers-color-scheme: dark)') when unset, replacing the prior single-case dark-only check.
Live media-query change listener
src/js/app.js
A matchMedia('(prefers-color-scheme: dark)') change listener (lines 124–131) is registered to dynamically toggle the dark class and update the theme icon when no saved theme preference exists, enabling real-time OS theme changes in the UI.

CI workflow updates

Layer / File(s) Summary
Program classification detection expansion
.github/workflows/program-classification-validator.yml
The detectProgram() function (lines 92–117) now matches additional checkbox-style PR-body text variants and both \n and \r\n newline separators for gssoc, nsoc, and general program detection, improving robustness of PR classification matching.
TENET workflow error tolerance
.github/workflows/tenet-pr-review.yml
The "Run TENET PR Review" step (line 52) now includes continue-on-error: true, allowing the job to continue even if the TENET review command fails.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • feat: System Theme Preference Support #1945: This PR directly implements the system theme preference support described in that issue, including prefers-color-scheme: dark detection, a dynamic media-query listener, and the three-mode theme flow (dark/light/system-default).

Possibly related PRs

Suggested labels

gssoc26, dco-verified, size/xs

Suggested reviewers

  • S3DFX-CYBER
  • Neilblaze

Poem

🐰 Hippity hop, the theme knows the way,
Dark or light — or what the system will say!
No more guessing, no more one-track mind,
The OS whispers and the page will find.
✨ Three branches bloom where one used to be,
A theme-aware rabbit, happy and free!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: System Theme Preference Support #1945' directly and clearly summarizes the main change: adding system theme preference detection and support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly relates to the changeset, describing OS theme preference detection feature with problem statement, proposed solution, and acceptance criteria verification.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added missing-program-classification and removed gssoc26 GirlScript Summer of Code 2026 labels Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

✅ Program Classification Verified

Detected contribution program:

  • GSSOC

Program-aware automation and routing are now enabled for this PR.

@github-actions github-actions Bot added gssoc26 GirlScript Summer of Code 2026 and removed gssoc26 GirlScript Summer of Code 2026 labels Jun 24, 2026

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

🧹 Nitpick comments (2)
index.html (1)

83-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use globalThis for media-query access.

Line 83 uses window.matchMedia; switching to globalThis.matchMedia aligns with the project’s static-analysis expectation and avoids recurring warnings.

Suggested change
-        } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
+        } else if (globalThis.matchMedia?.('(prefers-color-scheme: dark)').matches) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@index.html` at line 83, Replace the `window.matchMedia` reference with
`globalThis.matchMedia` on line 83 where the color scheme preference is being
checked. This change aligns with the project's static analysis expectations and
eliminates linter warnings. Locate the line containing the condition
`window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches`
and update both occurrences of `window` to `globalThis` to ensure consistency
with the project standards.

Source: Linters/SAST tools

src/js/app.js (1)

117-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace window with globalThis in theme media-query handling.

Using globalThis.matchMedia here keeps this file consistent with the repo convention and resolves the Sonar warnings at Lines 117, 124, and 125.

Suggested change
-    } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
+    } else if (globalThis.matchMedia?.('(prefers-color-scheme: dark)').matches) {
       document.documentElement.classList.add('dark');
     } else {
       document.documentElement.classList.remove('dark');
     }
     updateThemeIcon();

-    if (window.matchMedia) {
-      window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
+    if (globalThis.matchMedia) {
+      globalThis.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
         if (!localStorage.getItem('theme')) {
           document.documentElement.classList.toggle('dark', e.matches);
           updateThemeIcon();
         }
       });

Based on learnings, this repository intentionally prefers globalThis over window for environment-agnostic JavaScript and SonarCloud compliance.

Also applies to: 124-125

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/js/app.js` at line 117, Replace all instances of `window.matchMedia` with
`globalThis.matchMedia` in the theme media-query handling section. This change
should be applied to the three occurrences in the conditional checks for color
scheme preference detection (the check for `(prefers-color-scheme: dark)` and
related media queries at lines 117, 124, and 125). Update each
`window.matchMedia` call to use `globalThis.matchMedia` instead to maintain
consistency with repository conventions.

Sources: Learnings, Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@index.html`:
- Line 83: Replace the `window.matchMedia` reference with
`globalThis.matchMedia` on line 83 where the color scheme preference is being
checked. This change aligns with the project's static analysis expectations and
eliminates linter warnings. Locate the line containing the condition
`window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches`
and update both occurrences of `window` to `globalThis` to ensure consistency
with the project standards.

In `@src/js/app.js`:
- Line 117: Replace all instances of `window.matchMedia` with
`globalThis.matchMedia` in the theme media-query handling section. This change
should be applied to the three occurrences in the conditional checks for color
scheme preference detection (the check for `(prefers-color-scheme: dark)` and
related media queries at lines 117, 124, and 125). Update each
`window.matchMedia` call to use `globalThis.matchMedia` instead to maintain
consistency with repository conventions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c987dad3-556b-4da2-ac07-47464f194655

📥 Commits

Reviewing files that changed from the base of the PR and between 2262547 and cc7780e.

📒 Files selected for processing (2)
  • index.html
  • src/js/app.js
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-06-15T18:15:28.688Z
Learnt from: arghya29
Repo: S3DFX-CYBER/GSoC-Org-Finder- PR: 1882
File: src/js/footer.js:33-33
Timestamp: 2026-06-15T18:15:28.688Z
Learning: In this repo’s JavaScript (e.g., footer.js), `globalThis` is intentionally preferred over `window` to keep code environment-agnostic and to satisfy SonarCloud static analysis. The project targets modern browsers (ES2021) with no transpilation, so `globalThis` is fully supported—do not flag `globalThis` usage as a browser compatibility concern or suggest replacing it with `window` during review.

Applied to files:

  • src/js/app.js
🪛 GitHub Check: SonarCloud Code Analysis
src/js/app.js

[warning] 124-124: Prefer globalThis over window.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ73500adr37K3w57TlM&open=AZ73500adr37K3w57TlM&pullRequest=1953


[warning] 125-125: Prefer globalThis over window.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ73500adr37K3w57TlN&open=AZ73500adr37K3w57TlN&pullRequest=1953


[warning] 117-117: Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ73500adr37K3w57TlK&open=AZ73500adr37K3w57TlK&pullRequest=1953


[warning] 117-117: Prefer globalThis over window.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ73500Zdr37K3w57TlJ&open=AZ73500Zdr37K3w57TlJ&pullRequest=1953


[warning] 117-117: Prefer globalThis over window.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ73500adr37K3w57TlL&open=AZ73500adr37K3w57TlL&pullRequest=1953

index.html

[warning] 83-83: Prefer globalThis over window.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ7351DQdr37K3w57TlO&open=AZ7351DQdr37K3w57TlO&pullRequest=1953


[warning] 83-83: Prefer globalThis over window.

See more on https://sonarcloud.io/project/issues?id=S3DFX-CYBER_GSoC-Org-Finder-&issues=AZ7351DQdr37K3w57TlP&open=AZ7351DQdr37K3w57TlP&pullRequest=1953

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 24, 2026
@github-actions github-actions Bot added type:devops gssoc26 GirlScript Summer of Code 2026 and removed gssoc26 GirlScript Summer of Code 2026 labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 TENET Agent Review

📋 Summary

This pull request introduces support for automatically detecting and respecting the user's operating system theme preference (dark/light mode). It prioritizes user-saved preferences in localStorage, falls back to system preference, and dynamically updates the theme if the system preference changes during a session. The changes are implemented in index.html for early FOUC prevention and in app.js for comprehensive theme initialization and dynamic updates. Additionally, it includes minor updates to GitHub workflows for PR classification and review job configuration. The approach is sound and addresses the stated problem effectively.

🔐 Security Findings

No security issues found.

🧹 Code Quality

  • program-classification-validator.yml - The multiple body.includes checks for various program classifications could be refactored for better readability and maintainability, perhaps by using an array of patterns or a regular expression.
  • src/js/app.js - The if (window.matchMedia) check is repeated before the event listener. While harmless, it could be slightly cleaner by assigning the matchMedia result to a variable once and then checking that variable.

✅ What's Done Well

  • FOUC Prevention: The early script in index.html effectively prevents Flash of Unstyled Content by applying the theme before the main application script loads.
  • Robust Theme Logic: The theme logic correctly prioritizes user-saved preferences over system preferences and provides a clear fallback mechanism.
  • Dynamic Theme Updates: The addition of an event listener for prefers-color-scheme changes ensures a seamless user experience when the OS theme is toggled during a session.

📝 Overall Verdict

APPROVE - The feature is well-implemented, addresses the problem, and introduces no security concerns.


Review powered by TENET Agent 🛡️ | Triggered automatically on PR #1953

@coderabbitai
coderabbitai Bot requested a review from Neilblaze June 24, 2026 04:36

@cubic-dev-ai cubic-dev-ai 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.

2 issues found and verified against the latest diff

Confidence score: 3/5

  • In index.html, the theme bootstrap puts localStorage access and matchMedia fallback in the same try, so if storage access throws, OS-theme detection is skipped and users can get the wrong initial theme flash/state—split the error handling so matchMedia still runs when storage is unavailable before merging.
  • Theme resolution is currently duplicated across index.html and src/js/app.js, with an additional inline block in index.html that ignores OS preference, which increases drift risk and can cause inconsistent theme selection between first paint and app startup—consolidate to a single shared resolution path (or make all paths honor the same precedence) before merging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="index.html">

<violation number="1" location="index.html:78">
P1: OS-theme fallback is skipped when localStorage access throws because the matchMedia check is inside the same try block.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread index.html
Comment thread index.html
@github-actions github-actions Bot added the gssoc26 GirlScript Summer of Code 2026 label Jun 24, 2026

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread .github/workflows/program-classification-validator.yml
@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

✅ Merge Conflicts Resolved

Thanks @desireddymohithreddy0925, this PR is mergeable again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

1 participant