Skip to content

Studio: turn navigator at the chat's left edge, building on #11668 - #16300

Merged
shimmyshimmer merged 14 commits into
mainfrom
studio-turn-navigator
Nov 2, 2026
Merged

shimmyshimmer merged 14 commits into
mainfrom
studio-turn-navigator

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Long chats get a turn navigator at the chat's left edge: one short line per prompt. Hovering shows the prompt and the start of its reply; clicking jumps to that turn.

This builds on #11668 by @mahiatlinux, with a new look:

  • Look:
    • The rail sits in the left gutter, and lines grow to the right with a small fisheye around the pointer. Only that hover scale animates; the on-screen tint switches without a transition, so scrolling never restyles the rail.
    • Prompts currently on screen are drawn brighter.
    • The preview card opens to the right of the rail: the prompt on one line, then up to three lines of the reply.
    • When the gutter is too narrow, the rail stays hidden until hovered or focused, so it never covers the chat.
    • Sizes: 8px between lines, 24px lines (8px at rest), 18px from the chat's left edge, the card 32px from the line, the rail capped at the window height less 18rem, and the card's prompt and reply at one size with a 20px line height and 12px padding.
    • Centred vertically on the chat, and the card uses the standard popup surface (no border, Studio's dropdown shadow and dark glow); its bookmark icon takes the prompt's colour.
  • From Unsloth Studio / Desktop: number chat turns and add a pinned turn navigator #11668:
    • Turn numbering that follows the displayed branch (thread-turns.ts).
    • Bookmarks from the prompt's action bar, the reply's More menu or the card. They are stored per chat and cleaned up when messages, chats, projects or all chats are deleted.
    • The rail follows the thread's scroll, with fades at its ends.
    • The jump completes progressive mounts first, then lands the prompt at the top with a short shine.
    • Arrow keys, Home and End move between turns.
    • The card follows a streaming reply.
    • A Turn navigation switch in Settings > Chat.

Changes from #11668:

  • The rail is on the left.
  • On by default; the switch still removes it entirely.
  • Shows from 3 turns instead of 5.
  • The card drops the turn number; markers still announce "Turn N".

#11668 conflicts with main today; this PR carries its code forward. With it, #11668 would be superseded.

Hover lag in long chats

Also fixes a lag that is on main today, independent of the rail. Hovering a message mounts its action bar, and Chromium then restyled the whole chat and sidebar (about 10k elements) whenever any :has() rule in the app had a broad subject. On a 200-turn chat that was about 30 ms per hover, and at 4x CPU throttle scrolling with the pointer over the thread stalled for 37 to 44 s of long tasks in some runs.

  • vite-plugin-has-anchor.ts rewrites Tailwind's group-has-* and peer-has-* output from X:is(:where(.group):has(A) *) to :where(.group):has(A) X: the same match and specificity, which Chromium invalidates precisely.
  • The composer pills' hover swap sets a variable on .composer-pill-glyph instead of styling > :not(.composer-pill-x) behind a :has().
  • The glass sidebar rule matches a focused or open button itself instead of asking the row with :has().
  • The glass page-route wallpaper rules use the data-chat-wallpaper-workspace-ready root flag that background.tsx already sets.
  • The unused avatar group count sizes its icon through a variable.
200-turn chat, headless Chromium Before After
Style recalc over 40 message hovers 305 ms 43 ms (17 ms with every :has() rule removed)
Long tasks scrolling over the thread, 4x throttle 0.9 to 44 s (bimodal) 0.3 to 0.6 s
Frame time p95 while scrolling, 4x throttle up to 400 ms 16.8 ms
Rail style recalc while scrolling, 4x throttle 192 ms 46 ms (12 ms with the rail off)

Verification

  • npm run typecheck, npm run i18n:check:strict, npm test, npm run build
  • tests/thread-turns.test.ts, tests/bookmarked-turns-store.test.ts (from Unsloth Studio / Desktop: number chat turns and add a pinned turn navigator #11668, updated for the left-side card) and tests/turn-navigation-layout.test.ts
  • In a local Studio build, with a 12-turn chat in dark and light themes:
    • The rail sits 18px from the chat's left edge and is centred vertically.
    • The card opens to the right of the rail and shows the right prompt and reply.
    • Clicking a turn lands its prompt at the top of the thread.
    • Bookmarking from the card turns that line the accent colour.
  • tests/has-anchor-order.test.ts: the rewrite on Tailwind's real output, equivalence cases, and selectors it must leave alone.
  • In a local Studio build: composer pills still swap their icon for the X on hover (Search, Tools, Skills), and compact pills with a menu keep their icon. The glass theme with a wallpaper and WebKit (Desktop on macOS and Linux) were not exercised here; the rewritten selectors match the same elements.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 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-11-02T04:00:30.964217Z 541ed5b 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.

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 31, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 286b05ba14

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

Copy link
Copy Markdown
Member

The studiobench UI parity red here (Parity verdict, scored against the null) comes from this PR's intended change, not from main or the harness. All 14 stable actions differ in both repetitions, and every difference is in thread scaffolding outside any message, for example delete_message: 14309->23860c, model_change: 12291->21842c, thread_reopen: 14340->23877c. The null control for the same run audited clean, with 0 stable actions differing.

That fits the turn navigator being rendered at the thread's left edge. The run had UI_CHANGE_DECLARED: false because the PR has no labels. If the navigator is meant to show up in every thread, adding the affects UI# label makes the workflow report the rendering differences with before/after evidence instead of failing on them. Behaviour differences still fail under that label. A rerun after labelling should go green, unless the navigator is supposed to stay hidden until a thread has enough turns, in which case this check found a real problem.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 787157b9f8

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: fa089e3697

ℹ️ 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 changed the title Studio: turn navigator at the chat's left edge, combining #11668 with T3 Code's minimap design Studio: turn navigator at the chat's left edge, building on #11668 Nov 1, 2026
# Conflicts:
#	studio/frontend/src/features/settings/tabs/chat-tab.tsx
# Conflicts:
#	studio/frontend/src/features/settings/tabs/chat-tab.tsx
- Only the hover fisheye animates, on the scale property the dashes actually use; the in-view tint switches without a colour transition, which restyled the rail every scrolled frame.
- The edge fades set the rail's mask directly instead of inherited custom properties that restyled every marker.
- The rail mounts from a local settled flag; the published turn map was never read.
- Bookmarks use bookmark-01, as everywhere else since #16409.
Hovering a message mounts its action bar, and Chromium then rechecked every :has() anchor above it. With any :has() rule over a broad subject, that restyled the whole chat and sidebar (about 10k elements, roughly 30 ms per hover on a 200-turn chat).

- A Vite plugin rewrites Tailwind's group-has-* and peer-has-* output from X:is(:where(.group):has(A) *) to :where(.group):has(A) X: the same match and specificity, which Chromium invalidates precisely.
- The composer pills' hover swap sets a variable on the glyph instead of styling > :not(.composer-pill-x) behind a :has().
- The glass sidebar rule matches a focused or open button itself instead of asking the row with :has().
- The glass page-route wallpaper rules use the root flag background.tsx already sets.
- The avatar group count sizes its icon through a variable.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@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: 191850c3ff

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

}
}
return () => observer.disconnect();
}, [viewportRef, signature, turnCount]);

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 Refresh visibility observers when prompt rows are replaced

When a user edits a prompt and then cancels, ThreadMessage switches from UserMessage to EditComposer and back, replacing the observed MessagePrimitive.Root. The opener signature and turn count remain unchanged, so this effect never reruns and the observer keeps watching the detached element. That turn's marker consequently stops updating its on-screen tint until the turn list changes or the navigator remounts. Reattach observation when message elements are replaced, or observe a stable row wrapper.

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.

Reproducible but cosmetic: after an edit is cancelled, only that turn's on-screen tint can go stale until the next turn arrives. Jumping, the preview card and bookmarks look messages up fresh by id, so nothing is lost or misrouted. Re-observing on every replaced row would mean a MutationObserver over the thread, which is the cost this PR removes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 191850c3ff

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

Copy link
Copy Markdown
Member Author

@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: 541ed5b698

ℹ️ 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 d56738f into main Nov 2, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-turn-navigator branch November 2, 2026 04:41
danielhanchen added a commit that referenced this pull request Nov 2, 2026
…#16464)

## Summary

`Parity verdict, scored against the null` fails on unrelated PRs whose
base includes #16300 (`d56738f404`, the turn navigator at the chat's
left edge). In the last two hours it failed on #16458 (a backend-only
change) and on staging for #16463 and #16435, each time the same way:

```
matched:                    0
unstable actions differing: 32  (expected to vary; not a verdict)
NOTHING WAS COMPARED. ... This is not a pass.
```

In the null control (the same build on both arms), every action's thread
scaffold digest differs, even between two repetitions on the same arm,
while its length stays equal (`thread scaffolding outside any message
(24167->24167c)`). That is an instance id leaking into the structural
signature.

#16300 renders the navigator inside the thread root, outside every
message, as one button per turn with `data-turn-id={openerId}`.
`openerId` is the turn's opening message id (`thread-turns.ts` pushes
`message.id`). `scene/parity.js` already drops the values of
`data-message-id`, `data-thread-id` and the other id attributes it knew
about, but not this new one. Studio's message ids are short and random,
so `ID_RE` does not catch them in the value either.

The product is fine; the instrument fell behind the DOM.

## Change

- **`tests/studio/studiobench/scene/parity.js`:** an attribute is
volatile if it is in `VOLATILE_ATTRS`, or if its name matches
`data-*-id`. A volatile attribute keeps its presence in the signature
and loses only its value, as before.
- Every `data-*-id` in the frontend names an instance, e.g.
`data-turn-id`, `data-queue-item-id`, `data-bookmark-id`,
`data-entry-id`.
- So the next one added inside the thread cannot silently empty the
verdict the way this one did.
- Non-id data attributes (`data-turn`, `data-role`, `data-state`, ...)
still compare by value.
-
**`tests/studio/studiobench/fixture/selftest/test_studiobench_parity_digest.py`**
(these run the shipped `parity.js` under node):
- `test_every_data_id_attribute_is_volatile`: two different
`data-turn-id` values sign the same, a button with the attribute still
differs from one without it, and the same holds for
`data-queue-item-id`.
- `test_a_data_attribute_that_is_not_an_id_still_moves_the_signature`:
`data-turn="1"` against `"2"` still differs.

## Testing

- `tests/studio/studiobench/fixture/selftest`, `sweep/selftest` and
`analysis/selftest`: 606 passed.
- Sabotage: with main's `parity.js`,
`test_every_data_id_attribute_is_volatile` fails; the other new test
passes on both.
- Not proven here: I did not rerun the full parity sweep locally. The
PR's own parity job is the end-to-end check. On main's harness it should
report a non-zero `matched` count on this PR, as the runs before #16300
did (28 or 29).
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Nov 6, 2026
…the chat grows (unslothai#16801)

Adds a browser CI gate that fails when typing in a long chat costs more
as the chat grows, the shape of unslothai#16603.

**Stacked on unslothai#16656. Please merge unslothai#16656 first**: this branch contains
its commits, and the gate fails on current `main` by design (that is the
regression it catches).

## Why

unslothai#16603 came back because nothing in CI measured per-keystroke cost
against chat length. Bisecting the Studio frontend from `v0.1.913` to
`main`:

| Build (200-turn agent chat, about 427K tokens) | Style work per
keystroke |
| --- | --- |
| before unslothai#16333 | 15.6 ms |
| unslothai#16333 (wallpaper fade `:has()`) | 619 ms |
| `v0.1.914-beta` | 144 ms |
| `main` | 136.5 ms |
| `main` + unslothai#16656 | 4.6 ms |

unslothai#16333 added a descendant `:has()` on elements that hold the whole
thread (`[data-wallpaper-workspace]`, `[data-chat-content-root]`), so
Chromium (Desktop, Chrome, Edge) walks every message on each keystroke.
Firefox is not affected, which matches the "browser is fine" reports.
unslothai#16751 (Reduce Motion default off) then made scroll pay that walk more
often (61 ms to 188 ms per wheel step), which is why turning Reduce
Motion back on did not help typing. unslothai#16300 (`d56738f40`) already removed
two other unslothai#16333 rules that restyled the whole page on every key
(real-app bisect: 563.8 to 91.2 ms per key), which is why 0.1.914 was
slow but not as slow as unslothai#16333. The fade rule stayed. unslothai#16656 removes
every such rule and adds a static guard test; this PR adds the runtime
gate so a new rule of that shape, or anything else that scales with chat
length, cannot ship again.

## What the gate does

`tests/studio/playwright_long_thread_gate.py` runs **first** in every
frontend lane, right after `npm ci`: Frontend CI (Linux, Windows),
Composer compatibility (Ubuntu, macOS, Windows, Safari) and Inline
images (Ubuntu, macOS, Windows).

1. Builds `smoke-thread-weight.html` for production
(`vite.long-thread.config.ts`) and seeds an agent-style history inside
the real app ancestors (`?shell=1`: sidebar workspace, wallpaper, chat
content root) with open reasoning, tool cards, web sources, compaction
markers, code, KaTeX and tables. The fixture shape is checked, so a
fixture that stops rendering something fails.
2. Measures the 200-turn chat first. Two untraced keys decide how much
to trace: a healthy page traces 10 keys, a slow one 2, and a page
hundreds of times slower than healthy fails on the untraced number
alone.
3. Fails if `:has()` matching costs more than 5 ms per key at 200 turns,
or if total selector matching per key grows more than 2x from 40 to 200
turns. A second repeat runs only when the ratio is near the limit. Both
checks are ratios or tiny budgets on selector matching, so a slow runner
cannot fail them.

## What a failure says

A failure prints ms per key at each size, how far over budget it is and
the top selectors with their match attempts. Selectors tried on most of
the DOM are marked as likely victims of a whole-page restyle. It then
pins down the trigger: it removes `:has()` rules from the stylesheet
text before fresh page loads (rules switched off in a page that already
rendered leave Chromium's `:has()` state behind and blame the wrong
rule) and bisects for the rule whose removal makes typing cheap, trying
rules that search an element holding the thread first. Each rule found
is mapped to its likely source with a text match, worded as a
possibility. On current `main`:

```
FAIL: :has() matching costs 63.6 ms per keystroke at 200 turns, budget 5.0 ms (12.7x over); total selector matching 358.9 ms/key
  pin-down at 60 turns, untraced style recalc per keystroke: 48.5 ms with all 262 :has() rules, 1.1 ms with none of them
  Measured: removing only this rule takes the keystroke from 48.5 to 1.8 ms (no :has() rules: 1.1 ms); this rule on its own costs 4.9 ms:
    :is([data-wallpaper-workspace], [data-chat-content-root]):has(> .chat-wallpaper[data-ready] .chat-wallpaper-image[data-fade="false"]) .thread-bottom-fade
    It is possible this section caused the issue, but we cannot be sure (a text match):
      studio/frontend/src/index.css:6210 (exact text match)
    Pattern: `:has(> .chat-wallpaper[data-ready] .chat-wallpaper-image[data-fade="false"])` on `:is([data-wallpaper-workspace], [data-chat-content-root])` searches all descendants (no leading `>`, or a space inside), so Chromium re-walks everything under that element after each DOM change, whether or not anything matches.
      `[data-wallpaper-workspace]` (first found in studio/frontend/src/app/routes/__root.tsx:720) holds the whole thread, so every keystroke walks every message.
```

`tests/studio/test_css_culprit.py` covers the source mapping and the
`:has()` shape check.

## Replay against past stylesheets

The gate on this branch, with only `index.css` swapped in from each
commit (CPU runner):

| `index.css` from | Verdict | Time | Pin-down |
| --- | --- | --- | --- |
| before unslothai#16333 (`4ce36bc3b5`) | PASS | 25 s | |
| unslothai#16333 (`65e868dcf5`) | FAIL | 104 s | fade rule: 276.0 to 1.5 ms
without it |
| unslothai#16442 (`6401ceda29`) | FAIL | 105 s | fade rule |
| `v0.1.914-beta` | FAIL | 101 s | fade rule |
| `main` | FAIL | 104 s | fade rule: 48.5 to 1.8 ms without it |
| this branch | PASS | 28 s | |

On GitHub runners a passing gate takes 30 to 77 s per lane plus 12 to 24
s for Chromium (staging run of every lane on Linux, Windows and macOS).

## Other changes

- The smoke fixture gains `rich` agent content (markdown, table, list)
and the `?shell=1` app shell.
- The gate's Chromium step installs missing Linux libraries only when
Chromium cannot launch, through `retry-with-apt-lock.sh` with
`APT_ACQUIRE_RETRIES=0` and a 10 minute step timeout, like the other
browser steps.

---------

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