feat(code): canvas — experimental Channels space with gen-UI dashboards (project-bluebird)#2522
Merged
Conversation
Contributor
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
apps/code/src/renderer/features/canvas/components/WebsiteLayout.tsx:82-100
Both `onSave` and `onFork` silently discard errors. `onSave` wraps `saveDashboard` (which calls `mutateAsync`) in `void`, so any server error is dropped with no user feedback. `onFork` is `async` with `await createDashboard` but no `try/catch`; since React doesn't handle rejected Promises from click handlers, a network or server failure becomes an unhandled rejection and the user sees nothing.
```suggestion
const onSave = () => {
if (!dirty) return;
// The h1 title is the dashboard's name: sync it to the file on every save so
// renaming the canvas title renames the saved dashboard.
saveDashboard(dashboardId, liveSpec, dashboardTitleFromSpec(liveSpec)).catch(
(error) => {
toast.error("Couldn't save dashboard", {
description: error instanceof Error ? error.message : String(error),
});
},
);
};
const onFork = async () => {
if (!hasSpec) return;
try {
const title =
dashboardTitleFromSpec(liveSpec) ?? dashboard?.name ?? "Dashboard";
const name = `${title} (fork)`;
const record = await createDashboard(channelId, name, liveSpec);
setEditing(record.id, true);
void navigate({
to: "/website/$channelId/dashboards/$dashboardId",
params: { channelId, dashboardId: record.id },
});
} catch (error) {
toast.error("Couldn't fork dashboard", {
description: error instanceof Error ? error.message : String(error),
});
}
};
```
### Issue 2 of 3
apps/code/src/renderer/features/canvas/components/ChannelsList.tsx:144-156
**Orphaned dashboards on channel deletion**
`deleteChannel` removes the channel folder from the backend, but dashboards stored as child `desktop_file_system` entries (with `meta.channelId === channel.id`) are not cleaned up. If the backend doesn't cascade-delete children, those dashboard rows become orphaned — invisible in any channel list but still consuming storage and accumulating over time. Consider fetching and deleting child dashboards before (or concurrently with) deleting the folder, or at least documenting a backend expectation that DELETE cascades.
### Issue 3 of 3
apps/code/src/renderer/features/canvas/components/WebsiteDashboardsIndex.tsx:101-112
**N+1 IPC/API calls for dashboard preview thumbnails**
Each `DashboardCard` calls `useDashboard(summary.id)` to load the full spec for its preview. For a channel with N dashboards, opening the grid fires N+1 round trips (1 `dashboards.list` in main → N individual `dashboards.get` calls). The `staleTime: 5_000` helps on repeat views but the initial load is unbounded. Consider either including the spec in the list endpoint response, or adding a bulk-fetch procedure so the grid can be populated in a single call.
Reviews (1): Last reviewed commit: "feat(canvas): rename the channel "Sessio..." | Re-trigger Greptile |
Contributor
Author
|
Addressed the review comments in 97a5b53:
|
Stage 1 of landing feat/canvas on the post-#2442 (package-split) main: - canvas-gen, dashboards, dashboard-query services kept in apps/code/src/main/ services, imports rewired to the new homes (@posthog/core/auth, @posthog/shared for TypedEventEmitter+AcpMessage, @posthog/workspace-server agent service+token). - DI: tokens + strongly-typed MainBindings + container singleton binds. - trpc: canvasGen + dashboards routers registered in the root router. - Re-add @json-render/core dependency (dropped on reset). Extend @posthog/workspace-server AgentService with systemPromptOverride (replaces the default coding prompt for constrained surfaces) and disallowedTools (passed to the Claude SDK), which the canvas generator needs to inject its json-render catalog prompt and sandbox the agent to PostHog-MCP-only. The new shared agent API had dropped both. Code app + workspace-server + agent packages all typecheck clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ge graph Stage 2-3 of landing feat/canvas on post-#2442 main. Everything typechecks across all packages (22/22 turbo tasks). Renderer (→ packages/ui/src/features/canvas): - 27 files relocated; imports rewired to @posthog/ui/* + @posthog/* aliases. - Stores/subscriptions get the host tRPC client via resolveService(HOST_TRPC_CLIENT) (non-React DI accessor); hooks use useHostTRPC. - Website routes → packages/ui/src/router/routes/website*, route tree regenerated. tRPC visibility fix (the renderer types against HostRouter): - Canvas schemas + DI tokens + service interfaces → @posthog/core/canvas. - canvas-gen + dashboards routers → packages/host-router, registered in hostRouter. - Service classes stay in apps/code/main, bound to the core tokens in the container. Channels API: add desktop_file_system methods (get/create/rename/delete) to @posthog/api-client's PostHogAPIClient (the routes aren't in the generated OpenAPI). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Stage 4 — shell integration, gated by project-bluebird: - Add PROJECT_BLUEBIRD_FLAG to @posthog/shared. - Port the AppNav rail (Code ↔ Channels) into the canvas feature. - __root renders the rail when the flag is on, and gives /website its own chrome-free Channels space (the channel sidebar + content come from WebsiteLayout). Code space gains the rail so users can switch. Full repo typechecks (22/22 turbo tasks). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
WebsiteLayout only renders the content outlet; the channel list column lives in __root's channels-space branch (as before the port). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Web-readiness alignment with the package split: - DashboardsService + DashboardQueryService → packages/core/src/canvas (they only need AuthService + fetch, so any host can run them). They inject the core AUTH_SERVICE token + ROOT_LOGGER and are bound via canvasCoreModule. - CanvasGenService stays in apps/code/main: it bridges the agent runtime (@posthog/workspace-server) AND auth (@posthog/core), which can't be combined in a lower package without a dependency cycle (core → workspace-client → workspace-server → core). The app is the only layer that can depend on both. Full repo typechecks (22/22 turbo tasks). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Host boundary: move CanvasGenService out of apps/code (which must stay a thin Electron host — no @Injectable business services) into @posthog/host-router, the host-side package that already owns the canvas routers and depends on both @posthog/core (auth/schemas) and @posthog/workspace-server (agent), so no dependency cycle. The renderer imports host-router type-only, so no node code enters the bundle. Bound to CANVAS_GEN_SERVICE in the app container as before. - react-doctor: replace two "adjust state on prop change" effects (reset-on-open in CreateChannelModal, countdown reset in DashboardRefreshControl) with the inline prev-prop comparison pattern — no stale-for-one-commit flash. Full repo typechecks (22/22); host-boundary check + react-doctor both clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # packages/ui/src/router/routeTree.gen.ts
The /website routes stay registered regardless of project-bluebird, so a stale URL or restored session could strand a flag-off user in the channel layout rendered inside the Code chrome. Redirect them to Code once flags resolve, matching the pre-canvas behaviour exactly when the flag is off. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jonathanlab
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Everything new here is gated behind the
project-bluebirdfeature flag (on by default in dev builds only). With the flag off — every production user today — the app is the existing code-only shell, untouched: no nav rail,/websiteand/inboxredirect to/code, and the Code chrome is byte-for-byte as it is onmain. So this is safe to land and iterate on behind the flag.The app rail is the split point between the two UXs:
What this adds
A Slack-like vertical app nav rail (
AppNav) that switches between top-level "spaces", plus a whole new Channels space built on the PostHog desktop file system API.New routes
//code(no standalone home)./code,/code/*/website/website/$channelId/website/$channelId/dashboards/$dashboardId/website/$channelId/new/website/$channelId/tasks/$taskId/website/$channelId/settingsThe Channels space has its own chrome (rail + a persistent channel-list sidebar + its own breadcrumb/toolbar bars) rather than the Code header/sidebar.
Channels = desktop file-system folders
A channel is a top-level
folderrow on the project'sdesktop_file_systemsurface. Create / rename / delete go straight through the REST API, so channel names live on the backend and sync across clients.Dashboards & gen UI
A dashboard is a small, live, data-driven view of the current PostHog project — built conversationally rather than hand-configured.
How the gen UI works. Each dashboard has a chat thread. A PostHog agent (reusing the existing agent + PostHog MCP server) runs with a
json-rendersystem prompt describing a fixed component catalog (Page, Grid, Card, Stat, Table, BarList, Heading, etc.). The agent:json-renderJSONL patches, which the main process assembles into a Spec (a root + flat element map) and forwards to the renderer to render live.state.queries, so the dashboard can be refreshed (or polled) later by re-running those queries and patching the values back in.The dashboard always opens with a top-level h1 Heading — that h1 is the dashboard's name. Editing it renames the dashboard. Inline text editing is supported in edit mode (drag-and-drop reordering was removed).
How it's backed by the file-system API. Dashboards are not local files — each one is a
dashboard-typed row nested under its channel folder on the samedesktop_file_systemsurface:path.metaJSON blob (typed/documented asDashboardFileMeta).DashboardsService(main), which talks to the backend viaauthenticatedFetch.meta.specis currently last-write-wins (no versioning) — fine for now, revisit if multi-client editing becomes real.This keeps dashboards and their names in sync with the backend — the same surface that owns channel names.
See
apps/code/src/renderer/features/canvas/AGENTS.mdfor the breadcrumb / naming / storage conventions.Behind
project-bluebird; no-op for users until we flip the flag.