@@ -367,7 +367,6 @@ import {
367367import { deriveLatestContextWindowSnapshot , formatContextWindowTokens } from "../lib/contextWindow" ;
368368import {
369369 DRAFT_HERO_TRANSITION_ANIMATION_ID ,
370- DRAFT_HERO_TRANSITION_DURATION_MS ,
371370 DRAFT_HERO_TRANSITION_EASING ,
372371 MOBILE_COMPOSER_VIEW_TRANSITION_NAME ,
373372 MOBILE_DRAFT_HEADLINE_VIEW_TRANSITION_NAME ,
@@ -490,7 +489,11 @@ const EMPTY_PROVIDERS: ServerProvider[] = [];
490489const EMPTY_USAGE_LIMIT_SOURCES : UsageLimitSourceSnapshots = [ ] ;
491490const EMPTY_PROVIDER_SKILLS : ServerProvider [ "skills" ] = [ ] ;
492491const EMPTY_PENDING_USER_INPUT_ANSWERS : Record < string , PendingUserInputDraftAnswer > = { } ;
493- function useDraftHeroLayoutTransition ( isDraftHeroState : boolean ) {
492+ function useDraftHeroLayoutTransition (
493+ isDraftHeroState : boolean ,
494+ animationsActive : boolean ,
495+ animationDurationMs : number ,
496+ ) {
494497 const transitionGroupRef = useRef < HTMLDivElement | null > ( null ) ;
495498 const composerAnchorRef = useRef < HTMLDivElement | null > ( null ) ;
496499 const previousStateRef = useRef ( isDraftHeroState ) ;
@@ -510,9 +513,6 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
510513 const transitionGroup = transitionGroupRef . current ;
511514 const nextComposerRect = composerAnchorRef . current ?. getBoundingClientRect ( ) ?? null ;
512515 const stateChanged = previousStateRef . current !== isDraftHeroState ;
513- const prefersReducedMotion =
514- typeof window !== "undefined" &&
515- window . matchMedia ?.( "(prefers-reduced-motion: reduce)" ) . matches ;
516516 const mobileComposerTransitionActive =
517517 typeof document !== "undefined" &&
518518 document . documentElement . dataset . mobileComposerRouteTransition === "true" ;
@@ -523,7 +523,7 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
523523 const previousComposerRect = previousComposerRectRef . current ;
524524 if (
525525 stateChanged &&
526- ! prefersReducedMotion &&
526+ animationsActive &&
527527 ! mobileComposerTransitionActive &&
528528 transitionGroup &&
529529 previousComposerRect &&
@@ -539,7 +539,7 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
539539 { transform : "translate3d(0, 0, 0)" } ,
540540 ] ,
541541 {
542- duration : DRAFT_HERO_TRANSITION_DURATION_MS ,
542+ duration : animationDurationMs ,
543543 easing : DRAFT_HERO_TRANSITION_EASING ,
544544 } ,
545545 ) ;
@@ -558,7 +558,7 @@ function useDraftHeroLayoutTransition(isDraftHeroState: boolean) {
558558
559559 previousStateRef . current = isDraftHeroState ;
560560 previousComposerRectRef . current = nextComposerRect ;
561- } , [ isDraftHeroState ] ) ;
561+ } , [ animationDurationMs , animationsActive , isDraftHeroState ] ) ;
562562
563563 return [ attachTransitionGroupRef , attachComposerAnchorRef , captureComposerRect ] as const ;
564564}
@@ -3275,7 +3275,11 @@ export default function ChatView(props: ChatViewProps) {
32753275 attachDraftHeroTransitionGroupRef ,
32763276 attachDraftHeroComposerAnchorRef ,
32773277 captureDraftHeroComposerRect ,
3278- ] = useDraftHeroLayoutTransition ( isDraftHeroState ) ;
3278+ ] = useDraftHeroLayoutTransition (
3279+ isDraftHeroState ,
3280+ panelAnimationsActive ,
3281+ panelAnimationDurationMs ,
3282+ ) ;
32793283
32803284 const gitCwd = activeProject
32813285 ? projectScriptCwd ( {
@@ -6996,13 +7000,19 @@ export default function ChatView(props: ChatViewProps) {
69967000 const dockStarted = new Promise < void > ( ( resolve ) => {
69977001 resolveDockStarted = resolve ;
69987002 } ) ;
6999- const dockTransition = runMobileComposerTransition ( ( ) => {
7000- flushSync ( ( ) => {
7001- captureDraftHeroComposerRect ( ) ;
7002- setDockedDraftHeroThreadKey ( activeThreadKey ) ;
7003- } ) ;
7004- resolveDockStarted ?.( ) ;
7005- } ) ;
7003+ const dockTransition = runMobileComposerTransition (
7004+ ( ) => {
7005+ flushSync ( ( ) => {
7006+ captureDraftHeroComposerRect ( ) ;
7007+ setDockedDraftHeroThreadKey ( activeThreadKey ) ;
7008+ } ) ;
7009+ resolveDockStarted ?.( ) ;
7010+ } ,
7011+ {
7012+ active : panelAnimationsActive ,
7013+ durationMs : panelAnimationDurationMs ,
7014+ } ,
7015+ ) ;
70067016 void dockTransition . catch ( ( ) => resolveDockStarted ?.( ) ) ;
70077017 await dockStarted ;
70087018 }
0 commit comments