diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsx index f6c7fc9646a97..f441ed538421e 100644 --- a/apps/mobile/src/features/home/HomeRouteScreen.tsx +++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx @@ -102,6 +102,8 @@ export function HomeRouteScreen() { unsnoozeThread, pinThread, unpinThread, + hideThread, + unhideThread, setThreadAutoSettle, moveThread, renameThread, @@ -202,6 +204,8 @@ export function HomeRouteScreen() { onUnsettleThread={unsettleThread} onPinThread={pinThread} onUnpinThread={unpinThread} + onHideThread={hideThread} + onUnhideThread={unhideThread} onSetThreadAutoSettle={setThreadAutoSettle} onMoveThread={moveThread} onRenameThread={renameThread} diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx index 6d68f87900ed1..a1ae8785e2f6f 100644 --- a/apps/mobile/src/features/home/HomeScreen.tsx +++ b/apps/mobile/src/features/home/HomeScreen.tsx @@ -82,6 +82,7 @@ import { ThreadListV2SettledShelfHeader, ThreadListV2ShowMoreRow, ThreadListV2SnoozedShelfHeader, + ThreadListV2HiddenShelfHeader, ThreadListV2WorkingShelfHeader, } from "../threads/thread-list-v2-items"; import { useThreadRowProviderInstanceResolver } from "../threads/thread-provider-instance"; @@ -146,6 +147,8 @@ interface HomeScreenProps { readonly onUnsettleThread: (thread: EnvironmentThreadShell) => void; readonly onPinThread: (thread: EnvironmentThreadShell) => Promise; readonly onUnpinThread: (thread: EnvironmentThreadShell) => Promise; + readonly onHideThread: (thread: EnvironmentThreadShell) => Promise; + readonly onUnhideThread: (thread: EnvironmentThreadShell) => Promise; readonly onSetThreadAutoSettle: ( thread: EnvironmentThreadShell, enabled: boolean, @@ -380,6 +383,8 @@ export function HomeScreen(props: HomeScreenProps) { const handlePinThread = props.onPinThread; const handleMoveThread = props.onMoveThread; const handleUnpinThread = props.onUnpinThread; + const handleHideThread = props.onHideThread; + const handleUnhideThread = props.onUnhideThread; const handleSetThreadAutoSettle = props.onSetThreadAutoSettle; const handleRegenerateThreadTitle = props.onRegenerateThreadTitle; const handleRenameThread = props.onRenameThread; @@ -398,10 +403,12 @@ export function HomeScreen(props: HomeScreenProps) { setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT); const { loaded: shelfPreferencesLoaded, + hiddenShelfExpanded, settledShelfExpanded, snoozedShelfExpanded, workingShelfEnabled, workingShelfExpanded, + toggleHiddenShelf, toggleSettledShelf, toggleSnoozedShelf, toggleWorkingShelf, @@ -417,6 +424,7 @@ export function HomeScreen(props: HomeScreenProps) { snoozePresetsByEnvironmentId, pinningEnvironmentIds, autoSettleOptOutEnvironmentIds, + hideEnvironmentIds, pinReorderEnvironmentIds, activeReorderEnvironmentIds, titleRegenerationEnvironmentIds, @@ -450,6 +458,7 @@ export function HomeScreen(props: HomeScreenProps) { workingShelfExpanded, snoozedShelfExpanded, settledShelfExpanded, + hiddenShelfExpanded, selectedThreadKey, }); // Called as `props.onSelectThread(...)`, the compiler would cache this handler on the whole @@ -539,6 +548,25 @@ export function HomeScreen(props: HomeScreenProps) { /> ); } + if (item.type === "v2-show-more") { + return ( + showMoreOlderSettled(olderSettledShelf, showMoreSettled)} + /> + ); + } + if (item.type === "v2-hidden-shelf") { + return ( + + ); + } const thread = item.item.thread; const rowPermissions = rowPermissionsByEnvironmentId.get(thread.environmentId) ?? DEFAULT_THREAD_ROW_PERMISSIONS; @@ -601,6 +629,7 @@ export function HomeScreen(props: HomeScreenProps) { snoozePresets={snoozePresetsByEnvironmentId.get(thread.environmentId)} pinningSupported={pinningEnvironmentIds.has(thread.environmentId)} autoSettleOptOutSupported={autoSettleOptOutEnvironmentIds.has(thread.environmentId)} + hideSupported={hideEnvironmentIds.has(thread.environmentId)} reorderSupported={ item.item.pinned ? pinReorderEnvironmentIds.has(thread.environmentId) @@ -613,6 +642,8 @@ export function HomeScreen(props: HomeScreenProps) { onUnsettleThread={handleUnsettleThread} onPinThread={handlePinThread} onUnpinThread={handleUnpinThread} + onHideThread={handleHideThread} + onUnhideThread={handleUnhideThread} onSetThreadAutoSettle={handleSetThreadAutoSettle} onMoveThread={handleMoveThread} onSwipeableClose={handleSwipeableClose} @@ -815,19 +846,6 @@ export function HomeScreen(props: HomeScreenProps) { ListHeaderComponent={v2ListHeader} // Lifted above the rows so an iOS filter menu's dismissal morph is not covered. ListHeaderComponentStyle={{ zIndex: 1 }} - ListFooterComponent={ - settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? ( - showMoreOlderSettled(olderSettledShelf, showMoreSettled)} - /> - ) : null - } ListEmptyComponent={v2ListEmpty} style={{ flex: 1 }} automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"} diff --git a/apps/mobile/src/features/home/ThreadUndoNotice.tsx b/apps/mobile/src/features/home/ThreadUndoNotice.tsx index 064b693fdac38..13b63e8accb0c 100644 --- a/apps/mobile/src/features/home/ThreadUndoNotice.tsx +++ b/apps/mobile/src/features/home/ThreadUndoNotice.tsx @@ -103,7 +103,9 @@ export function ThreadUndoNotice(props: { ? gt`Settled thread` : notice.action === "Snoozed" ? gt`Snoozed thread` - : gt`Unpinned thread` + : notice.action === "Hidden" + ? gt`Hidden thread` + : gt`Unpinned thread` } action={{ label: gt`Undo`, diff --git a/apps/mobile/src/features/home/thread-swipe-actions.tsx b/apps/mobile/src/features/home/thread-swipe-actions.tsx index 8e4574b3f39c5..4b193ed8d3265 100644 --- a/apps/mobile/src/features/home/thread-swipe-actions.tsx +++ b/apps/mobile/src/features/home/thread-swipe-actions.tsx @@ -311,6 +311,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { const [actionsFor, setActionsFor] = useState(null); const [isDismissing, setIsDismissing] = useState(false); const [collapsedInList, setCollapsedInList] = useState(false); + const [restoredDismissals, setRestoredDismissals] = useState(0); const dismissing = useSharedValue(false); const rowHeight = useSharedValue(0); const rowWidth = useSharedValue(props.fullSwipeWidth); @@ -324,6 +325,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { const restoreRow = useCallback(() => { if (!mountedRef.current) return; + if (dismissalRef.current !== null) setRestoredDismissals((count) => count + 1); dismissalRef.current = null; setActionsFor(null); // RN-to-UI jobs run in order, so this also resets a queued dismissal. @@ -569,7 +571,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { return ( - + ; readonly undo: () => Promise; }; diff --git a/apps/mobile/src/features/home/useThreadListActions.ts b/apps/mobile/src/features/home/useThreadListActions.ts index ecda4f26a0577..04150577951dd 100644 --- a/apps/mobile/src/features/home/useThreadListActions.ts +++ b/apps/mobile/src/features/home/useThreadListActions.ts @@ -57,6 +57,13 @@ function environmentSupportsAutoSettleOptOut( ); } +function environmentSupportsThreadHide(environmentId: EnvironmentThreadShell["environmentId"]) { + return ( + appAtomRegistry.get(environmentServerConfigsAtom).get(environmentId)?.environment.capabilities + .threadHide === true + ); +} + type ThreadListAction = "archive" | "unarchive" | "delete" | "settle" | "unsettle"; const ACTION_FAILURES: Record = { @@ -206,7 +213,7 @@ function useThreadActionExecutor( } onSucceeded?.(result.value); if (action === "archive" || action === "delete") { - for (const kind of ["settle", "snooze", "pin"]) ThreadUndo.invalidate(kind, key); + ThreadUndo.invalidatePlacement(key); } if (action === "archive" || action === "unarchive" || action === "delete") { refreshArchivedThreadsForEnvironment(thread.environmentId); @@ -252,6 +259,8 @@ export function useThreadListActions(): { readonly unsettleThread: (thread: EnvironmentThreadShell) => Promise; readonly pinThread: (thread: EnvironmentThreadShell) => Promise; readonly unpinThread: (thread: EnvironmentThreadShell) => Promise; + readonly hideThread: (thread: EnvironmentThreadShell) => Promise; + readonly unhideThread: (thread: EnvironmentThreadShell) => Promise; readonly setThreadAutoSettle: ( thread: EnvironmentThreadShell, enabled: boolean, @@ -268,6 +277,10 @@ export function useThreadListActions(): { const unsnoozeMutation = useAtomCommand(threadEnvironment.unsnooze, { reportFailure: false }); const pinMutation = useAtomCommand(threadEnvironment.pin, { reportFailure: false }); const unpinMutation = useAtomCommand(threadEnvironment.unpin, { reportFailure: false }); + const hideMutation = useAtomCommand(threadEnvironment.hide, { reportFailure: false }); + const hideAgainMutation = useAtomCommand(threadEnvironment.hideAgain, { reportFailure: false }); + const settleMutation = useAtomCommand(threadEnvironment.settle, { reportFailure: false }); + const unhideMutation = useAtomCommand(threadEnvironment.unhide, { reportFailure: false }); const setAutoSettleMutation = useAtomCommand(threadEnvironment.setAutoSettle, { reportFailure: false, }); @@ -283,7 +296,7 @@ export function useThreadListActions(): { const archiveThread = (thread: EnvironmentThreadShell) => executeAction("archive", thread); const offerUndo = ( thread: EnvironmentThreadShell, - action: "Settled" | "Snoozed" | "Unpinned", + action: "Settled" | "Snoozed" | "Unpinned" | "Hidden", claim: ReturnType, plan: ThreadUndo.ThreadUndoPlan, ) => @@ -317,6 +330,25 @@ export function useThreadListActions(): { }); case "unsnooze": return unsnoozeThread(thread); + case "unhide": + return unhideThread(thread); + case "hide": + case "settle": { + const result = await (step.action === "hide" + ? hideAgainMutation({ + environmentId: thread.environmentId, + input: { threadId: thread.id }, + }) + : settleMutation({ + environmentId: thread.environmentId, + input: { + threadId: thread.id, + ...(step.settledAt === undefined ? {} : { settledAt: step.settledAt }), + }, + })); + if (result._tag === "Failure") throw Cause.squash(result.cause); + return true; + } case "pin": return pinThread(thread, step.orderKey); case "reorderActive": { @@ -331,7 +363,9 @@ export function useThreadListActions(): { const failureTitle = action === "Unpinned" ? m(msg("Could not undo unpin")) - : m(msg("Could not undo settle")); + : action === "Hidden" + ? m(msg("Could not undo hide")) + : m(msg("Could not undo settle")); if (!checkThreadOperationPermission(thread, failureTitle, true)) return false; const result = await snoozeMutation({ environmentId: thread.environmentId, @@ -414,6 +448,7 @@ export function useThreadListActions(): { } selectionHaptic(); + ThreadUndo.invalidate("hide", key); const claim = ThreadUndo.begin("snooze", key); const result = await withThreadDismissal( key, @@ -438,7 +473,7 @@ export function useThreadListActions(): { ); return false; } - offerUndo(thread, "Snoozed", claim, ThreadUndo.planThreadUndo("snooze")); + offerUndo(thread, "Snoozed", claim, ThreadUndo.planThreadUndo("snooze", thread)); return true; })(); snoozeInFlightThreadKeys.current.delete(key); @@ -522,10 +557,7 @@ export function useThreadListActions(): { restoreOrderKey === undefined ? (pinOrderKeyBetween(null, firstKey) ?? undefined) : (restoreOrderKey ?? undefined); - ThreadUndo.invalidate("pin", scopedThreadKey(thread.environmentId, thread.id)); - // Pinning clears snooze, so older Settled or Snoozed undos would fight this pin. - ThreadUndo.invalidate("settle", scopedThreadKey(thread.environmentId, thread.id)); - ThreadUndo.invalidate("snooze", scopedThreadKey(thread.environmentId, thread.id)); + ThreadUndo.invalidatePlacement(scopedThreadKey(thread.environmentId, thread.id)); const result = await withThreadDismissal( scopedThreadKey(thread.environmentId, thread.id), () => @@ -586,6 +618,67 @@ export function useThreadListActions(): { offerUndo(thread, "Unpinned", claim, plan); return true; }; + const hideThread = async (thread: EnvironmentThreadShell) => { + if (!checkThreadOperationPermission(thread, m(msg("Could not hide thread")))) return false; + if (!environmentSupportsThreadHide(thread.environmentId)) { + Dialog.alert( + m(msg("Could not hide thread")), + m( + msg( + "This environment's server does not support hiding yet. Update the server to use Hide.", + ), + ), + ); + return false; + } + selectionHaptic(); + const key = scopedThreadKey(thread.environmentId, thread.id); + const plan = ThreadUndo.planThreadUndo("hide", thread); + ThreadUndo.invalidatePlacement(key); + const claim = ThreadUndo.begin("hide", key); + const result = await withThreadDismissal( + key, + () => + hideMutation({ + environmentId: thread.environmentId, + input: { threadId: thread.id }, + }), + (result) => result._tag === "Success", + ); + if (result._tag === "Failure") { + claim.finish(); + const error = Cause.squash(result.cause); + Dialog.alert( + m(msg("Could not hide thread")), + error instanceof Error && errorDisplayMessage(error, m) !== null + ? (errorDisplayMessage(error, m) ?? error.message) + : m(msg("The thread could not be hidden.")), + ); + return false; + } + offerUndo(thread, "Hidden", claim, plan); + return true; + }; + const unhideThread = async (thread: EnvironmentThreadShell) => { + if (!checkThreadOperationPermission(thread, m(msg("Could not unhide thread")))) return false; + selectionHaptic(); + ThreadUndo.invalidate("hide", scopedThreadKey(thread.environmentId, thread.id)); + const result = await unhideMutation({ + environmentId: thread.environmentId, + input: { threadId: thread.id }, + }); + if (result._tag === "Failure") { + const error = Cause.squash(result.cause); + Dialog.alert( + m(msg("Could not unhide thread")), + error instanceof Error && errorDisplayMessage(error, m) !== null + ? (errorDisplayMessage(error, m) ?? error.message) + : m(msg("The thread could not be unhidden.")), + ); + return false; + } + return true; + }; const setThreadAutoSettle = async (thread: EnvironmentThreadShell, enabled: boolean) => { if (!environmentSupportsAutoSettleOptOut(thread.environmentId)) { Dialog.alert( @@ -791,10 +884,7 @@ export function useThreadListActions(): { const orderKey = assignments.find( ({ id }) => id === scopedThreadKey(thread.environmentId, thread.id), )?.orderKey; - // Same as pinThread: older Unpinned, Settled, or Snoozed undos would fight this pin. - ThreadUndo.invalidate("pin", scopedThreadKey(thread.environmentId, thread.id)); - ThreadUndo.invalidate("settle", scopedThreadKey(thread.environmentId, thread.id)); - ThreadUndo.invalidate("snooze", scopedThreadKey(thread.environmentId, thread.id)); + ThreadUndo.invalidatePlacement(scopedThreadKey(thread.environmentId, thread.id)); const result = await pinMutation({ environmentId: thread.environmentId, input: { threadId: thread.id, ...(orderKey === undefined ? {} : { orderKey }) }, @@ -873,6 +963,12 @@ export function useThreadListActions(): { unpinThread: useStableCallback((thread: EnvironmentThreadShell) => unpinThread(liveThread(thread)), ), + hideThread: useStableCallback((thread: EnvironmentThreadShell) => + hideThread(liveThread(thread)), + ), + unhideThread: useStableCallback((thread: EnvironmentThreadShell) => + unhideThread(liveThread(thread)), + ), setThreadAutoSettle: useStableCallback((thread: EnvironmentThreadShell, enabled: boolean) => setThreadAutoSettle(liveThread(thread), enabled), ), diff --git a/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts b/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts index 065d6263bac95..a9c4ec872a6a6 100644 --- a/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts +++ b/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts @@ -8,14 +8,12 @@ import { type HardwareKeyboardCommand, } from "./hardwareKeyboardCommands"; -type ThreadShortcutListItem = ThreadListV2ListItem | { readonly type: "v2-show-more" }; - export function threadJumpIndex(command: HardwareKeyboardCommand) { return THREAD_JUMP_KEYBINDING_COMMANDS.findIndex((candidate) => candidate === command); } export function threadJumpTarget( - items: ReadonlyArray, + items: ReadonlyArray, command: HardwareKeyboardCommand, ) { let index = threadJumpIndex(command); @@ -28,7 +26,7 @@ export function threadJumpTarget( } export function useThreadJumpShortcuts( - items: ReadonlyArray, + items: ReadonlyArray, onSelectThread: (thread: EnvironmentThreadShell) => void, onSelectPendingTask: (pendingTask: PendingNewTask) => void, ) { diff --git a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx index e870b8c79c948..dac8a338773ac 100644 --- a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx +++ b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx @@ -218,7 +218,8 @@ function ThreadArrangementSheet(props: { onClose: () => void }) { const active = getThreadListV2OrderedSection({ ...shared, section: "active" }); const visible = new Set([...pinned, ...active].map(keyOf)); const parked = threads.filter( - (thread) => thread.archivedAt === null && !visible.has(keyOf(thread)), + (thread) => + thread.archivedAt === null && thread.hiddenAt == null && !visible.has(keyOf(thread)), ); return { pinned, @@ -233,6 +234,10 @@ function ThreadArrangementSheet(props: { onClose: () => void }) { useOlderSettledShelfGrowth(olderSettledShelf, listedSettled); const visibleSettled = listedSettled.slice(0, settledVisibleCount); const settledCount = sections.settled.length + olderSettledShelf.unloadedCount(threads); + const nextSettledPageCount = Math.min( + settledCount - visibleSettled.length, + THREAD_LIST_V2_SETTLED_PAGE_COUNT, + ); const planners = useMemo(() => { const planner = (section: "pinned" | "active") => createThreadMovePlanner({ @@ -559,10 +564,10 @@ function ThreadArrangementSheet(props: { onClose: () => void }) { : olderSettledShelf.failed ? gt`Could not load older threads. Retry` : gt`${plural( - { count: settledCount - visibleSettled.length }, + { count: nextSettledPageCount }, { - one: part`Show more (${{ count: settledCount - visibleSettled.length }} settled hidden)`, - other: part`Show more (${{ count: settledCount - visibleSettled.length }} settled hidden)`, + one: part`Show ${{ count: nextSettledPageCount }} more`, + other: part`Show ${{ count: nextSettledPageCount }} more`, }, )}`} diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index abcdb08028dda..c4c0bb1a475f1 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -591,6 +591,7 @@ function ThreadDetailBody( }); const unsnoozeThread = useAtomCommand(threadEnvironment.unsnooze, { reportFailure: false }); const unsettleThread = useAtomCommand(threadEnvironment.unsettle, { reportFailure: false }); + const unhideThread = useAtomCommand(threadEnvironment.unhide, { reportFailure: false }); const canTriageThread = !useEnvironmentScopeDenied( props.environmentId, AuthOrchestrationOperateScope, @@ -697,7 +698,8 @@ function ThreadDetailBody( lastVisitedAt: props.selectedThread.lastVisitedAt, latestRunCompletedAt: props.selectedThread.latestRun?.completedAt ?? null, }); - const runStatusAction = async (action: "stop" | "wake" | "unsettle" | "dismiss") => { + const hidden = props.selectedThread.hiddenAt != null; + const runStatusAction = async (action: "stop" | "wake" | "unsettle" | "unhide" | "dismiss") => { const permitted = action === "wake" || action === "unsettle" ? canTriageThread : props.canOperateThread; if (statusPending || !permitted) return; @@ -739,10 +741,12 @@ function ThreadDetailBody( : await unsnoozeThread({ ...target, input: { ...target.input, reason: "user" } }) : action === "unsettle" ? await unsettleThread({ ...target, input: { ...target.input, reason: "user" } }) - : await visitThread({ - ...target, - input: { ...target.input, visitedAt: wokeAt ?? lifecycleNow }, - }); + : action === "unhide" + ? await unhideThread(target) + : await visitThread({ + ...target, + input: { ...target.input, visitedAt: wokeAt ?? lifecycleNow }, + }); props.setStatusRequests((current) => current[request.threadKey] !== request ? current @@ -810,6 +814,20 @@ function ThreadDetailBody( }; })(); const lifecycleLine = ((): ThreadStatusLineModel | null => { + if (contentPresentationKind === "ready" && hidden) { + const unhideLabel = gt({ context: "verb, thread action" })`Unhide`; + return { + key: "lifecycle", + icon: "eye.slash", + label: gt({ context: "thread state" })`Hidden`, + action: { + label: statusPending ? gt`Unhiding...` : unhideLabel, + accessibilityLabel: unhideLabel, + disabled: !props.canOperateThread || statusPending, + onPress: () => void runStatusAction("unhide"), + }, + }; + } if (contentPresentationKind !== "ready" || !(lifecycleSnoozed || settled || woke)) return null; const actionLabel = lifecycleSnoozed ? gt`Wake now` diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx index a2fb11820c771..569a757e9f8cf 100644 --- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx @@ -72,6 +72,7 @@ import { ThreadListV2SettledShelfHeader, ThreadListV2ShowMoreRow, ThreadListV2SnoozedShelfHeader, + ThreadListV2HiddenShelfHeader, ThreadListV2WorkingShelfHeader, } from "./thread-list-v2-items"; import { useThreadRowProviderInstanceResolver } from "./thread-provider-instance"; @@ -79,7 +80,6 @@ import type { ThreadPrPresentation } from "../../state/thread-pr-presentation"; import { ThreadPrDemandProvider } from "../../state/thread-pr-demand"; import { showMoreOlderSettled } from "../../state/olderSettledShelf"; import { - isThreadListV2ListItem, threadListV2ListItemsAreEqual, THREAD_LIST_V2_SETTLED_INITIAL_COUNT, THREAD_LIST_V2_SETTLED_PAGE_COUNT, @@ -89,15 +89,6 @@ import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspace import { NativeScrollView } from "../../native/NativeScrollViewMarker"; import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-context"; -type SidebarListItem = - | ThreadListV2ListItem - | { - readonly type: "v2-show-more"; - readonly key: string; - readonly hiddenCount: number; - readonly state?: "loading" | "failed"; - }; - interface ThreadNavigationSidebarProps { readonly width: number; readonly visible: boolean; @@ -158,6 +149,8 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { unsettleThread, pinThread, unpinThread, + hideThread, + unhideThread, setThreadAutoSettle, moveThread, renameThread, @@ -260,10 +253,12 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT); const { loaded: shelfPreferencesLoaded, + hiddenShelfExpanded, settledShelfExpanded, snoozedShelfExpanded, workingShelfEnabled, workingShelfExpanded, + toggleHiddenShelf, toggleSettledShelf, toggleSnoozedShelf, toggleWorkingShelf, @@ -279,6 +274,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { snoozePresetsByEnvironmentId, pinningEnvironmentIds, autoSettleOptOutEnvironmentIds, + hideEnvironmentIds, pinReorderEnvironmentIds, activeReorderEnvironmentIds, titleRegenerationEnvironmentIds, @@ -288,7 +284,6 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { const resolveProviderInstance = useThreadRowProviderInstanceResolver(providersByEnvironmentId); const pendingOrder = usePendingThreadOrder(); const { - layout: threadListV2Layout, items: threadListV2Items, contentOnlyThreadKeys, olderSettledShelf, @@ -312,24 +307,10 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { workingShelfExpanded, snoozedShelfExpanded, settledShelfExpanded, + hiddenShelfExpanded, selectedThreadKey, }); - const listItems: readonly SidebarListItem[] = - settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 - ? [ - ...threadListV2Items, - { - type: "v2-show-more", - key: "v2-show-more", - hiddenCount: threadListV2Layout.hiddenSettledCount, - ...(olderSettledShelf.loading - ? { state: "loading" as const } - : olderSettledShelf.failed - ? { state: "failed" as const } - : {}), - }, - ] - : threadListV2Items; + const listItems = threadListV2Items; const handleSwipeableWillOpen = (methods: SwipeableMethods) => { if (openSwipeableRef.current !== methods) { @@ -387,16 +368,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { rowLayout, }; useThreadJumpShortcuts(listItems, handleSelectThread, props.onOpenPendingTask); - const sidebarItemsAreEqual = (previous: SidebarListItem, item: SidebarListItem): boolean => { - if (isThreadListV2ListItem(previous) && isThreadListV2ListItem(item)) { - return threadListV2ListItemsAreEqual(previous, item); - } - if (previous.type === "v2-show-more" && item.type === "v2-show-more") { - return previous.hiddenCount === item.hiddenCount && previous.state === item.state; - } - return false; - }; - const renderListItem = ({ item }: { readonly item: SidebarListItem }) => { + const renderListItem = ({ item }: { readonly item: ThreadListV2ListItem }) => { switch (item.type) { case "v2-pending": { const pendingScopeKey = scopedProjectKey( @@ -500,6 +472,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)} snoozePresets={snoozePresetsByEnvironmentId.get(thread.environmentId)} pinningSupported={pinningEnvironmentIds.has(thread.environmentId)} + hideSupported={hideEnvironmentIds.has(thread.environmentId)} autoSettleOptOutSupported={autoSettleOptOutEnvironmentIds.has(thread.environmentId)} reorderSupported={ item.item.pinned @@ -513,6 +486,8 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { onUnsettleThread={unsettleThread} onPinThread={pinThread} onUnpinThread={unpinThread} + onHideThread={hideThread} + onUnhideThread={unhideThread} onSetThreadAutoSettle={setThreadAutoSettle} onMoveThread={moveThread} onSwipeableClose={handleSwipeableClose} @@ -551,11 +526,21 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { pane="sidebar" /> ); + case "v2-hidden-shelf": + return ( + + ); case "v2-show-more": return ( showMoreOlderSettled(olderSettledShelf, showMoreSettled)} /> @@ -650,7 +635,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { estimatedItemSize={64} extraData={listExtraData} getItemType={(item) => item.type} - itemsAreEqual={sidebarItemsAreEqual} + itemsAreEqual={threadListV2ListItemsAreEqual} keyExtractor={(item) => item.key} renderItem={renderListItem} automaticallyAdjustsScrollIndicatorInsets @@ -707,7 +692,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) { estimatedItemSize={64} extraData={listExtraData} getItemType={(item) => item.type} - itemsAreEqual={sidebarItemsAreEqual} + itemsAreEqual={threadListV2ListItemsAreEqual} keyExtractor={(item) => item.key} renderItem={renderListItem} contentContainerStyle={{ 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 ea7c8c7df79c4..88d39f6ed0a27 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -28,7 +28,11 @@ import { import { type EnvironmentId, type EnvironmentMachineKind } from "@t3tools/contracts"; import { toServerClock } from "@t3tools/client-runtime/clock"; import type { SnoozePresetSetting } from "@t3tools/contracts/settings"; -import { canSnooze, type SnoozePreset } from "@t3tools/client-runtime/state/thread-settled"; +import { + canSnooze, + hasUnseenCompletion, + type SnoozePreset, +} from "@t3tools/client-runtime/state/thread-settled"; import { threadChipCopyTarget } from "@t3tools/client-runtime/thread-reference"; import type { MenuAction } from "@react-native-menu/menu"; import { useNavigation } from "@react-navigation/native"; @@ -81,10 +85,10 @@ import { threadCanArchive } from "../home/threadArchive"; import { threadCanStartHandoff } from "@t3tools/client-runtime/state/peerLinks"; import { threadListV2ShowMoreAccessibilityLabel, + THREAD_LIST_V2_SETTLED_PAGE_COUNT, resolveThreadListV2SnoozeGateExpiryMs, resolveThreadListV2SnoozeMenuSelection, resolveThreadListV2SnoozePresets, - threadHasUnseenCompletion, resolveThreadListV2RowStatus, resolveThreadListV2Status, resolveThreadListV2ProviderStack, @@ -343,6 +347,10 @@ const SNOOZED_MENU_ACTIONS: UnresolvedMenuAction[] = [ }, ]; +const HIDDEN_MENU_ACTIONS: UnresolvedMenuAction[] = [ + { id: "unhide", title: msg({ context: "verb, thread action" })`Unhide`, image: "eye" }, +]; + const LEGACY_MENU_ACTIONS: UnresolvedMenuAction[] = [ { id: "archive", @@ -491,6 +499,19 @@ const SHELF_COPY = { collapse: msg("Collapses the settled threads."), expand: msg("Expands the settled threads."), }, + hidden: { + label: msg({ context: "thread list section" })`Hidden`, + count: ({ count }: { count: number }) => + msg`${plural( + { count }, + { + one: part`${{ count }} hidden thread`, + other: part`${{ count }} hidden threads`, + }, + )}`, + collapse: msg("Collapses the hidden threads."), + expand: msg("Expands the hidden threads."), + }, } as const; function ThreadListV2ShelfHeader( @@ -534,25 +555,32 @@ export const ThreadListV2SettledShelfHeader = memo(function ThreadListV2SettledS return ; }); +export const ThreadListV2HiddenShelfHeader = memo(function ThreadListV2HiddenShelfHeader( + props: ThreadListV2ShelfHeaderProps, +) { + return ; +}); + export const ThreadListV2ShowMoreRow = memo(function ThreadListV2ShowMoreRow(props: { readonly pane?: "screen" | "sidebar"; - readonly hiddenCount: number; + readonly moreCount: number; /** Older settled threads are loading, or their last read failed. */ readonly state?: "loading" | "failed"; readonly onPress: () => void; }) { const gt = useGT(); const messages = useMessages(); + const shownCount = Math.min(props.moreCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT); const label = props.state === "loading" ? gt({ context: "older threads are loading" })`Loading` : props.state === "failed" ? gt`Could not load older threads. Retry` : gt`${plural( - { count: props.hiddenCount }, + { count: shownCount }, { - one: part`Show more (${{ count: props.hiddenCount }} settled hidden)`, - other: part`Show more (${{ count: props.hiddenCount }} settled hidden)`, + one: part`Show ${{ count: shownCount }} more`, + other: part`Show ${{ count: shownCount }} more`, }, )}`; return ( @@ -560,7 +588,7 @@ export const ThreadListV2ShowMoreRow = memo(function ThreadListV2ShowMoreRow(pro accessibilityRole="button" accessibilityLabel={ props.state === undefined - ? threadListV2ShowMoreAccessibilityLabel(props.hiddenCount, messages) + ? threadListV2ShowMoreAccessibilityLabel(props.moreCount, messages) : label } disabled={props.state === "loading"} @@ -923,8 +951,11 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { readonly onArchiveThread: (thread: EnvironmentThreadShell) => void; readonly onPinThread: (thread: EnvironmentThreadShell) => void; readonly onUnpinThread: (thread: EnvironmentThreadShell) => void; + readonly onHideThread: (thread: EnvironmentThreadShell) => void; + readonly onUnhideThread: (thread: EnvironmentThreadShell) => void; readonly onSetThreadAutoSettle: (thread: EnvironmentThreadShell, enabled: boolean) => void; readonly settlementSupported: boolean; + readonly hideSupported: boolean; readonly snoozeSupported: boolean; readonly snoozePresets: ReadonlyArray | undefined; readonly pinningSupported: boolean; @@ -969,10 +1000,13 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { onArchiveThread, onPinThread, onUnpinThread, + onHideThread, + onUnhideThread, onSetThreadAutoSettle, onMoveThread, } = props; const snoozedRow = props.snoozed === true; + const hiddenRow = thread.hiddenAt != null; const pinnedRow = props.pinned === true; const dormant = useSwipeRowDormant(props.activationKey); @@ -1011,7 +1045,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { const rawStatus = resolveThreadListV2Status(thread); const status = resolveThreadListV2RowStatus(thread); - const isUnread = status === "ready" && threadHasUnseenCompletion(thread); + const isUnread = status === "ready" && hasUnseenCompletion(thread); const showsWoke = status === "ready" && props.wokeAt !== null; const statusEntry = threadRowStatusLabel(status, { goalActive: thread.goal?.status === "active", @@ -1105,6 +1139,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { const handleUnsettle = useCallback(() => onUnsettleThread(thread), [onUnsettleThread, thread]); const handlePin = useCallback(() => onPinThread(thread), [onPinThread, thread]); const handleUnpin = useCallback(() => onUnpinThread(thread), [onUnpinThread, thread]); + const handleHide = useCallback(() => onHideThread(thread), [onHideThread, thread]); + const handleUnhide = useCallback(() => onUnhideThread(thread), [onUnhideThread, thread]); const handleSetAutoSettle = useCallback( (enabled: boolean) => onSetThreadAutoSettle(thread, enabled), [onSetThreadAutoSettle, thread], @@ -1129,13 +1165,18 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { snoozeSupported: props.snoozeSupported, snoozable: canSnooze(thread, { now: snoozeGateNow }), snoozed: snoozedRow, + hidden: hiddenRow, + hideSupported: props.hideSupported, }); + const offersSnooze = + swipeActions.secondary === "snooze" || + (hiddenRow && props.snoozeSupported && canSnooze(thread, { now: snoozeGateNow })); const snoozePresets = - swipeActions.secondary === "snooze" && props.snoozePresetMinute && props.resolvedSnoozePresets + offersSnooze && props.snoozePresetMinute && props.resolvedSnoozePresets ? props.resolvedSnoozePresets : resolveThreadListV2SnoozePresets( { - secondary: swipeActions.secondary, + secondary: offersSnooze ? "snooze" : null, now: props.snoozePresetMinute ?? snoozeGateNow, presets: props.snoozePresets, }, @@ -1188,6 +1229,13 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { : [], [gt, props.pinningSupported, thread.pinnedAt], ); + const hideMenuItems = useMemo( + () => + props.hideSupported + ? [{ id: "hide", title: gt({ context: "verb, thread action" })`Hide`, image: "eye.slash" }] + : [], + [gt, props.hideSupported], + ); const autoSettleMenuItems = useMemo( () => props.autoSettleOptOutSupported @@ -1295,6 +1343,37 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { ] : []), ]; + const snoozeMenuItems: MenuAction[] = offersSnooze + ? [ + { + id: "snooze", + title: gt({ context: "verb, thread action" })`Snooze`, + image: "clock", + subactions: snoozePresetActions, + }, + ] + : []; + if (hiddenRow) { + return layoutThreadListV2RowMenuActions( + { + nested, + direct: [ + ...direct, + ...(props.hideSupported ? [localized(HIDDEN_MENU_ACTIONS[0]!)] : []), + ...snoozeMenuItems, + ], + reorder: [], + pin: pinMenuItems, + secondary: [ + ...titleMenuItems, + ...autoSettleMenuItems, + localized(LEGACY_MENU_ACTIONS[0]!), + localized(LEGACY_MENU_ACTIONS[1]!), + ], + }, + m, + ); + } if (snoozedRow) { return layoutThreadListV2RowMenuActions( { @@ -1305,6 +1384,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { secondary: [ ...titleMenuItems, ...autoSettleMenuItems, + ...hideMenuItems, localized(LEGACY_MENU_ACTIONS[0]!), localized(SNOOZED_MENU_ACTIONS[1]!), ], @@ -1319,7 +1399,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { direct: [...direct, localized(LEGACY_MENU_ACTIONS[0]!)], reorder: reorderMenuItems, pin: pinMenuItems, - secondary: [...titleMenuItems, localized(LEGACY_MENU_ACTIONS[1]!)], + secondary: [...titleMenuItems, ...hideMenuItems, localized(LEGACY_MENU_ACTIONS[1]!)], }, m, ); @@ -1336,6 +1416,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { secondary: [ ...titleMenuItems, ...autoSettleMenuItems, + ...hideMenuItems, localized(LEGACY_MENU_ACTIONS[0]!), localized(SLIM_MENU_ACTIONS[1]!), ], @@ -1346,25 +1427,13 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { return layoutThreadListV2RowMenuActions( { nested, - direct: [ - ...direct, - localized(CARD_MENU_ACTIONS[0]!), - ...(swipeActions.secondary === "snooze" - ? [ - { - id: "snooze", - title: gt({ context: "verb, thread action" })`Snooze`, - image: "clock", - subactions: snoozePresetActions, - }, - ] - : []), - ], + direct: [...direct, localized(CARD_MENU_ACTIONS[0]!), ...snoozeMenuItems], reorder: reorderMenuItems, pin: pinMenuItems, secondary: [ ...titleMenuItems, ...autoSettleMenuItems, + ...hideMenuItems, localized(LEGACY_MENU_ACTIONS[0]!), localized(CARD_MENU_ACTIONS[1]!), ], @@ -1378,14 +1447,17 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { canMoveWorkspace, thread.runtime, canUnsettle, + hiddenRow, + hideMenuItems, + offersSnooze, pinMenuItems, + props.hideSupported, props.settlementSupported, reorderMenuItems, snoozePresetActions, snoozedRow, gt, m, - swipeActions.secondary, thread.branch, titleMenuItems, ]); @@ -1397,6 +1469,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { if (nativeEvent.event === "unsnooze") handleUnsnooze(); if (nativeEvent.event === "pin") handlePin(); if (nativeEvent.event === "unpin") handleUnpin(); + if (nativeEvent.event === "hide") handleHide(); + if (nativeEvent.event === "unhide") handleUnhide(); if (nativeEvent.event === "auto-settle:enabled") handleSetAutoSettle(true); if (nativeEvent.event === "auto-settle:disabled") handleSetAutoSettle(false); if (nativeEvent.event === "arrange") appAtomRegistry.set(threadArrangementOpenAtom, true); @@ -1481,6 +1555,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { handleSettle, handleSnooze, handleSetAutoSettle, + handleHide, + handleUnhide, handleUnpin, handleUnsettle, handleUnsnooze, @@ -1501,6 +1577,16 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { onPress: handleArchive, }; } + if (swipeActions.primary === "unhide") { + return { + accessibilityLabel: gt`Unhide ${{ title: thread.title }}`, + icon: "eye" as const, + label: gt({ context: "verb, thread action" })`Unhide`, + swipeHint: gt`Opens the thread. Swipe left to unhide.`, + swipeSnoozeHint: gt`Opens the thread. Swipe left to unhide.`, + onPress: handleUnhide, + }; + } if (swipeActions.primary === "unsnooze") { return { accessibilityLabel: gt`Wake ${{ title: thread.title }} now`, @@ -1532,6 +1618,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { gt, handleArchive, handleSettle, + handleUnhide, handleUnsettle, handleUnsnooze, swipeActions.primary, @@ -1836,7 +1923,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { onSwipeableWillOpen={props.onSwipeableWillOpen} primaryAction={primaryAction} secondaryAction={secondaryAction} - resetKey={`${thread.environmentId}:${thread.id}:${variant}:${snoozedRow}:${thread.settledAt}:${thread.unsettledAt}:${thread.snoozedUntil}:${thread.pinnedAt}`} + resetKey={`${thread.environmentId}:${thread.id}:${variant}:${snoozedRow}:${thread.settledAt}:${thread.unsettledAt}:${thread.snoozedUntil}:${thread.pinnedAt}:${thread.hiddenAt}`} simultaneousWith={props.simultaneousSwipeGesture} threadTitle={thread.title} > diff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.ts index fdb3dbebcf4c3..33f96f41d5426 100644 --- a/apps/mobile/src/features/threads/threadListV2.test.ts +++ b/apps/mobile/src/features/threads/threadListV2.test.ts @@ -14,7 +14,11 @@ import { type ThreadMoveAvailability, } from "./threadOrder"; import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; -import { canSnooze, resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled"; +import { + canSnooze, + hasUnseenCompletion, + resolveSnoozePresets, +} from "@t3tools/client-runtime/state/thread-settled"; import { CommandId, EnvironmentId, @@ -48,7 +52,6 @@ import { threadListV2ListItemsAreEqual, threadListV2RowAccessibilityLabel, threadListV2ShowMoreAccessibilityLabel, - threadHasUnseenCompletion, type ThreadListV2ListItem, } from "./threadListV2"; @@ -205,7 +208,7 @@ describe("resolveThreadListV2Status", () => { expect(resolveThreadListV2Status(disconnected)).toBe( status === "failed" ? "failed" : "ready", ); - expect(threadHasUnseenCompletion(disconnected)).toBe(threadHasUnseenCompletion(thread)); + expect(hasUnseenCompletion(disconnected)).toBe(hasUnseenCompletion(thread)); }, ); @@ -311,26 +314,30 @@ describe("resolveThreadListV2Status", () => { ); expect(resolveThreadListV2Status(thread)).toBe(status); - expect(threadHasUnseenCompletion(thread)).toBe(true); + expect(hasUnseenCompletion(thread)).toBe(true); }, ); - it.each(["interrupted", "cancelled"] as const)( - "does not present a %s run as an unseen completion", - (status) => { - const thread = presentThreadShell( - environmentId, - makeRawThreadShell({ - latestRunId: RunId.make("run-stopped"), - status, - latestRunCompletedAt: DateTime.makeUnsafe(NOW), - lastVisitedAt: DateTime.makeUnsafe("2026-06-01T23:59:00.000Z"), - }), - ); + it.each([ + ["an interrupted run", { status: "interrupted" }], + ["a cancelled run", { status: "cancelled" }], + [ + "a hidden thread's completed run", + { status: "completed", hiddenAt: DateTime.makeUnsafe(NOW) }, + ], + ] as const)("does not present %s as an unseen completion", (_name, overrides) => { + const thread = presentThreadShell( + environmentId, + makeRawThreadShell({ + latestRunId: RunId.make("run-stopped"), + latestRunCompletedAt: DateTime.makeUnsafe(NOW), + lastVisitedAt: DateTime.makeUnsafe("2026-06-01T23:59:00.000Z"), + ...overrides, + }), + ); - expect(threadHasUnseenCompletion(thread)).toBe(false); - }, - ); + expect(hasUnseenCompletion(thread)).toBe(false); + }); }); describe("threadListV2ShowMoreAccessibilityLabel", () => { @@ -338,8 +345,8 @@ describe("threadListV2ShowMoreAccessibilityLabel", () => { [1, "Show 1 more settled thread"], [2, "Show 2 more settled threads"], [26, "Show 25 more settled threads"], - ])("announces the next page for %i hidden settled threads", (hiddenCount, expected) => { - expect(threadListV2ShowMoreAccessibilityLabel(hiddenCount)).toBe(expected); + ])("announces the next page for %i more settled threads", (moreCount, expected) => { + expect(threadListV2ShowMoreAccessibilityLabel(moreCount)).toBe(expected); }); }); @@ -598,6 +605,72 @@ describe("buildThreadListV2Items", () => { expect(layout.snoozedCount).toBe(2); }); + it("folds hidden threads into the Hidden shelf after Settled, whatever else they are", () => { + const hiddenAt = "2026-06-01T12:00:00.000Z"; + const layout = buildThreadListV2Items({ + threads: [ + makeThread({ id: ThreadId.make("active"), title: "Active" }), + makeThread({ + id: ThreadId.make("settled"), + title: "Settled", + settledOverride: "settled", + settledAt: NOW, + }), + makeThread({ + id: ThreadId.make("hidden-pinned"), + title: "Hidden pinned", + pinnedAt: NOW, + hiddenAt, + }), + makeThread({ + id: ThreadId.make("hidden-snoozed"), + title: "Hidden snoozed", + snoozedUntil: "2026-06-03T09:00:00.000Z", + snoozedAt: hiddenAt, + hiddenAt, + }), + makeThread({ + id: ThreadId.make("hidden-settled"), + title: "Hidden settled", + settledOverride: "settled", + settledAt: NOW, + hiddenAt, + }), + ], + environmentId: null, + searchQuery: "", + now: NOW, + hiddenShelfExpanded: false, + selectedThreadKey: `${environmentId}:hidden-settled`, + }); + expect(layout.items.map((item) => item.thread.id)).toEqual([ + "active", + "settled", + "hidden-settled", + ]); + expect(layout).toMatchObject({ hiddenCount: 3, hiddenShelfHeaderIndex: 2, settledCount: 1 }); + + const items = buildThreadListV2ListItems({ + items: layout.items, + pendingTasks: [], + settledCount: layout.settledCount, + settledShelfHeaderIndex: layout.settledShelfHeaderIndex, + settledShelfExpanded: true, + showMoreSettled: { moreCount: 4 }, + hiddenCount: layout.hiddenCount, + hiddenShelfHeaderIndex: layout.hiddenShelfHeaderIndex, + }); + expect(items.map((item) => item.type)).toEqual([ + "v2-thread", + "v2-settled-shelf", + "v2-thread", + "v2-show-more", + "v2-hidden-shelf", + "v2-thread", + ]); + expect(items[4]).toMatchObject({ count: 3, expanded: false }); + }); + it("keeps the selected thread on a collapsed shelf", () => { const layout = buildThreadListV2Items({ threads: [ @@ -771,7 +844,7 @@ describe("buildThreadListV2Items settled paging", () => { now: NOW, }); - expect(layout.hiddenSettledCount).toBe(2); + expect(layout.moreSettledCount).toBe(2); expect(layout.items.filter((item) => item.variant === "slim")).toHaveLength(2); expect(layout.items.map((item) => item.thread.id)).toEqual([ "active", @@ -806,7 +879,7 @@ describe("buildThreadListV2Items settled paging", () => { "settled-1", ]); expect(layout.settledCount).toBe(43); - expect(layout.hiddenSettledCount).toBe(40); + expect(layout.moreSettledCount).toBe(40); // A scope whose settled threads are all older still shows its Settled header. const unloadedOnly = buildThreadListV2Items({ diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts index a912a90af0dfa..ce9cfa649c754 100644 --- a/apps/mobile/src/features/threads/threadListV2.ts +++ b/apps/mobile/src/features/threads/threadListV2.ts @@ -1,15 +1,16 @@ import { msg, plural, part as gtPart } from "gt-react-native"; import { canSnooze, - effectiveSnoozed, hasQueuedTurnStart, pickSnoozePreset, QUEUED_TURN_START_GRACE_MS, resolveSnoozePresets, + resolveThreadPlacement, snoozeWakeLabel, threadWokeAt, } from "@t3tools/client-runtime/state/thread-settled"; import { + hasUnseenCompletion, hasUnseenRunFailure, type SnoozePreset, } from "@t3tools/client-runtime/state/thread-settled"; @@ -80,7 +81,13 @@ export type ThreadListV2Status = | "failed" | "limited" | "ready"; -export type ThreadListV2SwipeAction = "archive" | "settle" | "unsettle" | "snooze" | "unsnooze"; +export type ThreadListV2SwipeAction = + | "archive" + | "settle" + | "unsettle" + | "snooze" + | "unsnooze" + | "unhide"; /** * Presets for a row's snooze menu, read at the list's minute instead of the @@ -154,10 +161,15 @@ export function resolveThreadListV2SwipeActions(input: { readonly snoozeSupported: boolean; readonly snoozable: boolean; readonly snoozed?: boolean; + readonly hidden?: boolean; + readonly hideSupported?: boolean; }): { readonly primary: Exclude; readonly secondary: "snooze" | null; } { + if (input.hidden === true) { + return { primary: input.hideSupported === true ? "unhide" : "archive", secondary: null }; + } if (input.snoozed === true) { return { primary: "unsnooze", secondary: null }; } @@ -269,21 +281,6 @@ export function threadListV2LayoutTime(input: { export const THREAD_LIST_V2_SETTLED_INITIAL_COUNT = 10; export const THREAD_LIST_V2_SETTLED_PAGE_COUNT = 25; -export function threadHasUnseenCompletion( - thread: Pick, -): boolean { - const completedAt = thread.latestRun?.completedAt; - if (!completedAt) return false; - const status = thread.latestRun?.status; - if (status === "interrupted" || status === "cancelled") return false; - const completedAtMs = Date.parse(completedAt); - if (Number.isNaN(completedAtMs)) return false; - if (!thread.lastVisitedAt) return false; - const lastVisitedAtMs = Date.parse(thread.lastVisitedAt); - if (Number.isNaN(lastVisitedAtMs)) return true; - return completedAtMs > lastVisitedAtMs; -} - export function resolveThreadListV2WokeAt( thread: EnvironmentThreadShell, options: { readonly now: string }, @@ -344,15 +341,15 @@ export function resolveThreadListV2Status( } export function threadListV2ShowMoreAccessibilityLabel( - hiddenCount: number, + moreCount: number, resolve: MessageResolver = m, ): string { return resolve( msg`${plural( - { count: Math.min(hiddenCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT) }, + { count: Math.min(moreCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT) }, { - one: gtPart`Show ${{ count: Math.min(hiddenCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT) }} more settled thread`, - other: gtPart`Show ${{ count: Math.min(hiddenCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT) }} more settled threads`, + one: gtPart`Show ${{ count: Math.min(moreCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT) }} more settled thread`, + other: gtPart`Show ${{ count: Math.min(moreCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT) }} more settled threads`, }, )}`, ); @@ -428,23 +425,18 @@ export function getThreadListV2OrderedSection(input: { readonly queuedThreadKeys?: ReadonlySet; }): EnvironmentThreadShell[] { const queuedThreadKeys = input.queuedThreadKeys?.size ? input.queuedThreadKeys : undefined; - const threads = input.threads.filter((thread) => { - if (thread.archivedAt !== null || !isListedThreadLineage(thread.lineage)) return false; - if ( - (input.settlementEnvironmentIds?.has(thread.environmentId) ?? true) && - thread.settledOverride === "settled" && - queuedThreadKeys?.has(`${thread.environmentId}:${thread.id}`) !== true - ) { - return false; - } - if ( - (input.snoozeEnvironmentIds?.has(thread.environmentId) ?? true) && - effectiveSnoozed(thread, { now: input.now }) - ) { - return false; - } - return (thread.pinnedAt != null) === (input.section === "pinned"); - }); + const threads = input.threads.filter( + (thread) => + thread.archivedAt === null && + isListedThreadLineage(thread.lineage) && + resolveThreadPlacement(thread, { + now: input.now, + supportsSnooze: input.snoozeEnvironmentIds?.has(thread.environmentId) ?? true, + supportsSettlement: + (input.settlementEnvironmentIds?.has(thread.environmentId) ?? true) && + queuedThreadKeys?.has(`${thread.environmentId}:${thread.id}`) !== true, + }) === input.section, + ); const ordered = input.section === "pinned" ? sortPinnedThreadsByOrderKey(threads) @@ -467,7 +459,7 @@ export interface ThreadListV2Item { export interface ThreadListV2Layout { readonly items: ThreadListV2Item[]; - readonly hiddenSettledCount: number; + readonly moreSettledCount: number; /** The settled rows the shelf may list, before its visible limit. */ readonly listedSettledThreads: ReadonlyArray; readonly workingCount: number; @@ -476,6 +468,8 @@ export interface ThreadListV2Layout { readonly snoozedShelfHeaderIndex: number | null; readonly settledCount: number; readonly settledShelfHeaderIndex: number | null; + readonly hiddenCount: number; + readonly hiddenShelfHeaderIndex: number | null; /** Arm a timeout here to repartition at snooze expiry rather than the next minute tick. */ readonly nextSnoozeWakeAt: string | null; /** Threads listed only because their messages match the search. */ @@ -529,12 +523,29 @@ export interface ThreadListV2SettledShelfListItem { readonly disabled: boolean; } +export interface ThreadListV2HiddenShelfListItem { + readonly type: "v2-hidden-shelf"; + readonly key: "v2-hidden-shelf"; + readonly count: number; + readonly expanded: boolean; + readonly disabled: boolean; +} + +export interface ThreadListV2ShowMoreListItem { + readonly type: "v2-show-more"; + readonly key: "v2-show-more"; + readonly moreCount: number; + readonly state?: "loading" | "failed"; +} + export type ThreadListV2ListItem = | ThreadListV2ThreadListItem | ThreadListV2PendingListItem | ThreadListV2WorkingShelfListItem | ThreadListV2SnoozedShelfListItem - | ThreadListV2SettledShelfListItem; + | ThreadListV2SettledShelfListItem + | ThreadListV2ShowMoreListItem + | ThreadListV2HiddenShelfListItem; export function isThreadListV2ListItem(value: { readonly type: string; @@ -544,7 +555,9 @@ export function isThreadListV2ListItem(value: { value.type === "v2-pending" || value.type === "v2-working-shelf" || value.type === "v2-snoozed-shelf" || - value.type === "v2-settled-shelf" + value.type === "v2-settled-shelf" || + value.type === "v2-show-more" || + value.type === "v2-hidden-shelf" ); } @@ -600,6 +613,19 @@ export function threadListV2ListItemsAreEqual( previous.expanded === item.expanded && previous.disabled === item.disabled ); + case "v2-show-more": + return ( + previous.type === "v2-show-more" && + previous.moreCount === item.moreCount && + previous.state === item.state + ); + case "v2-hidden-shelf": + return ( + previous.type === "v2-hidden-shelf" && + previous.count === item.count && + previous.expanded === item.expanded && + previous.disabled === item.disabled + ); } } @@ -614,7 +640,7 @@ function resolveThreadListV2ItemTimeLabel( variant === "card" && (resolveThreadListV2RowStatus(thread) !== "ready" || item.wokeAt !== null || - threadHasUnseenCompletion(thread)) + hasUnseenCompletion(thread)) ) return ""; const settledTimestamp = @@ -638,6 +664,10 @@ export function buildThreadListV2ListItems(input: { readonly settledCount?: number; readonly settledShelfExpanded?: boolean; readonly settledShelfHeaderIndex?: number | null; + readonly showMoreSettled?: Omit | null; + readonly hiddenCount?: number; + readonly hiddenShelfExpanded?: boolean; + readonly hiddenShelfHeaderIndex?: number | null; readonly snoozeLabelNow?: string; readonly snoozeEnvironmentIds?: ReadonlySet; readonly queuedThreadKeys?: ReadonlySet; @@ -691,7 +721,10 @@ export function buildThreadListV2ListItems(input: { const snoozedShelfHeaderIndex = input.snoozedShelfHeaderIndex ?? null; const settledCount = input.settledCount ?? 0; const settledShelfHeaderIndex = input.settledShelfHeaderIndex ?? null; - const snoozedEnd = settledShelfHeaderIndex ?? threadItems.length; + const hiddenCount = input.hiddenCount ?? 0; + const hiddenShelfHeaderIndex = input.hiddenShelfHeaderIndex ?? null; + const settledEnd = hiddenShelfHeaderIndex ?? threadItems.length; + const snoozedEnd = settledShelfHeaderIndex ?? settledEnd; const workingEnd = snoozedShelfHeaderIndex ?? snoozedEnd; const activeEnd = workingShelfHeaderIndex ?? workingEnd; const result: ThreadListV2ListItem[] = [...pendingItems, ...threadItems.slice(0, activeEnd)]; @@ -724,7 +757,20 @@ export function buildThreadListV2ListItems(input: { expanded: input.settledShelfExpanded !== false, disabled: shelfDisabled, }); - result.push(...threadItems.slice(settledShelfHeaderIndex)); + result.push(...threadItems.slice(settledShelfHeaderIndex, settledEnd)); + } + if (input.showMoreSettled != null) { + result.push({ type: "v2-show-more", key: "v2-show-more", ...input.showMoreSettled }); + } + if (hiddenShelfHeaderIndex !== null && hiddenCount > 0) { + result.push({ + type: "v2-hidden-shelf", + key: "v2-hidden-shelf", + count: hiddenCount, + expanded: input.hiddenShelfExpanded === true, + disabled: shelfDisabled, + }); + result.push(...threadItems.slice(hiddenShelfHeaderIndex)); } return result.map((entry, index) => { if (entry.type !== "v2-thread" && entry.type !== "v2-pending") return entry; @@ -779,6 +825,7 @@ export function buildThreadListV2Items(input: { readonly inboxReturnAt?: (thread: EnvironmentThreadShell) => number | undefined; readonly snoozedShelfExpanded?: boolean; readonly settledShelfExpanded?: boolean; + readonly hiddenShelfExpanded?: boolean; readonly selectedThreadKey?: string | null; readonly queuedThreadKeys?: ReadonlySet; /** Whether the shelf may list a settled row yet; older settled rows load in pages. */ @@ -810,6 +857,7 @@ export function buildThreadListV2Items(input: { const working: EnvironmentThreadShell[] = []; const settled: EnvironmentThreadShell[] = []; const snoozed: EnvironmentThreadShell[] = []; + const hidden: EnvironmentThreadShell[] = []; let nextSnoozeWakeAt: string | null = null; const queuedThreadKeys = input.queuedThreadKeys?.size ? input.queuedThreadKeys : undefined; const listedThreads = input.threads.filter( @@ -843,29 +891,29 @@ export function buildThreadListV2Items(input: { if (input.matchedThreadKeys?.has(key) !== true) continue; contentOnlyThreadKeys.add(key); } - const supportsSettlement = input.settlementEnvironmentIds?.has(thread.environmentId) ?? true; - const supportsSnooze = input.snoozeEnvironmentIds?.has(thread.environmentId) ?? true; - if (supportsSnooze && effectiveSnoozed(thread, { now })) { - snoozed.push(thread); - if ( - thread.snoozedUntil != null && - (nextSnoozeWakeAt === null || - parseTimestampMs(thread.snoozedUntil) < parseTimestampMs(nextSnoozeWakeAt)) - ) { - nextSnoozeWakeAt = thread.snoozedUntil; - } - continue; + const placement = resolveThreadPlacement(thread, { + now, + supportsSnooze: input.snoozeEnvironmentIds?.has(thread.environmentId) ?? true, + supportsSettlement: + (input.settlementEnvironmentIds?.has(thread.environmentId) ?? true) && + queuedThreadKeys?.has(`${thread.environmentId}:${thread.id}`) !== true, + }); + if ( + placement === "snoozed" && + thread.snoozedUntil != null && + (nextSnoozeWakeAt === null || + parseTimestampMs(thread.snoozedUntil) < parseTimestampMs(nextSnoozeWakeAt)) + ) { + nextSnoozeWakeAt = thread.snoozedUntil; } - const hasQueuedMessages = - queuedThreadKeys?.has(`${thread.environmentId}:${thread.id}`) === true; - if (supportsSettlement && thread.settledOverride === "settled" && !hasQueuedMessages) { - settled.push(thread); - } else if (thread.pinnedAt != null) { - pinned.push(thread); - } else if (workingShelfEnabled && (input.isWorking ?? isThreadWorking)(thread)) { + if ( + placement === "active" && + workingShelfEnabled && + (input.isWorking ?? isThreadWorking)(thread) + ) { working.push(thread); } else { - active.push(thread); + ({ hidden, snoozed, settled, pinned, active })[placement].push(thread); } } @@ -873,7 +921,7 @@ export function buildThreadListV2Items(input: { // Searching lists every match by rank across shelves, as the palette and // the web sidebar do, then threads listed for their messages in the // server's order. Each row keeps its shelf's look. - const slim = new Set([...snoozed, ...settled]); + const slim = new Set([...snoozed, ...settled, ...hidden]); const snoozedThreads = new Set(snoozed); const pinnedThreads = new Set(pinned); const threadByKey = new Map( @@ -896,7 +944,7 @@ export function buildThreadListV2Items(input: { wokeAt: slim.has(thread) ? null : resolveThreadListV2WokeAt(thread, { now }), isLast: index === results.length - 1, })), - hiddenSettledCount: 0, + moreSettledCount: 0, listedSettledThreads: [], workingCount: 0, workingShelfHeaderIndex: null, @@ -904,6 +952,8 @@ export function buildThreadListV2Items(input: { snoozedShelfHeaderIndex: null, settledCount: 0, settledShelfHeaderIndex: null, + hiddenCount: 0, + hiddenShelfHeaderIndex: null, nextSnoozeWakeAt, contentOnlyThreadKeys, }; @@ -930,6 +980,13 @@ export function buildThreadListV2Items(input: { : orderedSnoozed.filter( (thread) => `${thread.environmentId}:${thread.id}` === selectedThreadKey, ); + const orderedHidden = sortThreadsForListV2(hidden); + const visibleHidden = + input.hiddenShelfExpanded === true + ? orderedHidden + : orderedHidden.filter( + (thread) => `${thread.environmentId}:${thread.id}` === selectedThreadKey, + ); const orderedSettled = sortSettledThreadsReusingLast(settled); const listedSettled = input.isListedSettled === undefined @@ -1013,13 +1070,24 @@ export function buildThreadListV2Items(input: { isLast: false, }); } + const hiddenShelfHeaderIndex = orderedHidden.length > 0 ? items.length : null; + for (const thread of visibleHidden) { + items.push({ + thread, + variant: "slim", + snoozed: false, + pinned: false, + wokeAt: null, + isLast: false, + }); + } const last = items.at(-1); if (last) { items[items.length - 1] = { ...last, isLast: true }; } return { items, - hiddenSettledCount: Math.max(0, settledTotal - pagedSettled.length), + moreSettledCount: Math.max(0, settledTotal - pagedSettled.length), listedSettledThreads: listedSettled, workingCount: orderedWorking.length, workingShelfHeaderIndex, @@ -1027,6 +1095,8 @@ export function buildThreadListV2Items(input: { snoozedShelfHeaderIndex, settledCount: settledTotal, settledShelfHeaderIndex, + hiddenCount: orderedHidden.length, + hiddenShelfHeaderIndex, nextSnoozeWakeAt, contentOnlyThreadKeys, }; diff --git a/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts b/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts index 13ba59cce2cff..cf082eb08eae9 100644 --- a/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts +++ b/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts @@ -10,6 +10,8 @@ export function useThreadListV2ShelfPreferences() { const loaded = AsyncResult.isSuccess(preferencesResult); const snoozedShelfExpanded = loaded && preferencesResult.value.threadListSnoozedShelfExpanded === true; + const hiddenShelfExpanded = + loaded && preferencesResult.value.threadListHiddenShelfExpanded === true; const settledShelfExpanded = loaded && preferencesResult.value.threadListSettledShelfExpanded === true; const workingShelfEnabled = loaded && preferencesResult.value.workingShelfEnabled !== false; @@ -25,6 +27,14 @@ export function useThreadListV2ShelfPreferences() { }), }); }; + const toggleHiddenShelf = () => { + if (!loaded) return; + void savePreferences({ + transform: (current) => ({ + threadListHiddenShelfExpanded: current.threadListHiddenShelfExpanded !== true, + }), + }); + }; const toggleSettledShelf = () => { if (!loaded) return; void savePreferences({ @@ -44,10 +54,12 @@ export function useThreadListV2ShelfPreferences() { return { loaded, + hiddenShelfExpanded, settledShelfExpanded, snoozedShelfExpanded, workingShelfEnabled, workingShelfExpanded, + toggleHiddenShelf, toggleSettledShelf, toggleSnoozedShelf, toggleWorkingShelf, diff --git a/apps/mobile/src/features/threads/useThreadListV2.test.tsx b/apps/mobile/src/features/threads/useThreadListV2.test.tsx index 7eac8955efa14..686dfee462c2b 100644 --- a/apps/mobile/src/features/threads/useThreadListV2.test.tsx +++ b/apps/mobile/src/features/threads/useThreadListV2.test.tsx @@ -59,6 +59,7 @@ it("reuses a large thread list across tab renders and updates when its inputs ch workingShelfExpanded: false, snoozedShelfExpanded: false, settledShelfExpanded: true, + hiddenShelfExpanded: false, selectedThreadKey: null, }; const seen: Array> = []; diff --git a/apps/mobile/src/features/threads/useThreadListV2.ts b/apps/mobile/src/features/threads/useThreadListV2.ts index 3df795f3f5429..8c2d1ed74cc9d 100644 --- a/apps/mobile/src/features/threads/useThreadListV2.ts +++ b/apps/mobile/src/features/threads/useThreadListV2.ts @@ -85,6 +85,7 @@ export function useThreadListV2(input: { readonly workingShelfExpanded: boolean; readonly snoozedShelfExpanded: boolean; readonly settledShelfExpanded: boolean; + readonly hiddenShelfExpanded: boolean; readonly selectedThreadKey: string | null; }) { // Rows hold resolved text, so two builds of an unchanged row compare equal; a language switch rebuilds them. @@ -174,6 +175,7 @@ export function useThreadListV2(input: { isWorking: inbox.isWorking, snoozedShelfExpanded: input.snoozedShelfExpanded, settledShelfExpanded: input.settledShelfExpanded, + hiddenShelfExpanded: input.hiddenShelfExpanded, selectedThreadKey: input.selectedThreadKey, isListedSettled: isListed, unloadedSettledCount: unloadedCount( @@ -206,6 +208,7 @@ export function useThreadListV2(input: { inbox.isWorking, input.snoozedShelfExpanded, input.settledShelfExpanded, + input.hiddenShelfExpanded, input.selectedThreadKey, isListed, unloadedCount, @@ -246,6 +249,20 @@ export function useThreadListV2(input: { settledCount: layout.settledCount, settledShelfExpanded: input.settledShelfExpanded, settledShelfHeaderIndex: layout.settledShelfHeaderIndex, + showMoreSettled: + input.settledShelfExpanded && layout.moreSettledCount > 0 + ? { + moreCount: layout.moreSettledCount, + ...(olderSettledShelf.loading + ? { state: "loading" as const } + : olderSettledShelf.failed + ? { state: "failed" as const } + : {}), + } + : null, + hiddenCount: layout.hiddenCount, + hiddenShelfExpanded: input.hiddenShelfExpanded, + hiddenShelfHeaderIndex: layout.hiddenShelfHeaderIndex, snoozeLabelNow: threadListMinute(input.now), snoozeEnvironmentIds: input.snoozeEnvironmentIds, queuedThreadKeys: input.queuedThreadKeys, @@ -259,6 +276,9 @@ export function useThreadListV2(input: { input.workingShelfExpanded, input.snoozedShelfExpanded, input.settledShelfExpanded, + olderSettledShelf.loading, + olderSettledShelf.failed, + input.hiddenShelfExpanded, input.now, input.snoozeEnvironmentIds, input.queuedThreadKeys, diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json index 49dd220c41e63..5f68cf32a40c3 100644 --- a/apps/mobile/src/i18n/translations/de.json +++ b/apps/mobile/src/i18n/translations/de.json @@ -11029,13 +11029,13 @@ "667bf02685203ecc": "Threads anordnen schließen", "7f26d39b2e4645a9": "Wird geladen", "b655b62eded46c1a": "Ältere Threads konnten nicht geladen werden. Erneut versuchen", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "one": ["Mehr anzeigen (", ["count"], " erledigter ausgeblendet)"], - "other": ["Mehr anzeigen (", ["count"], " erledigte ausgeblendet)"] + "one": ["", ["count"], " weiteren anzeigen"], + "other": ["", ["count"], " weitere anzeigen"] } ] ], @@ -12859,5 +12859,31 @@ "0ee67c40e79362f8": "Arbeitsordner fehlt", "2df76011417604dd": "Dieser Thread wird in einem leeren Ordner fortgesetzt. Der Gesprächsverlauf bleibt erhalten.", "9ed416604a3e6a5f": "Der Gesprächsverlauf bleibt im Thread. Die Dateien bleiben in ihrem aktuellen Ordner.", - "6837963e9a802a65": "Aktueller Ordner" + "6837963e9a802a65": "Aktueller Ordner", + "fa0786a9170b1cd7": "Ausgeblendeter Thread", + "2bde1c10f853e8f3": "Ausblenden", + "0ec186ae0b93c05d": "Thread konnte nicht eingeblendet werden", + "484712e66df5b34e": "Ausgeblendet", + "45e455c01ccff7eb": "Ausgeblendet", + "e6e90f962f988893": "Der Server dieser Umgebung unterstützt das Ausblenden noch nicht. Aktualisiere den Server, um Ausblenden zu verwenden.", + "001bab0c1e11c35b": "Ausblenden konnte nicht rückgängig gemacht werden", + "bdf094b13f693010": "Klappt die ausgeblendeten Threads ein.", + "2bb41f87277a0f97": "Wird eingeblendet...", + "eda55223d4551b4f": "Einblenden", + "014ff8a44a9172fb": "Thread konnte nicht ausgeblendet werden", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "one": [["count"], " ausgeblendeter Thread"], + "other": [["count"], " ausgeblendete Threads"] + } + ] + ], + "d1f318553ce62566": "Der Thread konnte nicht ausgeblendet werden.", + "c05ce0e4ca4a36fb": "Klappt die ausgeblendeten Threads aus.", + "6f0142fed67cd509": "Der Thread konnte nicht eingeblendet werden.", + "bb0466f9f0d75ee2": [["title"], " einblenden"], + "0f622958cbc4fa89": "Öffnet den Thread. Nach links wischen zum Einblenden." } diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json index 4600cccf88ab2..9b02742e7a2da 100644 --- a/apps/mobile/src/i18n/translations/en.json +++ b/apps/mobile/src/i18n/translations/en.json @@ -10815,13 +10815,13 @@ "667bf02685203ecc": "Close arrange threads", "7f26d39b2e4645a9": "Loading", "b655b62eded46c1a": "Could not load older threads. Retry", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "one": ["Show more (", ["count"], " settled hidden)"], - "other": ["Show more (", ["count"], " settled hidden)"] + "one": ["Show ", ["count"], " more"], + "other": ["Show ", ["count"], " more"] } ] ], @@ -12614,5 +12614,31 @@ "0ee67c40e79362f8": "Workspace folder missing", "2df76011417604dd": "This thread will continue in an empty folder. Its conversation stays here.", "9ed416604a3e6a5f": "The conversation stays with the thread. Files stay in their current folder.", - "6837963e9a802a65": "Current folder" + "6837963e9a802a65": "Current folder", + "fa0786a9170b1cd7": "Hidden thread", + "2bde1c10f853e8f3": "Hide", + "0ec186ae0b93c05d": "Could not unhide thread", + "484712e66df5b34e": "Hidden", + "45e455c01ccff7eb": "Hidden", + "e6e90f962f988893": "This environment's server does not support hiding yet. Update the server to use Hide.", + "001bab0c1e11c35b": "Could not undo hide", + "bdf094b13f693010": "Collapses the hidden threads.", + "2bb41f87277a0f97": "Unhiding...", + "eda55223d4551b4f": "Unhide", + "014ff8a44a9172fb": "Could not hide thread", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "one": [["count"], " hidden thread"], + "other": [["count"], " hidden threads"] + } + ] + ], + "d1f318553ce62566": "The thread could not be hidden.", + "c05ce0e4ca4a36fb": "Expands the hidden threads.", + "6f0142fed67cd509": "The thread could not be unhidden.", + "bb0466f9f0d75ee2": ["Unhide ", ["title"]], + "0f622958cbc4fa89": "Opens the thread. Swipe left to unhide." } diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json index a1475d47005dd..080c8b5c735b7 100644 --- a/apps/mobile/src/i18n/translations/es.json +++ b/apps/mobile/src/i18n/translations/es.json @@ -11006,13 +11006,13 @@ "667bf02685203ecc": "Cerrar Organizar hilos", "7f26d39b2e4645a9": "Cargando", "b655b62eded46c1a": "No se pudieron cargar los hilos anteriores. Reintentar", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "one": ["Mostrar más (", ["count"], " resuelto oculto)"], - "other": ["Mostrar más (", ["count"], " resueltos ocultos)"] + "one": ["Mostrar ", ["count"], " más"], + "other": ["Mostrar ", ["count"], " más"] } ] ], @@ -12822,5 +12822,31 @@ "0ee67c40e79362f8": "Falta la carpeta de trabajo", "2df76011417604dd": "Este hilo continuará en una carpeta vacía. La conversación se queda aquí.", "9ed416604a3e6a5f": "La conversación sigue en el hilo. Los archivos se quedan en su carpeta actual.", - "6837963e9a802a65": "Carpeta actual" + "6837963e9a802a65": "Carpeta actual", + "fa0786a9170b1cd7": "Hilo oculto", + "2bde1c10f853e8f3": "Ocultar", + "0ec186ae0b93c05d": "No se pudo mostrar el hilo", + "484712e66df5b34e": "Ocultos", + "45e455c01ccff7eb": "Oculto", + "e6e90f962f988893": "El servidor de este entorno aún no admite ocultar hilos. Actualiza el servidor para usar Ocultar.", + "001bab0c1e11c35b": "No se pudo deshacer el ocultado", + "bdf094b13f693010": "Contrae los hilos ocultos.", + "2bb41f87277a0f97": "Mostrando...", + "eda55223d4551b4f": "Mostrar", + "014ff8a44a9172fb": "No se pudo ocultar el hilo", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "one": [["count"], " hilo oculto"], + "other": [["count"], " hilos ocultos"] + } + ] + ], + "d1f318553ce62566": "No se pudo ocultar el hilo.", + "c05ce0e4ca4a36fb": "Expande los hilos ocultos.", + "6f0142fed67cd509": "No se pudo mostrar el hilo.", + "bb0466f9f0d75ee2": ["Mostrar ", ["title"]], + "0f622958cbc4fa89": "Abre el hilo. Desliza a la izquierda para mostrarlo." } diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json index 21b7bc45adcfa..4d3fe81240de6 100644 --- a/apps/mobile/src/i18n/translations/fr.json +++ b/apps/mobile/src/i18n/translations/fr.json @@ -11052,13 +11052,13 @@ "667bf02685203ecc": "Fermer l’organisation des fils", "7f26d39b2e4645a9": "Chargement", "b655b62eded46c1a": "Impossible de charger les fils plus anciens. Réessayer", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "one": ["Afficher plus (", ["count"], " clos masqué)"], - "other": ["Afficher plus (", ["count"], " clos masqués)"] + "one": ["Afficher ", ["count"], " de plus"], + "other": ["Afficher ", ["count"], " de plus"] } ] ], @@ -12867,5 +12867,31 @@ "0ee67c40e79362f8": "Dossier de travail introuvable", "2df76011417604dd": "Cette conversation continuera dans un dossier vide. Son historique reste ici.", "9ed416604a3e6a5f": "L’historique de la conversation est conservé. Les fichiers restent dans leur dossier actuel.", - "6837963e9a802a65": "Dossier actuel" + "6837963e9a802a65": "Dossier actuel", + "fa0786a9170b1cd7": "Fil masqué", + "2bde1c10f853e8f3": "Masquer", + "0ec186ae0b93c05d": "Impossible d’afficher le fil", + "484712e66df5b34e": "Masqués", + "45e455c01ccff7eb": "Masqué", + "e6e90f962f988893": "Le serveur de cet environnement ne permet pas encore de masquer. Mettez à jour le serveur pour utiliser Masquer.", + "001bab0c1e11c35b": "Impossible d’annuler le masquage", + "bdf094b13f693010": "Réduit les fils masqués.", + "2bb41f87277a0f97": "Affichage...", + "eda55223d4551b4f": "Afficher", + "014ff8a44a9172fb": "Impossible de masquer le fil", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "one": [["count"], " fil masqué"], + "other": [["count"], " fils masqués"] + } + ] + ], + "d1f318553ce62566": "Le fil n’a pas pu être masqué.", + "c05ce0e4ca4a36fb": "Développe les fils masqués.", + "6f0142fed67cd509": "Le fil n’a pas pu être affiché.", + "bb0466f9f0d75ee2": ["Afficher ", ["title"]], + "0f622958cbc4fa89": "Ouvre le fil. Balayez vers la gauche pour l’afficher." } diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json index 370a9662fae34..a32221a288fab 100644 --- a/apps/mobile/src/i18n/translations/ja.json +++ b/apps/mobile/src/i18n/translations/ja.json @@ -10359,12 +10359,12 @@ "667bf02685203ecc": "スレッドの並べ替えを閉じる", "7f26d39b2e4645a9": "読み込み中", "b655b62eded46c1a": "以前のスレッドを読み込めませんでした。再試行", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "other": ["さらに表示 (対応済み ", ["count"], " 件を非表示)"] + "other": ["さらに ", ["count"], " 件表示"] } ] ], @@ -12100,5 +12100,30 @@ "0ee67c40e79362f8": "作業フォルダーが見つかりません", "2df76011417604dd": "このスレッドは空のフォルダーで続きます。会話履歴はここに残ります。", "9ed416604a3e6a5f": "会話履歴はスレッドに残ります。ファイルは現在のフォルダーに残ります。", - "6837963e9a802a65": "現在のフォルダー" + "6837963e9a802a65": "現在のフォルダー", + "fa0786a9170b1cd7": "スレッドを非表示にしました", + "2bde1c10f853e8f3": "非表示", + "0ec186ae0b93c05d": "スレッドを再表示できませんでした", + "484712e66df5b34e": "非表示", + "45e455c01ccff7eb": "非表示", + "e6e90f962f988893": "この環境のサーバーはまだ非表示に対応していません。非表示を使うにはサーバーを更新してください。", + "001bab0c1e11c35b": "非表示を元に戻せませんでした", + "bdf094b13f693010": "非表示のスレッドを折りたたみます。", + "2bb41f87277a0f97": "再表示しています...", + "eda55223d4551b4f": "再表示", + "014ff8a44a9172fb": "スレッドを非表示にできませんでした", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "other": ["非表示のスレッド ", ["count"], " 件"] + } + ] + ], + "d1f318553ce62566": "スレッドを非表示にできませんでした。", + "c05ce0e4ca4a36fb": "非表示のスレッドを展開します。", + "6f0142fed67cd509": "スレッドを再表示できませんでした。", + "bb0466f9f0d75ee2": [["title"], " を再表示"], + "0f622958cbc4fa89": "スレッドを開きます。左にスワイプすると再表示します。" } diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json index d976a80ccea75..e0b2772735fa7 100644 --- a/apps/mobile/src/i18n/translations/ko.json +++ b/apps/mobile/src/i18n/translations/ko.json @@ -10276,12 +10276,12 @@ "667bf02685203ecc": "스레드 정렬 닫기", "7f26d39b2e4645a9": "불러오는 중", "b655b62eded46c1a": "이전 스레드를 불러올 수 없습니다. 다시 시도", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "other": ["더 보기(정리됨 ", ["count"], "개 숨김)"] + "other": ["", ["count"], "개 더 보기"] } ] ], @@ -12014,5 +12014,30 @@ "0ee67c40e79362f8": "작업 폴더를 찾을 수 없음", "2df76011417604dd": "이 대화는 빈 폴더에서 계속됩니다. 대화 기록은 여기에 남습니다.", "9ed416604a3e6a5f": "대화 기록은 유지됩니다. 파일은 현재 폴더에 남습니다.", - "6837963e9a802a65": "현재 폴더" + "6837963e9a802a65": "현재 폴더", + "fa0786a9170b1cd7": "스레드를 숨김", + "2bde1c10f853e8f3": "숨기기", + "0ec186ae0b93c05d": "스레드 숨김을 해제할 수 없습니다", + "484712e66df5b34e": "숨김", + "45e455c01ccff7eb": "숨김", + "e6e90f962f988893": "이 환경의 서버는 아직 숨기기를 지원하지 않습니다. 숨기기를 사용하려면 서버를 업데이트하세요.", + "001bab0c1e11c35b": "숨기기를 실행 취소할 수 없습니다", + "bdf094b13f693010": "숨긴 스레드를 접습니다.", + "2bb41f87277a0f97": "숨김 해제하는 중...", + "eda55223d4551b4f": "숨김 해제", + "014ff8a44a9172fb": "스레드를 숨길 수 없습니다", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "other": ["숨긴 스레드 ", ["count"], "개"] + } + ] + ], + "d1f318553ce62566": "스레드를 숨길 수 없습니다.", + "c05ce0e4ca4a36fb": "숨긴 스레드를 펼칩니다.", + "6f0142fed67cd509": "스레드 숨김을 해제할 수 없습니다.", + "bb0466f9f0d75ee2": [["title"], " 숨김 해제"], + "0f622958cbc4fa89": "스레드를 엽니다. 숨김을 해제하려면 왼쪽으로 스와이프하세요." } diff --git a/apps/mobile/src/i18n/translations/pl.json b/apps/mobile/src/i18n/translations/pl.json index cdc23d7de74e1..a60d4efc70d24 100644 --- a/apps/mobile/src/i18n/translations/pl.json +++ b/apps/mobile/src/i18n/translations/pl.json @@ -11987,15 +11987,15 @@ "667bf02685203ecc": "Zamknij uporządkowanie wątków", "7f26d39b2e4645a9": "Ładowanie", "b655b62eded46c1a": "Nie udało się załadować starszych wątków. Ponów", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "few": ["Pokaż więcej (", ["count"], " dokończone ukryte)"], - "many": ["Pokaż więcej (", ["count"], " dokończonych ukrytych)"], - "one": ["Pokaż więcej (", ["count"], " dokończony ukryty)"], - "other": ["Pokaż więcej (", ["count"], " dokończonych ukrytych)"] + "one": ["Pokaż ", ["count"], " więcej"], + "few": ["Pokaż ", ["count"], " więcej"], + "many": ["Pokaż ", ["count"], " więcej"], + "other": ["Pokaż ", ["count"], " więcej"] } ] ], @@ -13858,5 +13858,33 @@ "0ee67c40e79362f8": "Brak folderu roboczego", "2df76011417604dd": "Ten wątek będzie kontynuowany w pustym folderze. Historia rozmowy zostanie tutaj.", "9ed416604a3e6a5f": "Historia rozmowy zostanie w wątku. Pliki pozostaną w bieżącym folderze.", - "6837963e9a802a65": "Bieżący folder" + "6837963e9a802a65": "Bieżący folder", + "fa0786a9170b1cd7": "Wątek ukryty", + "2bde1c10f853e8f3": "Ukryj", + "0ec186ae0b93c05d": "Nie udało się pokazać wątku", + "484712e66df5b34e": "Ukryte", + "45e455c01ccff7eb": "Ukryty", + "e6e90f962f988893": "Serwer tego środowiska nie obsługuje jeszcze ukrywania. Zaktualizuj serwer, aby użyć Ukryj.", + "001bab0c1e11c35b": "Nie udało się cofnąć ukrycia", + "bdf094b13f693010": "Zwija ukryte wątki.", + "2bb41f87277a0f97": "Pokazywanie...", + "eda55223d4551b4f": "Pokaż", + "014ff8a44a9172fb": "Nie udało się ukryć wątku", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "few": [["count"], " ukryte wątki"], + "many": [["count"], " ukrytych wątków"], + "one": [["count"], " ukryty wątek"], + "other": [["count"], " ukrytych wątków"] + } + ] + ], + "d1f318553ce62566": "Nie udało się ukryć wątku.", + "c05ce0e4ca4a36fb": "Rozwija ukryte wątki.", + "6f0142fed67cd509": "Nie udało się pokazać wątku.", + "bb0466f9f0d75ee2": ["Pokaż ", ["title"]], + "0f622958cbc4fa89": "Otwiera wątek. Przesuń w lewo, aby pokazać." } diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json index 5b61830484fd2..31e9e597ba1e5 100644 --- a/apps/mobile/src/i18n/translations/pt-BR.json +++ b/apps/mobile/src/i18n/translations/pt-BR.json @@ -11001,13 +11001,13 @@ "667bf02685203ecc": "Fechar organização de threads", "7f26d39b2e4645a9": "Carregando", "b655b62eded46c1a": "Não foi possível carregar threads mais antigas. Tentar novamente", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "one": ["Mostrar mais (", ["count"], " concluída oculta)"], - "other": ["Mostrar mais (", ["count"], " concluídas ocultas)"] + "one": ["Mostrar mais ", ["count"]], + "other": ["Mostrar mais ", ["count"]] } ] ], @@ -12814,5 +12814,31 @@ "0ee67c40e79362f8": "Pasta de trabalho ausente", "2df76011417604dd": "Esta conversa continuará em uma pasta vazia. O histórico permanece aqui.", "9ed416604a3e6a5f": "O histórico da conversa é mantido. Os arquivos ficam na pasta atual.", - "6837963e9a802a65": "Pasta atual" + "6837963e9a802a65": "Pasta atual", + "fa0786a9170b1cd7": "Thread oculta", + "2bde1c10f853e8f3": "Ocultar", + "0ec186ae0b93c05d": "Não foi possível reexibir a thread", + "484712e66df5b34e": "Ocultas", + "45e455c01ccff7eb": "Oculta", + "e6e90f962f988893": "O servidor deste ambiente ainda não oferece suporte para ocultar. Atualize o servidor para usar Ocultar.", + "001bab0c1e11c35b": "Não foi possível desfazer o ocultar", + "bdf094b13f693010": "Recolhe as threads ocultas.", + "2bb41f87277a0f97": "Reexibindo...", + "eda55223d4551b4f": "Reexibir", + "014ff8a44a9172fb": "Não foi possível ocultar a thread", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "one": [["count"], " thread oculta"], + "other": [["count"], " threads ocultas"] + } + ] + ], + "d1f318553ce62566": "Não foi possível ocultar a thread.", + "c05ce0e4ca4a36fb": "Expande as threads ocultas.", + "6f0142fed67cd509": "Não foi possível reexibir a thread.", + "bb0466f9f0d75ee2": ["Reexibir ", ["title"]], + "0f622958cbc4fa89": "Abre a thread. Deslize para a esquerda para reexibir." } diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json index 71d678a0eb19f..b032983b0e0be 100644 --- a/apps/mobile/src/i18n/translations/ru.json +++ b/apps/mobile/src/i18n/translations/ru.json @@ -11756,15 +11756,15 @@ "667bf02685203ecc": "Закрыть упорядочивание тредов", "7f26d39b2e4645a9": "Загрузка", "b655b62eded46c1a": "Не удалось загрузить старые треды. Повторить", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "few": ["Показать ещё (скрыто ", ["count"], " разобранных)"], - "many": ["Показать ещё (скрыто ", ["count"], " разобранных)"], - "one": ["Показать ещё (скрыт ", ["count"], " разобранный)"], - "other": ["Показать ещё (скрыто ", ["count"], " разобранного)"] + "one": ["Показать ещё ", ["count"]], + "few": ["Показать ещё ", ["count"]], + "many": ["Показать ещё ", ["count"]], + "other": ["Показать ещё ", ["count"]] } ] ], @@ -13626,5 +13626,33 @@ "0ee67c40e79362f8": "Рабочая папка недоступна", "2df76011417604dd": "Эта ветка продолжится в пустой папке. История разговора сохранится здесь.", "9ed416604a3e6a5f": "История разговора сохранится в ветке. Файлы останутся в текущей папке.", - "6837963e9a802a65": "Текущая папка" + "6837963e9a802a65": "Текущая папка", + "fa0786a9170b1cd7": "Тред скрыт", + "2bde1c10f853e8f3": "Скрыть", + "0ec186ae0b93c05d": "Не удалось показать тред", + "484712e66df5b34e": "Скрытые", + "45e455c01ccff7eb": "Скрыт", + "e6e90f962f988893": "Сервер этого окружения пока не поддерживает скрытие. Обновите сервер, чтобы использовать «Скрыть».", + "001bab0c1e11c35b": "Не удалось отменить скрытие", + "bdf094b13f693010": "Сворачивает скрытые треды.", + "2bb41f87277a0f97": "Показываем...", + "eda55223d4551b4f": "Показать", + "014ff8a44a9172fb": "Не удалось скрыть тред", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "few": [["count"], " скрытых треда"], + "many": [["count"], " скрытых тредов"], + "one": [["count"], " скрытый тред"], + "other": [["count"], " скрытого треда"] + } + ] + ], + "d1f318553ce62566": "Не удалось скрыть тред.", + "c05ce0e4ca4a36fb": "Разворачивает скрытые треды.", + "6f0142fed67cd509": "Не удалось показать тред.", + "bb0466f9f0d75ee2": ["Показать ", ["title"]], + "0f622958cbc4fa89": "Открывает тред. Смахните влево, чтобы показать." } diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json index 7c2f3a5433fce..4a8e73e7222b8 100644 --- a/apps/mobile/src/i18n/translations/sv.json +++ b/apps/mobile/src/i18n/translations/sv.json @@ -10913,13 +10913,13 @@ "667bf02685203ecc": "Stäng ordna trådar", "7f26d39b2e4645a9": "Läser in", "b655b62eded46c1a": "Kunde inte läsa in äldre trådar. Försök igen", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "one": ["Visa fler (", ["count"], " klar dold)"], - "other": ["Visa fler (", ["count"], " klara dolda)"] + "one": ["Visa ", ["count"], " till"], + "other": ["Visa ", ["count"], " till"] } ] ], @@ -12687,5 +12687,31 @@ "0ee67c40e79362f8": "Arbetsmappen saknas", "2df76011417604dd": "Tråden fortsätter i en tom mapp. Konversationen finns kvar här.", "9ed416604a3e6a5f": "Konversationen följer med tråden. Filerna ligger kvar i den nuvarande mappen.", - "6837963e9a802a65": "Nuvarande mapp" + "6837963e9a802a65": "Nuvarande mapp", + "fa0786a9170b1cd7": "Dold tråd", + "2bde1c10f853e8f3": "Dölj", + "0ec186ae0b93c05d": "Kunde inte visa tråden", + "484712e66df5b34e": "Dolda", + "45e455c01ccff7eb": "Dold", + "e6e90f962f988893": "Den här miljöns server stöder inte att dölja ännu. Uppdatera servern för att använda Dölj.", + "001bab0c1e11c35b": "Kunde inte ångra döljningen", + "bdf094b13f693010": "Fäller ihop de dolda trådarna.", + "2bb41f87277a0f97": "Visar...", + "eda55223d4551b4f": "Visa", + "014ff8a44a9172fb": "Kunde inte dölja tråden", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "one": [["count"], " dold tråd"], + "other": [["count"], " dolda trådar"] + } + ] + ], + "d1f318553ce62566": "Tråden kunde inte döljas.", + "c05ce0e4ca4a36fb": "Fäller ut de dolda trådarna.", + "6f0142fed67cd509": "Tråden kunde inte visas.", + "bb0466f9f0d75ee2": ["Visa ", ["title"]], + "0f622958cbc4fa89": "Öppnar tråden. Svep åt vänster för att visa." } diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json index 4bef677f27afe..8da135d8e03b2 100644 --- a/apps/mobile/src/i18n/translations/zh.json +++ b/apps/mobile/src/i18n/translations/zh.json @@ -10012,12 +10012,12 @@ "667bf02685203ecc": "关闭整理会话", "7f26d39b2e4645a9": "加载中", "b655b62eded46c1a": "无法加载更早的会话,点击重试", - "3869625fab56d674": [ + "9d9449dceadb1b2c": [ [ "count", "plural", { - "other": ["显示更多(已隐藏 ", ["count"], " 个已搞定)"] + "other": ["再显示 ", ["count"], " 个"] } ] ], @@ -11726,5 +11726,30 @@ "0ee67c40e79362f8": "找不到工作区文件夹", "2df76011417604dd": "此对话将在空文件夹中继续,对话记录会保留在这里。", "9ed416604a3e6a5f": "对话记录会随对话保留,文件仍留在原文件夹中。", - "6837963e9a802a65": "当前文件夹" + "6837963e9a802a65": "当前文件夹", + "fa0786a9170b1cd7": "已隐藏的会话", + "2bde1c10f853e8f3": "隐藏", + "0ec186ae0b93c05d": "无法取消隐藏会话", + "484712e66df5b34e": "已隐藏", + "45e455c01ccff7eb": "已隐藏", + "e6e90f962f988893": "此环境的服务器尚不支持隐藏。请更新服务器以使用隐藏。", + "001bab0c1e11c35b": "无法撤销隐藏", + "bdf094b13f693010": "折叠已隐藏的会话。", + "2bb41f87277a0f97": "正在取消隐藏…", + "eda55223d4551b4f": "取消隐藏", + "014ff8a44a9172fb": "无法隐藏会话", + "c3ab6b10bfd4d0de": [ + [ + "count", + "plural", + { + "other": [["count"], " 个已隐藏的会话"] + } + ] + ], + "d1f318553ce62566": "无法隐藏该会话。", + "c05ce0e4ca4a36fb": "展开已隐藏的会话。", + "6f0142fed67cd509": "无法取消隐藏该会话。", + "bb0466f9f0d75ee2": ["取消隐藏 ", ["title"]], + "0f622958cbc4fa89": "打开会话。向左滑动可取消隐藏。" } diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts index b94622e47d16b..2986c18657aac 100644 --- a/apps/mobile/src/persistence/mobile-preferences.ts +++ b/apps/mobile/src/persistence/mobile-preferences.ts @@ -195,6 +195,7 @@ export interface Preferences { }>; readonly threadListSettledShelfExpanded?: boolean; readonly threadListSnoozedShelfExpanded?: boolean; + readonly threadListHiddenShelfExpanded?: boolean; readonly threadListWorkingShelfExpanded?: boolean; readonly threadListFilters?: ThreadListFilters; readonly pullRequestListFilters?: PullRequestListPreferences; @@ -290,6 +291,7 @@ function sanitizePreferences(parsed: Preferences): Preferences { modelFavorites?: Preferences["modelFavorites"]; threadListSettledShelfExpanded?: boolean; threadListSnoozedShelfExpanded?: boolean; + threadListHiddenShelfExpanded?: boolean; threadListWorkingShelfExpanded?: boolean; threadListFilters?: ThreadListFilters; pullRequestListFilters?: PullRequestListPreferences; @@ -478,6 +480,9 @@ function sanitizePreferences(parsed: Preferences): Preferences { if (typeof parsed.threadListSnoozedShelfExpanded === "boolean") { preferences.threadListSnoozedShelfExpanded = parsed.threadListSnoozedShelfExpanded; } + if (typeof parsed.threadListHiddenShelfExpanded === "boolean") { + preferences.threadListHiddenShelfExpanded = parsed.threadListHiddenShelfExpanded; + } if (typeof parsed.threadListWorkingShelfExpanded === "boolean") { preferences.threadListWorkingShelfExpanded = parsed.threadListWorkingShelfExpanded; } diff --git a/apps/mobile/src/state/thread-list-environments.ts b/apps/mobile/src/state/thread-list-environments.ts index 9a2a6f42990ff..421c169c272be 100644 --- a/apps/mobile/src/state/thread-list-environments.ts +++ b/apps/mobile/src/state/thread-list-environments.ts @@ -12,7 +12,7 @@ export type ThreadListProvider = Pick< "instanceId" | "driver" | "enabled" | "displayName" | "accentColor" | "iconUrl" >; -const capabilityKeys = ["threadAutoSettleOptOut"] as const; +const capabilityKeys = ["threadAutoSettleOptOut", "threadHide"] as const; function selectEnvironment(config: ServerConfig, isConnected: boolean) { return { @@ -61,6 +61,7 @@ function collectEnvironments(environments: ReadonlyMap(); const autoSettleOptOutEnvironmentIds = new Set(); + const hideEnvironmentIds = new Set(); const reorderableEnvironmentIds = new Set(); const snoozePresetsByEnvironmentId = new Map(); for (const [ @@ -72,6 +73,7 @@ function collectEnvironments(environments: ReadonlyMap { { taskId: "sleep-600", kind: "command" as const, awaited: true as const }, ], }, + { + ...shell("thread:c-hidden", "project:c", false), + hiddenAt: DateTime.makeUnsafe("2026-01-03T00:00:00Z"), + }, ]; const shellRequests: Array> = []; const service = layerOrchestratorService.pipe( @@ -6263,6 +6267,26 @@ describe("OrchestratorMcpService thread list", () => { }).pipe(Effect.provide(service)), ); + it.effect("filters hidden threads and reports which are hidden", () => + Effect.gen(function* () { + const mcp = yield* OrchestratorMcpService.OrchestratorMcpService; + const projectId = ProjectId.make("project:c"); + const hidden = yield* mcp.listThreads(client, { projectId, hidden: true }); + const shown = yield* mcp.listThreads(client, { projectId, hidden: false }); + assert.deepStrictEqual( + hidden.threads.map((thread) => [thread.threadId, thread.hidden]), + [[ThreadId.make("thread:c-hidden"), true]], + ); + assert.deepStrictEqual( + shown.threads.map((thread) => [thread.threadId, thread.hidden]), + [ + [ThreadId.make("thread:c-settled"), false], + [ThreadId.make("thread:c-awaiting-command"), false], + ], + ); + }).pipe(Effect.provide(service)), + ); + it.effect("builds shells only for the threads on the page", () => Effect.gen(function* () { const mcp = yield* OrchestratorMcpService.OrchestratorMcpService; diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 9786a76fe539c..9e1562077dd5e 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -1088,6 +1088,7 @@ function listItemFromShell( ...threadPullRequests(shell.pullRequests), ...threadSettlement(shell), ...threadSnooze(shell, nowMs), + hidden: shell.hiddenAt != null, pinned: shell.pinnedAt != null, ...threadBackgroundWork(shell), parentThreadId: shell.lineage.parentThreadId, @@ -1168,6 +1169,7 @@ function threadDetail( archived: projection.thread.archivedAt !== null, ...threadSettlement(projection.thread), ...threadSnooze(shell, nowMs), + hidden: shell.hiddenAt != null, pinned: shell.pinnedAt != null, ...threadBackgroundWork(shell), createdAt: DateTime.formatIso(projection.thread.createdAt), @@ -3732,6 +3734,9 @@ const make = Effect.gen(function* () { (thread) => titleContains === undefined || thread.title.toLocaleLowerCase().includes(titleContains), ) + .filter( + (thread) => input.hidden === undefined || (thread.hiddenAt != null) === input.hidden, + ) // Only a snooze that ends later can hold, so the rest skip building a shell. .filter( (thread) => diff --git a/apps/server/src/mcp/toolkits/thread/tools.ts b/apps/server/src/mcp/toolkits/thread/tools.ts index 121a4370fa4dd..9b4bfd24b6b3e 100644 --- a/apps/server/src/mcp/toolkits/thread/tools.ts +++ b/apps/server/src/mcp/toolkits/thread/tools.ts @@ -33,7 +33,7 @@ import * as McpInvocationContext from "../../McpInvocationContext.ts"; const ThreadOrganizeTool = Tool.make("t3_thread_organize", { description: - "Pin, snooze, settle, archive, or mark a thread unread. Omit `threadId` for this thread. `snooze` needs `snoozedUntil`. Settling this thread applies at turn end. A failed turn or queued message leaves it active.", + "Pin, snooze, hide, settle, archive, or mark a thread unread. Omit `threadId` for this thread. `snooze` needs `snoozedUntil`. `hide` keeps it running but out of the list until unhidden. Settling this thread applies at turn end. A failed turn or queued message leaves it active.", parameters: Schema.Struct({ environmentId: OrchestratorMcpEnvironmentTarget, threadId: Schema.optional(ThreadId), @@ -42,6 +42,8 @@ const ThreadOrganizeTool = Tool.make("t3_thread_organize", { "unpin", "snooze", "unsnooze", + "hide", + "unhide", "settle", "unsettle", "archive", diff --git a/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts b/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts index 68e90a7ef267b..ca2c70aab3742 100644 --- a/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts +++ b/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts @@ -2674,6 +2674,154 @@ it.effect("explicit settle clears snooze atomically and stays idempotent after r }).pipe(Effect.provide(layerTest)), ); +const createHideThread = Effect.fn("test.createHideThread")(function* (name: string) { + const orchestrator = yield* Orchestrator.OrchestratorV2; + const threadId = ThreadId.make(`thread:${name}`); + yield* orchestrator.dispatch({ + type: "thread.create", + commandId: CommandId.make(`create-${name}`), + threadId, + projectId: ProjectId.make(`project:${name}`), + title: "Hidden thread", + modelSelection, + runtimeMode: "full-access", + interactionMode: "default", + branch: null, + worktreePath: null, + createdBy: "user", + creationSource: "web", + }); + return threadId; +}); + +it.effect("hide clears pin, snooze and settle, and pin, snooze or unhide bring it back", () => + Effect.gen(function* () { + const orchestrator = yield* Orchestrator.OrchestratorV2; + const projections = yield* ProjectionStore.ProjectionStoreV2; + const threadId = yield* createHideThread("hide-lifecycle"); + const snoozedUntil = DateTime.formatIso(DateTime.add(yield* DateTime.now, { hours: 1 })); + const send = ( + type: "thread.hide" | "thread.unhide" | "thread.settle" | "thread.pin", + round: string, + ) => orchestrator.dispatch({ type, commandId: CommandId.make(`${type}-${round}`), threadId }); + const expectEverywhere = Effect.fn("test.expectEverywhere")(function* ( + expected: Record, + ) { + assert.deepInclude(yield* projections.getThreadShell(threadId), expected); + assert.deepInclude((yield* projections.getThreadProjection(threadId)).thread, expected); + assert.deepInclude( + (yield* orchestrator.getShellSnapshot()).threads.find((thread) => thread.id === threadId), + expected, + ); + }); + + yield* send("thread.settle", "before-hide"); + yield* TestClock.adjust("1 second"); + yield* send("thread.hide", "settled"); + yield* expectEverywhere({ + hiddenAt: yield* DateTime.now, + settledOverride: null, + settledAt: null, + unsettledAt: null, + }); + yield* send("thread.unhide", "settled"); + yield* expectEverywhere({ hiddenAt: null, settledOverride: null }); + + yield* orchestrator.dispatch({ + type: "thread.unsettle", + commandId: CommandId.make("unsettle-before-hide"), + threadId, + reason: "user", + }); + yield* send("thread.hide", "active"); + yield* expectEverywhere({ settledOverride: "active" }); + const settle = yield* send("thread.settle", "hidden").pipe(Effect.flip); + assert(settle._tag === "OrchestratorDispatchError"); + yield* send("thread.unhide", "active"); + + yield* send("thread.pin", "before-hide"); + yield* orchestrator.dispatch({ + type: "thread.snooze", + commandId: CommandId.make("snooze-before-hide"), + threadId, + snoozedUntil, + }); + yield* TestClock.adjust("1 second"); + yield* send("thread.hide", "first"); + const hiddenAt = yield* DateTime.now; + yield* expectEverywhere({ + hiddenAt, + pinnedAt: null, + pinOrderKey: null, + snoozedUntil: null, + snoozedAt: null, + }); + + yield* TestClock.adjust("1 second"); + yield* send("thread.hide", "again"); + yield* expectEverywhere({ hiddenAt }); + + yield* send("thread.unhide", "first"); + yield* expectEverywhere({ hiddenAt: null }); + const unhiddenAt = yield* DateTime.now; + const lastUnhiddenAt = Effect.map( + projections.getAgentAwarenessSnapshot(threadId), + (snapshot) => snapshot.threads[0]?.lastUnhiddenAt, + ); + assert.deepEqual(yield* lastUnhiddenAt, unhiddenAt); + yield* TestClock.adjust("1 second"); + yield* send("thread.unhide", "already-visible"); + assert.deepEqual(yield* lastUnhiddenAt, unhiddenAt); + + yield* send("thread.hide", "before-pin"); + yield* send("thread.pin", "hidden"); + const pinned = yield* projections.getThreadShell(threadId); + assert.isNull(pinned?.hiddenAt); + assert.isNotNull(pinned?.pinnedAt); + assert.deepEqual(yield* lastUnhiddenAt, yield* DateTime.now); + + yield* send("thread.hide", "before-snooze"); + yield* orchestrator.dispatch({ + type: "thread.snooze", + commandId: CommandId.make("snooze-hidden"), + threadId, + snoozedUntil, + }); + yield* expectEverywhere({ hiddenAt: null, snoozedUntil: DateTime.makeUnsafe(snoozedUntil) }); + }).pipe(Effect.provide(layerTest)), +); + +it.effect("a message from another thread's agent leaves a hidden thread hidden", () => + Effect.gen(function* () { + const orchestrator = yield* Orchestrator.OrchestratorV2; + const projections = yield* ProjectionStore.ProjectionStoreV2; + const threadId = yield* createHideThread("hide-messages"); + const otherThreadId = yield* createHideThread("hide-messages-sender"); + yield* orchestrator.dispatch({ + type: "thread.hide", + commandId: CommandId.make("hide-messages-hide"), + threadId, + }); + const hiddenAt = (yield* projections.getThreadShell(threadId))?.hiddenAt; + assert.isNotNull(hiddenAt); + + yield* TestClock.adjust("1 second"); + yield* orchestrator.dispatch({ + type: "message.dispatch", + commandId: CommandId.make("hide-messages-agent"), + threadId, + messageId: MessageId.make("message:hide-messages-agent"), + text: "From another agent", + attachments: [], + dispatchMode: { type: "start_immediately" }, + createdBy: "agent", + creationSource: "mcp", + senderThreadId: otherThreadId, + }); + assert.deepEqual((yield* projections.getThreadShell(threadId))?.hiddenAt, hiddenAt); + }).pipe(Effect.provide(layerTest)), +); + it.effect("keeps a snooze when a live question is cancelled or an approval is answered", () => Effect.gen(function* () { const orchestrator = yield* Orchestrator.OrchestratorV2; diff --git a/apps/server/src/orchestration-v2/Orchestrator.ts b/apps/server/src/orchestration-v2/Orchestrator.ts index 4ea37d7c8614a..21343ab1dcebb 100644 --- a/apps/server/src/orchestration-v2/Orchestrator.ts +++ b/apps/server/src/orchestration-v2/Orchestrator.ts @@ -699,6 +699,8 @@ function commandThreadId(command: OrchestrationV2ServerCommand): ThreadId { case "thread.auto-settle.set": case "thread.pin": case "thread.unpin": + case "thread.hide": + case "thread.unhide": case "thread.pin.reorder": case "thread.active.reorder": case "thread.tag.set": @@ -4659,6 +4661,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio | "thread.auto-settle.set" | "thread.pin" | "thread.unpin" + | "thread.hide" + | "thread.unhide" | "thread.pin.reorder" | "thread.tag.set" | "thread.tool-overrides.set" @@ -4835,6 +4839,13 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio cause: `Thread ${command.threadId} is archived.`, }); } + if (command.type === "thread.settle" && thread.hiddenAt != null) { + return yield* new OrchestratorDispatchError({ + commandId: command.commandId, + commandType: command.type, + cause: `Thread ${command.threadId} is hidden and cannot be settled.`, + }); + } // Reject reorder after unpin so a raced request cannot restore a cleared pin. if (command.type === "thread.pin.reorder" && thread.pinnedAt == null) { return yield* new OrchestratorDispatchError({ @@ -5203,7 +5214,11 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio const run = usageLimitBlockedRun(projection.runs, projection.turnItems, null); const failure = latestRootProviderFailure(run, projection.turnItems); const resetMs = Date.parse(command.limitRecovery.resetAt); - if (command.limitRecovery.snooze === true && resetMs <= DateTime.toEpochMillis(now)) { + if ( + command.limitRecovery.snooze === true && + thread.hiddenAt == null && + resetMs <= DateTime.toEpochMillis(now) + ) { return yield* new OrchestratorDispatchError({ commandId: command.commandId, commandType: command.type, @@ -5394,6 +5409,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio snoozedUntil, limitRecovery: thread.limitRecovery ? { ...thread.limitRecovery, snooze: false } : null, snoozedAt: now, + hiddenAt: null, + lastUnhiddenAt: thread.hiddenAt == null ? thread.lastUnhiddenAt : now, updatedAt: now, }; } @@ -5417,7 +5434,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio } case "thread.pin": { const alreadyPinned = thread.pinnedAt != null; - const promotes = thread.settledOverride === "settled" || thread.snoozedUntil != null; + const promotes = + thread.settledOverride === "settled" || + thread.snoozedUntil != null || + thread.hiddenAt != null; return { ...thread, pinnedAt: alreadyPinned ? thread.pinnedAt : now, @@ -5431,6 +5451,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio snoozedUntil: null, snoozedAt: null, lastSnoozeWakeAt: thread.snoozedUntil == null ? thread.lastSnoozeWakeAt : now, + hiddenAt: null, + lastUnhiddenAt: thread.hiddenAt == null ? thread.lastUnhiddenAt : now, updatedAt: alreadyPinned && !promotes ? thread.updatedAt : now, }; } @@ -5443,6 +5465,38 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio updatedAt: alreadyUnpinned ? thread.updatedAt : now, }; } + case "thread.hide": { + const alreadyHidden = + thread.hiddenAt != null && + thread.pinnedAt == null && + thread.snoozedUntil == null && + thread.settledOverride !== "settled"; + const settled = thread.settledOverride === "settled"; + return { + ...thread, + hiddenAt: thread.hiddenAt ?? now, + pinnedAt: null, + pinOrderKey: null, + snoozedUntil: null, + snoozedAt: null, + settledOverride: settled ? null : thread.settledOverride, + settledAt: settled ? null : thread.settledAt, + unsettledAt: thread.settledOverride === "active" ? thread.unsettledAt : null, + limitRecovery: thread.limitRecovery + ? { ...thread.limitRecovery, snooze: false } + : thread.limitRecovery, + updatedAt: alreadyHidden ? thread.updatedAt : now, + }; + } + case "thread.unhide": { + const alreadyVisible = thread.hiddenAt == null; + return { + ...thread, + hiddenAt: null, + lastUnhiddenAt: alreadyVisible ? thread.lastUnhiddenAt : now, + updatedAt: alreadyVisible ? thread.updatedAt : now, + }; + } case "thread.pin.reorder": { const keyUnchanged = thread.pinOrderKey === command.orderKey; return { @@ -5506,7 +5560,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio ...command.limitRecovery, autoResume: command.limitRecovery.autoResume ?? previousRecovery?.autoResume ?? false, - snooze: command.limitRecovery.snooze ?? previousRecovery?.snooze ?? false, + snooze: + thread.hiddenAt == null && + (command.limitRecovery.snooze ?? previousRecovery?.snooze ?? false), requestId: command.commandId, }; return { @@ -5981,6 +6037,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio return "thread.pinned" as const; case "thread.unpin": return "thread.unpinned" as const; + case "thread.hide": + return "thread.hidden" as const; + case "thread.unhide": + return "thread.unhidden" as const; case "thread.pin.reorder": return "thread.pin-reordered" as const; case "thread.active.reorder": @@ -16833,6 +16893,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio ); if ( thread.settledOverride !== null || + thread.hiddenAt != null || DateTime.toEpochMillis(thread.updatedAt) > DateTime.toEpochMillis(command.snapshotAt) ) { return yield* new OrchestratorDispatchError({ @@ -16975,6 +17036,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio case "thread.auto-settle.set": case "thread.pin": case "thread.unpin": + case "thread.hide": + case "thread.unhide": case "thread.pin.reorder": case "thread.active.reorder": case "thread.tag.set": diff --git a/apps/server/src/orchestration-v2/ProjectionSettlement.test.ts b/apps/server/src/orchestration-v2/ProjectionSettlement.test.ts index 2155c22a75f1c..31ac1c81c3bb8 100644 --- a/apps/server/src/orchestration-v2/ProjectionSettlement.test.ts +++ b/apps/server/src/orchestration-v2/ProjectionSettlement.test.ts @@ -230,6 +230,7 @@ it.effect( ["settled", { settledOverride: "settled" }], ["unsettled", { settledOverride: "active" }], ["pinned", { pinnedAt: old }], + ["hidden", { hiddenAt: old }], ["auto-settle-disabled", { autoSettleDisabledAt: old }], ] satisfies ReadonlyArray]>) { yield* createRun(yield* createThread(name, overrides)); diff --git a/apps/server/src/orchestration-v2/ProjectionStore.test.ts b/apps/server/src/orchestration-v2/ProjectionStore.test.ts index 228c3004ee96c..ad8d44d824abb 100644 --- a/apps/server/src/orchestration-v2/ProjectionStore.test.ts +++ b/apps/server/src/orchestration-v2/ProjectionStore.test.ts @@ -2907,7 +2907,29 @@ const backgroundThreadUpdatesKeepTimestamp = Effect.gen(function* () { occurredAt: DateTime.add(createdAt, { minutes: 55 }), payload: { ...pinned.thread, pinnedAt: null, pinOrderKey: null }, }); - yield* readActivity; + const unpinned = yield* readActivity; + + const hiddenAt = DateTime.add(createdAt, { minutes: 56 }); + yield* store.apply({ + id: EventId.make("event:background-updates:hidden"), + type: "thread.hidden", + threadId, + occurredAt: hiddenAt, + payload: { ...unpinned.thread, hiddenAt }, + }); + const hidden = yield* readActivity; + assert.deepEqual(hidden.thread.hiddenAt, hiddenAt); + yield* assertShellIndexCoversShells(); + + yield* store.apply({ + id: EventId.make("event:background-updates:unhidden"), + type: "thread.unhidden", + threadId, + occurredAt: DateTime.add(createdAt, { minutes: 57 }), + payload: { ...hidden.thread, hiddenAt: null }, + }); + assert.isNull((yield* readActivity).thread.hiddenAt); + yield* assertShellIndexCoversShells(); }); it.effect("SQL projection keeps background thread updates out of updatedAt", () => diff --git a/apps/server/src/orchestration-v2/ProjectionStore.ts b/apps/server/src/orchestration-v2/ProjectionStore.ts index d7ea43543d2bd..4c9c786b1618f 100644 --- a/apps/server/src/orchestration-v2/ProjectionStore.ts +++ b/apps/server/src/orchestration-v2/ProjectionStore.ts @@ -240,6 +240,7 @@ export type ProjectionSettlementCandidate = Pick< | "archivedAt" | "settledOverride" | "pinnedAt" + | "hiddenAt" | "autoSettleDisabledAt" | "snoozedUntil" | "snoozedAt" @@ -547,6 +548,7 @@ export type ActiveThreadListEntry = Pick< | "settledOverride" | "settledAt" | "snoozedUntil" + | "hiddenAt" | "updatedAt" >; @@ -1096,6 +1098,8 @@ export function applyToProjection( case "thread.auto-settle-set": case "thread.pinned": case "thread.unpinned": + case "thread.hidden": + case "thread.unhidden": case "thread.pin-reordered": case "thread.metadata-updated": case "thread.runtime-mode-updated": @@ -1284,11 +1288,13 @@ export type AgentAwarenessThread = ProjectThreadAwarenessV2Input["thread"] & | "archivedAt" | "snoozedUntil" | "snoozedAt" + | "hiddenAt" | "pendingGuestMessageCount" | "activeRunId" | "latestRunId" | "hasActionableProposedPlan" - >; + > & + Pick; type ShellThreadRow = { readonly fork_run_ids_json: string | null; @@ -2084,6 +2090,7 @@ export function threadShellFromProjection( snoozedUntil: projection.thread.snoozedUntil ?? null, snoozedAt: projection.thread.snoozedAt ?? null, pinnedAt: projection.thread.pinnedAt ?? null, + hiddenAt: projection.thread.hiddenAt ?? null, autoSettleDisabledAt: projection.thread.autoSettleDisabledAt ?? null, pinOrderKey: projection.thread.pinOrderKey ?? null, @@ -2393,6 +2400,7 @@ function shellFromState(input: { snoozedUntil: input.state.thread.snoozedUntil ?? null, snoozedAt: input.state.thread.snoozedAt ?? null, pinnedAt: input.state.thread.pinnedAt ?? null, + hiddenAt: input.state.thread.hiddenAt ?? null, autoSettleDisabledAt: input.state.thread.autoSettleDisabledAt ?? null, pinOrderKey: input.state.thread.pinOrderKey ?? null, @@ -2605,6 +2613,8 @@ export const layer: Layer.Layer` SELECT t.thread_id, @@ -10297,7 +10314,8 @@ export const layer: Layer.Layer = new Set< "thread.auto-settle-set", "thread.pinned", "thread.unpinned", + "thread.hidden", + "thread.unhidden", "thread.pin-reordered", "thread.active-reordered", "thread.model-selection-updated", diff --git a/apps/server/src/orchestration-v2/ThreadForkService.ts b/apps/server/src/orchestration-v2/ThreadForkService.ts index 2981b4ccfb519..698062439dfa0 100644 --- a/apps/server/src/orchestration-v2/ThreadForkService.ts +++ b/apps/server/src/orchestration-v2/ThreadForkService.ts @@ -139,6 +139,7 @@ export const layer: Layer.Layer = Layer.succeed( snoozedAt: null, lastSnoozeWakeAt: null, pinnedAt: null, + hiddenAt: null, pinOrderKey: null, activeOrderKey: null, autoSettleDisabledAt: null, diff --git a/apps/server/src/orchestration-v2/ThreadManagementService.ts b/apps/server/src/orchestration-v2/ThreadManagementService.ts index 674145f24210c..bd647222ac7b1 100644 --- a/apps/server/src/orchestration-v2/ThreadManagementService.ts +++ b/apps/server/src/orchestration-v2/ThreadManagementService.ts @@ -1274,6 +1274,7 @@ const make = Effect.gen(function* () { const trySettle = Effect.gen(function* () { const sequence = yield* orchestrator.getThreadEventSequence(input.threadId); const records = yield* getProjectThreadRecords(input, ["runs"]); + if (records.thread.hiddenAt != null) return true; // Settling ends every watch; one the agent started after asking to settle must outlive it. if ( threadPullRequestsOf(records.thread).some( @@ -1375,6 +1376,9 @@ const make = Effect.gen(function* () { "orchestrationV2.threadManagement.settleThread", )(function* (input) { const shell = input.byOwnAgent ? yield* orchestrator.getThreadShell(input.threadId) : null; + if (shell?.hiddenAt != null) { + return { sequence: yield* orchestrator.getThreadEventSequence(input.threadId) }; + } if (shell != null && shell.activeRunId !== null) { yield* settleAfterRun({ projectId: shell.projectId, diff --git a/apps/server/src/orchestration-v2/ThreadSettlementService.ts b/apps/server/src/orchestration-v2/ThreadSettlementService.ts index 829a8e4689f85..f50c01ec475ce 100644 --- a/apps/server/src/orchestration-v2/ThreadSettlementService.ts +++ b/apps/server/src/orchestration-v2/ThreadSettlementService.ts @@ -186,7 +186,9 @@ export function isAutoSettlementCandidate( nowMs: number, ): boolean { if (thread.archivedAt !== null || thread.settledOverride !== null) return false; - if (thread.pinnedAt != null || thread.autoSettleDisabledAt != null) return false; + if (thread.pinnedAt != null || thread.hiddenAt != null || thread.autoSettleDisabledAt != null) { + return false; + } if (thread.pendingRuntimeRequest !== null) return false; // A guest is waiting on the owner; settling would hide the Request. if ((thread.pendingGuestMessageCount ?? 0) > 0) return false; diff --git a/apps/server/src/orchestration-v2/runtimeLayer.test.ts b/apps/server/src/orchestration-v2/runtimeLayer.test.ts index 4ddb221dfaad5..eaa120c9d90a2 100644 --- a/apps/server/src/orchestration-v2/runtimeLayer.test.ts +++ b/apps/server/src/orchestration-v2/runtimeLayer.test.ts @@ -8743,6 +8743,80 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => { }), ); + it.effect("leaves a hidden thread unsettled when its own agent asks to settle", () => + Effect.gen(function* () { + const orchestrator = yield* Orchestrator.OrchestratorV2; + const eventSink = yield* EventSink.EventSinkV2; + const threadManagement = yield* ThreadManagementService.ThreadManagementService; + const projectId = ProjectId.make("runtime-layer-hidden-settle-project"); + const threadId = ThreadId.make("runtime-layer-hidden-settle-thread"); + + yield* orchestrator.dispatch({ + type: "thread.create", + createdBy: "user", + creationSource: "web", + commandId: CommandId.make("runtime-layer-hidden-settle-create"), + threadId, + projectId, + title: "Hidden settle", + modelSelection, + runtimeMode: "full-access", + interactionMode: "default", + branch: null, + worktreePath: "/tmp/runtime-layer-hidden-settle", + }); + yield* orchestrator.dispatch({ + type: "message.dispatch", + createdBy: "user", + creationSource: "web", + commandId: CommandId.make("runtime-layer-hidden-settle-message"), + threadId, + messageId: MessageId.make("runtime-layer-hidden-settle-message"), + text: "Settle this thread when done.", + attachments: [], + modelSelection, + dispatchMode: { type: "start_immediately" }, + }); + const run = (yield* orchestrator.getThreadProjection(threadId)).runs[0]; + if (run === undefined) return yield* Effect.die(new Error("Run missing.")); + + const settleRequest = yield* threadManagement + .settleAfterRun({ projectId, threadId, runId: run.id }) + .pipe(Effect.forkChild); + yield* orchestrator.dispatch({ + type: "thread.hide", + commandId: CommandId.make("runtime-layer-hidden-settle-hide"), + threadId, + }); + const result = yield* threadManagement.settleThread({ + threadId, + commandId: CommandId.make("runtime-layer-hidden-settle-settle"), + byOwnAgent: true, + }); + assert.isTrue("sequence" in result); + + const now = yield* DateTime.now; + yield* eventSink.write({ + commandId: CommandId.make("runtime-layer-hidden-settle-completed"), + events: [ + { + id: EventId.make("runtime-layer-hidden-settle-completed"), + type: "run.updated", + threadId, + runId: run.id, + occurredAt: now, + payload: { ...run, status: "completed", startedAt: now, completedAt: now }, + }, + ], + }); + yield* Fiber.join(settleRequest); + + const thread = (yield* orchestrator.getThreadProjection(threadId)).thread; + assert.isNull(thread.settledOverride); + assert.isNotNull(thread.hiddenAt ?? null); + }), + ); + it.effect("keeps a pull request watch its agent started after asking to settle", () => Effect.gen(function* () { const orchestrator = yield* Orchestrator.OrchestratorV2; @@ -15072,6 +15146,7 @@ it.layer(layerTest)("usage-limit recovery", (it) => { "manual-snooze", "invalid-snooze", "settled", + "hidden", "cancel-resume-keep-snooze", "independent-patches", "expired-snooze", @@ -15257,6 +15332,32 @@ it.layer(layerTest)("usage-limit recovery", (it) => { ); return; } + if (scenario === "hidden") { + const arm = (name: string) => + orchestrator.dispatch({ + type: "thread.metadata.update", + commandId: CommandId.make(`recovery:${name}:hidden`), + threadId, + limitRecovery: { runId: run.id, resetAt, autoResume: true, snooze: true }, + }); + const expectUnsnoozed = Effect.fn("test.expectUnsnoozed")(function* () { + const current = (yield* orchestrator.getThreadProjection(threadId)).thread; + assert.isNull(current.snoozedUntil ?? null); + assert.isNull(current.snoozedAt ?? null); + assert.isNotNull(current.hiddenAt ?? null); + assert.deepInclude(current.limitRecovery, { autoResume: true, snooze: false }); + }); + yield* arm("arm-before-hide"); + yield* orchestrator.dispatch({ + type: "thread.hide", + commandId: CommandId.make("recovery:hide:hidden"), + threadId, + }); + yield* expectUnsnoozed(); + yield* arm("arm"); + yield* expectUnsnoozed(); + return; + } const snooze = scenario === "wake" || scenario === "cancel-resume-keep-snooze"; const autoResume = scenario !== "wake"; const arm = limitRecoveryCommand(shell, autoResume, DateTime.toEpochMillis(now), snooze); diff --git a/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts b/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts index 7209626697c7e..3b87c8d57696f 100644 --- a/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts +++ b/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts @@ -152,6 +152,8 @@ function commandThreadIds(command: OrchestrationV2Command): ReadonlyArray = {}): OrchestrationV2ThreadShell { +type TestThread = OrchestrationV2ThreadShell & + Pick; + +function shell(overrides: Partial = {}): TestThread { return { id: THREAD_ID, projectId: PROJECT_ID, @@ -124,12 +127,14 @@ const decodePublishPayload = Schema.decodeUnknownSync(Schema.fromJsonString(Publ const unused = () => Effect.die("Unexpected test dependency call"); describe("startup agent activity", () => { - it("publishes active work and only terminal runs completed after startup", () => { + it("publishes active work, only terminal runs completed after startup, and hidden threads only while waiting", () => { const startedAt = DateTime.toEpochMillis(DateTime.makeUnsafe(NOW)); const oldCompleted = ThreadId.make("old-completed"); const newCompleted = ThreadId.make("new-completed"); const oldFailed = ThreadId.make("old-failed"); const newFailed = ThreadId.make("new-failed"); + const hiddenWaiting = ThreadId.make("hidden-waiting"); + const hiddenAt = DateTime.makeUnsafe(NOW); const ids = AgentAwarenessRelay.resolveAgentAwarenessRelayActiveThreadIds({ environmentId: EnvironmentId.make("relay-env"), startedAt, @@ -158,9 +163,25 @@ describe("startup agent activity", () => { }), shell({ id: ThreadId.make("idle"), status: "idle" }), shell({ id: ThreadId.make("missing-project"), projectId: ProjectId.make("missing") }), + shell({ id: ThreadId.make("hidden-running"), hiddenAt }), + shell({ + id: ThreadId.make("hidden-failed"), + hiddenAt, + status: "failed", + latestRunCompletedAt: DateTime.makeUnsafe("2026-09-04T12:00:01.000Z"), + }), + shell({ + id: hiddenWaiting, + hiddenAt, + pendingRuntimeRequest: { + id: RuntimeRequestId.make("hidden-request"), + kind: "command", + createdAt: hiddenAt, + }, + }), ], }); - assert.deepStrictEqual(ids, [THREAD_ID, newCompleted, newFailed]); + assert.deepStrictEqual(ids, [THREAD_ID, newCompleted, newFailed, hiddenWaiting]); }); }); @@ -204,7 +225,7 @@ const makeTestRelay = Effect.fnUntraced(function* ( remove: (name) => Effect.sync(() => void values.delete(name)), getOrCreateRandom: unused, }); - const currentShell = yield* Ref.make(shell()); + const currentShell = yield* Ref.make(shell()); const shellReads: ThreadId[] = []; const catchUp = { activitySnapshotReads: 0 }; const threads = ThreadManagementService.ThreadManagementService.of({ @@ -792,6 +813,176 @@ describe("AgentAwarenessRelay", () => { }), ); + it.effect("keeps a hidden thread quiet unless it needs approval or input", () => + Effect.gen(function* () { + const events = yield* Queue.unbounded(); + const pulls = yield* Queue.unbounded(); + const { relay, currentShell, publications } = yield* makeTestRelay({ + domainEvents: Stream.fromEffectRepeat( + Queue.offer(pulls, undefined).pipe(Effect.andThen(Queue.take(events))), + ), + }); + yield* relay.start(); + yield* Queue.take(pulls); + yield* relay.publishThread(THREAD_ID); + const hiddenAt = yield* DateTime.now; + const request = (kind: "command" | "user_input") => ({ + pendingRuntimeRequest: { + id: RuntimeRequestId.make(`hidden-${kind}`), + kind, + createdAt: hiddenAt, + }, + }); + for (const next of [ + shell({ hiddenAt }), + shell({ hiddenAt, ...request("command") }), + shell({ hiddenAt, status: "failed", latestRunCompletedAt: hiddenAt }), + shell({ hiddenAt, ...request("user_input") }), + shell({ hiddenAt, status: "completed", latestRunCompletedAt: hiddenAt }), + ]) { + yield* Ref.set(currentShell, next); + yield* relay.publishThread(THREAD_ID); + yield* TestClock.adjust("5 seconds"); + yield* relay.drain; + } + assert.deepEqual( + publications.map((publication) => publication.state?.phase ?? null), + ["running", null, "waiting_for_approval", null, "waiting_for_input", null], + ); + + const phases = () => publications.map((publication) => publication.state?.phase ?? null); + const emitNow = Effect.fnUntraced(function* ( + type: "thread.hidden" | "thread.unhidden" | "thread.pinned" | "thread.metadata-updated", + next: TestThread, + ) { + yield* Ref.set(currentShell, next); + yield* Queue.offer(events, { + id: EventId.make(`event:${type}:${publications.length}:${next.status}:${next.title}`), + type, + threadId: THREAD_ID, + occurredAt: yield* DateTime.now, + payload: { ...next, lastVisitedAt: null }, + }); + yield* Queue.take(pulls); + yield* relay.drain; + }); + const emit = Effect.fnUntraced(function* ( + type: Parameters[0], + next: TestThread, + ) { + yield* emitNow(type, next); + yield* TestClock.adjust("5 seconds"); + yield* relay.drain; + }); + const update = Effect.fnUntraced(function* (next: TestThread) { + yield* Ref.set(currentShell, next); + yield* relay.publishThread(THREAD_ID); + yield* TestClock.adjust("5 seconds"); + yield* relay.drain; + }); + + const completed = shell({ status: "completed", latestRunCompletedAt: hiddenAt }); + yield* TestClock.adjust("1 second"); + const unhiddenAt = yield* DateTime.now; + yield* emit("thread.unhidden", { ...completed, lastUnhiddenAt: unhiddenAt }); + yield* emit("thread.metadata-updated", { + ...completed, + title: "Renamed thread", + lastUnhiddenAt: unhiddenAt, + }); + assert.lengthOf(publications, 6); + yield* emit("thread.unhidden", shell({ lastUnhiddenAt: yield* DateTime.now })); + assert.deepEqual(phases().slice(6), ["running"]); + + yield* Ref.set(currentShell, shell({ hiddenAt: yield* DateTime.now })); + yield* relay.publishThread(THREAD_ID); + const finishedWhileHidden = shell({ + status: "completed", + latestRunCompletedAt: yield* DateTime.now, + }); + yield* Ref.set(currentShell, { ...finishedWhileHidden, hiddenAt: yield* DateTime.now }); + yield* relay.publishThread(THREAD_ID); + yield* TestClock.adjust("1 second"); + yield* emit("thread.unhidden", { + ...finishedWhileHidden, + lastUnhiddenAt: yield* DateTime.now, + }); + assert.deepEqual(phases().slice(7), [null]); + + const visibleCompletion = shell({ + status: "completed", + latestRunCompletedAt: yield* DateTime.now, + lastUnhiddenAt: unhiddenAt, + }); + yield* update(visibleCompletion); + assert.deepEqual(phases().slice(7), [null, "completed"]); + yield* emit("thread.unhidden", visibleCompletion); + assert.deepEqual(phases().slice(7), [null, "completed"]); + + yield* emit("thread.hidden", { ...visibleCompletion, hiddenAt: yield* DateTime.now }); + yield* update( + shell({ + status: "completed", + latestRunCompletedAt: yield* DateTime.now, + hiddenAt: yield* DateTime.now, + }), + ); + const pinnedAt = yield* DateTime.now; + const pinned = shell({ + status: "completed", + latestRunCompletedAt: (yield* Ref.get(currentShell))?.latestRunCompletedAt ?? null, + pinnedAt, + lastUnhiddenAt: pinnedAt, + }); + yield* emit("thread.pinned", pinned); + yield* emit("thread.metadata-updated", { ...pinned, title: "Pinned thread" }); + assert.deepEqual(phases().slice(9), [null]); + + const heldByBackgroundWork: Partial = { + status: "completed", + latestRunCompletedAt: yield* DateTime.now, + pendingBackgroundTasks: [{ taskId: "watch", kind: "monitor", awaited: true }], + }; + yield* update(shell({ ...heldByBackgroundWork, hiddenAt: yield* DateTime.now })); + yield* emit( + "thread.unhidden", + shell({ ...heldByBackgroundWork, lastUnhiddenAt: yield* DateTime.now }), + ); + assert.deepEqual(phases().slice(9), [null, "running"]); + yield* update( + shell({ + ...heldByBackgroundWork, + pendingBackgroundTasks: [], + lastUnhiddenAt: (yield* Ref.get(currentShell))?.lastUnhiddenAt ?? null, + }), + ); + assert.deepEqual(phases().slice(9), [null, "running", "completed"]); + + const earlierUnhide = (yield* Ref.get(currentShell))?.lastUnhiddenAt ?? null; + yield* update(shell({ lastUnhiddenAt: earlierUnhide })); + const heldCompletion = shell({ + status: "completed", + latestRunCompletedAt: yield* DateTime.now, + lastUnhiddenAt: earlierUnhide, + }); + yield* Ref.set(currentShell, heldCompletion); + yield* relay.publishThread(THREAD_ID); + yield* TestClock.adjust("1 second"); + yield* emitNow("thread.hidden", { ...heldCompletion, hiddenAt: yield* DateTime.now }); + yield* TestClock.adjust("1 second"); + const unhiddenDuringHold = { ...heldCompletion, lastUnhiddenAt: yield* DateTime.now }; + yield* emitNow("thread.unhidden", unhiddenDuringHold); + yield* update({ + ...unhiddenDuringHold, + settledOverride: "settled", + settledAt: yield* DateTime.now, + }); + yield* TestClock.adjust("5 seconds"); + yield* relay.drain; + assert.deepEqual(phases().slice(12), ["running", null]); + }), + ); + it.effect("still publishes a completion when the thread settles during the hold", () => Effect.gen(function* () { const { relay, currentShell, publications } = yield* makeTestRelay(); diff --git a/apps/server/src/relay/AgentAwarenessRelay.ts b/apps/server/src/relay/AgentAwarenessRelay.ts index 95b68bf0a5344..122d5b2fc988a 100644 --- a/apps/server/src/relay/AgentAwarenessRelay.ts +++ b/apps/server/src/relay/AgentAwarenessRelay.ts @@ -99,6 +99,8 @@ function shouldPublishAgentAwarenessEvent( case "thread.pull-request-synced": case "thread.issue-synced": case "thread.settled": + case "thread.hidden": + case "thread.unhidden": case "thread.model-selection-updated": case "thread.provider-switched": case "run.created": @@ -366,19 +368,18 @@ function resolveAgentAwarenessRelayPublishSnapshot(input: { state?.phase !== projectThreadAwarenessV2(awarenessInput)?.phase; return { projectId: input.thread.value.projectId, - state: snoozedCompletion(input.thread.value, state) - ? null - : sanitizeRelayAgentActivityState(state), + state: isSilent(input.thread.value, state) ? null : sanitizeRelayAgentActivityState(state), subagentWait: childDrivesWait ? input.pendingSubagentRequest : null, reason: "snapshot", }; } -// Checked at completion time, so a completion processed after the wake stays silent too. -function snoozedCompletion( - thread: AgentAwarenessThread, - state: { readonly phase: string } | null, -): boolean { +const blocksOnUser = (state: { readonly phase: string } | null) => + state?.phase === "waiting_for_approval" || state?.phase === "waiting_for_input"; + +function isSilent(thread: AgentAwarenessThread, state: { readonly phase: string } | null): boolean { + if (thread.hiddenAt != null) return !blocksOnUser(state); + // Snooze is checked at completion time, so a completion processed after the wake stays silent too. if (state?.phase !== "completed" || thread.latestRunCompletedAt == null) return false; const completedAt = DateTime.toEpochMillis(thread.latestRunCompletedAt); if (thread.snoozedAt != null && completedAt < DateTime.toEpochMillis(thread.snoozedAt)) { @@ -387,10 +388,12 @@ function snoozedCompletion( return isSnoozed(thread, completedAt); } -function terminalWorkSinceStart(thread: AgentAwarenessThread, startedAt: number): boolean { +function resultIsNew(thread: AgentAwarenessThread, startedAt: number): boolean { + if (thread.latestRunCompletedAt == null) return false; + const completedAt = DateTime.toEpochMillis(thread.latestRunCompletedAt); return ( - thread.latestRunCompletedAt != null && - DateTime.toEpochMillis(thread.latestRunCompletedAt) > startedAt + completedAt > startedAt && + (thread.lastUnhiddenAt == null || completedAt > DateTime.toEpochMillis(thread.lastUnhiddenAt)) ); } @@ -416,9 +419,10 @@ export function resolveAgentAwarenessRelayActiveThreadIds(input: { }); return ( state !== null && + (thread.hiddenAt == null || blocksOnUser(state)) && (state.phase !== "completed" && state.phase !== "failed" ? true - : terminalWorkSinceStart(thread, input.startedAt)) + : resultIsNew(thread, input.startedAt)) ); }) .map((thread) => thread.id); @@ -610,7 +614,7 @@ export const make = Effect.gen(function* () { (snapshot.state?.phase === "completed" || snapshot.state?.phase === "failed") && !hasLivePublishedState(publishedStateByThread, threadId) ) { - if (Option.isNone(thread) || !terminalWorkSinceStart(thread.value, startedAt)) return; + if (Option.isNone(thread) || !resultIsNew(thread.value, startedAt)) return; } if ( publishedStateByThread.get(threadId) === publishIdentity && @@ -631,7 +635,9 @@ export const make = Effect.gen(function* () { // Confirm tombstones over live state to avoid removing active cards. // Confirm completion: a run can end moments before its continuation starts, and the relay // alerts on every move into completed. - const requiresConfirmation = snapshot.state === null || snapshot.state?.phase === "completed"; + const hidden = Option.isSome(thread) && thread.value.hiddenAt != null; + const requiresConfirmation = + (snapshot.state === null && !hidden) || snapshot.state?.phase === "completed"; if (requiresConfirmation) { if (snapshot.state?.phase === "completed") heldCompletions.add(threadId); const nowMs = (yield* DateTime.now).epochMilliseconds; diff --git a/apps/server/src/telemetry/FeatureUsage.ts b/apps/server/src/telemetry/FeatureUsage.ts index 61fb57ada454e..9db6cc43dfc22 100644 --- a/apps/server/src/telemetry/FeatureUsage.ts +++ b/apps/server/src/telemetry/FeatureUsage.ts @@ -34,6 +34,7 @@ const COMMAND_FEATURES: { "thread.archive": () => ({ feature: "thread.archive" }), "thread.snooze": () => ({ feature: "thread.snooze" }), "thread.pin": () => ({ feature: "thread.pin" }), + "thread.hide": () => ({ feature: "thread.hide" }), "thread.settle": () => ({ feature: "thread.settle" }), "thread.pull-request.link": () => ({ feature: "thread.pull_request.link" }), "thread.pull-request.watch": (command) => diff --git a/apps/web/src/components/BackgroundThreadAnnouncer.tsx b/apps/web/src/components/BackgroundThreadAnnouncer.tsx index 649898cf2e5a5..a8d16349f21bc 100644 --- a/apps/web/src/components/BackgroundThreadAnnouncer.tsx +++ b/apps/web/src/components/BackgroundThreadAnnouncer.tsx @@ -55,6 +55,7 @@ export function startBackgroundThreadAnnouncements( runStatus: resolveBackgroundThreadRunStatus(thread), activeRunId: thread.runtime?.activeRunId ?? null, snoozed: effectiveSnoozed(thread, { now }), + hidden: thread.hiddenAt != null, }); } const next = nextBackgroundThreadAnnouncement(memory, snapshots, openThreadKey); diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index bac6531d468d2..6f122b62f60ab 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -188,7 +188,7 @@ import { useRightPanelStore, } from "../rightPanelStore"; import { getLatestThreadForProject, sortThreads } from "@t3tools/client-runtime/state/thread-sort"; -import { effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled"; +import { resolveThreadPlacement } from "@t3tools/client-runtime/state/thread-settled"; import { cn, getLocalFileManagerName, @@ -961,9 +961,10 @@ function OpenCommandPaletteDialog(props: { ) : null; const now = new Date().toISOString(); - const openableThreads = threads.filter( - (thread) => thread.settledOverride !== "settled" && !effectiveSnoozed(thread, { now }), - ); + const openableThreads = threads.filter((thread) => { + const placement = resolveThreadPlacement(thread, { now }); + return placement === "active" || placement === "pinned"; + }); const latestThread = groupedProjectKeys ? (sortThreads( openableThreads.filter( diff --git a/apps/web/src/components/CommandPaletteThreadActions.tsx b/apps/web/src/components/CommandPaletteThreadActions.tsx index 77adbd8c0e2e8..5250049869022 100644 --- a/apps/web/src/components/CommandPaletteThreadActions.tsx +++ b/apps/web/src/components/CommandPaletteThreadActions.tsx @@ -4,6 +4,8 @@ import { CircleCheckIcon, ClockIcon, CopyIcon, + EyeIcon, + EyeOffIcon, FolderIcon, FolderPlusIcon, GitBranchIcon, @@ -34,6 +36,8 @@ const ICONS: Record = { "circle-check": CircleCheckIcon, clock: ClockIcon, copy: CopyIcon, + eye: EyeIcon, + "eye-off": EyeOffIcon, folder: FolderIcon, "folder-plus": FolderPlusIcon, "git-branch": GitBranchIcon, diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index 9d1eb30b44b0d..3ecf81d284b56 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -1038,6 +1038,7 @@ describe("sidebar settled pagination", () => { [ activeProject.environmentId, { + environment: { capabilities: {} }, scratchWorkspaceRoot: null, shellThreadFamilies: false, } as unknown as EnvironmentServerConfig, @@ -1116,6 +1117,7 @@ describe("sidebar settled pagination", () => { [ activeProject.environmentId, { + environment: { capabilities: {} }, scratchWorkspaceRoot: null, shellThreadFamilies: false, } as unknown as EnvironmentServerConfig, diff --git a/apps/web/src/components/Sidebar.drag.test.ts b/apps/web/src/components/Sidebar.drag.test.ts index e1febcd68d533..e7cd69edf0e96 100644 --- a/apps/web/src/components/Sidebar.drag.test.ts +++ b/apps/web/src/components/Sidebar.drag.test.ts @@ -491,6 +491,42 @@ describe("sidebar drag projection", () => { expect(result.get("s")?.y).toBe(13); }); + it("keeps the Hidden shelf still under spare space and an unsortable Show more row", () => { + const items = [ + pinnedHeader, + divider, + thread("a1", "active"), + thread("a2", "active"), + settledHeader, + thread("s", "settled"), + marker("hidden-header"), + thread("h", "hidden"), + ]; + const strategy = createSidebarSortingStrategy({ + items, + settledOrder: ["s", "more"], + settledExpanded: true, + settledVisibleCount: 1, + }); + const args = layout(items, "a1", "a2"); + const gaps = new Map([ + [sidebarMarkerId("settled-header"), 200], + [sidebarMarkerId("hidden-header"), 37], + ]); + let shift = 0; + const rects = args.rects.map((rect, index) => { + shift += gaps.get(sidebarListItemId(items[index]!)) ?? 0; + return { ...rect, top: rect.top + shift, bottom: rect.bottom + shift }; + }); + const y = (id: string) => + strategy({ ...args, rects, index: items.findIndex((item) => sidebarListItemId(item) === id) }) + ?.y; + expect(y("a2")).toBe(-83); + expect(y(sidebarMarkerId("settled-header"))).toBe(0); + expect(y(sidebarMarkerId("hidden-header"))).toBe(0); + expect(y("h")).toBe(0); + }); + it("keeps a collapsed settled target without inserting a hidden row", () => { const items = [ pinnedHeader, diff --git a/apps/web/src/components/Sidebar.drag.ts b/apps/web/src/components/Sidebar.drag.ts index 76f2c9bf3a3ec..819a4a283a869 100644 --- a/apps/web/src/components/Sidebar.drag.ts +++ b/apps/web/src/components/Sidebar.drag.ts @@ -17,7 +17,8 @@ const isShelfHeader = (item: SidebarListItem | undefined) => item?.kind === "marker" && (item.marker === "working-header" || item.marker === "snoozed-header" || - item.marker === "settled-header"); + item.marker === "settled-header" || + item.marker === "hidden-header"); export function restrictBelowSidebarLabel( { transform, containerNodeRect, draggingNodeRect }: Parameters[0], @@ -120,6 +121,7 @@ export function createSidebarSortingStrategy(input: { working: [], snoozed: [], settled: [], + hidden: [], }; let cardHeight = input.cardHeight; let slimHeight = input.slimHeight; @@ -190,6 +192,10 @@ export function createSidebarSortingStrategy(input: { } marker("settled-header"); section("settled"); + if (items.some((item) => item.kind === "marker" && item.marker === "hidden-header")) { + marker("hidden-header"); + projected.push(...groups.hidden); + } const heights = projected.map((item) => { const index = indices.get(sidebarListItemId(item)); const rect = index === undefined ? undefined : rects[index]; @@ -208,6 +214,13 @@ export function createSidebarSortingStrategy(input: { ? fallback : (rect?.height ?? fallback); }); + const hiddenHeader = items.findIndex( + (item) => item.kind === "marker" && item.marker === "hidden-header", + ); + const hiddenRect = rects[hiddenHeader]; + const beforeHidden = rects[hiddenHeader - 1]; + const hiddenGap = + hiddenRect && beforeHidden ? Math.max(0, hiddenRect.top - beforeHidden.bottom - 1) : 0; const firstShelf = items.findIndex(isShelfHeader); const shelfRect = rects[firstShelf]; const beforeShelf = rects[firstShelf - 1]; @@ -216,7 +229,10 @@ export function createSidebarSortingStrategy(input: { shelfRect && beforeShelf && lastRect && shelfRect.top > beforeShelf.bottom + 1 ? Math.max( 0, - lastRect.bottom - rects[0].top - heights.reduce((sum, height) => sum + height + 1, -1), + lastRect.bottom - + rects[0].top - + hiddenGap - + heights.reduce((sum, height) => sum + height + 1, -1), ) : 0; const result = items.map(() => hidden); @@ -226,6 +242,7 @@ export function createSidebarSortingStrategy(input: { top += shelfSpace; shelfSpace = 0; } + if (item.kind === "marker" && item.marker === "hidden-header") top += hiddenGap; const index = indices.get(sidebarListItemId(item)); const rect = index === undefined ? undefined : rects[index]; if (index !== undefined && rect) result[index] = { ...stationary, y: top - rect.top }; diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index b8eb9704b2ea2..43f3970c99af5 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -1,6 +1,7 @@ import { presentThreadShell } from "@t3tools/client-runtime/state/models"; import { threadKey } from "@t3tools/client-runtime/state/entities"; import { isThreadWorking as isSidebarThreadWorking } from "@t3tools/client-runtime/state/thread-inbox"; +import { hasUnseenCompletion } from "@t3tools/client-runtime/state/thread-settled"; import * as DateTime from "effect/DateTime"; import { deriveActiveWorkStartedAt } from "../session-logic.ts"; import { describe, expect, it } from "vite-plus/test"; @@ -14,7 +15,6 @@ import { resolveScopedNewThreadProjectRef, deleteSelectedThreadEntries, getFallbackThreadIdAfterDelete, - hasUnseenCompletion, orderItemsByPreferredIds, pinOrderKeyBetween, resolveSidebarSweepKeys, @@ -775,6 +775,7 @@ describe("getFallbackThreadIdAfterDelete", () => { ], ["delegated", { id: ThreadId.make("thread-delegated") }], ["settled", { settledOverride: "settled", settledAt: "2026-03-09T10:06:00.000Z" }], + ["hidden", { hiddenAt: "2026-03-09T10:06:00.000Z" }], [ "side chat", { @@ -1035,6 +1036,9 @@ describe("navigation after parking a thread", () => { ["snooze", null, "2026-09-12T09:00:00.000Z", "thread", false], ["snooze", null, "2099-01-01T00:00:00.000Z", "thread", false, true], ["snooze", null, "2099-01-01T00:00:00.000Z", "other-thread", false], + ["hide", null, null, "thread", true, false, "2026-09-12T09:00:00.000Z"], + ["hide", null, null, "thread", false], + ["hide", null, null, "other-thread", false, false, "2026-09-12T09:00:00.000Z"], ] as const)( "%s with state %s / %s on %s navigates: %s", ( @@ -1044,6 +1048,7 @@ describe("navigation after parking a thread", () => { currentThreadKey, expected, hasPendingApprovals: boolean = false, + hiddenAt: string | null = null, ) => { expect( shouldNavigateAfterThreadPark({ @@ -1059,6 +1064,7 @@ describe("navigation after parking a thread", () => { latestTurn: null, hasPendingApprovals, hasPendingUserInput: false, + hiddenAt, }, }), ).toBe(expected); @@ -1238,31 +1244,39 @@ describe("Working shelf (beta)", () => { row("w1", "working"), marker("settled-header"), row("s1", "settled"), + marker("hidden-header"), + row("h1", "hidden"), ]; - it("never drops into the Working shelf, and keeps it out of the inbox order", () => { + it("never drops into the Working shelf or Hidden, and keeps them out of the inbox order", () => { expect(resolveSidebarDropTarget(items, "a1", "w1")).toBeNull(); + expect(resolveSidebarDropTarget(items, "a1", "h1")).toBeNull(); expect(resolveSidebarDropTarget(items, "p1", "a2")).toEqual({ section: "active", pinnedOrder: [], activeOrder: ["a1", "a2", "p1"], }); expect(resolveSidebarDropVerb("active", "working")).toBeNull(); + expect(resolveSidebarDropVerb("active", "hidden")).toBeNull(); + expect(resolveSidebarDropVerb("hidden", "active")).toBeNull(); }); it.each([ - ["pinned", "p1"], - ["active", "a2"], - ["settled", "s1"], + ["working", "w1", "pinned", "p1"], + ["working", "w1", "active", "a2"], + ["working", "w1", "settled", "s1"], + ["hidden", "h1", "pinned", "p1"], + ["hidden", "h1", "active", "a2"], + ["hidden", "h1", "settled", "s1"], ] as const)( - "does not move a Working thread into %s when its reference drag ends in the sidebar", - (section, overKey) => { - const target = resolveSidebarDropTarget(items, "w1", overKey); + "does not move a %s thread into %s when its reference drag ends in the sidebar", + (source, activeKey, section, overKey) => { + const target = resolveSidebarDropTarget(items, activeKey, overKey); expect(target?.section).toBe(section); expect( planSidebarThreadDrop({ - activeKey: "w1", - activeSection: "working", + activeKey, + activeSection: source, target: target!, pinnedOrder: ["p1"], pinnedKeysById: new Map([["p1", "m"]]), diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index b7407b729bc99..fea01d964b8d1 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -33,6 +33,7 @@ import type { SidebarProjectSortOrder, SidebarThreadSortOrder } from "@t3tools/c import type { AsyncResult } from "effect/reactivity"; import { effectiveSnoozed, + hasUnseenCompletion, hasUnseenRunFailure, type ThreadSnoozeShell, } from "@t3tools/client-runtime/state/thread-settled"; @@ -63,16 +64,21 @@ import { isRightPanelOpen, selectActiveRightPanel, useRightPanelStore } from ".. export function shouldNavigateAfterThreadPark(input: { readonly threadKey: string; readonly currentThreadKey: string | null; - readonly action: "settle" | "snooze"; + readonly action: "settle" | "snooze" | "hide"; readonly now: string; - readonly thread: (ThreadSnoozeShell & Pick) | null; + readonly thread: + | (ThreadSnoozeShell & + Pick & { readonly hiddenAt?: string | null }) + | null; }): boolean { return ( input.threadKey === input.currentThreadKey && input.thread !== null && (input.action === "settle" ? input.thread.settledOverride === "settled" - : effectiveSnoozed(input.thread, { now: input.now })) + : input.action === "hide" + ? input.thread.hiddenAt != null + : effectiveSnoozed(input.thread, { now: input.now })) ); } @@ -200,20 +206,7 @@ export function useRetainedValue(key: string | null, value: T | null): T | nu export const animateSidebarLayoutChanges: AnimateLayoutChanges = (args) => args.isSorting ? defaultAnimateLayoutChanges(args) : false; -// Snoozed rows cannot accept drops without a wake time. Working rows only drag out as chat context. - -export type SidebarSection = "pinned" | "active" | "working" | "snoozed" | "settled"; - -export function resolveSidebarThreadSection(input: { - readonly snoozed: boolean; - readonly settled: boolean; - readonly pinned: boolean; -}): SidebarSection { - if (input.snoozed) return "snoozed"; - if (input.settled) return "settled"; - if (input.pinned) return "pinned"; - return "active"; -} +export type SidebarSection = "pinned" | "active" | "working" | "snoozed" | "settled" | "hidden"; const SIDEBAR_MARKER_PREFIX = "sidebar-marker-"; @@ -224,7 +217,8 @@ export type SidebarListMarker = | "pinned-divider" | "working-header" | "snoozed-header" - | "settled-header"; + | "settled-header" + | "hidden-header"; export function sidebarMarkerId(marker: SidebarListMarker): string { return `${SIDEBAR_MARKER_PREFIX}${marker}`; @@ -247,6 +241,7 @@ function sectionAtSidebarSlot(items: readonly SidebarListItem[], index: number): else if (item.marker === "working-header") section = "working"; else if (item.marker === "snoozed-header") section = "snoozed"; else if (item.marker === "settled-header") section = "settled"; + else if (item.marker === "hidden-header") section = "hidden"; } return section; } @@ -268,7 +263,7 @@ export function resolveSidebarDropTarget( const moved = items.filter((_, index) => index !== activeIndex); moved.splice(overIndex, 0, items[activeIndex]!); const section = sectionAtSidebarSlot(moved, overIndex); - if (section === "working" || section === "snoozed") return null; + if (section === "working" || section === "snoozed" || section === "hidden") return null; const pinnedOrder: string[] = []; const activeOrder: string[] = []; let currentSection: SidebarSection = "pinned"; @@ -312,11 +307,21 @@ type SidebarThreadDropPlan = export type SidebarDropVerb = "pin" | "unpin" | "settle" | "unsettle" | "wake"; +// Snoozed rows cannot accept drops without a wake time. Working and hidden rows only drag out as +// chat context, and hidden threads leave Hidden only by an explicit Unhide, Pin or Snooze. export function resolveSidebarDropVerb( from: SidebarSection, to: SidebarSection | null, ): SidebarDropVerb | null { - if (to === null || to === from || to === "working" || to === "snoozed") return null; + if ( + to === null || + to === from || + from === "hidden" || + to === "working" || + to === "snoozed" || + to === "hidden" + ) + return null; if (to === "pinned") return "pin"; if (to === "settled") return "settle"; if (from === "pinned") return "unpin"; @@ -401,7 +406,7 @@ export function planSidebarThreadDrop(input: { activeKeysById, activeReorderableKeys, } = input; - if (activeSection === "working") return { kind: "none" }; + if (activeSection === "working" || activeSection === "hidden") return { kind: "none" }; if (input.supportsSettlement === false && (target.section === "settled" || activeSettled)) { return { kind: "none" }; } @@ -792,20 +797,6 @@ export function resolveThreadLastVisitedAt( return serverLastVisitedAt ?? undefined; } -export function hasUnseenCompletion(thread: ThreadStatusInput): boolean { - if (!thread.latestRun?.completedAt) return false; - if (thread.latestRun.status === "interrupted" || thread.latestRun.status === "cancelled") { - return false; - } - const completedAt = Date.parse(thread.latestRun.completedAt); - if (Number.isNaN(completedAt)) return false; - if (!thread.lastVisitedAt) return false; - - const lastVisitedAt = Date.parse(thread.lastVisitedAt); - if (Number.isNaN(lastVisitedAt)) return true; - return completedAt > lastVisitedAt; -} - // Suppress trailing double-click navigation; keyboard and synthetic clicks use detail 0. export function isTrailingDoubleClick(detail: number): boolean { return detail > 1; @@ -1382,7 +1373,7 @@ export function getFallbackThreadIdAfterDelete< > & ThreadSortInput & ThreadSnoozeShell & - Pick, + Pick & { readonly hiddenAt?: string | null }, >(input: { threads: readonly T[]; deletedThreadId: T["id"]; @@ -1406,6 +1397,7 @@ export function getFallbackThreadIdAfterDelete< thread.id !== deletedThreadId && !deletedThreadIds?.has(thread.id) && thread.settledOverride !== "settled" && + thread.hiddenAt == null && !effectiveSnoozed(thread, { now }) && !isShownUnderParent( { environmentId: thread.environmentId, threadId: thread.id }, diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 1f4dcd8dbede2..c30241a39bb62 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -29,7 +29,7 @@ import { SortableContext } from "@dnd-kit/sortable"; import { restrictToFirstScrollableAncestor, restrictToVerticalAxis } from "@dnd-kit/modifiers"; import { canSnooze, - effectiveSnoozed, + resolveThreadPlacement, threadWokeAt, } from "@t3tools/client-runtime/state/thread-settled"; import { @@ -207,7 +207,6 @@ import { resolveSidebarSweepKeys, resolveSidebarDropTarget, resolveSidebarDropVerb, - resolveSidebarThreadSection, resolveSidebarReorderableThreadKeys, searchSidebarThreads, shouldCreateNewThreadInCurrentProject, @@ -357,6 +356,7 @@ const REVEAL_ROW_CLASS_NAME = "flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground aria-disabled:cursor-default"; const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar:settled-expanded"; const SNOOZED_SHELF_EXPANDED_KEY = "t3code:sidebar:snoozed-expanded"; +const HIDDEN_SHELF_EXPANDED_KEY = "t3code:sidebar:hidden-expanded"; const WORKING_SHELF_EXPANDED_KEY = "t3code:sidebar:working-expanded"; const inboxReturns = createInboxReturnTracker(); @@ -488,6 +488,11 @@ function useSidebarThreads(input: { false, Schema.Boolean, ); + const [hiddenShelfExpanded, setHiddenShelfExpanded] = useLocalStorage( + HIDDEN_SHELF_EXPANDED_KEY, + false, + Schema.Boolean, + ); const [workingShelfExpanded, setWorkingShelfExpanded] = useLocalStorage( WORKING_SHELF_EXPANDED_KEY, false, @@ -519,8 +524,14 @@ function useSidebarThreads(input: { clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`, }); - const { pinnedThreads, activeThreads, workingThreads, snoozedThreads, settledThreads } = - partition; + const { + pinnedThreads, + activeThreads, + workingThreads, + snoozedThreads, + settledThreads, + hiddenThreads, + } = partition; // Older settled threads load in pages; the shelf lists them only as far as they are loaded. const olderSettledShelf = useOlderSettledShelf({ scopes: olderSettledScopes([...serverConfigs.keys()], scopedProjectKeys), @@ -550,6 +561,9 @@ function useSidebarThreads(input: { const visibleSnoozedThreads = snoozedShelfExpanded ? snoozedThreads : routeThreadOnly(snoozedThreads, shelfRouteThreadKey); + const visibleHiddenThreads = hiddenShelfExpanded + ? hiddenThreads + : routeThreadOnly(hiddenThreads, shelfRouteThreadKey); const visibleWorkingThreads = workingShelfExpanded ? workingThreads : routeThreadOnly(workingThreads, routeRowThreadKey); @@ -588,6 +602,7 @@ function useSidebarThreads(input: { ...visibleWorkingThreads, ...visibleSnoozedThreads, ...renderedSettledThreads, + ...visibleHiddenThreads, ]; const sectionByThreadKey = new Map(); for (const [list, section] of [ @@ -596,6 +611,7 @@ function useSidebarThreads(input: { [workingThreads, "working"], [snoozedThreads, "snoozed"], [settledThreads, "settled"], + [hiddenThreads, "hidden"], ] as const) { for (const thread of list) sectionByThreadKey.set(threadShellKey(thread), section); } @@ -609,6 +625,7 @@ function useSidebarThreads(input: { ...workingThreads, ...snoozedThreads, ...settledThreads, + ...hiddenThreads, ], settledVisibleCount, settledCount, @@ -623,6 +640,8 @@ function useSidebarThreads(input: { toggleSettledShelf: () => setSettledShelfExpanded((value) => !value), snoozedShelfExpanded, toggleSnoozedShelf: () => setSnoozedShelfExpanded((value) => !value), + hiddenShelfExpanded, + toggleHiddenShelf: () => setHiddenShelfExpanded((value) => !value), workingShelfExpanded, toggleWorkingShelf: () => setWorkingShelfExpanded((value) => !value), projectFolders, @@ -638,6 +657,7 @@ function useSidebarThreads(input: { }), renderedSettledThreads, visibleSnoozedThreads, + visibleHiddenThreads, visibleWorkingThreads, orderedThreadKeys: orderedThreads.map(threadShellKey), threadByKey: new Map(orderedThreads.map((thread) => [threadShellKey(thread), thread] as const)), @@ -681,6 +701,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { : active; const snoozed: EnvironmentThreadShell[] = []; const settled: EnvironmentThreadShell[] = []; + const hidden: EnvironmentThreadShell[] = []; const { draggableThreadKeys, activeReorderableThreadKeys } = resolveSidebarReorderableThreadKeys({ threads: visible, serverConfigs, @@ -707,18 +728,14 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { : { ...projected, snoozedAt: thread.snoozedAt, snoozedUntil: thread.snoozedUntil }, ); } else { - const section = resolveSidebarThreadSection({ - snoozed: configLoaded && effectiveSnoozed(thread, { now: preciseNow }), - settled: configLoaded && thread.settledOverride === "settled", - pinned: thread.pinnedAt != null, + const placement = resolveThreadPlacement(thread, { + now: preciseNow, + supportsSnooze: configLoaded, + supportsSettlement: configLoaded, }); - (section === "snoozed" - ? snoozed - : section === "settled" - ? settled - : section === "pinned" - ? pinned - : inbox(thread) + (placement === "active" + ? inbox(thread) + : { hidden, snoozed, settled, pinned }[placement] ).push(thread); } } @@ -755,6 +772,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { firstValidTimestampMs(right.snoozedUntil ?? null), ), settledThreads: sortSettledThreads(settled), + hiddenThreads: sortThreadsForSidebar(hidden), visibleThreads: visible, snoozeNow: preciseNow, }; @@ -795,13 +813,7 @@ function isOptimisticDropReleased(input: { if (thread === undefined || thread.archivedAt !== null) { return true; } - const canonicalSection = effectiveSnoozed(thread, { now }) - ? "snoozed" - : thread.settledOverride === "settled" - ? "settled" - : thread.pinnedAt != null - ? "pinned" - : "active"; + const canonicalSection = resolveThreadPlacement(thread, { now }); if ( canonicalSection !== optimisticDrop.sourceSection && canonicalSection !== optimisticDrop.section @@ -977,6 +989,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve unsettleThread, snoozeThread, unsnoozeThread, + hideThread, + unhideThread, pinThread, unpinThread, confirmAndUnpinThread, @@ -1380,6 +1394,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve workingThreads, snoozedThreads, settledThreads, + hiddenThreads, snoozeNow, searchableThreads, settledVisibleCount, @@ -1391,6 +1406,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve toggleSettledShelf, snoozedShelfExpanded, toggleSnoozedShelf, + hiddenShelfExpanded, + toggleHiddenShelf, workingShelfExpanded, toggleWorkingShelf, projectFolders, @@ -1398,6 +1415,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve toggleProjectFolderShowAll, renderedSettledThreads, visibleSnoozedThreads, + visibleHiddenThreads, visibleWorkingThreads, orderedThreadKeys, threadByKey, @@ -1699,6 +1717,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve return thread && !settledKeys.has(key) && !snoozedKeys.has(key) && + thread.hiddenAt == null && !coParkingKeys?.has(key) ? [scopeThreadRef(thread.environmentId, thread.id)] : []; @@ -1709,11 +1728,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const now = new Date().toISOString(); const nextRef = nextCardRefs.find((ref) => { const thread = readThreadShell(ref); - return ( - thread !== null && - thread.settledOverride !== "settled" && - !effectiveSnoozed(thread, { now }) - ); + const placement = thread && resolveThreadPlacement(thread, { now }); + return placement === "active" || placement === "pinned"; }); if (nextRef) navigateToThread(nextRef); else if (shell) void handleNewThread(scopeProjectRef(shell.environmentId, shell.projectId)); @@ -1803,6 +1819,59 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve } })(); }; + const attemptHide = ( + threadRef: ScopedThreadRef, + opts: { coHidingKeys?: ReadonlySet } = {}, + ) => { + void (async () => { + const threadKey = scopedThreadKey(threadRef); + const navigateAfterHide = planForwardNavigation(threadKey, opts.coHidingKeys); + if (navigateAfterHide) departRouteThread(threadKey); + const result = await hideThread(threadRef); + if (result._tag === "Failure") { + stayOnRouteThread(threadKey); + if (!isAtomCommandInterrupted(result)) { + toastManager.add( + stackedThreadToast({ + type: "error", + title: gt`Failed to hide thread`, + description: + thrownErrorMessage(squashAtomCommandFailure(result), m) ?? gt`An error occurred.`, + }), + ); + } + return; + } + if ( + shouldNavigateAfterThreadPark({ + threadKey, + currentThreadKey: readRouteThreadKey(router), + action: "hide", + now: new Date().toISOString(), + thread: readThreadShell(threadRef), + }) + ) { + navigateAfterHide?.(); + } else { + stayOnRouteThread(threadKey); + } + })(); + }; + const attemptUnhide = (threadRef: ScopedThreadRef) => { + void (async () => { + const result = await unhideThread(threadRef); + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { + toastManager.add( + stackedThreadToast({ + type: "error", + title: gt`Failed to unhide thread`, + description: + thrownErrorMessage(squashAtomCommandFailure(result), m) ?? gt`An error occurred.`, + }), + ); + } + })(); + }; const restrictBelowPins: Modifier = (args) => restrictBelowSidebarLabel(args, dragLabelOffsetRef.current); const dndModifiers = [ @@ -1843,7 +1912,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const isContextDrag = projectFolders !== null || dragState?.contextDrag === true || - dragState?.activeSection === "working"; + dragState?.activeSection === "working" || + dragState?.activeSection === "hidden"; const dragTargetSection = isContextDrag ? null : (dragState?.targetSection ?? null); const finishThreadDrag = (started: boolean) => { dragSensorRef.current = null; @@ -1931,10 +2001,11 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const originSection = sectionByThreadKeyRef.current.get(originKey); const canApply = (key: string) => { const thread = threadByKeyRef.current.get(key); + const config = thread && serverConfigs.get(thread.environmentId); return ( - thread !== undefined && + config !== undefined && sectionByThreadKeyRef.current.get(key) === originSection && - serverConfigs.has(thread.environmentId) + (action !== "unhide" || config.environment.capabilities.threadHide === true) ); }; let targetKey: string | null = null; @@ -1970,6 +2041,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const ref = parseScopedThreadKey(key); if (ref === null) continue; if (action === "unsettle") attemptUnsettle(ref); + else if (action === "unhide") attemptUnhide(ref); else attemptUnsnooze(ref); } }, @@ -2050,6 +2122,38 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve event.activatorEvent instanceof PointerEvent ? event.activatorEvent.clientY : null, }); }; + const showMoreSettledRow = + settledShelfExpanded && hiddenSettledCount > 0 ? ( +
  • + +
  • + ) : null; const hasProjectFolders = projectFolders !== null && projectFolders.length > 0; const sidebarListItemsFresh = ((): readonly SidebarListItem[] => { const rowsOf = ( @@ -2067,7 +2171,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve activeThreads.length + workingThreads.length + snoozedThreads.length + - settledCount === + settledCount + + hiddenThreads.length === 0 ) { return []; @@ -2091,6 +2196,10 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const settledRows = rowsOf(renderedSettledThreads, "settled"); items.push({ kind: "marker", marker: "settled-placeholder" }); items.push(...settledRows); + if (hiddenThreads.length > 0) { + items.push({ kind: "marker", marker: "hidden-header" }); + items.push(...rowsOf(visibleHiddenThreads, "hidden")); + } return items; })(); // Preserve the list while streamed updates leave order unchanged to retain row memoization. @@ -2131,9 +2240,12 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve dragState === null && sidebarListItems.length + visibleDraftSessionCount > 0; // Cache on both fields so layout-key changes trigger the effect even when animate is unchanged. const listMotionPass = { layoutKey: listMotionLayoutKey, animate: listMotionAnimate }; - const shelfExpansionKey = [workingShelfExpanded, snoozedShelfExpanded, settledShelfExpanded].join( - ":", - ); + const shelfExpansionKey = [ + workingShelfExpanded, + snoozedShelfExpanded, + settledShelfExpanded, + hiddenShelfExpanded, + ].join(":"); const previousShelfExpansionKeyRef = useRef(shelfExpansionKey); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- records moved rows and updates list motion after each layout-affecting commit useLayoutEffect(() => { @@ -2433,8 +2545,14 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve return thread ? [thread] : []; }); const settlingThreads = selectedThreads.filter( - (thread) => thread.settledOverride !== "settled", + (thread) => thread.settledOverride !== "settled" && thread.hiddenAt == null, + ); + const hideThreads = selectedThreads.filter( + (thread) => + serverConfigs.get(thread.environmentId)?.environment.capabilities.threadHide === true, ); + const hidingThreads = hideThreads.filter((thread) => thread.hiddenAt == null); + const unhidingThreads = hideThreads.filter((thread) => thread.hiddenAt != null); const canSnoozeSelection = selectedThreads.every( (thread) => serverConfigs.has(thread.environmentId) && @@ -2502,6 +2620,24 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve }, ] : []), + ...(hidingThreads.length > 0 + ? [ + { + id: "hide" as const, + label: gt`Hide (${{ count: hidingThreads.length }})`, + disabled: !canOperateThreads(hidingThreads), + }, + ] + : []), + ...(unhidingThreads.length > 0 + ? [ + { + id: "unhide" as const, + label: gt`Unhide (${{ count: unhidingThreads.length }})`, + disabled: !canOperateThreads(unhidingThreads), + }, + ] + : []), ...(titleRegenerationMenuItem ? [ { @@ -2542,9 +2678,17 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const current = threadByKeyRef.current.get( scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), ); - return current && current.settledOverride !== "settled" ? [current] : []; + return current && + current.settledOverride !== "settled" && + current.hiddenAt == null + ? [current] + : []; }) - : selectedThreads; + : clicked.value === "hide" + ? hidingThreads + : clicked.value === "unhide" + ? unhidingThreads + : selectedThreads; if (clicked.value === "settle" && actionTargets.length === 0) return; if ( clicked.value !== "mark-unread" && @@ -2600,6 +2744,20 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve } return; } + if (clicked.value === "hide" || clicked.value === "unhide") { + const coHidingKeys = new Set( + actionTargets.map((thread) => + scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), + ), + ); + clearSelection(); + for (const thread of actionTargets) { + const threadRef = scopeThreadRef(thread.environmentId, thread.id); + if (clicked.value === "hide") attemptHide(threadRef, { coHidingKeys }); + else attemptUnhide(threadRef); + } + return; + } if (clicked.value === "unpin") { for (const thread of pinnedSelectedThreads) { attemptUnpin(scopeThreadRef(thread.environmentId, thread.id)); @@ -2778,9 +2936,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve projectByKey.get(`${thread.environmentId}:${thread.projectId}`)?.workspaceRoot ?? null; const configLoaded = serverConfigs.has(thread.environmentId); - const supportsAutoSettleOptOut = - serverConfigs.get(thread.environmentId)?.environment.capabilities - .threadAutoSettleOptOut === true; + const capabilities = serverConfigs.get(thread.environmentId)?.environment.capabilities; + const supportsAutoSettleOptOut = capabilities?.threadAutoSettleOptOut === true; const isRegeneratingTitle = thread.titleRegeneration != null; const isSettled = settledThreadKeysRef.current.has(threadKey); const isSnoozed = snoozedThreadKeysRef.current.has(threadKey); @@ -2816,6 +2973,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve } : null, isPinned, + isHidden: thread.hiddenAt != null, isSettled, autoSettleEnabled: thread.autoSettleDisabledAt == null, isSnoozed, @@ -2840,6 +2998,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve autoSettleOptOut: supportsAutoSettleOptOut, snooze: configLoaded, pinning: configLoaded, + hide: capabilities?.threadHide === true, titleRegeneration: configLoaded, }, snoozePresets, @@ -2921,6 +3080,12 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve case "unpin": attemptUnpin(threadRef); return; + case "hide": + attemptHide(threadRef); + return; + case "unhide": + attemptUnhide(threadRef); + return; case "turn-into-project": { const result = await turnThreadIntoProject(threadRef); if (result._tag === "Success") { @@ -3550,7 +3715,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve workingThreads.length + snoozedThreads.length === 0 && - (settledCount === 0 || scopedProjectGroups.length > 0) ? ( + (settledCount + hiddenThreads.length === 0 || scopedProjectGroups.length > 0) ? (
    {projects.length === 0 ? ( <> @@ -3569,7 +3734,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve ) : scopedProjectGroups.length > 0 ? ( <> - {settledCount > 0 + {settledCount + hiddenThreads.length > 0 ? scopedProjectGroups.length > 1 ? gt`No active threads in these projects` : gt`No active threads in ${{ project: scopedProjectGroups[0]!.displayName }}` @@ -3650,20 +3815,29 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve layout={rowLayout} navigationParent={ folderRow ?? - (section === "working" || section === "snoozed" || section === "settled" + (section === "working" || + section === "snoozed" || + section === "settled" || + section === "hidden" ? `shelf:${section}` : undefined) } variantAction={ - section === "snoozed" - ? "unsnooze" - : section === "settled" - ? "unsettle" - : "settle" + section === "hidden" + ? "unhide" + : section === "snoozed" + ? "unsnooze" + : section === "settled" + ? "unsettle" + : "settle" } settlementSupported={serverConfigs.has(thread.environmentId)} snoozeSupported={serverConfigs.has(thread.environmentId)} pinningSupported={serverConfigs.has(thread.environmentId)} + hideSupported={ + serverConfigs.get(thread.environmentId)?.environment.capabilities + .threadHide === true + } isPinned={thread.pinnedAt != null} dropVerb={ dragState?.activeKey === threadKey @@ -3720,6 +3894,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve onUnsettle={attemptUnsettle} onSnooze={attemptSnooze} onUnsnooze={attemptUnsnooze} + onUnhide={attemptUnhide} onUnpin={attemptUnpin} onAcknowledgeWoke={acknowledgeWoke} onFileDropThreads={handleThreadFileDrop} @@ -3892,6 +4067,21 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve />, ); break; + case "hidden-header": + if (showMoreSettledRow !== null) items.push(showMoreSettledRow); + items.push( + , + ); + break; case "settled-placeholder": items.push( 0 ? ( -
  • - -
  • - ) : null} + {hiddenThreads.length === 0 ? showMoreSettledRow : null} diff --git a/apps/web/src/components/ThreadNotificationCoordinator.logic.test.ts b/apps/web/src/components/ThreadNotificationCoordinator.logic.test.ts index 0efca647316ba..d8727b2bf931e 100644 --- a/apps/web/src/components/ThreadNotificationCoordinator.logic.test.ts +++ b/apps/web/src/components/ThreadNotificationCoordinator.logic.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vite-plus/test"; import { createThreadNotificationGate, - isSnoozedForNotification, + isQuietForNotification, RELEASED_COMPLETION_GRACE_MS, type ThreadNotificationObservation, } from "./ThreadNotificationCoordinator.logic"; @@ -218,7 +218,7 @@ describe("createThreadNotificationGate", () => { }); }); -describe("isSnoozedForNotification", () => { +describe("isQuietForNotification", () => { const snoozedAt = Date.parse("2026-01-01T11:00:00.000Z"); const wakeAt = Date.parse("2026-01-01T12:00:00.000Z"); const thread = { @@ -240,7 +240,14 @@ describe("isSnoozedForNotification", () => { wakeAt - 1, false, ], + [ + "on a hidden thread that never snoozed", + { hasPendingApprovals: false, hasPendingUserInput: false, hiddenAt: thread.snoozedAt }, + later, + later, + true, + ], ])("a completion %s is suppressed: %s", (_name, shell, completedAt, now, expected) => { - expect(isSnoozedForNotification(shell, completedAt, now)).toBe(expected); + expect(isQuietForNotification(shell, completedAt, now)).toBe(expected); }); }); diff --git a/apps/web/src/components/ThreadNotificationCoordinator.logic.ts b/apps/web/src/components/ThreadNotificationCoordinator.logic.ts index 057d976a17837..40f32ef3f93c5 100644 --- a/apps/web/src/components/ThreadNotificationCoordinator.logic.ts +++ b/apps/web/src/components/ThreadNotificationCoordinator.logic.ts @@ -3,6 +3,8 @@ import { type ThreadSnoozeShell, } from "@t3tools/client-runtime/state/thread-settled"; +import type { SidebarThreadStatus } from "./Sidebar.logic"; + export type ThreadNotificationKind = "input" | "completion"; export interface ThreadNotificationObservation { @@ -18,18 +20,24 @@ export interface ThreadNotificationObservation { readonly backgroundWake: boolean; } +export function notifiesAttention(status: SidebarThreadStatus, hidden: boolean): boolean { + if (status === "input" || status === "request" || status === "approval") return true; + return !hidden && (status === "failed" || status === "limited"); +} + /** Matches the push relay's completion confirmation: a final wake can start right after a progress wake. */ export const RELEASED_COMPLETION_GRACE_MS = 5_000; /** - * Whether completion notifications are suppressed by snooze. A completion that landed - * during the snooze stays suppressed even when its update is processed after the wake. + * A completion that landed during the snooze stays suppressed even when its update is processed + * after the wake. */ -export function isSnoozedForNotification( - thread: ThreadSnoozeShell, +export function isQuietForNotification( + thread: ThreadSnoozeShell & { readonly hiddenAt?: string | null }, completedAt: number | null, now: number, ): boolean { + if (thread.hiddenAt != null) return true; if (effectiveSnoozed(thread, { now: new Date(now).toISOString() })) return true; if (completedAt === null) return false; if (thread.snoozedAt != null && completedAt < Date.parse(thread.snoozedAt)) return false; diff --git a/apps/web/src/components/ThreadNotificationCoordinator.tsx b/apps/web/src/components/ThreadNotificationCoordinator.tsx index 7f91d48643bbf..39d12ddbaa693 100644 --- a/apps/web/src/components/ThreadNotificationCoordinator.tsx +++ b/apps/web/src/components/ThreadNotificationCoordinator.tsx @@ -37,7 +37,8 @@ import { resolveBackgroundThreadRequest } from "./backgroundThreadAnnouncement"; import { resolveSidebarThreadStatus, type SidebarThreadStatus } from "./Sidebar.logic"; import { createThreadNotificationGate, - isSnoozedForNotification, + isQuietForNotification, + notifiesAttention, type ThreadNotificationKind, type ThreadNotificationObservation, } from "./ThreadNotificationCoordinator.logic"; @@ -268,12 +269,7 @@ export function startThreadNotifications( const thread = presentThreadShell(environmentId, rawThread, subagentRequest); let status = resolveSidebarThreadStatus(thread); if (status === "ready" && thread.latestRun?.status === "failed") status = "failed"; - const needsAttention = - status === "input" || - status === "request" || - status === "approval" || - status === "failed" || - status === "limited"; + const needsAttention = notifiesAttention(status, rawThread.hiddenAt != null); const requestId = needsAttention ? resolveBackgroundThreadRequest(thread).requestId : null; // Queued messages become the latest run while a request stays pending, so a request // with an id is keyed by that id alone and announces once. @@ -308,7 +304,7 @@ export function startThreadNotifications( entry.gate.observe(state.thread.id, prior, state, { archived: state.thread.archivedAt !== null, quiet: state.raw.latestRunStopRequested === true, - snoozed: isSnoozedForNotification(state.thread, state.completedAt, now), + snoozed: isQuietForNotification(state.thread, state.completedAt, now), }); } }; diff --git a/apps/web/src/components/backgroundThreadAnnouncement.test.ts b/apps/web/src/components/backgroundThreadAnnouncement.test.ts index 51d3c693f9904..a33b05b4bcec1 100644 --- a/apps/web/src/components/backgroundThreadAnnouncement.test.ts +++ b/apps/web/src/components/backgroundThreadAnnouncement.test.ts @@ -27,6 +27,7 @@ function thread( runStatus: "running", activeRunId: null, snoozed: false, + hidden: false, ...state, }; } @@ -150,6 +151,17 @@ describe("nextBackgroundThreadAnnouncement", () => { ).toEqual([]); }); + it("speaks only requests for a hidden thread", () => { + expect( + speak([ + { threads: [login({ hidden: true })] }, + { threads: [login({ hidden: true, runStatus: "failed" })] }, + { threads: [login({ hidden: true, runId: secondRun, request: "approval" })] }, + { threads: [login({ hidden: true, runId: secondRun, runStatus: "completed" })] }, + ]), + ).toEqual(["Needs approval: Fix login redirect"]); + }); + it("speaks threads that change together in one announcement", () => { expect( speak([ diff --git a/apps/web/src/components/backgroundThreadAnnouncement.ts b/apps/web/src/components/backgroundThreadAnnouncement.ts index debacd3fe9a39..db4f849f864f9 100644 --- a/apps/web/src/components/backgroundThreadAnnouncement.ts +++ b/apps/web/src/components/backgroundThreadAnnouncement.ts @@ -23,8 +23,9 @@ export interface BackgroundThreadSnapshot { readonly runStatus: OrchestrationV2RunStatus | null; /** The run doing work now, which can be older than a queued run cancelled while it ran. */ readonly activeRunId: RunId | null; - /** A snoozed thread stays hidden until its timer, so it stays quiet too. */ + /** A snoozed thread stays out of the list until its timer, so it stays quiet too. */ readonly snoozed: boolean; + readonly hidden: boolean; } /** The request and its id come from the same source, so a subagent's request never takes the parent's id. */ @@ -110,7 +111,12 @@ export function nextBackgroundThreadAnnouncement( // cancelled before it started) isn't the thread finishing. The shell then // only reports the latest run, so the working run's own ending stays quiet. const anotherRunWorking = thread.activeRunId !== null && thread.activeRunId !== thread.runId; - if (outcome !== null && thread.runId !== before.settledRunId && !anotherRunWorking) { + if ( + outcome !== null && + thread.runId !== before.settledRunId && + !anotherRunWorking && + !thread.hidden + ) { announcements.push(resolve(msg`${{ status: outcome }}: ${{ title: thread.title }}`)); } } diff --git a/apps/web/src/components/chat/useThreadLifecycle.tsx b/apps/web/src/components/chat/useThreadLifecycle.tsx index 897a4e03a07ef..fcf93fc9a2bf7 100644 --- a/apps/web/src/components/chat/useThreadLifecycle.tsx +++ b/apps/web/src/components/chat/useThreadLifecycle.tsx @@ -52,7 +52,7 @@ import { } from "@t3tools/client-runtime/state/runtime"; import { useUiStateStore } from "../../uiStateStore"; import { type ChatMessage, DEFAULT_INTERACTION_MODE } from "../../types"; -import { AlarmClockIcon, CheckCircle2Icon } from "lucide-react"; +import { AlarmClockIcon, CheckCircle2Icon, EyeOffIcon } from "lucide-react"; import { stackedThreadToast, toastManager } from "../ui/toast"; import { titleRegenerationToast } from "../threadTitleRegenerationToast"; import { newMessageId } from "~/lib/utils"; @@ -196,7 +196,7 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { const messages = useMessages(); const navigate = useNavigate(); const router = useRouter(); - const { settleThread, pinThread, confirmAndUnpinThread } = useThreadActions(); + const { settleThread, pinThread, confirmAndUnpinThread, unhideThread } = useThreadActions(); const canWriteSourceControl = useEnvironmentScope(environmentId, AuthSourceControlWriteScope); const canTriageThread = !useEnvironmentScopeDenied(environmentId, AuthOrchestrationOperateScope); const switchGitRef = useAtomCommand(vcsEnvironment.switchRef, { reportFailure: false }); @@ -321,6 +321,27 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { setUnsnoozingThreadKey((current) => (current === threadKey ? null : current)); }; const handleUnsnoozeActiveThreadStable = useStableCallback(handleUnsnoozeActiveThread); + const activeThreadHidden = activeThreadShell?.hiddenAt != null; + const [unhidingThreadKey, setUnhidingThreadKey] = useState(null); + const isUnhiding = unhidingThreadKey !== null && unhidingThreadKey === activeThreadKey; + const handleUnhideActiveThread = async () => { + if (!activeThreadRef) return; + const threadKey = scopedThreadKey(activeThreadRef); + setUnhidingThreadKey(threadKey); + const result = await unhideThread(activeThreadRef); + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { + const error = squashAtomCommandFailure(result); + toastManager.add( + stackedThreadToast({ + type: "error", + title: m(msg("Failed to unhide thread")), + description: thrownErrorMessage(error, m) ?? m(msg("An error occurred.")), + }), + ); + } + setUnhidingThreadKey((current) => (current === threadKey ? null : current)); + }; + const handleUnhideActiveThreadStable = useStableCallback(handleUnhideActiveThread); const [restoringBranchThreadKeys, setRestoringBranchThreadKeys] = useState>( () => new Set(), ); @@ -662,7 +683,16 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { Date.parse(snoozedUntil) > Date.parse(snoozeNow) ? snoozeWakeLabel(snoozedUntil, { now: snoozeNow }, messages) : null; - const threadStatusLine = activeThreadSnoozed ? ( + const threadStatusLine = activeThreadHidden ? ( + } + label={gt({ context: "thread status" })`Hidden`} + clockMinute={nowMinute} + actionLabel={isUnhiding ? gt`Unhiding...` : gt`Unhide`} + actionDisabled={!canOperateThread || isUnhiding} + onAction={() => void handleUnhideActiveThreadStable()} + /> + ) : activeThreadSnoozed ? ( limitRecoveryHoldsSnooze ? null : ( } @@ -716,6 +746,7 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { if (!threadTriagePermitted(environmentId)) return false; // A held key would toggle back on every repeat; act on the first press only. if (event.repeat || !activeThreadShell || !activeThreadRef || !serverConfigLoaded) return; + if (activeThreadHidden) return; if (activeThreadSettled) { void handleUnsettleActiveThread(); return; diff --git a/apps/web/src/components/settings/SidebarRowLayoutRow.tsx b/apps/web/src/components/settings/SidebarRowLayoutRow.tsx index bf38b2c57c320..f63520dbba142 100644 --- a/apps/web/src/components/settings/SidebarRowLayoutRow.tsx +++ b/apps/web/src/components/settings/SidebarRowLayoutRow.tsx @@ -818,6 +818,7 @@ function PreviewSidebar(props: { layout: SidebarRowLayout }) { onUnsettle={noop} onSnooze={noop} onUnsnooze={noop} + onUnhide={noop} onUnpin={noop} onAcknowledgeWoke={noop} /> diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.tsx index da9444a5c1b24..211c23b7c3995 100644 --- a/apps/web/src/components/sidebar/SidebarListMarkers.tsx +++ b/apps/web/src/components/sidebar/SidebarListMarkers.tsx @@ -111,7 +111,7 @@ export function SidebarDragBoundary(props: { } export function SidebarSectionHeader(props: { - marker: "working-header" | "snoozed-header" | "settled-header"; + marker: "working-header" | "snoozed-header" | "settled-header" | "hidden-header"; label: string; /** A muted trailing count. */ count: number; @@ -125,7 +125,9 @@ export function SidebarSectionHeader(props: { ? "working" : props.marker === "snoozed-header" ? "snoozed" - : "settled"; + : props.marker === "hidden-header" + ? "hidden" + : "settled"; return ( ; } -export type SidebarSweepAction = "settle" | "unsettle" | "unsnooze"; -const dropVerbBadge: Record = { +export type SidebarSweepAction = "settle" | "unsettle" | "unsnooze" | "unhide"; +const dropVerbBadge: Record = { pin: ( <> @@ -634,6 +635,12 @@ const dropVerbBadge: Record = { Wake ), + unhide: ( + <> + + Unhide + + ), }; const TOP_STATUS_ICONS = { @@ -664,6 +671,7 @@ type SidebarThreadRowProps = { settlementSupported: boolean; snoozeSupported: boolean; pinningSupported: boolean; + hideSupported?: boolean | undefined; isPinned: boolean; sortable?: SortableThreadRowBag | undefined; dropVerb: SidebarDropVerb | null; @@ -708,6 +716,7 @@ type SidebarThreadRowProps = { onUnsettle: (threadRef: ScopedThreadRef) => void; onSnooze: (threadRef: ScopedThreadRef, preset: Pick) => void; onUnsnooze: (threadRef: ScopedThreadRef) => void; + onUnhide: (threadRef: ScopedThreadRef) => void; onUnpin: (threadRef: ScopedThreadRef) => void; onAcknowledgeWoke: (threadRef: ScopedThreadRef, visitedAt: string) => void; onFileDropThreads?: ((threadRef: ScopedThreadRef, files: File[]) => void) | undefined; @@ -798,6 +807,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr onThreadClick, onUnsettle, onUnsnooze, + onUnhide, onUnpin, readOpensPullRequestsInRightPanel, renamingTitle, @@ -1087,6 +1097,11 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr event.stopPropagation(); onUnsnooze(threadRef); }; + const handleUnhideClick = (event: ReactMouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + onUnhide(threadRef); + }; const handleUnpinClick = (event: ReactMouseEvent) => { event.preventDefault(); event.stopPropagation(); @@ -1139,7 +1154,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr const rowSurfaceClassName = cn( "group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring", - variantAction === "unsettle" && + (variantAction === "unsettle" || variantAction === "unhide") && !props.isActive && "[&:not(:hover):not(:focus-within)_*:not(.live-activity-focus_*)]:text-secondary-label", props.isActive @@ -1868,7 +1883,29 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
    )} - {variantAction === "unsnooze" ? ( + {variantAction === "unhide" ? ( + !props.hideSupported ? null : ( + + } + label={ + <> + Unhide thread + + } + > + + + ) + ) : variantAction === "unsnooze" ? ( !props.snoozeSupported ? null : (