diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index 8634f745ec..ffc39090f5 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -172,12 +172,11 @@ function deriveEmptyState(props: {
function ProjectGroupLabel(props: {
readonly project: EnvironmentProject;
readonly title: string;
- readonly totalThreadCount: number;
+ readonly hiddenCount: number;
readonly isExpanded: boolean;
readonly onToggleExpand: () => void;
readonly onNewThread: () => void;
}) {
- const hiddenCount = props.totalThreadCount - COLLAPSED_THREAD_LIMIT;
const iconMutedColor = useThemeColor("--color-icon-muted");
return (
@@ -212,13 +211,13 @@ function ProjectGroupLabel(props: {
/>
- {hiddenCount > 0 ? (
+ {props.hiddenCount > 0 ? (
- {props.isExpanded ? "Show less" : `${hiddenCount} more`}
+ {props.isExpanded ? "Show less" : `${props.hiddenCount} more`}
) : null}
@@ -568,9 +567,10 @@ export function HomeScreen(props: HomeScreenProps) {
) : (
projectGroups.map((group) => {
const isExpanded = expandedProjects.has(group.key);
- const visibleThreads = isExpanded
- ? group.threads
- : group.threads.slice(0, COLLAPSED_THREAD_LIMIT);
+ // Collapsed shows recent threads only; expanding reveals full history.
+ const collapsedThreads = group.recentThreads.slice(0, COLLAPSED_THREAD_LIMIT);
+ const visibleThreads = isExpanded ? group.threads : collapsedThreads;
+ const hiddenCount = group.threads.length - collapsedThreads.length;
return (
toggleExpanded(group.key)}
project={group.representative}
title={group.title}
- totalThreadCount={group.threads.length}
+ hiddenCount={hiddenCount}
/>
,
threads: ReadonlyArray,
@@ -57,6 +59,7 @@ function buildGroups(
projectSortOrder: "updated_at",
threadSortOrder: "updated_at",
projectGroupingMode: "repository",
+ now: NOW,
...overrides,
});
}
@@ -220,4 +223,95 @@ describe("buildHomeThreadGroups", () => {
);
expect(buildGroups(projects, threads, { projectGroupingMode: "separate" })).toHaveLength(2);
});
+
+ it("default view shows only threads from the last 5 days", () => {
+ const environmentId = EnvironmentId.make("environment-1");
+ const project = makeProject({
+ environmentId,
+ id: ProjectId.make("project-1"),
+ title: "T3 Code",
+ });
+ const threads = [
+ makeThread({
+ environmentId,
+ id: ThreadId.make("recent-1"),
+ projectId: project.id,
+ title: "Today",
+ updatedAt: "2026-06-28T00:00:00.000Z",
+ }),
+ makeThread({
+ environmentId,
+ id: ThreadId.make("recent-2"),
+ projectId: project.id,
+ title: "Within window",
+ updatedAt: "2026-06-25T00:00:00.000Z",
+ }),
+ makeThread({
+ environmentId,
+ id: ThreadId.make("old"),
+ projectId: project.id,
+ title: "Two weeks ago",
+ updatedAt: "2026-06-14T00:00:00.000Z",
+ }),
+ ];
+
+ const group = buildGroups([project], threads)[0];
+ // Default view trims to recent threads...
+ expect(group?.recentThreads.map((thread) => thread.id)).toEqual(["recent-1", "recent-2"]);
+ // ...while full history stays available for the expanded view.
+ expect(group?.threads.map((thread) => thread.id)).toEqual(["recent-1", "recent-2", "old"]);
+ });
+
+ it("falls back to the most recent 3 threads when none are within 5 days", () => {
+ const environmentId = EnvironmentId.make("environment-1");
+ const project = makeProject({
+ environmentId,
+ id: ProjectId.make("project-1"),
+ title: "T3 Code",
+ });
+ const threads = ["2026-06-01", "2026-06-02", "2026-06-03", "2026-06-04", "2026-06-05"].map(
+ (day, index) =>
+ makeThread({
+ environmentId,
+ id: ThreadId.make(`thread-${index}`),
+ projectId: project.id,
+ title: `Thread ${index}`,
+ updatedAt: `${day}T00:00:00.000Z`,
+ }),
+ );
+
+ const group = buildGroups([project], threads)[0];
+ expect(group?.recentThreads.map((thread) => thread.id)).toEqual([
+ "thread-4",
+ "thread-3",
+ "thread-2",
+ ]);
+ expect(group?.threads).toHaveLength(5);
+ });
+
+ it("does not apply the recency window while searching", () => {
+ const environmentId = EnvironmentId.make("environment-1");
+ const project = makeProject({
+ environmentId,
+ id: ProjectId.make("project-1"),
+ title: "T3 Code",
+ });
+ const threads = ["2026-06-01", "2026-06-02", "2026-06-03", "2026-06-04", "2026-06-05"].map(
+ (day, index) =>
+ makeThread({
+ environmentId,
+ id: ThreadId.make(`thread-${index}`),
+ projectId: project.id,
+ title: `Thread ${index}`,
+ updatedAt: `${day}T00:00:00.000Z`,
+ }),
+ );
+
+ const group = buildGroups([project], threads, { searchQuery: "T3 Code" })[0];
+ // Search reaches the full history rather than the 3-thread fallback.
+ expect(group?.recentThreads).toHaveLength(5);
+ expect(group?.recentThreads.map((thread) => thread.id)).toEqual(
+ group?.threads.map((thread) => thread.id),
+ );
+ });
});
diff --git a/apps/mobile/src/features/home/homeThreadList.ts b/apps/mobile/src/features/home/homeThreadList.ts
index 9f09e894c2..c848d1dc79 100644
--- a/apps/mobile/src/features/home/homeThreadList.ts
+++ b/apps/mobile/src/features/home/homeThreadList.ts
@@ -20,12 +20,23 @@ import { scopedProjectKey } from "../../lib/scopedEntities";
export type HomeProjectSortOrder = Exclude;
+/**
+ * Default home view only surfaces threads active within this window, to keep the
+ * screen compact while keeping recent work visible.
+ */
+const RECENT_THREAD_WINDOW_MS = 5 * 24 * 60 * 60 * 1000;
+/** Fallback when a project has no threads inside the recency window. */
+const RECENT_THREAD_FALLBACK_COUNT = 3;
+
export interface HomeThreadGroup {
readonly key: string;
readonly title: string;
readonly representative: EnvironmentProject;
readonly projects: ReadonlyArray;
+ /** Full sorted thread history for the group (revealed when expanded / searching). */
readonly threads: ReadonlyArray;
+ /** Subset shown by default: threads from the last few days, or the most recent few. */
+ readonly recentThreads: ReadonlyArray;
}
interface MutableHomeThreadGroup {
@@ -41,6 +52,24 @@ function groupSortTimestamp(group: HomeThreadGroup, sortOrder: HomeProjectSortOr
);
}
+/**
+ * Trims a group's threads to recent activity for the default home view.
+ * `sortedThreads` must already be ordered newest-first for `threadSortOrder`.
+ * Keeps threads within {@link RECENT_THREAD_WINDOW_MS}; when none qualify, keeps
+ * the most recent {@link RECENT_THREAD_FALLBACK_COUNT} so a project never vanishes.
+ */
+function selectRecentThreads(
+ sortedThreads: ReadonlyArray,
+ threadSortOrder: SidebarThreadSortOrder,
+ now: number,
+): ReadonlyArray {
+ const cutoff = now - RECENT_THREAD_WINDOW_MS;
+ const recent = sortedThreads.filter(
+ (thread) => getThreadSortTimestamp(thread, threadSortOrder) >= cutoff,
+ );
+ return recent.length > 0 ? recent : sortedThreads.slice(0, RECENT_THREAD_FALLBACK_COUNT);
+}
+
export function buildHomeThreadGroups(input: {
readonly projects: ReadonlyArray;
readonly threads: ReadonlyArray;
@@ -49,7 +78,10 @@ export function buildHomeThreadGroups(input: {
readonly projectSortOrder: HomeProjectSortOrder;
readonly threadSortOrder: SidebarThreadSortOrder;
readonly projectGroupingMode: SidebarProjectGroupingMode;
+ /** Current time used for the recency window; defaults to now. Injectable for tests. */
+ readonly now?: number;
}): ReadonlyArray {
+ const now = input.now ?? Date.now();
const groups = new Map();
const groupKeyByProjectKey = new Map();
@@ -113,12 +145,21 @@ export function buildHomeThreadGroups(input: {
continue;
}
+ const sortedThreads = sortThreads(matchingThreads, input.threadSortOrder);
+ // An active search should reach the full history, so the recency window
+ // only trims the default (no-query) view.
+ const recentThreads =
+ query.length === 0
+ ? selectRecentThreads(sortedThreads, input.threadSortOrder, now)
+ : sortedThreads;
+
result.push({
key: group.key,
title,
representative,
projects: group.projects,
- threads: sortThreads(matchingThreads, input.threadSortOrder),
+ threads: sortedThreads,
+ recentThreads,
});
}