Skip to content
Closed
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 @@ -102,6 +102,7 @@ export function HomeRouteScreen() {
moveThread,
renameThread,
regenerateThreadTitle,
markThreadUnread,
unsettleThread,
} = useThreadListActions();
const pendingTasks = usePendingNewTasks();
Expand Down Expand Up @@ -211,6 +212,7 @@ export function HomeRouteScreen() {
onMoveThread={moveThread}
onRenameThread={renameThread}
onRegenerateThreadTitle={regenerateThreadTitle}
onMarkThreadUnread={markThreadUnread}
onEnvironmentChange={setSelectedEnvironmentId}
onProjectChange={setSelectedProjectKey}
onOpenSettings={() => selectTab("settings")}
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ interface HomeScreenProps {
) => Promise<boolean>;
readonly onRenameThread: (thread: EnvironmentThreadShell) => void;
readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
readonly onMarkThreadUnread: (thread: EnvironmentThreadShell) => Promise<boolean>;
readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
Expand Down Expand Up @@ -561,6 +562,7 @@ export function HomeScreen(props: HomeScreenProps) {
onArchiveThread={props.onArchiveThread}
onRenameThread={handleRenameThread}
onRegenerateThreadTitle={handleRegenerateThreadTitle}
onMarkThreadUnread={props.onMarkThreadUnread}
titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
onSettleThread={handleSettleThread}
Expand Down
30 changes: 30 additions & 0 deletions apps/mobile/src/features/home/useThreadListActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export function useThreadListActions(): {
) => Promise<boolean>;
readonly renameThread: (thread: EnvironmentThreadShell) => void;
readonly regenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
readonly markThreadUnread: (thread: EnvironmentThreadShell) => Promise<boolean>;
} {
const executeAction = useThreadActionExecutor();
const snoozeMutation = useAtomCommand(threadEnvironment.snooze, { reportFailure: false });
Expand All @@ -243,6 +244,9 @@ export function useThreadListActions(): {
const regenerateTitle = useAtomCommand(threadEnvironment.regenerateTitle, {
reportFailure: false,
});
const markUnreadMutation = useAtomCommand(threadEnvironment.markUnread, {
reportFailure: false,
});
const snoozeInFlightThreadKeys = useRef(new Set<string>());
const titleRegenerationInFlightThreadKeys = useRef(new Set<string>());

Expand Down Expand Up @@ -515,6 +519,31 @@ export function useThreadListActions(): {
}
return true;
};
const markThreadUnread = async (thread: EnvironmentThreadShell) => {
if (!environmentConfigLoaded(thread.environmentId)) {
Dialog.alert(
"Could not mark thread unread",
"This environment's server does not support read markers yet. Update the server to use Mark unread.",
);
return false;
}
selectionHaptic();
const result = await markUnreadMutation({
environmentId: thread.environmentId,
input: { threadId: thread.id },
});
if (result._tag === "Failure") {
const error = Cause.squash(result.cause);
Dialog.alert(
"Could not mark thread unread",
error instanceof Error && error.message.trim().length > 0
? error.message
: "The thread could not be marked unread.",
);
return false;
}
return true;
};
const regenerateThreadTitle = async (thread: EnvironmentThreadShell) => {
if (!checkThreadOperationPermission(thread, "Could not regenerate title")) return false;
const key = scopedThreadKey(thread.environmentId, thread.id);
Expand Down Expand Up @@ -753,6 +782,7 @@ export function useThreadListActions(): {
moveThread,
renameThread: (thread) => renameThread(liveThread(thread)),
regenerateThreadTitle: (thread) => regenerateThreadTitle(liveThread(thread)),
markThreadUnread: (thread) => markThreadUnread(liveThread(thread)),
};
}

Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
moveThread,
renameThread,
regenerateThreadTitle,
markThreadUnread,
} = useThreadListActions();
const pendingTasks = usePendingNewTasks();
const launchingThreads = useLaunchingThreads(threads);
Expand Down Expand Up @@ -458,6 +459,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
onArchiveThread={archiveThread}
onRenameThread={renameThread}
onRegenerateThreadTitle={regenerateThreadTitle}
onMarkThreadUnread={markThreadUnread}
titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
onSettleThread={settleThread}
Expand Down
9 changes: 9 additions & 0 deletions apps/mobile/src/features/threads/thread-list-v2-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
readonly onRenameThread: (thread: EnvironmentThreadShell) => void;
readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => void;
readonly onMarkThreadUnread: (thread: EnvironmentThreadShell) => void;
readonly onSettleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
readonly onSnoozeThread: (thread: EnvironmentThreadShell, snoozedUntil: string) => void;
readonly onUnsnoozeThread: (thread: EnvironmentThreadShell) => void;
Expand Down Expand Up @@ -718,6 +719,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
onDeleteThread,
onRenameThread,
onRegenerateThreadTitle,
onMarkThreadUnread,
onNewThreadOnBranch,
onSettleThread,
onSnoozeThread,
Expand Down Expand Up @@ -803,6 +805,10 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
() => onRegenerateThreadTitle(thread),
[onRegenerateThreadTitle, thread],
);
const handleMarkUnread = useCallback(
() => onMarkThreadUnread(thread),
[onMarkThreadUnread, thread],
);
const handleSettle = useCallback(() => onSettleThread(thread), [onSettleThread, thread]);
const [customSnoozeOpen, setCustomSnoozeOpen] = useState(false);
// Recycling changes identity without remounting; clear local UI directly because equality may skip the render closure.
Expand Down Expand Up @@ -926,6 +932,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
supported: props.titleRegenerationSupported,
isRegenerating: isRegeneratingTitle,
}),
{ id: "mark-unread", title: "Mark unread", image: "envelope.badge" },
...(canTurnIntoProject
? [
{
Expand Down Expand Up @@ -1039,6 +1046,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
if (nativeEvent.event === "archive") handleArchive();
if (nativeEvent.event === "rename") handleRename();
if (nativeEvent.event === "regenerate-title") handleRegenerateTitle();
if (nativeEvent.event === "mark-unread") handleMarkUnread();
if (nativeEvent.event === "turn-into-project") void turnThreadIntoProject(thread);
if (nativeEvent.event === "copy-thread") {
const target = threadChipCopyTarget(
Expand Down Expand Up @@ -1077,6 +1085,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
thread,
handleArchive,
handleDelete,
handleMarkUnread,
handleRegenerateTitle,
handleRename,
handleMoveDown,
Expand Down
Loading