Repository navigation
Studio: keep replaced replies out of ShareGPT exports - #10941
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: ea8a41ef0c
ℹ️ 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".
| return ( | ||
| format !== "jsonl-raw" && | ||
| format !== "jsonl-messages" && | ||
| format !== "sharegpt" |
There was a problem hiding this comment.
Export the branch selected in the live thread
When a user uses the branch picker to return to an earlier reply and then exports ShareGPT, this setting does not export the branch currently on screen. loadConversationMessages rereads storage, while orderBySelectedBranch chooses sorted.at(-1) as the head (message-order.ts:58); branch-picker navigation does not update message timestamps or persist a selected head. Consequently both single and bulk ShareGPT exports silently contain the newest-created branch instead of the displayed one, potentially training on the reply the user navigated away from. Pass the live selected branch/head into the exporter or persist branch selection rather than inferring it from creation time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct catch, fixed in 229e08a. The branch picker only moves the head in memory, so the exporter now takes the displayed head from the open thread and walks the parent chain from there, falling back to the newest branch when the thread is not open or that head is not saved yet. Training JSONL and Message JSONL had the same gap on main and use the same path, so they are covered too. The new tests in sharegpt-export-branches.test.ts fail on ea8a41e and pass on 229e08a.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 229e08a1c3
ℹ️ 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".
| let currentId: string | null = | ||
| headId != null && byId.has(headId) ? headId : (sorted.at(-1)?.id ?? null); |
There was a problem hiding this comment.
Avoid exporting a fallback branch while the live head is pending
When ShareGPT is exported immediately after regenerating or editing a turn, the new branch's history append can still be pending: exports remain enabled during runs (thread.tsx:6057-6059), and listStoredChatMessages does not wait for that append (chat-history-storage.ts:718-747). In that window the live head is absent from byId, so this fallback selects the newest stored leaf—often the rejected reply—and silently puts it back into the training export. Wait for pending history writes or use the nearest persisted ancestor of the live branch instead of falling back to an unrelated leaf.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct catch, fixed in 86fc432. A regenerated reply is saved only when its run finishes, so the exporter now walks back to the newest saved turn of the branch on screen instead of falling back to the newest leaf. While an edited first prompt is still unsaved it exports nothing from the old branch. A closed thread still follows the newest branch. The two new cases in sharegpt-export-branches.test.ts fail on 229e08a and pass on 86fc432.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86fc4325f1
ℹ️ 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".
| if (!hasParentIds) return raw; | ||
| return orderByParentChain(raw, { includeSiblings }) as typeof raw; | ||
| // Newest saved turn of the branch on screen: a reply still generating is not stored yet, and falling back to the newest leaf would export the reply it replaces. | ||
| const liveBranch = liveThreadBranch(threadId); |
There was a problem hiding this comment.
Capture the selected branch before awaiting storage
When an export is started from a branch-picked thread and the user switches chats before listStoredChatMessages finishes, this lookup runs against the newly displayed thread and returns null for the exported ID. Since that storage read includes backend requests, the race can be long enough to hit in normal use; headId then becomes undefined, so ShareGPT and Training/Message JSONL silently fall back to the newest stored leaf and can export the rejected reply. Capture the live branch before the asynchronous storage read so the export remains tied to the branch selected when it was initiated.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct catch, fixed in bd516c9. The live branch is now read before the storage request, so switching chats while the export loads no longer points the lookup at another thread. The new case in sharegpt-export-branches.test.ts switches the chat during the read; it fails on 86fc432 and passes on bd516c9.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
Review + GitHub Actions UI evidencePinned head:
Real Studio flow, same harness on every leg (fresh upstream
Controls held on every leg: 3 stored rows, picker 2/2 → 1/2, first reply on screen. The same legs were also run in isolated Modal containers with identical facts. What Export chat actually downloaded. The Studio screen is the same on every leg (reply 1/2, "Apples", is picked); this PR changes only the downloaded files:
PR head Fixed head Tests. Each new case in |
|
Confirmed this hits ndjson.ts where exportFormatIncludesSiblings still returns true for sharegpt, so regenerated and edited turns end up in the exported training file. Will get this reviewed. |
BeforeOn merge base AfterHead Real Studio runs used Ling-3.0-tiny-Q6_K through a local llama.cpp CUDA server on an RTX 5060 Ti:
VerdictConfirmed issue, fixed by the existing head. No additional defects found. Regression checks99 focused tests plus five additional edge cases pass on head and merge. Coverage includes legacy conversations, empty live branches, inactive threads, disposed views, multi-turn branch selection, unsaved replies and switching chats during export. CSV retains every branch in real downloads; Markdown export tests pass. Base, head and merge builds pass. Head typecheck and focused ESLint pass. CompatibilityLinux x86_64, Node 26.8.2, Python 3.14.4, Playwright 1.62.0, NVIDIA driver 595.91.07. Browser downloads verified on base and head in Chromium 151.0.7922.34, Firefox 153.0, Google Chrome 153.0.8010.36 and Microsoft Edge 153.0.4234.32, at 1280×900. UI evidenceCaptured and inspected five before/after pairs. The chat looks the same; the footer annotations show the actual downloaded contents. Full report, browser screenshots, downloaded files, commands and test logs. FixesNo repair commits needed. Reviewed head: |
mahiatlinux
left a comment
There was a problem hiding this comment.
LGTM! Ready to merge, all manually checked.



Exporting a chat as ShareGPT included replies you had regenerated and prompts you had edited, with nothing to mark them. Training on that file teaches the model the replies you rejected. The Training JSONL export already left them out.
ShareGPT export now includes only the version of the chat you see, like Training JSONL. Markdown and CSV exports still include every version.
Tested in the real Studio UI with Qwen3-0.6B. After regenerating a reply and after editing a prompt, the ShareGPT export on main held the old turns and on this branch held only the current chat. New tests cover both cases and fail on main, with no other new failures.