Skip to content

Improve AllChats UI: grouping, URL tabs, avatar fix#21

Merged
diyor28 merged 3 commits into
mainfrom
codex/bichat-ui-polish
Mar 29, 2026
Merged

Improve AllChats UI: grouping, URL tabs, avatar fix#21
diyor28 merged 3 commits into
mainfrom
codex/bichat-ui-polish

Conversation

@diyor28

@diyor28 diyor28 commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • AllChatsList: collapsible user groups (collapsed by default) when no user filter active
  • Sidebar: controlled activeTab/onTabChange props for URL-driven tab state
  • useBichatRouter: /all-chats URL prefix support, sidebarTab, onSidebarTabChange
  • UserAvatar: inline styles for colors instead of Tailwind classes (fixes rendering in shadow DOM portals)
  • Export ActiveTab type

Test plan

  • All Chats tab shows users grouped with collapsible headers
  • Navigating to All Chats sets URL to /all-chats, persists on refresh
  • Selecting a session from All Chats navigates to /all-chats/session/:id
  • Switching back to My Chats navigates to /
  • User avatars render with colored backgrounds in dropdowns
  • Sidebar works without activeTab/onTabChange (backward compat)

Summary by CodeRabbit

Release Notes

  • New Features

    • Implemented expandable/collapsible chat grouping organized by owner with smooth animations
    • Enhanced navigation with improved "My Chats" and "All Chats" view switching
    • Chat groups now display member counts and automatically sort by most recent activity
  • Bug Fixes

    • Fixed avatar color rendering in portaled and shadow-DOM UI contexts

… colors

- AllChatsList: collapsible user groups (collapsed by default)
- Sidebar: controlled activeTab/onTabChange props for URL routing
- useBichatRouter: /all-chats URL prefix, sidebarTab, onSidebarTabChange
- UserAvatar: inline styles for colors (fixes portal rendering in shadow DOM)
- Export ActiveTab type
@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@diyor28 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 3 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 3 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d6d1ca4-1fbd-42b8-a14c-ee7a3b6ae34e

📥 Commits

Reviewing files that changed from the base of the PR and between 6cb2f71 and c2e1ce2.

📒 Files selected for processing (3)
  • ui/src/bichat/components/AllChatsList.tsx
  • ui/src/bichat/components/Sidebar.tsx
  • ui/src/bichat/components/UserAvatar.tsx

Walkthrough

The PR restructures chat list rendering with collapsible owner-based grouping (when no user is selected), adds controlled/uncontrolled tab state management to Sidebar, introduces all-chats view routing support, and converts avatar colors from Tailwind classes to inline hex values for shadow DOM compatibility.

Changes

Cohort / File(s) Summary
Chat List Grouping & Animation
ui/src/bichat/components/AllChatsList.tsx
Introduces expandedGroups state tracking, toggleGroup() callback, and groupedChats computation that groups chats by owner ID when no user is selected. Replaces flat rendering with conditional logic: grouped view uses AnimatePresence + motion components for expandable/collapsible animations with height/opacity transitions; flat view preserves existing per-chat styling. Adds group headers with count badges and member counts.
Sidebar State Control & Tab Management
ui/src/bichat/components/Sidebar.tsx, ui/src/bichat/index.ts
Exports ActiveTab type and extends SidebarProps with optional activeTab and onTabChange props for controlled/uncontrolled mode. Implements derived state pattern using internalActiveTab and centralized handleTabChange() callback for all tab-switch handlers. Re-exports ActiveTab type from index for public API.
Routing Integration for All-Chats View
ui/src/bichat/hooks/useBichatRouter.ts
Adds onAllChatsView(), sidebarTab, and onSidebarTabChange(tab) to UseBichatRouterReturn. Implements URL-derived routing mode detection (isAllChats), prefixes session navigation with /all-chats when in all-chats section, and updates onNewChat() to respect current view mode. Updated dependency lists include isAllChats for routing consistency.
Avatar Color Styling
ui/src/bichat/components/UserAvatar.tsx
Replaces Tailwind color class interpolation (bg-*/text-* classes) with explicit hex color values in colorPalette object, applying colors via inline style={{ backgroundColor, color }} attributes for improved shadow DOM compatibility.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Sidebar
    participant Router as useBichatRouter
    participant AllChatsList

    User->>Sidebar: Click "All Chats" tab
    Sidebar->>Sidebar: handleTabChange('all-chats')
    Sidebar->>Router: onSidebarTabChange('all-chats')
    Router->>Router: navigate to /all-chats
    Router->>Sidebar: sidebarTab = 'all-chats'
    Sidebar->>AllChatsList: selectedUser = null
    AllChatsList->>AllChatsList: Compute groupedChats<br/>(group by owner.id)
    AllChatsList->>AllChatsList: Render group headers<br/>with AnimatePresence
    User->>AllChatsList: Click group caret
    AllChatsList->>AllChatsList: toggleGroup(ownerId)<br/>update expandedGroups
    AllChatsList->>AllChatsList: AnimatePresence triggers<br/>height/opacity transition
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 Grouped chats now collapse with grace,
Tabs dance between their rightful place,
Routes point to /all-chats bright,
Colors shine in shadow's light,
Animations smooth the UI's flight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the three main changes: AllChats UI grouping feature, URL-driven tabs support, and avatar inline styling fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/bichat-ui-polish

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/src/bichat/components/AllChatsList.tsx`:
- Around line 143-156: expandedGroups only updates on manual toggles and can
become stale across route/filter changes; add a useEffect that watches
activeSessionId and selectedUser and reseeds setExpandedGroups accordingly: when
activeSessionId is present, derive its ownerId (from the sessions/props state
used in this component) and call setExpandedGroups(new Set([ownerId])) so the
owner group is expanded to reveal the selected session, otherwise call
setExpandedGroups(new Set()) to return to the default collapsed view; keep
toggleGroup unchanged.
- Around line 165-170: The owner fallback in AllChatsList.tsx currently
hardcodes "Unknown", "User", and "Unknown User" when chat.owner is missing;
replace those hardcoded strings with calls to the app's localization function
(the same translation keys used by the sidebar) — import/use the existing i18n
hook/function (e.g., useTranslation or t) in AllChatsList, and substitute the
fallback values in the owner = chat.owner ?? { ... } object with localized
strings (e.g., t('sidebar.unknown'), t('sidebar.user'),
t('sidebar.unknownUser')); apply the same change for the other occurrence
mentioned (the fallback at the second location).

In `@ui/src/bichat/components/Sidebar.tsx`:
- Around line 218-227: handleTabChange currently only updates internalActiveTab
when onTabChange is absent, causing the uncontrolled mode to stay stuck when a
callback is passed; change handleTabChange (and its dependencies) so it always
calls onTabChange if provided, and updates internalActiveTab only when
controlledActiveTab is undefined (e.g. if (!controlledActiveTab)
setInternalActiveTab(tab)); reference handleTabChange, internalActiveTab,
controlledActiveTab, onTabChange, and setInternalActiveTab when making the
change.

In `@ui/src/bichat/components/UserAvatar.tsx`:
- Around line 41-50: The palette in UserAvatar (the array of { bg, text }
objects) uses '#ffffff' for every entry which yields poor contrast on lighter
backgrounds (amber, lime, cyan, green); update those entries so their text color
is a dark value (e.g. '#000000' or a dark gray like '#111827') or implement a
small luminance check inside the UserAvatar component to pick dark vs light text
dynamically based on the bg value so initials are readable (adjust the objects
for bg '#22c55e', '#06b6d4', '#f59e0b', '#84cc16' (and any other light hues) to
use dark text, or add a helper used by the UserAvatar render logic to choose
'#ffffff' vs '#111827' by calculating background luminance).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08e452a7-4f63-43bf-aee1-0335c680b957

📥 Commits

Reviewing files that changed from the base of the PR and between aaa3623 and 6cb2f71.

📒 Files selected for processing (5)
  • ui/src/bichat/components/AllChatsList.tsx
  • ui/src/bichat/components/Sidebar.tsx
  • ui/src/bichat/components/UserAvatar.tsx
  • ui/src/bichat/hooks/useBichatRouter.ts
  • ui/src/bichat/index.ts

Comment on lines +143 to +156
// Expanded state for user groups (tracks expanded owner IDs; collapsed by default)
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(new Set());

const toggleGroup = useCallback((ownerId: string) => {
setExpandedGroups((prev) => {
const next = new Set(prev);
if (next.has(ownerId)) {
next.delete(ownerId);
} else {
next.add(ownerId);
}
return next;
});
}, []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reconcile group expansion with route/filter changes.

expandedGroups only changes on manual toggles right now. After a refresh on /all-chats/session/:id, the selected session can stay hidden inside a collapsed owner group, and clearing selectedUser reuses stale expansion state instead of returning to the default collapsed view. Please seed/reset this set when activeSessionId or selectedUser changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/bichat/components/AllChatsList.tsx` around lines 143 - 156,
expandedGroups only updates on manual toggles and can become stale across
route/filter changes; add a useEffect that watches activeSessionId and
selectedUser and reseeds setExpandedGroups accordingly: when activeSessionId is
present, derive its ownerId (from the sessions/props state used in this
component) and call setExpandedGroups(new Set([ownerId])) so the owner group is
expanded to reveal the selected session, otherwise call setExpandedGroups(new
Set()) to return to the default collapsed view; keep toggleGroup unchanged.

Comment thread ui/src/bichat/components/AllChatsList.tsx
Comment thread ui/src/bichat/components/Sidebar.tsx Outdated
Comment thread ui/src/bichat/components/UserAvatar.tsx Outdated
diyor28 added 2 commits March 29, 2026 17:33
…ol, contrast

- Auto-expand owner group when activeSessionId is present (deep-link fix)
- Localize "Unknown User" fallback with t('BiChat.Common.Untitled')
- Fix handleTabChange to work in both controlled and uncontrolled modes
- Use dark text on light avatar backgrounds for accessibility
@diyor28 diyor28 merged commit 721938a into main Mar 29, 2026
2 checks passed
@diyor28 diyor28 deleted the codex/bichat-ui-polish branch March 29, 2026 12:42
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.

1 participant