Repository navigation
Studio: fork a chat from its row menu - #11564
Conversation
Forking was reachable only from a message inside the open thread. Add Fork to the chat row menu, under Mark as unread, and group the menu so what acts on the row is set off from what reaches outside it.
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: 3c57cab52d
ℹ️ 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".
Fork stayed enabled on a streaming row, where the last stored message is the prompt or a half-written reply, so the copy ended mid-answer. It now takes the row's isGenerating, the way the message-level Fork takes thread.isRunning. Reopening the menu and picking Fork again before the first request landed posted a second, each with its own thread id. The in-flight store moves out of thread.tsx so the row menu and the thread share one flag.
|
Both findings were right, and both are fixed in 39fc80d. Fork on a generating row. The item checked only whether the row was a comparison, so Fork stayed live while a reply was streaming. Duplicate forks. There was no in-flight guard, so reopening the menu and picking Fork again before the first request landed posted a second, each with its own thread id, and the two navigations raced. Rather than give the row menu a second flag of its own, Running the full suite caught a third thing worth mentioning:
@codex review |
…11561) * Studio: drag sidebar rows in the desktop app, and drop the drag hint Sidebar rows were wired to the HTML5 drag API, which the desktop webview never forwards to the page, so no row could be dragged there. Rebuild the gesture on pointer events, and take out the label that followed the cursor. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Keep the edge scroll going, and let one pointer own the drag Edge scrolling ran off pointermove alone, so a pointer resting on the edge took one step and stalled, and the cue stayed on the row that had slid away. A frame loop drives it now and re-aims as the list moves. The window handlers also answered every pointer, so a finger could drive and drop a drag the mouse started, which is what touch is kept out of. Each one now answers only the pointer that pressed the row. --------- Co-authored-by: Unsloth <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39fc80d4db
ℹ️ 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".
…no git (#11565) Qwen-Image-2.1 refuses to load with "needs diffusers >= 0.41.0 ... this environment has diffusers 0.40.0" on installs that did nothing wrong. The pinned main build is a git+https requirement, and install_python_stack skips that step non-fatally when _has_working_git() is false. The desktop bundle ships no git, and on macOS `git` is frequently a bare xcrun shim that exits non-zero, so the skip fires for a large share of desktop installs and the only visible sign is one note during a long dependency pass. Reproduced end to end with the shipped bundles, git shimmed to exit 1: installing 0.1.811 leaves diffusers 0.40.0, and updating to 0.1.812 leaves it at 0.40.0 as well, so reinstalling the app does not repair it. With a working git both land on 0.41.0.dev0 at the pinned commit. Nothing in that step actually needs git: the same commit is a zip over plain https. _github_archive_url derives it from the requirement, so there is still one commit written down in one place, and the git clone stays the default because it records a ref. The derivation is deliberately narrow (github.com, full 40 character commit, no subdirectory) because an archive records no ref of its own, so only a SHA in the URL identifies the tree afterwards. _direct_reference_is_installed has to read that back or the fallback works exactly once. Measured: the archive install reads as absent to a vcs_info-only check, _diffusers_main_supersedes_release then says the release pin was not superseded, and the next pass reinstalls 0.40.0 straight over it. The refusal message also pointed at `pip install -r diffusers-main.txt`, which resolves the same git URL and fails identically for the most likely cause. It now names git as the thing to check and quotes the zip, read out of the pin file so it cannot drift from the commit that is installed. Verified on a real git-less install: the dependency pass logs "diffusers main (no git, from archive)", diffusers ends at 0.41.0.dev0 with direct_url.json recording the pinned commit's archive, _diffusers_main_resident() is True against it, and a second forced pass leaves it in place.
The disabled state reads runningByThreadId, which is this tab's memory: empty after a reload and blind to a second tab. A chat generating in either case passed it and forked to the prompt, or to a reply still being written. The click now checks the backend snapshot chat-api calls authoritative, and an unreachable backend falls back to the local map rather than blocking every fork. A chat that is still generating is reported as a refusal, not a failure.
|
Right again, and fixed in e853e2a. I checked the claim before acting and
So the previous fix only closed the same-tab case. A chat generating in a second tab, or one whose tab was reloaded mid-generation, still reached The click now reads the backend snapshot and refuses if the thread is in It stays at the click rather than in the One thing I added beyond the finding: a chat that is still generating is a refusal, not a failure, so it no longer surfaces as "Failed to fork". The error carries
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e853e2aa0e
ℹ️ 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".
A client snapshot cannot close this: another tab can start a generation between the check and the POST, and the route forked regardless. It now refuses with a 409, which is the only guard inside the request that forks. The client check moves after the message read so it covers the read that chose the tip, and a 409 is reported as a refusal rather than a failure.
|
Right, and I was wrong to try to close this from the client. Fixed in 145fda0. The route now refuses with a 409 when the thread it is asked to fork has a generation in flight, read from
Two things came out of implementing it. The client check stays, but it moved to after the message read rather than before it. The fork is anchored to whichever message id the read picked, so what matters is whether the tip was settled at that moment, not at the moment of the POST. Asked before the read, a prompt appended in between was invisible to it. Asked after, it covers the read that chose the tip. A 409 from the route is now reported as a refusal rather than a failure, matching the client-side refusal path. I also checked the case that would have made a blanket route refusal wrong, forking at an earlier message while a later turn streams, and it does not apply: the message-level Fork already disables itself on Backend: two tests in @codex review |
* Keep weight_decay when embedding_learning_rate is set Setting embedding_learning_rate routes optimizer creation through _create_unsloth_optimizer, which read the decay from optimizer_kwargs. transformers keeps the decay on the param groups and only puts it in optimizer_kwargs for schedule-free and stable_adamw, so the .get(..., 0.0) default always won: the run trained with no weight decay at all, silently, with the value the user set still on the config. _create_q_galore_optimizer in the same file already reads self.args.weight_decay. Read it from the config, and split the groups on Trainer.get_decay_parameter_names so restoring the decay does not start decaying biases and norm weights, which the path this replaces excludes. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop the empty param groups the four-way split creates The decay fix is right, but splitting non_embeddings and embeddings each into a decay and a no-decay group emits four groups where there used to be two, and on a LoRA run two of them are always empty: nothing trains a bias or a norm, so both no-decay groups come back with no params. An empty group is not free. AdafactorSchedule.get_lr reads group["params"][0] with no emptiness guard, so optim="adafactor" now raises IndexError. And torch's load_state_dict rejects a checkpoint whose group count differs from the optimizer's, so every run checkpointed before this stopped being resumable, even at weight_decay=0. Dropping the empty groups fixes both and costs nothing: the categories are logical, they do not have to each be a group. _create_q_galore_optimizer in this same file already guards its groups the same way. A LoRA run is back to the two groups it always had, in the same order and the same sizes, so old checkpoints load again. test_create_optimizer_model_arg asserted on param_groups[1] being empty, which was only ever incidental; it now asserts what it meant. * Tighten the comments on the decay fix Twelve comment lines to five. The two facts that are not visible from the code stay: transformers only puts weight_decay in optimizer_kwargs for schedule-free and stable_adamw, and an empty group breaks both AdafactorSchedule and resume. * Migrate a pre-split optimizer checkpoint instead of refusing it Splitting the decay out gives a model with trainable biases or norms more param groups than the two it was checkpointed with, and torch requires the counts and per-group sizes to match, so resume_from_checkpoint raised instead of continuing. Fixing only the optimizer moves the failure one line later into the scheduler, which overwrites base_lrs wholesale, so both are handled. The remap is exact rather than inferred: torch keys saved state by a parameter's position in the flat concatenation of its groups, and the old layout (non-embeddings then embeddings, each in named_parameters order) is reproducible from the model, so old position maps to parameter maps to new position one to one. Anything that is not exactly that old shape is refused and torch raises as before, because pairing a parameter with another parameter's moments would corrupt a run in silence where today it stops. A resumed run now also gets the decay it was configured with rather than the 0.0 the old checkpoint recorded. The two resume tests fail without this and pass with it; the third asserts the refusal and is a guard against a future over-eager migration rather than a regression test for this commit. * Key the migration on the group shape, and remap the plateau floors Two gaps in the previous commit, both reproduced. The migration was gated on the group COUNT differing, which misses the case where it does not. A model with no trainable embedding has a legacy layout of [all non-embeddings, empty embeddings] and a new one of [decayed, non-decayed]: two groups either way, different sizes, and torch rejects it on the size check instead. Gated on the shape now, so the count coinciding no longer hides it. reduce_lr_on_plateau also carries a per-group min_lrs. Expanding base_lrs and _last_lr but not that one let a two-element list replace a correctly sized one, and the next reduction raised once it walked the optimizer's groups. Both new tests fail without these and pass with them. * Offer every legacy checkpoint to the migration, and remap the scheduler by role Two more gaps, both silent rather than loud, both reproduced. A LoRA resume needs no reshaping because the old and new layouts coincide, so the migration was skipped and torch loaded the group hyperparameters from the checkpoint, including the weight_decay=0.0 this change exists to correct. The decay was silently off again for the most common shape there is. Every recognisably legacy checkpoint is offered to the migration now, not only the ones whose shape moved. The scheduler remap keyed on list length, and two entries can mean two things: with no trainable embedding both current groups are non-embeddings, so a saved [ordinary, embedding] pair is the same length yet handed the second group the embedding rate. Remapped by role instead, which is the identity whenever the roles already line up. Both new tests fail without these and pass with them. * Hook the scheduler on a subclass, not on the instance My own regression, and a worse one than the bug it sat next to. A scheduler's state_dict is its __dict__ minus the optimizer, so assigning the wrapper to the instance put an unpicklable closure into it: torch.save raised PicklingError on the FIRST checkpoint of any run with embedding_learning_rate set, whether or not anything was ever resumed. Overridden on a per-instance subclass instead, so it lives on the class and never reaches the state dict. isinstance and the class name are unchanged. The optimizer hook was never affected, since Optimizer.state_dict builds its result explicitly rather than from __dict__, and the test now saves both. Fails without this with PicklingError, passes with it. * Find the roles through the accelerate wrapper, and keep per-group optimizer state Two more, both reproduced, both silent. accelerator.prepare swaps self.optimizer for an AcceleratedOptimizer before create_scheduler runs, and that wrapper defines no __getattr__, so asking it for the recorded roles returned None and the scheduler hook quietly installed nothing on the ordinary training path. The lookup unwraps now. The test pins the absence of __getattr__ on the real class, so it stops passing if accelerate ever changes that. The migration also rebuilt each group from the freshly constructed one and restored only lr, which resets anything an optimizer keeps per group. Schedule-free holds its own progress there (k, weight_sum, lr_max), so the saved per-parameter state would have come back beside reset group state. The saved group is the base now, and only what deliberately changed, the params and the corrected weight_decay, is overridden. Both new tests fail without these and pass with them. * Remap the scheduler only when the optimizer says the checkpoint was legacy Length cannot tell a legacy [ordinary, embedding] pair from a current pair that is two non-embedding groups, which is what you get when embedding_learning_rate is set and no embedding is trainable. Remapping the latter copied the first group's value over the second, so distinct per-group min_lr floors written by this very code came back collapsed. transformers loads the optimizer before the scheduler, so the optimizer hook now records whether what it just saw was the old layout, and the scheduler remaps only then. The scheduler tests follow that same order, which is what the trainer actually does. Fails without this with min_lrs collapsing to the first floor. * Tighten the comments the review rounds accumulated Post-convergence pass. Six rounds of fixes left overlapping explanations, one of them sitting above a guard that had since moved. Comments and docstrings only, AST verified, 224 comment lines to 205 in this file. Every surviving line is a fact the code does not state: why the saved group is the base, why the hook is on a subclass, why the scheduler remap is gated on the optimizer, and why the lookup unwraps. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: danielhanchen <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 145fda02a2
ℹ️ 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".
Escape cancels while the button is still down, and the release comes later. The guard was armed at the keypress and torn down on the next tick, so releasing over the source row opened the chat the drag had just been cancelled out of. The gesture keeps its listeners through escape now. The release is what detaches, swallows the click and, being escaped, drops nothing. Co-authored-by: Unsloth <[email protected]>
A client cannot choose it safely. Checking activity before the read lets another tab append a prompt in between; checking after misses a generation that finishes in between, leaving the same dangling prompt as the tip. Either order has a round trip in the middle of it. The route resolves the tip itself now, straight after its own generation check, so messageId is optional and the row menu sends none. The message level Fork still names its own message.
|
Right, and it is the window I talked myself out of last round. Fixed in 1b20ded, but not by reordering again. The two findings so far point in opposite directions, and that is the useful part. Checking activity before the read lets another tab append a prompt in between, which is what the earlier comment caught. Checking after misses a generation that finishes in between, which is what this one catches. Both are true, because either order has a network round trip sitting in the middle of a read and a check that need to agree. So the client no longer picks the tip. This also took code out rather than adding more: Backend tests cover the tip being resolved to the last message, the 404 when a thread has none, and that the generation check runs first, the last one by making Two of my own tests pinned the client-side tip selection and had to be rewritten rather than loosened, since the behaviour genuinely moved. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b20ded99b
ℹ️ 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".
|
Promoted the accepted staging head The remaining generation-admission finding is fixed: The final changes preserve assistant replies with tied timestamps, legacy flat/mixed history, and the branch currently visible in an open chat. Closed chats still resolve their tip on the server. Existing explicit branches, settings, project membership, metadata detachment, comparison-row restrictions, shared duplicate-request protection, and sandbox warnings remain supported. The small refactor extracts the identical success notification into Executed validation on the accepted head:
Browser appearance was not verified; no screenshot evidence is claimed. The full upstream CI matrix was not rerun locally or used as a reason to repeat the completed review. |
mahiatlinux
left a comment
There was a problem hiding this comment.
LGTM! Ready to merge, all manually checked.
|
Correct finding, and I verified every step of it: No change needed though. It is already closed on main, by the version of this PR that merged, and closed better than the route-level check I had started on.
That works because Tests for it are on main as well: I had a route-level version of this ready and threw it away rather than send a redundant PR. |
Add the row-menu fork action with shared request protection. Serialize forks with durable chat and research runs, preserve legacy history and the selected branch, and share fork success notifications.
What this changes
Forking was reachable only from a message inside the open thread, so copying a chat meant opening it first and finding the message to fork from. A chat row's menu now carries Fork.
The menu was one run of items with a single rule before Archive. It now reads as three groups:
The fork itself
forkChatRowsits incomponents/chat-row-menu.ts, beside the rest of what a chat row's menu is made of, so the Projects page rows can take the same item later.It forks from the chat's last message and settles the chat's thread-scoped settings first. The fork copies
settings_jsoninside its own transaction, so a pill toggled moments ago and still inside the debounce would not be in the copy, and the fork would open on the modes the chat had before rather than the ones it has now. This is the same guard the thread's own Fork uses.The copy opens straight away, the same as forking from a message, and the container snapshot warning is carried into the toast when there is one.
Fork is disabled on a comparison row. A comparison is two threads and has no single tip to fork from.
Tests
npm run testpasses 8466.sidebar-row-actions.test.tsgains coverage for the placement under Mark as unread, the rule that follows it, the comparison guard, the settings settle before the copy, and opening the fork once it is made. Lint is unchanged from the baseline on every file touched.