Pull uncommitted work: home thread list changes (worktree c4c62ae9), resolve HomeScreen conflicts
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
9531885405
commit
efee0c9f26
3 files changed
+144
-9
No files matched your search
@@ -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: {
|
||||
/>
|
||||
</Pressable>
|
||||
|
||||
{hiddenCount > 0 ? (
|
||||
{props.hiddenCount > 0 ? (
|
||||
<Pressable onPress={props.onToggleExpand} hitSlop={8}>
|
||||
<Text
|
||||
className="text-xs font-t3-medium text-foreground-muted"
|
||||
style={{ letterSpacing: 0.4 }}
|
||||
>
|
||||
{props.isExpanded ? "Show less" : `${hiddenCount} more`}
|
||||
{props.isExpanded ? "Show less" : `${props.hiddenCount} more`}
|
||||
</Text>
|
||||
</Pressable>
|
||||
) : 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 (
|
||||
<Animated.View
|
||||
@@ -586,7 +586,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
onToggleExpand={() => toggleExpanded(group.key)}
|
||||
project={group.representative}
|
||||
title={group.title}
|
||||
totalThreadCount={group.threads.length}
|
||||
hiddenCount={hiddenCount}
|
||||
/>
|
||||
<View
|
||||
className="overflow-hidden rounded-[20px] bg-card"
|
||||
|
||||
@@ -44,6 +44,8 @@ function makeThread(
|
||||
};
|
||||
}
|
||||
|
||||
const NOW = Date.parse("2026-06-29T00:00:00.000Z");
|
||||
|
||||
function buildGroups(
|
||||
projects: ReadonlyArray<EnvironmentProject>,
|
||||
threads: ReadonlyArray<EnvironmentThreadShell>,
|
||||
@@ -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),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -20,12 +20,23 @@ import { scopedProjectKey } from "../../lib/scopedEntities";
|
||||
|
||||
export type HomeProjectSortOrder = Exclude<SidebarProjectSortOrder, "manual">;
|
||||
|
||||
/**
|
||||
* 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<EnvironmentProject>;
|
||||
/** Full sorted thread history for the group (revealed when expanded / searching). */
|
||||
readonly threads: ReadonlyArray<EnvironmentThreadShell>;
|
||||
/** Subset shown by default: threads from the last few days, or the most recent few. */
|
||||
readonly recentThreads: ReadonlyArray<EnvironmentThreadShell>;
|
||||
}
|
||||
|
||||
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<EnvironmentThreadShell>,
|
||||
threadSortOrder: SidebarThreadSortOrder,
|
||||
now: number,
|
||||
): ReadonlyArray<EnvironmentThreadShell> {
|
||||
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<EnvironmentProject>;
|
||||
readonly threads: ReadonlyArray<EnvironmentThreadShell>;
|
||||
@@ -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<HomeThreadGroup> {
|
||||
const now = input.now ?? Date.now();
|
||||
const groups = new Map<string, MutableHomeThreadGroup>();
|
||||
const groupKeyByProjectKey = new Map<string, string>();
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user