Repository navigation
fix(prompt storage): follow up, restore prompt list bookmarking, the kind pill and drag autoscroll - #9788
Merged
danielhanchen merged 38 commits intoSep 29, 2026
Conversation
Cards rendered the full prompt body with no truncation, so a few dozen saved prompts became a long scroll of uneven cards. Editing happened inline in a four-row textarea, so long prompts were edited through a peephole while the list shifted underneath. Replace the flat list with a master-detail layout: a compact rail of name plus one-line preview on the left, and a detail pane on the right that owns its height. Unsaved edits are held per entry so switching rows no longer discards them, with a dirty marker in the rail and Save/Revert in the footer. List items now auto-size to their content and reorder by dragging the grips, animated with FLIP. The drag listener lives on window rather than using setPointerCapture: reordering makes React move the row's DOM node, and detaching implicitly releases pointer capture, which ended the drag after one row. Hit-testing uses offsetTop/offsetHeight since a client rect reports the pre-animation position while FLIP is in flight. Add a Preview toggle on both tabs backed by the existing MarkdownPreview, and allow bookmarking prompt lists into the + menu next to bookmarked prompts. Rows there carry a Prompt / List pill, since selecting a prompt fills the composer while selecting a list queues and sends every prompt in it. Presentation only: no schema migration, no API change, no change to the export formats or import parser, and onUse/onRunList signatures are unchanged.
Select a newly created prompt or list only after the refresh resolves. The keep-a-row-selected effect runs against whatever list is in state, so selecting the new id while the old list was still in state made the effect bounce the selection to the first existing entry, and the new entry was never shown. Let the body shrink and stack on small viewports. The fixed 420px floor plus the header could exceed the dialog's 94dvh on a short window and clip the detail pane's actions behind overflow-hidden, and a fixed 248px rail left the detail pane unusably narrow below ~600px. The floor is now capped against the viewport, the rail narrows at sm and stacks below it, and the action rows wrap. Report when a list cannot be queued. startQueue refuses synchronously when queueing is unavailable and does not run the onAborted callback, so running a list from the project new-chat composer silently did nothing from both the Run button and the bookmarked-list menu items.
A list taller than the detail pane could only be reordered within the visible region: the pointer handler hit-tested coordinates but never scrolled the overflow-y-auto ancestor, and pointerdown suppresses the browser's own drag gesture, so there was nothing to pull the list along. Holding a grip near the top or bottom edge now scrolls the pane and re-runs the hit-test each frame, so a drag can reach any row. The step ramps with depth into the edge band and is capped per frame. The step calculation lives in its own module with unit tests covering the dead zone, both directions, the ramp, the cap, and panes too short to hold two edge bands.
Awaiting the refresh was not enough on its own. With a search active that the new entry does not match, the refreshed rail still excludes it, so the keep-a-row-selected effect bounced the selection to the first row that did match and the form closed on someone else's prompt. Clear the search alongside the selection so the new entry is eligible for the filtered rail. Applies to both create forms.
…ased off-window The auto-sizing textarea only remeasured when its value changed, so any width change that rewrapped the text left the old height in place. With overflowY set to hidden that clipped the newly wrapped lines until the next keystroke. It now remeasures on window resize, and on a ResizeObserver width change for the cases where the column moves without the window doing so. The grip deliberately does not capture the pointer, so releasing the mouse outside the window delivered neither pointerup nor pointercancel and the drag stayed live, still autoscrolling and reordering. A move reporting no buttons held is now treated as the release that was missed, and window blur ends the drag for a release that happens entirely off the page.
…rips Export passed the saved entry while the pane could be showing unsaved edits, so the downloaded file silently disagreed with what was on screen. It now exports the draft when there is one, normalised the way saving would normalise it, for both prompts and lists. A right- or middle-press on a reorder grip started a drag, and the zero-buttons recovery could not end it because buttons reads 2 or 4, so opening a context menu over a grip could reorder the list. Reordering now starts only on a primary press; touch and pen contacts report button 0 so they still drag, and isPrimary keeps a second finger from starting a competing drag.
…new-entry drafts Run queued entry.items while the editor could be showing something else. Worst case, deleting every draft item left the button enabled off the stored length and silently ran the whole old list. Run now fires the visible non-blank items and disables on those. The window-level drag listeners saw every pointer on the device, so a second finger's movement reordered using its own clientY and its release ended the first finger's drag. The initiating pointerId is now recorded and the other pointers are ignored. The new-entry forms held their name and text locally, so selecting any row in the rail unmounted the form and discarded a half-written prompt or list without warning. That state now lives in the parent alongside the edit drafts, and the New button carries a dot while a draft is waiting. Starting a bookmarked list bypassed the busy gate that ordinary sends respect, overwriting the queue refs and firing another send on top of a run already in flight. It now refuses while a run or an existing queue is active and says so.
…hrink the body floor Ordinary sends gate on isDictating and this path did not, so selecting a bookmarked list mid-dictation set the composer text and scheduled a send that a landing transcription could overwrite first, queueing the dictated words instead of the saved prompt. isPrimary is scoped per pointer type, so on a hybrid device a primary mouse or pen press passed the guard while a touch drag was already running and took the drag over, stranding the pointer that started it. Pointer-down is now rejected outright while a drag is bound. The body floor took a flat share of the viewport, so on a phone in landscape it still added up past the dialog's 94dvh once the ~13rem of non-shrinking header and tab/search chrome was counted, and the detail actions were clipped. The floor now subtracts that chrome, and clamps at zero when the viewport is shorter than it.
…he delete race The stacked grid kept a hard 96px minimum on the rail row, which with the gap and padding exceeded the whole body floor on a short viewport: the detail pane collapsed to zero height and its actions overflowed into DialogContent's clipping region, undoing the floor fix. The rail row is now shrinkable and the gap and bottom padding tighten below sm. The queue abort callback reopened the storage dialog, which was right for a run started inside it but threw a modal over the destination chat when the run came from the "+" submenu. The launch source is now passed through so only a dialog-started run reopens it. Deleting awaited the request and then cleared the selection outright, so selecting another row while the delete was in flight was undone. The deleted id now goes up and the parent clears only if it still matches.
…dirty entry Shrinking the grid tracks did not shrink what was inside them. On a short viewport the rail's new button and count footer, and the detail pane's name field, metadata and action row, still overflowed their tracks and spilled into DialogContent's clipping region, so the actions stayed unusable at exactly the size the previous change targeted. Each pane now keeps the minimum its own fixed chrome needs and the body scrolls when those minimums do not fit. Delete sits beside the draft controls in this layout, where the old one was hidden while editing, so a single click destroyed the stored entry and the only copy of the unsaved draft together. Deleting a dirty prompt or list now asks first and names what is being lost.
The busy guard read React state that only refreshes on the 200ms handle poll, so a list started in the window right after a send queued over the live generation. It now asks the handles directly, the way that poll does. A staged image or audio attachment was left in place, and send() picks those up, so the first prompt in the list went out with the attachment and the rest without it. Running a list while something is staged is now refused rather than clearing it, since the attachment belongs to the user. The draft maps were plain objects keyed by entry id. Ids come from storage and may be any string, so an entry called "constructor" or "toString" resolved to an inherited prototype member: the row read as permanently dirty and the inherited function's own `name` could land in the editor as the entry name and be saved from there. They are Maps now.
The composer is deliberately raised above the generated-image overlay, so the "+" menu stays clickable while an image edit is pending. Submitting normally rewrites the prompt into an edit instruction, sets the pending image reference and closes the overlay; startQueue appends the saved text untouched, so the first list prompt was either applied to the selected image or consumed the pending reference outright. Running a list now refuses while the overlay is open and says why. The shared composer has no overlay of its own, so this is limited to the chat thread path.
Several had grown to five or more lines, restating the reasoning from review rather than the fact a reader needs. Each is now at most three lines and keeps only what is not evident from the code: why there is no pointer capture, why the hit-test uses layout offsets, why the draft maps are Maps, and so on. No behaviour change.
…s factories Prompts and lists live in separate tables with independent ids, and the "+" submenu renders both as siblings, so a shared id produced duplicate React keys and the wrong row could be reused or dropped on an async refresh. Keys are prefixed by kind in both composers. The empty new-entry drafts were shared module constants, so every reset handed back the same `items` array. Nothing mutates it today, but one in-place edit would corrupt it permanently; they are factories now.
Serialize the mutations. PUT is an unconditional upsert, so a Save pressed while a DELETE was still in flight wrote the row back. Both details now refuse a second mutation while one is pending, and report a failure instead of swallowing it. Reorder by insertion slot rather than by the row under the pointer. Hit-testing the containing row oscillates across uneven heights: drop a short row onto a tall one and the tall row is still under the pointer, which sends it straight back. reorder.ts counts the passed midpoints of the other rows, which has a fixed point at every pointer height. FLIP off layout offsets. Client rects move with the scroll position, so scrolling between reorders baked the accumulated distance into every transform. Hand autoscroll outwards through the whole scroll chain. A nested scroller reports its unclipped height, so its edge could sit past the ancestor hiding it and past the viewport, where the pointer can never reach it. clipSpan intersects the pane with what clips it. Give the rail a roving tabindex and aria-current, so reaching the editor no longer means tabbing through the library. Sequence the plus-menu refreshes and drop the rows on failure, so a stale or deleted list cannot be queued from the menu. Guard the composer paths the earlier rounds missed: dictation on the chat thread's menu, and audio still being read into base64, which pendingAudio cannot see yet. Fix the lint the new component tripped: refs read during render, and setState called synchronously from an effect.
Per review: land the master-detail relayout on its own. Three things that rode along with it come out, to follow separately once this is in. Bookmarked lists in the "+" menu. The pinnedListIds store, the pin control on a list, the pinned marker in the rail, and the menu entries in both composers. thread.tsx, shared-composer.tsx and plus-menu-prefs-store.ts go back to main untouched, so the guards those menu entries needed (live handles, dictation, staged attachments, the image overlay) travel with them. That also returns the storage dialog's Run button to how main queues a list. The kind pill. It exists only to tell a prompt from a list once both share the "+" submenu, so it has no reason to land before the lists do. Drag autoscroll. The module, its tests, and the scroll-chain walk in the drag loop. Reordering still works over what the pane shows; it just does not scroll to reach the rest. What stays is the layout: the rail and detail pane, per-entry drafts, the preview toggle, the auto-sizing rows and their drag/keyboard reorder, and the review fixes for that surface.
…croll Split out of unslothai#8692 so the master-detail relayout could land on its own, as Daniel asked. This is the other half, unchanged, stacked back on top of it. Three separable features share these files, which is why they travelled together and why they had to be separated by hand: - List bookmarking in the plus menu. plus-menu-prefs-store.ts holds the pinned list and shared-composer.tsx surfaces it. - The kind pill, prompt-kind-pill.tsx, which labels an item as prompt or list in the master column. - Drag autoscroll, autoscroll.ts, so a drag near the edge of a long list scrolls instead of stalling. Covered by prompt-list-drag-autoscroll.test.ts.
unslothai#8692 landed as a squash, so resolve toward main and keep only this PR's delta (bookmarked lists, kind pill, drag autoscroll). Drops the unrelated backend reformatting of llama_cpp.py, routes/inference.py and two backend tests, as asked in review.
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Sep 29, 2026
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Sep 29, 2026
Drop the Prompt pill from saved prompts in the + menu and replace the List · N pill with a small round count, so prompt names are no longer truncated and the menu reads cleaner.
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Sep 29, 2026
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Sep 29, 2026
shimmyshimmer
pushed a commit
to shimmyshimmer/unsloth-staging-4
that referenced
this pull request
Sep 29, 2026
…e send is preparing
danielhanchen
added a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #8692. That PR was cut down to the master-detail relayout on its own, as requested. This is the other half, unchanged in intent, stacked back on top of it.
Three separable features share these files, which is why they travelled together in the first place and why they had to be split by hand:
plus-menu-prefs-store.tsholds the pinned list,shared-composer.tsxsurfaces it.prompt-count-badge.tsx, a small round count on a bookmarked list in the "+" menu, so it reads as N prompts rather than one. Saved prompts carry no badge.autoscroll.ts, so a drag near the edge of a long list scrolls instead of stalling.Depends on #8692
Land that one first. Both touch
sortable-prompt-items.tsxandprompt-storage-dialog.tsx.Codex findings carried over from #8692
Three review threads on #8692 were about this code, not the layout change, so they came here with it. Two are already implemented:
busyonly refreshes on the 200 ms poll, so a list started right after a single send could schedule over a run still in flight.runPromptListnow asks the handles directly, the way the poll does:busy || Object.values(handlesRef.current).some((h) => h.isRunning()).send()reads whatever is staged, so only the first prompt would have carried the image or audio and the rest would be text-only, silently changing the experiment. It now refuses whilependingImagesRef,pendingAudioReforaudioDecodingRefis non-empty, rather than clearing the attachment, which is the user's and not ours to discard.The third, namespace keys in the mixed saved-items menu, landed earlier in
ac6764c.Verification
npm teston Windows 11: 5217 pass, 0 fail. That includesprompt-list-drag-autoscroll.test.ts, which is the 10 tests this PR restores over #8692's suite.npm run typecheck,npm run buildandbundle:checkall pass; the bundle has 58.2 KB transfer to spare.eslint on the five shared files reports 94 problems here against 95 on #8692's head, so this adds none.
Before / after
Two isolated Studio installs, BEFORE =
mainat e22e297 (the PR's original merge base predates #8692, somainis the honest base now that #8692 has landed), AFTER = this branch at 47e10a8. One saved prompt and one three-item list seeded on each side.Prompt Lists tab. The list detail footer gains a bookmark button (clicked here, so it is filled), and the bookmarked list is marked in the master column.
"+" menu, Saved prompts. The bookmarked list appears below the saved prompt with a count bubble for its three prompts. Selecting it queues all three.
Drag autoscroll is not visible in a still; it is covered by
prompt-list-drag-autoscroll.test.ts.