@@ -406,7 +406,6 @@ import {
406406import { deriveLatestContextWindowSnapshot , formatContextWindowTokens } from "../lib/contextWindow" ;
407407import {
408408 DRAFT_HERO_TRANSITION_ANIMATION_ID ,
409- DRAFT_HERO_TRANSITION_DURATION_MS ,
410409 DRAFT_HERO_TRANSITION_EASING ,
411410 MOBILE_COMPOSER_VIEW_TRANSITION_NAME ,
412411 MOBILE_DRAFT_HEADLINE_VIEW_TRANSITION_NAME ,
@@ -539,7 +538,11 @@ const EMPTY_PROVIDERS: ServerProvider[] = [];
539538const EMPTY_USAGE_LIMIT_SOURCES : UsageLimitSourceSnapshots = [ ] ;
540539const EMPTY_PROVIDER_SKILLS : ServerProvider [ "skills" ] = [ ] ;
541540const EMPTY_PENDING_USER_INPUT_ANSWERS : Record < string , PendingUserInputDraftAnswer > = { } ;
542- function useDraftHeroLayoutTransition ( isDraftHeroState : boolean ) {
541+ function useDraftHeroLayoutTransition (
542+ isDraftHeroState : boolean ,
543+ animationsActive : boolean ,
544+ animationDurationMs : number ,
545+ ) {
543546 const transitionGroupRef = useRef < HTMLDivElement | null > ( null ) ;
544547 const composerAnchorRef = useRef < HTMLDivElement | null > ( null ) ;
545548 const previousStateRef = useRef ( isDraftHeroState ) ;
@@ -559,9 +562,6 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
559562 const transitionGroup = transitionGroupRef . current ;
560563 const nextComposerRect = composerAnchorRef . current ?. getBoundingClientRect ( ) ?? null ;
561564 const stateChanged = previousStateRef . current !== isDraftHeroState ;
562- const prefersReducedMotion =
563- typeof window !== "undefined" &&
564- window . matchMedia ?.( "(prefers-reduced-motion: reduce)" ) . matches ;
565565 const mobileComposerTransitionActive =
566566 typeof document !== "undefined" &&
567567 document . documentElement . dataset . mobileComposerRouteTransition === "true" ;
@@ -572,7 +572,7 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
572572 const previousComposerRect = previousComposerRectRef . current ;
573573 if (
574574 stateChanged &&
575- ! prefersReducedMotion &&
575+ animationsActive &&
576576 ! mobileComposerTransitionActive &&
577577 transitionGroup &&
578578 previousComposerRect &&
@@ -588,7 +588,7 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
588588 { transform : "translate3d(0, 0, 0)" } ,
589589 ] ,
590590 {
591- duration : DRAFT_HERO_TRANSITION_DURATION_MS ,
591+ duration : animationDurationMs ,
592592 easing : DRAFT_HERO_TRANSITION_EASING ,
593593 } ,
594594 ) ;
@@ -607,7 +607,7 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
607607
608608 previousStateRef . current = isDraftHeroState ;
609609 previousComposerRectRef . current = nextComposerRect ;
610- } , [ isDraftHeroState ] ) ;
610+ } , [ animationDurationMs , animationsActive , isDraftHeroState ] ) ;
611611
612612 return [ attachTransitionGroupRef , attachComposerAnchorRef , captureComposerRect ] as const ;
613613}
@@ -3634,7 +3634,11 @@ export default function ChatView(props: ChatViewProps) {
36343634 attachDraftHeroTransitionGroupRef ,
36353635 attachDraftHeroComposerAnchorRef ,
36363636 captureDraftHeroComposerRect ,
3637- ] = useDraftHeroLayoutTransition ( isDraftHeroState ) ;
3637+ ] = useDraftHeroLayoutTransition (
3638+ isDraftHeroState ,
3639+ panelAnimationsActive ,
3640+ panelAnimationDurationMs ,
3641+ ) ;
36383642
36393643 const gitCwd = activeProject
36403644 ? projectScriptCwd ( {
@@ -7877,13 +7881,19 @@ export default function ChatView(props: ChatViewProps) {
78777881 const dockStarted = new Promise < void > ( ( resolve ) => {
78787882 resolveDockStarted = resolve ;
78797883 } ) ;
7880- const dockTransition = runMobileComposerTransition ( ( ) => {
7881- flushSync ( ( ) => {
7882- captureDraftHeroComposerRect ( ) ;
7883- setDockedDraftHeroThreadKey ( activeThreadKey ) ;
7884- } ) ;
7885- resolveDockStarted ?.( ) ;
7886- } ) ;
7884+ const dockTransition = runMobileComposerTransition (
7885+ ( ) => {
7886+ flushSync ( ( ) => {
7887+ captureDraftHeroComposerRect ( ) ;
7888+ setDockedDraftHeroThreadKey ( activeThreadKey ) ;
7889+ } ) ;
7890+ resolveDockStarted ?.( ) ;
7891+ } ,
7892+ {
7893+ active : panelAnimationsActive ,
7894+ durationMs : panelAnimationDurationMs ,
7895+ } ,
7896+ ) ;
78877897 void dockTransition . catch ( ( ) => resolveDockStarted ?.( ) ) ;
78887898 await dockStarted ;
78897899 }
0 commit comments