Skip to content

Commit 97ae3ef

Browse files
authored
fix(sig): Always show the inbox is there are reports, add ability to view all tasks in dev (#1388)
1 parent 4af35f8 commit 97ae3ef

6 files changed

Lines changed: 109 additions & 50 deletions

File tree

apps/code/src/renderer/features/inbox/components/InboxSignalsTab.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
useInboxReportSignals,
77
useInboxReportsInfinite,
88
} from "@features/inbox/hooks/useInboxReports";
9+
import { useSignalSourceConfigs } from "@features/inbox/hooks/useSignalSourceConfigs";
910
import { useInboxCloudTaskStore } from "@features/inbox/stores/inboxCloudTaskStore";
1011
import { useInboxSignalsFilterStore } from "@features/inbox/stores/inboxSignalsFilterStore";
1112
import { useInboxSignalsSidebarStore } from "@features/inbox/stores/inboxSignalsSidebarStore";
@@ -19,6 +20,7 @@ import {
1920
INBOX_REFETCH_INTERVAL_MS,
2021
} from "@features/inbox/utils/inboxConstants";
2122
import { useDraftStore } from "@features/message-editor/stores/draftStore";
23+
import { useSettingsDialogStore } from "@features/settings/stores/settingsDialogStore";
2224
import { useCreateTask } from "@features/tasks/hooks/useTasks";
2325
import { useFeatureFlag } from "@hooks/useFeatureFlag";
2426
import { useRepositoryIntegration } from "@hooks/useIntegrations";
@@ -116,6 +118,9 @@ export function InboxSignalsTab() {
116118
const sortField = useInboxSignalsFilterStore((s) => s.sortField);
117119
const sortDirection = useInboxSignalsFilterStore((s) => s.sortDirection);
118120
const searchQuery = useInboxSignalsFilterStore((s) => s.searchQuery);
121+
const { data: signalSourceConfigs } = useSignalSourceConfigs();
122+
const hasSignalSources = signalSourceConfigs?.some((c) => c.enabled) ?? false;
123+
const openSettings = useSettingsDialogStore((s) => s.open);
119124

120125
const windowFocused = useRendererWindowFocusStore((s) => s.focused);
121126
const isInboxView = useNavigationStore((s) => s.view.type === "inbox");
@@ -307,6 +312,37 @@ export function InboxSignalsTab() {
307312
}
308313

309314
if (allReports.length === 0) {
315+
if (!hasSignalSources) {
316+
return (
317+
<Flex
318+
direction="column"
319+
align="center"
320+
justify="center"
321+
gap="5"
322+
height="100%"
323+
px="5"
324+
style={{ maxWidth: 480, margin: "0 auto" }}
325+
>
326+
<Flex direction="column" gap="2" style={{ width: "100%" }}>
327+
<Text
328+
size="2"
329+
weight="medium"
330+
align="center"
331+
style={{ color: "var(--gray-12)" }}
332+
>
333+
Enable Inbox
334+
</Text>
335+
<Text size="1" align="center" style={{ color: "var(--gray-11)" }}>
336+
Inbox automatically analyzes your product data and prioritizes
337+
actionable tasks. Choose which sources to enable for this project.
338+
</Text>
339+
</Flex>
340+
<Button size="2" onClick={() => openSettings("signals")}>
341+
Configure signal sources
342+
</Button>
343+
</Flex>
344+
);
345+
}
310346
return <InboxWarmingUpState />;
311347
}
312348

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,11 @@
11
import { useSettingsDialogStore } from "@features/settings/stores/settingsDialogStore";
22
import { useSetHeaderContent } from "@hooks/useSetHeaderContent";
33
import { EnvelopeSimpleIcon, GearSixIcon } from "@phosphor-icons/react";
4-
import { Box, Button, Flex, Text } from "@radix-ui/themes";
4+
import { Box, Flex, Text } from "@radix-ui/themes";
55
import { useMemo } from "react";
6-
import { useSignalSourceConfigs } from "../hooks/useSignalSourceConfigs";
76
import { InboxSignalsTab } from "./InboxSignalsTab";
87

9-
function SignalsNotConfiguredState() {
10-
const openSettings = useSettingsDialogStore((s) => s.open);
11-
12-
return (
13-
<Flex
14-
direction="column"
15-
align="center"
16-
justify="center"
17-
gap="5"
18-
height="100%"
19-
px="5"
20-
style={{ maxWidth: 480, margin: "0 auto" }}
21-
>
22-
<Flex direction="column" gap="2" style={{ width: "100%" }}>
23-
<Text
24-
size="2"
25-
weight="medium"
26-
align="center"
27-
style={{ color: "var(--gray-12)" }}
28-
>
29-
Enable Inbox
30-
</Text>
31-
<Text size="1" align="center" style={{ color: "var(--gray-11)" }}>
32-
Inbox automatically analyzes your product data and prioritizes
33-
actionable tasks. Choose which sources to enable for this project.
34-
</Text>
35-
</Flex>
36-
37-
<Button size="2" onClick={() => openSettings("signals")}>
38-
Configure signal sources
39-
</Button>
40-
</Flex>
41-
);
42-
}
43-
448
export function InboxView() {
45-
const { data: configs, isLoading } = useSignalSourceConfigs();
46-
const hasConfigs = configs?.some((c) => c.enabled) ?? false;
479
const openSettings = useSettingsDialogStore((s) => s.open);
4810

4911
const headerContent = useMemo(
@@ -75,11 +37,7 @@ export function InboxView() {
7537

7638
return (
7739
<Box style={{ height: "100%" }}>
78-
{isLoading ? null : hasConfigs ? (
79-
<InboxSignalsTab />
80-
) : (
81-
<SignalsNotConfiguredState />
82-
)}
40+
<InboxSignalsTab />
8341
</Box>
8442
);
8543
}

apps/code/src/renderer/features/sidebar/components/TaskListView.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
FolderOpenIcon,
1111
FolderSimple,
1212
FunnelSimple as FunnelSimpleIcon,
13+
User,
14+
Users,
1315
} from "@phosphor-icons/react";
1416
import { Box, Flex, Popover, Text } from "@radix-ui/themes";
1517
import { useWorkspace } from "@renderer/features/workspace/hooks/useWorkspace";
@@ -120,8 +122,10 @@ function TaskRow({
120122
function TaskFilterMenu() {
121123
const organizeMode = useSidebarStore((state) => state.organizeMode);
122124
const sortMode = useSidebarStore((state) => state.sortMode);
125+
const showAllUsers = useSidebarStore((state) => state.showAllUsers);
123126
const setOrganizeMode = useSidebarStore((state) => state.setOrganizeMode);
124127
const setSortMode = useSidebarStore((state) => state.setSortMode);
128+
const setShowAllUsers = useSidebarStore((state) => state.setShowAllUsers);
125129

126130
const itemClassName =
127131
"flex w-full items-center justify-between rounded-sm px-1 py-1 text-left text-[13px] text-gray-12 transition-colors hover:bg-gray-3";
@@ -223,6 +227,51 @@ function TaskFilterMenu() {
223227
</button>
224228
</Box>
225229
</Box>
230+
231+
{import.meta.env.DEV && (
232+
<>
233+
<div className="my-0.25 border-gray-6 border-t" />
234+
235+
<Box>
236+
<Text
237+
size="1"
238+
className="text-gray-10"
239+
weight="medium"
240+
style={{ paddingLeft: "1px" }}
241+
>
242+
Show
243+
</Text>
244+
<Box mt="1">
245+
<button
246+
type="button"
247+
className={itemClassName}
248+
onClick={() => setShowAllUsers(false)}
249+
>
250+
<span className="flex items-center gap-1 text-gray-12">
251+
<User size={14} className="text-gray-12" />
252+
<span>My tasks</span>
253+
</span>
254+
{!showAllUsers && (
255+
<Check size={12} className="text-gray-12" />
256+
)}
257+
</button>
258+
<button
259+
type="button"
260+
className={itemClassName}
261+
onClick={() => setShowAllUsers(true)}
262+
>
263+
<span className="flex items-center gap-1 text-gray-12">
264+
<Users size={14} className="text-gray-12" />
265+
<span>All tasks</span>
266+
</span>
267+
{showAllUsers && (
268+
<Check size={12} className="text-gray-12" />
269+
)}
270+
</button>
271+
</Box>
272+
</Box>
273+
</>
274+
)}
226275
</Flex>
227276
</Popover.Content>
228277
</Popover.Root>

apps/code/src/renderer/features/sidebar/hooks/useSidebarData.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,22 @@ function groupByRepository(
145145
export function useSidebarData({
146146
activeView,
147147
}: UseSidebarDataProps): SidebarData {
148-
const { data: rawTasks = [], isLoading: isLoadingTasks } = useTasks();
148+
const showAllUsers = useSidebarStore((state) => state.showAllUsers);
149+
const { data: rawTasks = [], isLoading: isLoadingTasks } = useTasks({
150+
showAllUsers,
151+
});
149152
const { data: workspaces, isFetched: isWorkspacesFetched } = useWorkspaces();
150153
const archivedTaskIds = useArchivedTaskIds();
151154
const suspendedTaskIds = useSuspendedTaskIds();
152155
const isLoading = isLoadingTasks || !isWorkspacesFetched;
153156
const allTasks = useMemo(
154157
() =>
155158
rawTasks.filter(
156-
(task) => !archivedTaskIds.has(task.id) && !!workspaces?.[task.id],
159+
(task) =>
160+
!archivedTaskIds.has(task.id) &&
161+
(showAllUsers || !!workspaces?.[task.id]),
157162
),
158-
[rawTasks, archivedTaskIds, workspaces],
163+
[rawTasks, archivedTaskIds, workspaces, showAllUsers],
159164
);
160165
const sessions = useSessions();
161166
const { timestamps } = useTaskViewed();

apps/code/src/renderer/features/sidebar/stores/sidebarStore.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface SidebarStoreState {
1111
historyVisibleCount: number;
1212
organizeMode: "by-project" | "chronological";
1313
sortMode: "updated" | "created";
14+
showAllUsers: boolean;
1415
}
1516

1617
interface SidebarStoreActions {
@@ -27,6 +28,7 @@ interface SidebarStoreActions {
2728
resetHistoryVisibleCount: () => void;
2829
setOrganizeMode: (mode: SidebarStoreState["organizeMode"]) => void;
2930
setSortMode: (mode: SidebarStoreState["sortMode"]) => void;
31+
setShowAllUsers: (showAllUsers: boolean) => void;
3032
}
3133

3234
type SidebarStore = SidebarStoreState & SidebarStoreActions;
@@ -43,6 +45,7 @@ export const useSidebarStore = create<SidebarStore>()(
4345
historyVisibleCount: 25,
4446
organizeMode: "by-project",
4547
sortMode: "updated",
48+
showAllUsers: false,
4649
setOpen: (open) => set({ open, hasUserSetOpen: true }),
4750
setOpenAuto: (open) =>
4851
set((state) => (state.hasUserSetOpen ? state : { open })),
@@ -91,6 +94,7 @@ export const useSidebarStore = create<SidebarStore>()(
9194
resetHistoryVisibleCount: () => set({ historyVisibleCount: 25 }),
9295
setOrganizeMode: (organizeMode) => set({ organizeMode }),
9396
setSortMode: (sortMode) => set({ sortMode }),
97+
setShowAllUsers: (showAllUsers) => set({ showAllUsers }),
9498
}),
9599
{
96100
name: "sidebar-storage",
@@ -103,6 +107,7 @@ export const useSidebarStore = create<SidebarStore>()(
103107
historyVisibleCount: state.historyVisibleCount,
104108
organizeMode: state.organizeMode,
105109
sortMode: state.sortMode,
110+
showAllUsers: state.showAllUsers,
106111
}),
107112
merge: (persisted, current) => {
108113
const persistedState = persisted as {
@@ -114,6 +119,7 @@ export const useSidebarStore = create<SidebarStore>()(
114119
historyVisibleCount?: number;
115120
organizeMode?: SidebarStoreState["organizeMode"];
116121
sortMode?: SidebarStoreState["sortMode"];
122+
showAllUsers?: boolean;
117123
};
118124
return {
119125
...current,
@@ -127,6 +133,7 @@ export const useSidebarStore = create<SidebarStore>()(
127133
persistedState.historyVisibleCount ?? current.historyVisibleCount,
128134
organizeMode: persistedState.organizeMode ?? current.organizeMode,
129135
sortMode: persistedState.sortMode ?? current.sortMode,
136+
showAllUsers: persistedState.showAllUsers ?? current.showAllUsers,
130137
};
131138
},
132139
},

apps/code/src/renderer/features/tasks/hooks/useTasks.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ const taskKeys = {
2929
detail: (id: string) => [...taskKeys.details(), id] as const,
3030
};
3131

32-
export function useTasks(filters?: { repository?: string }) {
32+
export function useTasks(filters?: {
33+
repository?: string;
34+
showAllUsers?: boolean;
35+
}) {
3336
const { data: currentUser } = useMeQuery();
37+
const createdBy = filters?.showAllUsers ? undefined : currentUser?.id;
3438

3539
return useAuthenticatedQuery(
36-
taskKeys.list({ ...filters, createdBy: currentUser?.id }),
40+
taskKeys.list({ ...filters, createdBy }),
3741
(client) =>
3842
client.getTasks({
3943
repository: filters?.repository,
40-
createdBy: currentUser?.id,
44+
createdBy,
4145
}) as unknown as Promise<Task[]>,
4246
{ enabled: !!currentUser?.id, refetchInterval: TASK_LIST_POLL_INTERVAL_MS },
4347
);

0 commit comments

Comments
 (0)