Skip to content

feat(platform): host capabilities seam + boot-time binding guard#3446

Merged
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/host-capabilities
Jul 15, 2026
Merged

feat(platform): host capabilities seam + boot-time binding guard#3446
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/host-capabilities

Conversation

@gantoine

Copy link
Copy Markdown
Member

Summary

Two related, desktop-safe primitives peeled out of the apps/web browser-host work (previously #3353):

  1. HostCapabilities seam — a coarse { localWorkspaces: boolean } primitive in @posthog/platform, read via useHostCapabilities(). It defaults to localWorkspaces: true when unbound, so desktop is unchanged. Used to gate local-only UI (folder picker, terminal, worktree/cloud-mode toggles, in-app back/forward chrome, local settings sections, onboarding repo step) — every gate is a no-op while localWorkspaces is true.

  2. DI binding guardrailassertHostCapabilities() plus a REQUIRED_HOST_CAPABILITIES registry of the tokens shared @posthog/ui/@posthog/core resolve via service location (useService). Each composition root asserts them at boot, turning a missing host binding into a loud startup failure instead of a crash at the first navigation that resolves the token. useService<T>(TOKEN)'s type is caller-supplied, so a TypedContainer can't catch this — the runtime assertion can.

Desktop binds HOST_CAPABILITIES ({ localWorkspaces: true }) and runs the assertion on renderer boot.

Why now

Splitting the web-host PR into independently-reviewable pieces. This is the shared-package/desktop-touching half — the part with real (if minimal) blast radius — landing on its own so it gets focused review.

Testing

  • @posthog/di, @posthog/ui, apps/code typecheck.
  • @posthog/di guardrail unit tests (8) pass.
  • Full @posthog/ui suite: 176 files / 1566 tests pass — confirms the gating edits are no-ops on desktop (localWorkspaces: true).
  • Biome clean.

Created with PostHog Code

Introduce a coarse HostCapabilities primitive ({ localWorkspaces }) in
@posthog/platform, read via useHostCapabilities (defaults to
localWorkspaces:true, so desktop is unchanged). Use it to gate local-only
UI surfaces (folder picker, terminal, worktree/cloud-mode toggles,
back/forward chrome, local settings sections, onboarding repo step) so a
future cloud-only host renders correctly — every gate is a no-op on
desktop.

Also add a DI guardrail: assertHostCapabilities + a REQUIRED_HOST_CAPABILITIES
registry of tokens shared UI resolves via service location. Each
composition root asserts them at boot, so a host that forgets a binding
fails loudly at startup instead of at the first navigation that needs it.
Desktop binds HOST_CAPABILITIES and asserts the registry on renderer boot.

Enabling change for the browser web host, peeled out of #3353; no desktop
behavior change.

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

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 7537ee6.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(platform): host capabilities seam +..." | Re-trigger Greptile

@gantoine

Copy link
Copy Markdown
Member Author

/trunk merge

@trunk-io trunk-io Bot merged commit e338415 into main Jul 15, 2026
25 checks passed
@trunk-io trunk-io Bot deleted the posthog-code/host-capabilities branch July 15, 2026 14:39
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