:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(mobilehog): show reports for you by default (#115146)
Dylan Martincfdfbec38b64
diff --git a/products/desktop/apps/mobilehog/src/app/(drawer)/self-driving.tsx b/products/desktop/apps/mobilehog/src/app/(drawer)/self-driving.tsxindex 00b8ac95ef50..2c21945878c6 100644--- a/products/desktop/apps/mobilehog/src/app/(drawer)/self-driving.tsx+++ b/products/desktop/apps/mobilehog/src/app/(drawer)/self-driving.tsx@@ -1,5 +1,18 @@-import { Host, Picker, Text as SwiftText } from "@expo/ui/swift-ui";-import { pickerStyle, tag } from "@expo/ui/swift-ui/modifiers";+import {+ Button,+ Host,+ Image,+ Menu,+ Picker,+ Text as SwiftText,+} from "@expo/ui/swift-ui";+import {+ accessibilityLabel,+ frame,+ glassEffect,+ pickerStyle,+ tag,+} from "@expo/ui/swift-ui/modifiers";import { formatRelativeAge } from "@posthog/shared";import type { SignalReport } from "@posthog/shared/domain-types";import * as Haptics from "expo-haptics";@@ -20,6 +33,7 @@ import { MenuIcon } from "@/components/Icons";import { PriorityChip } from "@/components/ReportCard";import { TriageDeck } from "@/components/TriageDeck";import { REPORT_FILTERS, type ReportFilter } from "@/lib/reportFilters";+import { REPORT_SCOPES, useReportScope } from "@/lib/reportScope";import {useDismissReport,useMarkReportRead,@@ -35,14 +49,22 @@ const EMPTY: Record<ReportFilter, string> = {dismissed: "Nothing dismissed",};+const EMPTY_FOR_YOU: Record<ReportFilter, string> = {+ attention: "Nothing for you right now.",+ "pull-requests": "No pull requests ready for you.",+ dismissed: "Nothing dismissed for you.",+};+export default function SelfDrivingScreen() {const navigation = useNavigation<{ openDrawer: () => void }>();const router = useRouter();const insets = useSafeAreaInsets();const [filter, setFilter] = useState<ReportFilter>("attention");+ const scope = useReportScope((s) => s.scope);+ const setScope = useReportScope((s) => s.setScope);// The deck always works on the reports that need attention.- const reports = useReports();- const listed = useReports("", filter);+ const reports = useReports("", "attention", { scope });+ const listed = useReports("", filter, { scope });const markRead = useMarkReportRead();const dismiss = useDismissReport();const startTask = useStartReportTask();@@ -147,7 +169,40 @@ export default function SelfDrivingScreen() {</GlassCircleButton>)}<Text style={styles.title}>{showDeck ? "Triage" : "Reports"}</Text>- <View style={{ width: 46 }} />+ {showDeck ? (+ <View style={{ width: 46 }} />+ ) : (+ <Host matchContents>+ <Menu+ label={+ <Image+ systemName="slider.horizontal.3"+ size={18}+ color={colors.ink}+ />+ }+ modifiers={[+ frame({ width: 46, height: 46 }),+ glassEffect({+ glass: { variant: "regular", interactive: true },+ shape: "circle",+ }),+ accessibilityLabel("Report scope"),+ ]}+ >+ {REPORT_SCOPES.map((option) => (+ <Button+ key={option.value}+ label={option.label}+ systemImage={+ scope === option.value ? "checkmark" : option.icon+ }+ onPress={() => setScope(option.value)}+ />+ ))}+ </Menu>+ </Host>+ )}</View>{showDeck ? (@@ -198,7 +253,15 @@ export default function SelfDrivingScreen() {</Pressable>) : null}{rows.length === 0 && !listed.isLoading && !listFailed ? (- <Text style={styles.sectionTitle}>{EMPTY[filter]}</Text>+ scope === "for-you" ? (+ <Pressable onPress={() => setScope("entire-project")}>+ <Text style={styles.muted}>+ {EMPTY_FOR_YOU[filter]} Tap to show the entire project.+ </Text>+ </Pressable>+ ) : (+ <Text style={styles.sectionTitle}>{EMPTY[filter]}</Text>+ )) : null}{rows.map((report) => (<Pressablediff --git a/products/desktop/apps/mobilehog/src/components/DrawerContent.tsx b/products/desktop/apps/mobilehog/src/components/DrawerContent.tsxindex 8a879fb1198e..816b10367e1f 100644--- a/products/desktop/apps/mobilehog/src/components/DrawerContent.tsx+++ b/products/desktop/apps/mobilehog/src/components/DrawerContent.tsx@@ -12,6 +12,7 @@ import { activityAt, RowSkeletons, TaskRow } from "@/components/TaskRow";import { useActivity } from "@/lib/activity";import { useAuth } from "@/lib/auth";import { useTasks } from "@/lib/queries";+import { useReportScope } from "@/lib/reportScope";import { useReportReadStates, useReports } from "@/lib/reports";import { colors, fonts, radius } from "@/lib/theme";@@ -21,7 +22,8 @@ export function DrawerContent({ closeDrawer }: { closeDrawer: () => void }) {const tasks = useTasks();const userName = useAuth((s) => s.session?.userName ?? "");const unread = useActivity().data?.unread_count ?? 0;- const reports = useReports().data;+ const scope = useReportScope((s) => s.scope);+ const reports = useReports("", "attention", { scope }).data;const reportIds = useMemo(() => (reports ?? []).map((report) => report.id),[reports],diff --git a/products/desktop/apps/mobilehog/src/lib/accountLifecycle.ts b/products/desktop/apps/mobilehog/src/lib/accountLifecycle.tsindex 0746669e0f86..a4d6f08376e4 100644--- a/products/desktop/apps/mobilehog/src/lib/accountLifecycle.ts+++ b/products/desktop/apps/mobilehog/src/lib/accountLifecycle.ts@@ -11,6 +11,7 @@ import { useComposer } from "@/lib/composer";import { resetEngine } from "@/lib/engine";import { resetMcpClient } from "@/lib/mcp/client";import { useRepo } from "@/lib/repo";+import { useReportScope } from "@/lib/reportScope";import { resetUnstartedReportTasks } from "@/lib/reports";import { useSessions } from "@/lib/session";@@ -42,6 +43,7 @@ useAuth.subscribe((state, previous) => {resetMcpClient();useComposer.getState().reset();useRepo.setState({ repository: undefined });+ useReportScope.setState({ scope: "for-you" });resetUnstartedReportTasks();resetSentPhotos();});diff --git a/products/desktop/apps/mobilehog/src/lib/queries.ts b/products/desktop/apps/mobilehog/src/lib/queries.tsindex 0ca483183ada..546d2bb6758d 100644--- a/products/desktop/apps/mobilehog/src/lib/queries.ts+++ b/products/desktop/apps/mobilehog/src/lib/queries.ts@@ -8,7 +8,7 @@ import {} from "@tanstack/react-query";import { DEFAULT_MODEL, DEFAULT_REPOSITORY } from "@/config";import { type Photo, uploadStagedPhotos } from "@/lib/attachments";-import { useAuth } from "@/lib/auth";+import { type Session, useAuth } from "@/lib/auth";import { getClient } from "@/lib/client";import { currentRunConfig } from "@/lib/composer";import { useRepo } from "@/lib/repo";@@ -109,6 +109,14 @@ export function useTasks(search = "") {});}+export function currentUserQuery(session: Session | null) {+ return {+ queryKey: ["me", session?.host, session?.userId],+ queryFn: () => getClient().getCurrentUser(),+ staleTime: Number.POSITIVE_INFINITY,+ };+}+export function useTask(taskId: string) {const session = useAuth((s) => s.session);return useQuery({diff --git a/products/desktop/apps/mobilehog/src/lib/reportScope.test.ts b/products/desktop/apps/mobilehog/src/lib/reportScope.test.tsnew file mode 100644index 000000000000..e8c90fdae47a--- /dev/null+++ b/products/desktop/apps/mobilehog/src/lib/reportScope.test.ts@@ -0,0 +1,16 @@+import { describe, expect, it } from "vitest";+import { reportScopeParams } from "./reportScope";++describe("reportScopeParams", () => {+ it.each([+ ["entire-project", "user-1", {}],+ ["entire-project", undefined, {}],+ ["for-you", "user-1", { suggested_reviewers: "user-1" }],+ ["for-you", " user-1 ", { suggested_reviewers: "user-1" }],+ ["for-you", undefined, null],+ ["for-you", null, null],+ ["for-you", " ", null],+ ] as const)("%s with uuid %j", (scope, uuid, expected) => {+ expect(reportScopeParams(scope, uuid)).toEqual(expected);+ });+});diff --git a/products/desktop/apps/mobilehog/src/lib/reportScope.ts b/products/desktop/apps/mobilehog/src/lib/reportScope.tsnew file mode 100644index 000000000000..2c744996715c--- /dev/null+++ b/products/desktop/apps/mobilehog/src/lib/reportScope.ts@@ -0,0 +1,31 @@+import { buildSuggestedReviewerFilterParam } from "@posthog/core/inbox/reportFiltering";+import type { SignalReportsQueryParams } from "@posthog/shared/domain-types";+import { create } from "zustand";++export type ReportScope = "for-you" | "entire-project";++export const REPORT_SCOPES = [+ { value: "for-you", label: "For you", icon: "person" },+ { value: "entire-project", label: "Entire project", icon: "person.2" },+] as const;++export const useReportScope = create<{+ scope: ReportScope;+ setScope: (scope: ReportScope) => void;+}>((set) => ({+ scope: "for-you",+ setScope: (scope) => set({ scope }),+}));++// Null means "For you" has no reviewer to filter on. The caller must not fall+// back to the whole project then.+export function reportScopeParams(+ scope: ReportScope,+ userUuid: string | null | undefined,+): Pick<SignalReportsQueryParams, "suggested_reviewers"> | null {+ if (scope === "entire-project") return {};+ const reviewers = buildSuggestedReviewerFilterParam(+ userUuid ? [userUuid] : [],+ );+ return reviewers ? { suggested_reviewers: reviewers } : null;+}diff --git a/products/desktop/apps/mobilehog/src/lib/reports.ts b/products/desktop/apps/mobilehog/src/lib/reports.tsindex c72d4b974273..eb56cde23b18 100644--- a/products/desktop/apps/mobilehog/src/lib/reports.ts+++ b/products/desktop/apps/mobilehog/src/lib/reports.ts@@ -20,6 +20,7 @@ import { useCallback, useMemo } from "react";import { useAuth } from "@/lib/auth";import { getClient } from "@/lib/client";import { currentRunConfig } from "@/lib/composer";+import { currentUserQuery } from "@/lib/queries";import {hasOpenImplementationPr,type ReportFilter,@@ -32,6 +33,7 @@ import {restoreReadState,summarizeReadStates,} from "@/lib/reportReadState";+import { type ReportScope, reportScopeParams } from "@/lib/reportScope";import { fetchHasLiveImplementationTask } from "@/lib/reportTasks";import { useSessions } from "@/lib/session";@@ -45,18 +47,33 @@ export const reportKeys = {liveTask: (id: string) => ["reports", id, "live-task"] as const,};-// Defaults to the reports a person can act on right now.-export function useReports(search = "", filter: ReportFilter = "attention") {+// Defaults to the reports a person can act on right now, across the project.+export function useReports(+ search = "",+ filter: ReportFilter = "attention",+ { scope = "entire-project" }: { scope?: ReportScope } = {},+) {const session = useAuth((s) => s.session);- const key = [...reportKeys.list, filter];+ const queryClient = useQueryClient();+ const key = [...reportKeys.list, filter, scope];return useQuery({queryKey: search ? [...key, "search", search] : key,- queryFn: () =>- getClient().getSignalReports({+ queryFn: async () => {+ // "For you" waits for the user's uuid, so it never shows the whole+ // project first.+ const user =+ scope === "for-you"+ ? await queryClient.ensureQueryData(currentUserQuery(session))+ : null;+ const scoped = reportScopeParams(scope, user?.uuid);+ if (!scoped) throw new Error("Could not load your account");+ return getClient().getSignalReports({...reportFilterParams(filter),+ ...scoped,limit: 100,search: search || undefined,- }),+ });+ },enabled: !!session,refetchInterval: 60_000,select: (page) => {