Skip to content

Discover tab for mobile#1838

Merged
prxt6529 merged 7 commits intomainfrom
mobile-discover-tab
Jan 28, 2026
Merged

Discover tab for mobile#1838
prxt6529 merged 7 commits intomainfrom
mobile-discover-tab

Conversation

@prxt6529
Copy link
Copy Markdown
Collaborator

@prxt6529 prxt6529 commented Jan 27, 2026

Summary by CodeRabbit

  • New Features

    • Added "Discover" as a primary navigation item.
  • Updates

    • Swapped Home/Stream navigation semantics and rely on path-based routing; persistent Home-tab state removed.
    • Unified home routing to a single default home route.
    • Simplified footer and layout behavior; improved small-screen header/menu lifecycle.
    • Notifications default redirect updated.
  • Tests

    • Updated navigation, layout, and many mocks to reflect new routing and removed Home-tab APIs.
  • Chores

    • Removed Home-tab storage/sync utilities and related TitleContext setter/hooks.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: prxt6529 <prxt@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Navigation labels and routes were changed (introducing "Discover", renaming "Stream"→"Home"), home-tab state and storage logic were removed, navigation active-state logic simplified to path-based checks, helpers consolidated to getHomeRoute(), and related components, layout, brain modules, and tests updated accordingly.

Changes

Cohort / File(s) Summary
Navigation definitions & rendering
components/navigation/BottomNavigation.tsx, components/navigation/NavItem.tsx
Swapped nav labels/icons: first item → Discover (/discover, DiscoverIcon), second → Home (/, LogoIcon). Removed homeActiveTab usage and replaced Stream checks with Home/isLogoItem. Adjusted indicator/translation condition.
Navigation context & click handling
components/navigation/ViewContext.tsx, components/navigation/isNavItemActive.ts
Removed home-tab state/storage/events and related provider property; unified home routing via getHomeRoute(); updated isNavItemActive signature and logic (removed tab param, added Discover path special-case, simplified wave/message sub-route checks).
Route helper replacements & call sites
helpers/navigation.helpers.ts, proxy.ts, components/brain/*.tsx (e.g., BrainMobile.tsx, my-stream/*.tsx)
Replaced getHomeFeedRoute/getHomeLatestRoute with getHomeRoute; updated imports and fallback navigation calls to use getHomeRoute().
Home tab removal (hooks/storage & UI impact)
components/home/useHomeTabs.ts (removed), components/footer/FooterWrapper.tsx, components/layout/AppLayout.tsx, components/layout/SmallScreenLayout.tsx, components/brain/notifications/hooks/useNotificationsController.ts
Deleted home-tab hook/module and storage/event logic; removed home-tab-driven branches in footer/layout; simplified overflow/header/menu logic and footer visibility.
Tests and mocks updated
__tests__/components/navigation/*, __tests__/**/*, __tests__/utils/titleTestUtils.tsx
Updated fixtures/assertions to reflect renames (Stream→Home, Home→Discover), removed homeActiveTab and setStreamHasNewItems/useSetStreamHasNewItems from test mocks, and adjusted route expectations.
Title context & small comment changes
contexts/TitleContext.tsx, components/brain/layout/LayoutContext.tsx
Removed setStreamHasNewItems from TitleContext API and stream/home-tab related logic; adjusted title derivation and comments (feed → view wording).

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
actor User as Client
participant Nav as BottomNavigation/NavItem
participant VC as ViewContext
participant Router as Router
participant Helper as getHomeRoute
Client->>Nav: click nav item (Discover or Home)
Nav->>VC: handleNavClick(item)
VC->>Router: determine target (item.href or getHomeRoute())
alt item is Home
VC->>Helper: call getHomeRoute()
Helper-->>VC: return route (e.g., "/")
end
VC->>Router: push route
Router-->>Client: navigate to new URL
note right of Nav: isNavItemActive recomputes based on pathname/search params

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • #1731 — Overlaps refactoring of ViewContext.tsx and URL/tab handling.
  • #1626 — Related changes to ViewContext public surface and navigation behaviors.
  • #1787 — Modifies navigation/layout components (BottomNavigation/AppLayout) similar to this PR.

Suggested reviewers

  • simo6529
  • ragnep

Poem

🐰 I hopped through lines with a twitch and a spin,

Stream donned a new name and Discover came in.
Tabs tucked away, routes stitched just right,
I munched a carrot and bounded from night to bright. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 'Discover tab for mobile' accurately reflects the main changes in this pull request, which introduce a new Discover navigation item and refactor the Home/Stream navigation structure for mobile.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Copy Markdown

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
__tests__/components/navigation/ViewContext.test.tsx (1)

65-81: Test data does not match the test description.

This test is labeled "handles route navigation" suggesting it tests generic route behavior, but the NavItem uses name: "Home" which triggers the special Home handling in handleNavClick. The href: "/home" is never used because the Home-specific branch always calls router.push(getHomeLatestRoute()) which returns "/".

Consider either:

  1. Rename this test to clarify it's testing Home navigation (but then it duplicates the test below), or
  2. Change the item name to something other than "Home" (e.g., "Network") to test generic route navigation.
Proposed fix to test generic route navigation
 it("handles route navigation", () => {
   render(
     <ViewProvider>
       <TestNavComponent
         item={
           {
             kind: "route",
-            name: "Home",
-            href: "/home",
-            icon: "h",
+            name: "Network",
+            href: "/network",
+            icon: "n",
           } as NavItem
         }
       />
     </ViewProvider>
   );
-  expect(push).toHaveBeenCalledWith("/");
+  expect(push).toHaveBeenCalledWith("/network");
 });

Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Copy link
Copy Markdown

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
contexts/TitleContext.tsx (2)

93-111: Route-change reset never runs due to duplicated routeRef update.

Because the earlier effect (Line 93-100) sets routeRef.current before this effect executes, the guard at Line 103 short-circuits and the reset (setWaveData(null) / setStreamHasNewItems(false)) never fires on route changes. This defeats the intended cleanup.

Consider consolidating into a single effect so the reset reliably executes on route changes.

🔧 Proposed consolidation
-  useEffect(() => {
-    if (routeRef.current === pathname) {
-      return;
-    }
-    routeRef.current = pathname;
-    const defaultTitle = getDefaultTitleForRoute(pathname);
-    setTitle(defaultTitle);
-  }, [pathname]);
-
-  useEffect(() => {
-    if (routeRef.current !== pathname) {
-      routeRef.current = pathname;
-      queryRef.current = searchParams;
-      const defaultTitle = getDefaultTitleForRoute(pathname);
-      setTitle(defaultTitle);
-      setWaveData(null);
-      setStreamHasNewItems(false);
-    }
-  }, [pathname, searchParams]);
+  useEffect(() => {
+    if (routeRef.current === pathname) {
+      return;
+    }
+    routeRef.current = pathname;
+    queryRef.current = searchParams;
+    const defaultTitle = getDefaultTitleForRoute(pathname);
+    setTitle(defaultTitle);
+    setWaveData(null);
+    setStreamHasNewItems(false);
+  }, [pathname, searchParams]);

132-155: isHomeFeedTab is undefined after tab-state removal.

This symbol is no longer declared in the file, which will fail type-check/build. Replace it with a route-based flag (e.g., home pathname) or remove the branch if no longer needed.

✅ Suggested fix (route-based home flag)
   const isWaveRoute =
     pathname?.startsWith("/waves") ||
     pathname?.startsWith("/messages") ||
     (pathname === "/" && searchParams?.get("view") === "waves");
+  const isHomeRoute = pathname === "/";

   const computedTitle = useMemo(() => {
     const waveTitle = (() => {
       if (!waveParam || !waveData) return null;
       let newItemsText = "";
       if (waveData.newItemsCount > 0 && notificationCount === 0) {
         const messageText =
           waveData.newItemsCount === 1 ? "message" : "messages";
         newItemsText = `(${waveData.newItemsCount} new ${messageText}) `;
       }
       return `${newItemsText}${waveData.name} | Brain`;
     })();

-    if (isHomeFeedTab) {
+    if (isHomeRoute) {
       if (waveTitle) return waveTitle;

       const prefix =
         streamHasNewItems && notificationCount === 0
           ? "(New messages) My Stream"
           : "My Stream";
       return `${prefix} | Brain`;
     }
@@
   }, [
-    isHomeFeedTab,
+    isHomeRoute,
     isWaveRoute,
     waveParam,
     waveData,
     streamHasNewItems,
     title,
     notificationCount,
   ]);

Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Copy link
Copy Markdown

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
contexts/TitleContext.tsx (1)

93-111: Duplicate useEffect causes wave state reset to never execute.

The first effect (lines 93-100) updates routeRef.current when pathname changes. Since effects run in declaration order, by the time the second effect (lines 102-111) executes, routeRef.current already equals pathname, making the condition routeRef.current !== pathname always false on pathname change.

Result: setWaveData(null) and setStreamHasNewItems(false) on lines 108-109 are dead code—they never run when navigating between routes.

🐛 Proposed fix: Consolidate into a single effect
-  useEffect(() => {
-    if (routeRef.current === pathname) {
-      return;
-    }
-    routeRef.current = pathname;
-    const defaultTitle = getDefaultTitleForRoute(pathname);
-    setTitle(defaultTitle);
-  }, [pathname]);
-
-  useEffect(() => {
-    if (routeRef.current !== pathname) {
-      routeRef.current = pathname;
-      queryRef.current = searchParams;
-      const defaultTitle = getDefaultTitleForRoute(pathname);
-      setTitle(defaultTitle);
-      setWaveData(null);
-      setStreamHasNewItems(false);
-    }
-  }, [pathname, searchParams]);
+  useEffect(() => {
+    if (routeRef.current === pathname) {
+      return;
+    }
+    routeRef.current = pathname;
+    queryRef.current = searchParams;
+    const defaultTitle = getDefaultTitleForRoute(pathname);
+    setTitle(defaultTitle);
+    setWaveData(null);
+    setStreamHasNewItems(false);
+  }, [pathname, searchParams]);

Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

@prxt6529 prxt6529 merged commit aca26c2 into main Jan 28, 2026
7 checks passed
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