Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(desktop): integrate products/desktop into monorepo tooling (#76394)

Charles Vien6e491aa084dd
diff --git a/.env.example b/.env.example
index 03e1419cb33a..4261c92e7f7c 100644
--- a/.env.example
+++ b/.env.example
@@ -8,8 +8,8 @@ OIDC_RSA_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFA
# RS256 private key for sandbox JWT authentication (public key is derived from this)
SANDBOX_JWT_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDMAaMESiOX8PDM\nozOHunt1s+zp78nmLnHs6IvOoKS4rQXFVV2/ouTivIfLRMRDe2TAybsYK0yfAJeK\nFxW7O+MD/vjCMS7kJtOjskQIl3wQTjz/T4fwHkFpiqVHLWczeO5LdvaJBZ4FUYdc\nLaV+9T+4wEavJa5G/Ggl+9eWee/TuThN21wMuAQb7WZhWKqDVm8WfmZpvOXJJ/U1\nkg+8GVg7eMTs6GV0MI7YYwzEHRn3PUQrQmc+q6gROwHU7pEv8DdOLjDH5iYZL/4k\ndnW1KGO/Hqf7vzKEMN23YjL6bC4FDRfM5z/4nQUEjvXihzZ1yK6yChwEd7Ma/PUG\nIh6Pm5azAgMBAAECggEAE/nlDeUkmcWMuWe8WAIOrMvdhbARQ7+F2v46Z7/wi+ow\nB86qy2UWpzfGzu9WOIq7UZVvWJfaJ4erTxOg8SCVbi1oC7vn14y7FJW+y7M/AWm9\nLKg2VhuK/twGAHOVs23tXOkH4wrwb5ziyvKSo109zB19I7wQ1f/z7XmSTA3Mn3Kf\n6GecR6di+LuDUNeEPwuP061EnUUsSYZY/QnhUNHfAyWaO4Ezc4bdl8w2q3O1ElBo\ndaYx9ht9aw8bTjIAS6QUdnh3OPXrQ/E7+2RaEh6NFFuXsh93aGSXKB6ZgURk0wIc\nBtNGA5Sxur8nwMfYT+6Z8fi7wMGuGtKISNK+DXCVwQKBgQD+nG92xjZebauJaYOn\nK7cDgWza9zwG6nDv13vRPS+D9wlJP3eUH1O+vZsar9UdTrXGh51oBskc4giOK9aL\nOvp9SjfrRx9KbkLLTzcS+r0XIYog0TO0onswaJ+ybwuvXU6zx+GjoKmPFDYrsjC5\n/3AkBPgEhorM4bZ1plfsFMzbaQKBgQDNHogqPPIXSco9ESTA6b3IeyzEGVcODDFq\nZgEIuFZJ70FCgg+TfxvZyQKfEGjxg6nLKQswaAQ7Pt3yMvYmEiVTrxaLBIjG9Lu8\nTWOMmJDiA7rgFVsU5ENI6UH8Nv8FkS5JSAPgC8hFnLKvs/9RjCTET3UCGoK5ymdM\nO1c/L0epuwKBgDYLUKGeizXaA5pEWlymq89Drq5/4i75noVacP7GBQr26fKxVRmM\n2MLZDk5I2mzBI1aDvMazAgdudzBuX7joCPmFQn9fdmXfJ7BuHRubO33ocaBrp5UF\nFC7/Vj6S0aEkpisFF4Ea/kLPoHv/89XXQZ9zqo2TXW0F0CwC5hDHjYBZAoGAG4IN\ntsRnnxHpSllDOY/fQMSsEzxmvV6LPf6iAt5dzBqHAPlaR2iTfpiDfnt/52vF2JYP\nhxVcA+oBb9q/wglK8jcX6drY0P2/M5iZUiCfxX/EjwquJVYbY+rMS5vAhambsH40\n7tYFrLhACmo0QmZuA9m4EmklwO7Q/ZszryiTDsMCgYBUUMWlQfuTN8m+D/Eo614J\neRYx8/YcaQpASOzy74woAZyHGLjuu5eW9wclkdhklHGh6KyQ5B6JUXlQsbZxLbBb\n9oW6Jg+UvL0KKLqHoNmNitiAUGONrVpxLjrKUUrUfDD+sWsxQpzcOgBqalTZ2g30\nN6ctjTLJp5PqIIE9tZB9PQ==\n-----END PRIVATE KEY-----"
-# Point this to your PostHog Desktop monorepo root to use the local version of your @posthog/agent package instead of the published version. This is useful for testing changes to the agent package locally without needing to publish a new version.
-LOCAL_POSTHOG_CODE_MONOREPO_ROOT=/path/to/posthog-code
+# Point this to the desktop tree to use the local version of your @posthog/agent package instead of the published version. This is useful for testing changes to the agent package locally without needing to publish a new version. The desktop source lives in this repo at products/desktop; an out-of-tree PostHog/code checkout also works.
+LOCAL_POSTHOG_CODE_MONOREPO_ROOT=./products/desktop
# Sandbox provider (you can choose between "docker" or "modal")
SANDBOX_PROVIDER=docker
diff --git a/.github/scripts/desktop/react-doctor-comment.mjs b/.github/scripts/desktop/react-doctor-comment.mjs
new file mode 100644
index 000000000000..7c6bb879bebe
--- /dev/null
+++ b/.github/scripts/desktop/react-doctor-comment.mjs
@@ -0,0 +1,158 @@
+import fs from "node:fs";
+
+const [reportPath, outPath] = process.argv.slice(2);
+const MARKER = "<!-- desktop-react-doctor:summary -->";
+const slug = process.env.GITHUB_REPOSITORY;
+// The scan runs with cwd=products/desktop, so report paths are relative to it;
+// blob links need the repo-root path back.
+const rawPrefix = process.env.REACT_DOCTOR_PATH_PREFIX || "";
+const pathPrefix =
+ rawPrefix && !rawPrefix.endsWith("/") ? `${rawPrefix}/` : rawPrefix;
+const server = (process.env.GITHUB_SERVER_URL || "https://github.com").replace(
+ /\/$/,
+ "",
+);
+const head = (
+ process.env.REACT_DOCTOR_HEAD_SHA ||
+ process.env.GITHUB_SHA ||
+ ""
+).trim();
+
+const MAX_LISTED = 50;
+const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
+const inline = (value) =>
+ String(value ?? "")
+ .replace(/\s+/g, " ")
+ .replace(/[`<>]/g, "")
+ .trim();
+const byFileThenLine = (a, b) =>
+ a.filePath === b.filePath
+ ? a.line - b.line
+ : a.filePath < b.filePath
+ ? -1
+ : 1;
+const encodedPath = (file) =>
+ String(file ?? "")
+ .split("/")
+ .map((segment) =>
+ encodeURIComponent(segment).replace(/[()]/g, (c) =>
+ c === "(" ? "%28" : "%29",
+ ),
+ )
+ .join("/");
+const fileLink = (file, line) =>
+ slug && head
+ ? `[\`${inline(file)}:${line}\`](${server}/${slug}/blob/${head}/${encodedPath(pathPrefix + file)}#L${line})`
+ : `\`${inline(file)}:${line}\``;
+
+let report;
+try {
+ report = JSON.parse(fs.readFileSync(reportPath, "utf8"));
+} catch {
+ report = null;
+}
+
+const lines = [MARKER, ""];
+
+if (!report) {
+ lines.push("**React Doctor** could not produce a report.");
+} else if (!report.ok) {
+ lines.push(
+ "**React Doctor** could not complete this scan.",
+ "",
+ `> ${inline(report.error?.message) || "scan failed"}`,
+ );
+} else {
+ const summary = report.summary ?? {};
+ const total = summary.totalDiagnosticCount ?? 0;
+ // Diagnostic filePaths are relative to their project (e.g. apps/mobile), not
+ // the scan root; rejoin them so labels and blob links resolve.
+ const scanRoot = String(report.directory ?? "").replace(/\/+$/, "");
+ const diagnostics = (report.projects ?? []).flatMap((project) => {
+ const dir = String(project.directory ?? "");
+ const projectRel =
+ scanRoot && dir.startsWith(scanRoot)
+ ? dir.slice(scanRoot.length).replace(/^\/+/, "")
+ : "";
+ return (project.diagnostics ?? []).map((diagnostic) => ({
+ ...diagnostic,
+ filePath: projectRel
+ ? `${projectRel}/${diagnostic.filePath}`
+ : diagnostic.filePath,
+ }));
+ });
+
+ if (total === 0) {
+ lines.push("**React Doctor** found no issues in the changed files. 🎉");
+ } else {
+ const severity = [];
+ if (summary.errorCount) severity.push(plural(summary.errorCount, "error"));
+ if (summary.warningCount)
+ severity.push(plural(summary.warningCount, "warning"));
+ const severityTail = severity.length ? ` · ${severity.join(" & ")}` : "";
+ lines.push(
+ `**React Doctor** found **${plural(total, "issue")}** in ${plural(summary.affectedFileCount ?? 0, "file")}${severityTail}.`,
+ );
+
+ const errors = diagnostics
+ .filter((d) => d.severity === "error")
+ .sort(byFileThenLine);
+ if (errors.length) {
+ lines.push("", "**Errors**", "");
+ for (const error of errors.slice(0, MAX_LISTED)) {
+ const title = inline(error.title);
+ lines.push(
+ `- ❌ ${fileLink(error.filePath, error.line)}${title ? ` ${title}` : ""} \`${inline(error.rule)}\``,
+ );
+ }
+ if (errors.length > MAX_LISTED)
+ lines.push(
+ "",
+ `${plural(errors.length - MAX_LISTED, "more error")} not shown.`,
+ );
+ }
+
+ const warnings = diagnostics
+ .filter((d) => d.severity === "warning")
+ .sort(byFileThenLine);
+ if (warnings.length) {
+ lines.push(
+ "",
+ `<details><summary>${plural(warnings.length, "warning")}</summary>`,
+ "",
+ );
+ let currentFile = null;
+ for (const warning of warnings.slice(0, MAX_LISTED)) {
+ if (warning.filePath !== currentFile) {
+ if (currentFile !== null) lines.push("");
+ lines.push(`**\`${inline(warning.filePath)}\`**`);
+ currentFile = warning.filePath;
+ }
+ const title = inline(warning.title);
+ lines.push(
+ `- ⚠️ ${fileLink(warning.filePath, warning.line)}${title ? ` ${title}` : ""} \`${inline(warning.rule)}\``,
+ );
+ }
+ if (warnings.length > MAX_LISTED)
+ lines.push(
+ "",
+ `${plural(warnings.length - MAX_LISTED, "more warning")} not shown.`,
+ );
+ lines.push("", "</details>");
+ }
+ }
+}
+
+const commit = head ? ` for commit \`${head.slice(0, 7)}\`` : "";
+lines.push(
+ "",
+ `<sub>Reviewed by [React Doctor](https://react.doctor)${commit}.</sub>`,
+);
+
+fs.writeFileSync(
+ outPath,
+ `${lines
+ .join("\n")
+ .replace(/\n{3,}/g, "\n\n")
+ .trimEnd()}\n`,
+);
diff --git a/.github/workflows/desktop-react-doctor.yml b/.github/workflows/desktop-react-doctor.yml
new file mode 100644
index 000000000000..c1172a7068c1
--- /dev/null
+++ b/.github/workflows/desktop-react-doctor.yml
@@ -0,0 +1,119 @@
+name: Desktop React Doctor
+
+# Advisory only: posts a sticky PR comment with findings for changed desktop
+# files and never fails the PR. The source repo's --blocking enforcement step
+# is deliberately not ported (see products/desktop/MIGRATION.md).
+
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, ready_for_review]
+ # Workflow-level paths only work because react-doctor is not a required
+ # check. If it ever becomes required, move the skip into a gate job like
+ # desktop-ci.yml, or path-skipped PRs will wait on it forever.
+ paths:
+ - 'products/desktop/**/*.ts'
+ - 'products/desktop/**/*.tsx'
+ - 'products/desktop/**/*.jsx'
+ - '.github/workflows/desktop-react-doctor.yml'
+ - '.github/scripts/desktop/react-doctor-comment.mjs'
+
+permissions:
+ contents: read
+ pull-requests: write
+
+concurrency:
+ group: desktop-react-doctor-${{ github.head_ref || github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ react-doctor:
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 0
+ filter: blob:none
+ persist-credentials: false
+
+ - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
+ with:
+ node-version: 22
+ package-manager-cache: false
+
+ - id: scan
+ name: Run react-doctor on changed desktop files
+ shell: bash
+ working-directory: products/desktop
+ env:
+ NO_COLOR: '1'
+ REACT_DOCTOR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: |
+ # -e omitted: exit codes are captured and inspected explicitly.
+ set -uo pipefail
+ CHANGED="${RUNNER_TEMP}/react-doctor-changed-files.txt"
+ # --relative: react-doctor runs from products/desktop, so the changed
+ # file list must be relative to it, not to the repo root.
+ if ! git diff --name-only --relative --diff-filter=ACMR "${REACT_DOCTOR_BASE_SHA}...${HEAD_SHA}" -- . > "$CHANGED"; then
+ echo "Could not diff ${REACT_DOCTOR_BASE_SHA}...${HEAD_SHA}; failing rather than skipping the scan." >&2
+ echo "exit-code=1" >> "$GITHUB_OUTPUT"
+ exit 1
+ fi
+ if [ ! -s "$CHANGED" ]; then
+ echo "No changed files; nothing for react-doctor to scan."
+ echo "exit-code=0" >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ REPORT="${RUNNER_TEMP}/react-doctor-report.json"
+ status=0
+ # Pinned: products/desktop/.npmrc's minimum release age makes @latest
+ # intermittently unresolvable in CI. Bump deliberately, not via latest.
+ npx --yes [email protected] . --blocking error --changed-files-from "$CHANGED" --json --json-compact --no-telemetry > "$REPORT" || status=$?
+ echo "exit-code=$status" >> "$GITHUB_OUTPUT"
+ echo "report=$REPORT" >> "$GITHUB_OUTPUT"
+ if [ "$status" -ne 0 ]; then
+ echo "react-doctor exited with status ${status}; advisory only, not failing the job." >&2
+ cat "$REPORT" >&2 || true
+ fi
+
+ - name: Render report summary
+ id: render
+ if: ${{ always() && steps.scan.outputs.report != '' }}
+ shell: bash
+ env:
+ GITHUB_REPOSITORY: ${{ github.repository }}
+ GITHUB_SERVER_URL: ${{ github.server_url }}
+ REACT_DOCTOR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ REACT_DOCTOR_PATH_PREFIX: products/desktop
+ REPORT: ${{ steps.scan.outputs.report }}
+ run: |
+ set -euo pipefail
+ BODY="${RUNNER_TEMP}/react-doctor-comment.md"
+ node "${GITHUB_WORKSPACE}/.github/scripts/desktop/react-doctor-comment.mjs" "$REPORT" "$BODY"
+ cat "$BODY" >> "$GITHUB_STEP_SUMMARY"
+ echo "body-path=$BODY" >> "$GITHUB_OUTPUT"
+
+ - name: Upsert sticky PR comment
+ # Fork PRs only get a read-only token, so the upsert would fail there;
+ # skip it explicitly instead of failing silently. Fork contributors
+ # still get the report via the job summary above.
+ if: ${{ always() && steps.render.outputs.body-path != '' && github.event.pull_request.head.repo.full_name == github.repository }}
+ continue-on-error: true
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ GITHUB_REPOSITORY: ${{ github.repository }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ BODY: ${{ steps.render.outputs.body-path }}
+ run: |
+ set -uo pipefail
+ jq -Rs '{body: .}' "$BODY" > "${RUNNER_TEMP}/react-doctor-payload.json"
+ marker="<!-- desktop-react-doctor:summary -->"
+ existing=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" --paginate \
+ --jq ".[] | select(.body | startswith(\"${marker}\")) | .id" | head -n1 || true)
+ if [ -n "$existing" ]; then
+ gh api -X PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${existing}" --input "${RUNNER_TEMP}/react-doctor-payload.json" >/dev/null
+ else
+ gh api -X POST "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" --input "${RUNNER_TEMP}/react-doctor-payload.json" >/dev/null
+ fi
diff --git a/.oxfmtrc.json b/.oxfmtrc.json
index e0edbc6f4b73..cdcf38d8d611 100644
--- a/.oxfmtrc.json
+++ b/.oxfmtrc.json
@@ -80,7 +80,21 @@
}
],
"ignorePatterns": [
- "products/desktop",
+ "products/desktop/**/*.ts",
+ "products/desktop/**/*.tsx",
+ "products/desktop/**/*.js",
+ "products/desktop/**/*.jsx",
+ "products/desktop/**/*.mjs",
+ "products/desktop/**/*.cjs",
+ "products/desktop/**/*.mts",
+ "products/desktop/**/*.json",
+ "products/desktop/**/*.jsonc",
+ "products/desktop/**/*.css",
+ "products/desktop/**/*.scss",
+ "products/desktop/**/*.md",
+ "products/desktop/**/*.mdx",
+ "products/desktop/pnpm-lock.yaml",
+ "products/desktop/apps/code/snapshots.yml",
"venv",
"env",
".venv",
diff --git a/bin/mprocs.yaml b/bin/mprocs.yaml
index 2e01e4d85818..04f1cc70c75c 100755
--- a/bin/mprocs.yaml
+++ b/bin/mprocs.yaml
@@ -576,6 +576,13 @@ procs:
layer: Product services
tech: Python
+ desktop:
+ shell: 'bin/start-desktop'
+ capability: desktop_app
+ groups:
+ layer: Application
+ tech: Node
+
migrate-postgres:
shell: 'bin/wait-for-docker && bin/hogli db:restore-schema-if-fresh && bin/migrate --scope=postgres'
capability: core_infra
diff --git a/bin/start-desktop b/bin/start-desktop
new file mode 100755
index 000000000000..c09b36446beb
--- /dev/null
+++ b/bin/start-desktop
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+cd "$(dirname "$0")/../products/desktop"
+
+pnpm install --frozen-lockfile
+
+exec pnpm exec turbo dev --filter=@posthog/code --filter=@posthog/agent --filter=@posthog/git --filter=@posthog/platform --filter=@posthog/enricher
diff --git a/devenv/intent-map.yaml b/devenv/intent-map.yaml
index 2b30d45ffe6e..1977525c0624 100644
--- a/devenv/intent-map.yaml
+++ b/devenv/intent-map.yaml
@@ -230,6 +230,11 @@ capabilities:
requires: [core_infra]
docker_profiles: [duckgres]
+ desktop_app:
+ description: 'PostHog Desktop app (Electron) and its package watchers'
+ requires: [core_infra]
+ docker_profiles: []
+
# Intents map to products/features developers work on
intents:
product_analytics:
@@ -418,6 +423,10 @@ intents:
description: 'Dagster for clickhouse maintenance, system workflows'
capabilities: [dagster_pipelines]
+ desktop:
+ description: 'PostHog Desktop app (Electron) with local task runs'
+ capabilities: [desktop_app, temporal_workflows, agent_proxy, llm_gateway]
+
# Always-required processes regardless of intent
# This is the core stack needed for any development
always_required:
diff --git a/docs/internal/monorepo-layout.md b/docs/internal/monorepo-layout.md
index 95f7c253b4d0..a6e6f99cca57 100644
--- a/docs/internal/monorepo-layout.md
+++ b/docs/internal/monorepo-layout.md
@@ -50,6 +50,8 @@ User-facing features with their own backend (Django app) and frontend (React). E
See [products/README.md](/products/README.md) for how to create products. For new isolated products, see [products/architecture.md](/products/architecture.md) for design principles (DTOs, facades, isolation rules).
+One exception to the Django-plus-React shape: `products/desktop/` is the PostHog desktop app (Electron, plus mobile and web hosts), imported from the PostHog/code repo. It is a nested standalone pnpm workspace with its own lockfile, Node version and Biome toolchain, deliberately excluded from the root pnpm workspace, with its own `desktop-*` CI. Its `AGENTS.md` covers the architecture and its `MIGRATION.md` covers the resync contract with PostHog/code. Day to day, drive it through `hogli desktop:*` commands, or `cd products/desktop` and use pnpm directly.
+
#### What a product can own
Most products are a Django app plus React scenes — and most already carry more: an `mcp/` directory of MCP tool definitions, often a `skills/` directory of agent skills. A product can own anything attributable to it, runtime and tooling alike. Nest it under the product instead of scattering it across top-level dirs:
diff --git a/docs/internal/sandboxes-setup-guide.md b/docs/internal/sandboxes-setup-guide.md
index 21d820d59152..d6f32f712b3d 100644
--- a/docs/internal/sandboxes-setup-guide.md
+++ b/docs/internal/sandboxes-setup-guide.md
@@ -182,13 +182,14 @@ Then fill in the secrets. `POSTHOG_UI_APPS_TOKEN` and `POSTHOG_ANALYTICS_API_KEY
```bash
# In your .env:
SANDBOX_PROVIDER=MODAL_DOCKER
-LOCAL_POSTHOG_CODE_MONOREPO_ROOT=/path/to/posthog-code
+# The desktop source lives in this repo; an out-of-tree PostHog/code checkout also works
+LOCAL_POSTHOG_CODE_MONOREPO_ROOT=./products/desktop
```
Then build the agent package and restart the temporal worker:
```bash
-cd /path/to/posthog-code/packages/agent && pnpm build
+cd products/desktop/packages/agent && pnpm build
```
### Sandbox providers
@@ -273,7 +274,7 @@ When both `SANDBOX_PROVIDER=MODAL_DOCKER` and `LOCAL_POSTHOG_CODE_MONOREPO_ROOT`
After changing agent-server code, rebuild and restart the worker:
```bash
-cd /path/to/posthog-code/packages/agent && pnpm build
+cd products/desktop/packages/agent && pnpm build
```
> **Note:** The build context is cached for the lifetime of the worker process (`lru_cache`).
diff --git a/hogli.yaml b/hogli.yaml
index 259965ed0b55..15981efb085e 100644
--- a/hogli.yaml
+++ b/hogli.yaml
@@ -62,6 +62,8 @@ metadata:
title: Authenticate to internal services
- key: tools
title: Developer tools and utilities
+ - key: desktop
+ title: Desktop app (products/desktop)
- key: devex
title: Developer experience feedback
- key: utilities
@@ -1019,6 +1021,23 @@ tools:
ci:preflight:
click: hogli_commands.ci_preflight:ci_preflight
description: Catch deterministic CI failures reachable from your diff before you push (advisory; --fix, --strict)
+desktop:
+ desktop:dev:
+ cmd: pnpm --dir products/desktop dev
+ description: Run the desktop app dev stack (build deps, then phrocs with Electron)
+ desktop:test:
+ cmd: pnpm --dir products/desktop test
+ description: Run desktop unit tests (Vitest via turbo, nested workspace)
+ desktop:typecheck:
+ cmd: pnpm --dir products/desktop typecheck
+ description: Typecheck all desktop packages (turbo)
+ desktop:lint:
+ cmd: pnpm --dir products/desktop exec biome ci . && node products/desktop/scripts/check-host-boundaries.mjs
+ description: Check desktop code quality without writing (Biome + host boundaries, mirrors desktop-quality CI)
+ desktop:lint:fix:
+ cmd: pnpm --dir products/desktop run lint
+ description: Autofix desktop lint issues (biome check --write --unsafe)
+
owners:
owners:resolve:
click: posthog_owners.cli:cmd_resolve
@@ -1175,3 +1194,7 @@ environment:
bin_script: ensure-local-setup
description: Idempotent local-dev bootstrap (e.g. the wizard OAuth app); runs automatically on hogli start
hidden: true
+ start:desktop:
+ bin_script: start-desktop
+ description: 'Install the nested products/desktop workspace and run its dev stack (Electron app plus package watchers via turbo); used by the desktop intent on hogli start'
+ hidden: true
diff --git a/package.json b/package.json
index ec30d1583791..08d5912b7272 100644
--- a/package.json
+++ b/package.json
@@ -100,6 +100,7 @@
"bin/hogli format:js"
],
"{playwright,frontend,products,common,ee,services,docs}/**/*.{js,jsx,mjs,mts,ts,tsx}": "bin/hogli format:js",
+ "products/desktop/**/*.{js,mjs,ts,tsx,json,jsonc,css}": "pnpm --dir products/desktop exec biome check --write --no-errors-on-unmatched --files-ignore-unknown=true",
"nodejs/**/*.{js,jsx,mjs,mts,ts,tsx}": "bin/hogli format:nodejs",
"funnel-udf/**/*.rs": "bin/hogli format:rust",
"!(posthog/hogql/grammar/*|posthog/personhog_client/proto/generated/*|products/*/skills/*/scripts/*)*.{py,pyi}": [
diff --git a/products/desktop/.claude/settings.json b/products/desktop/.claude/settings.json
deleted file mode 100644
index e73b7b90136a..000000000000
--- a/products/desktop/.claude/settings.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/claude-code-settings.json",
- "permissions": {
- "deny": [
- "Read(./apps/cli/**)",
- "Edit(./apps/cli/**)",
- "Write(./apps/cli/**)"
- ]
- }
-}
diff --git a/products/desktop/.claude/skills/merging-prs/SKILL.md b/products/desktop/.claude/skills/merging-prs/SKILL.md
deleted file mode 100644
index cc8685b02de6..000000000000
--- a/products/desktop/.claude/skills/merging-prs/SKILL.md
+++ /dev/null
@@ -1,121 +0,0 @@
----
-name: merging-prs
-description: Merge a PR into main through the Trunk merge queue and babysit it until it lands. Enqueue with a "/trunk merge" comment, then poll the "Trunk Merge Queue" check run and the PR state until it is MERGED or FAILED, reporting the Trunk bot's failure reason if the PR is kicked out. Use when asked to merge a PR, "merge when ready", "land it", "ship it", or to babysit/watch a PR through the queue. Never use `gh pr merge` in this repo -- the queue is the only path into main.
-allowed-tools: Bash(gh pr view:*), Bash(gh pr checks:*), Bash(gh pr comment:*), Bash(gh pr ready:*), Bash(gh api:*), Bash(sleep:*)
----
-
-# Merge a PR through the Trunk merge queue
-
-Merges into `main` go **exclusively** through the [Trunk](https://trunk.io) merge
-queue. `gh pr merge` and the GitHub merge button are blocked by branch ruleset.
-To merge, you enqueue the PR with a comment, then watch it until Trunk lands it.
-
-When a developer says "merge this PR", "merge it when it's ready", "land it",
-"ship it", or "babysit this PR", do the full loop below — enqueue **and** watch
-to completion, reporting the outcome.
-
-`<n>` below is the PR number. Resolve the repo slug once if you need it:
-`REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)`.
-
-## 1. Preflight
-
-```bash
-gh pr view <n> --json state,isDraft,mergeable,reviewDecision,statusCheckRollup
-```
-
-- **Not open** (already merged/closed) → report and stop.
-- **Draft** → it can't be merged. Ask the developer to confirm, then
- `gh pr ready <n>` before continuing. Don't un-draft silently.
-- **Failing required checks** (`statusCheckRollup`) → the queue will just reject
- it. Report which checks are red and stop; fix them first. **Pending** checks
- are fine — the queue waits for them.
-- **Not yet approved** (`reviewDecision` empty or `REVIEW_REQUIRED`) → fine,
- enqueue anyway. See below.
-- **Merge conflicts** (`mergeable == "CONFLICTING"`) → report and stop; rebase first.
-
-Enqueueing before approval is safe, and is the closest thing this repo has to
-auto-merge. A submitted PR sits in Trunk's `Queued` state until GitHub's branch
-protection on `main` is satisfied — one approving review, code-owner review, and
-the required checks (`build`, `quality`, `unit-test`, `integration-test`,
-`typecheck`) — and Trunk merges it once they land. Trunk is not a bypass actor on
-those rules, so it cannot merge an unapproved or red PR.
-
-The catch: **pushing new commits drops the PR from the queue.** If review
-feedback is likely, either wait for approval before enqueueing, or re-enqueue
-with `/trunk merge` after each push.
-
-## 2. Enqueue
-
-```bash
-gh pr comment <n> --body "/trunk merge"
-```
-
-Within ~2 minutes, confirm Trunk picked it up — a check run whose name starts
-with `Trunk Merge Queue` should appear on the head commit:
-
-```bash
-SHA=$(gh pr view <n> --json headRefOid -q .headRefOid)
-gh api repos/$REPO/commits/$SHA/check-runs \
- --jq '.check_runs[] | select(.name | startswith("Trunk Merge Queue")) | {name, status, conclusion, details_url}'
-```
-
-If nothing appears after a couple of minutes, the developer may lack write
-access or GitHub-comment commands may be disabled — report that and suggest the
-`trunk-merge-queue-submit` label as a fallback.
-
-## 3. Poll until it lands
-
-Loop about every 60 seconds, up to ~45–60 minutes total. Each iteration:
-
-```bash
-gh pr view <n> --json state,mergedAt # MERGED -> success, stop
-SHA=$(gh pr view <n> --json headRefOid -q .headRefOid)
-gh api repos/$REPO/commits/$SHA/check-runs \
- --jq '.check_runs[] | select(.name | startswith("Trunk Merge Queue")) | {status, conclusion, details_url}'
-sleep 60
-```
-
-- `state == "MERGED"` → done. Report success with the merge commit.
-- Check run `status` moves `queued` → `in_progress` → `completed`. Report each
- transition so the developer can follow along.
-- Watch the **check run + PR state**, not `gh pr checks --watch`: the queue runs
- CI on Trunk's own draft/`trunk-merge/**` branch, so this PR's own checks don't
- reflect the queue's testing.
-- If it's parked in `Queued` waiting on a human review, say so once and slow the
- cadence to ~5 minutes. Keep watching — the merge still has to be reported.
-- Stop at the timeout with a status summary rather than looping forever. If it
- was still waiting on review, say that's why and offer to keep watching.
-
-## 4. Handle failure
-
-If the check run completes with `conclusion == "failure"` (or the PR drops out
-of the queue), Trunk kicks the PR and its bot comments with the failing
-workflow. Read the newest comments and report the reason:
-
-```bash
-gh pr view <n> --comments | tail -n 40
-```
-
-- If the failure is clearly caused by this PR **and** the fix is obvious, fix it,
- push, wait for the PR's own checks to go green, and re-enqueue **once** with
- `/trunk merge`.
-- Otherwise stop and report the failure and the workflow link. Don't repeatedly
- re-enqueue a red PR.
-
-## 5. Cancel
-
-If the developer asks to stop the merge:
-
-```bash
-gh pr comment <n> --body "/trunk cancel"
-```
-
-Confirm the check run reports cancelled.
-
-## Hard rules
-
-- **Never** run `gh pr merge` — it's blocked and it's not how this repo merges.
-- **Never** force-push a branch while it is in the queue — it removes the PR
- from the queue.
-- Re-enqueue a failed PR **at most once** automatically; beyond that, hand back
- to the developer.
diff --git a/products/desktop/.claude/skills/quill-code/SKILL.md b/products/desktop/.claude/skills/quill-code/SKILL.md
index a61c9429b1c2..147ab4ef413f 100644
--- a/products/desktop/.claude/skills/quill-code/SKILL.md
+++ b/products/desktop/.claude/skills/quill-code/SKILL.md
@@ -1,20 +1,26 @@
---
name: quill-code
-description: Edit the @posthog/quill design system locally and consume the change in this repo (posthog-code) before it is published to npm. Use when changing quill components/primitives/tokens, when a quill change must be tested inside the Code app, or when the user mentions quill, the design system, the .local-quill tarball, or the @posthog/quill pnpm override.
+description: Edit the @posthog/quill design system locally and consume the change in products/desktop before it is published to npm. Use when changing quill components/primitives/tokens, when a quill change must be tested inside the Code app, or when the user mentions quill, the design system, the .local-quill tarball, or the @posthog/quill pnpm override.
---
# quill-code
-`@posthog/quill` is **not** in this repo. It is a published catalog dependency whose
-source lives in the main PostHog monorepo at `../posthog/packages/quill`. To test an
-unpublished quill change inside this repo (posthog-code), you build quill, pack it to a
-tarball, and point a pnpm `overrides` entry at that tarball. This is a **temporary
-local-dev** state — revert before merging (see below).
+`@posthog/quill`'s source lives in this monorepo at `packages/quill` (repo root, two
+levels up from products/desktop). Desktop still consumes the **published npm package**
+via its nested workspace catalog — products/desktop is excluded from the root pnpm
+workspace, so `workspace:` linking cannot reach it. To test an unpublished quill change
+here, you build quill in-repo, pack it to a tarball, and point a pnpm `overrides` entry
+at that tarball. This is a **temporary local-dev** state — revert before merging (see
+below).
+
+All commands below run from `products/desktop/`. Building quill uses the **root**
+workspace's install, so run `pnpm install` at the monorepo root once first.
## Quill layout (where to edit)
-`../posthog/packages/quill` is the **workspace** (`@posthog/quill-workspace`). It
-contains sub-packages, each a layer of the design system:
+`packages/quill` (from the monorepo root) is the **workspace**
+(`@posthog/quill-workspace`). It contains sub-packages, each a layer of the design
+system:
- `packages/primitives/src` — base components (Card, Badge, Button, Progress, …)
- `packages/components/src` — composed components (DataTable, DateTimePicker, Metric)
@@ -28,10 +34,12 @@ A new export in any sub-package flows to `@posthog/quill` automatically on build
1. Edit/add the component in the right sub-package (above) and export it from that
package's `src/index.ts`.
-2. Re-sync into this repo manually — build → pack → point the override → reinstall:
+2. Re-sync into products/desktop manually — build → pack → point the override → reinstall:
```bash
- QUILL_DIR="${QUILL_DIR:-../posthog/packages/quill/packages/quill}"
+ # From products/desktop/
+ DESKTOP_ROOT="$PWD"
+ QUILL_DIR="${QUILL_DIR:-../../packages/quill/packages/quill}"
# a. Build the WHOLE quill workspace (two levels up from the aggregate), so the
# sub-packages rebuild BEFORE the aggregate bundles them.
@@ -40,8 +48,10 @@ A new export in any sub-package flows to `@posthog/quill` automatically on build
# b. Pack into .local-quill/ under a UNIQUE filename. pnpm pins a tarball by
# integrity, so a stable name caches stale across re-syncs — drop old local
# tarballs first, then rename the packed file to a unique local name.
+ # (Anchor on $DESKTOP_ROOT, not `git rev-parse --show-toplevel`: the git
+ # toplevel is the monorepo root, not this workspace.)
rm -f .local-quill/posthog-quill-local-*.tgz
- ( cd "$QUILL_DIR" && npm pack --pack-destination "$(git rev-parse --show-toplevel)/.local-quill" )
+ ( cd "$QUILL_DIR" && npm pack --pack-destination "$DESKTOP_ROOT/.local-quill" )
mv .local-quill/posthog-quill-[0-9]*.tgz ".local-quill/posthog-quill-local-$(git rev-parse --short HEAD)-$$.tgz"
# c. Point the override at the new tarball, then reinstall.
@@ -57,15 +67,18 @@ A new export in any sub-package flows to `@posthog/quill` automatically on build
After every quill edit you **must** re-run the sync — the app consumes the tarball, not
the quill source, so unsynced edits are invisible here.
-If quill lives elsewhere, set `QUILL_DIR=/abs/path/to/posthog/packages/quill/packages/quill`.
+For an out-of-tree quill checkout, set
+`QUILL_DIR=/abs/path/to/posthog/packages/quill/packages/quill`.
-## Why a tarball, not `link:`
+## Why a tarball, not `link:` or `workspace:`
-`link:` symlinks into the mono's `node_modules` and drags in its **React 18** types,
-colliding with this repo's **React 19** (dual-React → broken typecheck +
-invalid-hook-call at runtime). The tarball is copied into this repo's store and deduped
-against React 19. The filename is **content-hashed** because pnpm pins a tarball by
-integrity, so a stable filename gets cached stale across re-syncs.
+`workspace:` cannot resolve across the nested-workspace boundary (products/desktop is
+excluded from the root pnpm workspace). `link:` symlinks into the root workspace's
+`node_modules` and drags in its **React 18** types, colliding with this workspace's
+**React 19** (dual-React → broken typecheck + invalid-hook-call at runtime). The
+tarball is copied into this workspace's store and deduped against React 19. The
+filename is **content-hashed** because pnpm pins a tarball by integrity, so a stable
+filename gets cached stale across re-syncs.
## The override (what the script rewrites)
@@ -83,7 +96,8 @@ There is also a permanent pin you should leave alone:
## Reverting (before merge)
-The override is local-dev only. Once the quill change is published to npm:
+The override is local-dev only. Once the quill change is published to npm (quill
+publishes from this monorepo via the manual `publish-quill-npm` workflow dispatch):
1. Bump the catalog version in `pnpm-workspace.yaml` (`'@posthog/quill': 0.3.0-beta.x`)
to the published version.
diff --git a/products/desktop/AGENTS.md b/products/desktop/AGENTS.md
index 950c6be10099..e7b76af74751 100644
--- a/products/desktop/AGENTS.md
+++ b/products/desktop/AGENTS.md
@@ -219,15 +219,6 @@ await boot(container);
- `pnpm --filter code package|make`: package the Electron app.
- `node scripts/check-host-boundaries.mjs`: verify host boundary allowlist.
-## Merging PRs
-
-All merges into `main` go through the Trunk merge queue. Never run `gh pr merge` or click the GitHub merge button -- both are blocked by branch ruleset.
-
-- Enqueue: `gh pr comment <number> --body "/trunk merge"`. Cancel: `gh pr comment <number> --body "/trunk cancel"`.
-- After enqueueing, babysit the PR until it merges or fails -- follow [`.claude/skills/merging-prs/SKILL.md`](./.claude/skills/merging-prs/SKILL.md) for the preflight, poll, and failure-handling loop.
-- Queue progress is the `Trunk Merge Queue (main)` check run on the PR's head commit. On failure the Trunk bot comments with links to the failing workflows; fix, push, and re-enqueue.
-- Never force-push a branch while it is in the queue -- it removes the PR from the queue.
-
## UI Components
**Radix is banned. Do not add a `@radix-ui/*` import to any file, ever.** That covers
diff --git a/products/desktop/CONTRIBUTING.md b/products/desktop/CONTRIBUTING.md
index 67588450db3f..238e4c28899a 100644
--- a/products/desktop/CONTRIBUTING.md
+++ b/products/desktop/CONTRIBUTING.md
@@ -2,6 +2,9 @@
We love contributions big and small. The PostHog desktop app is the IDE for understanding how users interact with your product -- and we want the community involved in shaping it.
+> [!NOTE]
+> This code lives at `products/desktop` inside [posthog/posthog](https://github.com/PostHog/posthog). If you already have that repo checked out, work there instead of cloning separately.
+
## Getting started
1. Fork the repo and clone it locally
diff --git a/products/desktop/MIGRATION.md b/products/desktop/MIGRATION.md
index 057b981eba5a..dd0cfbf9e2e4 100644
--- a/products/desktop/MIGRATION.md
+++ b/products/desktop/MIGRATION.md
@@ -51,6 +51,24 @@ The tree is a verbatim copy of the source at the pinned SHA except:
- `docs/testing.md`: the "Storybook Visual Regression" CI paragraphs are replaced with a
note that the storybook CI was removed post-merge (see `POST-MIGRATION.md` step 6). The
source still documents its own storybook workflow; reapply on resync.
+- Monorepo-context doc patches (reapply on resync; upstream to PostHog/code where noted):
+ `.claude/skills/merging-prs/` is deleted and the "Merging PRs" section is removed from
+ `AGENTS.md` — both describe the source repo's Trunk queue on `main`, which is wrong
+ here and misleads agents working under products/desktop (they fall through to the root
+ repo's merge guidance instead); the section is still correct upstream, so this stays a
+ monorepo-only removal. `README.md` and `CONTRIBUTING.md` carry a short "this lives at
+ products/desktop inside posthog/posthog" note, and `docs/LOCAL-DEVELOPMENT.md` step 3
+ gains a monorepo branch (skip the clone, `cd products/desktop`, Node 22 caveat) ahead
+ of the standalone-clone instructions. `.claude/skills/quill-code/SKILL.md` is
+ rewritten for the monorepo: quill's source is now in-repo at `packages/quill` (the
+ source text says it is not), and its pack step anchored on
+ `git rev-parse --show-toplevel`, which here is the monorepo root, so the tarball
+ landed outside the workspace. `.claude/settings.json` is deleted: its only content
+ denied access to `./apps/cli/**`, which does not exist. Upstream both to
+ PostHog/code where they apply (the toplevel anchor bug does not; the source repo's
+ toplevel is the workspace root).
+- `mprocs.yaml` and `pnpm-workspace.yaml` are oxfmt-formatted (yaml only; see the
+ `.oxfmtrc.json` entry below for the reapply command).
- Local security patches (reapply on resync until the pin includes the upstream fix):
`apps/code/src/main/utils/encryption.ts` passes `{ authTagLength: 16 }` to
`createDecipheriv` (semgrep `gcm-no-tag-length`, ERROR). For the simple-git 3.36 RCE fix,
@@ -97,13 +115,36 @@ separate project.
- `pytest.ini`: `--ignore=products/desktop` added to `addopts`. Same reason for the Django
suite: posthog pytest would otherwise collect desktop's Python tooling tests.
- `.github/workflows/desktop-*.yml`: ported workflows (mapping below).
-- `.github/scripts/products/desktop/`: scripts the ported workflows need that lived in the source
- repo's `.github/scripts/`.
+- Post-merge integrations, all outside products/desktop/ and untouched by resyncs:
+ `hogli.yaml` has a `desktop:*` command category wrapping `pnpm --dir products/desktop`;
+ `hogli test` routes desktop paths to the owning package's Vitest
+ (tools/hogli-commands test_runner.py); `hogli ci:preflight` validates each pnpm
+ workspace against its own lockfile and runs desktop's Biome on desktop diffs
+ (ci_preflight.py); the root package.json lint-staged runs desktop's Biome on staged
+ desktop files (desktop's own .husky/ is dead code here — core.hooksPath is the
+ monorepo root .husky); ci-backend.yml (and the .depot mirror) re-couples
+ `products/desktop/packages/{agent,shared,git}/**` to the Django suite via a
+ `desktop_agent_packages` filter key OR'd into the `backend`/`tasks_temporal` outputs,
+ because excludes inside the `backend` filter apply to every glob.
+- `.github/scripts/desktop/`: scripts the ported workflows need that lived in the source
+ repo's `.github/scripts/` (the directory ci-frontend.yml's `!.github/scripts/desktop/**`
+ exclude already covers).
- `.oxlintrc.json`: `"desktop"` added to `ignorePatterns` (root `lint:js` runs repo-wide;
desktop code is Biome-linted by its own workflow).
-- `.oxfmtrc.json`: `"desktop"` added to `ignorePatterns` (the frontend CI formats
- `**/*.{md,mdx,yaml,yml}` repo-wide; desktop keeps Biome formatting).
+- `.oxfmtrc.json`: desktop is ignored per-extension, not as a whole tree. Code
+ extensions (ts/tsx/js/json/css/...) stay ignored because desktop formats them with
+ Biome and the root `format:frontend` glob would fight it. Markdown stays ignored:
+ oxfmt's emphasis normalization corrupts bare `*` glob patterns in desktop's prose
+ (e.g. rewriting `desktop-*` in running text), so md governance waits on an upstream
+ cleanup. Yaml IS governed (mprocs.yaml, pnpm-workspace.yaml reformatted; the
+ publish-critical `pnpm-lock.yaml` and VR-signed `apps/code/snapshots.yml` stay
+ ignored). Reapply on resync: run
+ `pnpm exec oxfmt "products/desktop/**/*.{yaml,yml}"` after the tree is replaced, or
+ ci-frontend's repo-wide format check reds on unrelated PRs.
- `.config/.markdownlint-cli2.jsonc`: `"products/desktop/**"` added to `ignores`.
+ Deliberately retained after the migration: a trial run found 151 violations across
+ 25 imported files, and fixing them in-repo would be resync-reverted drift. Lift the
+ ignore only after the markdown is cleaned up upstream in PostHog/code.
- `.github/workflows/ci-security.yaml` (monorepo-native, not resynced): security scanning
for the import. Convention-only jobs still exclude `products/desktop` because imported code
does not follow the monorepo's custom rules (`semgrep-python`'s `.semgrep/rules/security`
@@ -134,6 +175,7 @@ separate project.
| agent-release.yml | desktop-agent-release.yml | sandbox rebuild dispatch is now same-repo with `actions: write` (cross-repo GH app retired) |
| agent-tag.yml | desktop-agent-tag.yml | agent tags stay `agent-v*`; patch count scoped `-- products/desktop/packages/agent` (unscoped would count every monorepo commit) |
| mobile-build.yml | desktop-mobile-build.yml | |
+| react-doctor.yml | desktop-react-doctor.yml | advisory-only port (added post-merge): the source's "Enforce blocking findings" step is dropped so the job never fails a PR; react-doctor pinned to 0.9.1 (the source's 0.5.4 predates most rules; `@latest` trips desktop's minimum-release-age); comment script ported to `.github/scripts/desktop/react-doctor-comment.mjs` with a `desktop-react-doctor:summary` marker, a `products/desktop` blob-link prefix and project-relative diagnostic paths rejoined to their project directory (latent link bug in the source script) |
| mobile-promote.yml | desktop-mobile-promote.yml | |
| pr-build-installer.yml | desktop-pr-build-installer.yml | |
@@ -142,7 +184,6 @@ Dropped (the monorepo already provides the function):
| Source | Reason |
| --- | --- |
| codeql.yml | monorepo `ci-security.yaml` covers the repo |
-| react-doctor.yml | intentionally not imported for now; re-add on a later resync if desktop wants it in the monorepo |
| stale.yml | monorepo `stale.yaml` |
| trunk-impacted-targets.yml | code repo's Trunk merge queue does not carry over; desktop inherits the monorepo queue |
| pr-approval-agent.yml | monorepo runs its own `pr-approval-agent.yml` on all PRs |
@@ -242,8 +283,11 @@ ports from source using these rules.
quiet. PostHog/code#3490 (S3 feed) simplifies this on its next resync into this import.
- `desktop-cleanup-draft-releases.yml` cleans PostHog/code draft releases for the same
reason.
-- `products/desktop/apps/code/package.json` `repository` fields and in-repo docs still reference
- PostHog/code; cosmetic, fixed opportunistically.
+- `products/desktop/packages/agent/package.json` still declares
+ `"repository": "https://github.com/PostHog/code"` (apps/code/package.json has no
+ repository field). Fix it alongside the npm trusted-publisher re-registration, ideally
+ upstream in PostHog/code. Other in-repo docs referencing PostHog/code are cosmetic,
+ fixed opportunistically.
## Not done in this PR (follow-ups)
@@ -280,7 +324,12 @@ the PR's side; that file is the one to follow on merge day.
`packages/ui/src/features/canvas/freeform/FreeformCanvas.tsx` posts to a `"*"` target
origin, which is required for its opaque-origin sandboxed srcDoc iframe.
- **Dependency CVEs (local patch, reapply on resync until the pin includes the upstream
- fix)**: `pnpm-workspace.yaml` overrides pin advisory-flagged packages to patched,
+ fix)**: this recipe is the standing security-patch process for the whole desktop tree,
+ not a one-off: automated patching does not function here (Dependabot's auto-PR
+ mechanism is disabled repo-wide and Renovate is deliberately dashboard-only with
+ vulnerability auto-PRs off), so Dependabot alerts on desktop's two lockfiles are
+ worked off manually with the override-pin + lockfile-regeneration steps below.
+ `pnpm-workspace.yaml` overrides pin advisory-flagged packages to patched,
age-compliant versions (protobufjs 7.6.5, axios 1.18.1, hono 4.12.28, @xmldom/xmldom
0.8.13, node-forge 1.4.0, simple-git 3.36.0, drizzle-orm 0.45.2, fast-uri 3.1.4,
@hono/node-server 1.19.13, lodash 4.18.0, serialize-javascript 7.0.5, undici 8.5.0/7.28.0,
diff --git a/products/desktop/POST-MIGRATION.md b/products/desktop/POST-MIGRATION.md
index 6b08ff8ca677..93f859ef154b 100644
--- a/products/desktop/POST-MIGRATION.md
+++ b/products/desktop/POST-MIGRATION.md
@@ -5,6 +5,12 @@ the ones above it are done. `MIGRATION.md` covers the import itself and the resy
This file is monorepo-only. Restore it on a resync (see `MIGRATION.md`).
+Status as of 2026-08-01: steps 2, 3, 4, 5 and 6 are done. Step 7 (npm trusted publisher)
+is still open and actively broken: both post-resync `@posthog/agent` releases failed with
+ENEEDAUTH (seen on agent-v2.4.1), so no monorepo-triggered agent release has ever
+succeeded. Two items beyond the original list also need an admin (see "Remaining ops
+work" at the bottom).
+
## Merging
Trunk's merge queue is paused, so `/trunk merge` is a no-op. Squash is the only method the
@@ -115,12 +121,13 @@ regression.
## 5. Register the required status checks
-These run and pass today, but nothing enforces them:
+Done 2026-08-01: the four contexts are registered on the `master` ruleset (id 6958621),
+with the caller-job prefix the reusable-workflow dispatch gives them:
-- `Desktop Build Pass`
-- `Desktop Typecheck Pass`
-- `Desktop Quality Pass`
-- `Desktop Tests Pass`
+- `build / Desktop Build Pass`
+- `typecheck / Desktop Typecheck Pass`
+- `quality / Desktop Quality Pass`
+- `test / Desktop Tests Pass`
## 6. Storybook CI (removed post-merge)
@@ -137,15 +144,34 @@ git history and let the VR bot commit a posthog-signed baseline.
`@posthog/agent` publishes from `desktop-agent-release.yml`. Re-register the trusted
publisher as posthog/posthog + that workflow, or agent releases fail at publish.
+## Remaining ops work (needs an admin)
+
+1. **npm trusted publisher for `@posthog/agent`** (step 7 above): re-register as
+ posthog/posthog + `desktop-agent-release.yml` in npm's package settings. Every agent
+ release currently fails with ENEEDAUTH. Decide at the same time whether to strip
+ publish rights from the old PostHog/code + agent-release.yml pairing.
+2. **Disable `agent-tag.yml` and `agent-release.yml` on PostHog/code**: only
+ `code-tag.yml` was disabled there (step 3). The old agent pair is still active, so a
+ stray commit touching packages/agent on the frozen repo could race the monorepo's
+ `agent-v*` tagging.
+3. **AWS OIDC trust policy for `desktop-update-e2e.yml`**: the nightly macOS update E2E
+ fails `sts:AssumeRoleWithWebIdentity` against `AWS_TWIG_APP_ASSETS_ROLE_ARN`, while
+ `desktop-release.yml` succeeds with the same secret. Add the update-e2e workflow (and
+ its `schedule` event) to the role's allowed `sub` claims.
+
## Lower priority
-- **Backend test coupling**: add `products/desktop/packages/{agent,shared,git}/**` to
- `ci-backend.yml`'s paths filter (Django's tasks tests exercise the agent overlay), and
- point `LOCAL_POSTHOG_CODE_MONOREPO_ROOT` (products/tasks `local_packages.py`) at the
- in-repo `products/desktop/`.
-- **hogli**: add a `desktop` category (`desktop:dev` etc.) to `hogli.yaml`.
+- **Backend test coupling**: done 2026-08-01. `ci-backend.yml` (and the `.depot` mirror)
+ couples `products/desktop/packages/{agent,shared,git}/**` to the Django suite via a
+ `desktop_agent_packages` filter key. Root docs now point
+ `LOCAL_POSTHOG_CODE_MONOREPO_ROOT` at the in-repo `products/desktop/`.
+- **hogli**: done 2026-08-01. `hogli.yaml` has a `desktop:*` category, `hogli test`
+ routes desktop paths to Vitest and `hogli ci:preflight` validates the nested lockfile
+ and runs desktop's Biome.
- **Dual-publish retirement**: `desktop-release.yml` and `desktop-cleanup-draft-releases.yml`
still target PostHog/code for the legacy update feed. Retire once app-version telemetry
shows the old feed is quiet.
- **Dependency tail**: the remaining transitive high/moderate advisories (minimatch,
picomatch, js-yaml, form-data, svgo) are left for a dedicated dependency-hygiene sweep.
+ Note automated patching does not cover this tree: see the standing security-patch
+ procedure in `MIGRATION.md`.
diff --git a/products/desktop/README.md b/products/desktop/README.md
index 114081d96122..589ab320d03d 100644
--- a/products/desktop/README.md
+++ b/products/desktop/README.md
@@ -7,7 +7,10 @@ Found a bug or want to share feedback? [Open an issue](https://github.com/PostHo
# PostHog
-This is the monorepo for the PostHog desktop and mobile apps and the agent framework that powers them.
+This is the source for the PostHog desktop and mobile apps and the agent framework that powers them.
+
+> [!NOTE]
+> This directory lives at `products/desktop` inside [posthog/posthog](https://github.com/PostHog/posthog). If you already have that repo checked out, there is no separate clone: `cd products/desktop` and follow the setup below. It is a standalone pnpm workspace with its own lockfile and Node version.
## Development
diff --git a/products/desktop/docs/LOCAL-DEVELOPMENT.md b/products/desktop/docs/LOCAL-DEVELOPMENT.md
index 0991eeaf6661..bc8616558123 100644
--- a/products/desktop/docs/LOCAL-DEVELOPMENT.md
+++ b/products/desktop/docs/LOCAL-DEVELOPMENT.md
@@ -60,6 +60,17 @@ openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -outform PEM | \
## 3. Clone and run the app
+Already working in the posthog/posthog monorepo? Skip the clone: the app lives at `products/desktop`. Note it needs Node 22 (see `.node-version`), not the Node version the monorepo's flox environment provides, so switch with your version manager first.
+
+```bash
+cd products/desktop
+pnpm install
+cp .env.example .env
+pnpm dev
+```
+
+Starting fresh from the standalone repo instead:
+
```bash
git clone https://github.com/PostHog/code.git
cd code
diff --git a/products/desktop/mprocs.yaml b/products/desktop/mprocs.yaml
index c216b4070db2..83caba5f234f 100644
--- a/products/desktop/mprocs.yaml
+++ b/products/desktop/mprocs.yaml
@@ -1,76 +1,76 @@
procs:
- code:
- shell: 'node scripts/wait-for-electron-exit.mjs && node scripts/pnpm-run.mjs --filter code run start'
- env:
- DEBUG: "false"
- depends_on:
- - agent
- - git
- - enricher
- - platform
- groups:
- layer: Application
+ code:
+ shell: 'node scripts/wait-for-electron-exit.mjs && node scripts/pnpm-run.mjs --filter code run start'
+ env:
+ DEBUG: 'false'
+ depends_on:
+ - agent
+ - git
+ - enricher
+ - platform
+ groups:
+ layer: Application
- agent:
- shell: 'node scripts/pnpm-run.mjs --filter agent run dev'
- groups:
- layer: Packages
+ agent:
+ shell: 'node scripts/pnpm-run.mjs --filter agent run dev'
+ groups:
+ layer: Packages
- git:
- shell: 'node scripts/pnpm-run.mjs --filter @posthog/git run dev'
- groups:
- layer: Packages
+ git:
+ shell: 'node scripts/pnpm-run.mjs --filter @posthog/git run dev'
+ groups:
+ layer: Packages
- platform:
- shell: 'node scripts/pnpm-run.mjs --filter @posthog/platform run dev'
- groups:
- layer: Packages
+ platform:
+ shell: 'node scripts/pnpm-run.mjs --filter @posthog/platform run dev'
+ groups:
+ layer: Packages
- enricher:
- shell: 'node scripts/pnpm-run.mjs --filter @posthog/enricher run dev'
- groups:
- layer: Packages
+ enricher:
+ shell: 'node scripts/pnpm-run.mjs --filter @posthog/enricher run dev'
+ groups:
+ layer: Packages
- storybook:
- shell: 'node scripts/pnpm-run.mjs --filter code run storybook'
- autostart: false
- groups:
- layer: Tools
+ storybook:
+ shell: 'node scripts/pnpm-run.mjs --filter code run storybook'
+ autostart: false
+ groups:
+ layer: Tools
- mobile-ios:
- shell: 'node scripts/pnpm-run.mjs --filter @posthog/mobile run ios'
- autostart: false
- groups:
- layer: Application
+ mobile-ios:
+ shell: 'node scripts/pnpm-run.mjs --filter @posthog/mobile run ios'
+ autostart: false
+ groups:
+ layer: Application
- chromium-log:
- shell: 'tail -F ~/.posthog-code/logs-dev/chromium.log'
- groups:
- layer: Tools
+ chromium-log:
+ shell: 'tail -F ~/.posthog-code/logs-dev/chromium.log'
+ groups:
+ layer: Tools
- web:
- shell: 'node scripts/pnpm-run.mjs --filter @posthog/web run dev'
- autostart: false
- groups:
- layer: Application
+ web:
+ shell: 'node scripts/pnpm-run.mjs --filter @posthog/web run dev'
+ autostart: false
+ groups:
+ layer: Application
- web-playwright:
- shell: 'node scripts/pnpm-run.mjs --filter @posthog/web run test:e2e'
- autostart: false
- groups:
- layer: Tools
+ web-playwright:
+ shell: 'node scripts/pnpm-run.mjs --filter @posthog/web run test:e2e'
+ autostart: false
+ groups:
+ layer: Tools
- # The desktop e2e fixture launches the PACKAGED app from out/, so package
- # first (matches CI) or it fails with "No packaged app found". Slow on first
- # run; re-run test:e2e directly if the app is already packaged and unchanged.
- desktop-playwright:
- shell: 'node scripts/pnpm-run.mjs --filter code run package && node scripts/pnpm-run.mjs --filter code run test:e2e'
- autostart: false
- groups:
- layer: Tools
+ # The desktop e2e fixture launches the PACKAGED app from out/, so package
+ # first (matches CI) or it fails with "No packaged app found". Slow on first
+ # run; re-run test:e2e directly if the app is already packaged and unchanged.
+ desktop-playwright:
+ shell: 'node scripts/pnpm-run.mjs --filter code run package && node scripts/pnpm-run.mjs --filter code run test:e2e'
+ autostart: false
+ groups:
+ layer: Tools
# Grouping dimension the sidebar starts grouped by (press `g` to cycle/disable).
default_group: layer
group_order:
- layer: [Application, Packages, Tools]
+ layer: [Application, Packages, Tools]
diff --git a/products/desktop/pnpm-workspace.yaml b/products/desktop/pnpm-workspace.yaml
index a072f47a1036..5eefcf4f24de 100644
--- a/products/desktop/pnpm-workspace.yaml
+++ b/products/desktop/pnpm-workspace.yaml
@@ -1,145 +1,145 @@
packages:
- - apps/*
- - packages/*
- - tooling/*
+ - apps/*
+ - packages/*
+ - tooling/*
catalog:
- '@hono/node-server': ^1.13.7
- '@hono/trpc-server': ^0.3.4
- '@earendil-works/pi-agent-core': 0.83.0
- '@earendil-works/pi-ai': 0.83.0
- '@earendil-works/pi-coding-agent': 0.83.0
- '@earendil-works/pi-tui': 0.83.0
- '@parcel/watcher': ^2.5.6
- '@phosphor-icons/react': ^2.1.10
- '@posthog/quill': 0.3.0-beta.24
- '@radix-ui/themes': ^3.2.1
- '@tanstack/react-query': ^5.100.14
- '@tanstack/react-router': ^1.170.10
- '@tanstack/react-router-devtools': ^1.167.0
- '@tanstack/router-generator': ^1.167.17
- '@tanstack/router-plugin': ^1.168.13
- '@trpc/client': ^11.17.0
- '@trpc/server': ^11.17.0
- '@trpc/tanstack-react-query': ^11.17.0
- '@types/node': ^20.0.0
- '@types/react': ^19.2.15
- '@types/react-dom': ^19.2.3
- hono: ^4.6.14
- inversify: ^7.10.6
- react: 19.2.6
- react-dom: 19.2.6
- reflect-metadata: ^0.2.2
- superjson: ^2.2.2
- tsup: ^8.5.1
- typescript: ^5.5.0
+ '@hono/node-server': ^1.13.7
+ '@hono/trpc-server': ^0.3.4
+ '@earendil-works/pi-agent-core': 0.83.0
+ '@earendil-works/pi-ai': 0.83.0
+ '@earendil-works/pi-coding-agent': 0.83.0
+ '@earendil-works/pi-tui': 0.83.0
+ '@parcel/watcher': ^2.5.6
+ '@phosphor-icons/react': ^2.1.10
+ '@posthog/quill': 0.3.0-beta.24
+ '@radix-ui/themes': ^3.2.1
+ '@tanstack/react-query': ^5.100.14
+ '@tanstack/react-router': ^1.170.10
+ '@tanstack/react-router-devtools': ^1.167.0
+ '@tanstack/router-generator': ^1.167.17
+ '@tanstack/router-plugin': ^1.168.13
+ '@trpc/client': ^11.17.0
+ '@trpc/server': ^11.17.0
+ '@trpc/tanstack-react-query': ^11.17.0
+ '@types/node': ^20.0.0
+ '@types/react': ^19.2.15
+ '@types/react-dom': ^19.2.3
+ hono: ^4.6.14
+ inversify: ^7.10.6
+ react: 19.2.6
+ react-dom: 19.2.6
+ reflect-metadata: ^0.2.2
+ superjson: ^2.2.2
+ tsup: ^8.5.1
+ typescript: ^5.5.0
ignoredBuiltDependencies:
- - msw
- - protobufjs
+ - msw
+ - protobufjs
minimumReleaseAge: 10080
minimumReleaseAgeExclude:
- - '@agentclientprotocol/sdk'
- - '@anthropic-ai/claude-agent-sdk'
- - '@anthropic-ai/claude-agent-sdk-darwin-arm64'
- - '@anthropic-ai/claude-agent-sdk-darwin-x64'
- - '@anthropic-ai/claude-agent-sdk-linux-arm64'
- - '@anthropic-ai/claude-agent-sdk-linux-arm64-musl'
- - '@anthropic-ai/claude-agent-sdk-linux-x64'
- - '@anthropic-ai/claude-agent-sdk-linux-x64-musl'
- - '@anthropic-ai/claude-agent-sdk-win32-arm64'
- - '@anthropic-ai/claude-agent-sdk-win32-x64'
- - '@anthropic-ai/sdk'
- - '@earendil-works/pi-agent-core'
- - '@earendil-works/pi-ai'
- - '@earendil-works/pi-coding-agent'
- - '@earendil-works/pi-tui'
- - '@pierre/diffs'
- - '@pierre/theming'
- - '@posthog/quill'
- - '@posthog/quill-charts'
- - '@posthog/quill-tokens'
- - '@tanstack/devtools-core'
- - '@tanstack/history'
- - '@tanstack/react-router'
- - '@tanstack/react-router-devtools'
- - '@tanstack/react-store'
- - '@tanstack/react-virtual'
- - '@tanstack/router-core'
- - '@tanstack/router-devtools-core'
- - '@tanstack/router-generator'
- - '@tanstack/router-plugin'
- - '@tanstack/router-utils'
- - '@tanstack/store'
- - '@tanstack/virtual-core'
- - '@tanstack/virtual-file-routes'
+ - '@agentclientprotocol/sdk'
+ - '@anthropic-ai/claude-agent-sdk'
+ - '@anthropic-ai/claude-agent-sdk-darwin-arm64'
+ - '@anthropic-ai/claude-agent-sdk-darwin-x64'
+ - '@anthropic-ai/claude-agent-sdk-linux-arm64'
+ - '@anthropic-ai/claude-agent-sdk-linux-arm64-musl'
+ - '@anthropic-ai/claude-agent-sdk-linux-x64'
+ - '@anthropic-ai/claude-agent-sdk-linux-x64-musl'
+ - '@anthropic-ai/claude-agent-sdk-win32-arm64'
+ - '@anthropic-ai/claude-agent-sdk-win32-x64'
+ - '@anthropic-ai/sdk'
+ - '@earendil-works/pi-agent-core'
+ - '@earendil-works/pi-ai'
+ - '@earendil-works/pi-coding-agent'
+ - '@earendil-works/pi-tui'
+ - '@pierre/diffs'
+ - '@pierre/theming'
+ - '@posthog/quill'
+ - '@posthog/quill-charts'
+ - '@posthog/quill-tokens'
+ - '@tanstack/devtools-core'
+ - '@tanstack/history'
+ - '@tanstack/react-router'
+ - '@tanstack/react-router-devtools'
+ - '@tanstack/react-store'
+ - '@tanstack/react-virtual'
+ - '@tanstack/router-core'
+ - '@tanstack/router-devtools-core'
+ - '@tanstack/router-generator'
+ - '@tanstack/router-plugin'
+ - '@tanstack/router-utils'
+ - '@tanstack/store'
+ - '@tanstack/virtual-core'
+ - '@tanstack/virtual-file-routes'
overrides:
- # node-abi predates Electron 42; ^3.92.0 is the first release that knows its ABI
- # (146), needed when rebuilding native modules against Electron 42.
- node-abi: ^3.92.0
- # Dedupe the zod 4.x line to one version so cross-package schema types stay
- # nameable (TS2742). Scoped to 4.x; 3.x consumers are untouched.
- 'zod@^4.0.0': 4.4.3
- # Keep one React across the monorepo so shared packages resolve one runtime.
- react: 19.2.6
- react-dom: 19.2.6
- react-test-renderer: 19.2.6
- # Dedupe @types/react so shared UI Ref types unify across apps (a second copy
- # makes nominally-distinct Ref types and breaks ref props in packages/ui).
- '@types/react': ^19.2.15
- '@types/react-dom': ^19.2.3
- # quill 0.3.0-beta.14 ships a broken `@base-ui/react: catalog:` dependency (the
- # catalog protocol leaked into the published package and can't resolve for an
- # external dep); pin it to a real version so installs of quill succeed.
- '@posthog/quill>@base-ui/react': ^1.3.0
- # node-gyp 12 downloads Node headers via undici (^6.25.0). undici through 7.27.2
- # crashes intermittently with `assert(!this.paused)` in the H1 parser's finish()
- # when the socket ends while the body stream is paused, which happens when a
- # native module compiles from source under backpressure (e.g. node-pty in CI).
- # undici 8.4.1 dropped that assertion and handles the paused case gracefully;
- # node-gyp only uses stable public exports (fetch/Agent), so 8.x is safe.
- 'node-gyp>undici': 8.5.0
- # Swap vite for the rolldown-based fork for faster dev boot times (#3027).
- vite: npm:[email protected]
- # Security: force patched versions for advisory-flagged packages (each pin is over the
- # 7-day minimumReleaseAge and clears the package's advisories). Local mirror of the
- # PostHog/code hardening PR; drop once a resync pins to a commit that already has it.
- protobufjs: 7.6.5
- axios: 1.18.1
- hono: 4.12.28
- '@xmldom/xmldom': 0.8.13
- node-forge: 1.4.0
- simple-git: 3.36.0
- # Additional HIGH transitive fixes (low-risk patch/minor bumps within range).
- drizzle-orm: 0.45.2
- fast-uri: 3.1.4
- '@hono/node-server': 1.19.13
- lodash: 4.18.0
- serialize-javascript: 7.0.5
- '@electron/get>undici': 7.28.0
- rollup: 4.59.0
- 'brace-expansion@1': 1.1.16
- 'brace-expansion@2': 2.1.2
- 'ws@7': 7.5.11
- 'ws@8': 8.21.0
- 'path-to-regexp@8': 8.4.2
- qs: 6.15.3
- smol-toml: 1.6.1
+ # node-abi predates Electron 42; ^3.92.0 is the first release that knows its ABI
+ # (146), needed when rebuilding native modules against Electron 42.
+ node-abi: ^3.92.0
+ # Dedupe the zod 4.x line to one version so cross-package schema types stay
+ # nameable (TS2742). Scoped to 4.x; 3.x consumers are untouched.
+ 'zod@^4.0.0': 4.4.3
+ # Keep one React across the monorepo so shared packages resolve one runtime.
+ react: 19.2.6
+ react-dom: 19.2.6
+ react-test-renderer: 19.2.6
+ # Dedupe @types/react so shared UI Ref types unify across apps (a second copy
+ # makes nominally-distinct Ref types and breaks ref props in packages/ui).
+ '@types/react': ^19.2.15
+ '@types/react-dom': ^19.2.3
+ # quill 0.3.0-beta.14 ships a broken `@base-ui/react: catalog:` dependency (the
+ # catalog protocol leaked into the published package and can't resolve for an
+ # external dep); pin it to a real version so installs of quill succeed.
+ '@posthog/quill>@base-ui/react': ^1.3.0
+ # node-gyp 12 downloads Node headers via undici (^6.25.0). undici through 7.27.2
+ # crashes intermittently with `assert(!this.paused)` in the H1 parser's finish()
+ # when the socket ends while the body stream is paused, which happens when a
+ # native module compiles from source under backpressure (e.g. node-pty in CI).
+ # undici 8.4.1 dropped that assertion and handles the paused case gracefully;
+ # node-gyp only uses stable public exports (fetch/Agent), so 8.x is safe.
+ 'node-gyp>undici': 8.5.0
+ # Swap vite for the rolldown-based fork for faster dev boot times (#3027).
+ vite: npm:[email protected]
+ # Security: force patched versions for advisory-flagged packages (each pin is over the
+ # 7-day minimumReleaseAge and clears the package's advisories). Local mirror of the
+ # PostHog/code hardening PR; drop once a resync pins to a commit that already has it.
+ protobufjs: 7.6.5
+ axios: 1.18.1
+ hono: 4.12.28
+ '@xmldom/xmldom': 0.8.13
+ node-forge: 1.4.0
+ simple-git: 3.36.0
+ # Additional HIGH transitive fixes (low-risk patch/minor bumps within range).
+ drizzle-orm: 0.45.2
+ fast-uri: 3.1.4
+ '@hono/node-server': 1.19.13
+ lodash: 4.18.0
+ serialize-javascript: 7.0.5
+ '@electron/get>undici': 7.28.0
+ rollup: 4.59.0
+ 'brace-expansion@1': 1.1.16
+ 'brace-expansion@2': 2.1.2
+ 'ws@7': 7.5.11
+ 'ws@8': 8.21.0
+ 'path-to-regexp@8': 8.4.2
+ qs: 6.15.3
+ smol-toml: 1.6.1
onlyBuiltDependencies:
- - '@parcel/watcher'
- - '@posthog/cli'
- - better-sqlite3
- - core-js
- - electron
- - electron-winstaller
- - esbuild
- - node-pty
- - tree-sitter-cli
+ - '@parcel/watcher'
+ - '@posthog/cli'
+ - better-sqlite3
+ - core-js
+ - electron
+ - electron-winstaller
+ - esbuild
+ - node-pty
+ - tree-sitter-cli
patchedDependencies:
- node-pty: patches/node-pty.patch
- react-hotkeys-hook: patches/react-hotkeys-hook.patch
+ node-pty: patches/node-pty.patch
+ react-hotkeys-hook: patches/react-hotkeys-hook.patch
diff --git a/tools/hogli-commands/hogli_commands/ci_preflight.py b/tools/hogli-commands/hogli_commands/ci_preflight.py
index edcc4c74e8d6..c3481e81a848 100644
--- a/tools/hogli-commands/hogli_commands/ci_preflight.py
+++ b/tools/hogli-commands/hogli_commands/ci_preflight.py
@@ -47,7 +47,7 @@ from hogli_commands.build import (
from hogli_commands.change_detection import changed_files, matches_globs
from hogli_commands.devenv.generator import TRACKED_MPROCS_FILES
-Requirement = Literal["node", "stack", "clickhouse"]
+Requirement = Literal["node", "desktop-node", "stack", "clickhouse"]
@dataclass
@@ -63,6 +63,10 @@ class DiffCheck:
advice: str | None = None # nudge-only: preflight never runs this check, it just says what to run
requires: tuple[Requirement, ...] = () # capabilities the check needs, else it skips
takes_files: bool = False # append matched files to the command
+ # Run once per pnpm workspace containing matched files (cwd = that workspace),
+ # so nested workspaces like products/desktop validate their own lockfile instead
+ # of the root one. Capability (node_modules present) is checked per workspace.
+ workspace_scoped: bool = False
matched: list[str] = field(default_factory=list)
@@ -74,12 +78,23 @@ DIFF_CHECKS: list[DiffCheck] = [
key="lockfile",
label="broken pnpm-lock.yaml (blocks ALL CI)",
# pnpm-workspace.yaml (catalog versions) and patches/* (patchedDependencies
- # hashes) invalidate the lockfile just like a package.json edit.
- triggers=["package.json", "*/package.json", "pnpm-lock.yaml", "pnpm-workspace.yaml", "patches/*"],
+ # hashes) invalidate the lockfile just like a package.json edit. The `*/`
+ # variants reach nested standalone workspaces (products/desktop), which
+ # workspace scoping then validates against their own lockfile.
+ triggers=[
+ "package.json",
+ "*/package.json",
+ "pnpm-lock.yaml",
+ "*/pnpm-lock.yaml",
+ "pnpm-workspace.yaml",
+ "*/pnpm-workspace.yaml",
+ "patches/*",
+ "*/patches/*",
+ ],
# --lockfile-only validates manifest/lockfile agreement without touching node_modules.
verify=["pnpm", "install", "--frozen-lockfile", "--lockfile-only"],
fix=["pnpm", "install", "--no-frozen-lockfile"],
- requires=("node",),
+ workspace_scoped=True,
),
DiffCheck(
key="uv-lock",
@@ -104,6 +119,23 @@ DIFF_CHECKS: list[DiffCheck] = [
fix=["ruff", "format"],
takes_files=True,
),
+ DiffCheck(
+ key="desktop-biome",
+ label="desktop lint/format (Biome, what desktop-quality CI runs)",
+ triggers=[
+ "products/desktop/*.ts",
+ "products/desktop/*.tsx",
+ "products/desktop/*.json",
+ "products/desktop/*.jsonc",
+ "products/desktop/*.css",
+ ],
+ # `pnpm --dir` runs from the nested workspace, so `.` is products/desktop
+ # and Biome resolves desktop's own biome.jsonc. `biome ci` is read-only;
+ # the fix path applies safe fixes only (desktop's own lint script is --unsafe).
+ verify=["pnpm", "--dir", "products/desktop", "exec", "biome", "ci", "."],
+ fix=["pnpm", "--dir", "products/desktop", "exec", "biome", "check", "--write", "."],
+ requires=("desktop-node",),
+ ),
DiffCheck(
key="type-check",
label="Python type checking (mypy)",
@@ -186,6 +218,9 @@ def _port_open(port: int) -> bool:
def _capability_met(req: Requirement) -> bool:
if req == "node":
return _has_node_modules()
+ if req == "desktop-node":
+ # products/desktop is a nested standalone workspace with its own install.
+ return (REPO_ROOT / "products" / "desktop" / "node_modules" / ".pnpm").exists()
if req == "stack":
# Postgres reachable — proxy for "dev stack is running".
return _port_open(5432)
@@ -203,10 +238,68 @@ Status = Literal["pass", "fail", "advisory", "skipped"]
_CHECK_TIMEOUT_SECONDS = 600
+def _pnpm_workspace_root(file_path: str) -> str:
+ """Repo-relative root of the pnpm workspace owning *file_path* ("." for the root
+ workspace): the nearest ancestor directory with a pnpm-workspace.yaml. The lockfile
+ is not a workspace marker on purpose — products/desktop/packages/agent carries a
+ publish-only pnpm-lock.yaml but belongs to the desktop workspace."""
+ current = (REPO_ROOT / file_path).parent.resolve()
+ root = REPO_ROOT.resolve()
+ while current != root and root in current.parents:
+ if (current / "pnpm-workspace.yaml").exists():
+ return current.relative_to(root).as_posix()
+ current = current.parent
+ return "."
+
+
+def _workspace_install_present(ws_root: Path) -> bool:
+ return (ws_root / "node_modules" / ".pnpm").exists()
+
+
+def _run_workspace_scoped(chk: DiffCheck, do_fix: bool) -> tuple[Status, str]:
+ """Run *chk* once per pnpm workspace containing matched files, cwd'd into it."""
+ statuses: list[Status] = []
+ parts: list[str] = []
+ for ws in sorted({_pnpm_workspace_root(f) for f in chk.matched}):
+ ws_root = REPO_ROOT if ws == "." else REPO_ROOT / ws
+ label = "root" if ws == "." else ws
+ if not _workspace_install_present(ws_root):
+ statuses.append("skipped")
+ parts.append(f"{label}: needs node (no install)")
+ continue
+ cmd = list(chk.fix) if do_fix and chk.fix is not None else list(chk.verify or [])
+ if not cmd or shutil.which(cmd[0]) is None:
+ statuses.append("skipped")
+ parts.append(f"{label}: {cmd[0] if cmd else 'command'} not found")
+ continue
+ try:
+ result = subprocess.run(cmd, cwd=ws_root, capture_output=True, text=True, timeout=_CHECK_TIMEOUT_SECONDS)
+ except subprocess.TimeoutExpired:
+ statuses.append("fail")
+ parts.append(f"{label}: timed out after {_CHECK_TIMEOUT_SECONDS}s")
+ continue
+ if result.returncode == 0:
+ statuses.append("pass")
+ parts.append(f"{label}: {'fixed' if do_fix else 'ok'}")
+ else:
+ lines = (result.stdout or result.stderr).strip().splitlines()
+ parts.append(f"{label}: {lines[0] if lines else f'exit {result.returncode}'}")
+ statuses.append("fail")
+ if "fail" in statuses:
+ overall: Status = "fail"
+ elif "pass" in statuses:
+ overall = "pass"
+ else:
+ overall = "skipped"
+ return overall, " · ".join(parts)
+
+
def _run_diff_check(chk: DiffCheck, do_fix: bool) -> tuple[Status, str]:
if chk.advice is not None:
# Nudge-only: nothing to run, nothing to auto-fix — the advisory *is* the check.
return "advisory", chk.advice
+ if chk.workspace_scoped:
+ return _run_workspace_scoped(chk, do_fix)
unmet = _unmet(chk)
if do_fix and chk.fix is not None and not unmet:
cmd = list(chk.fix)
diff --git a/tools/hogli-commands/hogli_commands/test_runner.py b/tools/hogli-commands/hogli_commands/test_runner.py
index 131b915dbe9d..c7048d1a6b92 100644
--- a/tools/hogli-commands/hogli_commands/test_runner.py
+++ b/tools/hogli-commands/hogli_commands/test_runner.py
@@ -22,6 +22,8 @@ from hogli_commands.change_detection import changed_files
_PYTHON_ROOTS = ("posthog/", "ee/", "products/", "common/", "dags/", "tools/", "services/")
+_DESKTOP_ROOT = "products/desktop"
+
def _is_test_file(path: str, rs_cfg_test: set[str] | None = None) -> bool:
"""Check if a file path looks like a test file for any supported language.
@@ -369,6 +371,37 @@ def _detect_go_test(file_only: str) -> TestRunConfig:
)
+def _detect_desktop_vitest(path: str, node_id: str | None = None) -> TestRunConfig:
+ """Detect Vitest configuration for the desktop nested workspace.
+
+ products/desktop is a standalone pnpm workspace whose packages test with
+ Vitest; the root Jest config ignores the whole tree, so run vitest from the
+ nearest desktop package (its own config and deps). For the workspace root
+ itself, defer to desktop's `pnpm test` (turbo), which is what desktop CI runs.
+ """
+ package_json = _find_nearest(path, "package.json")
+ pkg_dir = str(package_json.parent.relative_to(REPO_ROOT)) if package_json else None
+ if pkg_dir is None or pkg_dir in (_DESKTOP_ROOT, "products", "."):
+ return TestRunConfig(
+ test_type="vitest",
+ command=["pnpm", "--dir", _DESKTOP_ROOT, "test"],
+ description="Desktop tests via turbo (nested workspace)",
+ )
+
+ rel = str(PurePosixPath(path).relative_to(pkg_dir))
+ command = ["pnpm", "--dir", pkg_dir, "exec", "vitest", "run"]
+ if rel != ".":
+ command.append(rel)
+ if node_id:
+ command.extend(["-t", node_id])
+
+ return TestRunConfig(
+ test_type="vitest",
+ command=command,
+ description=f"Desktop Vitest (in {pkg_dir})",
+ )
+
+
def _detect_jest_test(file_only: str, file_path: str, node_id: str | None = None) -> TestRunConfig:
"""Detect Jest test configuration by finding the nearest package.json.
@@ -377,6 +410,8 @@ def _detect_jest_test(file_only: str, file_path: str, node_id: str | None = None
rely on. The product's own package.json has no jest config, so route them to
@posthog/frontend; jest treats the path as a testPathPattern and matches it there.
"""
+ if file_only.startswith(_DESKTOP_ROOT + "/"):
+ return _detect_desktop_vitest(file_only, node_id)
if file_only.startswith("products/"):
pkg_name: str | None = "@posthog/frontend"
else:
@@ -408,6 +443,11 @@ def _detect_directory(dir_path: str) -> TestRunConfig:
if _find_nearest(dir_path, "Cargo.toml"):
return _detect_rust_test(dir_path)
+ # Desktop nested workspace: Vitest, not the root turbo/pytest/Jest routing
+ normalized = dir_path.rstrip("/")
+ if normalized == _DESKTOP_ROOT or normalized.startswith(_DESKTOP_ROOT + "/"):
+ return _detect_desktop_vitest(normalized)
+
# Product root: use Turbo pipeline (only for top-level product dirs)
if dir_path.startswith("products/"):
parts = PurePosixPath(dir_path.rstrip("/")).parts
diff --git a/tools/hogli-commands/hogli_commands/tests/test_ci_preflight.py b/tools/hogli-commands/hogli_commands/tests/test_ci_preflight.py
index 622ca62058fe..92a38bdb1aa0 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_ci_preflight.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_ci_preflight.py
@@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch
from click.testing import CliRunner
from hogli.cli import cli
-from hogli_commands.ci_preflight import _staleness_risks
+from hogli_commands.ci_preflight import DIFF_CHECKS, _pnpm_workspace_root, _run_workspace_scoped, _staleness_risks
runner = CliRunner()
@@ -128,3 +128,82 @@ class TestStalenessRisks:
assert len(risks) == len(expected_fragments)
for fragment, risk in zip(expected_fragments, risks):
assert fragment in risk
+
+
+class TestWorkspaceScopedLockfile:
+ """The lockfile check must validate each pnpm workspace against its own lockfile.
+ These hit the real repo layout, like TestDetectTestType in test_test_runner.py."""
+
+ @pytest.mark.parametrize(
+ "file_path,expected_workspace",
+ [
+ ("package.json", "."),
+ ("frontend/package.json", "."),
+ ("nodejs/package.json", "."),
+ ("products/desktop/package.json", "products/desktop"),
+ ("products/desktop/pnpm-lock.yaml", "products/desktop"),
+ ("products/desktop/packages/core/package.json", "products/desktop"),
+ # agent has a publish-only pnpm-lock.yaml but is a desktop workspace member
+ ("products/desktop/packages/agent/package.json", "products/desktop"),
+ ("tools/hedgebox-dummy/package.json", "tools/hedgebox-dummy"),
+ ],
+ )
+ def test_workspace_root_resolution(self, file_path: str, expected_workspace: str) -> None:
+ assert _pnpm_workspace_root(file_path) == expected_workspace
+
+ @pytest.mark.parametrize(
+ "changed,expected_dirs",
+ [
+ (["products/desktop/package.json"], ["products/desktop"]),
+ (["package.json"], ["."]),
+ (["package.json", "products/desktop/packages/core/package.json"], [".", "products/desktop"]),
+ ],
+ )
+ @patch("hogli_commands.ci_preflight._workspace_install_present", return_value=True)
+ @patch("hogli_commands.ci_preflight.shutil.which", return_value="/usr/bin/pnpm")
+ @patch("hogli_commands.ci_preflight.subprocess.run")
+ def test_lockfile_runs_once_per_workspace(
+ self,
+ mock_run: MagicMock,
+ mock_which: MagicMock,
+ mock_install: MagicMock,
+ changed: list[str],
+ expected_dirs: list[str],
+ ) -> None:
+ mock_run.return_value = MagicMock(returncode=0, stdout="", stderr="")
+ lockfile = next(chk for chk in DIFF_CHECKS if chk.key == "lockfile")
+ assert lockfile.workspace_scoped
+ lockfile.matched = changed
+
+ status, detail = _run_workspace_scoped(lockfile, do_fix=False)
+
+ assert status == "pass"
+ ran_dirs = [call.kwargs["cwd"] for call in mock_run.call_args_list]
+ from hogli.manifest import REPO_ROOT
+
+ assert ran_dirs == [REPO_ROOT if d == "." else REPO_ROOT / d for d in expected_dirs]
+
+ @patch("hogli_commands.ci_preflight._workspace_install_present", return_value=True)
+ @patch("hogli_commands.ci_preflight.shutil.which", return_value="/usr/bin/pnpm")
+ @patch("hogli_commands.ci_preflight.subprocess.run")
+ def test_lockfile_failure_names_the_workspace(
+ self, mock_run: MagicMock, mock_which: MagicMock, mock_install: MagicMock
+ ) -> None:
+ mock_run.return_value = MagicMock(returncode=1, stdout="ERR_PNPM_OUTDATED_LOCKFILE", stderr="")
+ lockfile = next(chk for chk in DIFF_CHECKS if chk.key == "lockfile")
+ lockfile.matched = ["products/desktop/package.json"]
+
+ status, detail = _run_workspace_scoped(lockfile, do_fix=False)
+
+ assert status == "fail"
+ assert "products/desktop: ERR_PNPM_OUTDATED_LOCKFILE" in detail
+
+ @patch("hogli_commands.ci_preflight._workspace_install_present", return_value=False)
+ def test_lockfile_skips_workspace_without_install(self, mock_install: MagicMock) -> None:
+ lockfile = next(chk for chk in DIFF_CHECKS if chk.key == "lockfile")
+ lockfile.matched = ["products/desktop/package.json"]
+
+ status, detail = _run_workspace_scoped(lockfile, do_fix=False)
+
+ assert status == "skipped"
+ assert "products/desktop: needs node" in detail
diff --git a/tools/hogli-commands/hogli_commands/tests/test_test_runner.py b/tools/hogli-commands/hogli_commands/tests/test_test_runner.py
index c676f45cf323..53db6d20acd9 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_test_runner.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_test_runner.py
@@ -86,6 +86,59 @@ class TestDetectTestType:
assert config.test_type == "jest"
assert config.command == ["pnpm", "--filter=@posthog/frontend", "exec", "jest", file_path]
+ @parameterized.expand(
+ [
+ (
+ "products/desktop/packages/core/src/archive/archiveListView.test.ts",
+ "products/desktop/packages/core",
+ "src/archive/archiveListView.test.ts",
+ ),
+ (
+ "products/desktop/packages/ui/src/shell/logCapture.test.ts",
+ "products/desktop/packages/ui",
+ "src/shell/logCapture.test.ts",
+ ),
+ ]
+ )
+ def test_desktop_test_file_routes_to_package_vitest(self, file_path: str, pkg_dir: str, rel: str) -> None:
+ config = detect_test_type(file_path)
+ assert config.test_type == "vitest"
+ assert config.command == ["pnpm", "--dir", pkg_dir, "exec", "vitest", "run", rel]
+
+ def test_desktop_node_id_adds_test_name_filter(self) -> None:
+ config = detect_test_type("products/desktop/packages/core/src/archive/archiveListView.test.ts::renders rows")
+ assert config.test_type == "vitest"
+ assert config.command == [
+ "pnpm",
+ "--dir",
+ "products/desktop/packages/core",
+ "exec",
+ "vitest",
+ "run",
+ "src/archive/archiveListView.test.ts",
+ "-t",
+ "renders rows",
+ ]
+
+ @parameterized.expand(
+ [
+ (
+ "products/desktop/packages/core",
+ ["pnpm", "--dir", "products/desktop/packages/core", "exec", "vitest", "run"],
+ ),
+ (
+ "products/desktop/packages/core/src/archive",
+ ["pnpm", "--dir", "products/desktop/packages/core", "exec", "vitest", "run", "src/archive"],
+ ),
+ ("products/desktop", ["pnpm", "--dir", "products/desktop", "test"]),
+ ("products/desktop/packages", ["pnpm", "--dir", "products/desktop", "test"]),
+ ]
+ )
+ def test_desktop_directories_route_to_vitest_or_turbo(self, dir_path: str, expected_command: list[str]) -> None:
+ config = detect_test_type(dir_path)
+ assert config.test_type == "vitest"
+ assert config.command == expected_command
+
def test_jest_node_id_adds_test_name_pattern(self) -> None:
config = detect_test_type("frontend/src/lib/utils.test.ts::some test name")
assert config.test_type == "jest"