Skip to content

fix: keep /web problem statements clear of the problem switcher - #1073

Merged
boomzero merged 3 commits into
devfrom
fix/problem-switcher-overlap-1072
Nov 22, 2026
Merged

boomzero merged 3 commits into
devfrom
fix/problem-switcher-overlap-1072

Conversation

@boomzero

@boomzero boomzero commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What does this PR aim to accomplish?:

Closes #1072 — on the new /web contest problem pages, the fixed problem switcher covers the left edge of the problem statement.

How does this PR accomplish the above?:

On the legacy pages the content sat in a centred container, leaving room on the left for the switcher. In the /web app, the problem view's .jumbotron spans the full width (live DOM: #app > div > .jumbotron > .xmoj-problem-body > .cnt-row), so the switcher sits on top of the statement.

  • After the switcher is mounted, its width is measured and stored as --xmoj-problem-switcher-width on #app; a ResizeObserver on the switcher re-measures it (font loading, media queries, viewport changes) and is disconnected when the route's AbortController aborts
  • #app .jumbotron { margin-left: var(--xmoj-problem-switcher-width, 0px); } (the variable is only set on problem pages) — the width is 0 when the switcher is hidden (e.g. the ≤768px rule in MonochromeUI), so nothing moves then
  • ClearRoute() removes the variable when leaving the page

One custom CSS rule is unavoidable here: Bootstrap has no class for clearing a fixed element of measured width.

Does this PR need a documentation update?:

No

Testing / not yet verified:

  • node --check XMOJ.user.js passes; the 12 non-browser tests pass (same as on dev)
  • The 5 Playwright tests were not run (no matching Chromium installed locally)
  • Not yet tested in a browser, so item 11 (all four UI combinations) is not verified — the review checkbox below is left unchecked until a maintainer QA-tests it. The switcher is only created on the /web problem pages, so the classic pages should be unaffected

By submitting this pull request, I confirm the following:

  1. I have read and understood the contributor's guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against. (dev for XMOJ-Script, master for everything else).
  2. I have commented on my proposed changes within the code.
  3. I have tested my changes.
  4. I am willing to help maintain this change if there are issues with it later.
  5. It is compatible with the GNU General Public License v3.0
  6. I have squashed any insignificant commits. (git rebase)
  7. I have checked that another pull request for this purpose does not exist.
  8. I have considered and confirmed that this submission will be valuable to others.
  9. I accept that this submission may not be used, and the pull request can be closed at the will of the maintainer.
  10. I give this submission freely and claim no ownership to its content.
  11. I have verified that my changes work correctly in all four UI combinations:
    • the script's monochrome UI on XMOJ's new UI (/web pages)
    • the script's monochrome UI on XMOJ's old/classic pages
    • the script's classic UI on XMOJ's new UI (/web pages)
    • the script's classic UI on XMOJ's old/classic pages

  • I have read the above and my PR is ready for review. Check this box to confirm

🤖 Generated with Claude Code

https://claude.ai/code/session_01JhQLfJB3LWW4vkNXK85xL1

Summary by Sourcery

Keep /web contest problem statements clear of the fixed problem switcher across layout changes.

Bug Fixes:

  • Prevent the fixed problem switcher from obscuring the left edge of problem statements on /web contest pages.

Enhancements:

  • Reserve responsive space for the problem switcher and clean up that layout state when navigating away.

Build:

  • Bump the project and userscript version to 4.0.7.

Summary by cubic

Keeps /web contest problem statements clear of the fixed problem switcher that previously covered the left edge of the statement (#1072). Bumps the project and userscript version to 4.0.7.

  • Measures the switcher after it mounts and applies its width as a left margin on the full-width problem view (#app .jumbotron); a ResizeObserver re-measures it whenever the width changes, including when fonts finish loading or a media query hides the switcher.
  • Clears the margin when leaving the route; it stays 0 while the switcher is hidden (e.g. on ≤768px screens), so the layout doesn't shift there.

Written for commit 2e6c748. Summary will update on new commits.

View guided diff Turn on auto-fix

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying xmoj-script-dev-channel with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2e6c748
Status: ✅  Deploy successful!
Preview URL: https://ce23b5b3.xmoj-script-dev-channel.pages.dev
Branch Preview URL: https://fix-problem-switcher-overlap.xmoj-script-dev-channel.pages.dev

View logs

@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

UI

Reserve measured space for the problem switcher in /web statements, and clear that layout state when the route ends.

  • XMOJ.user.js L3268-3272, L3510, L3793-3799

Configuration

Bump the userscript and package versions to 4.0.7 for this fix.

  • Update.json L4013-4023
  • XMOJ.user.js L3
  • package.json L3

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hendragon-bot hendragon-bot Bot added the user-script This issue or pull request is related to the main user script label Nov 22, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T14:07:22.550142Z af7c7fd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Nov 22, 2026

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

Sourcery assessment

Approved.

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

Hey - I've found 1 issue

Fixed security issues:

  • Cross-site scripting (XSS) via untrusted HTML/JS injection in web rendering sinks (link)
Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="XMOJ.user.js" line_range="3793-3794" />
<code_context>
                 });
                 document.body.appendChild(switcher);
+                const ReserveSwitcherSpace = () => root.style.setProperty("--xmoj-problem-switcher-width", switcher.offsetWidth + "px");
+                ReserveSwitcherSpace();
+                window.addEventListener("resize", ReserveSwitcherSpace, {signal: controller.signal});
             }
         }
</code_context>
<issue_to_address>
**Statement remains partly covered**

When the monochrome web font finishes loading after the switcher is measured, without a window resize, `ReserveSwitcherSpace` records the switcher’s fallback-font width at mount and only updates on window resize. When the web font changes the switcher’s width, the jumbotron margin stays too narrow and the switcher covers part of the statement.

Update the reserved space when the web font loads or when the switcher’s width changes.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: XMOJ.user.js:3794


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread XMOJ.user.js Resolved

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Update.json">

<violation number="1" location="Update.json:4014">
P2: This `4.0.7` entry was written by hand, but the repo's UpdateVersion automation owns version bumps and `Update.json` entries (see CLAUDE.md and README.md). Remove the manual version bump and its entry, and let the automation generate it, or add `//!ci-no-touch` if the manual bump is intentional.</violation>
</file>

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread XMOJ.user.js Resolved
Comment thread Update.json
],
"Notes": "No release notes were provided for this release."
},
"4.0.7": {

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.

P2: This 4.0.7 entry was written by hand, but the repo's UpdateVersion automation owns version bumps and Update.json entries (see CLAUDE.md and README.md). Remove the manual version bump and its entry, and let the automation generate it, or add //!ci-no-touch if the manual bump is intentional.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At Update.json, line 4014:

<comment>This `4.0.7` entry was written by hand, but the repo's UpdateVersion automation owns version bumps and `Update.json` entries (see CLAUDE.md and README.md). Remove the manual version bump and its entry, and let the automation generate it, or add `//!ci-no-touch` if the manual bump is intentional.</comment>

<file context>
@@ -4010,6 +4010,17 @@
             ],
             "Notes": "No release notes were provided for this release."
+        },
+        "4.0.7": {
+            "UpdateDate": 1795356391705,
+            "Prerelease": true,
</file context>

@github-actions
github-actions Bot force-pushed the fix/problem-switcher-overlap-1072 branch from d135d64 to f779edc Compare November 22, 2026 14:12

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

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

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

View guided diff | Turn on auto-fix | Re-trigger cubic

@sourcery-ai
sourcery-ai Bot dismissed their stale review November 22, 2026 14:20

Sourcery withdrew this approval because it has stopped reviewing this pull request.

@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Sourcery has withdrawn its approval of this pull request. It auto-reviews a pull request 5 times, and this push is past that limit, so the approval no longer reflects code Sourcery has read.

Comment @sourcery-ai review to get a fresh review, which can approve again.

Re-reviews, rate limits and approvals

The /web problem view spans the full width (#app > div > .jumbotron), unlike
the legacy page's centred container, so the fixed problem switcher covered
the left edge of the statement once the window was narrow enough. Measure
the switcher (with a ResizeObserver, so font loading, media queries and
window resizes are covered) and give the jumbotron a matching left margin;
the width is 0 while the switcher is hidden and is cleared on route change.

Closes #1072

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JhQLfJB3LWW4vkNXK85xL1
@boomzero
boomzero force-pushed the fix/problem-switcher-overlap-1072 branch from 6939462 to f0c9676 Compare November 22, 2026 14:22
@boomzero
boomzero merged commit b2da604 into dev Nov 22, 2026
7 checks passed
@boomzero
boomzero deleted the fix/problem-switcher-overlap-1072 branch November 22, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S user-script This issue or pull request is related to the main user script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant