Skip to content

Read the sidebar pin's width only where matchMedia exists, and expect the update card's scaled width - #11700

Merged
danielhanchen merged 2 commits into
mainfrom
fix/sidebar-pin-without-matchmedia
Sep 23, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix/sidebar-pin-without-matchmedia

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Two checks are red on main (ebf2f2a5d). Both show on #11603, the first PR whose CI ran against a main with today's fixes.

1. Frontend unit tests: training-dataset-source-transitions.test.ts (product)

TypeError: window.matchMedia is not a function
    at loadPinned (src/hooks/use-sidebar-pin.ts:23:32)
    ...
    at async eval (src/components/tauri/window-titlebar.tsx:9:31)

This fails both Frontend build + bundle sanity and Frontend unit tests (Windows), and reproduces locally on main.

Cause: #11660 made use-sidebar-pin.ts read the (min-width: 1024px) query when the module is imported, via readStored() ?? window.matchMedia(WIDE_QUERY).matches. It never asks whether window.matchMedia exists. Frontend tests whose import graph reaches the window titlebar set a partial window with no matchMedia, so the import throws and the whole file fails.

Why fix the product rather than the test: the module already handles typeof window === "undefined" by keeping the desktop default. A read at import time that throws takes down every importer, not one call. It now asks through wideQuery(), which returns null when there is no matchMedia. The width default then falls back to pinned, the same as with no window, and subscribe skips the width listener. Browsers behave exactly as before.

New test: tests/sidebar-pin-without-matchmedia.test.ts has two cases:

  • Without matchMedia, the module imports, holds and releases.
  • With matchMedia, the lg query is still read, once on load and again on release.

Against main's hook, both cases fail.

2. Chat UI Tests (chat): the update card's width at 20px (test)

[banner] 921x534 at 20px: the card keeps its full width whatever the scrollbar does (cardLayoutWidth=597 want=448 ...)

Cause: #11648 made the card's max width calc(448px * var(--ui-space-scale, 1)). At the 20px UI size that is 448 * 1.25 / 0.9375 = 597.3px, which is what the page measured. The layout pass still wanted a fixed 448. It only reached this check once #11673 made the pass's font-scale probe readable. Before that, the 20px pass could not tell it was scaled.

Change: playwright_update_banner_layout.py reads --ui-space-scale through a length probe, the same way it now reads --ui-font-scale, and wants min(448 * scale, width - 32). At the default size the scale is 1, so the 448 check is unchanged.

Verification

  • Local:
    • tsc -b, vite build and bundle:check all pass, with 208.9 KB raw to spare.
    • npm test passes: 8,599 tests, 0 failed.
    • training-dataset-source-transitions.test.ts passes 9 of 9.
  • Not run locally: the Playwright banner pass needs a full Studio install. This PR's staging run of Chat UI Tests (chat) is what verifies it.

#11660 made use-sidebar-pin read the lg media query when it is imported,
without asking whether window.matchMedia exists. Frontend tests that reach
the window titlebar supply a partial window with no matchMedia, so the import
threw and failed training-dataset-source-transitions.test.ts on main.

With nothing to ask, keep the desktop default, as the module already does
when there is no window at all, and skip the width listener.
#11648 made the card's max width calc(448px * var(--ui-space-scale, 1)), so
at the 20px UI size it is 597px, and the layout pass still wanted 448. The
pass only reached that check once #11673 made its scale probe readable.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T15:45:18.966642Z cbdc4e7 Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: cbdc4e7101

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@danielhanchen
danielhanchen merged commit d79753c into main Sep 23, 2026
51 of 52 checks passed
@danielhanchen
danielhanchen deleted the fix/sidebar-pin-without-matchmedia branch September 23, 2026 17:01
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
… the update card's scaled width (unslothai#11700)

* Read the sidebar pin's width default only where matchMedia exists

unslothai#11660 made use-sidebar-pin read the lg media query when it is imported,
without asking whether window.matchMedia exists. Frontend tests that reach
the window titlebar supply a partial window with no matchMedia, so the import
threw and failed training-dataset-source-transitions.test.ts on main.

With nothing to ask, keep the desktop default, as the module already does
when there is no window at all, and skip the width listener.

* Expect the update card's scaled width at a larger UI size

unslothai#11648 made the card's max width calc(448px * var(--ui-space-scale, 1)), so
at the 20px UI size it is 597px, and the layout pass still wanted 448. The
pass only reached that check once unslothai#11673 made its scale probe readable.
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.

1 participant