Skip to content
Open
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
2 changes: 2 additions & 0 deletions apps/mobile/src/features/home/HomeRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function HomeRouteScreen() {
moveThread,
renameThread,
regenerateThreadTitle,
ungroupThreads,
unsettleThread,
} = useThreadListActions();
const pendingTasks = usePendingNewTasks();
Expand Down Expand Up @@ -243,6 +244,7 @@ export function HomeRouteScreen() {
onMoveThread={moveThread}
onRenameThread={renameThread}
onRegenerateThreadTitle={regenerateThreadTitle}
onUngroupThreads={ungroupThreads}
onEnvironmentChange={setSelectedEnvironmentId}
onProjectChange={setSelectedProjectKey}
onOpenSettings={() =>
Expand Down
10 changes: 10 additions & 0 deletions apps/mobile/src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ interface HomeScreenProps {
) => Promise<boolean>;
readonly onRenameThread: (thread: EnvironmentThreadShell) => void;
readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
readonly onUngroupThreads: (threads: readonly EnvironmentThreadShell[]) => Promise<boolean>;
readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
Expand Down Expand Up @@ -464,6 +465,12 @@ export function HomeScreen(props: HomeScreenProps) {
},
[props.onRegenerateThreadTitle],
);
const handleUngroupThreads = useCallback(
(threads: readonly EnvironmentThreadShell[]) => {
void props.onUngroupThreads(threads);
},
[props.onUngroupThreads],
);
const handleRenameThread = useCallback(
(thread: EnvironmentThreadShell) => props.onRenameThread(thread),
[props.onRenameThread],
Expand Down Expand Up @@ -746,6 +753,8 @@ export function HomeScreen(props: HomeScreenProps) {
hasQueuedMessages={item.hasQueuedMessages}
snoozed={item.item.snoozed}
pinned={item.item.pinned}
group={item.item.group}
onUngroupThreads={handleUngroupThreads}
snoozePresetMinute={item.snoozePresetMinute ?? ""}
snoozeWakeLabelText={item.snoozeWakeLabelText}
timeLabel={item.timeLabel}
Expand Down Expand Up @@ -808,6 +817,7 @@ export function HomeScreen(props: HomeScreenProps) {
handleMoveThread,
handlePinThread,
handleRegenerateThreadTitle,
handleUngroupThreads,
handleRenameThread,
handleSettleThread,
handleSnoozeThread,
Expand Down
27 changes: 27 additions & 0 deletions apps/mobile/src/features/home/useThreadListActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ export function useThreadListActions(): {
) => Promise<boolean>;
readonly renameThread: (thread: EnvironmentThreadShell) => void;
readonly regenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
/** Takes each thread out of its group. */
readonly ungroupThreads: (threads: readonly EnvironmentThreadShell[]) => Promise<boolean>;
} {
const executeAction = useThreadActionExecutor();
const snoozeMutation = useAtomCommand(threadEnvironment.snooze, { reportFailure: false });
Expand Down Expand Up @@ -533,6 +535,30 @@ export function useThreadListActions(): {
},
[updateThreadMetadata],
);
const ungroupThreads = useCallback(
async (threads: readonly EnvironmentThreadShell[]) => {
selectionHaptic();
const results = await Promise.all(
threads.map((thread) =>
updateThreadMetadata({
environmentId: thread.environmentId,
input: { threadId: thread.id, groupedUnderThreadId: null },
}),
),
);
const failure = results.find((result) => result._tag === "Failure");
if (failure === undefined) return true;
const error = Cause.squash(failure.cause);
Alert.alert(
"Could not ungroup",
error instanceof Error && error.message.trim().length > 0
? error.message
: "The threads could not be taken out of their group.",
);
return false;
},
[updateThreadMetadata],
);
const renameThread = useCallback(
(thread: EnvironmentThreadShell) => {
const commit = (title: string) => {
Expand Down Expand Up @@ -766,6 +792,7 @@ export function useThreadListActions(): {
moveThread,
renameThread,
regenerateThreadTitle,
ungroupThreads,
};
}

Expand Down
15 changes: 13 additions & 2 deletions apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import {
threadDragAction,
type ThreadMoveDestination,
} from "./threadOrder";
import { getThreadListV2OrderedSection, threadListInboxReturns } from "./threadListV2";
import {
getThreadListV2LiveGroupThreads,
getThreadListV2OrderedSection,
threadListInboxReturns,
} from "./threadListV2";
import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences";

const ROW_HEIGHT = 56;
Expand Down Expand Up @@ -193,8 +197,15 @@ export function ThreadArrangementSheet(props: { onClose: () => void }) {
const pinned = getThreadListV2OrderedSection({ ...shared, section: "pinned" });
const active = getThreadListV2OrderedSection({ ...shared, section: "active" });
const visible = new Set([...pinned, ...active].map(keyOf));
// Threads in a live group move with it, so only snoozed and settled
// threads outside such groups fill the parked lists.
const liveGrouped = getThreadListV2LiveGroupThreads(shared);
const parked = threads.filter(
(thread) => thread.archivedAt === null && !visible.has(keyOf(thread)),
(thread) =>
thread.archivedAt === null &&
!visible.has(keyOf(thread)) &&
!liveGrouped.has(thread) &&
(thread.settledOverride === "settled" || effectiveSnoozed(thread, { now })),
);
return {
pinned,
Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function ThreadNavigationSidebarPane(
moveThread,
renameThread,
regenerateThreadTitle,
ungroupThreads,
} = useThreadListActions();
const pendingTasks = usePendingNewTasks();
const queuedThreadKeys = useQueuedThreadKeys();
Expand Down Expand Up @@ -696,6 +697,8 @@ function ThreadNavigationSidebarPane(
hasQueuedMessages={item.hasQueuedMessages}
snoozed={item.item.snoozed}
pinned={item.item.pinned}
group={item.item.group}
onUngroupThreads={ungroupThreads}
snoozePresetMinute={item.snoozePresetMinute ?? ""}
snoozeWakeLabelText={item.snoozeWakeLabelText}
timeLabel={item.timeLabel}
Expand Down Expand Up @@ -812,6 +815,7 @@ function ThreadNavigationSidebarPane(
projectByKey,
projectTitleByProjectKey,
regenerateThreadTitle,
ungroupThreads,
renameThread,
props.onNewThreadOnBranch,
props.searchQuery,
Expand Down
Loading
Loading