• Will Chen's avatar
    Fix scroll behavior when switching between chats (#2643) · fd27826e
    Will Chen 提交于
    ## Summary
    - Fix scroll behavior when switching between chats with existing
    messages
    - Use double `requestAnimationFrame` to wait for Virtuoso to render
    before scrolling to bottom when switching chats
    - Distinguish between chat switches and new message sends to handle
    scrolling appropriately
    - Avoid premature scrolling when switching to chats where messages
    haven't been fetched yet
    
    ## Test plan
    1. Open Dyad and start a chat with some messages
    2. Start another chat with messages
    3. Switch between chats and verify scroll position stays at the bottom
    4. Send a new message and verify it scrolls to show the new message
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2643"
    target="_blank">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Fixes chat auto-scroll to keep the view anchored at the bottom when
    switching chats or sending messages. Prevents flicker and jumps before
    messages render.
    
    - **Bug Fixes**
    - Distinguish chat switches vs new sends; adjust scroll timing
    accordingly.
    - On chat switch with existing messages, wait for Virtuoso to render
    (double requestAnimationFrame), then scroll to bottom instantly.
    - On new message send, wait for the placeholder to render (double
    requestAnimationFrame) before scrolling; skip auto-scroll when switching
    to a chat with no messages yet.
    
    <sup>Written for commit 8814a601a9615b60efbfbff0aff5b7150a75fa63.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    
    <!-- CURSOR_SUMMARY -->
    ---
    
    > [!NOTE]
    > **Low Risk**
    > Scoped to `ChatPanel` scroll timing logic; risk is limited to possible
    UI regressions (missed/extra scroll) when switching chats or starting
    streams.
    > 
    > **Overview**
    > Fixes `ChatPanel` auto-scroll behavior by **distinguishing chat
    switches from new stream starts** and delaying the scroll until after
    Virtuoso has rendered.
    > 
    > On chat switch, it now scrolls to bottom *only after messages exist*
    (avoiding premature scroll before fetch/render) and uses a double
    `requestAnimationFrame` with `instant` scrolling; on new message sends
    (`streamCount` changes), it similarly waits for render before scrolling
    with the default behavior.
    > 
    > <sup>Written by [Cursor
    Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
    8814a601a9615b60efbfbff0aff5b7150a75fa63. This will update automatically
    on new commits. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    ---------
    Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
    fd27826e
名称
最后提交
最后更新
..
__tests__ 正在载入提交数据...
app 正在载入提交数据...
atoms 正在载入提交数据...
client_logic 正在载入提交数据...
components 正在载入提交数据...
constants 正在载入提交数据...
contexts 正在载入提交数据...
db 正在载入提交数据...
hooks 正在载入提交数据...
i18n 正在载入提交数据...
ipc 正在载入提交数据...
lib 正在载入提交数据...
main 正在载入提交数据...
neon_admin 正在载入提交数据...
pages 正在载入提交数据...
paths 正在载入提交数据...
pro 正在载入提交数据...
prompts 正在载入提交数据...
routes 正在载入提交数据...
shared 正在载入提交数据...
store 正在载入提交数据...
styles 正在载入提交数据...
supabase_admin 正在载入提交数据...
utils 正在载入提交数据...
backup_manager.ts 正在载入提交数据...
main.ts 正在载入提交数据...
preload.ts 正在载入提交数据...
renderer.tsx 正在载入提交数据...
router.ts 正在载入提交数据...