From 632d61daedbedd475615b30b6214e9d084e13af6 Mon Sep 17 00:00:00 2001 From: Cuju Ju Date: Sun, 15 Nov 2026 16:38:10 -0800 Subject: [PATCH 1/4] fix(mobile): mark read threads unread from the context menu Reuse eligibility checks from #17914, Android icon and failure handling from #35592, and shared menu placement from #36061. Co-authored-by: Tobi <155588579+spiky02plateau@users.noreply.github.com> Co-authored-by: mkollar-dev Co-authored-by: RVZO6 <66844656+RVZO6@users.noreply.github.com> --- .../src/components/ui/AppSymbol.android.tsx | 2 + .../features/threads/thread-list-v2-items.tsx | 39 ++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/apps/mobile/src/components/ui/AppSymbol.android.tsx b/apps/mobile/src/components/ui/AppSymbol.android.tsx index 4a5a16298b956..e1e7374c4964f 100644 --- a/apps/mobile/src/components/ui/AppSymbol.android.tsx +++ b/apps/mobile/src/components/ui/AppSymbol.android.tsx @@ -88,6 +88,7 @@ import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing"; import IconMicrophone from "@tabler/icons-react-native/IconMicrophone"; import IconLink from "@tabler/icons-react-native/IconLink"; import IconListNumbers from "@tabler/icons-react-native/IconListNumbers"; +import IconMail from "@tabler/icons-react-native/IconMail"; import IconMenu2 from "@tabler/icons-react-native/IconMenu2"; import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion"; import IconMessage from "@tabler/icons-react-native/IconMessage"; @@ -207,6 +208,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = { "doc.text": IconFileText, "file.diff": IconFileDiff, ellipsis: IconDots, + "envelope.badge": IconMail, moon: IconMoon, "ellipsis.circle": IconDotsCircleHorizontal, "envelope.badge": IconMail, diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index aa12551f9ce1f..711111852ed49 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -800,6 +800,24 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false }); const markThreadUnread = useAtomCommand(threadEnvironment.markUnread, { reportFailure: false }); + const canMarkUnread = + status === "ready" && + thread.lastVisitedAt !== undefined && + thread.latestRun?.completedAt != null && + !threadHasUnseenCompletion(thread); + const handleMarkUnread = useCallback(async () => { + if (!canMarkUnread) return; + const result = await markThreadUnread({ + environmentId: thread.environmentId, + input: { threadId: thread.id }, + }); + if (result._tag === "Failure") { + Dialog.alert( + "Could not mark thread unread", + "The thread could not be marked unread. Try again.", + ); + } + }, [canMarkUnread, markThreadUnread, thread.environmentId, thread.id]); const handleAcknowledgeWoke = useCallback(() => { if (props.wokeAt === null) return; void visitThread({ @@ -946,7 +964,9 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { supported: props.titleRegenerationSupported, isRegenerating: isRegeneratingTitle, }), - { id: "mark-unread", title: "Mark unread", image: "envelope.badge" }, + ...(canMarkUnread + ? [{ id: "mark-unread", title: "Mark unread", image: "envelope.badge" }] + : []), ...(canTurnIntoProject ? [ { @@ -958,7 +978,13 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { ] : []), ], - [canTurnIntoProject, props.titleRegenerationSupported, thread.runtime, isRegeneratingTitle], + [ + canMarkUnread, + canTurnIntoProject, + props.titleRegenerationSupported, + thread.runtime, + isRegeneratingTitle, + ], ); const menuActions = useMemo(() => { const nested = Platform.OS === "ios"; @@ -1060,13 +1086,8 @@ 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") void handleMarkUnread(); if (nativeEvent.event === "turn-into-project") void turnThreadIntoProject(thread); - if (nativeEvent.event === "mark-unread") { - void markThreadUnread({ - environmentId: thread.environmentId, - input: { threadId: thread.id }, - }); - } if (nativeEvent.event === "copy-thread") { const target = threadChipCopyTarget( { environmentId: thread.environmentId, threadId: thread.id }, @@ -1104,6 +1125,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { thread, handleArchive, handleDelete, + handleMarkUnread, handleRegenerateTitle, handleRename, handleMoveDown, @@ -1115,7 +1137,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { handleUnpin, handleUnsettle, handleUnsnooze, - markThreadUnread, setCustomSnoozeOpen, snoozePresets, props.snoozePresets, From 07c8a8b095dcaad8c7830304126d059e03bd4268 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 16 Nov 2026 01:07:55 +0000 Subject: [PATCH 2/4] refactor(mobile): test which threads can be marked unread Co-Authored-By: Claude Opus 5.5 --- .../features/threads/thread-list-v2-items.tsx | 7 +-- .../src/features/threads/threadListV2.test.ts | 48 +++++++++++++++++++ .../src/features/threads/threadListV2.ts | 13 +++++ 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index 711111852ed49..041cfa479a499 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -75,6 +75,7 @@ import { canTurnThreadIntoProject, turnThreadIntoProject } from "./turnThreadInt import { threadCanArchive } from "../home/threadArchive"; import { THREAD_LIST_V2_SETTLED_PAGE_COUNT, + canMarkThreadUnread, resolveThreadListV2SnoozeGateExpiryMs, resolveThreadListV2SnoozeMenuSelection, resolveThreadListV2SnoozePresets, @@ -800,11 +801,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false }); const markThreadUnread = useAtomCommand(threadEnvironment.markUnread, { reportFailure: false }); - const canMarkUnread = - status === "ready" && - thread.lastVisitedAt !== undefined && - thread.latestRun?.completedAt != null && - !threadHasUnseenCompletion(thread); + const canMarkUnread = canMarkThreadUnread(thread, status); const handleMarkUnread = useCallback(async () => { if (!canMarkUnread) return; const result = await markThreadUnread({ diff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.ts index 7324f039cd11e..10287c0b9e260 100644 --- a/apps/mobile/src/features/threads/threadListV2.test.ts +++ b/apps/mobile/src/features/threads/threadListV2.test.ts @@ -46,6 +46,7 @@ import { threadListV2ListItemsAreEqual, threadListV2RowAccessibilityLabel, threadHasUnseenCompletion, + canMarkThreadUnread, type ThreadListV2ListItem, } from "./threadListV2"; @@ -228,6 +229,53 @@ describe("resolveThreadListV2Status", () => { ); }); +describe("canMarkThreadUnread", () => { + const completed = { status: "completed", completedAt: NOW } as const; + it.each([ + { + name: "a read completed run", + latestRun: completed, + lastVisitedAt: NOW, + status: "ready", + can: true, + }, + { + name: "an unread completed run", + latestRun: completed, + lastVisitedAt: "2026-06-01T00:00:00.000Z", + status: "ready", + can: false, + }, + { + name: "no completed run", + latestRun: undefined, + lastVisitedAt: NOW, + status: "ready", + can: false, + }, + { + name: "a server without visit tracking", + latestRun: completed, + lastVisitedAt: undefined, + status: "ready", + can: false, + }, + { + name: "a working thread", + latestRun: completed, + lastVisitedAt: NOW, + status: "working", + can: false, + }, + ] as const)("is $can for $name", ({ latestRun, lastVisitedAt, status, can }) => { + const thread = { latestRun, lastVisitedAt } as Pick< + EnvironmentThreadShell, + "latestRun" | "lastVisitedAt" + >; + expect(canMarkThreadUnread(thread, status)).toBe(can); + }); +}); + describe("threadListV2RowAccessibilityLabel", () => { const row = { title: "Fix login", diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts index 61652bd0c3599..0cf1d3ca91d5c 100644 --- a/apps/mobile/src/features/threads/threadListV2.ts +++ b/apps/mobile/src/features/threads/threadListV2.ts @@ -246,6 +246,19 @@ export function threadHasUnseenCompletion( return completedAtMs > lastVisitedAtMs; } +/** The server rejects Mark unread without a completed run; older servers cannot persist it. */ +export function canMarkThreadUnread( + thread: Pick, + status: ThreadListV2Status, +): boolean { + return ( + status === "ready" && + thread.lastVisitedAt !== undefined && + thread.latestRun?.completedAt != null && + !threadHasUnseenCompletion(thread) + ); +} + export function resolveThreadListV2WokeAt( thread: EnvironmentThreadShell, options: { readonly now: string }, From 41c31b689f629a062e16fa9d7db549a29119fc57 Mon Sep 17 00:00:00 2001 From: Cuju Ju Date: Sun, 15 Nov 2026 17:19:54 -0800 Subject: [PATCH 3/4] fix(mobile): put mark unread first in More --- .../src/features/threads/threadListV2.test.ts | 17 +++++++++++++++-- .../mobile/src/features/threads/threadListV2.ts | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.ts index 10287c0b9e260..03b526507fd87 100644 --- a/apps/mobile/src/features/threads/threadListV2.test.ts +++ b/apps/mobile/src/features/threads/threadListV2.test.ts @@ -115,7 +115,14 @@ describe("layoutThreadListV2RowMenuActions", () => { direct: actions("new-thread-on-branch", "copy-thread", "copy-thread-id", "settle", "snooze"), reorder: actions("arrange", "move-up", "move-down"), pin: actions("unpin"), - secondary: actions("rename", "regenerate-title", "turn-into-project", "archive", "delete"), + secondary: actions( + "rename", + "regenerate-title", + "mark-unread", + "turn-into-project", + "archive", + "delete", + ), }; const flat = layoutThreadListV2RowMenuActions({ ...full, nested: false }); const nested = layoutThreadListV2RowMenuActions({ ...full, nested: true }); @@ -133,6 +140,7 @@ describe("layoutThreadListV2RowMenuActions", () => { "more", ]); expect(nested.at(-1)?.subactions?.map((action) => action.id)).toEqual([ + "mark-unread", "arrange-menu", "rename", "regenerate-title", @@ -148,7 +156,12 @@ describe("layoutThreadListV2RowMenuActions", () => { reorder: actions("arrange"), nested: true, }); - expect(slim.at(-1)?.subactions?.[0]?.id).toBe("arrange"); + expect( + slim + .at(-1) + ?.subactions?.slice(0, 2) + .map((action) => action.id), + ).toEqual(["mark-unread", "arrange"]); }); }); diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts index 0cf1d3ca91d5c..ab95c531d3a49 100644 --- a/apps/mobile/src/features/threads/threadListV2.ts +++ b/apps/mobile/src/features/threads/threadListV2.ts @@ -151,6 +151,7 @@ export function layoutThreadListV2RowMenuActions(input: { if (!input.nested) { return [...input.direct, ...input.reorder, ...input.pin, ...input.secondary]; } + const markUnread = input.secondary.find((action) => action.id === "mark-unread"); return [ ...input.direct, ...input.pin, @@ -159,6 +160,7 @@ export function layoutThreadListV2RowMenuActions(input: { title: "More", image: "ellipsis.circle", subactions: [ + ...(markUnread ? [markUnread] : []), ...(input.reorder.length > 1 ? [ { @@ -169,7 +171,7 @@ export function layoutThreadListV2RowMenuActions(input: { }, ] : input.reorder), - ...input.secondary, + ...input.secondary.filter((action) => action.id !== "mark-unread"), ], }, ]; From db5606b5a090daa2c18ca26a2d85f0b07eade1d4 Mon Sep 17 00:00:00 2001 From: Cuju Ju Date: Sun, 15 Nov 2026 19:28:28 -0800 Subject: [PATCH 4/4] fix(mobile): reuse the upstream unread icon --- apps/mobile/src/components/ui/AppSymbol.android.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/mobile/src/components/ui/AppSymbol.android.tsx b/apps/mobile/src/components/ui/AppSymbol.android.tsx index e1e7374c4964f..4a5a16298b956 100644 --- a/apps/mobile/src/components/ui/AppSymbol.android.tsx +++ b/apps/mobile/src/components/ui/AppSymbol.android.tsx @@ -88,7 +88,6 @@ import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing"; import IconMicrophone from "@tabler/icons-react-native/IconMicrophone"; import IconLink from "@tabler/icons-react-native/IconLink"; import IconListNumbers from "@tabler/icons-react-native/IconListNumbers"; -import IconMail from "@tabler/icons-react-native/IconMail"; import IconMenu2 from "@tabler/icons-react-native/IconMenu2"; import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion"; import IconMessage from "@tabler/icons-react-native/IconMessage"; @@ -208,7 +207,6 @@ const ANDROID_ICON_BY_SF_SYMBOL = { "doc.text": IconFileText, "file.diff": IconFileDiff, ellipsis: IconDots, - "envelope.badge": IconMail, moon: IconMoon, "ellipsis.circle": IconDotsCircleHorizontal, "envelope.badge": IconMail,