Skip to content

Studio: clickable sidebar settings cog, long name truncation, Canvas menu opt-in - #7171

Merged
shimmyshimmer merged 9 commits into
mainfrom
studio-sidebar-settings-cog
Jul 16, 2026
Merged

shimmyshimmer merged 9 commits into
mainfrom
studio-sidebar-settings-cog

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

What

Started as a sidebar polish and grew into a set of small chat shell fixes: the account row settings cog is now a real control that opens settings directly, long profile names truncate instead of breaking layouts, and the Canvas chat menu item is hidden by default behind a settings opt-in.

Changes

Sidebar account row

  • The settings cog was a decorative aria-hidden span inside the account dropdown trigger. It is now a real <button> rendered as a sibling of the trigger (nested buttons are invalid HTML), absolutely positioned over the right edge of the row, following the same pattern as SidebarMenuAction. Clicking it opens the settings dialog directly via useSettingsDialogStore.getState().openDialog(); clicking the rest of the row still opens the account menu.
  • Circular hover treatment per existing icon button conventions (rounded-full, hover:bg-black/10, dark:hover:bg-white/10) plus a focus-visible ring and aria-label. As a native button it gains focus normally, so the dialog's captureOpener() focus restoration works.
  • The name column now has min-w-0 flex-1 and the trigger reserves right padding, so very long profile names truncate with an ellipsis instead of pushing the cog out of the row.

Welcome greeting

  • Names over 20 characters are capped with an ellipsis before being interpolated into the greeting line, so an unbroken long name no longer wraps the headline.

Canvas chat menu item

  • HTML canvases render regardless of the + menu Canvas toggle (the fenced-HTML path is unconditional), so the menu item mostly confused people. It is now hidden by default. The Canvas row stays in the Settings > Chat > Chat menu list, but its switch controls visibility instead of placement: off (the default) removes Canvas from the + menu entirely, on brings it back (persisted in localStorage as unsloth_chat_show_canvas_menu_item).
  • The artifactsEnabled behavior itself is unchanged: the render_html tool exposure, canvas instruction, in-place code collapsing, and the composer pill all work as before for users who have it on.

Testing

  • npm run build (tsc + vite) passes.
  • Built and served the changes from a local Studio instance and confirmed the running server picks up the new bundle. Sidebar collapsed state keeps hiding the cog as before.
  • Review feedback on the earlier nested-control approach was verified against the code and addressed by the sibling-button restructure.

@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 settings cog in the application sidebar to act as an interactive button that directly opens the settings dialog, adding accessibility attributes and event handlers. The review feedback correctly identifies that calling e.preventDefault() on pointerdown prevents the element from gaining focus, which breaks the dialog's focus restoration mechanism when closed.

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.

Comment on lines +1575 to +1579
onPointerDown={(e) => {
// Radix opens the dropdown on pointerdown; block it.
e.stopPropagation();
e.preventDefault();
}}

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

Calling e.preventDefault() on pointerdown prevents the settings cog from gaining focus when clicked. This breaks the dialog's focus restoration mechanism (captureOpener()), which relies on document.activeElement being the clicked element to restore focus back to the cog when the settings dialog is closed.

To fix this, only call e.stopPropagation() to prevent the Radix dropdown from opening, and allow the default focus behavior to occur.

Suggested change
onPointerDown={(e) => {
// Radix opens the dropdown on pointerdown; block it.
e.stopPropagation();
e.preventDefault();
}}
onPointerDown={(e) => {
// Radix opens the dropdown on pointerdown; block it.
e.stopPropagation();
}}

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, verified: captureOpener() in settings-dialog-store.ts reads document.activeElement at openDialog time, so preventDefault on pointerdown did break focus restoration. Fixed by restructuring the cog as a sibling button of the trigger (see latest commit), so it gains focus natively and no pointerdown handling is needed at all.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Pushed a follow up: very long profile names were pushing the cog out of the row since the name column had no width constraint. Added min-w-0 flex-1 to the name column so the name truncates with an ellipsis and the cog stays pinned on the right.

@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: 2a0d2726e7

ℹ️ 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 +1572 to +1573
role="button"
tabIndex={0}

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 Avoid nesting the settings control inside the trigger

SidebarMenuButton renders a native <button> when asChild is false (components/ui/sidebar.tsx), so adding a focusable span role="button" here still creates an interactive descendant inside the account-menu button. HTML forbids focusable descendants inside buttons, and keyboard/screen-reader behavior can become inconsistent for users trying to tab to or activate the cog as a separate control. Consider rendering the row trigger as a non-button wrapper or moving the cog to a sibling control instead of nesting it.

Useful? React with 👍 / 👎.

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.

Agreed. SidebarMenuButton renders a native button here, so a focusable descendant was invalid HTML. Moved the cog out of the trigger entirely: it is now a real button sibling inside SidebarMenuItem (which is position relative), absolutely positioned over the right edge of the row, following the same pattern as SidebarMenuAction. The trigger button reserves right padding so long names still truncate before the cog.

@shimmyshimmer shimmyshimmer changed the title Studio: make sidebar settings cog clickable with hover state, opens settings directly Studio: clickable sidebar settings cog, long name truncation, Canvas menu opt-in Jul 16, 2026

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

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

codeToolsEnabled: loadBool(CHAT_CODE_TOOLS_ENABLED_KEY, false),
imageToolsEnabled: loadBool(CHAT_IMAGE_TOOLS_ENABLED_KEY, false),
artifactsEnabled: loadBool(CHAT_ARTIFACTS_ENABLED_KEY, false),
showCanvasMenuItem: loadBool(CHAT_SHOW_CANVAS_MENU_ITEM_KEY, false),

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 Preserve existing Canvas menu pins on upgrade

For profiles that already persisted unsloth_plus_menu_pins with pins.canvas: true, this new flag is absent, so loadBool(..., false) initializes showCanvasMenuItem to false and the composer menus now render the canvas node as null. Upgrading therefore hides the Canvas action for users who explicitly pinned it before; consider deriving or migrating the initial value from the existing plus-menu pin when the new key is missing.

Useful? React with 👍 / 👎.

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.

Right, verified: loadBool falls back to false when the key is absent, so profiles with pins.canvas true would have lost the item on upgrade. Fixed: when the visibility flag is missing from localStorage, it now derives from the persisted plus-menu pin, so anyone who explicitly pinned Canvas keeps it visible. An explicitly saved flag still wins once the user toggles it either way.

@shimmyshimmer
shimmyshimmer merged commit aad11f4 into main Jul 16, 2026
37 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-sidebar-settings-cog branch July 16, 2026 13:01
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

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

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

),
canvas: (
// Hidden by default; enabled from Settings > Chat > Canvas.
canvas: showCanvasMenuItem ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Filter hidden Canvas out of the menu item lists

When Canvas is disabled, this makes plusMenuNodes.canvas null while PLUS_MENU_ORDER still includes canvas in pinnedPlusItems/overflowPlusItems. If a user pins every other configurable item with Canvas off, overflowPlusItems.length is still 1, so the + menu renders a More submenu with no entries; the compare composer has the same pattern. Please exclude hidden items before computing/rendering pinned and overflow menus.

Useful? React with 👍 / 👎.

rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Jul 17, 2026
test_sidebar_account_block_uses_leading_tight hardcoded flex flex-col
adjacency, but the account-block divs in app-sidebar.tsx now carry
min-w-0 (and flex-1) between flex and flex-col following the sidebar
truncation work (unslothai#7171). The leading-tight class is still present, so
this is a stale test rather than a UI regression. Loosen the regex to
allow the extra layout utilities while still asserting the leading-*
class the guard exists for.
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