Repository navigation
Anchor studio source slices on declarations, not on comment text - #10297
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 765f54c072
ℹ️ 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".
| and took 93 tests here down with it, none of which were about anything it changed. | ||
| Anchor on the declaration or statement the comment sits above instead. | ||
| """ | ||
| if marker.lstrip().startswith(("//", "/*")): |
There was a problem hiding this comment.
Reject JSX comment anchors too
When test_project_chat_view_switch._provider_jsx() passes its existing end marker " {/* The view stays mounted", this predicate does not recognize the JSX comment prefix and therefore permits the same brittle comment-based slicing this change is intended to prevent. Rewording or removing that comment will still break the test, so the validation should also reject JSX comments such as {/* ... */}.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, and I missed it: my scan looked for // and /* and never for {/*, so both the guard and the sweep had a hole exactly where JSX lives.
The guard now rejects {/* as well, and the two JSX-comment anchors that existed are converted:
test_project_chat_view_switch._provider_jsx()ends on{children}.test_desktop_reliability_frontend_contractends on the<DiffusionTrainPanelbranch. Worth noting the naive choice was wrong there:{pageMode === "train" ? (on its own first matches 3.4k characters BEFORE the comment, which would have quietly shortened the header slice rather than failing. Pinning the two lines together is unique and lands where the comment did.
Battery: rewording either JSX comment passes, while dropping {children} from the provider and flipping the images header's divider rule both fail.
|
@codex review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
#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.
…rd (unslothai#10307) `Repo tests (CPU)` was red on `main` at `99a83f6a6` and `a2a4143ce`, and so on PRs branched from them, on one test out of 15,899: ``` FAILED tests/studio/test_auth_form_input_count.py::test_auth_flow_routes_do_not_mount_global_settings assert 'if (!active || !mounted) return null;' in mount ``` unslothai#10237 gave `SettingsDialogMount` a second surface, so the single lazy-mount flag became two: ```diff - const [mounted, setMounted] = useState(open || monitorOpen); - if (!active || !mounted) return null; + if (!active || !(settingsMounted || monitorMounted)) return null; ``` That is right and it did not open the auth routes. `!active` still short-circuits, so an inactive mount still renders nothing, which is the whole of what this test is named for. The other two assertions in the test still match byte for byte, so the chain it protects, auth route to `active={false}` to nothing rendered, is intact at every link. The assertion had simply quoted the auth gate and the lazy-mount bookkeeping as one string. ## The change Assert the property rather than a spelling: `SettingsDialogMount` must return null from its own top level on every inactive render. The guard is read as a parse, because a textual match is what got us here: - Comments and string bodies are blanked first, in a same-length copy so indices still line up. The assertion this replaces matched `// if (!active || !mounted) return null;` just as happily as the live line, so the guard could have been struck out entirely and the test would have stayed green. - The slice is the real function body. The signature is `({ active }: { active: boolean })`, so the body brace is found by walking the parameter list rather than taking the first brace after the name. - Only statements directly in that body count, so `(active) => { if (!active) return null; }` cannot answer for the component. - The condition must be a disjunction whose first operand is `!active`. A top-level `?` or `,` disqualifies it, since both bind looser than `||`: `!active || mounted ? false : true` and `!active || track(), active` each leave the disjunction as a discarded sub-expression and skip the return while inactive. `?.` and `??` are neither. - `{ return null; }` is accepted alongside `return null;`, so a bracing pass does not go red for nothing. This is the same shape as unslothai#10267, unslothai#10231, unslothai#10289 and unslothai#10297. The file had already reached that conclusion twice on its own, as "Lock the count, not the spelling, so a rename does not falsely fail" and "Lock the behaviour, not one spelling of it, so either form passes". This assertion had not had the treatment. ## Verified by breaking it The predicate was checked directly against 15 conditions, all correct. Then fifteen edits to `settings-dialog-mount.tsx`, each run against the test, next to what a plain re-sync of the literal would give: | edit | re-synced literal | this change | | --- | --- | --- | | baseline | passed | passed | | both mount flags renamed | **failed** | **passed** | | a third surface joins the mount | **failed** | **passed** | | the operands reordered | **failed** | **passed** | | back to a single flag, as before unslothai#10237 | **failed** | **passed** | | optional chaining in the second operand | **failed** | **passed** | | the guard braced by a formatter | **failed** | **passed** | | the `!active` half dropped | failed | failed | | `||` becomes `&&` | failed | failed | | the whole guard deleted | failed | failed | | the gate inverted to `active` | failed | failed | | a ternary swallows the disjunction | failed | failed | | a comma expression discards the disjunction | failed | failed | | the guard moved into a nested callback | failed | failed | | the guard survives only as a comment | **passed** | **failed** | Six harmless forms pass where a re-sync goes red on all six, none of which touches the auth routes. Nine real regressions fail. The last row is the one that matters most: a re-sync, and the assertion that was there before it, both accept a guard that exists only as a comment. `tests/studio`: 7483 passed, 195 skipped. No source changes. Staging CI green.
* 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.
Repo tests (CPU)is red onmainat553fdf8b6, and so on every PR branched from it, with 93 failures out of 15,899:Almost all of them are one line in the harness:
#10114 is right, and it changed no behaviour at all
studio/frontendcarries no JS test runner, so these tests slice the real source verbatim into a node harness and run it. The slices are delimited by markers, and a lot of those markers were comments.#10114 trimmed comments across 245 frontend files. That comment now reads
and four others the tests named were removed outright. Not one line of behaviour moved, and 93 tests went red.
A comment is prose about the code, not the code. It is exactly the thing a maintainer is free to reword, and a comment-only PR is the clearest possible case of a change these tests should not be able to see. They failed the one kind of edit they should have been blind to.
The change
Anchor the slices on the declaration or statement the comment sat above, not on the comment. 29 anchors across 12 files, including ones that still happen to match today and would have broken on the next trim.
return slice_between( read(RUNTIME), " const confirmedStatus = await getInferenceStatus().catch(() => null);", - " // Block queue materialization before taking the cancellation snapshot.", + " const lifecycleLease = useChatRuntimeStore", )Each replacement was checked against the source as it stood immediately before #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 between it and the marker it replaces. So every slice covers the same statements it covered before, and each new anchor occurs exactly once in the file it is read from.
slice_betweennow refuses a comment as an anchor rather than failing later withsubstring not foundseveral frames away:Re-syncing the literals is the obvious alternative and it is what the table below argues against: it gets
maingreen today and goes red again on the next comment edit, which is the same edit #10114 made.Verified by breaking it
Thirteen edits to
studio/frontend, each run against the test file that reads it. Comment-only edits must pass, real regressions must still fail:Three of those started out as bad mutations of mine that passed when they should have failed, which is the check working.
Next to what a plain re-sync of the literal would give, on the anchor that took 56 of the 93 down:
tests/studio: 7483 passed, 195 skipped. No source changes.