Address macroscope review findings
- selectEnvironment: fall back to workspace basename, then title, when the selected project has no repositoryIdentity, so computer switching still follows the same repo instead of resetting to the target's first project. - ThreadListGroupHeader: lift the new-thread button out of the collapse toggle Pressable — nested touchables are invisible to VoiceOver/TalkBack. - homeListItems: compare canShowLess against the group's recency baseline instead of the global page size, so stale groups can collapse back. - HomeScreen: only offer the quick new-thread button on single-project groups; an aggregated group's representative is arbitrary. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
f726113e14
commit
3edb72e016
5 files changed
+110
-41
No files matched your search
@@ -249,7 +249,11 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
isFirst={item.isFirst}
|
||||
groupKey={item.group.key}
|
||||
onGroupAction={updateGroupDisplay}
|
||||
onNewThread={props.onNewThreadInProject}
|
||||
// Aggregated groups (same repo across machines) have no single
|
||||
// target project, so the quick new-thread button is single-project only.
|
||||
onNewThread={
|
||||
item.group.projects.length === 1 ? props.onNewThreadInProject : undefined
|
||||
}
|
||||
project={item.group.representative}
|
||||
threadCount={item.group.threads.length + item.group.pendingTasks.length}
|
||||
title={item.group.title}
|
||||
|
||||
@@ -157,6 +157,47 @@ describe("buildHomeListLayout", () => {
|
||||
expect(reset.visibleCount).toBe(HOME_INITIAL_VISIBLE_THREADS);
|
||||
});
|
||||
|
||||
it("offers show-less after expanding a stale group whose baseline is below the page size", () => {
|
||||
// Stale project: 10 threads total but only 3 within the recency window.
|
||||
const project = makeProject("stale", "stale");
|
||||
const threads = Array.from({ length: 10 }, (_, index) =>
|
||||
makeThread(`stale-thread-${index}`, project.id),
|
||||
);
|
||||
const group: HomeThreadGroup = {
|
||||
key: "stale",
|
||||
title: "stale",
|
||||
representative: project,
|
||||
projects: [project],
|
||||
pendingTasks: [],
|
||||
threads,
|
||||
recentThreads: threads.slice(0, 3),
|
||||
};
|
||||
|
||||
const collapsedToRecent = buildHomeListLayout({
|
||||
groups: [group],
|
||||
displayStates: displayStates({}),
|
||||
});
|
||||
expect(collapsedToRecent.items.filter((item) => item.type === "thread")).toHaveLength(3);
|
||||
expect(collapsedToRecent.items.at(-1)).toMatchObject({
|
||||
type: "show-more",
|
||||
hiddenCount: 7,
|
||||
canShowLess: false,
|
||||
});
|
||||
|
||||
const expanded = buildHomeListLayout({
|
||||
groups: [group],
|
||||
displayStates: displayStates({
|
||||
stale: nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "show-more"),
|
||||
}),
|
||||
});
|
||||
expect(expanded.items.filter((item) => item.type === "thread")).toHaveLength(10);
|
||||
expect(expanded.items.at(-1)).toMatchObject({
|
||||
type: "show-more",
|
||||
hiddenCount: 0,
|
||||
canShowLess: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("hides threads and the show-more row for collapsed groups", () => {
|
||||
const layout = buildHomeListLayout({
|
||||
groups: [makeGroup("alpha", 12), makeGroup("beta", 2)],
|
||||
|
||||
@@ -195,7 +195,10 @@ export function buildHomeListLayout(input: {
|
||||
key: `show-more:${group.key}`,
|
||||
groupKey: group.key,
|
||||
hiddenCount,
|
||||
canShowLess: visibleCount > HOME_INITIAL_VISIBLE_THREADS,
|
||||
// Compare against the group's own baseline, not the global page size:
|
||||
// stale projects start below HOME_INITIAL_VISIBLE_THREADS, and "Show
|
||||
// less" must be offered as soon as anything beyond the baseline shows.
|
||||
canShowLess: visibleCount > baselineCount,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,19 +482,33 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
|
||||
const selectEnvironment = useCallback(
|
||||
(environmentId: EnvironmentId) => {
|
||||
const projectsOnTarget = projects.filter(
|
||||
(project) => project.environmentId === environmentId,
|
||||
);
|
||||
const repositoryKey = selectedProject?.repositoryIdentity?.canonicalKey ?? null;
|
||||
// Prefer the repository identity; projects without one (e.g. not yet
|
||||
// indexed) fall back to workspace basename, then title, so switching
|
||||
// computers still follows the same repo instead of resetting to
|
||||
// whatever project is first on the target machine.
|
||||
const workspaceBasename = selectedProject?.workspaceRoot.split("/").at(-1) ?? null;
|
||||
const match =
|
||||
repositoryKey === null
|
||||
? undefined
|
||||
: projects.find(
|
||||
(project) =>
|
||||
project.environmentId === environmentId &&
|
||||
(project.repositoryIdentity?.canonicalKey ?? null) === repositoryKey,
|
||||
);
|
||||
(repositoryKey !== null
|
||||
? projectsOnTarget.find(
|
||||
(project) => (project.repositoryIdentity?.canonicalKey ?? null) === repositoryKey,
|
||||
)
|
||||
: undefined) ??
|
||||
(workspaceBasename !== null
|
||||
? projectsOnTarget.find(
|
||||
(project) => project.workspaceRoot.split("/").at(-1) === workspaceBasename,
|
||||
)
|
||||
: undefined) ??
|
||||
(selectedProject !== null
|
||||
? projectsOnTarget.find((project) => project.title === selectedProject.title)
|
||||
: undefined);
|
||||
setSelectedEnvironmentId(environmentId);
|
||||
setSelectedProjectKey(match ? scopedProjectKey(match.environmentId, match.id) : null);
|
||||
},
|
||||
[projects, selectedProject?.repositoryIdentity?.canonicalKey],
|
||||
[projects, selectedProject],
|
||||
);
|
||||
|
||||
const setWorkspaceMode = useCallback(
|
||||
|
||||
@@ -55,22 +55,27 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
|
||||
);
|
||||
const handleNewThread = useCallback(() => onNewThread?.(project), [onNewThread, project]);
|
||||
|
||||
// The new-thread button is a SIBLING of the collapse toggle, not a child:
|
||||
// nested touchables are unreachable to VoiceOver/TalkBack (the parent
|
||||
// swallows focus), so the row is a plain View with two adjacent pressables.
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded: !props.collapsed }}
|
||||
accessibilityLabel={`${props.title}, ${props.threadCount} threads`}
|
||||
accessibilityHint={props.collapsed ? "Expands the project" : "Collapses the project"}
|
||||
className={compact ? "bg-screen" : undefined}
|
||||
onPress={handleToggle}
|
||||
<View
|
||||
className={
|
||||
compact
|
||||
? `flex-row items-center gap-2.5 bg-screen px-5 pb-3 ${props.isFirst ? "pt-2" : "pt-6"}`
|
||||
: `flex-row items-center gap-2 px-3 pb-2 ${props.isFirst ? "pt-1" : "pt-5"}`
|
||||
}
|
||||
style={{ minHeight: compact ? 44 : 36 }}
|
||||
>
|
||||
<View
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded: !props.collapsed }}
|
||||
accessibilityLabel={`${props.title}, ${props.threadCount} threads`}
|
||||
accessibilityHint={props.collapsed ? "Expands the project" : "Collapses the project"}
|
||||
className={
|
||||
compact
|
||||
? `flex-row items-center gap-2.5 px-5 pb-3 ${props.isFirst ? "pt-2" : "pt-6"}`
|
||||
: `flex-row items-center gap-2 px-3 pb-2 ${props.isFirst ? "pt-1" : "pt-5"}`
|
||||
compact ? "flex-1 flex-row items-center gap-2.5" : "flex-1 flex-row items-center gap-2"
|
||||
}
|
||||
style={{ minHeight: compact ? 44 : 36 }}
|
||||
onPress={handleToggle}
|
||||
>
|
||||
<ProjectFavicon
|
||||
environmentId={props.project.environmentId}
|
||||
@@ -98,23 +103,25 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
|
||||
>
|
||||
{props.threadCount}
|
||||
</Text>
|
||||
{onNewThread ? (
|
||||
<Pressable
|
||||
accessibilityLabel={`Create new thread in ${props.title}`}
|
||||
accessibilityRole="button"
|
||||
hitSlop={8}
|
||||
onPress={handleNewThread}
|
||||
style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1, marginRight: compact ? 10 : 8 })}
|
||||
>
|
||||
<SymbolView
|
||||
name="square.and.pencil"
|
||||
size={compact ? 16 : 14}
|
||||
tintColor={iconMutedColor}
|
||||
type="monochrome"
|
||||
weight="medium"
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
</Pressable>
|
||||
{onNewThread ? (
|
||||
<Pressable
|
||||
accessibilityLabel={`Create new thread in ${props.title}`}
|
||||
accessibilityRole="button"
|
||||
hitSlop={8}
|
||||
onPress={handleNewThread}
|
||||
style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1, marginRight: compact ? 10 : 8 })}
|
||||
>
|
||||
<SymbolView
|
||||
name="square.and.pencil"
|
||||
size={compact ? 16 : 14}
|
||||
tintColor={iconMutedColor}
|
||||
type="monochrome"
|
||||
weight="medium"
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<Pressable accessible={false} hitSlop={8} onPress={handleToggle}>
|
||||
<SymbolView
|
||||
name={props.collapsed ? "chevron.right" : "chevron.down"}
|
||||
size={compact ? 13 : 11}
|
||||
@@ -122,8 +129,8 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
|
||||
type="monochrome"
|
||||
weight="semibold"
|
||||
/>
|
||||
</View>
|
||||
</Pressable>
|
||||
</Pressable>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user