Skip to content

feat(sidebar): feature-flagged file-system tree sidebar#2468

Draft
raquelmsmith wants to merge 4 commits into
mainfrom
posthog-code/file-system-sidebar
Draft

feat(sidebar): feature-flagged file-system tree sidebar#2468
raquelmsmith wants to merge 4 commits into
mainfrom
posthog-code/file-system-sidebar

Conversation

@raquelmsmith
Copy link
Copy Markdown
Member

Summary

Behind the posthog-code-file-system-sidebar feature flag (force-enabled in dev), this replaces the sidebar's repo/task list with a tree of items from the PostHog file-system desktop surface introduced server-side by PostHog #61047. Folders render with a # icon and are expandable exactly like the current repo sections; leaf items render as inert rows (no-op click) for this first pass.

The desktop tree is served from its own server-controlled route GET /api/projects/{id}/desktop_file_system/ (surface is not a query param). That route isn't in the generated OpenAPI client yet, so it's called via the raw fetcher, mirroring getTaskSummaries.

Changes

New (under apps/code/src/renderer/features/sidebar/):

  • utils/fileSystemTree.ts — pure buildFileSystemTree() turning the flat FileSystem[] into a nested tree: derives intermediate folders from path segments, attaches explicit type: "folder" rows, guards empty segments, sorts folders-first then alphabetically.
  • utils/fileSystemTree.test.ts — 6 unit tests (folder derivation, explicit rows, sorting, empty-segment guarding, folder/leaf collisions).
  • hooks/useDesktopFileSystem.tsuseAuthenticatedQuery wrapper, mirroring useTaskSummaries.
  • components/FileSystemTreeView.tsx — recursive renderer using SidebarSection (folders, # icon) and SidebarItem (leaves), with a "Nothing here yet" empty state, fs:-namespaced collapse keys, and a visual indent cap.

Modified:

  • api/posthogClient.tsgetDesktopFileSystem() with pagination-following.
  • shared/constants.tsFILE_SYSTEM_SIDEBAR_FLAG.
  • components/SidebarSection.tsx — additive depth prop for nested indentation (depth=0 reproduces the prior pl-2, so TaskListView is visually unchanged).
  • components/SidebarMenu.tsx — flag branch between FileSystemTreeView and the existing TaskListView; top nav and ProjectSwitcher untouched.

Notes

  • The desktop surface may return an empty list until populated server-side, in which case the sidebar shows the empty state.
  • Leaf-item clicks are intentionally inert for now; the click hook is left ready for later wiring.

Verification

  • pnpm --filter code typecheck passes
  • biome lint clean on all changed files
  • pnpm --filter code test fileSystemTree — 6/6 pass

Not yet verified with a live Electron run.

Behind the `posthog-code-file-system-sidebar` flag (force-enabled in dev),
replace the sidebar's repo/task list with a tree of items from the PostHog
file-system "desktop" surface (PostHog PR #61047). Folders render with a `#`
icon and are expandable like the current repo sections; leaf items render as
inert rows for now.

- posthogClient: getDesktopFileSystem() hits the server-controlled
  /api/projects/{id}/desktop_file_system/ route via the raw fetcher with
  pagination-following (route isn't in the generated OpenAPI client).
- buildFileSystemTree(): pure util turning the flat list into a nested tree
  (derives intermediate folders, attaches explicit folder rows, guards empty
  segments, sorts folders-first then alphabetically) + unit tests.
- useDesktopFileSystem(): useAuthenticatedQuery wrapper mirroring useTaskSummaries.
- FileSystemTreeView: recursive renderer reusing SidebarSection (folders) and
  SidebarItem (leaves), with empty state and fs:-namespaced collapse keys.
- SidebarSection: additive `depth` prop for nested indentation (depth=0 keeps
  the existing TaskListView rendering unchanged).
- SidebarMenu: flag branch between the new tree view and TaskListView.

Generated-By: PostHog Code
Task-Id: 26a4498f-f1b9-405b-a439-56af14877c6d
Make the flagged file-system sidebar a panel the user can switch away
from, instead of fully replacing the task list. Adds a two-segment
"Files" / "Tasks" toggle shown only when the file-system sidebar flag is
on, with the selected panel persisted in the sidebar store. When the
flag is off, the task list renders as before.

Generated-By: PostHog Code
Task-Id: 26a4498f-f1b9-405b-a439-56af14877c6d
Rename the file-system sidebar panel label from "Files" to "Channels"
(keeping the persisted "files" panel value), and add the ability to
create and delete top-level channels synced to the cloud
desktop_file_system surface.

- SidebarPanelToggle: label "Channels" with Hash icon
- posthogClient: createDesktopFileSystemChannel / deleteDesktopFileSystem
- useDesktopFileSystemMutations: create/delete with query invalidation
- ChannelsHeader: inline add-channel input
- SidebarSection: generic hover delete action
- FileSystemTreeView: delete top-level channels behind a confirmation

Generated-By: PostHog Code
Task-Id: b3c22a1c-8b74-4790-b7a1-673715dee381
Replace the inline channel-name input in the sidebar with a Slack-style
"Create a channel" modal: a Name field with a # prefix, character
counter, helper text, and a Create action.

Generated-By: PostHog Code
Task-Id: b3c22a1c-8b74-4790-b7a1-673715dee381
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.

1 participant