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
4 changes: 3 additions & 1 deletion apps/mobile/src/features/home/ThreadUndoNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function ThreadUndoNotice(props: { readonly visible: boolean }) {
? gt("Settled thread")
: notice.action === "Snoozed"
? gt("Snoozed thread")
: gt("Unpinned thread")
: notice.action === "Rescheduled"
? gt("Rescheduled thread")
: gt("Unpinned thread")
}
action={{
label: gt("Undo"),
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/features/home/thread-undo-notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as ThreadUndo from "@t3tools/client-runtime/state/thread-undo";
import { useSyncExternalStore } from "react";

type UndoNotice = {
readonly action: "Settled" | "Snoozed" | "Unpinned";
readonly action: "Settled" | "Snoozed" | "Rescheduled" | "Unpinned";
readonly claim: ReturnType<typeof ThreadUndo.begin>;
readonly undo: () => Promise<void>;
};
Expand Down
15 changes: 15 additions & 0 deletions apps/mobile/src/features/home/useThreadListActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,21 @@ describe("thread action undo", () => {
});
});

it("restores the previous wake time when undoing a reschedule", async () => {
const thread = makeThread({
snoozedAt: "2026-09-02T00:00:00.000Z",
snoozedUntil: "2099-01-01T09:00:00.000Z",
});
await useThreadListActions().snoozeThread(thread, "2099-01-02T09:00:00.000Z");
expect(readThreadUndoNotice()?.action).toBe("Rescheduled");
await readThreadUndoNotice()!.undo();
expect(state.requests.map(({ action }) => action)).toEqual(["snooze", "snooze"]);
expect(state.requests[1]?.input).toEqual({
threadId: thread.id,
snoozedUntil: "2099-01-01T09:00:00.000Z",
});
});

it.each([null, "2099-01-01T09:00:00.000Z", "2000-01-01T09:00:00.000Z"])(
"restores an unpinned thread's previous position and unexpired snooze (%s)",
async (snoozedUntil) => {
Expand Down
49 changes: 29 additions & 20 deletions apps/mobile/src/features/home/useThreadListActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ThreadMoveDestination } from "../threads/threadOrder";
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
import * as ThreadUndo from "@t3tools/client-runtime/state/thread-undo";
import { showThreadUndoNotice } from "./thread-undo-notice";
import { canSnooze } from "@t3tools/client-runtime/state/thread-settled";
import { canSnooze, effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";
import { AuthOrchestrationOperateScope } from "@t3tools/contracts";
import * as Cause from "effect/Cause";
import * as Haptics from "expo-haptics";
Expand Down Expand Up @@ -267,7 +267,7 @@ export function useThreadListActions(): {
const archiveThread = (thread: EnvironmentThreadShell) => executeAction("archive", thread);
const offerUndo = (
thread: EnvironmentThreadShell,
action: "Settled" | "Snoozed" | "Unpinned",
action: "Settled" | "Snoozed" | "Rescheduled" | "Unpinned",
claim: ReturnType<typeof ThreadUndo.begin>,
plan: ThreadUndo.ThreadUndoPlan,
) =>
Expand Down Expand Up @@ -295,10 +295,12 @@ export function useThreadListActions(): {
return true;
}
case "snooze": {
const failureTitle =
action === "Unpinned"
? m(msg("Could not undo unpin"))
: m(msg("Could not undo settle"));
const failureTitle = {
Settled: m(msg("Could not undo settle")),
Snoozed: m(msg("Could not undo snooze")),
Rescheduled: m(msg("Could not undo reschedule")),
Unpinned: m(msg("Could not undo unpin")),
}[action];
if (!checkThreadOperationPermission(thread, failureTitle)) return false;
const result = await snoozeMutation({
environmentId: thread.environmentId,
Expand Down Expand Up @@ -380,30 +382,37 @@ export function useThreadListActions(): {

selectionHaptic();
const claim = ThreadUndo.begin("snooze", key);
const result = await withThreadDismissal(
key,
() =>
snoozeMutation({
environmentId: thread.environmentId,
input: {
threadId: thread.id,
snoozedUntil,
},
}),
(result) => result._tag === "Success",
);
const snooze = () =>
snoozeMutation({
environmentId: thread.environmentId,
input: {
threadId: thread.id,
snoozedUntil,
},
});
// A reschedule keeps the row on the snoozed shelf, so it must not
// play the exit animation that a fresh snooze uses.
const rescheduling = effectiveSnoozed(thread, { now: new Date().toISOString() });
const result = rescheduling
? await snooze()
: await withThreadDismissal(key, snooze, (result) => result._tag === "Success");
if (result._tag === "Failure") {
claim.finish();
const error = Cause.squash(result.cause);
Dialog.alert(
m(msg("Could not snooze thread")),
rescheduling ? m(msg("Could not reschedule thread")) : m(msg("Could not snooze thread")),
error instanceof Error && errorDisplayMessage(error, m) !== null
? (errorDisplayMessage(error, m) ?? error.message)
: m(msg("The thread could not be snoozed.")),
);
return false;
}
offerUndo(thread, "Snoozed", claim, ThreadUndo.planThreadUndo("snooze"));
offerUndo(
thread,
rescheduling ? "Rescheduled" : "Snoozed",
claim,
ThreadUndo.planThreadUndo("snooze", rescheduling ? thread : null),
);
return true;
})();
snoozeInFlightThreadKeys.current.delete(key);
Expand Down
16 changes: 13 additions & 3 deletions apps/mobile/src/features/threads/thread-list-v2-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const SLIM_MENU_ACTIONS: MenuAction[] = [
];

const SNOOZED_MENU_ACTIONS: MenuAction[] = [
{ id: "unsnooze", title: msg("Wake thread"), image: "clock" },
{ id: "unsnooze", title: msg("Wake thread"), image: "bell.badge" },
{
id: "delete",
title: msg("Delete", { $context: "verb, thread action" }),
Expand Down Expand Up @@ -982,6 +982,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
const snoozePresets = resolveThreadListV2SnoozePresets(
{
secondary: swipeActions.secondary,
snoozed: snoozedRow,
now: props.snoozePresetMinute || snoozeGateNow,
presets: props.snoozePresets,
},
Expand Down Expand Up @@ -1118,7 +1119,16 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
return layoutThreadListV2RowMenuActions(
{
nested,
direct: [...direct, localized(SNOOZED_MENU_ACTIONS[0]!)],
direct: [
...direct,
localized(SNOOZED_MENU_ACTIONS[0]!),
{
id: "snooze",
title: gt("Reschedule"),
image: "clock",
subactions: snoozePresetActions,
},
],
reorder: [],
pin: [],
secondary: [
Expand Down Expand Up @@ -1307,7 +1317,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
if (swipeActions.primary === "unsnooze") {
return {
accessibilityLabel: gt("Wake {title} now", { title: thread.title }),
icon: "clock" as const,
icon: "bell.badge" as const,
label: gt("Wake", { $context: "verb, thread action" }),
swipeHint: gt("Opens the thread. Swipe left to wake."),
swipeSnoozeHint: gt("Opens the thread. Swipe left for wake and snooze actions."),
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/src/features/threads/threadListV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe("resolveThreadListV2SnoozePresets", () => {

const presets = resolveThreadListV2SnoozePresets({
secondary: "snooze",
snoozed: false,
now: laterMinute,
presets: undefined,
});
Expand Down Expand Up @@ -1467,6 +1468,8 @@ describe("threadListV2ListItemsAreEqual", () => {
};
expect(rows(earlier).snoozeWakeLabelText).toBe("2h");
expect(rows(later).snoozeWakeLabelText).toBe("1h");
// Snoozed rows show the snooze presets under Reschedule, so they keep the minute clock.
expect(rows(later).snoozePresetMinute).toBe(isoAt(BASE_MS + MINUTE_MS));
expect(threadListV2ListItemsAreEqual(rows(earlier), rows(later))).toBe(false);
});

Expand Down
7 changes: 4 additions & 3 deletions apps/mobile/src/features/threads/threadListV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ export type ThreadListV2SwipeAction = "archive" | "settle" | "unsettle" | "snooz
export function resolveThreadListV2SnoozePresets(
input: {
readonly secondary: "snooze" | null;
readonly snoozed: boolean;
readonly now: string;
readonly presets: ReadonlyArray<SnoozePresetSetting> | undefined;
},
resolve: MessageResolver = m,
): ReadonlyArray<SnoozePreset> {
return input.secondary === "snooze"
return input.secondary === "snooze" || input.snoozed
? resolveSnoozePresets(new Date(input.now), presetOptions(input.presets), resolve)
: [];
}
Expand Down Expand Up @@ -605,11 +606,11 @@ export function buildThreadListV2ListItems(input: {
? snoozeWakeLabel(item.thread.snoozedUntil, { now: input.snoozeLabelNow }, resolve)
: undefined;
// Put the clock on items so recycler equality limits ticks to rows displaying snooze preset times.
// Snoozed rows show the same presets under Reschedule.
const snoozePresetMinute =
!item.snoozed &&
input.snoozeLabelNow !== undefined &&
(input.snoozeEnvironmentIds?.has(item.thread.environmentId) ?? true) &&
canSnooze(item.thread, { now: input.snoozeLabelNow })
(item.snoozed || canSnooze(item.thread, { now: input.snoozeLabelNow }))
? input.snoozeLabelNow
: undefined;
const move =
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,7 @@
"32a8bfef83ff2d97": "Thread-Filter zurücksetzen",
"c395d6d5b8e3b1c3": "Erledigter Thread",
"364216d868acbcb8": "Zurückgestellter Thread",
"9b5a1047f965ac6f": "Thread neu geplant",
"96c28451c4aae602": "Losgelöster Thread",
"33b29a0f59128a96": "Rückgängig",
"0fb95f74fce8584e": "Öffnet die Umgebungseinstellungen",
Expand Down Expand Up @@ -2313,15 +2314,18 @@
"3e36eba09bae8803": "Thread löschen?",
"f648c00c1c86f594": "„{title}“ wird endgültig gelöscht, einschließlich seines Terminal-Verlaufs.",
"7089864a172bd9e3": "Löschen",
"4ef62b5dbba907d2": "Loslösen konnte nicht rückgängig gemacht werden",
"f8b89d159e44c512": "Erledigen konnte nicht rückgängig gemacht werden",
"1ec80b5eb4cdbae5": "Zurückstellen konnte nicht rückgängig gemacht werden",
"3defb1664921b0a5": "Neuplanung konnte nicht rückgängig gemacht werden",
"4ef62b5dbba907d2": "Loslösen konnte nicht rückgängig gemacht werden",
"807dd1b1a6ebd721": "Zurückstellen konnte nicht wiederhergestellt werden",
"fe3a91464aed32c8": "Der Thread konnte nicht zurückgestellt werden.",
"142a179fc1d6bf3b": "Thread-Aktion konnte nicht rückgängig gemacht werden",
"6fc712c4f5a55ee2": "Thread konnte nicht zurückgestellt werden",
"876b987471f908d4": "Der Server dieser Umgebung unterstützt das Zurückstellen noch nicht. Aktualisiere den Server, um „Zurückstellen“ zu nutzen.",
"d308bfc93992408b": "Dieser Thread wartet auf dich. Beantworte die ausstehende Anfrage, bevor du ihn zurückstellst.",
"af6f4b448ec34fbd": "Dieser Thread startet noch eine Runde. Versuch es erneut, sobald er läuft.",
"5ad183fe6af8884e": "Thread konnte nicht neu geplant werden",
"e9682864e49df67a": "Thread konnte nicht aufgeweckt werden",
"ac30839c3687c496": "Der Server dieser Umgebung unterstützt das Zurückstellen noch nicht. Aktualisiere den Server, um diesen Thread aufzuwecken.",
"f1bcc9682d9f46e7": "Der Thread konnte nicht aufgeweckt werden.",
Expand Down Expand Up @@ -4781,6 +4785,7 @@
"1385e2d8bd696370": "In Projekt umwandeln",
"a1fcc064a5cece14": "Thread kopieren",
"7b24be8e29a2efc5": "Thread-ID kopieren",
"0f6758106a241c35": "Neu planen",
"4205928193aec525": "Zurückstellen",
"618aa0a6bf093a70": "Versuch erneut, diesen Thread zu kopieren.",
"b2332fb96c0a55fb": "Dieser Zeitpunkt ist bereits vorbei. Wähle einen anderen.",
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,7 @@
"32a8bfef83ff2d97": "Reset thread filters",
"c395d6d5b8e3b1c3": "Settled thread",
"364216d868acbcb8": "Snoozed thread",
"9b5a1047f965ac6f": "Rescheduled thread",
"96c28451c4aae602": "Unpinned thread",
"33b29a0f59128a96": "Undo",
"0fb95f74fce8584e": "Opens environment settings",
Expand Down Expand Up @@ -2313,15 +2314,18 @@
"3e36eba09bae8803": "Delete thread?",
"f648c00c1c86f594": "“{title}” will be permanently deleted, including its terminal history.",
"7089864a172bd9e3": "Delete",
"4ef62b5dbba907d2": "Could not undo unpin",
"f8b89d159e44c512": "Could not undo settle",
"1ec80b5eb4cdbae5": "Could not undo snooze",
"3defb1664921b0a5": "Could not undo reschedule",
"4ef62b5dbba907d2": "Could not undo unpin",
"807dd1b1a6ebd721": "Could not restore snooze",
"fe3a91464aed32c8": "The thread could not be snoozed.",
"142a179fc1d6bf3b": "Could not undo thread action",
"6fc712c4f5a55ee2": "Could not snooze thread",
"876b987471f908d4": "This environment's server does not support snoozing yet. Update the server to use Snooze.",
"d308bfc93992408b": "This thread is waiting on you. Respond to the pending request before snoozing it.",
"af6f4b448ec34fbd": "This thread is still starting a turn. Try again once it's running.",
"5ad183fe6af8884e": "Could not reschedule thread",
"e9682864e49df67a": "Could not wake thread",
"ac30839c3687c496": "This environment's server does not support snoozing yet. Update the server to wake this thread.",
"f1bcc9682d9f46e7": "The thread could not be woken.",
Expand Down Expand Up @@ -4782,6 +4786,7 @@
"1385e2d8bd696370": "Turn into project",
"a1fcc064a5cece14": "Copy thread",
"7b24be8e29a2efc5": "Copy thread ID",
"0f6758106a241c35": "Reschedule",
"4205928193aec525": "Snooze",
"618aa0a6bf093a70": "Try copying this thread again.",
"b2332fb96c0a55fb": "That snooze time has passed. Choose another time.",
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,7 @@
"32a8bfef83ff2d97": "Restablecer filtros de hilos",
"c395d6d5b8e3b1c3": "Hilo resuelto",
"364216d868acbcb8": "Hilo pospuesto",
"9b5a1047f965ac6f": "Hilo reprogramado",
"96c28451c4aae602": "Hilo desfijado",
"33b29a0f59128a96": "Deshacer",
"0fb95f74fce8584e": "Abre los ajustes del entorno",
Expand Down Expand Up @@ -2313,15 +2314,18 @@
"3e36eba09bae8803": "¿Eliminar el hilo?",
"f648c00c1c86f594": "«{title}» se eliminará de forma permanente, incluido su historial de terminal.",
"7089864a172bd9e3": "Eliminar",
"4ef62b5dbba907d2": "No se pudo deshacer el desfijado",
"f8b89d159e44c512": "No se pudo deshacer la resolución",
"1ec80b5eb4cdbae5": "No se pudo deshacer la posposición",
"3defb1664921b0a5": "No se pudo deshacer la reprogramación",
"4ef62b5dbba907d2": "No se pudo deshacer el desfijado",
"807dd1b1a6ebd721": "No se pudo restaurar el pospuesto",
"fe3a91464aed32c8": "No se pudo posponer el hilo.",
"142a179fc1d6bf3b": "No se pudo deshacer la acción del hilo",
"6fc712c4f5a55ee2": "No se pudo posponer el hilo",
"876b987471f908d4": "El servidor de este entorno aún no permite posponer hilos. Actualiza el servidor para usar Posponer.",
"d308bfc93992408b": "Este hilo está esperando tu respuesta. Responde a la solicitud pendiente antes de posponerlo.",
"af6f4b448ec34fbd": "Este hilo aún está iniciando un turno. Vuelve a intentarlo cuando esté en ejecución.",
"5ad183fe6af8884e": "No se pudo reprogramar el hilo",
"e9682864e49df67a": "No se pudo reactivar el hilo",
"ac30839c3687c496": "El servidor de este entorno aún no admite posponer. Actualiza el servidor para reactivar este hilo.",
"f1bcc9682d9f46e7": "No se pudo reactivar el hilo.",
Expand Down Expand Up @@ -4774,6 +4778,7 @@
"1385e2d8bd696370": "Convertir en proyecto",
"a1fcc064a5cece14": "Copiar hilo",
"7b24be8e29a2efc5": "Copiar ID del hilo",
"0f6758106a241c35": "Reprogramar",
"4205928193aec525": "Posponer",
"618aa0a6bf093a70": "Prueba a copiar este hilo de nuevo.",
"b2332fb96c0a55fb": "Esa hora para posponer ya pasó. Elige otra.",
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,7 @@
"32a8bfef83ff2d97": "Réinitialiser les filtres de fils",
"c395d6d5b8e3b1c3": "Fil clos",
"364216d868acbcb8": "Fil reporté",
"9b5a1047f965ac6f": "Fil replanifié",
"96c28451c4aae602": "Fil désépinglé",
"33b29a0f59128a96": "Annuler",
"0fb95f74fce8584e": "Ouvre les paramètres de l’environnement",
Expand Down Expand Up @@ -2313,15 +2314,18 @@
"3e36eba09bae8803": "Supprimer le fil ?",
"f648c00c1c86f594": "« {title} » sera définitivement supprimé, y compris l’historique de son terminal.",
"7089864a172bd9e3": "Supprimer",
"4ef62b5dbba907d2": "Impossible d’annuler le désépinglage",
"f8b89d159e44c512": "Impossible d’annuler la clôture",
"1ec80b5eb4cdbae5": "Impossible d’annuler la mise en veille",
"3defb1664921b0a5": "Impossible d’annuler la replanification",
"4ef62b5dbba907d2": "Impossible d’annuler le désépinglage",
"807dd1b1a6ebd721": "Impossible de rétablir le report",
"fe3a91464aed32c8": "Le fil n’a pas pu être reporté.",
"142a179fc1d6bf3b": "Impossible d’annuler l’action sur le fil",
"6fc712c4f5a55ee2": "Impossible de reporter le fil",
"876b987471f908d4": "Le serveur de cet environnement ne permet pas encore de reporter les fils. Mettez à jour le serveur pour utiliser Reporter.",
"d308bfc93992408b": "Ce fil attend votre réponse. Répondez à la demande en attente avant de le reporter.",
"af6f4b448ec34fbd": "Ce fil est encore en train de démarrer un tour. Réessayez une fois qu’il est en cours.",
"5ad183fe6af8884e": "Impossible de replanifier le fil",
"e9682864e49df67a": "Impossible de réveiller le fil",
"ac30839c3687c496": "Le serveur de cet environnement ne prend pas encore en charge le report. Mettez à jour le serveur pour réveiller ce fil.",
"f1bcc9682d9f46e7": "Le fil n’a pas pu être réveillé.",
Expand Down Expand Up @@ -4775,6 +4779,7 @@
"1385e2d8bd696370": "Transformer en projet",
"a1fcc064a5cece14": "Copier le fil",
"7b24be8e29a2efc5": "Copier l’ID du fil",
"0f6758106a241c35": "Replanifier",
"4205928193aec525": "Reporter",
"618aa0a6bf093a70": "Essayez de copier à nouveau ce fil.",
"b2332fb96c0a55fb": "Cette heure de report est passée. Choisissez-en une autre.",
Expand Down
Loading
Loading