Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions apps/mobile/__tests__/screens/today-screen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ vi.mock("@react-native-async-storage/async-storage", () => ({
},
}));

vi.mock("@/hooks/use-habit-queries", () => ({
useTotalHabitCount: () => 10,
}));

vi.mock("@/hooks/use-coach-tour", () => ({
useCoachTour: () => {},
}));
Expand Down
4 changes: 0 additions & 4 deletions apps/mobile/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
useDeleteHabit,
} from "@/hooks/use-habits";
import { useTags } from "@/hooks/use-tags";
import { useTotalHabitCount } from "@/hooks/use-habit-queries";
import { useCoachTour } from "@/hooks/use-coach-tour";
import { useUIStore } from "@/stores/ui-store";
import { useReferralPromptStore } from "@/stores/referral-prompt-store";
Expand Down Expand Up @@ -132,7 +131,6 @@ export default function TodayScreen() {
const { profile } = useProfile();
const reviewReminder = useReviewReminder(profile);
const { tags } = useTags();
const totalHabitCount = useTotalHabitCount();
useCoachTour();
const deleteHabit = useDeleteHabit();

Expand Down Expand Up @@ -894,7 +892,6 @@ export default function TodayScreen() {
showCompleted={showCompleted}
isFetching={habitsQuery.isFetching}
allCollapsed={habitListAllCollapsed}
showFilters={totalHabitCount >= 5}
showControlsMenu={showControlsMenu}
controlsMenuAnchorRect={controlsMenuAnchorRect}
showFreqMenu={showFreqMenu}
Expand Down Expand Up @@ -964,7 +961,6 @@ export default function TodayScreen() {
swipeGesture,
tags,
toggleTagFilter,
totalHabitCount,
freqMenuAnchorRect,
showFreqMenu,
],
Expand Down
36 changes: 14 additions & 22 deletions apps/mobile/components/today/today-habits-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ interface TodayHabitsHeaderProps {
showCompleted: boolean;
isFetching: boolean;
allCollapsed: boolean;
showFilters: boolean;
showControlsMenu: boolean;
controlsMenuAnchorRect: MenuAnchorRect | null;
showFreqMenu: boolean;
Expand Down Expand Up @@ -240,7 +239,6 @@ export function TodayHabitsHeader({
showCompleted,
isFetching,
allCollapsed,
showFilters,
showControlsMenu,
controlsMenuAnchorRect,
showFreqMenu,
Expand Down Expand Up @@ -304,8 +302,6 @@ export function TodayHabitsHeader({
{dayProgress.done}/{dayProgress.total}
</Text>
) : null}
{showFilters ? (
<>
<Pressable
onPress={onSearchToggle}
accessibilityRole="button"
Expand Down Expand Up @@ -372,8 +368,6 @@ export function TodayHabitsHeader({
<MoreVertical size={18} color={tokens.fg2} strokeWidth={1.8} />
</Pressable>
</MenuAnchorHost>
</>
) : null}
</View>
}
>
Expand Down Expand Up @@ -408,22 +402,20 @@ export function TodayHabitsHeader({
/>
) : null}

{showFilters ? (
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
contentContainerStyle={styles.filtersContent}
>
{tags.map((tag) => (
<TagChip
key={tag.id}
tag={tag}
active={selectedTagIds.includes(tag.id)}
onPress={() => onTagToggle(tag.id)}
/>
))}
</ScrollView>
) : null}
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
contentContainerStyle={styles.filtersContent}
>
{tags.map((tag) => (
<TagChip
key={tag.id}
tag={tag}
active={selectedTagIds.includes(tag.id)}
onPress={() => onTagToggle(tag.id)}
/>
))}
</ScrollView>

<AnchoredMenu
visible={showControlsMenu}
Expand Down
17 changes: 2 additions & 15 deletions apps/web/__tests__/app/today-page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { createMockHabit, createMockProfile } from '@orbit/shared/__tests__/fact
import type { NormalizedHabit } from '@orbit/shared/types/habit'
import { computeHabitCardStatus } from '@orbit/shared/utils'

const { useHabitsMock, totalHabitCountRef } = vi.hoisted(() => ({
const { useHabitsMock } = vi.hoisted(() => ({
useHabitsMock: vi.fn(),
totalHabitCountRef: { value: 10 },
}))

const dateParamState = { value: null as string | null }
Expand Down Expand Up @@ -129,10 +128,6 @@ vi.mock('@/hooks/use-habits', () => ({
useBulkSkipHabits: () => ({ mutateAsync: bulkSkipMutateAsync }),
}))

vi.mock('@/hooks/use-habit-queries', () => ({
useTotalHabitCount: () => totalHabitCountRef.value,
}))

vi.mock('@/hooks/use-coach-tour', () => ({
useCoachTour: () => {},
}))
Expand Down Expand Up @@ -217,21 +212,13 @@ describe('TodayPage bulk parent prompts', () => {
uiState.selectedTagIds = []
uiState.showCompleted = false
uiState.selectedHabitIds = new Set<string>()
totalHabitCountRef.value = 10
})

afterEach(() => {
vi.useRealTimers()
})

it('hides the advanced filter row until the user has five habits', () => {
totalHabitCountRef.value = 4
const { unmount } = render(<TodayPage />)
expect(screen.queryByTestId('today-utility-row')).toBeNull()
expect(screen.getByTestId('habit-list')).toBeInTheDocument()
unmount()

totalHabitCountRef.value = 5
it('always shows the filter row regardless of habit count', () => {
render(<TodayPage />)
expect(screen.getByTestId('today-utility-row')).toBeInTheDocument()
expect(screen.getByTestId('habit-list')).toBeInTheDocument()
Expand Down
52 changes: 24 additions & 28 deletions apps/web/app/(app)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
useHabits,
} from '@/hooks/use-habits'
import { useTags } from '@/hooks/use-tags'
import { useTotalHabitCount } from '@/hooks/use-habit-queries'
import { useCoachTour } from '@/hooks/use-coach-tour'
import { useBulkActions } from '@/hooks/use-bulk-actions'
import {
Expand Down Expand Up @@ -72,7 +71,6 @@ export default function TodayPage() {
const queryClient = useQueryClient()
const { profile } = useProfile()
const { tags } = useTags()
const totalHabitCount = useTotalHabitCount()
useCoachTour()
const listMotionPreset = resolveMotionPreset('list-enter', Boolean(prefersReducedMotion))
const listTransition = {
Expand Down Expand Up @@ -456,32 +454,30 @@ export default function TodayPage() {

{currentActiveView === 'today' && <SetupChecklistCard />}

{totalHabitCount >= 5 && (
<motion.div layout transition={listTransition} data-testid="today-utility-row">
<TodayUtilityRow
activeView={currentActiveView}
searchOpen={searchOpen}
searchValue={localSearchQuery}
selectedFrequency={selectedFrequency}
selectedTagIds={selectedTagIds}
tags={tags}
frequencyOptions={frequencyOptions}
isSelectMode={isSelectMode}
showCompleted={showCompleted}
isFetching={habitsQuery.isFetching}
allCollapsed={habitListAllCollapsed}
onSearchToggle={toggleSearch}
onSearchChange={setLocalSearchQuery}
onSearchClear={() => setLocalSearchQuery('')}
onFrequencyChange={setSelectedFrequency}
onTagToggle={toggleTagFilter}
onToggleSelect={toggleSelectMode}
onToggleCollapse={handleToggleCollapse}
onRefresh={handleRefresh}
onToggleCompleted={() => setShowCompleted(!showCompleted)}
/>
</motion.div>
)}
<motion.div layout transition={listTransition} data-testid="today-utility-row">
<TodayUtilityRow
activeView={currentActiveView}
searchOpen={searchOpen}
searchValue={localSearchQuery}
selectedFrequency={selectedFrequency}
selectedTagIds={selectedTagIds}
tags={tags}
frequencyOptions={frequencyOptions}
isSelectMode={isSelectMode}
showCompleted={showCompleted}
isFetching={habitsQuery.isFetching}
allCollapsed={habitListAllCollapsed}
onSearchToggle={toggleSearch}
onSearchChange={setLocalSearchQuery}
onSearchClear={() => setLocalSearchQuery('')}
onFrequencyChange={setSelectedFrequency}
onTagToggle={toggleTagFilter}
onToggleSelect={toggleSelectMode}
onToggleCollapse={handleToggleCollapse}
onRefresh={handleRefresh}
onToggleCompleted={() => setShowCompleted(!showCompleted)}
/>
</motion.div>

{!hasFetched && (
<div className="stagger-enter" style={{ padding: '12px 20px 8px' }}>
Expand Down