Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(composer): animate the reasoning slider settle

ZeroY7d2e30c0ed0d
diff --git a/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx b/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
index a5175abac..f04a55d27 100644
--- a/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
+++ b/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState, type CSSProperties } from "react";
+import { useEffect, useRef, useState, type CSSProperties } from "react";
import type { TFunction } from "i18next";
import { formatTokenCount, modelIdsMatch } from "@pi-desktop/shared";
import { AnchoredMenu } from "../../../components/settings/AnchoredMenu";
@@ -93,6 +93,11 @@ export function ComposerModelPicker({
// never snaps back mid-drag. The lead clears once the store confirms.
const thinkingLevelsKey = thinkingMenuLevels.join("|");
const [dragThinkingIndex, setDragThinkingIndex] = useState<number | null>(null);
+ // Settle pulse: only when a drag commit has just landed (the drag lead goes
+ // from set to cleared) do we mark the control settling, which lets the
+ // thumb play its overshoot pop once. Opening the menu never settles.
+ const [settling, setSettling] = useState(false);
+ const settleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => {
setDragThinkingIndex(null);
}, [thinkingLevelsKey]);
@@ -100,15 +105,25 @@ export function ComposerModelPicker({
if (dragThinkingIndex === null) return;
if (thinkingMenuLevels[dragThinkingIndex] === thinkingLevel) {
setDragThinkingIndex(null);
+ setSettling(true);
+ if (settleTimerRef.current) clearTimeout(settleTimerRef.current);
+ settleTimerRef.current = setTimeout(() => setSettling(false), 220);
}
}, [dragThinkingIndex, thinkingLevel, thinkingLevelsKey, thinkingMenuLevels]);
+ useEffect(
+ () => () => {
+ if (settleTimerRef.current) clearTimeout(settleTimerRef.current);
+ },
+ [],
+ );
const thinkingSliderValue = dragThinkingIndex ?? thinkingSliderIndex;
- // The rail line spans the stop-to-stop distance (it starts and ends half a
- // column in), so the fill percentage is relative to that span: i/(n-1)
- // reaches exactly the active stop's column center and the thumb's x.
+ // The accent fill starts half a column in and its width is a fraction of
+ // the full rail width, so i/n reaches exactly the active stop's column
+ // center and the thumb's x. (The fill layer is the rail's ::after; its
+ // percentage is relative to the full rail width.)
const thinkingSliderPercent =
thinkingMenuLevels.length > 1
- ? (thinkingSliderValue / (thinkingMenuLevels.length - 1)) * 100
+ ? (thinkingSliderValue / thinkingMenuLevels.length) * 100
: 0;
return (
@@ -190,6 +205,8 @@ export function ComposerModelPicker({
{thinkingMenuLevels.length > 1 ? (
<div
className="composer-thinking-slider"
+ data-dragging={dragThinkingIndex !== null ? "true" : undefined}
+ data-settling={settling ? "true" : undefined}
style={{ "--stop-count": thinkingMenuLevels.length } as CSSProperties}
>
{/*
@@ -198,6 +215,12 @@ export function ComposerModelPicker({
all sit on the same column center for every stop count. The
range input is the accessible control and overlays the dots
row only, leaving the labels free to be clicked and hovered.
+
+ Motion: while a drag is in flight (data-dragging) the thumb,
+ dots and fill track the pointer with no transition so the
+ control feels direct; once the store confirms and the drag
+ lead clears, the settle transition plays (thumb pop, dot and
+ label color, fill slide). See composer-menus.css.
*/}
<div className="composer-thinking-rail">
<div className="composer-thinking-dots" aria-hidden="true">
diff --git a/apps/desktop/src/styles/composer-menus.css b/apps/desktop/src/styles/composer-menus.css
index c16864d59..7b629868c 100644
--- a/apps/desktop/src/styles/composer-menus.css
+++ b/apps/desktop/src/styles/composer-menus.css
@@ -267,22 +267,27 @@
}
/* The rail line spans the stop-to-stop distance: it starts and ends half a
- column in from the edges so its tips land on the first/last dot centers. */
-.composer-thinking-rail::before {
+ column in from the edges so its tips land on the first/last dot centers.
+ The muted base rail is ::before and the accent fill is ::after, a separate
+ layer whose width transitions smoothly between stops. */
+.composer-thinking-rail::before,
+.composer-thinking-rail::after {
content: "";
position: absolute;
top: var(--thinking-track-center);
left: calc(100% / (2 * var(--stop-count, 1)));
- right: calc(100% / (2 * var(--stop-count, 1)));
height: var(--thinking-track-height);
border-radius: var(--radius-full);
- background: linear-gradient(
- to right,
- var(--ds-accent) 0,
- var(--ds-accent) var(--composer-thinking-progress, 0%),
- var(--ds-border-subtle) var(--composer-thinking-progress, 0%),
- var(--ds-border-subtle) 100%
- );
+}
+
+.composer-thinking-rail::before {
+ right: calc(100% / (2 * var(--stop-count, 1)));
+ background: var(--ds-border-subtle);
+}
+
+.composer-thinking-rail::after {
+ width: var(--composer-thinking-progress, 0%);
+ background: var(--ds-accent);
}
/* One dot per stop, centered on the rail at each full-width column center. */
@@ -303,6 +308,10 @@
border-radius: var(--radius-full);
background: var(--ds-text-muted);
opacity: 0.55;
+ transition:
+ background-color var(--motion-duration-fast) var(--motion-ease-out),
+ opacity var(--motion-duration-fast) var(--motion-ease-out),
+ transform var(--motion-duration-fast) var(--motion-ease-out);
}
/* The thumb covers the selected dot; accent keeps a partial cover readable. */
@@ -361,6 +370,27 @@
background: var(--ds-accent);
}
+/* Settle feedback: the thumb plays a single overshoot pop only when a drag
+ commit has just landed (data-settling), never while dragging or on open.
+ The fill slides between stops whenever the control is not mid-drag. */
+.composer-thinking-slider[data-settling] .composer-thinking-range::-webkit-slider-thumb {
+ animation: composer-thinking-thumb-pop var(--motion-duration-normal)
+ cubic-bezier(0.34, 1.56, 0.64, 1);
+}
+.composer-thinking-slider[data-settling] .composer-thinking-range::-moz-range-thumb {
+ animation: composer-thinking-thumb-pop var(--motion-duration-normal)
+ cubic-bezier(0.34, 1.56, 0.64, 1);
+}
+.composer-thinking-slider:not([data-dragging]) .composer-thinking-rail::after {
+ transition: width var(--motion-duration-fast) var(--motion-ease-out);
+}
+
+@keyframes composer-thinking-thumb-pop {
+ 0% { transform: scale(1); }
+ 40% { transform: scale(1.25); }
+ 100% { transform: scale(1); }
+}
+
/* Labels form the same full-width n-column grid as the dots, so label i
centers under dot i and the thumb at index i. Long words ellipsize inside
the column; every label stays visible. */
@@ -411,6 +441,16 @@
.composer-model-thinking-menu {
animation: none;
}
+
+ .composer-thinking-range::-webkit-slider-thumb,
+ .composer-thinking-range::-moz-range-thumb {
+ animation: none;
+ }
+
+ .composer-thinking-rail::after,
+ .composer-thinking-dot {
+ transition: none;
+ }
}
.composer-model-heading {