Skip to content

studio: make the chat column width adjustable, scaled to the space available - #10960

Closed
shimmyshimmer wants to merge 2 commits into
mainfrom
feat/studio-chat-width
Closed

shimmyshimmer wants to merge 2 commits into
mainfrom
feat/studio-chat-width

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

The chat column is pinned at 48rem (768px). On a wide window the messages and the composer sit stranded in the middle while most of the area goes unused.

This makes the width adjustable. The default is unchanged: 100% is exactly the 48rem column Studio has today, so a fresh install looks the same as before this branch and only a deliberate change widens anything.

The setting scales with the space available

An absolute cap is the wrong knob here. Once the window is the binding constraint, two different settings render identically: at a 1000px window both 1600px and 2000px produce 1000px, so the control looks broken to anyone not on a large display.

Instead the percentage interpolates between the default column and the width actually available:

--studio-chat-width: calc(48rem + (100% - 48rem) * var(--studio-chat-fill));

Measured from the live DOM of a build of this branch, probing a w-full element under the same utility:

setting 1200px available 1000px available 700px available
100% (default) 768 768 700
125% 876 826 700
150% 984 884 700
175% 1092 942 700
200% 1200 1000 700

Every step is distinct at every size that has room to give. At 700px the window is genuinely narrower than the base column, so no setting can change it, which is the correct outcome rather than a saturating one.

Plumbing

One document-level variable, consumed by every surface that bounds the column:

surface before after
--thread-max-width on the thread root 48rem var(--studio-chat-width, 48rem)
composer shell in thread.tsx max-w-[46rem] the variable minus 2rem, holding the old inset
page composer in chat-page.tsx max-w-[48rem] the variable

Messages already derive from --thread-max-width, so they follow with no change.

The page composer is a sibling of ThreadPrimitive.Root, so the inline --thread-max-width on that root never reached it and it carried its own hardcoded 48rem. A variable on :root reaches both.

Setting

Appearance gets a Chat width row, following the uiFontSize pattern rather than introducing anything new:

  • chatWidth: number | null on AppearanceCustomization, in percent
  • CHAT_WIDTH_RANGE of 100 to 200, default 100
  • the shared sanitizeSize clamp, which already rejects non-finite values and clamps out of range
  • the existing number input, which now takes a unit so this row reads % where the font sizes read px

The default lives in index.css, and the store clears the variable when the value equals the default, so a stock document carries no inline override. That keeps the store's documented invariant that a default customization leaves the document byte-identical to stock.

Checks

  • npm run typecheck clean (tsc -b plus the test project), npm run build passed
  • full suite 7470 passing, 0 failing, including two new chat-width-setting tests
  • npm run i18n:check:strict passing. All 12 locales were at zero missing keys, so the label and description are translated in every one, not only en
  • lint on the touched files is unchanged from baseline, and the new test file is clean

Not yet verified

The width behaviour above is measured, but I have not driven the Appearance row itself in a browser. The control is wired the same way as the existing font size rows, so the risk is low, but it is untested end to end.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T02:48:46.033719Z aeff55e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 51a0205349

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

/** Code/pre font size in px. null = inherit each element's own size. */
codeFontSize: number | null;
/** Cap on the chat column in px, not a fixed width. null = app default (1600). */
chatWidth: number | null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Persist chat width in the personalization backend

For signed-in users, this field is sent with every personalization save, but PersonalizationCustomization in studio/backend/routes/settings.py uses extra = "ignore" and does not declare chatWidth, so the PUT silently drops it. On the next startup, usePersonalizationSync sees customizationSaved as true and replaces the local customization with the remote payload; sanitization then turns the missing width into null, resetting the user's choice to 1600 px. Add a matching bounded backend field and a save/load round-trip test.

Useful? React with 👍 / 👎.

@shimmyshimmer shimmyshimmer changed the title studio: make the chat column width adaptive and adjustable studio: make the chat column width adjustable, scaled to the space available Sep 15, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Reworked the control in 21c61c2, and rewrote the description above to match.

The first pass had the setting as an absolute px cap, which is a poor knob. Once the window is narrower than the cap, the window wins and different settings render identically: at 1000px available, both 1600 and 2000 gave 1000. On a laptop most of the range would have done nothing visible.

It is now a percentage that interpolates between the default column and the space actually available, so every step differs wherever there is room to give. At 1000px available, 125/150/175/200 give 826/884/942/1000.

The default also moves back to the 48rem column Studio already had. 100% is byte-identical to today, so this no longer changes anything for anyone who does not go looking for it. That also drops the earlier concern about a wide default hurting line length: the wide reading measure is now opt-in.

The column was pinned at 48rem (768px), so a wide window left the messages and
the composer stranded in the middle with most of the area unused.

Raise the cap to 1600px and route every surface that bounds the column through
one document-level variable, --studio-chat-width. Those surfaces are already
w-full under a max-width, so they keep tracking the window and simply stop at
the new cap instead of becoming a fixed slab.

The page composer in chat-page.tsx is a sibling of ThreadPrimitive.Root, so the
inline --thread-max-width on that root never reached it. A variable on :root
does.

Add a Chat width control to Appearance settings, following the uiFontSize
pattern: chatWidth on the customization, CHAT_WIDTH_RANGE of 640 to 2400
defaulting to 1600, the shared sanitizeSize clamp, and the existing px number
input. The default lives in index.css and the store clears the variable at that
value, so a stock document carries no inline override.
A px cap is the wrong knob. Once the window is the binding constraint, two
different settings render identically: at a 1000px window both 1600 and 2000
produced 1000, so the control looked broken.

Make the setting a percentage that interpolates between the default column and
the width actually available:

  --studio-chat-width: calc(48rem + (100% - 48rem) * var(--studio-chat-fill))

Every step now differs at every window size. At a 1000px window 125/150/175/200
give 826/884/942/1000, and at 1200px they give 876/984/1092/1200.

Restore the default to the previous 48rem column: 100% is unchanged from before
this branch, and only a deliberate change widens anything. The store still
clears the variable at the default, so stock carries no inline override.

CHAT_WIDTH_RANGE becomes 100 to 200 percent, and the shared number input takes
a unit so this row reads % where the font sizes read px.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Rebased onto current main, which had moved on by ten commits since this branch was cut.

One conflict, in appearance-custom-controls.tsx. #9666 landed the same generalisation this PR needed: FontSizeInput is now SizeInput with a required unit, so the version of that change carried here is dropped in favour of main's, and the Chat width row just passes unit="%" like the rows around it.

Re-verified on the new base: tsc --noEmit clean, build passed, i18n:check:strict passing, and the full suite is 7491 passing with 0 failing. The width numbers are unchanged, re-measured from a build of the rebased branch:

setting 1200px available 1000px available
100% (default) 768 768
150% 984 884
200% 1200 1000

On the earlier CI run, Backend CI was already red on main at the time (dff8cb327, de1f4a743), so that one is not from this branch. The Chat UI Tests (extra) failure was a context-length persistence assertion unrelated to anything here, on a base that was ten commits stale. Watching the fresh run.

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

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

// in index.css queries. It sits outside the surface so those rules can
// trim the surface's own padding.
<div className="unsloth-composer-shell relative mx-auto min-w-0 w-full max-w-[46rem]">
<div className="unsloth-composer-shell relative mx-auto min-w-0 w-full max-w-[calc(var(--studio-chat-width,48rem)-2rem)]">

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 Interpolate the composer width only once

For settings between 100% and 200%, this expression resolves its 100% against a parent that has already been capped using the same interpolated width (for example, the dock wrapper at line 2148 and the compare wrapper in chat-page.tsx). With 1200 px available and a 150% setting, the outer wrapper becomes roughly 984 px, but this nested calculation makes the composer roughly 844 px instead of the intended 952 px after its 2rem inset, leaving it substantially narrower than the messages and making the slider's response quadratic. Calculate the interpolation against the pane only once, then derive the composer inset from that result.

Useful? React with 👍 / 👎.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Closing in favour of #10958, which is the same feature and was opened first.

That PR is further along: it syncs the setting to the server, handles comparison panes, and was verified in a browser at five viewport widths. None of that is true of this one.

The two also cannot coexist. Both add a property named chatWidth to AppearanceCustomization, with incompatible types ("standard" | "wide" | "full" there, number | null here). A trial merge is worse than a plain conflict: only three files conflict loudly, while the store and all 12 locale files auto-merge silently into duplicate chatWidth keys in the same object literal. That is 1822 typecheck errors, with nothing in the git output to warn you.

The one idea worth keeping from here is going to #10958 separately: its Wide preset is a fixed 72rem, which collapses onto Full once the pane is under about 1150px, so at 1000px both render 1000 and two of the three presets stop differing.

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