Skip to content

feat(tasks): add toggle for internal tasks in sidebar for staff#1952

Merged
joshsny merged 2 commits intomainfrom
posthog-code/show-internal-tasks-toggle
Apr 30, 2026
Merged

feat(tasks): add toggle for internal tasks in sidebar for staff#1952
joshsny merged 2 commits intomainfrom
posthog-code/show-internal-tasks-toggle

Conversation

@posthog
Copy link
Copy Markdown
Contributor

@posthog posthog Bot commented Apr 30, 2026

Summary

Adds a dev-only toggle to the sidebar's task filter menu for showing internal tasks. Mirrors PostHog/posthog#56943, which adds the equivalent toggle to the main tasks page in the PostHog app — making PostHog Code usable as a debug UI for internal task runs locally.

The backend (products/tasks/backend/api.py) already gates internal=true behind settings.DEBUG, so this is a no-op in production builds even if import.meta.env.DEV somehow evaluated true.

Changes

  • Task type: add optional internal?: boolean field.
  • posthogClient.getTasks: forward an optional internal query param.
  • useTasks hook: accept showInternal and pass through to the API + query key.
  • sidebarStore: persist showInternal flag alongside the other filter state.
  • useSidebarData: when showInternal is on, bypass the local-workspace filter (internal tasks are server-side and won't have a workspace).
  • TaskListView's TaskFilterMenu: new "Internal tasks" radio group (Hide/Show), rendered only when import.meta.env.DEV, sitting next to the existing dev-only "Show all users" toggle.

Test plan

  • In dev, open the sidebar filter menu — confirm the "Internal tasks" Hide/Show radio group appears under the "Show" group.
  • Toggle to "Show" — task list refetches with internal=true and only internal tasks render (created by the agent service / etc.).
  • Toggle back to "Hide" — only user-facing tasks render again.
  • Reload the app — selection persists via sidebar-storage.
  • In a production build, confirm the toggle does not render.

Created with PostHog Code

PostHog Code and others added 2 commits April 30, 2026 14:59
Mirrors the upstream PostHog/posthog#56943 toggle so the desktop app can
surface internal tasks for local debugging. The toggle lives in the
sidebar's task filter menu, only renders when import.meta.env.DEV is
true, and bypasses the workspace-existence filter so server-side
internal tasks (which won't have a local workspace) are visible. The
backend already gates internal=true behind DEBUG, so this stays a no-op
in production.

Generated-By: PostHog Code
Task-Id: 10e42168-e889-48c0-a19e-bf07d32c2b37
@joshsny joshsny force-pushed the posthog-code/show-internal-tasks-toggle branch from 908fba3 to 799a9c0 Compare April 30, 2026 14:09
@joshsny joshsny changed the title feat(tasks): add dev-only toggle for internal tasks in sidebar feat(tasks): add toggle for internal tasks in sidebar for staff Apr 30, 2026
@joshsny joshsny marked this pull request as ready for review April 30, 2026 14:10
@joshsny joshsny requested a review from a team April 30, 2026 14:10
@joshsny joshsny enabled auto-merge (squash) April 30, 2026 14:11
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/renderer/features/tasks/hooks/useTasks.ts:39-40
**`createdBy` not cleared when fetching internal tasks**

When `showInternal` is `true` but `showAllUsers` is `false`, `createdBy` is still set to `currentUser?.id`. Internal tasks are created by the agent service (not the current user), so the backend receives both `internal=true` and `created_by=<userId>` — and applying both filters together will likely return an empty result set. `createdBy` should be `undefined` whenever `showInternal` is `true`.

```suggestion
  const createdBy = filters?.showAllUsers || filters?.showInternal ? undefined : currentUser?.id;
```

### Issue 2 of 2
apps/code/src/renderer/features/sidebar/components/TaskListView.tsx:199-222
**Toggle visible in production for staff users but silently non-functional**

The existing "Show all users" toggle is gated by `import.meta.env.DEV`, but this new toggle uses `isStaff`. Staff users in production builds will see "Task visibility" in the filter menu; however, the backend only honours `internal=true` when `settings.DEBUG` is enabled, so the toggle silently does nothing in production. Consider aligning the guard with the existing pattern (`import.meta.env.DEV`) or adding an `import.meta.env.DEV` check alongside `isStaff` to avoid showing a non-functional control to production staff.

Reviews (1): Last reviewed commit: "show for staff users" | Re-trigger Greptile

Comment on lines 39 to +40
const createdBy = filters?.showAllUsers ? undefined : currentUser?.id;
const internal = filters?.showInternal ? true : undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 createdBy not cleared when fetching internal tasks

When showInternal is true but showAllUsers is false, createdBy is still set to currentUser?.id. Internal tasks are created by the agent service (not the current user), so the backend receives both internal=true and created_by=<userId> — and applying both filters together will likely return an empty result set. createdBy should be undefined whenever showInternal is true.

Suggested change
const createdBy = filters?.showAllUsers ? undefined : currentUser?.id;
const internal = filters?.showInternal ? true : undefined;
const createdBy = filters?.showAllUsers || filters?.showInternal ? undefined : currentUser?.id;
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/tasks/hooks/useTasks.ts
Line: 39-40

Comment:
**`createdBy` not cleared when fetching internal tasks**

When `showInternal` is `true` but `showAllUsers` is `false`, `createdBy` is still set to `currentUser?.id`. Internal tasks are created by the agent service (not the current user), so the backend receives both `internal=true` and `created_by=<userId>` — and applying both filters together will likely return an empty result set. `createdBy` should be `undefined` whenever `showInternal` is `true`.

```suggestion
  const createdBy = filters?.showAllUsers || filters?.showInternal ? undefined : currentUser?.id;
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 199 to 222
</DropdownMenuRadioGroup>
</>
)}

{isStaff && (
<>
<DropdownMenuSeparator />

<MenuLabel>Task visibility</MenuLabel>
<DropdownMenuRadioGroup
value={showInternal ? "internal" : "external"}
onValueChange={(value) => setShowInternal(value === "internal")}
>
<DropdownMenuRadioItem value="external">
External
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="internal">
Internal
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</>
)}
</DropdownMenuContent>
</DropdownMenu>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Toggle visible in production for staff users but silently non-functional

The existing "Show all users" toggle is gated by import.meta.env.DEV, but this new toggle uses isStaff. Staff users in production builds will see "Task visibility" in the filter menu; however, the backend only honours internal=true when settings.DEBUG is enabled, so the toggle silently does nothing in production. Consider aligning the guard with the existing pattern (import.meta.env.DEV) or adding an import.meta.env.DEV check alongside isStaff to avoid showing a non-functional control to production staff.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/sidebar/components/TaskListView.tsx
Line: 199-222

Comment:
**Toggle visible in production for staff users but silently non-functional**

The existing "Show all users" toggle is gated by `import.meta.env.DEV`, but this new toggle uses `isStaff`. Staff users in production builds will see "Task visibility" in the filter menu; however, the backend only honours `internal=true` when `settings.DEBUG` is enabled, so the toggle silently does nothing in production. Consider aligning the guard with the existing pattern (`import.meta.env.DEV`) or adding an `import.meta.env.DEV` check alongside `isStaff` to avoid showing a non-functional control to production staff.

How can I resolve this? If you propose a fix, please make it concise.

@joshsny joshsny merged commit 76f020c into main Apr 30, 2026
15 checks passed
@joshsny joshsny deleted the posthog-code/show-internal-tasks-toggle branch April 30, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants