Skip to content

ECHO-212 add scroll to bottom button in chat for tablet and desktop#264

Merged
ussaama merged 2 commits intomainfrom
chat-scroll
Aug 13, 2025
Merged

ECHO-212 add scroll to bottom button in chat for tablet and desktop#264
ussaama merged 2 commits intomainfrom
chat-scroll

Conversation

@ussaama
Copy link
Copy Markdown
Contributor

@ussaama ussaama commented Aug 13, 2025

Summary by CodeRabbit

  • New Features
    • Added a scroll-to-bottom button in project chat that appears when you’re not viewing the latest messages.
    • Button shows or hides based on whether the chat’s bottom anchor is visible on-screen.
    • One-tap scrolls to the most recent messages for quicker navigation.
    • Responsively positioned above the footer on medium and larger screens for improved accessibility.

@linear
Copy link
Copy Markdown

linear bot commented Aug 13, 2025

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

Adds on-screen visibility tracking for a bottom anchor in ProjectChatRoute, exposes a scroll target ref and visibility, and integrates a responsive ScrollToBottomButton that appears when the anchor is off-screen and scrolls to the latest messages when activated.

Changes

Cohort / File(s) Summary of Changes
Chat scroll-to-bottom integration
echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx
Added useElementOnScreen usage producing [scrollTargetRef, isVisible], inserted a bottom anchor <div ref={scrollTargetRef} aria-hidden />, exposed scrollTargetRef/isVisible through hooks, imported and rendered ScrollToBottomButton wired with elementRef={scrollTargetRef} and isVisible={isVisible}.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant PCR as ProjectChatRoute
  participant OBS as useElementOnScreen
  participant BTN as ScrollToBottomButton
  participant AN as Bottom Anchor

  U->>PCR: Open chat / scroll
  PCR->>OBS: Observe AN (scrollTargetRef)
  OBS-->>PCR: isVisible
  PCR->>BTN: Render with elementRef and isVisible
  U->>BTN: Click
  BTN->>AN: scrollIntoView()
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Scroll to bottom button in a Chat (ECHO-212)

Suggested reviewers

  • spashii

LGTM.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chat-scroll

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot requested a review from spashii August 13, 2025 09:39
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61f3583 and 91e3b5c.

📒 Files selected for processing (1)
  • echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (2)
echo/frontend/src/hooks/useElementOnScreen.ts (1)
  • useElementOnScreen (3-22)
echo/frontend/src/components/common/ScrollToBottom.tsx (1)
  • ScrollToBottomButton (10-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ci-check-server
🔇 Additional comments (3)
echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (3)

47-49: Imports look tight.

Good additions. Both the component and hook are used below; no dead imports. LGTM.


249-251: Exposing the bottom-anchor state from the hook is fine.

Returning scrollTargetRef and isVisible from useDembraneChat keeps the route lean. LGTM.


280-282: Plumbing into the route is correct.

Destructuring the new fields and passing them down is consistent. LGTM.

@cursor
Copy link
Copy Markdown

cursor bot commented Aug 13, 2025

🚨 Bugbot Trial Expired

Your team's Bugbot trial has expired. Please contact your team administrator to turn on the paid plan to continue using Bugbot.

A team admin can activate the plan in the Cursor dashboard.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (2)

65-69: IntersectionObserver config: memoize options + use threshold 0 for zero-height sentinel; bottom-only rootMargin.

  • Inline options cause the observer to be torn down/recreated on every render because the hook depends on options identity. Memoize.
  • Zero-height sentinel + threshold: 0.1 can be flaky; use 0 for reliable firing.
  • Prefer bottom-only rootMargin: "0px 0px -83px 0px" so only the bottom is adjusted.

This is a refinement of a previous suggestion; keeping it concise here.

Apply within this hunk:

-  const [scrollTargetRef, isVisible] = useElementOnScreen({
-    root: null,
-    rootMargin: "-83px",
-    threshold: 0.1,
-  });
+  const [scrollTargetRef, isVisible] = useElementOnScreen(intersectionOptions);

And insert just above Line 65:

const intersectionOptions = useMemo<IntersectionObserverInit>(
  () => ({
    root: null,
    rootMargin: "0px 0px -83px 0px",
    threshold: 0,
  }),
  [],
);

Optional: if 83px is a magic number, measure the sticky footer’s height (via a ref) and derive rootMargin dynamically so the button reliably hides when the footer height changes.


469-479: Absolute positioning above sticky footer: consider a stable offset and anchored container.

  • bottom-[105%] depends on the parent height and can drift as the footer grows/shrinks (textarea resize, alerts). A fixed offset above the footer’s top edge is more stable.
  • Use Tailwind’s -translate-x-1/2 instead of an arbitrary translate for consistency.
  • Ensure the immediate wrapper has relative so the absolute child is anchored predictably.

Previous discussion noted; repeating succinctly for future hardening.

For example:

-<Stack className="pb-2">
+<Stack className="relative pb-2">
-  className="absolute bottom-[105%] left-1/2 z-50 hidden translate-x-[-50%] md:flex"
+  className="absolute -top-3 left-1/2 z-50 hidden -translate-x-1/2 md:flex"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91e3b5c and 4bd1d1a.

📒 Files selected for processing (1)
  • echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-13T09:55:32.304Z
Learnt from: ussaama
PR: Dembrane/echo#264
File: echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx:462-465
Timestamp: 2025-08-13T09:55:32.304Z
Learning: For scroll sentinel elements used with Intersection Observer in React components, aria-hidden="true" is sufficient for accessibility without needing explicit height styling, as the observer can detect zero-height elements entering/exiting the viewport.

Applied to files:

  • echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx
🧬 Code Graph Analysis (1)
echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (2)
echo/frontend/src/hooks/useElementOnScreen.ts (1)
  • useElementOnScreen (3-22)
echo/frontend/src/components/common/ScrollToBottom.tsx (1)
  • ScrollToBottomButton (10-32)
🔇 Additional comments (3)
echo/frontend/src/routes/project/chat/ProjectChatRoute.tsx (3)

47-49: LGTM: correct imports for the new UI control and hook.

Imports are accurate and scoped to the new feature. Ship it.


249-251: LGTM: exposing the sentinel ref and visibility from the hook makes the component integration clean.

Shape and naming are fine for now; good separation of concerns.


463-465: LGTM: sentinel placement and a11y.

aria-hidden="true" on the zero-height anchor matches our prior learning and keeps it out of the a11y tree while remaining observable. Clean.

@ussaama ussaama added this pull request to the merge queue Aug 13, 2025
Merged via the queue into main with commit b11ae43 Aug 13, 2025
12 checks passed
@ussaama ussaama deleted the chat-scroll branch August 13, 2025 10:44
spashii pushed a commit that referenced this pull request Nov 18, 2025
…264)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a scroll-to-bottom button in project chat that appears when
you’re not viewing the latest messages.
* Button shows or hides based on whether the chat’s bottom anchor is
visible on-screen.
  * One-tap scrolls to the most recent messages for quicker navigation.
* Responsively positioned above the footer on medium and larger screens
for improved accessibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants