Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat(dictation): liquid cancel button, pill spacing, and overlay smoothness (#1886)

clarkmaanba2a6414a907
diff --git a/preload.js b/preload.js
index 5cd94212e..434e87102 100644
--- a/preload.js
+++ b/preload.js
@@ -502,6 +502,8 @@ contextBridge.exposeInMainWorld("electronAPI", {
getHyprlandConfigStatus: () => ipcRenderer.invoke("get-hyprland-config-status"),
startWindowDrag: () => ipcRenderer.invoke("start-window-drag"),
stopWindowDrag: () => ipcRenderer.invoke("stop-window-drag"),
+ startControlPanelDrag: () => ipcRenderer.invoke("start-control-panel-drag"),
+ stopControlPanelDrag: () => ipcRenderer.invoke("stop-control-panel-drag"),
getMainWindowHorizontalDirection: () =>
ipcRenderer.invoke("get-main-window-horizontal-direction"),
onMainWindowHorizontalDirectionChanged: registerListener(
diff --git a/scripts/run-electron.js b/scripts/run-electron.js
index 014930471..a2b9d9701 100644
--- a/scripts/run-electron.js
+++ b/scripts/run-electron.js
@@ -64,6 +64,11 @@ if (shouldForceXWayland(args)) {
// Chromium flags must come before the app path, app args after.
const chromiumFlags = args.filter((a) => a.startsWith(OZONE_PLATFORM_PREFIX));
+// Dev-only: OW_DEBUG_CDP=<port> exposes the Chrome DevTools Protocol so tools
+// can inspect the renderers (used for animation/window diagnostics).
+if (process.env.OW_DEBUG_CDP) {
+ chromiumFlags.push(`--remote-debugging-port=${process.env.OW_DEBUG_CDP}`);
+}
const appArgs = args.filter((a) => !a.startsWith(OZONE_PLATFORM_PREFIX));
const child = spawn(electronPath, [...chromiumFlags, appDir, ...appArgs], {
stdio: "inherit",
diff --git a/src/App.jsx b/src/App.jsx
index fce8bb8c6..31f3efc3d 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,6 +1,5 @@
import React, { useState, useEffect, useLayoutEffect, useRef } from "react";
import { useTranslation } from "react-i18next";
-import { X } from "lucide-react";
import "./index.css";
import { useToast } from "./components/ui/useToast";
import { useHotkey } from "./hooks/useHotkey";
@@ -22,6 +21,7 @@ import { LiveTranscriptPanel } from "./components/dictation/LiveTranscriptPanel"
import { VoiceModePanelCore } from "./components/dictation/VoiceModePanelCore";
import { PillTooltip } from "./components/dictation/PillTooltip";
import { PillCommandMenu } from "./components/dictation/PillCommandMenu";
+import { LiquidCancelButton } from "./components/dictation/LiquidCancelButton";
import { createMainWindowResizeCoordinator } from "./utils/mainWindowResizeCoordinator";
import {
ASSISTANT_FOOTER_TRANSITION_TIMING,
@@ -32,9 +32,11 @@ import {
resolveListeningEntrancePresentation,
resolveVoiceActivityPresentation,
resolveVoiceHorizontalDirection,
+ resolvePillVisualSuppression,
resolveVoicePanelCorePresentation,
resolveVoicePillDock,
resolveVoicePillInteraction,
+ VOICE_PILL_FOOTPRINT,
isVoicePillActivationKey,
shouldActivateVoicePill,
shouldOfferLiveTranscriptReopen,
@@ -276,7 +278,9 @@ export default function App() {
isAssistantVoice,
assistantThinking: assistant.thinking || assistant.busy,
});
- const listeningEntrancePhase = useListeningEntrancePhase(voicePillIsRecording);
+ const listeningEntrancePhase = useListeningEntrancePhase(voicePillIsRecording, {
+ afterAssistantFooterHandoff: assistant.open,
+ });
const listeningEntrance = resolveListeningEntrancePresentation({
isRecording: voicePillIsRecording,
phase: listeningEntrancePhase,
@@ -284,13 +288,13 @@ export default function App() {
const isCompactPill = voicePillIsRecording
? listeningEntrance.compactPill
: voiceActivity.compactPill;
- // The native window grows during the entrance's static thinking hold, not
- // when the pill starts its width transition: a setBounds landing mid
- // animation forces compositor work that visibly stutters the expansion, and
- // the growing pill can clip against the old bounds if the resize IPC lags.
+ // BASE and RECORDING resolve to the same native box (windowConfig.js), so
+ // recording edges never call setBounds — resizing the transparent window
+ // always kicks a compositor frame. This flag still feeds the size ladder so
+ // a menu opening over the compact pill resolves to EXPANDED geometry.
const windowFitsCompactPill = voicePillIsRecording || voiceActivity.compactPill;
- const { dictationErrorPillHandoffActive } = useMainWindowSizeOwner({
+ const { dictationErrorPillHandoffActive, panelReturnResizeActive } = useMainWindowSizeOwner({
requestMainWindowSize,
dictationErrorActionCount,
toastCount,
@@ -481,6 +485,19 @@ export default function App() {
isHovered,
});
const pillIsInteractive = voicePillInteraction.pillInteractive;
+ // The cancel button pours out of the pill as a fused liquid skin — except
+ // inside the Live Transcript panel, where the pill is already headless and
+ // the classic bordered circle stays (with the same emergence motion).
+ const [cancelSkinActive, setCancelSkinActive] = useState(false);
+ const cancelFused = !liveTranscript.open;
+ // isCompactPill tracks the pill's footprint through the entrance phases
+ // (logo-collapsed thinking renders 40×40 even while recording). These are
+ // targets, not rendered sizes: the pill transitions between footprints over
+ // GROW_TRANSITION, and the skin tweens its geometry to match
+ // (usePillFootprintTween in LiquidCancelButton).
+ const cancelPillFootprint = isCompactPill
+ ? VOICE_PILL_FOOTPRINT.recording
+ : VOICE_PILL_FOOTPRINT.idle;
const activateVoicePill = () => {
if (!pillIsInteractive) return;
if (canReopenLiveTranscript) {
@@ -539,21 +556,33 @@ export default function App() {
// Keep one pill DOM node alive while final Agent actions own the footer. On
// close it can fade and travel from the panel dock instead of mounting at
// the resting dock halfway through the surface contraction.
+ const pillHasLiveActivity = voicePillIsRecording || voicePillIsProcessing;
const assistantActionsSuppressPill = shouldSuppressPillForAssistantActions({
assistantOpen: assistant.open,
footerPillVisible: assistantFooter.pillVisible,
assistantClosing: assistant.closing,
- hasLiveActivity: voicePillIsRecording || voicePillIsProcessing,
+ hasLiveActivity: pillHasLiveActivity,
+ });
+ // assistant.closing folds the pill into the panel's own exit: it fades with
+ // the closing content, stays hidden through the surface contraction, the
+ // travel, and the masked window shrink (panelReturnResizeActive picks up at
+ // unmount), and materializes once at its settled dock — one beat, not a
+ // condense-then-blink. Live activity opts out of that fold: the pill is the
+ // only owner left once beginClose hides the companion.
+ const pillVisuallySuppressed = resolvePillVisualSuppression({
+ dictationErrorSuppressed: dictationErrorSuppressesPill,
+ assistantActionsSuppressed: assistantActionsSuppressPill,
+ assistantClosing: assistant.closing,
+ panelReturnResizeActive,
+ hasLiveActivity: pillHasLiveActivity,
});
- const pillVisuallySuppressed = dictationErrorSuppressesPill || assistantActionsSuppressPill;
- const pillInteractionSuppressed = pillVisuallySuppressed || assistant.closing;
return (
<div className="dictation-window">
{/* The panel footer can hide this pill, but never unmounts it. */}
<div
className={`voice-pill-position voice-pill-position-${voicePillDock} fixed z-50 transition-opacity duration-150 ease-out ${
- pillInteractionSuppressed ? "pointer-events-none" : ""
+ pillVisuallySuppressed ? "pointer-events-none" : ""
} ${pillVisuallySuppressed ? "opacity-0" : "opacity-100"}`}
style={{
"--voice-pill-travel-duration": `${voicePillTravelDuration}ms`,
@@ -563,7 +592,7 @@ export default function App() {
aria-hidden={pillVisuallySuppressed || undefined}
>
<div
- className="assistant-pill-presence relative flex items-center gap-2"
+ className="assistant-pill-presence relative flex items-center"
data-assistant-footer-phase={assistant.open ? assistant.footerPhase : undefined}
data-horizontal-direction={voiceHorizontalDirection}
style={{
@@ -599,6 +628,7 @@ export default function App() {
waveformVisible={listeningEntrance.waveformVisible}
waveformOnlyWhileRecording={anyPanelMounted}
integratedWithPanel={liveTranscript.open}
+ liquidFused={cancelSkinActive}
agentMode={agentModeActive}
showExpandChevron={canReopenLiveTranscript && isHovered}
getAudioLevel={getAudioLevel}
@@ -662,24 +692,21 @@ export default function App() {
}}
/>
</PillTooltip>
- {voicePillInteraction.cancelVisible && (
- <button
- type="button"
- aria-label={
- isRecording ? t("app.buttons.cancelRecording") : t("app.buttons.cancelProcessing")
- }
- onMouseDown={(event) => event.stopPropagation()}
- onClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- if (isRecording) cancelRecording();
- else cancelProcessing();
- }}
- className="flex size-7 shrink-0 items-center justify-center rounded-full border border-border/55 bg-surface-2 text-muted-foreground shadow-sm transition-colors hover:bg-surface-3 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
- >
- <X size={13} strokeWidth={2.5} aria-hidden="true" />
- </button>
- )}
+ <LiquidCancelButton
+ visible={voicePillInteraction.cancelVisible}
+ fused={cancelFused}
+ pillWidth={cancelPillFootprint.width}
+ pillHeight={cancelPillFootprint.height}
+ pillState={commonPillState}
+ ariaLabel={
+ isRecording ? t("app.buttons.cancelRecording") : t("app.buttons.cancelProcessing")
+ }
+ onCancel={() => {
+ if (isRecording) cancelRecording();
+ else cancelProcessing();
+ }}
+ onFusedSkinChange={setCancelSkinActive}
+ />
{!anyPanelMounted && isCommandMenuOpen && (
<PillCommandMenu
buttonRef={buttonRef}
diff --git a/src/AppRouter.jsx b/src/AppRouter.jsx
index d281fff70..0ca3815d6 100644
--- a/src/AppRouter.jsx
+++ b/src/AppRouter.jsx
@@ -8,6 +8,7 @@ import UpdateNotificationOverlay from "./components/UpdateNotificationOverlay.ts
import BackgroundModelDownloadTray from "./components/onboarding/BackgroundModelDownloadTray.tsx";
import { LEGACY_ONBOARDING_STEP_KEY, ONBOARDING_SESSION_KEY } from "./components/onboarding/flow";
import { useAuth } from "./hooks/useAuth";
+import { useControlPanelWindowDrag } from "./hooks/useControlPanelWindowDrag";
import { useTheme } from "./hooks/useTheme";
import { usePolicyStore } from "./stores/policyStore";
import { resolveSettledControlPanelWindowMode } from "./utils/controlPanelWindowMode.ts";
@@ -59,6 +60,8 @@ function MainApp() {
const isControlPanel = isControlPanelWindow();
const isDictationPanel = !isControlPanel;
+ // Covers every surface this window hosts: onboarding, reauth, the panel.
+ useControlPanelWindowDrag(isControlPanel);
useEffect(() => {
if (isControlPanel) {
diff --git a/src/components/AuthenticationStep.tsx b/src/components/AuthenticationStep.tsx
index 71545b599..109d6f139 100644
--- a/src/components/AuthenticationStep.tsx
+++ b/src/components/AuthenticationStep.tsx
@@ -1,4 +1,5 @@
import React, { useCallback, useEffect, useState, useRef } from "react";
+import { createPortal } from "react-dom";
import { useTranslation } from "react-i18next";
import { useAuth } from "../hooks/useAuth";
import {
@@ -113,6 +114,11 @@ const AppleIcon = ({ className }: { className?: string }) => (
</svg>
);
+/** Lift a compact-window control out of the step tree so it can out-stack the
+ * onboarding shell's drag band; embedded (SignInDialog) has no band to escape. */
+const withCompactPortal = (embedded: boolean, control: React.ReactElement) =>
+ embedded ? control : createPortal(control, document.body);
+
export default function AuthenticationStep({
onContinueWithoutAccount,
onAuthComplete,
@@ -490,20 +496,33 @@ export default function AuthenticationStep({
{t("auth.welcomeSubtitle")}
</p>
- <button
- type="button"
- onClick={handleBack}
- className={
- embedded
- ? "mb-3 inline-flex h-8 items-center gap-1 text-xs text-[var(--onboarding-text-secondary)] transition-colors hover:text-[var(--onboarding-text-primary)]"
- : "absolute left-5 top-13 inline-flex h-8 items-center gap-1 text-xs font-medium text-white/80 transition-colors hover:text-white"
- }
- style={embedded ? undefined : ({ WebkitAppRegion: "no-drag" } as React.CSSProperties)}
- disabled={isSubmitting}
- >
- <ChevronLeft className="size-3.5" />
- {t("auth.common.back")}
- </button>
+ {/* The compact Back sits at y=52, inside the onboarding shell's drag
+ band — which spans the full 192px hero on compact screens. Nothing
+ in the step tree can out-stack that z-50 band (the step wrapper's
+ entry animation keeps a transform, so its descendants are capped
+ regardless of z-index — see OnboardingShell), so it has to leave
+ the tree entirely or its clicks are swallowed and this screen has
+ no way back. Portalled to body exactly like CompactPermissionsStep's
+ Continue; no-drag keeps both the JS drag fallback and the
+ Windows/Linux app-region off it. Embedded in SignInDialog there is
+ no band, so it stays inline. */}
+ {withCompactPortal(
+ embedded,
+ <button
+ type="button"
+ onClick={handleBack}
+ className={
+ embedded
+ ? "mb-3 inline-flex h-8 items-center gap-1 text-xs text-[var(--onboarding-text-secondary)] transition-colors hover:text-[var(--onboarding-text-primary)]"
+ : "fixed left-5 top-13 z-[60] inline-flex h-8 items-center gap-1 text-xs font-medium text-white/80 transition-colors hover:text-white"
+ }
+ style={embedded ? undefined : ({ WebkitAppRegion: "no-drag" } as React.CSSProperties)}
+ disabled={isSubmitting}
+ >
+ <ChevronLeft className="size-3.5" />
+ {t("auth.common.back")}
+ </button>
+ )}
<form onSubmit={handleSubmit} className="mt-4 space-y-3 text-left">
<label className="block space-y-2">
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index e15627be7..3b05da521 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -1030,6 +1030,7 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
{isSidePanelLayout && (
<div
className={platform === "darwin" ? "ml-[84px] mt-[16px]" : "ml-2"}
+ data-no-window-drag=""
style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
>
<Button
@@ -1045,7 +1046,11 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
)}
<div className="flex-1" />
{platform !== "darwin" && (
- <div className="pr-1" style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}>
+ <div
+ className="pr-1"
+ data-no-window-drag=""
+ style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
+ >
<WindowControls />
</div>
)}
@@ -1240,6 +1245,7 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
className={`absolute z-40 flex h-10 items-center ${
platform === "darwin" ? "left-21 top-2" : "left-2 top-0"
}`}
+ data-no-window-drag=""
style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
onMouseEnter={sidebarCollapsed ? showSidebarPeek : undefined}
onMouseLeave={sidebarCollapsed ? leaveSidebarToggle : undefined}
diff --git a/src/components/dictation/AgentDictationPillOverlay.tsx b/src/components/dictation/AgentDictationPillOverlay.tsx
index 6ebc292cc..5d4f946c4 100644
--- a/src/components/dictation/AgentDictationPillOverlay.tsx
+++ b/src/components/dictation/AgentDictationPillOverlay.tsx
@@ -6,12 +6,12 @@ import {
useState,
type CSSProperties,
} from "react";
-import { X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { useListeningEntrancePhase } from "../../hooks/useListeningEntrancePhase";
import { useLiveTranscriptPanel } from "../../hooks/useLiveTranscriptPanel";
import {
LIVE_TRANSCRIPT_ENTRANCE_TIMING,
+ VOICE_PILL_FOOTPRINT,
resolveCompanionPillInteractive,
resolveListeningEntrancePresentation,
resolveLiveTranscriptEntrancePresentation,
@@ -20,6 +20,7 @@ import {
resolveVoicePillInteraction,
shouldOfferLiveTranscriptReopen,
} from "../../helpers/voicePillPresentation";
+import { LiquidCancelButton } from "./LiquidCancelButton";
import { LiveTranscriptPanel, type LiveTranscriptPhase } from "./LiveTranscriptPanel";
import { VoiceModePanelCore, type VoiceModePanelStage } from "./VoiceModePanelCore";
import { VoicePill, type VoicePillState } from "./VoicePill";
@@ -170,6 +171,11 @@ export default function AgentDictationPillOverlay() {
? "hover"
: "idle")) as VoicePillState;
const expanded = isRecording ? listeningEntrance.compactPill : voiceActivity.compactPill;
+ // Same liquid cancel as the main pill (App.jsx): footprint targets for the
+ // skin's geometry tween, and the pill goes headless while the skin owns the
+ // fused surface.
+ const [cancelSkinActive, setCancelSkinActive] = useState(false);
+ const cancelPillFootprint = expanded ? VOICE_PILL_FOOTPRINT.recording : VOICE_PILL_FOOTPRINT.idle;
// The shared rule (a mounted transcript locks the pill except while
// recording) comes from the tested helper; the companion additionally
// requires main-process consent and no transcript still processing.
@@ -218,7 +224,7 @@ export default function AgentDictationPillOverlay() {
}}
onMouseLeave={() => setHovered(false)}
>
- <div className="relative flex items-center gap-2">
+ <div className="relative flex items-center">
<VoicePill
variant={liveTranscript.open ? "panel" : "floating"}
state={state}
@@ -227,6 +233,7 @@ export default function AgentDictationPillOverlay() {
waveformVisible={listeningEntrance.waveformVisible}
waveformOnlyWhileRecording={liveTranscript.mounted}
integratedWithPanel={liveTranscript.open}
+ liquidFused={cancelSkinActive}
showExpandChevron={canReopenLiveTranscript && hovered}
getAudioLevel={getAudioLevel}
horizontalDirection={horizontalDirection}
@@ -235,22 +242,20 @@ export default function AgentDictationPillOverlay() {
aria-disabled={!pillInteractive}
onClick={activatePill}
/>
- {cancelVisible && (
- <button
- type="button"
- aria-label={
- isRecording ? t("app.buttons.cancelRecording") : t("app.buttons.cancelProcessing")
- }
- onClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- void window.electronAPI.cancelAgentPanelDictation?.();
- }}
- className="flex size-7 shrink-0 items-center justify-center rounded-full border border-border/55 bg-surface-2 text-muted-foreground shadow-sm transition-colors hover:bg-surface-3 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
- >
- <X size={13} strokeWidth={2.5} aria-hidden="true" />
- </button>
- )}
+ <LiquidCancelButton
+ visible={cancelVisible}
+ fused={!liveTranscript.open}
+ pillWidth={cancelPillFootprint.width}
+ pillHeight={cancelPillFootprint.height}
+ pillState={state}
+ ariaLabel={
+ isRecording ? t("app.buttons.cancelRecording") : t("app.buttons.cancelProcessing")
+ }
+ onCancel={() => {
+ void window.electronAPI.cancelAgentPanelDictation?.();
+ }}
+ onFusedSkinChange={setCancelSkinActive}
+ />
</div>
</div>
diff --git a/src/components/dictation/LiquidCancelButton.tsx b/src/components/dictation/LiquidCancelButton.tsx
new file mode 100644
index 000000000..d5a36f810
--- /dev/null
+++ b/src/components/dictation/LiquidCancelButton.tsx
@@ -0,0 +1,231 @@
+import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
+import { X } from "lucide-react";
+import { cn } from "../lib/utils";
+import { emergenceBlend, traceFusedOutline } from "./liquidFusion";
+import type { VoicePillState } from "./VoicePill";
+import { LISTENING_ENTRANCE_TIMING, VOICE_PILL_CANCEL } from "../../helpers/voicePillPresentation";
+
+const { size: CANCEL_BUTTON_SIZE, gap: CANCEL_BUTTON_GAP } = VOICE_PILL_CANCEL;
+const EMERGENCE_MS = 280;
+// The pill's chrome fade (VoicePill's inline 220ms background/border/shadow
+// transition, mirrored by .liquid-cancel-skin's fill/stroke) — change together.
+const CHROME_HANDOFF_MS = 220;
+
+// cubic-bezier(0.2, 0, 0, 1) — the house motion curve, solved numerically so
+// this rAF-driven emergence matches the CSS transitions around it.
+function houseEase(x: number): number {
+ if (x <= 0) return 0;
+ if (x >= 1) return 1;
+ let lo = 0;
+ let hi = 1;
+ let u = x;
+ for (let i = 0; i < 24; i++) {
+ const inv = 1 - u;
+ const bx = 0.6 * u * inv * inv + u * u * u;
+ if (bx < x) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ const inv = 1 - u;
+ return 3 * inv * u * u + u * u * u;
+}
+
+/** Drives the cancel button's emergence progress: 0 = swallowed by the pill,
+ * 1 = at rest beside it. Reversing mid-flight resumes from the current value. */
+function useCancelEmergence(visible: boolean): number {
+ const [t, setT] = useState(visible ? 1 : 0);
+ const raf = useRef(0);
+ const tRef = useRef(t);
+ tRef.current = t;
+
+ useEffect(() => {
+ const target = visible ? 1 : 0;
+ const from = tRef.current;
+ if (from === target) return;
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;
+ const duration = reduced ? 1 : EMERGENCE_MS * Math.abs(target - from);
+ let start = 0;
+ const step = (now: number) => {
+ if (!start) start = now;
+ const p = Math.min(1, (now - start) / duration);
+ setT(from + (target - from) * houseEase(p));
+ if (p < 1) raf.current = requestAnimationFrame(step);
+ };
+ raf.current = requestAnimationFrame(step);
+ return () => cancelAnimationFrame(raf.current);
+ }, [visible]);
+
+ return t;
+}
+
+/** Chases the pill footprint contract with the pill's own width/height
+ * transition (VOICE_PILL_GROW_TRANSITION: expansionMs on the house curve),
+ * so the skin never snaps while the real pill is mid-flight between
+ * footprints — the entrance's logo hold → compact expansion and the
+ * compact → thinking collapse at stop. It keeps chasing even while the skin
+ * is hidden so an emergence that starts mid-flight picks up the pill's
+ * current in-between size. Reduced motion snaps: the global reduced-motion
+ * rule drops width/height from transition-property, so the pill snaps too. */
+function usePillFootprintTween(width: number, height: number): { w: number; h: number } {
+ const [size, setSize] = useState({ w: width, h: height });
+ const raf = useRef(0);
+ const sizeRef = useRef(size);
+ sizeRef.current = size;
+
+ useEffect(() => {
+ const from = sizeRef.current;
+ if (from.w === width && from.h === height) return;
+ if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
+ setSize({ w: width, h: height });
+ return;
+ }
+ let start = 0;
+ const step = (now: number) => {
+ if (!start) start = now;
+ const p = Math.min(1, (now - start) / LISTENING_ENTRANCE_TIMING.expansionMs);
+ const e = houseEase(p);
+ setSize({ w: from.w + (width - from.w) * e, h: from.h + (height - from.h) * e });
+ if (p < 1) raf.current = requestAnimationFrame(step);
+ };
+ raf.current = requestAnimationFrame(step);
+ return () => cancelAnimationFrame(raf.current);
+ }, [width, height]);
+
+ return size;
+}
+
+interface LiquidCancelButtonProps {
+ visible: boolean;
+ /** Fused mode draws the liquid skin and the pill goes headless; plain mode
+ * (inside the Live Transcript panel, where the pill is already headless)
+ * keeps the classic bordered circle and only animates scale/fade. */
+ fused: boolean;
+ /** Footprint targets, not rendered sizes: the pill transitions between the
+ * footprints and the skin tweens its geometry to match (usePillFootprintTween). */
+ pillWidth: number;
+ pillHeight: number;
+ /** The pill state the skin replaces; keys the skin's stroke/fill to the
+ * pill's own chrome via .liquid-cancel-skin[data-pill-state] CSS. */
+ pillState: VoicePillState;
+ ariaLabel: string;
+ onCancel: () => void;
+ /** Fires when the fused skin starts/stops owning the pill surface, so the
+ * pill can go headless without the parent re-rendering every rAF frame. */
+ onFusedSkinChange?: (active: boolean) => void;
+}
+
+export function LiquidCancelButton({
+ visible,
+ fused,
+ pillWidth,
+ pillHeight,
+ pillState,
+ ariaLabel,
+ onCancel,
+ onFusedSkinChange,
+}: LiquidCancelButtonProps) {
+ // The 60fps emergence lives here so only this leaf re-renders per frame.
+ const t = useCancelEmergence(visible);
+ const pillSize = usePillFootprintTween(pillWidth, pillHeight);
+ const skinActive = fused && t > 0;
+ const [skinLingers, setSkinLingers] = useState(false);
+ const notifyRef = useRef(onFusedSkinChange);
+ notifyRef.current = onFusedSkinChange;
+ const skinWasActiveRef = useRef(false);
+ useLayoutEffect(() => {
+ notifyRef.current?.(skinActive);
+ const wasActive = skinWasActiveRef.current;
+ skinWasActiveRef.current = skinActive;
+ if (skinActive) {
+ setSkinLingers(false);
+ return undefined;
+ }
+ if (!wasActive) return undefined;
+ // Releasing the surface fades the pill's own chrome back in over
+ // CHROME_HANDOFF_MS. The swallowed skin (t=0) is geometry-identical to
+ // the bare pill, so keep painting it underneath until that fade lands —
+ // unmounting it mid-fade dips the capsule to the faded chrome. (Fuse-in
+ // is masked the same way for free: the skin mounts under the pill's
+ // still-painted chrome as it fades out.)
+ setSkinLingers(true);
+ const timer = setTimeout(() => setSkinLingers(false), CHROME_HANDOFF_MS + 40);
+ return () => clearTimeout(timer);
+ }, [skinActive]);
+
+ const slotWidth = t * (CANCEL_BUTTON_GAP + CANCEL_BUTTON_SIZE);
+ // The fused bud overlaps the pill until its slot is at least one button wide,
+ // so it stays inert until it clears. Plain mode scales in on its own hit area
+ // and is the panel's persistent discard control — it must be clickable at
+ // mount, as it was before the emergence motion existed.
+ const buttonInteractive = visible && (!fused || slotWidth >= CANCEL_BUTTON_SIZE);
+ const showSkin = skinActive || (fused && skinLingers);
+ const outline = useMemo(() => {
+ if (!showSkin) return null;
+ return traceFusedOutline(
+ {
+ pill: { w: pillSize.w, h: pillSize.h },
+ circle: {
+ cx: pillSize.w + slotWidth - CANCEL_BUTTON_SIZE / 2,
+ cy: pillSize.h / 2,
+ r: CANCEL_BUTTON_SIZE / 2,
+ },
+ },
+ { k: emergenceBlend(t) }
+ );
+ }, [showSkin, t, pillSize, slotWidth]);
+
+ if (t <= 0 && !skinLingers) return null;
+
+ return (
+ <div className="relative shrink-0" style={{ width: slotWidth, height: CANCEL_BUTTON_SIZE }}>
+ {outline && (
+ <svg
+ aria-hidden="true"
+ className="liquid-cancel-skin absolute"
+ data-pill-state={pillState}
+ viewBox={`${outline.minX} ${outline.minY} ${outline.width} ${outline.height}`}
+ style={{
+ left: outline.minX - pillSize.w,
+ top: outline.minY - (pillSize.h - CANCEL_BUTTON_SIZE) / 2,
+ width: outline.width,
+ height: outline.height,
+ zIndex: -1,
+ }}
+ >
+ <path d={outline.d} strokeWidth="1" />
+ </svg>
+ )}
+ <button
+ type="button"
+ aria-label={ariaLabel}
+ aria-hidden={!buttonInteractive || undefined}
+ disabled={!buttonInteractive}
+ tabIndex={buttonInteractive ? undefined : -1}
+ onMouseDown={(event) => event.stopPropagation()}
+ onClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ onCancel();
+ }}
+ className={cn(
+ "absolute right-0 top-0 flex items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
+ !fused && "border border-border/55 bg-surface-2 shadow-sm hover:bg-surface-3",
+ !buttonInteractive && "pointer-events-none"
+ )}
+ style={{
+ // Sized from the shared contract, not a utility class: the skin traces
+ // its circle at CANCEL_BUTTON_SIZE / 2, so a literal here would let the
+ // outline and the real control drift apart.
+ width: CANCEL_BUTTON_SIZE,
+ height: CANCEL_BUTTON_SIZE,
+ // The glyph surfaces once the bud is mostly out; plain mode just
+ // scales in with the slot.
+ opacity: fused ? Math.max(0, (t - 0.35) / 0.65) : t,
+ transform: fused ? undefined : `scale(${t})`,
+ }}
+ >
+ <X size={13} strokeWidth={2.5} aria-hidden="true" />
+ </button>
+ </div>
+ );
+}
diff --git a/src/components/dictation/VoicePill.tsx b/src/components/dictation/VoicePill.tsx
index eff7775d1..a05db036e 100644
--- a/src/components/dictation/VoicePill.tsx
+++ b/src/components/dictation/VoicePill.tsx
@@ -5,8 +5,8 @@ import { PillWaveform } from "./PillWaveform";
import { VoiceIdentityIcon } from "./VoiceIdentityIcon";
import { RESTING_WAVE_SILHOUETTE, WAVEFORM_BAR_COUNT } from "./waveformMath";
import {
- LISTENING_ENTRANCE_TIMING,
VOICE_PILL_FOOTPRINT,
+ VOICE_PILL_GROW_TRANSITION,
} from "../../helpers/voicePillPresentation";
export type VoicePillState =
@@ -21,13 +21,14 @@ interface VoicePillProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"
waveformVisible?: boolean;
waveformOnlyWhileRecording?: boolean;
integratedWithPanel?: boolean;
+ /** The cancel button's liquid skin owns the fused surface; go headless. */
+ liquidFused?: boolean;
agentMode?: boolean;
showExpandChevron?: boolean;
isDragging?: boolean;
horizontalDirection?: "left" | "right";
}
-const GROW_TRANSITION = `${LISTENING_ENTRANCE_TIMING.expansionMs}ms cubic-bezier(0.2, 0, 0, 1)`;
// Sized from WAVEFORM_BAR_COUNT so a bar-count change can never silently
// desync the resting silhouette from the live waveform's footprint.
const RESTING_WAVE_HEIGHTS = Array.from(
@@ -35,6 +36,14 @@ const RESTING_WAVE_HEIGHTS = Array.from(
(_, index) => RESTING_WAVE_SILHOUETTE[index % RESTING_WAVE_SILHOUETTE.length]
);
+// Icon↔waveform spacing inside the compact pill. Together with the 98px
+// recording footprint and pr-1.5, centering lands the documented 6/12 edge
+// insets (VOICE_PILL_FOOTPRINT in voicePillPresentation.js).
+const COMPACT_CONTENT_GAP_PX = 6;
+
+// Mirrored by .liquid-cancel-skin[data-pill-state] in dictation-panel.css,
+// which redraws this chrome while the cancel skin owns the fused surface —
+// change together.
const STATE_APPEARANCE: Record<VoicePillState, string> = {
idle: "border-border-hover bg-surface-1 text-muted-foreground dark:border-border/50",
hover: "border-border-hover bg-surface-3 text-foreground",
@@ -55,6 +64,7 @@ export const VoicePill = forwardRef<HTMLDivElement, VoicePillProps>(function Voi
waveformVisible = true,
waveformOnlyWhileRecording = false,
integratedWithPanel = false,
+ liquidFused = false,
agentMode = false,
showExpandChevron = false,
isDragging = false,
@@ -79,7 +89,9 @@ export const VoicePill = forwardRef<HTMLDivElement, VoicePillProps>(function Voi
const showCompactPill =
!collapseToIdentity && (isRecording || expanded || (isPanel && !waveformOnlyWhileRecording));
const showDivider = showCompactPill && waveformVisible && !isRecording;
- const dividerMargin = showCompactPill ? (showDivider ? 4 : 3) : 0;
+ // The hidden divider's margins are what carry the compact pill's 6px
+ // icon↔waveform gap; a visible divider keeps 4px flanking its 1px rule.
+ const dividerMargin = showCompactPill ? (showDivider ? 4 : COMPACT_CONTENT_GAP_PX / 2) : 0;
const identitySize = 22;
const floatingHover = !isPanel && state === "hover";
const footprint = showCompactPill ? VOICE_PILL_FOOTPRINT.recording : VOICE_PILL_FOOTPRINT.idle;
@@ -89,7 +101,7 @@ export const VoicePill = forwardRef<HTMLDivElement, VoicePillProps>(function Voi
ref={ref}
className={cn(
"voice-pill-control relative flex items-center justify-center overflow-hidden rounded-full border",
- showCompactPill && "pr-1",
+ showCompactPill && "pr-1.5",
"shadow-[var(--shadow-card)]",
STATE_APPEARANCE[state],
className
@@ -101,12 +113,16 @@ export const VoicePill = forwardRef<HTMLDivElement, VoicePillProps>(function Voi
width: footprint.width,
height: footprint.height,
cursor: isProcessing || isThinking ? "not-allowed" : isDragging ? "grabbing" : "pointer",
- boxShadow: floatingHover ? "var(--shadow-card-hover-subtle)" : undefined,
- transition: `width ${GROW_TRANSITION}, height ${GROW_TRANSITION}, padding-left ${GROW_TRANSITION}, padding-right ${GROW_TRANSITION}, background-color 220ms ease-out, border-color 220ms ease-out, box-shadow 220ms ease-out`,
+ // Yields to the fused rule's `box-shadow: none` while the liquid skin
+ // owns the chrome — an inline shadow would outrank it and paint a
+ // phantom capsule when a de-fusing skin lingers over a hovered pill.
+ boxShadow: floatingHover && !liquidFused ? "var(--shadow-card-hover-subtle)" : undefined,
+ transition: `width ${VOICE_PILL_GROW_TRANSITION}, height ${VOICE_PILL_GROW_TRANSITION}, padding-left ${VOICE_PILL_GROW_TRANSITION}, padding-right ${VOICE_PILL_GROW_TRANSITION}, background-color 220ms ease-out, border-color 220ms ease-out, box-shadow 220ms ease-out`,
...style,
}}
data-horizontal-direction={horizontalDirection}
data-integrated-with-panel={integratedWithPanel || undefined}
+ data-liquid-fused={liquidFused || undefined}
data-agent-mode={agentMode || undefined}
data-agent-beam-active={(agentMode && isThinking) || undefined}
data-expand-chevron={showExpandChevron || undefined}
@@ -155,7 +171,7 @@ export const VoicePill = forwardRef<HTMLDivElement, VoicePillProps>(function Voi
marginLeft: dividerMargin,
marginRight: dividerMargin,
opacity: showDivider ? 1 : 0,
- transition: `width ${GROW_TRANSITION}, margin ${GROW_TRANSITION}, opacity 180ms ease-out`,
+ transition: `width ${VOICE_PILL_GROW_TRANSITION}, margin ${VOICE_PILL_GROW_TRANSITION}, opacity 180ms ease-out`,
}}
/>
@@ -164,7 +180,7 @@ export const VoicePill = forwardRef<HTMLDivElement, VoicePillProps>(function Voi
style={{
width: showCompactPill ? 52 : 0,
height: showCompactPill ? 24 : 32,
- transition: `width ${GROW_TRANSITION}, height ${GROW_TRANSITION}`,
+ transition: `width ${VOICE_PILL_GROW_TRANSITION}, height ${VOICE_PILL_GROW_TRANSITION}`,
}}
>
<div
diff --git a/src/components/dictation/liquidFusion.ts b/src/components/dictation/liquidFusion.ts
new file mode 100644
index 000000000..71c9d0e6c
--- /dev/null
+++ b/src/components/dictation/liquidFusion.ts
@@ -0,0 +1,266 @@
+// Minimal liquid-fusion geometry for the pill's cancel button: the smooth-union
+// of two signed-distance fields traced into one SVG path. Extracted from the
+// "Liquid UI" engine (sdRoundBox + smin + marching squares); only what the
+// cancel emergence needs survives — two fixed shapes, one outline, no engine.
+//
+// Convention: the field is negative inside a shape, 0 on the surface, positive
+// outside. The fused outline is the iso-contour at 0. `smin` is the fillet
+// maker: k=0 is a hard union (sharp seam); larger k blends the fields near the
+// seam into the concave neck that makes the button read as poured out of the
+// pill.
+
+interface Pt {
+ x: number;
+ y: number;
+}
+
+export interface FusionShapes {
+ /** Pill rect at (0,0)..(w,h), radius h/2 (the rounded-full capsule). */
+ pill: { w: number; h: number };
+ /** Cancel circle center + radius, in the same space. */
+ circle: { cx: number; cy: number; r: number };
+}
+
+export interface FusionOptions {
+ /** Blend distance (px). Sized so the resting 8px pill↔button gap keeps a neck. */
+ k?: number;
+ /** Marching-squares grid step (px). */
+ cell?: number;
+ /** Chaikin smoothing passes on the traced loops. */
+ smooth?: number;
+}
+
+export const CANCEL_FUSION_DEFAULTS: Required<FusionOptions> = {
+ k: 24,
+ cell: 2,
+ smooth: 3,
+};
+
+/** Blend ramp for the cancel emergence. smin bulges up to ~k/4 outside a hard
+ * union, so a constant k would pop the skin 6px past the bare pill the moment
+ * it mounts. A smoothstep from a hard union (t=0, skin ≡ pill) to the full
+ * fillet keeps the handoff seamless and grows the neck gradually as the bud
+ * pushes out — a linear ramp reads as a step mid-flight. */
+export function emergenceBlend(t: number, k = CANCEL_FUSION_DEFAULTS.k): number {
+ const c = Math.max(0, Math.min(1, t));
+ return k * c * c * (3 - 2 * c);
+}
+
+function sdRoundBox(
+ px: number,
+ py: number,
+ cx: number,
+ cy: number,
+ hw: number,
+ hh: number,
+ r: number
+): number {
+ const rr = Math.min(r, Math.min(hw, hh));
+ const qx = Math.abs(px - cx) - hw + rr;
+ const qy = Math.abs(py - cy) - hh + rr;
+ const outside = Math.hypot(Math.max(qx, 0), Math.max(qy, 0));
+ const inside = Math.min(Math.max(qx, qy), 0);
+ return outside + inside - rr;
+}
+
+export function smin(a: number, b: number, k: number): number {
+ if (k <= 0) return Math.min(a, b);
+ const h = Math.max(0, Math.min(1, 0.5 + (0.5 * (b - a)) / k));
+ return b * (1 - h) + a * h - k * h * (1 - h);
+}
+
+function fieldEval(s: FusionShapes, k: number, x: number, y: number): number {
+ const { pill, circle } = s;
+ const dPill = sdRoundBox(x, y, pill.w / 2, pill.h / 2, pill.w / 2, pill.h / 2, pill.h / 2);
+ const dCircle = Math.hypot(x - circle.cx, y - circle.cy) - circle.r;
+ return smin(dPill, dCircle, k);
+}
+
+// Marching-squares edge table: for each 4-corner inside/outside mask, the cell
+// edges the contour crosses. Edges: 0=top, 1=right, 2=bottom, 3=left. Corner
+// bits: 8=TL, 4=TR, 2=BR, 1=BL (set = inside). Saddles (5, 10) are resolved by
+// the cell-center sign at trace time.
+const SADDLE_TL_BR: number[][] = [
+ [3, 0],
+ [2, 1],
+];
+const SADDLE_TR_BL: number[][] = [
+ [3, 2],
+ [0, 1],
+];
+const EDGES: number[][][] = [
+ [],
+ [[3, 2]],
+ [[2, 1]],
+ [[3, 1]],
+ [[0, 1]],
+ SADDLE_TR_BL,
+ [[0, 2]],
+ [[3, 0]],
+ [[3, 0]],
+ [[0, 2]],
+ SADDLE_TL_BR,
+ [[0, 1]],
+ [[3, 1]],
+ [[2, 1]],
+ [[3, 2]],
+ [],
+];
+
+function lerpEdge(x0: number, y0: number, v0: number, x1: number, y1: number, v1: number): Pt {
+ const denom = v0 - v1;
+ const t = Math.abs(denom) < 1e-6 ? 0.5 : Math.max(0, Math.min(1, v0 / denom));
+ return { x: x0 + (x1 - x0) * t, y: y0 + (y1 - y0) * t };
+}
+
+function stitch(segs: [Pt, Pt][], cell: number): Pt[][] {
+ // Matching endpoints are computed identically by adjacent cells, so this
+ // bucket rounding only absorbs float noise. eps must stay well below the
+ // narrowest contour-to-contour clearance (the smin neck), or two passing
+ // branches could stitch into one garbled loop — revisit if k/cell change.
+ const eps = cell * 0.5;
+ const key = (p: Pt) => `${Math.round(p.x / eps)},${Math.round(p.y / eps)}`;
+ const map = new Map<string, { seg: number; end: 0 | 1 }[]>();
+ segs.forEach((s, idx) => {
+ for (const end of [0, 1] as const) {
+ const k = key(s[end]);
+ const arr = map.get(k);
+ if (arr) arr.push({ seg: idx, end });
+ else map.set(k, [{ seg: idx, end }]);
+ }
+ });
+
+ const used = new Array(segs.length).fill(false);
+ const loops: Pt[][] = [];
+ for (let start = 0; start < segs.length; start++) {
+ if (used[start]) continue;
+ const loop: Pt[] = [];
+ let cur = start;
+ let end: 0 | 1 = 0;
+ let guard = 0;
+ while (!used[cur] && guard++ < segs.length + 2) {
+ used[cur] = true;
+ loop.push(segs[cur][end]);
+ const other = segs[cur][end === 0 ? 1 : 0];
+ const next = (map.get(key(other)) ?? []).find((c) => !used[c.seg]);
+ if (!next) break;
+ cur = next.seg;
+ end = next.end;
+ }
+ if (loop.length >= 3) loops.push(loop);
+ }
+ return loops;
+}
+
+function chaikin(pts: Pt[], passes: number): Pt[] {
+ let out = pts;
+ for (let p = 0; p < passes; p++) {
+ const next: Pt[] = [];
+ const n = out.length;
+ for (let i = 0; i < n; i++) {
+ const a = out[i];
+ const b = out[(i + 1) % n];
+ next.push({ x: a.x * 0.75 + b.x * 0.25, y: a.y * 0.75 + b.y * 0.25 });
+ next.push({ x: a.x * 0.25 + b.x * 0.75, y: a.y * 0.25 + b.y * 0.75 });
+ }
+ out = next;
+ }
+ return out;
+}
+
+export interface FusedOutline {
+ d: string;
+ minX: number;
+ minY: number;
+ width: number;
+ height: number;
+ /** Disconnected islands in the outline (1 while the neck holds). */
+ loops: number;
+}
+
+/** Trace the fused pill+circle outline into one SVG path. Coordinates are in
+ * the pill's own space (pill top-left at 0,0); bounds are padded by k so the
+ * fillet bulge is never clipped. */
+export function traceFusedOutline(shapes: FusionShapes, opts: FusionOptions = {}): FusedOutline {
+ const { k, cell, smooth } = { ...CANCEL_FUSION_DEFAULTS, ...opts };
+ const pad = k + cell;
+ const minX = Math.min(0, shapes.circle.cx - shapes.circle.r) - pad;
+ const minY = Math.min(0, shapes.circle.cy - shapes.circle.r) - pad;
+ const maxX = Math.max(shapes.pill.w, shapes.circle.cx + shapes.circle.r) + pad;
+ const maxY = Math.max(shapes.pill.h, shapes.circle.cy + shapes.circle.r) + pad;
+
+ const cols = Math.ceil((maxX - minX) / cell) + 1;
+ const rows = Math.ceil((maxY - minY) / cell) + 1;
+ const val = new Float32Array(cols * rows);
+ for (let j = 0; j < rows; j++) {
+ const y = minY + j * cell;
+ for (let i = 0; i < cols; i++) {
+ val[j * cols + i] = fieldEval(shapes, k, minX + i * cell, y);
+ }
+ }
+
+ const segs: [Pt, Pt][] = [];
+ for (let j = 0; j < rows - 1; j++) {
+ for (let i = 0; i < cols - 1; i++) {
+ const vTL = val[j * cols + i];
+ const vTR = val[j * cols + i + 1];
+ const vBR = val[(j + 1) * cols + i + 1];
+ const vBL = val[(j + 1) * cols + i];
+ let mask = 0;
+ if (vTL < 0) mask |= 8;
+ if (vTR < 0) mask |= 4;
+ if (vBR < 0) mask |= 2;
+ if (vBL < 0) mask |= 1;
+ if (mask === 0 || mask === 15) continue;
+
+ const x0 = minX + i * cell;
+ const y0 = minY + j * cell;
+ const x1 = x0 + cell;
+ const y1 = y0 + cell;
+ const edgePt = (edge: number): Pt => {
+ switch (edge) {
+ case 0:
+ return lerpEdge(x0, y0, vTL, x1, y0, vTR);
+ case 1:
+ return lerpEdge(x1, y0, vTR, x1, y1, vBR);
+ case 2:
+ return lerpEdge(x0, y1, vBL, x1, y1, vBR);
+ default:
+ return lerpEdge(x0, y0, vTL, x0, y1, vBL);
+ }
+ };
+
+ let cases = EDGES[mask];
+ if (mask === 5 || mask === 10) {
+ const centerInside = fieldEval(shapes, k, (x0 + x1) / 2, (y0 + y1) / 2) < 0;
+ cases = (mask === 5) === centerInside ? SADDLE_TL_BR : SADDLE_TR_BL;
+ }
+ for (const [ea, eb] of cases) segs.push([edgePt(ea), edgePt(eb)]);
+ }
+ }
+
+ const loops = stitch(segs, cell);
+ const fmt = (v: number) => v.toFixed(2);
+ const parts: string[] = [];
+ for (const loop of loops) {
+ const s = smooth > 0 ? chaikin(loop, smooth) : loop;
+ if (s.length < 3) continue;
+ parts.push(
+ `M ${fmt(s[0].x)} ${fmt(s[0].y)} ` +
+ s
+ .slice(1)
+ .map((p) => `L ${fmt(p.x)} ${fmt(p.y)}`)
+ .join(" ") +
+ " Z"
+ );
+ }
+
+ return {
+ d: parts.join(" "),
+ minX,
+ minY,
+ width: maxX - minX,
+ height: maxY - minY,
+ loops: parts.length,
+ };
+}
diff --git a/src/components/onboarding/OnboardingShell.tsx b/src/components/onboarding/OnboardingShell.tsx
index 2c703c988..b50c6f0c7 100644
--- a/src/components/onboarding/OnboardingShell.tsx
+++ b/src/components/onboarding/OnboardingShell.tsx
@@ -203,17 +203,39 @@ export default function OnboardingShell({
} as CSSProperties
}
>
- {/* 48px, not a sliver: this is the frameless window's only title bar, so
- it has to be a target someone can actually grab. Interactive overlays
- in this band need z-60 + app-region: no-drag and must live outside the
- step wrapper (a sibling here, or portalled to body) — the wrapper's
- entry animation retains a transform, capping its descendants below
- z-50. */}
+ {/* This is the frameless window's only title bar, so it has to be a
+ target someone can actually grab. Interactive overlays in this band
+ need z-60 + app-region: no-drag and must live outside the step wrapper
+ (a sibling here, or portalled to body) — the wrapper's entry animation
+ retains a transform, capping its descendants below z-50.
+
+ The native app-region strip stays 48px on every screen. A drag element
+ swallows the events under it, and it is a sibling of the step scroller
+ inside an overflow-hidden main, so a taller strip would eat wheel
+ scrolling over the top of a compact step — reachable, because
+ setOnboardingWindowMode clamps the compact window to the work area
+ height and the permissions list then overflows. */}
<div
className="absolute inset-x-0 top-0 z-50 h-12"
style={{ WebkitAppRegion: "drag" } as CSSProperties}
+ data-window-drag-zone=""
aria-hidden="true"
/>
+ {/* macOS only: the transparent control panel drops app-region entirely,
+ so the JS fallback (useControlPanelWindowDrag) is the sole drag path
+ there and can widen the grab target to the full compact hero — the
+ dithered ramp reads as window chrome, so people grab it to move the
+ window. pointer-events-none keeps it out of the event path, so it can
+ never swallow scrolling or clicks the way the app-region strip does;
+ the fallback matches declared zones by their bounds, not by hit
+ testing, so being out of the event path costs it nothing. */}
+ {compact && (
+ <div
+ className="pointer-events-none absolute inset-x-0 top-0 z-40 h-48"
+ data-window-drag-zone=""
+ aria-hidden="true"
+ />
+ )}
{getPlatform() !== "darwin" && <OnboardingWindowControls />}
<div
diff --git a/src/helpers/dragManager.js b/src/helpers/dragManager.js
index 1fd462356..11a8286bc 100644
--- a/src/helpers/dragManager.js
+++ b/src/helpers/dragManager.js
@@ -8,23 +8,29 @@ class DragManager {
this.dragOffset = { x: 0, y: 0 };
this.mouseTrackingInterval = null;
this.targetWindow = null;
+ this.activeWindow = null;
}
setTargetWindow(window) {
this.targetWindow = window;
}
- async startWindowDrag() {
- if (!this.targetWindow || this.targetWindow.isDestroyed()) {
+ /** Drags the configured target window by default; a caller that owns a
+ * different frameless window (the control panel's manual titlebar) passes
+ * it explicitly for the duration of one drag. */
+ async startWindowDrag(windowOverride = null) {
+ const win = windowOverride || this.targetWindow;
+ if (!win || win.isDestroyed()) {
return { success: false, message: "Window not available" };
}
try {
this.isDragging = true;
+ this.activeWindow = win;
// Get current cursor position
const cursorPos = screen.getCursorScreenPoint();
- const windowPos = this.targetWindow.getPosition();
+ const windowPos = win.getPosition();
// Calculate offset from cursor to window position
this.dragOffset = {
@@ -47,6 +53,7 @@ class DragManager {
async stopWindowDrag() {
try {
this.isDragging = false;
+ this.activeWindow = null;
this.stopMouseTracking();
debugLogger.info("Window drag stopped", undefined, "window-drag");
return { success: true };
@@ -62,7 +69,7 @@ class DragManager {
}
this.mouseTrackingInterval = setInterval(() => {
- if (this.isDragging && this.targetWindow && !this.targetWindow.isDestroyed()) {
+ if (this.isDragging && this.activeWindow && !this.activeWindow.isDestroyed()) {
this.updateWindowPosition();
}
}, 16); // ~60fps
@@ -71,7 +78,7 @@ class DragManager {
updateWindowPosition() {
try {
const cursorPos = screen.getCursorScreenPoint();
- const { width, height } = this.targetWindow.getBounds();
+ const { width, height } = this.activeWindow.getBounds();
const x = cursorPos.x - this.dragOffset.x;
const y = cursorPos.y - this.dragOffset.y;
@@ -84,7 +91,7 @@ class DragManager {
});
const clamped = WindowPositionUtil.clampToWorkArea({ x, y, width, height }, display);
- this.targetWindow.setPosition(clamped.x, clamped.y);
+ this.activeWindow.setPosition(clamped.x, clamped.y);
} catch (error) {
console.error("Error updating window position:", error);
this.stopWindowDrag();
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 445eee763..bd0cb279a 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -4014,6 +4014,14 @@ class IPCHandlers {
return await this.windowManager.stopWindowDrag();
});
+ ipcMain.handle("start-control-panel-drag", async () => {
+ return await this.windowManager.startControlPanelDrag();
+ });
+
+ ipcMain.handle("stop-control-panel-drag", async () => {
+ return await this.windowManager.stopControlPanelDrag();
+ });
+
ipcMain.handle("open-external", async (event, url) => {
try {
const { protocol } = new URL(url);
diff --git a/src/helpers/voicePillPresentation.js b/src/helpers/voicePillPresentation.js
index 72868aa4c..5b289289e 100644
--- a/src/helpers/voicePillPresentation.js
+++ b/src/helpers/voicePillPresentation.js
@@ -8,19 +8,40 @@ export { LIVE_TRANSCRIPT_SURFACE_LIMITS };
// and that window size may only change together.
export const VOICE_PILL_FOOTPRINT = Object.freeze({
idle: Object.freeze({ width: 40, height: 40 }),
- recording: Object.freeze({ width: 92, height: 36 }),
+ // 98 = 6px edge inset + 22px icon + 6px gap + 52px waveform + 12px edge
+ // inset (the waveform side keeps extra air; insets include the 1px border).
+ recording: Object.freeze({ width: 98, height: 36 }),
});
+// The hover cancel control that emerges beside the pill (px). Same contract:
+// WINDOW_SIZES.RECORDING must fit pill + gap + cancel inside its dock insets,
+// or the control clips at the native window bounds.
+export const VOICE_PILL_CANCEL = Object.freeze({ size: 28, gap: 8 });
+
export const LISTENING_ENTRANCE_TIMING = Object.freeze({
- // Give the Beam enough time to read as an intentional thinking state before
- // the persistent control begins changing shape.
- thinkingMs: 420,
+ // A short hold that reads as an acknowledged press before the control
+ // changes shape. It was 420ms when it also had to hide the native window
+ // grow; BASE and RECORDING now share one box (windowConfig.js), so the
+ // floating pill's hold is purely the design beat.
+ thinkingMs: 260,
+ // A recording that starts under the open assistant panel first hands the
+ // footer from final actions back to the pill (actions retreat + pill
+ // entrance — getAssistantFooterTransitionTimeline). The expansion must not
+ // start until that handoff settles, or both animate the same control.
+ assistantFooterThinkingMs: 420,
expansionMs: 300,
// Hold the finished footprint briefly so the waveform reveal cannot be
// perceived as part of the width animation.
waveformDelayMs: 100,
});
+// The pill's morph between the two VOICE_PILL_FOOTPRINT boxes. The cancel
+// skin tweens its capsule geometry against the same duration and curve
+// (usePillFootprintTween), so a fused outline never drifts off the real pill —
+// one definition keeps them from diverging.
+export const VOICE_PILL_GROW_EASING = "cubic-bezier(0.2, 0, 0, 1)";
+export const VOICE_PILL_GROW_TRANSITION = `${LISTENING_ENTRANCE_TIMING.expansionMs}ms ${VOICE_PILL_GROW_EASING}`;
+
export const ASSISTANT_FOOTER_TRANSITION_TIMING = Object.freeze({
pillRetreatMs: 180,
actionsRetreatMs: 220,
@@ -150,10 +171,16 @@ export function resolveVoicePillDock({
return `bottom-${horizontalDirection}`;
}
-export function getListeningEntranceTimeline(timing = LISTENING_ENTRANCE_TIMING) {
- const settleAtMs = timing.thinkingMs + timing.expansionMs;
+export function getListeningEntranceTimeline({
+ afterAssistantFooterHandoff = false,
+ timing = LISTENING_ENTRANCE_TIMING,
+} = {}) {
+ const thinkingMs = afterAssistantFooterHandoff
+ ? timing.assistantFooterThinkingMs
+ : timing.thinkingMs;
+ const settleAtMs = thinkingMs + timing.expansionMs;
return {
- expandAtMs: timing.thinkingMs,
+ expandAtMs: thinkingMs,
settleAtMs,
waveformAtMs: settleAtMs + timing.waveformDelayMs,
};
@@ -348,6 +375,28 @@ export function shouldSuppressPillForAssistantActions({
return !(assistantClosing && hasLiveActivity);
}
+/**
+ * Compose the persistent pill root's visibility from every owner that can hide
+ * it. `assistantClosing` folds the pill into the panel's exit — but never while
+ * the pill owns live activity: ownership returns to it at close INTENT (see
+ * voicePillOwnsActivity in App.jsx) and beginClose hides the companion on that
+ * same tick, so suppressing here would leave a running recording with no
+ * visible owner for the whole close. The panel-return mask stays unconditional
+ * like the dictation-error handoff — it is bounded by the native shrink it
+ * covers, not by the panel's full exit choreography.
+ */
+export function resolvePillVisualSuppression({
+ dictationErrorSuppressed,
+ assistantActionsSuppressed,
+ assistantClosing,
+ panelReturnResizeActive,
+ hasLiveActivity,
+}) {
+ if (dictationErrorSuppressed || assistantActionsSuppressed) return true;
+ if (panelReturnResizeActive) return true;
+ return Boolean(assistantClosing) && !hasLiveActivity;
+}
+
export function shouldActivateVoicePill({
hasDragged,
liveTranscriptMounted,
diff --git a/src/helpers/windowConfig.js b/src/helpers/windowConfig.js
index 0cfa5bbb8..656808176 100644
--- a/src/helpers/windowConfig.js
+++ b/src/helpers/windowConfig.js
@@ -125,13 +125,26 @@ function fitDictationErrorWindowToWorkArea(requestedSize, workArea) {
};
}
+// The pill docks 12px from the window's bottom corner (voice-pill-position
+// classes); the remaining area is click-through headroom so the hover
+// tooltip and the Signal glow's halo render without clipping at the window
+// bounds. Sized with dictation-panel.css's dock insets — change together.
+// The box fits the compact pill + gap + hover cancel (134px) inside its 184px
+// usable width, so the cancel control never clips. Those three numbers are
+// VOICE_PILL_FOOTPRINT.recording and VOICE_PILL_CANCEL in
+// src/helpers/voicePillPresentation.js — the renderer-side half of this
+// contract, and the only place they are defined.
+const PILL_WINDOW_SIZE = { width: 208, height: 120 };
+
const WINDOW_SIZES = {
- // The pill docks 12px from the window's bottom corner (voice-pill-position
- // classes); the remaining area is click-through headroom so the hover
- // tooltip and the Signal glow's halo render without clipping at the window
- // bounds. Sized with dictation-panel.css's dock insets — change together.
- BASE: { width: 176, height: 120 },
- RECORDING: { width: 208, height: 120 },
+ // BASE and RECORDING are deliberately the same box. Resizing a transparent
+ // always-on-top window paints one compositor frame of the stale texture
+ // inside the new bounds before the renderer catches up — no resize mask can
+ // cover it — so recording edges must never call setBounds. The keys stay
+ // distinct for the size ladder's ranking; identical bounds make the native
+ // resize a no-op.
+ BASE: PILL_WINDOW_SIZE,
+ RECORDING: PILL_WINDOW_SIZE,
DICTATION_ERROR: { width: DICTATION_ERROR_WINDOW_LIMITS.width, height: 112 },
DICTATION_ERROR_WITH_TRANSCRIPT: {
width: DICTATION_ERROR_WINDOW_LIMITS.width,
@@ -347,11 +360,20 @@ class WindowPositionUtil {
// macOS: Use panel level for proper floating behavior
// This ensures the window stays on top across spaces and fullscreen apps
window.setAlwaysOnTop(true, "floating", 1);
- window.setVisibleOnAllWorkspaces(true, {
- visibleOnFullScreen: true,
- skipTransformProcessType: true, // Keep Dock/Command-Tab behaviour
- });
- window.setFullScreenable(false);
+ // Re-applying the collection behavior when nothing drifted makes the
+ // window server momentarily pull the window out of the active Space,
+ // which blinks the entire visible window. Enforce calls land on hot
+ // paths (assistant panel open/close, window show), so Spaces membership
+ // is only touched when it was actually lost.
+ if (!window.isVisibleOnAllWorkspaces()) {
+ window.setVisibleOnAllWorkspaces(true, {
+ visibleOnFullScreen: true,
+ skipTransformProcessType: true, // Keep Dock/Command-Tab behaviour
+ });
+ }
+ if (window.isFullScreenable()) {
+ window.setFullScreenable(false);
+ }
if (window.isVisible()) {
window.setAlwaysOnTop(true, "floating", 1);
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.js
index ff10ed27b..d72a0cd0c 100644
--- a/src/helpers/windowManager.js
+++ b/src/helpers/windowManager.js
@@ -186,7 +186,8 @@ class WindowManager {
}
// The pill window is created focusable:false so it never steals focus; the
- // assistant panel needs keyboard focus so Escape can dismiss it reliably.
+ // assistant panel makes it focusable so it can take keyboard input at all.
+ // How it then becomes key is platform-split — see the branches below.
setAssistantPanelOpen(open) {
this._assistantPanelOpen = Boolean(open);
if (!this._assistantPanelOpen) {
@@ -198,12 +199,24 @@ class WindowManager {
// (PTT tap, auto-hide, tray); focus() is a no-op on a hidden window.
if (!this.mainWindow.isVisible()) this.mainWindow.showInactive();
this.mainWindow.setFocusable(true);
- this.mainWindow.focus();
+ // macOS: never request app activation for the overlay. focus() calls
+ // NSApp activate, and when another OpenWhispr window (control panel)
+ // lives on a different Space, macOS answers a granted activation by
+ // sliding the whole desktop to it — the "massive flash" on panel
+ // open/close. The window is a non-activating panel, so clicking its
+ // input still makes it key (typing and Escape work from then on)
+ // without activating the app or stealing the user's keyboard.
+ if (process.platform !== "darwin") {
+ this.mainWindow.focus();
+ }
} else {
// On Windows/Linux the pill is a normal/toolbar window, so focus()
// activated OpenWhispr — blur before dropping focusability to hand
- // the foreground back to the app the user was in.
- this.mainWindow.blur();
+ // the foreground back to the app the user was in. On macOS nothing
+ // was activated, and blur() would only churn key-window state.
+ if (process.platform !== "darwin") {
+ this.mainWindow.blur();
+ }
this.mainWindow.setFocusable(false);
}
this.enforceMainWindowOnTop();
@@ -419,6 +432,19 @@ class WindowManager {
? "center"
: `bottom-${this._activeHorizontalDirection || this.getMainWindowHorizontalDirection()}`;
this._baseBoundsBeforeResize = null;
+ if (
+ restored.x === currentBounds.x &&
+ restored.y === currentBounds.y &&
+ restored.width === currentBounds.width &&
+ restored.height === currentBounds.height
+ ) {
+ // Nothing moved (BASE and the grown size share bounds) — skip the mask
+ // handshake and setBounds so the restore cannot perturb the renderer.
+ this._lastResizeBounds = restored;
+ this._activeHorizontalDirection = null;
+ this._notifyMainWindowHorizontalDirection();
+ return { success: true, bounds: restored, changed: false };
+ }
await this._prepareRendererForMainWindowResize(restored, restoreAnchor);
if (!this.mainWindow || this.mainWindow.isDestroyed()) {
return { success: false, message: "Window not available" };
@@ -1131,6 +1157,21 @@ class WindowManager {
return this.hotkeyManager.isUsingNativeShortcut();
}
+ // The control panel is transparent on macOS, where Electron ignores
+ // `-webkit-app-region: drag` entirely — the renderer recreates its titlebar
+ // drag through the shared DragManager instead (useControlPanelWindowDrag).
+ // No pill bookkeeping: position ownership below is main-window-only.
+ async startControlPanelDrag() {
+ if (!this.controlPanelWindow || this.controlPanelWindow.isDestroyed()) {
+ return { success: false, message: "Window not available" };
+ }
+ return await this.dragManager.startWindowDrag(this.controlPanelWindow);
+ }
+
+ async stopControlPanelDrag() {
+ return await this.dragManager.stopWindowDrag();
+ }
+
async startWindowDrag() {
// A lookup started by a prior hotkey must never land while the user is
// taking ownership of the panel position.
diff --git a/src/hooks/useControlPanelWindowDrag.js b/src/hooks/useControlPanelWindowDrag.js
new file mode 100644
index 000000000..c35c5a3df
--- /dev/null
+++ b/src/hooks/useControlPanelWindowDrag.js
@@ -0,0 +1,115 @@
+import { useEffect } from "react";
+import { getCachedPlatform } from "../utils/platform";
+
+// Matches OnboardingShell's 48px drag strip — the frameless window's titlebar.
+const DRAG_STRIP_HEIGHT_PX = 48;
+// A press has to travel before it becomes a drag. Without this, a plain click
+// on the titlebar starts a tracked drag whose first tick runs the DragManager's
+// clampToWorkArea — snapping a window the user had parked past a screen edge.
+const DRAG_START_THRESHOLD_PX = 3;
+// A mousedown aimed at a control in the band must win over the drag.
+const INTERACTIVE_SELECTOR = [
+ "button",
+ "a",
+ "input",
+ "select",
+ "textarea",
+ "[role='button']",
+ "[role='tab']",
+ "[role='menuitem']",
+ "[role='combobox']",
+ "[contenteditable='true']",
+ "[data-no-window-drag]",
+].join(", ");
+
+/**
+ * Manual titlebar drag for the control panel window, macOS only. That window
+ * is transparent there (for the compact onboarding frame's rounded corners),
+ * and Electron ignores `-webkit-app-region: drag` entirely on a transparent
+ * window — the hiddenInset titlebar's native drag dies with it, leaving
+ * onboarding and the panel with no way to move the window. Windows/Linux keep
+ * an opaque window where app-region works, so the fallback stays off there
+ * rather than second-guessing the real drag regions (its 48px band would
+ * overshoot ControlPanel's own 40px strips).
+ *
+ * A press in the top strip that isn't aimed at an interactive control, once it
+ * travels past the threshold, moves the native window through the shared
+ * DragManager.
+ */
+export function useControlPanelWindowDrag(enabled) {
+ useEffect(() => {
+ if (!enabled || getCachedPlatform() !== "darwin") return undefined;
+ const api = window.electronAPI;
+ if (!api?.startControlPanelDrag) return undefined;
+
+ // Zones are matched by their bounds rather than by hit testing the event
+ // target: a declared zone can then be pointer-events-none and still count,
+ // which is what keeps the compact onboarding hero from swallowing the
+ // clicks and wheel scrolling of the step content it overlays.
+ const pointInDeclaredDragZone = (x, y) => {
+ for (const zone of document.querySelectorAll("[data-window-drag-zone]")) {
+ const rect = zone.getBoundingClientRect();
+ if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ let origin = null;
+ let dragging = false;
+ const stop = () => {
+ origin = null;
+ if (!dragging) return;
+ dragging = false;
+ void api.stopControlPanelDrag?.();
+ };
+ const onMouseDown = (event) => {
+ if (event.button !== 0) return;
+ const target = event.target instanceof Element ? event.target : null;
+ // The universal titlebar band, plus any surface that declares itself
+ // window chrome (e.g. the compact onboarding hero via
+ // data-window-drag-zone in OnboardingShell).
+ const inDragZone =
+ event.clientY <= DRAG_STRIP_HEIGHT_PX ||
+ pointInDeclaredDragZone(event.clientX, event.clientY);
+ if (!inDragZone) return;
+ if (target?.closest(INTERACTIVE_SELECTOR)) return;
+ origin = { x: event.clientX, y: event.clientY };
+ };
+ const onMouseMove = (event) => {
+ if (!origin || dragging) return;
+ // A mouseup that never reached this listener (a handler that stopped it,
+ // a release the window never saw) would otherwise leave `origin` armed
+ // and let the next unpressed move start a drag the user cannot end.
+ if (event.buttons === 0) {
+ stop();
+ return;
+ }
+ if (
+ Math.abs(event.clientX - origin.x) < DRAG_START_THRESHOLD_PX &&
+ Math.abs(event.clientY - origin.y) < DRAG_START_THRESHOLD_PX
+ ) {
+ return;
+ }
+ // DragManager captures its cursor-to-window offset when it starts, so
+ // beginning here rather than at mousedown costs no fidelity — the window
+ // picks up exactly under the cursor.
+ dragging = true;
+ void api.startControlPanelDrag();
+ };
+ // Capture phase: a step's own mousedown handling must not be able to
+ // swallow the titlebar gesture before it reaches this window listener.
+ window.addEventListener("mousedown", onMouseDown, true);
+ window.addEventListener("mousemove", onMouseMove, true);
+ window.addEventListener("mouseup", stop, true);
+ window.addEventListener("blur", stop);
+ return () => {
+ stop();
+ window.removeEventListener("mousedown", onMouseDown, true);
+ window.removeEventListener("mousemove", onMouseMove, true);
+ window.removeEventListener("mouseup", stop, true);
+ window.removeEventListener("blur", stop);
+ };
+ }, [enabled]);
+}
diff --git a/src/hooks/useListeningEntrancePhase.ts b/src/hooks/useListeningEntrancePhase.ts
index e077dd302..bd3d99f98 100644
--- a/src/hooks/useListeningEntrancePhase.ts
+++ b/src/hooks/useListeningEntrancePhase.ts
@@ -1,4 +1,4 @@
-import { useLayoutEffect, useState } from "react";
+import { useLayoutEffect, useRef, useState } from "react";
import { getListeningEntranceTimeline } from "../helpers/voicePillPresentation";
export type ListeningEntrancePhase = "idle" | "thinking" | "expanding" | "settled" | "waveform";
@@ -6,10 +6,23 @@ export type ListeningEntrancePhase = "idle" | "thinking" | "expanding" | "settle
/**
* Drives the recording pill's entrance choreography (thinking → expanding →
* settled → waveform). The main pill and the Agent companion pill share this
- * single timeline so their entrances can never drift apart.
+ * single timeline so their entrances can never drift apart (recording-visual
+ * ownership guarantees only one of them runs it at a time).
*/
-export function useListeningEntrancePhase(isRecording: boolean): ListeningEntrancePhase {
+export function useListeningEntrancePhase(
+ isRecording: boolean,
+ options?: {
+ /** The recording starts under the open assistant panel, whose footer must
+ * finish handing final actions back to the pill before the expansion may
+ * begin — this stretches the thinking hold past that handoff. Sampled at
+ * the recording edge, so a panel closing mid-recording cannot restart
+ * the entrance. */
+ afterAssistantFooterHandoff?: boolean;
+ }
+): ListeningEntrancePhase {
const [phase, setPhase] = useState<ListeningEntrancePhase>("idle");
+ const afterFooterRef = useRef(options?.afterAssistantFooterHandoff ?? false);
+ afterFooterRef.current = options?.afterAssistantFooterHandoff ?? false;
useLayoutEffect(() => {
if (!isRecording) {
@@ -18,7 +31,9 @@ export function useListeningEntrancePhase(isRecording: boolean): ListeningEntran
}
setPhase("thinking");
- const timeline = getListeningEntranceTimeline();
+ const timeline = getListeningEntranceTimeline({
+ afterAssistantFooterHandoff: afterFooterRef.current,
+ });
const expansionTimer = setTimeout(() => setPhase("expanding"), timeline.expandAtMs);
const settledTimer = setTimeout(() => setPhase("settled"), timeline.settleAtMs);
const waveformTimer = setTimeout(() => setPhase("waveform"), timeline.waveformAtMs);
diff --git a/src/hooks/useMainWindowSizeOwner.js b/src/hooks/useMainWindowSizeOwner.js
index 985f54e7b..86230ee66 100644
--- a/src/hooks/useMainWindowSizeOwner.js
+++ b/src/hooks/useMainWindowSizeOwner.js
@@ -1,14 +1,21 @@
import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { useSettingsStore } from "../stores/settingsStore";
-import { createDictationErrorPillHandoff } from "../utils/dictationErrorPillHandoff";
+import { createPillVisibilityHandoff } from "../utils/pillVisibilityHandoff";
import { SIZE_RANK, resolveMainWindowSizeKey } from "../utils/windowSizeLadder";
+// The pill container fades with App.jsx's `transition-opacity duration-150`;
+// wait out that fade plus a couple of frames so setBounds can never catch a
+// half-visible pill — change together.
+const PANEL_RETURN_FADE_MS = 180;
+
/**
* Single owner of the main window size: panel > menu > toast > compact pill >
* base. Grows apply immediately so content never clips; shrinks wait for the
* content collapse animation to finish before the window snaps down. Also owns
- * the dictation-error pill handoff, which hides the pill until the native
- * window has left the error footprint.
+ * the two pill-visibility handoffs around risky native resizes: the
+ * dictation-error handoff (pill hidden until the window leaves the error
+ * footprint) and the panel-return handoff (pill faded out across the
+ * panel-to-pill shrink).
*/
export function useMainWindowSizeOwner({
requestMainWindowSize,
@@ -26,17 +33,35 @@ export function useMainWindowSizeOwner({
const [handoffActive, setHandoffActive] = useState(false);
const actionCountRef = useRef(dictationErrorActionCount);
const handoffRef = useRef(null);
+ // Same masking for the panel-return shrink: snapping the native window from
+ // panel bounds back to the pill box paints one compositor frame of the old
+ // texture inside the new bounds, which blanks the just-settled pill. Fade
+ // the pill out, resize while nothing shows, reveal at rest.
+ const [panelReturnResizeActive, setPanelReturnResizeActive] = useState(false);
+ const panelReturnSuppressedRef = useRef(false);
+ const panelReturnHandoffRef = useRef(null);
useEffect(() => {
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: setHandoffActive,
shouldAutoHide: () => useSettingsStore.getState().floatingIconAutoHide,
hideWindow: () => window.electronAPI?.hideWindow?.(),
});
handoffRef.current = handoff;
if (actionCountRef.current > 0) handoff.suppress();
+ const panelReturnHandoff = createPillVisibilityHandoff({
+ onSuppressedChange: (suppressed) => {
+ panelReturnSuppressedRef.current = suppressed;
+ setPanelReturnResizeActive(suppressed);
+ },
+ });
+ panelReturnHandoffRef.current = panelReturnHandoff;
return () => {
handoff.dispose();
+ panelReturnHandoff.dispose();
if (handoffRef.current === handoff) handoffRef.current = null;
+ if (panelReturnHandoffRef.current === panelReturnHandoff) {
+ panelReturnHandoffRef.current = null;
+ }
};
}, []);
@@ -57,6 +82,11 @@ export function useMainWindowSizeOwner({
liveTranscriptMounted;
if (panelOwnsWindow) {
panelSizeReservationRef.current = true;
+ if (panelReturnSuppressedRef.current) {
+ // A panel reopened during the masked shrink; the pill re-docks inside
+ // it and must not stay hidden.
+ void panelReturnHandoffRef.current?.releaseAfter(async () => {});
+ }
return undefined;
}
@@ -94,7 +124,40 @@ export function useMainWindowSizeOwner({
});
return undefined;
}
- if (returningFromPanel || !prev || SIZE_RANK[target] >= SIZE_RANK[prev]) {
+ if (returningFromPanel) {
+ // The panel exit leaves the native window at panel bounds. Suppress the
+ // pill through its opacity fade, resize while nothing is visible, and
+ // reveal once bounds settle — the dictation-error handoff above exists
+ // for the same artifact. No cleanup: the chase below follows the size
+ // owner's latest target across effect re-runs.
+ const panelReturnHandoff = panelReturnHandoffRef.current;
+ if (!panelReturnHandoff) {
+ void requestMainWindowSize(target);
+ return undefined;
+ }
+ panelReturnHandoff.suppress();
+ void (async () => {
+ await new Promise((resolve) => setTimeout(resolve, PANEL_RETURN_FADE_MS));
+ // A panel reopening during the fade re-takes the window; leave its
+ // bounds alone and let the ownership branch reveal the pill.
+ if (panelSizeReservationRef.current) return;
+ await panelReturnHandoff.releaseAfter(async () => {
+ // A menu/toast edge can supersede the target while the fade runs.
+ // Follow the size owner's latest target before revealing. A dictation
+ // error takes over the window on its own path, so bail to it rather
+ // than chase a target it is already moving (same guard as the
+ // error-return chase above).
+ let settledTarget = lastSizeKeyRef.current;
+ await requestMainWindowSize(settledTarget);
+ while (actionCountRef.current === 0 && lastSizeKeyRef.current !== settledTarget) {
+ settledTarget = lastSizeKeyRef.current;
+ await requestMainWindowSize(settledTarget);
+ }
+ });
+ })();
+ return undefined;
+ }
+ if (!prev || SIZE_RANK[target] >= SIZE_RANK[prev]) {
void requestMainWindowSize(target);
return undefined;
}
@@ -128,5 +191,5 @@ export function useMainWindowSizeOwner({
void handoffRef.current?.releaseAfter(async () => {});
}, [assistantMounted, dictationErrorActionCount, handoffActive, liveTranscriptMounted]);
- return { dictationErrorPillHandoffActive: handoffActive };
+ return { dictationErrorPillHandoffActive: handoffActive, panelReturnResizeActive };
}
diff --git a/src/styles/dictation-panel.css b/src/styles/dictation-panel.css
index c2387bdf9..1b1f4339b 100644
--- a/src/styles/dictation-panel.css
+++ b/src/styles/dictation-panel.css
@@ -5,12 +5,16 @@
/* Shared pill-to-panel surface. Each mode chooses the pill corner it grows from. */
.expanding-panel-surface {
- clip-path: inset(calc(100% - 52px) 0 0 calc(100% - 108px) round 24px);
+ clip-path: inset(calc(100% - 52px) 0 0 calc(100% - 114px) round 24px);
opacity: 0;
pointer-events: none;
+ /* Exit transition (the -open state carries the entrance's). A fade much
+ faster than the 280ms contraction makes the surface blink-vanish a frame
+ or two in — it must stay visible long enough for the condense-into-the-
+ pill motion to read. */
transition:
clip-path 280ms cubic-bezier(0.2, 0, 0, 1),
- opacity 140ms ease-out,
+ opacity 240ms ease-out,
transform 280ms cubic-bezier(0.2, 0, 0, 1);
will-change: clip-path, opacity, transform;
}
@@ -21,7 +25,7 @@
}
.expanding-panel-anchor-bottom-left {
- clip-path: inset(calc(100% - 52px) calc(100% - 108px) 0 0 round 24px);
+ clip-path: inset(calc(100% - 52px) calc(100% - 114px) 0 0 round 24px);
transform: translate(-4px, 4px);
transform-origin: bottom left;
}
@@ -31,6 +35,12 @@
opacity: 1;
pointer-events: auto;
transform: none;
+ /* Entrance: turn solid fast so the expansion reads as a surface growing,
+ not a ghost inflating. The exit reads the base rule's slower fade. */
+ transition:
+ clip-path 280ms cubic-bezier(0.2, 0, 0, 1),
+ opacity 140ms ease-out,
+ transform 280ms cubic-bezier(0.2, 0, 0, 1);
}
/* Agent close first fades its complex inner tree while the surface is still
@@ -49,7 +59,7 @@
/* Live Transcript stages its empty surface before buffered text becomes visible. */
.expanding-panel-surface[data-panel-mode="live-transcript"] {
--live-transcript-footer-height: 4rem;
- --live-transcript-speaking-pill-width: 5.75rem;
+ --live-transcript-speaking-pill-width: 6.125rem;
--live-transcript-speaking-pill-height: 2.25rem;
--live-transcript-footer-inline-padding: 1rem;
--live-transcript-encapsulated-width: calc(
@@ -231,6 +241,53 @@
0 0 10px color-mix(in oklch, var(--color-agent-brand) 18%, transparent);
}
+/* While the cancel button's liquid skin owns the fused surface, the pill goes
+ headless like inside the Live Transcript panel. Placed after the agent-beam
+ rule so a fused pill never keeps the brand glow ring on its own box. */
+.voice-pill-control[data-liquid-fused="true"] {
+ border-color: transparent;
+ background-color: transparent;
+ box-shadow: none;
+}
+
+.liquid-cancel-skin {
+ pointer-events: none;
+}
+
+/* The skin's chrome mirrors VoicePill's STATE_APPEARANCE border/background
+ classes for every state it can replace — change together. Hover matters: a
+ de-fusing skin lingers over a hovered pill for its 280ms collapse, and
+ hover is the one state on surface-3. Fill and stroke transition at the
+ pill's own 220ms so a state flip under the skin (recording → thinking)
+ shades over instead of popping. */
+.liquid-cancel-skin path {
+ fill: var(--color-surface-1);
+ stroke: var(--color-border-hover);
+ transition:
+ fill 220ms ease-out,
+ stroke 220ms ease-out;
+}
+
+.liquid-cancel-skin[data-pill-state="hover"] path {
+ fill: var(--color-surface-3);
+}
+
+.liquid-cancel-skin[data-pill-state="processing"] path,
+.liquid-cancel-skin[data-pill-state="thinking"] path,
+.liquid-cancel-skin[data-pill-state="unavailable"] path {
+ stroke: color-mix(in oklab, var(--color-border) 60%, transparent);
+}
+
+/* The idle pill's dark-theme border is softer (dark:border-border/50). */
+.dark .liquid-cancel-skin[data-pill-state="idle"] path {
+ stroke: color-mix(in oklab, var(--color-border) 50%, transparent);
+}
+
+/* Match the pill's shadow-card, which only exists in dark theme. */
+.dark .liquid-cancel-skin {
+ filter: drop-shadow(0 1px 3px oklch(0 0 0 / 0.2));
+}
+
/* The Signal glow: a comet orbiting a breathing ambient halo around the
pill. Both identities light it for the thinking state only — brand blue
for dictation processing, the agent's purple for agent thinking. */
diff --git a/src/types/electron.ts b/src/types/electron.ts
index d4f0644d2..79433f2fd 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -1771,6 +1771,8 @@ declare global {
getPlatform: () => string;
startWindowDrag: () => Promise<void>;
stopWindowDrag: () => Promise<void>;
+ startControlPanelDrag: () => Promise<void>;
+ stopControlPanelDrag: () => Promise<void>;
setMainWindowInteractivity: (interactive: boolean) => Promise<void>;
setNotificationInteractivity: (interactive: boolean) => Promise<void>;
resizeMainWindow: (
diff --git a/src/utils/dictationErrorPillHandoff.ts b/src/utils/pillVisibilityHandoff.ts
similarity index 75%
rename from src/utils/dictationErrorPillHandoff.ts
rename to src/utils/pillVisibilityHandoff.ts
index 88e8e5e6f..f98c5c144 100644
--- a/src/utils/dictationErrorPillHandoff.ts
+++ b/src/utils/pillVisibilityHandoff.ts
@@ -1,6 +1,6 @@
import { waitForVisualFrames } from "./visualFrame";
-interface DictationErrorPillHandoffOptions {
+interface PillVisibilityHandoffOptions {
onSuppressedChange: (suppressed: boolean) => void;
shouldAutoHide?: () => boolean;
hideWindow?: () => Promise<unknown> | undefined;
@@ -8,17 +8,18 @@ interface DictationErrorPillHandoffOptions {
}
/**
- * Own the error-to-pill visibility handoff independently from React renders.
- * A new error invalidates every pending release, while a successful release
- * waits for native geometry and compositor frames before exposing the same
- * persistent pill root again.
+ * Hide the persistent pill root across a risky native resize, independently of
+ * React renders. Two callers own one each: the dictation-error return and the
+ * panel return (useMainWindowSizeOwner). A fresh suppress invalidates every
+ * pending release, while a successful release waits for native geometry and
+ * compositor frames before exposing the pill again.
*/
-export function createDictationErrorPillHandoff({
+export function createPillVisibilityHandoff({
onSuppressedChange,
shouldAutoHide = () => false,
hideWindow = () => undefined,
waitForFrames = waitForVisualFrames,
-}: DictationErrorPillHandoffOptions) {
+}: PillVisibilityHandoffOptions) {
let generation = 0;
let suppressed = false;
let disposed = false;
diff --git a/test/components/authenticationStep.test.js b/test/components/authenticationStep.test.js
index fa6d73e54..e3ed9ccb2 100644
--- a/test/components/authenticationStep.test.js
+++ b/test/components/authenticationStep.test.js
@@ -19,6 +19,7 @@ function createHarness(values = {}) {
discoveryResult: { exists: false },
discoveryError: null,
signupResult: {},
+ portalContainers: [],
};
}
@@ -41,13 +42,19 @@ async function settleAsyncHandler() {
test("email authentication discovers accounts before choosing sign-in or sign-up", async (t) => {
installBrowserGlobals(t, { window: { electronAPI: {} } });
+ // The compact Back control is portalled to body (it has to out-stack the
+ // onboarding shell's drag band), so rendering reads document.body.
+ const originalDocument = globalThis.document;
+ globalThis.document = { body: {} };
t.after(() => {
delete globalThis.__authenticationStepHarness;
+ if (originalDocument === undefined) delete globalThis.document;
+ else globalThis.document = originalDocument;
});
const vite = await createRendererServer(t, {
cachePrefix: "openwhispr-authentication-step-",
- noExternal: ["react", "react-i18next", "lucide-react"],
+ noExternal: ["react", "react-dom", "react-i18next", "lucide-react"],
mockModules: {
react: `
export default {};
@@ -110,6 +117,14 @@ test("email authentication discovers accounts before choosing sign-in or sign-up
return harness.discoveryResult;
}
`,
+ // Keep portalled children in the returned tree so findElement still
+ // reaches them; this harness walks elements rather than mounting a DOM.
+ // The container is recorded so the escape-the-drag-band contract is
+ // asserted rather than stubbed away.
+ "react-dom": `export function createPortal(children, container) {
+ globalThis.__authenticationStepHarness.portalContainers.push(container);
+ return children;
+ }`,
"/utils/logger": `export default { error() {} };`,
"/utils/platform": `export function getCachedPlatform() { return "linux"; }`,
"/ForgotPasswordView": `export default function ForgotPasswordView() { return null; }`,
@@ -143,6 +158,14 @@ test("email authentication discovers accounts before choosing sign-in or sign-up
await settleAsyncHandler();
};
+ const backPortal = createHarness({ [AUTH_MODE_INDEX]: "sign-in" });
+ render(backPortal);
+ assert.deepEqual(
+ backPortal.portalContainers,
+ [globalThis.document.body],
+ "the compact Back must be portalled to document.body so the shell's drag band cannot swallow it"
+ );
+
const existingAccount = createHarness({ [EMAIL_INDEX]: "[email protected]" });
existingAccount.discoveryResult = { exists: true };
await submitEmail(existingAccount);
diff --git a/test/helpers/liquidCancelFusion.test.js b/test/helpers/liquidCancelFusion.test.js
new file mode 100644
index 000000000..60116e121
--- /dev/null
+++ b/test/helpers/liquidCancelFusion.test.js
@@ -0,0 +1,118 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+// Mirrors of the shared pill contract, pinned against it below so these
+// fixtures can never drift from the geometry the component actually renders.
+const PILL = { w: 98, h: 36 };
+const R = 14;
+const GAP = 8;
+const SIZE = 28;
+
+test("the fusion fixtures still match the shared pill contract", async () => {
+ const { VOICE_PILL_FOOTPRINT, VOICE_PILL_CANCEL } = await import(
+ "../../src/helpers/voicePillPresentation.js"
+ );
+ assert.deepEqual(
+ { w: VOICE_PILL_FOOTPRINT.recording.width, h: VOICE_PILL_FOOTPRINT.recording.height },
+ PILL
+ );
+ assert.equal(VOICE_PILL_CANCEL.size, SIZE);
+ assert.equal(VOICE_PILL_CANCEL.gap, GAP);
+ // The skin's circle radius is half the button; the t=0 tangency proof rests
+ // on it (a capsule at least 2R tall swallows the circle exactly).
+ assert.equal(R, SIZE / 2);
+});
+
+function circleAt(t) {
+ return { cx: PILL.w + t * (GAP + SIZE) - SIZE / 2, cy: PILL.h / 2, r: R };
+}
+
+function pathPoints(d) {
+ return [...d.matchAll(/(-?\d+\.?\d*) (-?\d+\.?\d*)/g)].map((m) => ({
+ x: Number(m[1]),
+ y: Number(m[2]),
+ }));
+}
+
+test("swallowed cancel (t=0) leaves the pill outline untouched", async () => {
+ const { traceFusedOutline, emergenceBlend } = await import(
+ "../../src/components/dictation/liquidFusion.ts"
+ );
+ const out = traceFusedOutline({ pill: PILL, circle: circleAt(0) }, { k: emergenceBlend(0) });
+ assert.equal(out.loops, 1);
+ const pts = pathPoints(out.d);
+ const maxX = Math.max(...pts.map((p) => p.x));
+ const minX = Math.min(...pts.map((p) => p.x));
+ // the circle is tangent inside the pill's right cap, so the union is the pill
+ assert.ok(Math.abs(maxX - PILL.w) < 1.5, `maxX ${maxX} should sit at the pill edge`);
+ assert.ok(Math.abs(minX) < 1.5, `minX ${minX} should sit at 0`);
+});
+
+test("swallowed cancel stays pill-shaped at in-between footprints", async () => {
+ const { traceFusedOutline, emergenceBlend } = await import(
+ "../../src/components/dictation/liquidFusion.ts"
+ );
+ // The skin tweens through these while the pill's own width/height
+ // transition runs (40×40 idle ⇄ 98×36 recording), so the t=0 tangency must
+ // hold for every in-between capsule, not just the resting footprints.
+ for (const pill of [
+ { w: 55, h: 39 },
+ { w: 69, h: 38 },
+ { w: 84, h: 37 },
+ ]) {
+ const out = traceFusedOutline(
+ { pill, circle: { cx: pill.w - R, cy: pill.h / 2, r: R } },
+ { k: emergenceBlend(0) }
+ );
+ assert.equal(out.loops, 1, `pill ${pill.w}×${pill.h} should trace one loop`);
+ const pts = pathPoints(out.d);
+ const maxX = Math.max(...pts.map((p) => p.x));
+ const minX = Math.min(...pts.map((p) => p.x));
+ assert.ok(Math.abs(maxX - pill.w) < 1.5, `maxX ${maxX} should sit at the pill edge ${pill.w}`);
+ assert.ok(Math.abs(minX) < 1.5, `minX ${minX} should sit at 0`);
+ }
+});
+
+test("resting cancel (t=1) stays fused to the pill by a single neck", async () => {
+ const { traceFusedOutline, emergenceBlend } = await import(
+ "../../src/components/dictation/liquidFusion.ts"
+ );
+ const out = traceFusedOutline({ pill: PILL, circle: circleAt(1) }, { k: emergenceBlend(1) });
+ // one loop = the 8px gap is bridged by the smin fillet, not two islands
+ assert.equal(out.loops, 1);
+ const pts = pathPoints(out.d);
+ const maxX = Math.max(...pts.map((p) => p.x));
+ assert.ok(
+ Math.abs(maxX - (PILL.w + GAP + SIZE)) < 1.5,
+ `maxX ${maxX} should reach the cancel button's far edge`
+ );
+ // vertical symmetry about the shared centerline
+ const maxY = Math.max(...pts.map((p) => p.y));
+ const minY = Math.min(...pts.map((p) => p.y));
+ assert.ok(
+ Math.abs(maxY - PILL.h / 2 - (PILL.h / 2 - minY)) < 1,
+ `outline should be symmetric about y=${PILL.h / 2} (got ${minY}..${maxY})`
+ );
+});
+
+test("emergence is monotonic: the outline's reach grows with t", async () => {
+ const { traceFusedOutline, emergenceBlend } = await import(
+ "../../src/components/dictation/liquidFusion.ts"
+ );
+ const reach = (t) => {
+ const pts = pathPoints(
+ traceFusedOutline({ pill: PILL, circle: circleAt(t) }, { k: emergenceBlend(t) }).d
+ );
+ return Math.max(...pts.map((p) => p.x));
+ };
+ const r0 = reach(0);
+ const rHalf = reach(0.5);
+ const r1 = reach(1);
+ assert.ok(r0 < rHalf && rHalf < r1, `reach should grow: ${r0} < ${rHalf} < ${r1}`);
+});
+
+test("smin degrades to a hard min at k=0", async () => {
+ const { smin } = await import("../../src/components/dictation/liquidFusion.ts");
+ assert.equal(smin(3, 7, 0), 3);
+ assert.equal(smin(-2, 5, 0), -2);
+});
diff --git a/test/helpers/dictationErrorPillHandoff.test.js b/test/helpers/pillVisibilityHandoff.test.js
similarity index 79%
rename from test/helpers/dictationErrorPillHandoff.test.js
rename to test/helpers/pillVisibilityHandoff.test.js
index 991697607..2532c740d 100644
--- a/test/helpers/dictationErrorPillHandoff.test.js
+++ b/test/helpers/pillVisibilityHandoff.test.js
@@ -3,12 +3,12 @@ const assert = require("node:assert/strict");
const { deferred } = require("./harness/deferred");
test("the resting pill stays suppressed until bounds and compositor frames settle", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const bounds = deferred();
const frames = deferred();
const visibility = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => visibility.push(suppressed),
waitForFrames: () => frames.promise,
});
@@ -26,11 +26,11 @@ test("the resting pill stays suppressed until bounds and compositor frames settl
});
test("a new error invalidates an older in-flight pill reveal", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const bounds = deferred();
const visibility = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => visibility.push(suppressed),
waitForFrames: async () => {},
});
@@ -45,10 +45,10 @@ test("a new error invalidates an older in-flight pill reveal", async () => {
});
test("a rejecting settleBounds still releases suppression instead of stranding the pill", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const visibility = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => visibility.push(suppressed),
waitForFrames: async () => assert.fail("frames must not be awaited after a settle failure"),
});
@@ -63,10 +63,10 @@ test("a rejecting settleBounds still releases suppression instead of stranding t
});
test("a rejecting hideWindow still releases suppression instead of stranding the pill", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const visibility = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => visibility.push(suppressed),
shouldAutoHide: () => true,
hideWindow: async () => {
@@ -82,11 +82,11 @@ test("a rejecting hideWindow still releases suppression instead of stranding the
});
test("cancel supersedes an in-flight release but keeps the pill suppressed", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const bounds = deferred();
const visibility = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => visibility.push(suppressed),
waitForFrames: async () => {},
});
@@ -110,11 +110,11 @@ test("cancel supersedes an in-flight release but keeps the pill suppressed", asy
});
test("dispose permanently silences the handoff, including releases started later", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const bounds = deferred();
const visibility = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => visibility.push(suppressed),
waitForFrames: async () => {},
});
@@ -133,10 +133,10 @@ test("dispose permanently silences the handoff, including releases started later
});
test("auto-hide closes the native window before releasing DOM suppression", async () => {
- const { createDictationErrorPillHandoff } =
- await import("../../src/utils/dictationErrorPillHandoff.ts");
+ const { createPillVisibilityHandoff } =
+ await import("../../src/utils/pillVisibilityHandoff.ts");
const order = [];
- const handoff = createDictationErrorPillHandoff({
+ const handoff = createPillVisibilityHandoff({
onSuppressedChange: (suppressed) => order.push(suppressed ? "suppress" : "release"),
shouldAutoHide: () => true,
hideWindow: async () => order.push("hide"),
diff --git a/test/helpers/voicePillPresentation.test.js b/test/helpers/voicePillPresentation.test.js
index 202f7acd7..49aac7ac9 100644
--- a/test/helpers/voicePillPresentation.test.js
+++ b/test/helpers/voicePillPresentation.test.js
@@ -319,11 +319,20 @@ test("listening entrance settles at full width before revealing the waveform", a
test("listening entrance timers preserve the visual order", async () => {
const { getListeningEntranceTimeline } = await load();
- const timeline = getListeningEntranceTimeline();
- assert.ok(timeline.expandAtMs > 0);
- assert.ok(timeline.settleAtMs > timeline.expandAtMs);
- assert.ok(timeline.waveformAtMs > timeline.settleAtMs);
+ for (const afterAssistantFooterHandoff of [false, true]) {
+ const timeline = getListeningEntranceTimeline({ afterAssistantFooterHandoff });
+ assert.ok(timeline.expandAtMs > 0);
+ assert.ok(timeline.settleAtMs > timeline.expandAtMs);
+ assert.ok(timeline.waveformAtMs > timeline.settleAtMs);
+ }
+
+ // The floating pill has no footer handoff to wait out, so its hold is the
+ // shorter of the two speeds.
+ assert.ok(
+ getListeningEntranceTimeline().expandAtMs <
+ getListeningEntranceTimeline({ afterAssistantFooterHandoff: true }).expandAtMs
+ );
});
test("Agent footer retreats actions before the compact pill enters", async () => {
@@ -337,8 +346,12 @@ test("Agent footer retreats actions before the compact pill enters", async () =>
assert.ok(timeline.settledAtMs > timeline.handoffAtMs);
// Cross-policy contract: the footer handoff must fully settle before the
// listening entrance starts expanding the pill, or the two animations fight
- // over the same control.
- assert.ok(timeline.settledAtMs < getListeningEntranceTimeline().expandAtMs);
+ // over the same control. Only the footer-handoff hold carries this bound;
+ // the floating pill never runs the two together.
+ assert.ok(
+ timeline.settledAtMs <
+ getListeningEntranceTimeline({ afterAssistantFooterHandoff: true }).expandAtMs
+ );
});
test("Agent footer retreats the pill before final actions grow from its anchor", async () => {
@@ -703,6 +716,85 @@ test("final Agent actions keep the idle pill hidden until the panel finishes clo
);
});
+test("the composed pill suppression keeps a live recording visible through the close", async () => {
+ const { resolvePillVisualSuppression } = await load();
+
+ const base = {
+ dictationErrorSuppressed: false,
+ assistantActionsSuppressed: false,
+ assistantClosing: false,
+ panelReturnResizeActive: false,
+ hasLiveActivity: false,
+ };
+
+ // The regression this pins: folding the pill into the panel exit must not
+ // override the close-intent ownership handoff. beginClose hides the companion
+ // on the same tick, so a suppressed pill here leaves a running recording with
+ // no visible owner for the whole ~580ms close.
+ assert.equal(
+ resolvePillVisualSuppression({ ...base, assistantClosing: true, hasLiveActivity: true }),
+ false
+ );
+ // An idle close still folds into one beat.
+ assert.equal(resolvePillVisualSuppression({ ...base, assistantClosing: true }), true);
+
+ // The panel-return mask covers a real native shrink and is bounded by it, so
+ // it stays unconditional — same contract as the dictation-error handoff.
+ assert.equal(
+ resolvePillVisualSuppression({ ...base, panelReturnResizeActive: true, hasLiveActivity: true }),
+ true
+ );
+
+ // Error and footer owners are absolute regardless of activity.
+ assert.equal(
+ resolvePillVisualSuppression({
+ ...base,
+ dictationErrorSuppressed: true,
+ hasLiveActivity: true,
+ }),
+ true
+ );
+ assert.equal(
+ resolvePillVisualSuppression({
+ ...base,
+ assistantActionsSuppressed: true,
+ hasLiveActivity: true,
+ }),
+ true
+ );
+
+ // Nothing claiming the pill leaves it visible.
+ assert.equal(resolvePillVisualSuppression(base), false);
+});
+
+test("the composed suppression honours the assistant-actions carve-out end to end", async () => {
+ const { resolvePillVisualSuppression, shouldSuppressPillForAssistantActions } = await load();
+
+ // Both halves of the close: `assistantOpen` is still true through the content
+ // fade, then flips false while `closing` runs out the contraction. A live
+ // recording has to survive both, which is exactly what regressed when the
+ // composition ORed `closing` in unconditionally.
+ for (const assistantOpen of [true, false]) {
+ const assistantActionsSuppressed = shouldSuppressPillForAssistantActions({
+ assistantOpen,
+ footerPillVisible: false,
+ assistantClosing: true,
+ hasLiveActivity: true,
+ });
+ assert.equal(
+ resolvePillVisualSuppression({
+ dictationErrorSuppressed: false,
+ assistantActionsSuppressed,
+ assistantClosing: true,
+ panelReturnResizeActive: false,
+ hasLiveActivity: true,
+ }),
+ false,
+ `a live recording must stay visible with assistantOpen=${assistantOpen}`
+ );
+ }
+});
+
test("activity handed back at close intent stays visible through the content fade", async () => {
const { shouldSuppressPillForAssistantActions } = await load();
diff --git a/test/helpers/windowManagerAssistantPanel.test.js b/test/helpers/windowManagerAssistantPanel.test.js
index 746136fd1..dccf21bcd 100644
--- a/test/helpers/windowManagerAssistantPanel.test.js
+++ b/test/helpers/windowManagerAssistantPanel.test.js
@@ -309,10 +309,54 @@ test("live transcript events are mirrored to the companion only for plain dictat
assert.deepEqual(companionMessages, [{ channel: "preview-text", payload: "plain" }]);
});
-test("opening the assistant panel surfaces a hidden pill window before focusing it", () => {
- const { manager, calls } = makeManager({ visible: false });
- manager.setAssistantPanelOpen(true);
- assert.deepEqual(calls, ["showInactive", "focusable:true", "focus"]);
+// Both platform paths run on every runner: branching the expectation on the
+// host's own process.platform would leave whichever path CI is not running
+// unverified — and darwin is the one that carries the contract.
+function withPlatform(platform, run) {
+ const original = Object.getOwnPropertyDescriptor(process, "platform");
+ Object.defineProperty(process, "platform", { value: platform, configurable: true });
+ try {
+ run();
+ } finally {
+ Object.defineProperty(process, "platform", original);
+ }
+}
+
+test("opening the assistant panel surfaces a hidden pill window without activating on macOS", () => {
+ withPlatform("darwin", () => {
+ const { manager, calls } = makeManager({ visible: false });
+ manager.setAssistantPanelOpen(true);
+ // focus() answers a user-granted activation with a whole-desktop Space
+ // slide when another OpenWhispr window lives on a different Space. The
+ // non-activating panel becomes key on click instead.
+ assert.deepEqual(calls, ["showInactive", "focusable:true"]);
+ });
+});
+
+test("opening the assistant panel focuses the pill window on Windows/Linux", () => {
+ for (const platform of ["win32", "linux"]) {
+ withPlatform(platform, () => {
+ const { manager, calls } = makeManager({ visible: false });
+ manager.setAssistantPanelOpen(true);
+ assert.deepEqual(calls, ["showInactive", "focusable:true", "focus"], platform);
+ });
+ }
+});
+
+test("closing the assistant panel blurs only where opening focused", () => {
+ withPlatform("darwin", () => {
+ const { manager, calls } = makeManager({ visible: true });
+ manager.setAssistantPanelOpen(false);
+ // Nothing was activated, so blur() would only churn key-window state.
+ assert.ok(!calls.includes("blur"), "macOS must not blur the overlay");
+ });
+ for (const platform of ["win32", "linux"]) {
+ withPlatform(platform, () => {
+ const { manager, calls } = makeManager({ visible: true });
+ manager.setAssistantPanelOpen(false);
+ assert.ok(calls.includes("blur"), `${platform} hands the foreground back`);
+ });
+ }
});
test("showDictationPanel still surfaces a hidden window while the panel is open", () => {
diff --git a/test/helpers/windowPositionClamp.test.js b/test/helpers/windowPositionClamp.test.js
index fae50b498..bf40faf7c 100644
--- a/test/helpers/windowPositionClamp.test.js
+++ b/test/helpers/windowPositionClamp.test.js
@@ -54,7 +54,7 @@ const MONITOR_ABOVE = { workArea: { x: -451, y: -1440, width: 2560, height: 1440
test("the panel lands on a monitor mounted above the primary display", () => {
const position = WindowPositionUtil.getMainWindowPosition(MONITOR_ABOVE, null, "bottom-right");
- assert.deepEqual(position, { x: 1929, y: -124, width: 176, height: 120 });
+ assert.deepEqual(position, { x: 1897, y: -124, width: 208, height: 120 });
assert.ok(position.y < 0, "a display above the primary one needs a negative y");
});