Skip to content

Hide the chat header fades until the thread scrolls under them - #17690

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
Imagineer99:fix/dark-chat-header-banding
Nov 15, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
Imagineer99:fix/dark-chat-header-banding

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

With glass off, the 24px header fade under the model selector is drawn over a flat page. Over a flat page every engine rounds some of its gradient pixels one level off the page colour, which shows as a faint line or band below the header.

The chat and compare-pane header fades now stay hidden until their own thread scrolls under the header, and fade back out at the top. With nothing scrolled beneath them there is nothing to fade, so the page is exactly flat in every engine. Once content scrolls under the header, the fade softens it as before. The fades keep Tailwind's default Oklab interpolation; switching them to sRGB makes WebKit band.

A capture-phase scroll listener on each fade's parent toggles data-thread-scrolled on the DOM directly, so scrolling causes no React re-render. Only the thread viewport sets it; code blocks and the full-view dock thread are ignored. The separate plain-glass wallpaper fix is already on main in #17403.

Measurements

Live Studio /chat page built from the merge base and from this branch, 1600 x 350, dark theme, glass off, empty chat. Count = pixels inside the fade that differ from the page colour (24, 24, 24):

Engine DPR main this PR fade opacity at rest / scrolled / back at top
Chromium 1 0 / 31440 0 / 31440 0 / 1 / 0
Chromium 2 0 / 125760 0 / 125760 0 / 1 / 0
WebKit 1 0 / 31440 0 / 31440 0 / 1 / 0
WebKit 2 0 / 125760 0 / 125760 0 / 1 / 0
Firefox 1 17030 / 31440 0 / 31440 0 / 1 / 0
Firefox 2 62880 / 125760 0 / 125760 0 / 1 / 0

On main the fade's opacity is 1 in every state. The first version of this branch (sRGB fades) left Chromium unchanged and made WebKit band at DPR 1 (0 to 19650 of 31440 pixels); a bare gradient sweep also showed WebKit sRGB banding in 15 of 20 offset, theme and DPR cells, where Oklab was flat in all 20.

Firefox DPR 2, dark, empty chat. Orange marks every pixel one level off the page colour: a band below the header on main, none on this branch.

Tests

tests/chat-header-fade-scroll-gate.test.ts covers the flag following the thread viewport's scrollTop in the capture phase, other scrollers and the dock leaving it alone, the hidden-by-default CSS gate on a direct parent, and both fade parents carrying the tracker with Oklab kept. The frontend suite (15939 passed, 0 failed) and the production build pass.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T09:39:45.116784Z a61fb85 Manual request
ℹ️ 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.

@danielhanchen danielhanchen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the PR! The goal of this PR is to remove a faint one-level line at the top of the chat and compare-pane header fades on a flat dark page. As a summary, this PR switches both fades from Tailwind's default Oklab interpolation (to bottom in oklab) to sRGB (to bottom in srgb).

I could not reproduce the Chromium line, and the switch adds banding in WebKit, which is the engine behind Desktop on macOS and Linux.

Live Studio /chat page, merge base 610cbd9 vs this branch f537f25, 1600 x 350, dark theme, glass off, Linux Playwright. Count = pixels inside .chat-header-fade that differ from the flat page colour (24, 24, 24):

Engine DPR Base (oklab) This PR (srgb)
Chromium 159 1 0 / 31440 0 / 31440
Chromium 159 2 0 / 125760 0 / 125760
WebKit 1 0 / 31440 19650 / 31440 (values 23 and 25)
WebKit 2 0 / 125760 0 / 125760
Firefox 1 17030 (value 25) 15720 (value 25)
Firefox 2 62880 (value 25) 62880 (value 25)

A bare gradient over a flat page gives the same picture across top offsets of 48, 48.25, 48.5, 48.75 and 47.8 px, dark #181818 and light #fefefd, at DPR 1 and 2. Chromium (headless shell and Chrome for Testing) is 0 in every cell for both spaces. WebKit with Oklab is 0 in all 20 cells, and WebKit with sRGB bands in 15 of 20, including light theme at DPR 2 (0 vs 38400 px). Firefox dithers both spaces alike, so this change does not affect it.

Could you share the OS, browser and version, and GPU or compositing setup of the 196-pixel row 96 capture? It may be specific to GPU raster, or to Chromium on macOS or Windows (WebView2). Until it reproduces somewhere, keeping Oklab looks safer, since it is the interpolation that is uniform in both Chromium and WebKit here. If it does reproduce, a fix scoped to that engine would avoid moving WebKit.

Suggested change for both fades in studio/frontend/src/features/chat/chat-page.tsx (lines 1322 and 4798): keep bg-gradient-to-b from-background to-transparent as on main.

Concrete suggestions for each finding below.

Over a flat page every engine rounds some gradient pixels a level off the
page colour: Firefox in any interpolation space, WebKit in sRGB. Keep the
Oklab fades and hide them until their own thread viewport has scrolled.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 15, 2026
@danielhanchen danielhanchen changed the title Fix the faint line below the dark chat header Hide the chat header fades until the thread scrolls under them Nov 15, 2026
@danielhanchen
danielhanchen dismissed their stale review November 15, 2026 08:56

Addressed in 0d3da96: the fades keep Oklab and stay hidden until the thread scrolls.

@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: 0d3da96d31

ℹ️ 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 +10 to +12
if (!(viewport instanceof HTMLElement) || !viewport.classList.contains("aui-thread-viewport")) return;
if (viewport.closest(".chat-full-view-dock")) return;
this.toggleAttribute(THREAD_SCROLLED_ATTR, viewport.scrollTop > 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 Restrict each scroll flag to its owning thread viewport

When a user enters compare from a scrolled single chat and scrolls a compare pane back to the top, that event also clears the outer [data-chat-content-root] flag: both the pane host and the outer host capture it. ChatPage keeps the original single viewport mounted under the hidden baseBackgrounded wrapper, so returning to that chat can leave its header fade transparent despite its viewport still being scrolled, until another scroll event occurs there. Only update a host from its own viewport, excluding viewports belonging to nested tracked hosts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 1fafedc: each host marks itself and only accepts viewports whose nearest host it is, so a compare pane no longer moves the backgrounded chat's flag; regression test added.

Compare panes are tracked hosts nested inside the chat root, which keeps the
backgrounded single chat mounted. A pane scrolling back to the top no longer
clears the chat root's flag.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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: 1fafedc510

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


function onThreadScroll(this: HTMLElement, event: Event): void {
const viewport = event.target;
if (!(viewport instanceof HTMLElement) || !viewport.classList.contains("aui-thread-viewport")) return;

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 Track the project landing viewport for the shared header fade

With glass and wallpaper off, directly opening a project with enough chats to scroll leaves its header fade permanently hidden. ProjectLanding in chat-page.tsx scrolls a [data-wallpaper-reading-surface] div without the aui-thread-viewport class, while ChatPage still renders the shared .chat-header-fade in project mode. This guard therefore rejects every scroll from that viewport, leaving the fade at its new default opacity: 0 even when project content passes beneath the model-selector header. Include the owning project viewport in the scroll gate while continuing to exclude unrelated inner scrollers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in a8788ed: the project landing list carries a fade-scroller marker the gate accepts beside thread viewports; test added.

The project landing scrolls its own list under the chat header, not a thread
viewport, so mark it as a fade scroller.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

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

ℹ️ 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 +20 to +23
export function trackThreadScroll(host: HTMLElement | null): (() => void) | undefined {
if (!host) return undefined;
host.setAttribute(HOST_ATTR, "");
host.addEventListener("scroll", onThreadScroll, { capture: true, passive: true });

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 Reset the fade gate when the owning viewport is replaced

After scrolling a chat or project and opening a new empty chat or another project with glass and wallpaper off, ChatPage retains this host while Thread's runtimeThreadId key or ProjectLanding's project key replaces the viewport. The stable ref only updates the flag on scroll, so data-thread-scrolled remains set from the old viewport; a fresh viewport at scrollTop === 0 emits no event to clear it. The fade can therefore remain visible indefinitely on an empty or short destination, bringing back the band this change is intended to eliminate. Clear or recompute the flag when the owning viewport is replaced.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 9e2cf89: each scroller syncs its host's flag from its ref on mount (thread viewport ref re-runs per runtimeThreadId, project landing list has its own), so a replacement at the top clears it; test added.

A new empty chat or another project mounts its scroller at the top and fires no
scroll event, so the old scrolled flag kept the fade over a flat page. Each
scroller now syncs its host's flag from its ref.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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: 9e2cf89792

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

// Stable callback ref: scroll does not bubble, so listen in the capture phase on the fade's parent.
export function trackThreadScroll(host: HTMLElement | null): (() => void) | undefined {
if (!host) return undefined;
host.setAttribute(HOST_ATTR, "");

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 Mark the pane host before descendant refs synchronize

When compare opens from a scrolled single chat, React runs descendant refs before this parent ref, so the pane viewport calls syncThreadScroll(node) while its own host is still unmarked. closest() therefore resolves the already-marked outer chat root and clears its flag using the pane's initial scrollTop === 0. Later pane events stay local, so returning to the preserved chat leaves its fade hidden until that chat scrolls again. Unlike the previously fixed scroll-event path, the newly added scroller-ref synchronization causes this write during mounting. Make the ownership marker available before descendant refs synchronize.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in a61fb85: the host marker is now a static JSX attribute, present before descendant refs sync; test covers the mount order.

export function syncThreadScroll(scroller: HTMLElement | null): void {
// Compare panes are hosts nested in the chat root, which keeps the backgrounded chat mounted.
const host = scroller?.closest<HTMLElement>(`[${HOST_ATTR}]`);
if (!host || !scroller || scroller.closest(".chat-full-view-dock")) return;

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 Resync the fade flag when leaving the full-view dock

With glass and wallpaper off, scrolling a previously scrolled chat back to the top inside the browser's expanded full-view dock is ignored here, leaving data-thread-scrolled set. SingleContent keeps the same Thread mounted and only toggles the ancestor's dock class, so returning to normal chat does not rerun the viewport ref. If the viewport remains at scrollTop === 0, there is also no scroll event to correct the flag, and the restored header fade stays visible until another scroll, reintroducing the band this change is intended to remove. Resynchronize when leaving full view or keep the flag current while the header is hidden.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in a61fb85: the dock exclusion is gone, since the dock reuses the same thread; its scrolls keep the flag current.

…iew dock

React attaches child refs before the parent's, so a compare pane viewport
syncing on mount resolved the chat root while its own host was unmarked. The
full-view dock only toggles a class over the same thread, so its scrolls must
keep the flag current.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a61fb85480

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

@danielhanchen
danielhanchen merged commit 99fcc69 into unslothai:main Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants