Skip to content

Condense comments added since the last cleanup: installers, scripts and CI - #16112

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

danielhanchen merged 9 commits into
mainfrom
trim-comments-r2-scripts

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 installer helpers, scripts and CI (studio/*.py, studio/scripts, scripts/, .github, docker) 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).

50 files, +669 / -1,747 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:36:07.045239Z
We couldn’t complete this review. Comment @codex review to try again.
3a467bd 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 Nov 1, 2026
## Summary

`tests/studio/test_en_catalog.py::test_the_shipped_catalog_resolves`
fails on main since #16390 (`4726a1c1b8`, "say chats and projects are
permanently deleted in delete dialogs"). It shows up in
`workflow-trigger lint` on every PR based on current main, for example
staging CI for #16112:

```
assert en_string("shell.dialog.deleteChat.description").endswith('"{name}"?')
AssertionError: 'This permanently deletes "{name}" and its messages. This cannot be undone.'.endswith('"{name}"?')
```

#16390 reworded the dialog on purpose, from `Are you sure you want to
delete this chat "{name}"?` to `This permanently deletes "{name}" and
its messages. This cannot be undone.` The product is right. The test is
a smoke check that the catalog reader resolves a real nested key, and it
pinned the old sentence ending.

## Change

The assertion now checks that the resolved string still carries the
`"{name}"` placeholder, which is what the dialog needs, not how the
sentence ends. A comment says why. The other two checks in the test are
unchanged.

## Testing

- `tests/studio/test_en_catalog.py`: 1 failed on main, 44 passed here.
- Sabotage: with `"{name}"` removed from the `deleteChat.description`
string in `en.ts`, the test fails again.
- No other test reads the old copy (`git grep` over `tests/` and
`studio/backend/tests` for the old sentences finds nothing).
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 24, 2026
… again (#19245)

## Keep scan_packages.py clear of Bitdefender's Python stealer signature
again

`scripts/scan_packages.py` on main is flagged again on VirusTotal as
`Generic.PY.STEALER.B`, the same detection #12169 fixed in September.
Bitdefender, and every engine that ships its signatures, quarantines the
file on a contributor's machine.

### What changed

Comments only. The comment trim in #12969 shortened several comment
blocks near the top of the file; that is what brought the detection
back. This restores those comments (the 28 edits above the anti-analysis
patterns) and keeps the rest of the trim. The parsed code is identical
to main (same `ast.dump`), so behaviour does not change.

One line is added above `_joined` noting that trimming the comments
there re-triggered it, so the next cleanup rescans the file.

### Evidence (VirusTotal, fresh uploads, 2026-11-24)

| Version of `scripts/scan_packages.py` | Detections |
|---|---|
| After #12169 (Sep 27) and after #12884 (Oct 6) | 0 |
| After #12969 (Oct 26) | 8: ALYac, Arcabit, BitDefender, Emsisoft,
GData, MicroWorld-eScan, VIPRE `Generic.PY.STEALER.B`; CTX
`script.spyware.generic` |
| main today (after #16112) | the same 8 |
| main with the top 28 comment edits reverted | 0 |
| This PR | 0 / 72 (sha256
`29cb47f1b33b57815d75a1a76476c53b068ce452068c8569d10ea2f949b968af`) |

Bisecting the 110 comment edits between #12884 and main: applying only
edits 55 to 110 stays clean, while several small subsets of edits 0 to
21 each bring the detection back on their own. The detection reacts to
how much comment text separates the pattern tables near the top of the
file, not to any single word.

### Tests

- `tests/security/test_scan_packages.py`,
`tests/security/test_lint_av_shapes.py`,
`tests/test_scripts_write_lf.py`: 181 passed.
- `scripts/lint_av_shapes.py`: 0 new errors. Pre-commit ruff clean.

### Not covered

- Engines can change their signatures at any time; this is clean against
today's.
- Other files were not affected: the installers, setup scripts,
uninstallers, `studio/install_*.py` helpers and `scan_npm_packages.py`
on main are all 0 detections today.
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