Skip to content

Studio: make the run settings panel draggable - #7566

Merged
shimmyshimmer merged 1 commit into
mainfrom
studio-chat-settings-drag-resize
Jul 29, 2026
Merged

shimmyshimmer merged 1 commit into
mainfrom
studio-chat-settings-drag-resize

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Follows #7561, which landed PanelResizeHandle and createPanelWidthStore. Now rebased onto main and standalone.

The right-hand run settings panel is fixed at 17rem. Long preset names and the system prompt box have no room while the chat column often has space to spare, so this gives the panel the same draggable edge as the sidebar.

Behaviour

Identical to the sidebar, mirrored: the handle sits on the panel's left edge and the panel grows as the pointer moves left.

  • Drag to resize between 248px and 560px, additionally capped at 40% of the window.
  • Click the edge to close the panel, arrow keys nudge, Home restores the default 272px.
  • Width persists under chat_settings_width, separate from sidebar_width, so the two panels are independent.
  • Dragging inward stops at the minimum rather than closing.

The handle only renders while the panel is open, since closed it is 0px wide and there is no edge to grab. It is reopened from the existing toggle.

Sharing

No second copy of the drag logic. The direction inversion is a single edge prop, which the shared handle already had, and the store is the same factory with a different key, floor and ceiling.

Testing

npm run typecheck, npm run build and the unit tests pass.

Also driven under Playwright in Chromium, Firefox and WebKit against the real components: default width, handle placement on the left edge, inverted drag direction, clamping at both ends, no close-by-drag, persistence across reload, viewport cap and restore, cancelled drags, keyboard, and independence from the sidebar's stored width. 192 assertions, all passing in all three engines.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: adba11cac7

ℹ️ 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 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: 3dc2b93acc

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

const asideRef = useRef<HTMLElement>(null);
const t = useT();
const {
width: settingsWidth,

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 Recompute prompt overflow after resizing the panel

When a user resizes the panel across the width where the inline system prompt starts or stops wrapping, systemPromptOverflows remains stale because its measurement effect only depends on currentSystemPrompt and open. A newly overflowing prompt therefore may not open the popup editor when clicked, while a prompt widened enough to fit may still open it unnecessarily; remeasure when settingsWidth changes or observe the textarea's size.

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.

Confirmed and fixed in 5cd5574. The effect depended on [currentSystemPrompt, open], which was sufficient while the panel was a fixed width, so this is a regression this PR introduces rather than something pre-existing.

Went with observing the box rather than adding settingsWidth to the deps, because the drag lands the live width through a custom property without a re-render, so a width dependency would not fire until release and the affordance would lag the whole drag.

Verified by replicating the prompt box and its effect under Playwright: with the observer removed the flag stays false at both extremes, and with it in place it flips true when the panel is dragged to its minimum and back to false when widened. Passing in Chromium, Firefox and WebKit.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 5cd557441b

ℹ️ 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 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: 279d6fd436

ℹ️ 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 777 to 780
const observer = new ResizeObserver(measure);
observer.observe(el);
return () => observer.disconnect();
}, [currentSystemPrompt, open]);

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 Reattach the prompt observer after the textarea remounts

When the System Prompt section is collapsed, CollapsibleSection unmounts its textarea, but this observer remains attached to that detached element and the effect dependencies do not change when the section reopens. If the panel is resized while the section is closed, the newly mounted textarea is never observed and systemPromptOverflows retains the result from the old width, causing clicks to incorrectly open the editor or fail to open it for overflowing text. Track the section's mounted state or use a callback ref that observes each new textarea.

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.

Correct, and thanks for catching it. CollapsibleSection renders {open && <div className="pb-7">{children}</div>}, so collapsing the section genuinely unmounts the textarea. The stored observer kept watching the detached node, and the effect deps never changed on remount, so a panel resize while the section was closed left the overflow state stale.

Fixed in 0613243 by observing through a callback ref, so the observer always follows the live element:

const attachPromptBox = useCallback((node: HTMLTextAreaElement | null) => {
  systemPromptBoxRef.current = node;
  promptObserverRef.current?.disconnect();
  promptObserverRef.current = null;
  if (!node || typeof ResizeObserver === "undefined") return;
  const observer = new ResizeObserver(() => measurePromptRef.current());
  observer.observe(node);
  promptObserverRef.current = observer;
  measurePromptRef.current();
}, []);

Added a regression test for the exact sequence: widen the panel, collapse the section, resize while the textarea is unmounted, reopen, then assert the overflow flag matches the new width. It fails before the change and passes after. Full suite is 264/264 across Chromium 149, Firefox 151 and WebKit 26.5.

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

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

// browser sends next, whether it ended in a release or a cancel. This also
// runs as the effect cleanup, where no drag happened and a bare click from
// assistive tech must still get through.
if (dragRef.current) handledRef.current = 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 Clear the click guard when a drag is canceled

When an active pointer stream is canceled—for example, after an OS gesture or input-device interruption—no compatibility click follows that canceled sequence, yet endDrag() leaves handledRef armed. If the next activation is a bare synthesized click from switch or voice control, the onClick handler consumes it without toggling the panel. Arm the guard only on pointerup, or explicitly clear it on pointercancel.

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.

Right about the underlying problem, though the specific fix needed a bit of care. Two cases end a pointer sequence and they behave differently:

  1. A synthetic pointercancel followed by a real mouse release. The browser still emits a compatibility click, so clearing the guard on cancel reintroduces the collapse-on-release bug that an earlier regression test already covers.
  2. A genuine cancel, for example the OS taking over the pointer. No click follows, so a boolean guard stays armed forever and swallows the next click from switch or voice control. That is the bug you found.

A flag cannot distinguish the two, so I replaced it with a timestamp window in 6d89fc3 (cherry-picked onto #7561 as e0938f4):

const CLICK_COMPAT_WINDOW_MS = 300
...
if (Date.now() - handledAtRef.current < CLICK_COMPAT_WINDOW_MS) return
onToggle()

The compatibility click lands in the same tick, so it is still suppressed, and the guard self-heals after 300ms so a later assistive-technology click gets through. Keyboard toggles never arm it at all.

Both cases are now covered: the existing cancel-then-release test still passes, and a new test cancels the drag, waits past the window, dispatches a bare click and asserts it toggles. 264/264 across Chromium 149, Firefox 151 and WebKit 26.5.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 0613243512

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

Reviewed commit: 7c12f83bba

ℹ️ 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. Keep it up!

Reviewed commit: 869a962659

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

Base automatically changed from studio-sidebar-drag-resize to main July 29, 2026 05:16
The chat run settings panel was fixed at 17rem. It now uses the same drag
handle as the sidebar, on its left edge, between 248px and 560px and capped
at 40% of the window. The width persists and syncs across tabs.

Reuses PanelResizeHandle and createPanelWidthStore, so behaviour matches the
sidebar exactly. The panel width key joins the preference reset list.

The system prompt overflow check now runs off a ResizeObserver attached
through a callback ref. A drag changes the width through a custom property
without re-rendering, and the collapsible section unmounts the textarea, so
a stored observer would miss both.
@shimmyshimmer
shimmyshimmer force-pushed the studio-chat-settings-drag-resize branch from 869a962 to 9bc656c Compare July 29, 2026 05:23
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Rebased onto main now that #7561 has landed, which clears the conflicts.

#7561 was squash merged, so this branch was carrying the same changes under different commit hashes and every one of them collided. Rather than replay that history I reset the branch to main and reapplied the net run settings delta, so the PR is now a single commit containing only what is specific to this panel:

  • chat-settings-sheet.tsx
  • use-chat-settings-width.ts
  • the chat_settings_width entry in the preference reset list
  • the drag CSS in index.css
  • the reset-list guard in sidebar-width.test.ts

Everything shared (PanelResizeHandle, createPanelWidthStore, the locale strings) is already on main from #7561, so it is no longer duplicated here.

Two things on main touched the same file and both are preserved: the nParallel wiring in the settings sheet, and the panel wrapper styling, which this PR moves overflow-hidden off the aside and onto the inner container so the handle is not clipped.

Verified after the rebase: typecheck, test, i18n:check and build all pass, and the Playwright suite is 276/276 across Chromium 149, Firefox 151 and WebKit 26.5. Note npm install is needed on a stale tree, since main picked up @tauri-apps/plugin-deep-link in the meantime.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9bc656c904

ℹ️ 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 076c965 into main Jul 29, 2026
39 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-chat-settings-drag-resize branch July 29, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant