Skip to content

Unsloth Studio / Desktop: number chat turns and add a pinned turn navigator - #11668

Closed
mahiatlinux wants to merge 46 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-turn-navigator
Closed

mahiatlinux wants to merge 46 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-turn-navigator

Conversation

@mahiatlinux

@mahiatlinux mahiatlinux commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Adds opt-in turn navigation to Unsloth Studio / Desktop chat, requested on r/unsloth. Long chats get a rail on the right that numbers the turns, lets you bookmark them, and jumps to any of them. The prompt bubbles themselves look exactly as on main.

turn navigation

What it does

  • Setting: Settings > Chat > Turn navigation, off by default. While off, nothing renders or subscribes.
  • Bookmarks: from the prompt's action bar, the reply's More menu, or the rail card. A bookmarked turn's dash takes the accent colour and its card shows the filled icon. Saved per chat in localStorage, not offered in incognito, and cleaned up when chats or messages are deleted.
  • Rail: one thin dash per turn, from 5 turns up. Dashes magnify around the cursor, bookmarked turns are highlighted, and arrow keys move between them. The rail follows the chat's scroll and keeps the turn you're on centred.
  • Card: hovering a dash shows the turn number, the prompt and the start of the reply, with a bookmark toggle.
  • Jump: clicking a dash scrolls that turn into place and runs a short shine across the bubble. Skipped under reduced motion.

Turn numbers follow the displayed branch, and context compaction doesn't shift them.

hover card

shine, dark shine, light
4x slow, dark 4x slow, light

settings

Performance

  • The turn index is built once per thread. After a chat switch, the rail fills in once the chat has finished loading, so the switch itself pays nothing for it.
  • Scrolling does one read and one write on the rail. Fitting it to the window only happens on resize.
  • Hovering never restyles the chat: the card is portaled to the page and hidden rather than unmounted.

Checks (at 3dee72167f)

  • tsc: clean
  • npm test: 11,285 passed, 0 failed
  • npm run build: pass
  • npm run i18n:check:strict: pass, the turns.* and settings.chat.turnNavigation* keys are in all 14 locales
  • Jump shine driven in Chromium via Playwright on Linux, light and dark, on a seeded six-turn chat: the GIFs above.
  • At 460f327, driven in an Unsloth Desktop shell on Windows 11 at 125% scaling: labels, bookmarks, rail hover and scroll, jumps, chat switching, and window resizing. The resize in the GIF also has Unsloth Desktop: keep the page sized to the window after a fast resize on Windows #12542 stacked in, a separate fix that keeps the page sized to the window.

Earlier benchmarks (at e22e297, before the rail rework) found no regression with the setting off or on; see the comments for those runs.

Closes #10248.

Adds an opt-in "Turn navigation" setting under Settings > Chat. When on,
each user message shows a "Turn N" label, turns can be pinned from the
user action bar or the reply's More menu, and a rail on the right edge of
long chats jumps to any turn with a hover preview of its prompt.

Turn numbers come from one pass per message array (thread-turns.ts), so a
streamed token or keystroke costs each message an O(1) lookup. Pins are
kept per chat in localStorage, like pinned chats.
@mahiatlinux

This comment has been minimized.

@LeoBorcherding LeoBorcherding changed the title studio: number chat turns and add a pinned turn navigator Unsloth Studio / Desktop: number chat turns and add a pinned turn navigator Sep 26, 2026
…gator

# Conflicts:
#	studio/frontend/src/components/assistant-ui/thread.tsx
#	studio/frontend/src/features/chat/stores/chat-preferences-store.ts
#	studio/frontend/src/features/settings/tabs/chat-tab.tsx
#	studio/frontend/src/i18n/locales/ar.ts
#	studio/frontend/src/i18n/locales/de.ts
#	studio/frontend/src/i18n/locales/en.ts
#	studio/frontend/src/i18n/locales/es.ts
#	studio/frontend/src/i18n/locales/fr.ts
#	studio/frontend/src/i18n/locales/hi.ts
#	studio/frontend/src/i18n/locales/it.ts
#	studio/frontend/src/i18n/locales/ja.ts
#	studio/frontend/src/i18n/locales/ko.ts
#	studio/frontend/src/i18n/locales/pt-br.ts
#	studio/frontend/src/i18n/locales/ru.ts
#	studio/frontend/src/i18n/locales/zh-CN.ts
Dashes rest at 8px and the hovered one widens with its three neighbours on
either side tapering off, while every dash thins. The card beside the rail
shows the prompt on one line, the reply's opening lines and a pin toggle.
The hovered dash now reaches 20px instead of 34px, with the neighbours
tapering 16, 12 and 10px, and the card moves in to sit beside it.
Pinning a turn is now bookmarking it everywhere: the action bar, the More
menu, the turn label and the rail card show a bookmark that fills once set,
and the strings, store, storage key and components are renamed to match, so
it no longer reads like pinned chats. The dashes are 4px pills, thinning to
3px on hover, so their rounded ends show.
@mahiatlinux
mahiatlinux force-pushed the feat/studio-turn-navigator branch from 78d920a to c229c6f Compare September 28, 2026 11:29
@Imagineer99

This comment has been minimized.

The rail was gated on a 52rem thread width, which only leaves a free gutter for the standard chat width. With the wide or full chat width the message column reaches the viewport edge and the rail sat over bubbles and their action bars, taking their clicks. Show it only when the gap beside the column fits it; the standard width keeps the same threshold. Also tighten comments and make the turn-signature test cover a same-count branch switch and an appended reply step.
@Lyxot

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-10-11T08:35:26.538485Z 3dee721 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.

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

ℹ️ 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 +239 to +242
if (hasPendingProgressiveMounts()) {
waitForSettle();
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 Wait for history to arrive before settling the turn index

On a cold persisted-thread open—especially in Safari/WebKitGTK, where scheduleIdleTask uses its 120 ms fallback—the history can still be loading with zero messages when this callback runs. hasPendingProgressiveMounts() is then false, so this marks the index settled permanently; when a long history subsequently arrives and starts progressive mounting, the rail creates all of its markers and the labels publish during that load rather than after it, reintroducing the switch-time DOM work this gate is intended to defer. Account for the thread's loading state (and reset settling when mounting begins) before setting settled.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declined. This changes when the work happens, not what renders: the label box is mounted before its number fills in and the rail renders nothing under 5 turns, so a cold open that settles early shows the same labels and rail as one that settles late. The gate targets switches between loaded chats, where the messages are already in the runtime and the mounts are pending when the idle callback runs. Studio exposes no per-thread history loading flag to wait on, and the alternative, unsettling when a batch arrives, would blank labels that are already showing.

Comment on lines +273 to +275
if (Math.abs(offset) < 1) {
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 Keep polling alignment for the requested frames

When the initial jump lands within one pixel before a delayed math block above the target finishes laying out, the next animation frame takes this return and cancels all of the remaining JUMP_ALIGN_FRAMES. A layout shift in any later frame then moves the selected turn away from the top with no correction, defeating the multi-frame alignment this function is meant to provide; skip the scroll for a subpixel offset, but still schedule the remaining frames.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declined after measuring. Jumping from the top into a chat whose 12 replies each carry a 70 line code fence and a display math block, the target's offset from the viewport top over the 40 frames after the click was -0.5, -0.5, then -0.1 px for every remaining frame, in three trials. Deferred fences reserve their height from the line count and math renders synchronously, so nothing above the target settles after the first frame; the remaining frames exist for a shift that lands in the frame right after the scroll, and that frame still runs.

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

mahiatlinux commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

What this PR does, file by file

A walkthrough of the full diff at 3dee72167f (29 files, +1,426 / -29) with a clip for each part. Clips are the Studio web UI in Chromium on Linux, dark theme, on seeded chats.

1. The setting

  • features/chat/stores/chat-preferences-store.ts (+6): showTurnNavigation joins the persisted chat preferences (unsloth_chat_preferences), default off, with a merge fallback so older stored preferences still load.
  • features/settings/tabs/chat-tab.tsx (+16): a SettingsRow with a Switch under Settings > Chat.
  • features/settings/settings-search.ts (+1): the key is indexed, so settings search finds it.
  • 14 locale files (+10 each): the five turns.* strings and the two settings strings.

While the switch is off, nothing renders and nothing subscribes: TurnNavigator, BookmarkTurnButton and BookmarkTurnMenuItem each read the preference and return null before any other hook.

settings toggle

2. The turn index

  • components/assistant-ui/thread-turns.ts (new, 50 lines): threadTurns(messages) makes one pass over the thread's message array, collecting the user messages as turn openers (openerIds), the turn per message index (turnAt, an Int32Array) and a signature (the opener ids joined). The result is cached in a WeakMap keyed on the array's identity, so selectors that run on every store write (keystrokes, streamed tokens) hit the cache. turnOpenerIdAt maps any message to the prompt that opened its turn.
  • turn-navigation.tsx: TurnIndexPublisher builds one map per thread in useTurnIndexStore (keyed by the thread list item id, so compare panes do not share one) from that signature, and marks it settled only after progressive mounts finish. The rail mounts from the settled index, so it adds nothing to the chat switch itself.

Turn numbers follow the displayed branch, and context compaction is prompt side only, so they do not shift.

Tests in tests/thread-turns.test.ts: each user message opens a turn and its replies share it; a reply resolves to the prompt that opened its turn; one pass per message array, and a streamed reply keeps the signature.

Switching chats: the rail appears once the switch has settled, and the prompt bubbles are untouched, exactly as on main.

chat switch

3. Bookmarks

  • thread.tsx (+14): UserActionBar gets BookmarkTurnButton, the reply's More menu in AssistantActionBar gets BookmarkTurnMenuItem, the Thread mounts TurnNavigator with the viewport ref, and useDeleteMessage forgets the bookmark of a deleted prompt. Nothing is added above or around the prompt bubble.
  • features/chat/stores/bookmarked-turns-store.ts (new, 82 lines): a persisted store (unsloth_bookmarked_turns) mapping thread id to the opener ids of its bookmarked turns, with toggleBookmarkedTurn, forgetThreads and forgetTurns. The merge guards against a malformed stored value. Bookmarks are not offered in incognito.
  • Cleanup paths: use-chat-sidebar-items.ts forgets a deleted chat's bookmarks after the delete lands, so a rolled back delete keeps them; clear-all-chats.ts forgets the cleared chats; use-chat-projects.ts forgets the threads of a deleted project, and a failed lookup there leaves stale bookmarks rather than blocking the delete. tests/studio/test_multi_chat_prompt_queue_contract.py only updates its source assertion from return await clearStoredChats( to await clearStoredChats(, since the result is now used before it is returned.

Tests in tests/bookmarked-turns-store.test.ts: deleted chats leave no records behind; forgetting chats without bookmarks keeps the state object; every chat delete route forgets; clear all forgets; forgetting a deleted prompt drops only that bookmark; deleting a message forgets its bookmark and the rail resyncs after keyboard focus leaves; an open card reads its reply live while it streams.

Bookmarking from the prompt's action bar (the rail dash takes the accent colour and its card shows the filled icon), then removing it from the reply's More menu:

labels and bookmarks

4. The rail

TurnRail in turn-navigation.tsx, shown from 5 turns. A sticky zero-height anchor at the thread's vertical middle carries a gutter beside the message column, and a nav with one button per turn (labelled "Turn N" or "Turn N, bookmarked", described by the card).

  • Dashes are 6 x 2 px pills. Moving the pointer magnifies the nearest dash and three neighbours in a pyramid, computed continuously around the pointer so fast sweeps stay smooth. Bookmarked dashes use the primary colour.
  • Height is the smaller of rows x row height + 8 px and 40dvh, capped to twice the room on the tighter side of the anchor. Row height, line thickness and the start snap to whole device pixels, so 125% scaling renders even dashes.
  • Scrolling does one read and one write: the rail's scrollTop follows the thread's progress with a slight lead, so the first and last turns come into view before the thread reaches its ends, and the ends fade over 24 px scaled by how much is hidden. The fit and the device-pixel snap run only on resize.
  • The rail is not a scroller: wheel over it scrolls the thread. It is hidden from select-all copies and find in page.

Pyramid magnify, the card, and a bookmark from the card:

rail hover and card

The rail following a 60 turn chat:

rail follows the thread

5. The card

Hovering or focusing a dash shows a muted "Turn N" caption, the prompt on one line (240 characters of cleaned markdown), up to three lines of the reply (480 characters, with code fences, links and list markers stripped by previewText) and the bookmark toggle. The card carries select-none itself, since the portal takes it out of the rail anchor, so Select All over the chat never copies it.

  • Portaled to document.body and hidden with visibility rather than unmounted, so hovering never restyles the thread: adding or removing boxes trips a document-wide :has() restyle. The reply paragraph is collapsed by class for the same reason.
  • While the latest turn streams, the card reads its reply live; the live lookup is limited to the latest turn.
  • Its width is capped to the viewport (max-width: calc(100vw - rail offset - 2rem)), so a phone-width window or a larger UI text scale cannot push it off the left edge.
  • A 150 ms hide delay lets the pointer cross from the dash onto the card. It closes on Escape, on leaving the document, on resize and on blur (WebView2 sends no pointerleave onto the window frame). It has role="tooltip".

6. Keyboard

Arrow Up and Down move between dashes, Home and End go to the first and last, Enter jumps. Keyboard focus scrolls the rail to reveal its dash, the card follows the focused dash when the rail moves after a jump, and the rail follows the thread again once focus leaves.

keyboard

7. Jump and shine

jumpToTurn finds the opener's message element by data-message-id, completing progressive mounts first when it is not mounted yet, detaches the thread from bottom follow, and alignTurnTop scrolls the turn to the top, re-aligning over 4 frames because math blocks above the target settle from placeholder heights. Then shineTurn runs a 900 ms gradient sweep across the prompt bubble (SHINE_GRADIENT, light and dark variants), skipped under reduced motion.

jump

The bubble crops, dark and light, real speed and 4x slow, are in the PR body, and the comparison with the glass variant it replaces is in the comment above.

Checks at 3dee72167f

tsc clean, npm test 11,285 passed, npm run i18n:check:strict clean across 14 locales, npm run build pass.

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

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

</div>
{/* portaled out of the thread's autoscroll MutationObserver, and made invisible rather than
unmounted: adding or removing boxes trips a document-wide :has() restyle */}
{createPortal(

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 Hide the preview portal when its pane is backgrounded

When a preview is open and the app enters Compare without moving the pointer (for example through keyboard/programmatic navigation), chat-page.tsx deliberately keeps the prior single-chat provider mounted under a hidden wrapper. This portal escapes that wrapper, and the close effect only watches mouseout, resize, and window blur, so previewOpen can remain true and leave the old card over the Compare UI. Gate the navigator on useChatActive or close the preview whenever its pane becomes inactive.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declined after reproducing the sequence. Compare is URL state, so the pointer-free way in is browser back into an earlier ?compare= view. With the card open on a hovered dash, and separately on a keyboard-focused dash with the pointer parked elsewhere, going back into Compare (in-app history, confirmed by a window marker surviving) leaves the card with visibility hidden and the dash blurred, in both Chromium 153 and WebKit 26.6: the hidden pane's dash gets its leave or blur event and hidePreview runs. The card never sits over the Compare UI, so there is nothing for an active gate to close.

@mahiatlinux

Copy link
Copy Markdown
Contributor 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: dbc4223ca8

ℹ️ 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 +149 to +152
const threads = await listStoredChatThreads({ projectId }).catch(() => []);
const threadIds = threads.map((t) => t.id);
const kept = await deleteStoredChatProject(projectId, args);
useBookmarkedTurnsStore.getState().forgetThreads(threadIds);

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 Use transactional member IDs for bookmark cleanup

When a member chat is moved out of the project by another tab or API client after this pre-read but before the delete transaction, the backend preserves that chat while forgetThreads(threadIds) permanently removes its bookmarks; a chat moved in during the same window has the inverse stale-record problem. The backend transaction already computes authoritative membership under its lock as memberIds (studio/backend/storage/studio_db.py:3041-3081), so expose/consume those IDs from the delete result instead of cleaning up from this earlier snapshot.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declined. This needs another tab or API client to move a chat into or out of the project in the window between this read and the delete transaction, and the cost is one browser-local bookmark record on that chat, which the user can set again; the chat itself is untouched. Widening the backend delete response to carry member ids is not worth that window.

for (let index = 0; index < messages.length; index++) {
const message = messages[index];
if (message.role === "user") {
openerIds.push(message.id);

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 Keep opaque IDs out of newline-delimited signatures

For chats written by an API client, message IDs may legally contain newlines because ChatMessage.id is an unconstrained string and the write routes do not validate its characters (studio/backend/routes/chat_history.py:308-316,1467-1476). Joining such an opener ID here and splitting it again in TurnIndexPublisher creates phantom opener IDs, leaves the real user message without a turn number, and also breaks bookmark-key splitting; keep the IDs structurally rather than using \n as a delimiter.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declined. Message ids in Unsloth are UUIDs minted by the frontend and the backend; an id with a newline is malformed input from a hand-written API call, not something the UI produces or supports, and the same id would already break the per-message selector keys and the data-message-id lookups elsewhere in the thread.

{threadId && !incognito && (
<button
type="button"
tabIndex={-1}

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 Make the preview bookmark control keyboard reachable

When a keyboard user focuses and navigates the rail markers, the preview opens, but its only action is explicitly removed from the tab order here and has no equivalent key binding on the marker. Pressing Tab therefore leaves the rail and starts the preview's blur-hide timer instead of reaching the bookmark toggle; include this control in the focus flow and keep the card open while focus is inside it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declined. The card's toggle is a pointer shortcut; the keyboard path is the one the rail already gives: Enter on a marker jumps to the turn, and Tab then reaches the prompt's own Bookmark turn button in its action bar, which also sits in the reply's More menu. The card stays a tooltip (role=tooltip, aria-describedby) rather than a second focus stop.

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

Pushed 278242a: the turn card is capped to the viewport width, so on a phone-width window, or with a larger UI text scale, it no longer runs off the left edge (measurements and screenshots in the thread above). Checks at 278242a: tsc clean, npm test 11,283 passed, npm run build pass.

@mahiatlinux

Copy link
Copy Markdown
Contributor 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: 278242ac1c

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

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

Pushed f4c0a6f853: after a keyboard jump the rail re-centres the focused dash, and the card now moves with it instead of staying at its old spot (measurements in the thread above). Checks at f4c0a6f853: tsc clean, npm test 11,284 passed, npm run build pass.

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f4c0a6f853

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

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

Pushed b0a766ecbe: comment cleanup only. Every comment the PR adds, plus the upstream ones within a few lines of them, is now one lowercase line that says only what the code cannot; multi-line blocks are collapsed with their facts kept. Verified comment-only with an AST and TypeScript-printer comparison against the previous head, tsc clean, npm test 11,284 passed.

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: b0a766ecbe

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

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

Pushed 1cb103d: the "Turn N" label and its bookmark icon above prompt bubbles are gone, so the bubbles look exactly as on main. The rail card carries the turn number and the bookmark state on hover, and a bookmarked dash keeps the accent colour. The now unused turns.bookmarked string is dropped from all 14 locales. Every clip in the body and in the walkthrough is re-recorded from this head, and the rail scroll and resize clip at the top of the body is now from the same Chromium harness as the rest.

turn navigation

Checks at 1cb103d: tsc clean, npm test 11,284 passed, npm run i18n:check:strict clean across 14 locales, npm run build pass.

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

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

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

Pushed 3dee721: the rail card now opens with a muted "Turn N" caption before the prompt, so the turn number lives on hover and in the keyboard card, and the card carries select-none so Select All over the chat no longer copies it (measurements in the threads above). Clips that show the card are re-recorded. Checks at 3dee721: tsc clean, npm test 11,285 passed, npm run build pass.

@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: 3dee72167f

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

onPointerMove={onRailPointerMove}
onPointerLeave={clearMagnify}
onScroll={onRailScroll}
className="aui-turn-navigator group/rail pointer-events-auto absolute top-0 right-[-1.125rem] flex w-9 -translate-y-1/2 flex-col overflow-y-hidden py-1 transition-[height] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] [contain:layout_paint] [mask-image:linear-gradient(to_bottom,transparent,#000_var(--rail-fade-top,0px),#000_calc(100%_-_var(--rail-fade-bottom,0px)),transparent)] motion-reduce:transition-none"

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 Keep the rail hit area out of narrow message columns

When a chat has at least five turns on a narrow viewport (or uses a wide/full message column), the computed gutter can be zero, yet this 2.25rem pointer-events-auto nav is centered on the column edge via right: -1.125rem. Because every marker button fills that width, an 1.125rem strip sits above the right edge of user bubbles and their action bars and intercepts clicks or text selection whenever they pass behind the sticky rail. Hide or move the rail when the gutter cannot contain its hit area rather than only placing the visible dash in the padding.

Useful? React with 👍 / 👎.

shimmyshimmer added a commit that referenced this pull request Nov 2, 2026
…16300)

## 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 #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 #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.
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.

Feature Request: ChatGPT-style prompt navigator for long conversations

6 participants