Skip to content

studio/frontend: correct Think pill aria-label before model loads - #5655

Merged
danielhanchen merged 6 commits into
mainfrom
mh/aria-think-label-when-disabled
May 22, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
mh/aria-think-label-when-disabled

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

  • The composer Think pill's aria-label reads "Disable thinking" before a model loads, even though the button is disabled and visibly OFF (the LightbulbOffIcon variant is shown, data-active="false").
  • Root cause: reasoningEnabled defaults to true in the chat-runtime store (chat-runtime-store.ts:350,467), so effectiveReasoningEnabled is true on first paint -- and the aria-label falls through to the effectiveReasoningEnabled ? "Disable thinking" : "Enable thinking" branch without considering the disabled (model-not-loaded) gate above it.
  • Fix: insert a disabled branch between reasoningLockedOn and effectiveReasoningEnabled so the label reads "Thinking (model not loaded)" while the button is unreachable. Once the model is loaded, the existing enable/disable copy resumes. Same fix applied to the equivalent pill in shared-composer.tsx (where the disabled flag is named reasoningDisabled).
  • Surfaced by a screen-reader-style probe over the welcome page. Users heard "Disable thinking" on a grayed-out unclickable button, which contradicts the visible state.

Test plan

  • Open Studio without a loaded model, focus the Think pill, run a screen reader (or check via DevTools Accessibility tree) -- the label should now read "Thinking (model not loaded)" instead of "Disable thinking".
  • Load a model, verify the label flips to "Enable thinking" (default off) or "Disable thinking" (after the user toggles it on).
  • For a reasoning-locked-on model (e.g. GPT-5 or similar where supportsReasoningOff is false), verify the label stays "Thinking is required for this model".
  • Compose mode (shared-composer): same three states.

`reasoningEnabled` defaults to true in the chat-runtime store, so on a
fresh /chat with no model the Think pill renders disabled + visually
off (LightbulbOffIcon, data-active="false"), but its aria-label still
reads "Disable thinking" -- screen readers announce it as if the
button is currently on. Add a `disabled` branch between
reasoningLockedOn and effectiveReasoningEnabled so the label reads
"Thinking (model not loaded)" while the button is unreachable, then
falls through to the normal enable/disable copy once a model is
loaded. Apply the same fix to the equivalent pill in shared-composer
(where the disabled flag is named `reasoningDisabled`).

@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: e60a8bbca2

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

Comment on lines +706 to +707
: disabled
? "Thinking (model not loaded)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Distinguish unsupported reasoning from unloaded model

This new disabled branch conflates two different states in ReasoningToggle: disabled is true both when no model is loaded and when the loaded model does not support reasoning (const disabled = !(modelLoaded && effectiveSupportsReasoning)), so screen readers now hear "Thinking (model not loaded)" even for loaded non-reasoning models. That introduces an incorrect accessibility announcement and regresses state accuracy compared with the intended fix; the label should key off !modelLoaded specifically (or otherwise represent unsupported reasoning separately).

Useful? React with 👍 / 👎.

@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 updates the aria-label for reasoning toggles in thread.tsx and shared-composer.tsx to handle cases where reasoning is unavailable. Feedback indicates that the label "Thinking (model not loaded)" is misleading when a model is loaded but lacks reasoning support, and suggests differentiating between these states to provide more accurate accessibility feedback.

Comment on lines +706 to +710
: disabled
? "Thinking (model not loaded)"
: effectiveReasoningEnabled
? "Disable thinking"
: "Enable thinking"

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

The aria-label "Thinking (model not loaded)" is used whenever disabled is true. However, disabled is defined as !(modelLoaded && effectiveSupportsReasoning), which means it also covers cases where a model is loaded but simply doesn't support reasoning. In such cases, the label would be misleading for screen reader users. It's better to distinguish between the model not being loaded and the feature not being supported by the loaded model.

          : !modelLoaded
            ? "Thinking (model not loaded)"
            : disabled
              ? "Thinking (not supported)"
              : effectiveReasoningEnabled
                ? "Disable thinking"
                : "Enable thinking"

Comment on lines +996 to +1000
: reasoningDisabled
? "Thinking (model not loaded)"
: effectiveReasoningEnabled
? "Disable thinking"
: "Enable thinking"

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

Similar to the logic in thread.tsx, the aria-label "Thinking (model not loaded)" is applied whenever reasoningDisabled is true. Since reasoningDisabled includes models that are loaded but lack reasoning support, this label can be inaccurate. Splitting the condition provides more precise accessibility feedback.

                    : !modelLoaded
                      ? "Thinking (model not loaded)"
                      : reasoningDisabled
                        ? "Thinking (not supported)"
                        : effectiveReasoningEnabled
                          ? "Disable thinking"
                          : "Enable thinking"

@danielhanchen

Copy link
Copy Markdown
Member Author

Targeted fix is correct. Verified by installing this PR head into a temp Studio workspace and probing with Playwright:

  • No model loaded → Think pill aria-label="Thinking (model not loaded)", disabled=true, data-active="false". Exactly as intended. ✓
  • malicious_check.py: clean.
  • Both thread.tsx (uses disabled) and shared-composer.tsx (uses reasoningDisabled) are updated symmetrically.

One follow-up edge case I'd flag (not introduced by this PR, but the new wording makes it more visible):

The condition disabled = !(modelLoaded && effectiveSupportsReasoning) is also true when the model is loaded but doesn't support reasoning. In that case the new label Thinking (model not loaded) is factually wrong. I reproduced this by loading unsloth/Llama-3.2-1B-Instruct-GGUF (Q4_K_M): after the green-dot in the header confirms the model is active, the Think pill stays grayed with aria-label="Thinking (model not loaded)", while Search/Code pills correctly transition to enabled.

Cheap follow-up (separate PR, since the scope here is only the "before model loads" case):

: !modelLoaded
  ? "Thinking (model not loaded)"
  : !effectiveSupportsReasoning
    ? "Thinking is not supported by this model"
    : effectiveReasoningEnabled
      ? "Disable thinking"
      : "Enable thinking"

For this PR's stated scope (resolves the contradictory Disable thinking on a grayed-out unclickable button in the welcome state), it's a clean fix.

… reasoning

Address review feedback on #5655 (chatgpt-codex-connector + gemini-code-assist
both flagged the same edge case):

The previous `disabled` branch labeled the Think pill "Thinking (model not
loaded)" whenever the button was disabled, but `disabled` is defined as
`!(modelLoaded && effectiveSupportsReasoning)` (in thread.tsx) and
`!modelLoaded || !effectiveSupportsReasoning` (in shared-composer.tsx).
Both cover the second case where a model IS loaded but does not support
reasoning at all (e.g. Llama-3.2-1B-Instruct), which mislabeled the pill
for screen-reader users.

Split the branch so the no-model case keeps "Thinking (model not loaded)"
and the loaded-but-unsupported case reads "Thinking (not supported by this
model)". Locked-on / enabled / disabled labels are unchanged.

Verified by re-running the Playwright probe:
- no model           -> aria-label "Thinking (model not loaded)"
- Llama-3.2-1B loaded -> aria-label "Thinking (not supported by this model)"
- reasoning-capable loaded, OFF -> "Enable thinking"
- reasoning-capable loaded, ON  -> "Disable thinking"
- locked-on model    -> "Thinking is required for this model"
@danielhanchen

Copy link
Copy Markdown
Member Author

Follow-up commit 97f9817 addresses the chatgpt-codex-connector + gemini-code-assist inline reviews (both flagged the same edge case).

The previous "Thinking (model not loaded)" label was applied whenever disabled was true, but disabled = !(modelLoaded && effectiveSupportsReasoning) also covers the case where a model IS loaded but does not support reasoning (e.g. unsloth/Llama-3.2-1B-Instruct-GGUF), where the label was factually wrong.

Split the branch in both thread.tsx and shared-composer.tsx:

reasoningLockedOn
  ? "Thinking is required for this model"
  : !modelLoaded
    ? "Thinking (model not loaded)"
    : disabled // or reasoningDisabled in shared-composer
      ? "Thinking (not supported by this model)"
      : effectiveReasoningEnabled
        ? "Disable thinking"
        : "Enable thinking"

States covered:

  • no model loaded -> "Thinking (model not loaded)"
  • model loaded, no reasoning support -> "Thinking (not supported by this model)"
  • model loaded, reasoning support, OFF -> "Enable thinking"
  • model loaded, reasoning support, ON -> "Disable thinking"
  • locked-on reasoning model -> "Thinking is required for this model"

tsc + bun run build clean. Bundle confirms both labels are present.

…pdown pre-load mislabel

Address review consensus on #5655:

1. Extract the duplicate 5-branch aria-label conditional into a shared
   helper `thinkToggleAriaLabel` (plus a parallel `thinkEffortAriaLabel`
   for the reasoning-effort dropdown). Both `thread.tsx` and
   `shared-composer.tsx` now import from
   `components/assistant-ui/think-aria-label.ts`.

2. While reviewing the diff, an Opus reviewer noticed the same
   conceptual bug existed in the reasoning-effort dropdown branch in
   `thread.tsx:627` (the alternate render path used by Claude-style
   models with effort levels): before a model loaded, the aria-label
   announced e.g. "Reasoning effort: medium" on a disabled, grayed-out
   button. Same contradiction as the original bug for the on/off
   toggle. Now routed through `thinkEffortAriaLabel`, which falls back
   to "Thinking (model not loaded)" / "Thinking (not supported by this
   model)" while the button is unreachable and only emits the effort
   label when the model is loaded and actually supports reasoning.

3. Locked-on stays intentionally absent from `thinkEffortAriaLabel`:
   the dropdown remains interactive in that case (users can still pick
   an effort level), so the per-level label is the right announcement.

Verified by bun run typecheck (clean) and bun run build (clean). Bundle
confirms all six label strings still ship.
@danielhanchen

Copy link
Copy Markdown
Member Author

Follow-up commit 7ccbdab applies the consensus from a 3-fork Opus review on the latest head:

  • Extracted the 5-branch aria-label conditional into a shared helper at studio/frontend/src/components/assistant-ui/think-aria-label.ts (thinkToggleAriaLabel + thinkEffortAriaLabel). Eliminates the verbatim duplication between thread.tsx and shared-composer.tsx, and clears the Biome nested-ternary complexity warning.
  • Fixed the parallel pre-load bug in the reasoning-effort dropdown (thread.tsx:627). One of the reviewers spotted that the alternate render path used by Claude-style effort-level models had the same conceptual bug as the original Think pill issue: before a model loaded, the aria-label announced e.g. "Reasoning effort: medium" on a grayed-out disabled button. The dropdown now routes through thinkEffortAriaLabel, which falls back to the same "Thinking (model not loaded)" / "Thinking (not supported by this model)" wording while the button is unreachable, and only emits the effort label when the model is loaded and supports reasoning. Locked-on intentionally not special-cased there because the dropdown stays interactive (users still pick effort).

tsc + bun run build clean. Bundle confirms all 6 label strings are still shipped.

…ffortAriaLabel

12/12 reviewers flagged that the earlier think-aria-label helper was only wired into thread.tsx; the parallel reasoning-effort dropdown in shared-composer.tsx still hard-coded the raw "Reasoning effort: medium" label, so screen readers heard a stale effort value when the control was disabled (no model loaded, unsupported reasoning).

Route shared-composer's effort button through the same helper, matching thread.tsx.
@danielhanchen

Copy link
Copy Markdown
Member Author

Follow-up 801f464 from a 12-reviewer sweep (reviewer.py, 8-persona+4-generic mode):

All 12 reviewers independently flagged the same asymmetric-fix bug: studio/frontend/src/features/chat/shared-composer.tsx:902 still hard-coded aria-label={Reasoning effort: ${reasoningEffort}} while the parallel control in thread.tsx was already routed through thinkEffortAriaLabel(...). So when the shared composer rendered the effort-style Think control while reasoningDisabled was true (pre-load, or unsupported reasoning), the visual was greyed out but screen readers still heard "Reasoning effort: medium".

Fix: route the shared composer effort button through the same helper:

aria-label={thinkEffortAriaLabel({
  modelLoaded,
  reasoningDisabled,
  reasoningEffort,
})}

Also merged origin/main into the branch (commit f2ab93d) to clear the stale-rebase report flagged by the reviewer pre-flight (398 silent reverts across 9 files, including anthropic_compat.py, test_anthropic_messages.py, chat-providers-dialog.tsx). Without the merge, the GitHub merge UI would have silently reverted those.

bun run typecheck + bun run build pass.

@danielhanchen
danielhanchen merged commit 4c26def into main May 22, 2026
33 checks passed
@danielhanchen
danielhanchen deleted the mh/aria-think-label-when-disabled branch May 22, 2026 12:02
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request May 22, 2026
Conflict in studio/frontend/src/features/chat/shared-composer.tsx:
took main's helper-based aria-labels (thinkEffortAriaLabel /
thinkToggleAriaLabel from unslothai#5655) since this branch never touched
the Think pill — they were left at the pre-helper inline strings
from before the divergence.
rsd-darshan pushed a commit to rsd-darshan/unsloth that referenced this pull request Jun 3, 2026
…slothai#5655)

* studio/frontend: correct Think pill aria-label before model loads

`reasoningEnabled` defaults to true in the chat-runtime store, so on a
fresh /chat with no model the Think pill renders disabled + visually
off (LightbulbOffIcon, data-active="false"), but its aria-label still
reads "Disable thinking" -- screen readers announce it as if the
button is currently on. Add a `disabled` branch between
reasoningLockedOn and effectiveReasoningEnabled so the label reads
"Thinking (model not loaded)" while the button is unreachable, then
falls through to the normal enable/disable copy once a model is
loaded. Apply the same fix to the equivalent pill in shared-composer
(where the disabled flag is named `reasoningDisabled`).

* studio/frontend: Think pill distinguishes !modelLoaded vs unsupported reasoning

Address review feedback on unslothai#5655 (chatgpt-codex-connector + gemini-code-assist
both flagged the same edge case):

The previous `disabled` branch labeled the Think pill "Thinking (model not
loaded)" whenever the button was disabled, but `disabled` is defined as
`!(modelLoaded && effectiveSupportsReasoning)` (in thread.tsx) and
`!modelLoaded || !effectiveSupportsReasoning` (in shared-composer.tsx).
Both cover the second case where a model IS loaded but does not support
reasoning at all (e.g. Llama-3.2-1B-Instruct), which mislabeled the pill
for screen-reader users.

Split the branch so the no-model case keeps "Thinking (model not loaded)"
and the loaded-but-unsupported case reads "Thinking (not supported by this
model)". Locked-on / enabled / disabled labels are unchanged.

Verified by re-running the Playwright probe:
- no model           -> aria-label "Thinking (model not loaded)"
- Llama-3.2-1B loaded -> aria-label "Thinking (not supported by this model)"
- reasoning-capable loaded, OFF -> "Enable thinking"
- reasoning-capable loaded, ON  -> "Disable thinking"
- locked-on model    -> "Thinking is required for this model"

* studio/frontend: extract Think pill aria-label helper, fix effort dropdown pre-load mislabel

Address review consensus on unslothai#5655:

1. Extract the duplicate 5-branch aria-label conditional into a shared
   helper `thinkToggleAriaLabel` (plus a parallel `thinkEffortAriaLabel`
   for the reasoning-effort dropdown). Both `thread.tsx` and
   `shared-composer.tsx` now import from
   `components/assistant-ui/think-aria-label.ts`.

2. While reviewing the diff, an Opus reviewer noticed the same
   conceptual bug existed in the reasoning-effort dropdown branch in
   `thread.tsx:627` (the alternate render path used by Claude-style
   models with effort levels): before a model loaded, the aria-label
   announced e.g. "Reasoning effort: medium" on a disabled, grayed-out
   button. Same contradiction as the original bug for the on/off
   toggle. Now routed through `thinkEffortAriaLabel`, which falls back
   to "Thinking (model not loaded)" / "Thinking (not supported by this
   model)" while the button is unreachable and only emits the effort
   label when the model is loaded and actually supports reasoning.

3. Locked-on stays intentionally absent from `thinkEffortAriaLabel`:
   the dropdown remains interactive in that case (users can still pick
   an effort level), so the per-level label is the right announcement.

Verified by bun run typecheck (clean) and bun run build (clean). Bundle
confirms all six label strings still ship.

* studio/frontend: route shared composer effort dropdown through thinkEffortAriaLabel

12/12 reviewers flagged that the earlier think-aria-label helper was only wired into thread.tsx; the parallel reasoning-effort dropdown in shared-composer.tsx still hard-coded the raw "Reasoning effort: medium" label, so screen readers heard a stale effort value when the control was disabled (no model loaded, unsupported reasoning).

Route shared-composer's effort button through the same helper, matching thread.tsx.

* studio/frontend: shorten think-aria-label helper comments

---------

Co-authored-by: danielhanchen <[email protected]>
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.

2 participants