Skip to content

Condense comments added since the last cleanup: Studio frontend and Tauri - #16109

Merged
danielhanchen merged 10 commits into
mainfrom
trim-comments-r2-frontend
Nov 9, 2026
Merged

danielhanchen merged 10 commits into
mainfrom
trim-comments-r2-frontend

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Condenses the multi-line comments, docstrings and JSDoc / block comments that landed in the Studio frontend (studio/frontend) and the Tauri shell (studio/src-tauri) after the last cleanup (#12966, #12967, #12968, #12969, #15333, #15594). Same rules as before: every fact a reader needs stays (the reason for a workaround, version bounds, shapes and dtypes, env vars and flags, issue numbers, must / never rules, ordering and security reasons); narration, step-by-step restatement and history go. Informative one-line comments are not touched.

No code changes: every changed file has an identical code token stream (and, for Python, an identical AST once docstrings are removed).

109 files, +343 / -582 lines.

Scope

Only sections of 2+ lines whose lines were mostly written after the last cleanup merged. A rewrite is applied only when it saves at least one line, so tight comments are left as they are.

Left untouched:

  • section delimiters, license / SPDX headers, tool directives (noqa, type: ignore, eslint-disable, @ts-expect-error, biome-ignore, shellcheck, #region, ...), PowerShell comment-based help, JSX {/* */} comments
  • Python docstrings that can be read at runtime (decorated routes / tools / commands, pydantic models, classes outside tests, anything in a file that reads __doc__; module docstrings only where a reader analysis over the whole repo found no reader)
  • scripts that read their own text back ($0 / BASH_SOURCE / $PSCommandPath / __file__)
  • any comment containing a string literal that a test or source-reading script searches for, in a file that reader names (including escaped multi-line literals)
  • any comment inside a span that a frontend test regex matches in the source it reads
  • the line scripts/lint_av_shapes.py keys its baseline on
  • helpers that exist in more than one file (the shared install.ps1 / studio/setup.ps1 functions, a few Python helpers): every copy keeps the same comments, since tests compare the copies as text

Verification

  • comment_tools.py check --strict-ext --allow-docstring-edits passes on every changed file (code tokens identical, all languages).
  • Delimiter and tool-directive comment sequences are identical in every changed file.
  • scripts/lint_*.py (av_shapes, exec_literals, risky_loaders, workflow_triggers, no_parallel_clamp, no_duplicate_ts_imports, duplicate_definitions, backend_python_floor) and ruff check give the same result on main and on this branch.
  • CLI help: every --help surface (41 unsloth CLI commands, 40 scripts with a parser) is byte-identical to main.
  • Tests (no GPU), main vs all five round-2 branches together, compared by failing test ID: Studio backend tests that read source text (69,853 tests), root and unsloth_cli tests that read source text (41,578 tests), and every frontend node test (14,542 tests). No test fails only on the branch once ordering effects are rerun alone; the real readers this and staging CI turned up (a sidebar layout regex, the av_shapes baseline line, and the test that compares the install.ps1 / studio/setup.ps1 helpers) are handled by keeping those comments verbatim. Functions that were identical across files on main (PowerShell, shell, Python) are still identical on the branches.
  • PowerShell and shell tests that name install.ps1, studio/setup.ps1 or the changed shell test (64 files, run with pwsh / bash): all pass on main and on the branches.
  • Each rewrite was reviewed for meaning lost or claims added, removals in files that other files read were checked for readers, and proposed corrections went through a second check; anything flagged without a confirmed correction keeps its original text.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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 ⚠️ Failed 2026-10-30T11:35:52.896690Z
We couldn’t complete this review. Comment @codex review to try again.
af350c9 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.

danielhanchen added a commit that referenced this pull request Oct 30, 2026
… guards (#16116)

#15973 (add customizable chat background images and effects) left 12
frontend unit tests red on main. Every PR's `Frontend unit tests` and
`Frontend build + bundle sanity` jobs fail on them, for example #16109,
#16110 and #16112. This fixes 11 of the 12. The last one is the titlebar
`:has()` on the document root, which needs a product change and goes in
its own PR.

## 1. General Settings token sync (9 tests)

```
not ok - an untouched General Settings tab adopts a token changed in another tab   (and 8 more in the file)
  error: 'no stub for import "@/features/chat-background" in .../settings/tabs/general-tab.tsx'
```

`general-tab.tsx` now imports `resetChatBackground` from
`@/features/chat-background` for Reset all preferences. The test's stub
map was one module behind, so this adds `"@/features/chat-background": {
resetChatBackground: async () => true }`.

## 2. Every page loads the polyfill (1 test)

```
smoke-chat-background.html must load /crypto-boot.js
```

The new smoke page skipped the `crypto.randomUUID` polyfill that every
other page loads before its module entry. It now carries the same
`<script src="/crypto-boot.js"></script>`.

## 3. Toasts and composers read one shadow variable (1 test)

```
:is([data-wallpaper-workspace], [data-chat-content-root]):has(> .chat-wallpaper[data-ready]) .unsloth-composer-surface, .wallpaper-preview-composer uses the shared shadow
  actual: 'inset 0 0 0 1px var(--border)'   expected: 'var(--composer-shadow)'
```

The wallpaper composer draws an outline instead of a drop shadow, which
is a deliberate design. It now sets that through the variable rather
than around it: `--composer-shadow: inset 0 0 0 1px var(--border);
box-shadow: var(--composer-shadow);`. The "Composer outline" off rule
sets `--composer-shadow: none`, and its `:has()` is more specific, so it
still wins. Nothing reading `--composer-shadow` sits inside the composer
surface, so the override reaches nothing else.

## Verification

- Frontend suite: on main, 12 failures across those four files. Here,
`general-settings-token-sync` 9/9, `crypto-uuid-boot` 4/4,
`toast-composer-shadow` 2/2 and `chat-background` 7/7 pass. The one
remaining failure is `titlebar-modal-layering`'s document-root `:has()`,
as described above.
- Rendering on `smoke-chat-background.html`, driven the way
`tests/studio/playwright_chat_background.js` drives it (reset, upload an
image, toggle Composer outline):
- Computed `box-shadow` of both preview composers and the live composer
is `oklch(0.9208 0 0) 0px 0px 0px 1px inset` with the outline on and
`none` with it off, on main and here alike.
- A screenshot pixel diff in the same tree, with only `index.css`
swapped, is 80 / 26 pixels for outline on / off. Main against main is 71
/ 26, so that is the run-to-run noise floor and there is no visible
change.

## Screenshots

Chat background settings with an uploaded image on this branch. Composer
outline on: the previews and the live composer keep the 1px outline.

![Composer outline
on](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/16116/g_head_on_q-3049b6fa235e.png)

Composer outline off: no outline and no shadow, as on main.

![Composer outline
off](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/16116/g_head_off_q-de3798d52bfb.png)
danielhanchen added a commit that referenced this pull request Oct 30, 2026
…zoo 2026.10.10 (#16114)

`pip scan-packages :: studio` (and `:: extras`) now fails on every PR
whose closure resolves torch 2.15.0 (released 2026-10-28) or botocore
1.43.122 (released 2026-10-29), and `pip scan-packages :: hf-stack` on
every PR that resolves unsloth-zoo 2026.10.10 (released 2026-10-28).
Examples are #16109 and #15994 in staging:

```
Summary: 1 CRITICAL, 4 HIGH
  HIGH      torch  torch/_inductor/compile_worker/subproc_pool.py   same matched code, file digest outside the pin
  HIGH      torch  torch/_inductor/standalone_compile.py            same matched code, file digest outside the pin
  HIGH      torch  torch/_precompile.py                             1 matched line(s) appended to a reviewed file
  CRITICAL  torch  torch/testing/_internal/common_utils.py          the flagged code was rewritten
  HIGH      torch  torch/_vendor/quack/epilogue/library.py          (new site)
  CRITICAL  botocore  botocore/httpsession.py                       the flagged code was rewritten
```

I read each site in the shipped file. For torch I checked the v2.15.0
sources against the wheel's pinned file digests, and for botocore I read
the 1.43.122 wheel.

| Site | What the scanner matched | Verdict |
|---|---|---|
| `torch/_inductor/compile_worker/subproc_pool.py` | `time.sleep(3600)`
and `subprocess.Popen(` of the compile workers, byte-identical to the
reviewed entry. Only the lines moved, so the pinned file digest changed.
| benign, new pin |
| `torch/_inductor/standalone_compile.py` | `exec(compile(python_code,
"<compile_to_python>", "exec"), namespace)`, identical to the reviewed
entry and one line lower. | benign, new pin |
| `torch/_precompile.py` | The same `exec(compile(python_code,
"<precompile>", "exec"), module_ns)`, plus one more commented usage
example `# exec(open("this_file.py").read(), ns)`. | benign |
| `torch/testing/_internal/common_utils.py` | The DOTALL reverse-shell
pattern spans the file from `import socket` on L32, so any edit moves
its digest; every torch release has had its own entry. The only socket
use is `find_free_port`, which binds `localhost:0` and returns the port.
"connect" appears only in error strings, and there is no `dup2`,
`pty.spawn`, `/bin/sh` or `webbrowser`. | benign |
| `torch/_vendor/quack/epilogue/library.py` (new) | `_gen_epi_fn`
compiles and execs a generated epilogue `def`. `params` and `body` are
fixed fragments chosen by boolean flags, and `activation` is only a key
into a fixed map. The file documents the reason: the generated signature
lets absent operands compile out of the kernel. Nothing external reaches
the source. | benign |
| unsloth-zoo `compiler.py` | One matched line was added:
`compile(looped, "<peft lora forward>", "exec")` in
`_patch_lora_update`. It checks that PEFT's own forward source still
parses after a string replacement, then falls back if it does not. The
code object is discarded and nothing is executed. The other matched
lines are unchanged. | benign |
| unsloth-zoo `llama_cpp.py`, `mlx/loader.py`, `mlx/speculative.py`,
`temporary_patches/moe_utils.py`, `vllm_utils.py` | Byte-identical
matched code. Only the pinned file digest moved. | benign, new pins |
| `botocore/httpsession.py` | The env read is the opt-in `SSLKEYLOGFILE`
TLS key log. The `conn.urlopen(...)` call gained
`enforce_content_length=False` and an optional per-request timeout
through `extra_kwargs`. | benign |

## Change

I added the new entries (six for torch and botocore, six for
unsloth-zoo) next to the existing ones for each file and removed
nothing. The earlier entries stay, so shards that still resolve older
torch and botocore are unaffected. I did not regenerate with
`--write-baseline`: it writes only what the current scan sees, so a
partial scan would have dropped every other package's entries. The
pinned sites keep pins (`file_sha256`) at their new file digests.

dnspython 2.9.1 also showed up in one run, but it scans clean on its own
against this baseline, so it needs no entry.

## Verification

- `scripts/scan_packages.py torch==2.15.0`: on main `1 CRITICAL, 4 HIGH`
with exit 1, the same result as the CI runs. On this branch it exits 0.
- `scripts/scan_packages.py botocore==1.43.122`: on main `1 CRITICAL`
with exit 1. On this branch it exits 0.
- `scripts/scan_packages.py unsloth-zoo==2026.10.10`: on main `1
CRITICAL, 5 HIGH` (the CI hf-stack result). On this branch it exits 0.
- The tests that read the scanner or its baseline: 638 passed.
danielhanchen added a commit that referenced this pull request Oct 30, 2026
…load (#16130)

## Problem

`Frontend build + bundle sanity` fails intermittently at the `Titlebar
modal blur and window controls (Chromium)` step on unrelated PRs (seen
on #15994, #16091 and the staging run for #16109). Every time it is the
same shape: all modal checks pass, then the final `assert not errors`
trips on

```
504: http://127.0.0.1:5491/node_modules/.vite/deps/sonner.js?v=...
504: http://127.0.0.1:5491/node_modules/.vite/deps/zustand.js?v=...
```

with no page error logged. The smoke records every script, stylesheet or
font response at 400 or above. When the Vite dev server re-optimizes its
dependencies mid-load, it answers in-flight requests for the replaced
pre-bundles with `504 Outdated Optimize Dep` and then reloads the page.
That response is Vite's reload signal, not a missing asset, and the page
checks after it pass. It depends on runner timing, so it does not
reproduce on demand (a cold cache and the CI step order both passed
locally).

## Fix

- `tests/studio/_playwright_robust.py`: `is_vite_outdated_dep(response)`
matches exactly status 504 with the status text `Outdated Optimize Dep`.
Vite's other 504, `Optimize Deps Processing Error`, is a real failure
and still counts.
- `tests/studio/playwright_titlebar_blur.py`: the asset response guard
skips only that response. A 404, a 500 or a processing-error 504 is
still recorded and still fails the smoke.
- `tests/studio/test_vite_outdated_dep.py` pins this:
  - the predicate's truth table;
- that the smoke's guard keeps the exemption as a single `and not ...`
term;
- that the installed Vite still sends that status text, so a rename
upstream shows up here instead of as a dead exemption.

## Verification

- New tests pass (8 passed, the Vite source check included).
- Sabotage:
- With the predicate reduced to `status == 504`, two rows fail (the
processing-error and gateway-timeout cases).
  - With the exemption removed from the smoke, the guard test fails.
- In a real Chromium page served by a small HTTP server, Playwright
reports `status_text == "Outdated Optimize Dep"` for the first response,
and the predicate is true only there. It is false for `Optimize Deps
Processing Error`.
- `python3 tests/studio/playwright_titlebar_blur.py` passes with the
change.
danielhanchen added a commit that referenced this pull request Nov 1, 2026
…te for one archived result (#16401)

## Summary

`Frontend build + bundle sanity` (Linux) and `Frontend unit tests
(Windows)` fail on PRs based on current main. Staging CI shows it for
#16109, #16110 and #16112, all in the `data_settings` Playwright driver:

```
File "tests/studio/playwright_data_settings.py", line 705, in run_library_locales
AssertionError: Locator expected to contain text 'This permanently deletes 1 archived chats and their messages. This cannot be undone.'
Actual value: Delete chatThis permanently deletes "Sample 0" and its messages. This cannot be undone. ...
```

#16390 (`4726a1c1b8`) changed the archived chats dialog on purpose. When
exactly one chat is selected, it now shows the single-chat description,
which names the chat (`shell.dialog.deleteChat.description`), instead of
"1 archived chats". Its description lists this ("Archived chats: one
chat (now names the chat instead of reading "1 archived chats")"). The
driver still expected the bulk wording with `{count}` = 1.

## Change

`run_library_locales` now also reads
`shell.dialog.deleteChat.description` from each locale's catalog. For
the one-result delete, it expects that string with `{name}` = `Sample
0`, the one archived chat left after the No project filter.

## Testing

On this host, Chromium, same frontend tree, `python
tests/studio/playwright_data_settings.py`:

- main's driver: exit 1 with the same `AssertionError` as CI;
- this branch: exit 0, `chromium: 183 Data settings checks passed`,
across all 12 locales the driver walks.
danielhanchen added a commit that referenced this pull request Nov 6, 2026
… memo tests (#16908)

## Summary

`Repo tests (CPU, studio)` has been failing on unrelated PRs since
#16793 landed, always in the same test with a different parameter each
time:

```
tests/python/test_preference_chunked_logprobs.py:278: in test_matches_trl
    torch.testing.assert_close(g, w, rtol = 1e-4, atol = 1e-6)
E   AssertionError: Tensor-likes are not close!
E   Mismatched elements: 1 / 32 (3.1%)
E   Greatest absolute difference: 3.814697265625e-06 at index (0, 6) (up to 1e-06 allowed)
```

Seen on the staging runs for #16109, #16886, #16882 and #16877 today
(`cpo-kwargs1`, `kwargs2`, `kwargs3`, `kwargs5`, `kwargs6`, always
`qwen3_lora`).

The cause is test pollution. #16793 added
`test_load_probe_memo.py::test_fastmodel_adapter_load_probes_base_config_once`,
which runs `FastModel.from_pretrained` up to the weights. That load does
what it does in real use: it swaps PEFT's LoRA forwards
(`peft.tuners.lora.layer.Linear` and 8 other LoRA layer classes) for
Unsloth's, process-wide, and sets `UNSLOTH_FORCE_FLOAT32`,
`UNSLOTH_FULLGRAPH`, `UNSLOTH_RETURN_LOGITS` and `UNSLOTH_MODEL_NAME`.
The test never puts them back, so when xdist schedules the CPO parity
test on the same worker later, it compares the chunked path against TRL
on Unsloth's LoRA forward instead of stock PEFT, and its tight gradient
tolerance trips. The swapped forward is the part that matters: restoring
only the environment variables still fails with the same numbers,
restoring only the forwards passes.

Neither side's product code is wrong. #16793's loader change and its
probe-count assertions are correct; only the test leaks process state.

## Change

Tests only.

- `tests/python/test_load_probe_memo.py`: an autouse fixture records
every PEFT LoRA layer class's own `forward` and the `UNSLOTH_*`
variables before each test and puts them back after. A PEFT module first
imported during the load falls back to the `_unsloth_original_forward`
the wrapper carries.
- `tests/python/test_preference_chunked_logprobs.py`:
`test_matches_trl[...-qwen3_lora]` pins stock PEFT forwards for its
duration (through `monkeypatch`), since its reference is TRL on stock
PEFT. This keeps it deterministic whatever else ran earlier in the
worker.

## Testing

The failing worker's exact history from a local rerun of the CI shard
(`-n 4 --dist loadgroup`) replayed serially reproduces the CI failure
with the same numbers, and bisects to the #16793 test. With that test
followed by `test_matches_trl[cpo-kwargs1-qwen3_lora]`:

| | result |
|---|---|
| main | 1 failed (`3.814697265625e-06 at index (0, 6)`, as in CI) |
| this branch | 2 passed |
| this branch, parity test pin removed | 2 passed |
| this branch, probe memo fixture disabled | 2 passed |
| this branch, both removed | 1 failed (same numbers) |

The same failing worker's history replayed serially (1595 tests) on this
branch: `test_matches_trl[cpo-kwargs1-qwen3_lora]` passes. On main the
same replay fails it. One other failure in both arms,
`test_cached_paths_hold_no_credentials.py::test_model_cache_variables_are_not_treated_as_credential_homes`,
comes from this machine's environment; it passes in CI and is unchanged
here.

Both touched files pass in full: `tests/python/test_load_probe_memo.py`
plus `tests/python/test_preference_chunked_logprobs.py`, 33 passed
(torch 2.10.0+cpu, transformers 5.17.0, TRL 1.15.0, PEFT 0.21.2, the CI
shard's versions).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant