Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 0 additions & 24 deletions apps/mobile/src/features/tasks/components/TaskFilterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Text } from "@components/text";
import { Check, FunnelSimple } from "phosphor-react-native";
import { useState } from "react";
import { Modal, Pressable, ScrollView, View } from "react-native";
import { useUserQuery } from "@/features/auth";
import { useScreenInsets } from "@/hooks/useScreenInsets";
import { useThemeColors } from "@/lib/theme";
import {
Expand Down Expand Up @@ -49,10 +48,6 @@ export function TaskFilterMenu({ open, onClose }: TaskFilterMenuProps) {
const setOrganizeMode = useTaskStore((s) => s.setOrganizeMode);
const sortMode = useTaskStore((s) => s.sortMode);
const setSortMode = useTaskStore((s) => s.setSortMode);
const showInternal = useTaskStore((s) => s.showInternal);
const setShowInternal = useTaskStore((s) => s.setShowInternal);
const { data: userData } = useUserQuery();
const isStaff = userData?.is_staff === true;

const pickOrganize = (mode: OrganizeMode) => {
setOrganizeMode(mode);
Expand Down Expand Up @@ -120,25 +115,6 @@ export function TaskFilterMenu({ open, onClose }: TaskFilterMenuProps) {
onPress={() => pickSort("updated")}
/>
</View>

{/* Task visibility (staff only) */}
{isStaff ? (
<>
<SectionHeader title="Task visibility" />
<View className="mb-5">
<OptionRow
label="External"
selected={!showInternal}
onPress={() => setShowInternal(false)}
/>
<OptionRow
label="Internal"
selected={showInternal}
onPress={() => setShowInternal(true)}
/>
</View>
</>
) : null}
</ScrollView>
</View>
</Modal>
Expand Down
9 changes: 2 additions & 7 deletions apps/mobile/src/features/tasks/hooks/useTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function useTasks(filters?: {
}) {
const { projectId, oauthAccessToken } = useAuthStore();
const { data: currentUser } = useUserQuery();
const { sortMode, showInternal, filter } = useTaskStore();
const { sortMode, filter } = useTaskStore();

const queryFilters = {
...filters,
Expand All @@ -81,12 +81,7 @@ export function useTasks(filters?: {
(task) => task.latest_run?.environment !== "local",
);

const filteredTasks = filterAndSortTasks(
cloudTasks,
sortMode,
showInternal,
filter,
);
const filteredTasks = filterAndSortTasks(cloudTasks, sortMode, filter);

return {
tasks: filteredTasks,
Expand Down
9 changes: 2 additions & 7 deletions apps/mobile/src/features/tasks/stores/taskStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ describe("filterAndSortTasks", () => {
const placeholder = makeTask({ id: "warm", title, description });
const real = makeTask({ id: "real" });

const result = filterAndSortTasks(
[placeholder, real],
"updated",
false,
"",
);
const result = filterAndSortTasks([placeholder, real], "updated", "");

expect(result.map((t) => t.id)).toEqual(["real"]);
},
Expand All @@ -47,7 +42,7 @@ describe("filterAndSortTasks", () => {
])("keeps a real task with $name", ({ title, description }) => {
const task = makeTask({ id: "real", title, description });

const result = filterAndSortTasks([task], "updated", false, "");
const result = filterAndSortTasks([task], "updated", "");

expect(result.map((t) => t.id)).toEqual(["real"]);
});
Expand Down
11 changes: 0 additions & 11 deletions apps/mobile/src/features/tasks/stores/taskStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ interface TaskUIState {
selectedTaskId: string | null;
organizeMode: OrganizeMode;
sortMode: SortMode;
showInternal: boolean;
filter: string;
/** Most-recently-used repository for the new-task composer. Pre-fills the
* repo pill so users don't have to re-pick the same repo every time. */
Expand All @@ -36,7 +35,6 @@ interface TaskUIState {
selectTask: (taskId: string | null) => void;
setOrganizeMode: (mode: OrganizeMode) => void;
setSortMode: (mode: SortMode) => void;
setShowInternal: (showInternal: boolean) => void;
setFilter: (filter: string) => void;
setLastRepository: (selection: RepositorySelection) => void;
setComposerConfig: (
Expand All @@ -53,7 +51,6 @@ export const useTaskStore = create<TaskUIState>()(
selectedTaskId: null,
organizeMode: "by-project",
sortMode: "updated",
showInternal: false,
filter: "",
lastRepository: EMPTY_REPOSITORY_SELECTION,
composerConfigByTaskId: {},
Expand All @@ -62,7 +59,6 @@ export const useTaskStore = create<TaskUIState>()(
selectTask: (selectedTaskId) => set({ selectedTaskId }),
setOrganizeMode: (organizeMode) => set({ organizeMode }),
setSortMode: (sortMode) => set({ sortMode }),
setShowInternal: (showInternal) => set({ showInternal }),
setFilter: (filter) => set({ filter }),
setLastRepository: (lastRepository) => set({ lastRepository }),
setComposerConfig: (taskId, config) =>
Expand Down Expand Up @@ -99,7 +95,6 @@ export const useTaskStore = create<TaskUIState>()(
partialize: (state) => ({
organizeMode: state.organizeMode,
sortMode: state.sortMode,
showInternal: state.showInternal,
lastRepository: state.lastRepository,
composerConfigByTaskId: state.composerConfigByTaskId,
}),
Expand All @@ -123,19 +118,13 @@ export function taskActivityTimestamp(task: Task, sortMode: SortMode): number {
export function filterAndSortTasks(
tasks: Task[],
sortMode: SortMode,
showInternal: boolean,
filter: string,
): Task[] {
let filtered = tasks;

// Warm-sandbox prewarming creates empty placeholder tasks; never surface them.
filtered = filtered.filter((task) => !isContentlessTask(task));

// Visibility filter — mirrors desktop radio: External hides internal, Internal shows only internal.
filtered = filtered.filter((task) =>
showInternal ? task.internal === true : task.internal !== true,
);

if (filter) {
const lowerFilter = filter.toLowerCase();
filtered = filtered.filter(
Expand Down
70 changes: 70 additions & 0 deletions packages/core/src/sidebar/buildSidebarData.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { describe, expect, it } from "vitest";
import {
type FilterVisibleOptions,
filterVisibleTasks,
type SidebarTask,
} from "./buildSidebarData";

function task(id: string): SidebarTask {
return {
id,
title: id,
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
};
}

const BASE: FilterVisibleOptions = {
archivedIds: new Set(),
workspaceIds: new Set(),
provisioningIds: new Set(),
showAllUsers: false,
showSystemStarted: false,
};

describe("filterVisibleTasks", () => {
it("hides tasks with no local workspace/provisioning in the default view", () => {
const result = filterVisibleTasks([task("a")], BASE);
expect(result).toEqual([]);
});

it.each([
{ name: "workspace", key: "workspaceIds" as const },
{ name: "provisioning", key: "provisioningIds" as const },
])("shows a task present locally via $name", ({ key }) => {
const result = filterVisibleTasks([task("a")], {
...BASE,
[key]: new Set(["a"]),
});
expect(result.map((t) => t.id)).toEqual(["a"]);
});

it("always hides archived tasks, even when otherwise visible", () => {
const result = filterVisibleTasks([task("a")], {
...BASE,
workspaceIds: new Set(["a"]),
archivedIds: new Set(["a"]),
});
expect(result).toEqual([]);
});

it.each([
{ name: "showAllUsers", flag: "showAllUsers" as const },
{ name: "showSystemStarted", flag: "showSystemStarted" as const },
])("bypasses the local-scope gate when $name is set", ({ flag }) => {
const result = filterVisibleTasks([task("a"), task("b")], {
...BASE,
[flag]: true,
});
expect(result.map((t) => t.id)).toEqual(["a", "b"]);
});

it("still hides archived tasks when the local-scope gate is bypassed", () => {
const result = filterVisibleTasks([task("a"), task("b")], {
...BASE,
showSystemStarted: true,
archivedIds: new Set(["a"]),
});
expect(result.map((t) => t.id)).toEqual(["b"]);
});
});
16 changes: 7 additions & 9 deletions packages/core/src/sidebar/buildSidebarData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export interface FilterVisibleOptions {
workspaceIds: ReadonlySet<string>;
provisioningIds: ReadonlySet<string>;
showAllUsers: boolean;
showInternal: boolean;
// System-started tasks (signals, support queue, …) run in the cloud and have
// no local workspace, so this view bypasses the workspace/provisioning gate
// that scopes the default view to the tasks present on this machine.
showSystemStarted: boolean;
}

export function filterVisibleTasks(
Expand All @@ -75,7 +78,7 @@ export function filterVisibleTasks(
(task) =>
!options.archivedIds.has(task.id) &&
(options.showAllUsers ||
options.showInternal ||
options.showSystemStarted ||
options.workspaceIds.has(task.id) ||
options.provisioningIds.has(task.id)),
);
Expand Down Expand Up @@ -129,8 +132,6 @@ export interface DeriveTaskDataContext {
timestamp: TaskTimestamp | undefined;
pinnedIds: ReadonlySet<string>;
suspendedIds: ReadonlySet<string>;
slackTaskIds: ReadonlySet<string>;
slackThreadUrlByTaskId: ReadonlyMap<string, string>;
}

export function deriveTaskData(
Expand All @@ -154,11 +155,8 @@ export function deriveTaskData(
? task.latest_run.output.pr_url
: ((session?.cloudOutput?.pr_url as string | undefined) ?? null);

const originProduct =
task.origin_product ??
(ctx.slackTaskIds.has(task.id) ? "slack" : undefined);
const slackThreadUrl =
task.slack_thread_url ?? ctx.slackThreadUrlByTaskId.get(task.id);
const originProduct = task.origin_product;
const slackThreadUrl = task.slack_thread_url;

return {
id: task.id,
Expand Down
57 changes: 0 additions & 57 deletions packages/core/src/sidebar/summaryIds.test.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/core/src/sidebar/summaryIds.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/ui/src/features/canvas/hooks/useChannelTaskData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { useSuspendedTaskIds } from "@posthog/ui/features/suspension/useSuspende
import { useWorkspace } from "@posthog/ui/features/workspace/useWorkspace";
import { useMemo } from "react";

const EMPTY_SET: ReadonlySet<string> = new Set();
const EMPTY_MAP: ReadonlyMap<string, string> = new Map();

// Build the same `TaskData` shape the sidebar feeds into `<TaskIcon>` so a
// filed channel task renders the same status icons (needs-permission, cloud
// run status, PR state, generating, etc.) as in the sidebar/command palette.
Expand All @@ -36,8 +33,6 @@ export function useChannelTaskData(
timestamp: timestamps[task.id],
pinnedIds: pinnedTaskIds,
suspendedIds: suspendedTaskIds,
slackTaskIds: EMPTY_SET,
slackThreadUrlByTaskId: EMPTY_MAP,
});
}, [task, session, workspace, timestamps, pinnedTaskIds, suspendedTaskIds]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useTaskViewed } from "@posthog/ui/features/sidebar/useTaskViewed";
import { useMemo } from "react";

const EMPTY_SET: ReadonlySet<string> = new Set();
const EMPTY_STRING_MAP: ReadonlyMap<string, string> = new Map();

// Which canvas generation tasks should be shown nested under their canvas in
// the channel tree. A generation task nests while it's actively generating, and
Expand Down Expand Up @@ -57,8 +56,6 @@ export function useNestedGenerationTaskIds(
timestamp: timestamps[taskId],
pinnedIds: EMPTY_SET,
suspendedIds: EMPTY_SET,
slackTaskIds: EMPTY_SET,
slackThreadUrlByTaskId: EMPTY_STRING_MAP,
});
// `isUnread` requires a prior view (lastViewedAt set); a never-viewed
// task isn't "unread" but is still unseen, so check activity-vs-view
Expand Down
Loading
Loading