Skip to content

feat(web): cloud-tasks browser host#3447

Draft
gantoine wants to merge 3 commits into
mainfrom
posthog-code/web-host
Draft

feat(web): cloud-tasks browser host#3447
gantoine wants to merge 3 commits into
mainfrom
posthog-code/web-host

Conversation

@gantoine

Copy link
Copy Markdown
Member

Summary

Brings up apps/web as a cloud-tasks-only browser host for PostHog Code — the same @posthog/ui shell and @posthog/core services as the desktop app, running in a plain browser tab over web platform adapters (no Electron, no local workspace-server). An authenticated user can reach the cloud task list, create a cloud task, stream the SSE chat, review diffs, attach files, run /skill commands, and use Channels/Canvas — entirely client-side.

Also a portability smoke test for the layered architecture: @posthog/core and @posthog/ui run unchanged; everything web-specific lives in the apps/web composition root.

What's here

  • Auth — browser PKCE OAuth (popup → /callback → BroadcastChannel relay), refresh token encrypted at rest with a non-extractable Web Crypto key in IndexedDB.
  • Cloud tasks — real AuthService / CloudTaskService (host-agnostic core) over an in-process host-router slice via tRPC unstable_localLink; SSE chat, diffs, log history, sidebar.
  • Canvas / Channels — the four canvas routers over the host-agnostic canvas services (PostHog desktop_file_system API).
  • Attachments (drag/paste/picker), /skill commands (fflate bundler), posthog-js analytics/error-tracking/flags, browser notifications, per-device stores (localStorage).
  • Build — vendor + route code-splitting (TanStack Router autoCodeSplitting).
  • Tests — a hermetic Playwright happy-path e2e (boot → onboarding → sign-in → /callback), wired into CI alongside the desktop suite; mprocs procs for local dev.

⚠️ Depends on (merge first)

This is the additive web-host layer split out of #3353. It builds on three small enabling PRs and is red until they land, then a rebase turns it green:

  1. refactor(auth): make the token cipher async #3444refactor(auth): make the token cipher async
  2. feat(platform): host capabilities seam + boot-time binding guard #3446feat(platform): host capabilities seam + boot-time binding guard
  3. refactor(shared): move the SKILL.md serializer into @posthog/shared #3445refactor(shared): move the SKILL.md serializer into @posthog/shared

Verified locally: with all three applied on top of current main, @posthog/web and apps/code typecheck clean and the web e2e passes. The standalone red is exclusively unresolved symbols from those three (async cipher, @posthog/platform/host-capabilities + @posthog/di/hostCapabilities + REQUIRED_HOST_CAPABILITIES, serializeSkillMarkdown).

Notes

apps/web is a new app; nothing in main imports it, so its blast radius on the desktop host is nil. The shared-package/desktop changes that do carry risk were peeled into the three enabler PRs above.


Created with PostHog Code

Bring up apps/web as a cloud-tasks-only browser host: the same @posthog/ui
shell and @posthog/core services as desktop, over web platform adapters
(WebCrypto refresh-token cipher, popup PKCE OAuth, localStorage per-device
stores, in-browser host-router slice via unstable_localLink, posthog-js
analytics/flags, fflate skill bundler, @pierre/diffs worker). Vendor + route
code-splitting, a hermetic Playwright happy-path e2e, and mprocs procs.

Depends on (merge first): async token cipher, host-capabilities seam, and
the shared SKILL.md serializer. Red until those land; rebase then.

Generated-By: PostHog Code
Task-Id: 77d13a30-444d-4045-9d80-5e2a9f2e68ae
@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 1932a06.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(web): cloud-tasks browser host" | Re-trigger Greptile

Comment thread apps/web/src/web-oauth-flow.ts
@gantoine gantoine marked this pull request as draft July 14, 2026 20:18
gantoine added 2 commits July 15, 2026 14:28
Resolve conflicts in apps/web/vite.config.ts (keep web-host refactor,
carry over main's git alias into posthogSrcAliases) and mprocs.yaml
(adopt main's layer-grouping model, slot in the new web/web-playwright/
desktop-playwright procs).

Generated-By: PostHog Code
Task-Id: d5bcaf27-c54b-45d5-920d-cc4f65c9e9fb
The popup used a fixed window name ("posthog-code-oauth"), so a second
tab starting sign-in before the first finished could reuse and navigate
away the first tab's popup. The first flow's callback then never fired,
and the shared BroadcastChannel only carried the second flow's state, so
the first tab waited until the five-minute timeout.

Name each popup uniquely per flow (suffixing the per-flow OAuth state) so
concurrent sign-ins open independent windows. State-based callback
routing over the shared channel already delivers each callback to its own
flow.

Generated-By: PostHog Code
Task-Id: d5bcaf27-c54b-45d5-920d-cc4f65c9e9fb
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