Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2650,6 +2650,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
canSnoozeNow: canSnooze(thread, { now: new Date().toISOString() }),
isRegeneratingTitle,
isRunning: !threadRuntimeCanArchive(thread.runtime),
isWorking: isThreadWorking(thread),
canShareWithGuest: appAtomRegistry.get(
canShareWithGuestAtom(threadRef.environmentId),
),
Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/components/threadActionMenu.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const baseState: ThreadActionMenuState = {
canSnoozeNow: true,
isRegeneratingTitle: false,
isRunning: false,
isWorking: false,
supports: {
settlement: true,
autoSettleOptOut: true,
Expand Down Expand Up @@ -74,4 +75,15 @@ describe("buildThreadActionMenuItems", () => {
expect(items.find((item) => item.id === "archive")?.disabled).toBe(true);
expect(items.find((item) => item.id === "turn-into-project")?.disabled).toBe(true);
});

it("offers Mark unread only when the thread is not running", () => {
const offersMarkUnread = (isRunning: boolean, isWorking = false) =>
buildThreadActionMenuItems({ ...baseState, isRunning, isWorking }).some(
(item) => item.id === "mark-unread" && !item.disabled,
);
expect(offersMarkUnread(false)).toBe(true);
expect(offersMarkUnread(true)).toBe(false);
// Idle with held background work, or waiting: Working but archivable.
expect(offersMarkUnread(false, true)).toBe(false);
});
});
9 changes: 8 additions & 1 deletion apps/web/src/components/threadActionMenu.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export interface ThreadActionMenuState {
readonly isRegeneratingTitle: boolean;
/** Archive rejects attached providers, so disable it while running. */
readonly isRunning: boolean;
/** The Working shelf's status outranks unread, so Mark unread would show nothing. */
readonly isWorking: boolean;
readonly supports: {
readonly settlement: boolean;
readonly autoSettleOptOut: boolean;
Expand Down Expand Up @@ -178,7 +180,12 @@ export function buildThreadActionMenuItems(
},
]
: []),
{ id: "mark-unread", label: "Mark unread", icon: "mail-open" },
{
id: "mark-unread",
label: "Mark unread",
icon: "mail-open",
disabled: state.isRunning || state.isWorking,
},
...(state.canShareWithGuest
? [{ id: "share-guest" as const, label: "Share with guest", icon: "user-plus" }]
: []),
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/hooks/useThreadActionMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
} from "@t3tools/client-runtime/state/project-grouping";
import { buildPhysicalToLogicalProjectKeyMap } from "../sidebarProjectGrouping";
import { threadRuntimeCanArchive } from "@t3tools/client-runtime/state/models";
import { isThreadWorking } from "@t3tools/client-runtime/state/thread-inbox";
import { useCopyToClipboard } from "./useCopyToClipboard";
import { useNewThreadHandler } from "./useHandleNewThread";
import { useClientSettings } from "./useSettings";
Expand Down Expand Up @@ -148,6 +149,7 @@ export function useThreadActionMenu(input: {
canSnoozeNow: canSnooze(thread, { now: now.toISOString() }),
isRegeneratingTitle,
isRunning: !threadRuntimeCanArchive(thread.runtime),
isWorking: isThreadWorking(thread),
supports,
snoozePresets,
canShareWithGuest,
Expand Down
Loading