Skip to content

Commit 95c3826

Browse files
committed
Merge branch 'main' into posthog-code/channel-rename-delete-task-sync
2 parents 7133baf + d122837 commit 95c3826

587 files changed

Lines changed: 49029 additions & 6076 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
name: merging-prs
3+
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.
4+
allowed-tools: Bash(gh pr view:*), Bash(gh pr checks:*), Bash(gh pr comment:*), Bash(gh pr ready:*), Bash(gh api:*), Bash(sleep:*)
5+
---
6+
7+
# Merge a PR through the Trunk merge queue
8+
9+
Merges into `main` go **exclusively** through the [Trunk](https://trunk.io) merge
10+
queue. `gh pr merge` and the GitHub merge button are blocked by branch ruleset.
11+
To merge, you enqueue the PR with a comment, then watch it until Trunk lands it.
12+
13+
When a developer says "merge this PR", "merge it when it's ready", "land it",
14+
"ship it", or "babysit this PR", do the full loop below — enqueue **and** watch
15+
to completion, reporting the outcome. See also [docs/merge-queue.md](../../../docs/merge-queue.md).
16+
17+
`<n>` below is the PR number. Resolve the repo slug once if you need it:
18+
`REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)`.
19+
20+
## 1. Preflight
21+
22+
```bash
23+
gh pr view <n> --json state,isDraft,mergeable,reviewDecision,statusCheckRollup
24+
```
25+
26+
- **Not open** (already merged/closed) → report and stop.
27+
- **Draft** → it can't be merged. Ask the developer to confirm, then
28+
`gh pr ready <n>` before continuing. Don't un-draft silently.
29+
- **Failing required checks** (`statusCheckRollup`) → the queue will just reject
30+
it. Report which checks are red and stop; fix them first. **Pending** checks
31+
are fine — the queue waits for them.
32+
- **Merge conflicts** (`mergeable == "CONFLICTING"`) → report and stop; rebase first.
33+
34+
## 2. Enqueue
35+
36+
```bash
37+
gh pr comment <n> --body "/trunk merge"
38+
```
39+
40+
Within ~2 minutes, confirm Trunk picked it up — a check run whose name starts
41+
with `Trunk Merge Queue` should appear on the head commit:
42+
43+
```bash
44+
SHA=$(gh pr view <n> --json headRefOid -q .headRefOid)
45+
gh api repos/$REPO/commits/$SHA/check-runs \
46+
--jq '.check_runs[] | select(.name | startswith("Trunk Merge Queue")) | {name, status, conclusion, details_url}'
47+
```
48+
49+
If nothing appears after a couple of minutes, the developer may lack write
50+
access or GitHub-comment commands may be disabled — report that and suggest the
51+
`trunk-merge-queue-submit` label as a fallback.
52+
53+
## 3. Poll until it lands
54+
55+
Loop about every 60 seconds, up to ~45–60 minutes total. Each iteration:
56+
57+
```bash
58+
gh pr view <n> --json state,mergedAt # MERGED -> success, stop
59+
SHA=$(gh pr view <n> --json headRefOid -q .headRefOid)
60+
gh api repos/$REPO/commits/$SHA/check-runs \
61+
--jq '.check_runs[] | select(.name | startswith("Trunk Merge Queue")) | {status, conclusion, details_url}'
62+
sleep 60
63+
```
64+
65+
- `state == "MERGED"` → done. Report success with the merge commit.
66+
- Check run `status` moves `queued``in_progress``completed`. Report each
67+
transition so the developer can follow along.
68+
- Watch the **check run + PR state**, not `gh pr checks --watch`: the queue runs
69+
CI on Trunk's own draft/`trunk-merge/**` branch, so this PR's own checks don't
70+
reflect the queue's testing.
71+
- Stop at the timeout with a status summary rather than looping forever.
72+
73+
## 4. Handle failure
74+
75+
If the check run completes with `conclusion == "failure"` (or the PR drops out
76+
of the queue), Trunk kicks the PR and its bot comments with the failing
77+
workflow. Read the newest comments and report the reason:
78+
79+
```bash
80+
gh pr view <n> --comments | tail -n 40
81+
```
82+
83+
- If the failure is clearly caused by this PR **and** the fix is obvious, fix it,
84+
push, wait for the PR's own checks to go green, and re-enqueue **once** with
85+
`/trunk merge`.
86+
- Otherwise stop and report the failure and the workflow link. Don't repeatedly
87+
re-enqueue a red PR.
88+
89+
## 5. Cancel
90+
91+
If the developer asks to stop the merge:
92+
93+
```bash
94+
gh pr comment <n> --body "/trunk cancel"
95+
```
96+
97+
Confirm the check run reports cancelled.
98+
99+
## Hard rules
100+
101+
- **Never** run `gh pr merge` — it's blocked and it's not how this repo merges.
102+
- **Never** force-push a branch while it is in the queue — it removes the PR
103+
from the queue.
104+
- Re-enqueue a failed PR **at most once** automatically; beyond that, hand back
105+
to the developer.

.claude/skills/quill-code/SKILL.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: quill-code
3+
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.
4+
---
5+
6+
# quill-code
7+
8+
`@posthog/quill` is **not** in this repo. It is a published catalog dependency whose
9+
source lives in the main PostHog monorepo at `../posthog/packages/quill`. To test an
10+
unpublished quill change inside this repo (posthog-code), you build quill, pack it to a
11+
tarball, and point a pnpm `overrides` entry at that tarball. This is a **temporary
12+
local-dev** state — revert before merging (see below).
13+
14+
## Quill layout (where to edit)
15+
16+
`../posthog/packages/quill` is the **workspace** (`@posthog/quill-workspace`). It
17+
contains sub-packages, each a layer of the design system:
18+
19+
- `packages/primitives/src` — base components (Card, Badge, Button, Progress, …)
20+
- `packages/components/src` — composed components (DataTable, DateTimePicker, Metric)
21+
- `packages/blocks/src`**product-level blocks** (e.g. `ExperimentCard`). Add the
22+
file here and export it from `packages/blocks/src/index.ts`.
23+
- `packages/quill/src` — the **aggregate** that re-exports all layers as `@posthog/quill`.
24+
25+
A new export in any sub-package flows to `@posthog/quill` automatically on build.
26+
27+
## The loop (every quill change)
28+
29+
1. Edit/add the component in the right sub-package (above) and export it from that
30+
package's `src/index.ts`.
31+
2. Re-sync into this repo:
32+
33+
```bash
34+
.claude/skills/quill-code/scripts/sync-quill.sh
35+
```
36+
37+
This builds the **whole quill workspace** (recursive `pnpm build` at the workspace
38+
root — it rebuilds the sub-packages BEFORE the aggregate bundles them), packs it
39+
into `.local-quill/` as a content-hashed `posthog-quill-local-<hash>.tgz`, rewrites
40+
the override line in `pnpm-workspace.yaml`, deletes stale tarballs, and runs
41+
`pnpm install`.
42+
43+
> Building only the aggregate (`packages/quill/packages/quill`) re-bundles the
44+
> sub-packages' **stale** `dist/`, so edits to primitives/components/blocks are
45+
> silently dropped. Always build at the workspace root — the script does this.
46+
3. Verify in the Code app (`pnpm dev`, or the `test-electron-app` skill). Repeat from 1.
47+
48+
After every quill edit you **must** re-run the sync — the app consumes the tarball, not
49+
the quill source, so unsynced edits are invisible here.
50+
51+
If quill lives elsewhere, set `QUILL_DIR=/abs/path/to/posthog/packages/quill/packages/quill`.
52+
53+
## Why a tarball, not `link:`
54+
55+
`link:` symlinks into the mono's `node_modules` and drags in its **React 18** types,
56+
colliding with this repo's **React 19** (dual-React → broken typecheck +
57+
invalid-hook-call at runtime). The tarball is copied into this repo's store and deduped
58+
against React 19. The filename is **content-hashed** because pnpm pins a tarball by
59+
integrity, so a stable filename gets cached stale across re-syncs.
60+
61+
## The override (what the script rewrites)
62+
63+
In `pnpm-workspace.yaml`, under `overrides:`:
64+
65+
```yaml
66+
'@posthog/quill': file:./.local-quill/posthog-quill-local-<hash>.tgz
67+
```
68+
69+
There is also a permanent pin you should leave alone:
70+
71+
```yaml
72+
'@posthog/quill>@base-ui/react': ^1.3.0 # quill ships a broken catalog: dep; do not remove
73+
```
74+
75+
## Reverting (before merge)
76+
77+
The override is local-dev only. Once the quill change is published to npm:
78+
79+
1. Bump the catalog version in `pnpm-workspace.yaml` (`'@posthog/quill': 0.3.0-beta.x`)
80+
to the published version.
81+
2. Restore the override line to point back at the catalog, or remove the `file:` override.
82+
3. `pnpm install`.
83+
84+
Do not commit a `file:./.local-quill/...` override or the `.local-quill/` tarballs.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
# Build local @posthog/quill, pack it to a content-hashed tarball, point the
3+
# pnpm override at it, and reinstall. See SKILL.md for the why.
4+
set -euo pipefail
5+
6+
# code repo root = dir containing pnpm-workspace.yaml, walking up from this script
7+
CODE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && while [ ! -f pnpm-workspace.yaml ] && [ "$PWD" != / ]; do cd ..; done && pwd)"
8+
[ -f "$CODE_ROOT/pnpm-workspace.yaml" ] || { echo "could not find pnpm-workspace.yaml above $0" >&2; exit 1; }
9+
10+
QUILL_DIR="${QUILL_DIR:-$CODE_ROOT/../posthog/packages/quill/packages/quill}"
11+
[ -d "$QUILL_DIR" ] || { echo "quill source not found: $QUILL_DIR (set QUILL_DIR=...)" >&2; exit 1; }
12+
13+
# The quill workspace root (@posthog/quill-workspace) is two levels up from the
14+
# aggregate package. We MUST build there: its `pnpm build` runs the recursive
15+
# `pnpm -r --filter '@posthog/quill-*' --filter '@posthog/quill' build`, which
16+
# rebuilds the sub-packages (primitives, components, blocks, ...) BEFORE the
17+
# aggregate bundles them. Building inside QUILL_DIR alone only re-bundles the
18+
# sub-packages' STALE dist, so edits to blocks/primitives/etc. are silently lost.
19+
QUILL_WS="${QUILL_WS:-$(cd "$QUILL_DIR/../.." && pwd)}"
20+
21+
DEST="$CODE_ROOT/.local-quill"
22+
WS="$CODE_ROOT/pnpm-workspace.yaml"
23+
24+
echo "==> building quill workspace in $QUILL_WS"
25+
( cd "$QUILL_WS" && pnpm build )
26+
27+
echo "==> packing tarball -> $DEST"
28+
mkdir -p "$DEST"
29+
( cd "$QUILL_DIR" && npm pack --pack-destination "$DEST" >/dev/null )
30+
31+
RAW="$(ls -t "$DEST"/posthog-quill-*.tgz | grep -v -- '-local-' | head -1)"
32+
[ -n "$RAW" ] || { echo "npm pack produced no posthog-quill-*.tgz" >&2; exit 1; }
33+
34+
HASH="$(md5 -q "$RAW" | cut -c1-8)"
35+
HASHED="posthog-quill-local-$HASH.tgz"
36+
cp "$RAW" "$DEST/$HASHED"
37+
rm -f "$RAW"
38+
# drop stale local tarballs so the pnpm store can't resolve an old integrity
39+
find "$DEST" -name 'posthog-quill-local-*.tgz' ! -name "$HASHED" -delete
40+
41+
echo "==> pointing override at .local-quill/$HASHED"
42+
# single override line: '@posthog/quill': file:./.local-quill/...
43+
sed -i '' -E "s#('@posthog/quill': file:\./\.local-quill/)[^']*#\1$HASHED#" "$WS"
44+
grep -q "$HASHED" "$WS" || { echo "failed to rewrite override line in $WS" >&2; exit 1; }
45+
46+
echo "==> pnpm install"
47+
( cd "$CODE_ROOT" && pnpm install )
48+
49+
echo "==> done. @posthog/quill now resolves to .local-quill/$HASHED"

.github/workflows/code-release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ jobs:
196196
echo "OK: $bin"
197197
done
198198
199+
# The native codex CLI must ship as a sibling of codex-acp, or the
200+
# app-server harness silently falls back to codex-acp in production.
201+
for f in codex rg; do
202+
if [[ ! -f "$RESOURCES/app.asar.unpacked/.vite/build/codex-acp/$f" ]]; then
203+
echo "FAIL: codex-acp/$f missing in bundled binaries"
204+
exit 1
205+
fi
206+
echo "OK: codex-acp/$f"
207+
done
208+
199209
- name: Install Playwright
200210
run: pnpm --filter code exec playwright install
201211

0 commit comments

Comments
 (0)