Skip to content

fix(studio): equal padding in the dataset source segmented control - #7230

Merged
shimmyshimmer merged 2 commits into
mainfrom
fix/studio-dataset-source-tab-padding
Jul 19, 2026
Merged

shimmyshimmer merged 2 commits into
mainfrom
fix/studio-dataset-source-tab-padding

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Problem

On the Studio train page, the Dataset section has a Hugging Face / Local / Amazon S3 segmented control. Each button was forced to exactly one third of the track width with flex-1, and the sliding pill was hard coded to 33.3% width.

Since the three labels have very different lengths, the whitespace came out uneven: "Hugging Face" almost filled its pill while "Local" sat in a large empty segment, and the gaps between neighboring labels differed as well.

Fix

  • Buttons now use flex-auto instead of flex-1. Each button takes its label's natural width plus an equal share of the leftover track space, so the control still spans the full card width but the padding around every label and the spacing between buttons is now identical.
  • Since segments are no longer uniform width, the fixed 33% pill is replaced with a motion layoutId pill rendered inside the active button. The pill always matches the active button's true bounds and still animates smoothly between tabs.

This matches the pattern already used by ThemeSegmented in settings (same spring transition and reduced motion support), so the Studio control is now consistent with the rest of the app.

Testing

  • npm run typecheck passes
  • npm run build succeeds
  • Verified in a local Studio install that the pill hugs each tab and the spacing around all three labels is equal, including the two tab case for multimodal models where the S3 tab is hidden

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the sliding-pill segmented control in the DatasetSection component to use Framer Motion for smooth layout transitions, including support for reduced motion. The review feedback suggests using React's useId hook to dynamically scope the Framer Motion layoutId prop, which prevents potential animation conflicts and layout collisions if multiple instances of the component are rendered simultaneously.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { useNavigate } from "@tanstack/react-router";
import { motion, useReducedMotion } from "motion/react";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To prevent potential layoutId collisions when multiple instances of this component are rendered (e.g., during route transitions or in tests), we should scope the layoutId using a unique ID. Let's import useId from React.

import { motion, useReducedMotion } from "motion/react";
import { useId } from "react";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. Added useId in 3f2dedb, appended to the existing react import block instead of a separate import.

export function DatasetSection() {
const t = useT();
const navigate = useNavigate();
const reducedMotion = useReducedMotion();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Generate a unique ID for this component instance to scope the Framer Motion layoutId and avoid animation conflicts.

  const reducedMotion = useReducedMotion();
  const layoutId = useId();

Comment on lines +734 to +737
{datasetSource === item.value && (
<motion.span
aria-hidden="true"
layoutId="dataset-source-pill"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use the unique layoutId generated via useId to prevent layout animation conflicts across multiple instances of the segmented control.

Suggested change
{datasetSource === item.value && (
<motion.span
aria-hidden="true"
layoutId="dataset-source-pill"
{datasetSource === item.value && (
<motion.span
aria-hidden="true"
layoutId={"dataset-source-pill-" + layoutId}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 3f2dedb. Since useId is already unique per instance the pill uses it directly without a string prefix.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 3f2dedb1f2

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

@shimmyshimmer
shimmyshimmer merged commit 9073f07 into main Jul 19, 2026
41 checks passed
@shimmyshimmer
shimmyshimmer deleted the fix/studio-dataset-source-tab-padding branch July 19, 2026 04:08
VectorCipher pushed a commit to VectorCipher/unsloth that referenced this pull request Jul 20, 2026
…nslothai#7230)

* fix(studio): equal padding in dataset source segmented control

* fix(studio): scope dataset source pill layoutId per component instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant