Skip to content

Trim comments in studio/frontend chat, model picker and media features - #10114

Merged
danielhanchen merged 3 commits into
mainfrom
comment-trim-frontend-features
Sep 4, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
comment-trim-frontend-features

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Comment-only pass over 247 files under studio/frontend/src/features: chat, model-picker, images, video and audio.

before after change
comment lines 16,643 11,674 -29.9%
comment characters 1,131,625 920,568 -18.7%

What changed

Removed: restatements, section banners, spacer lines, per-consumer enumerations and measured tables whose conclusion is already stated. Long rationale paragraphs are rewritten to the claim plus at most one number or citation.

Every non-pragma comment line is at or under 120 columns. Three lines remain longer and are all functional: two biome-ignore directives in research-api.ts and one eslint-disable-next-line in chat-page.tsx.

Safety

Nothing outside comments changes. No code, string literals, licence headers or pragmas are touched.

JSX comment expressions have their text shortened in place and are never removed, since deleting the braces removes an AST node. Verified with an AST code-only signature of every file against the base commit; all 247 report code unchanged (comments only).

Why this cut is smaller than the backend ones

About 3,400 of the surviving comment lines are JSDoc. JSDoc is visible in editor tooltips and IntelliSense, so these blocks are shortened but never deleted; removing them would be an API surface change rather than a comment cleanup. That places a floor on this directory that the backend PRs do not have.

One pre-existing defect fixed in passing

chat-runtime-store.ts had an unterminated JSDoc block in the base commit, which swallowed text up to the next block terminator. It is replaced with a well formed two line block.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 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-04T09:22:13.074600Z d2e487a Draft marked ready
ℹ️ 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
danielhanchen marked this pull request as draft September 1, 2026 03:05
@danielhanchen

Copy link
Copy Markdown
Member Author

Moving this to draft. A check that was not run before opening it has now been run, and it fails.

Every verification behind this PR looked at what survived: the AST gate proves no code changed, the length rule proves no comment line is over 120 columns, and reading the diff shows sensible comments. None of those can see a fact that was dropped while a comment was being shortened, because the result still reads as a complete, well formed comment.

Measuring the other direction, comparing distinctive facts in the base commit's comments (identifiers, filenames, constants, issue references, measured values) against the text that survives, this PR has lost a material fraction of them. Sampling the losses with their original context shows they are not restatements that were correctly removed. Examples of the class:

  • write_bytes truncates first, so one shared directory lets a concurrent leg clobber another
  • n_tokens = 4096 and token_id=128009 survive redaction, which is the assertion's whole point
  • the mirror to /api/chat/settings is a 400ms debounce
  • token caches under $HF_HOME, ~/.netrc and XDG config are dropped from the child environment

These are the invariants and measured values the code cannot state, and they are exactly what the pass was supposed to protect.

I am running a restoration pass over the affected files and will push an update and mark this ready for review once the fact retention is measured and above threshold. Nothing here should be merged in its current state.

The underlying lesson, which is worth more than this PR: a comment-reduction pass cannot be validated by inspecting its output. It has to be validated by sampling what it discarded and what it rewrote, against the original.

@danielhanchen
danielhanchen force-pushed the comment-trim-frontend-features branch from 778f42c to dd054c4 Compare September 1, 2026 03:45
Comment-only pass over 247 files under studio/frontend/src/features:
chat, model-picker, images, video and audio.

16,643 -> 11,674 comment lines (-29.9%)
1,131,625 -> 920,568 comment characters (-18.7%)

Every non-pragma comment line is at or under 120 columns. Three lines
remain longer, all of them functional and untouchable: two biome-ignore
directives in research-api.ts and one eslint-disable-next-line in
chat-page.tsx.

Nothing outside comments changes: no code, string literals, licence
headers or pragmas. JSX comment expressions have their text shortened in
place, never removed, since deleting the braces removes an AST node.
Verified with an AST code-only signature of every file against the base
commit.

The reduction here is smaller than in the backend PRs for a structural
reason. About 3,400 of the surviving comment lines are JSDoc, which is
visible in editor tooltips and IntelliSense, so the blocks are shortened
but never deleted. Removing them would be an API surface change rather
than a comment cleanup.

One pre-existing defect is fixed in passing: chat-runtime-store.ts had an
unterminated JSDoc block in the base commit that swallowed text up to the
next block terminator. It is replaced with a well formed two line block.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b42a3bbdd3

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

// Gemini ships grounded search on chat-capable models. Most image-tier ids reject text-tool
// wiring, but Google documents it on the Gemini 3 image family, so allow only there.
// Custom Gemini OpenAI-compat proxies skip the native translator, so hide the pill.
// Output comes back inline as executableCode / codeExecutionResult parts.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Describe web-search output instead of code-execution parts

Remove or relocate this sentence because executableCode and codeExecutionResult are Gemini code-execution parts, not the output of the googleSearch capability documented by this branch. The backend tracks googleSearch through grounding metadata in external_provider.py, while those two parts are translated only by the code-execution path, so this comment gives maintainers the wrong protocol contract when changing web-search gating.

Useful? React with 👍 / 👎.

let mcpImages: McpImageToolResult | null = null;
if (mcpImgIdx !== -1) {
// The backend uses the same dir when there is no session_id; see tools.py _get_workdir.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Keep the sandbox-directory note beside the fallback ID

Move this note back to the later sandboxSessionId || "_default" fallback. This branch only parses an MCP image envelope and neither reads a session ID nor selects a working directory, so the newly inserted comment falsely suggests that _get_workdir is an invariant of MCP image parsing and obscures why this conditional exists.

Useful? React with 👍 / 👎.

Comment on lines +392 to +393
// the already-trusted LTX-2 base for the VAE / Gemma3 encoder) plus the GGUF quants, which
// keep the ~50 GB encoder in bf16 so consumer GPUs route to GGUF. Keyed on the artifact that

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Attribute the BF16 encoder burden to single-file artifacts

Rewrite this sentence so the relative clause refers to the BF16/FP8 single-file checkpoints rather than the GGUF quants. Those single-file artifacts retain the roughly 50 GB encoder in BF16, which is the reason consumer devices route to the separate GGUF artifact; the new wording instead says the GGUF variants carry that burden and then concludes that users should route to them, reversing and internally contradicting the catalog's routing rationale.

Useful? React with 👍 / 👎.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: d2e487a755

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

@danielhanchen
danielhanchen marked this pull request as ready for review September 4, 2026 09:14
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@danielhanchen
danielhanchen merged commit 7580935 into main Sep 4, 2026
35 of 40 checks passed
@danielhanchen
danielhanchen deleted the comment-trim-frontend-features branch September 4, 2026 09:14
danielhanchen added a commit that referenced this pull request Sep 4, 2026
Some tests locate a region of the frontend by indexing on a comment's
exact text, so to them a comment is an identifier and deleting one is
deleting a symbol. #10114 trimmed ten of them, and 71 tests in
tests/studio have been failing on main since it merged. Restored
verbatim from 7580935^, comments only.

Reflowing counts as deleting here. Most of these were not removed, they
were rewrapped onto one line or had a second line dropped, which reads
as harmless and breaks the lookup exactly the same way.

One was failing silently, which is worse. The deep research contract
splits the adapter on "// Project sources auto-scope" rather than
indexing it, and split does not raise when the marker is gone, it
returns the whole remainder. Four assertions were being checked against
about two thousand lines of unrelated source and passing. The suite was
green and proving nothing.

tests/studio: 7475 passed, 0 failed, from 7404 passed and 71 failed.
pull Bot pushed a commit to RealShocky/unsloth that referenced this pull request Sep 4, 2026
…lothai#10297)

`Repo tests (CPU)` was red on `main`, and so on every PR branched from it, with 93 failures out of 15,899. Almost all were one line in the harness, `slice_between` raising `ValueError: substring not found`.

`studio/frontend` carries no JS test runner, so these tests slice the real source verbatim into a node harness and run it. Many of the markers delimiting those slices were comments. unslothai#10114 trimmed comments across 245 frontend files, moving no behaviour at all, and 93 tests went red. A comment is prose about the code, not the code, and a comment-only PR is the clearest case of a change these tests should not be able to see.

This anchors the slices on the declaration or statement each comment sat above, 30 anchors across 14 files, including ones that still matched today and would have broken on the next trim. Every replacement was checked against the source as it stood immediately before unslothai#10114, where the old markers still resolve, and required to sit on the same side of the same code with nothing but comments and whitespace in between, so each slice covers the statements it covered before. Each new anchor occurs exactly once in the file it is read from.

`slice_between` now refuses a comment anchor outright, including the JSX `{/* ... */}` form, rather than failing later with `substring not found` several frames away.

One replacement was worth the care: the obvious end anchor for the images header, `{pageMode === "train" ? (`, first matches 3.4k characters BEFORE the comment it replaces, so it would have quietly shortened the slice and weakened the test rather than failing. Pinning it to the following `<DiffusionTrainPanel` line is unique and lands where the comment did.

Verified by breaking it. Seventeen edits to `studio/frontend`, each run against the test file that reads it: seven comment-only edits (trimming an anchor's own comment again, deleting one entirely, dropping a docblock, adding a new comment, rewording the two JSX comments, rewording the usage-examples comment) all pass, and ten real regressions all still fail. Three began as bad mutations of mine that passed when they should have failed, and were rewritten.

Next to what a plain re-sync of the literals would give, on the anchor that took 56 of the 93 down:

| | re-synced literal | this change |
| --- | --- | --- |
| baseline | 58 passed | 58 passed |
| that comment trimmed again | 56 failed, 2 passed | 58 passed |

A re-sync gets `main` green today and goes red again on the next comment edit, which is the same edit unslothai#10114 made.

`tests/studio`: 7483 passed, 195 skipped. No source changes. Staging CI green.
danielhanchen added a commit that referenced this pull request Sep 4, 2026
#10297 fixed this properly: the studio slice tests now anchor on the
declaration each comment sat above, and slice_between refuses a comment
anchor outright rather than failing several frames later. Restoring the
comment text only re-synced the literals, which goes red again on the
next trim, as that PR sets out.

This returns the branch to its one job, the facts #10114 dropped.
danielhanchen added a commit that referenced this pull request Sep 5, 2026
* Restore the facts the frontend comment trim reworded away

* Correct three restored facts that no longer matched the code

* Put back the comments the tests read as landmarks

Some tests locate a region of the frontend by indexing on a comment's
exact text, so to them a comment is an identifier and deleting one is
deleting a symbol. #10114 trimmed ten of them, and 71 tests in
tests/studio have been failing on main since it merged. Restored
verbatim from 7580935^, comments only.

Reflowing counts as deleting here. Most of these were not removed, they
were rewrapped onto one line or had a second line dropped, which reads
as harmless and breaks the lookup exactly the same way.

One was failing silently, which is worse. The deep research contract
splits the adapter on "// Project sources auto-scope" rather than
indexing it, and split does not raise when the marker is gone, it
returns the whole remainder. Four assertions were being checked against
about two thousand lines of unrelated source and passing. The suite was
green and proving nothing.

tests/studio: 7475 passed, 0 failed, from 7404 passed and 71 failed.

* Revert the anchor restorations, superseded by #10297

#10297 fixed this properly: the studio slice tests now anchor on the
declaration each comment sat above, and slice_between refuses a comment
anchor outright rather than failing several frames later. Restoring the
comment text only re-synced the literals, which goes red again on the
next trim, as that PR sets out.

This returns the branch to its one job, the facts #10114 dropped.
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