Threads that have been merged should have a merge indicator in purple remember we tried this before, can you get this info from GitHub
Merge indicator
The earlier "merged" work (lib/merge.ts, purple .badge.merged) never landed on main — its branch is gone from origin, so I'll rebuild it:
- Schema: add
mergedto the thread status enum +threads.prs_checked_atthrottle column (new migration, applied bynpm run buildon prod). - GitHub sync (
lib/merge.ts): collect PR URLs from agent post meta (latest per repo), callGET /repos/:o/:r/pulls/:nwith the workspace owner's token, flip the thread tomergedwhen every PR hasmerged_at. Only open/done threads flip; throttle 1 min per thread on the thread page, 10 min / ≤10 threads on the list pages, and once right after a run finishes. No webhook needed. - UI:
StatusBadgelabel "merged", outlined purple (--merged, GitHub's PR purple) in both light and dark — the only non-monochrome colour besides--karma.
Will post a screenshot of the badge in the list once done.
threadide@46b7182Rebuilt the merged indicator from scratch (the earlier attempt's branch no longer exists on origin). Pushed to thread/a0e0a322; no PR opened yet — say the word if you want one.
What it does
- A thread whose PRs have all been merged on GitHub shows an outlined purple
MERGEDbadge (GitHub's PR purple,--merged) in the thread list and the thread header. Screenshot attached (static mockup against the real CSS — the·glyphs are a mockup charset artefact, not app code). - Info comes straight from GitHub:
GET /repos/:o/:r/pulls/:n→merged_at, using the workspace owner's token (falls back toGITHUB_TOKEN). PR numbers are taken from the agent posts'meta.prs; the latest post per repo wins, so after a merged thread gets a new run (new PR on the same branch) it goes back toopenuntil that one lands too. - No webhook. It syncs lazily where people already look:
- Thread page — before render, throttled to once/min per thread, so opening a thread shows the current GitHub state.
- Home / workspace lists — after the response (
next/server after()), 10-min throttle, at most 10 threads per view. - After a run finishes —
finishJobre-syncs immediately after resetting the status.
- Flips only
open/done/waiting_on_human→merged; never touchesrunningorfailed. Emits an SSEstatusevent so an open thread page refreshes.
Schema
drizzle/0004_merged_status.sql: ALTER TYPE thread_status ADD VALUE 'merged' + threads.prs_checked_at (throttle stamp, written even when GitHub errors so a dead token can't turn every page view into retries). Applied by npm run build on the prod deploy once this merges — nothing to run by hand.
Verification
tscclean.- Ran the migration chain 0000→0004 through
scripts/migrate.tson a real Postgres 17 in the sandbox — theADD VALUEinside the migrator's transaction is fine. - End-to-end script against that DB with GitHub mocked: latest-per-alias selection, throttle, partial-merge stays open, full merge flips + bumps
updatedAtwithout moving it backwards, merged/running threads untouched, list sync skips general-discussion rows. It caught one real bug (aDateinside a rawsql\`` fragment isn't serialized by postgres-js) — fixed in the second commit, and noted in memory.
Existing threads
Already-merged threads (e.g. the Reply-button one) will flip the next time someone opens them or the list is viewed after deploy; no backfill needed.
I think there’s merge conflicts
Confirmed: main moved on after I branched (PR #37, link previews) and both sides touched app/globals.css, app/threads/[id]/page.tsx, app/workspaces/[id]/page.tsx. I'll merge origin/main into thread/a0e0a322, resolve the conflicts by hand, re-run tsc, and push.
threadide@de30a65Conflicts resolved and pushed — thread/a0e0a322 now merges cleanly into main (verified with git merge-tree).
What conflicted: main gained PR #37 (link previews) after I branched. Git auto-merged app/globals.css and app/workspaces/[id]/page.tsx; the only real conflict was the import block in app/threads/[id]/page.tsx, where both sides added imports (syncThreadMergeStatus vs SignInGate/threadPreview/previewMetadata). Kept both — the merge-status sync still runs after the anonymous SignInGate early-return, so crawlers never trigger GitHub calls.
Verified: tsc --noEmit clean; syncStaleThreads after() hooks still present on home + workspace pages; .badge.merged / --merged vars intact in globals.css.
Merge commit: de30a65. Still no PR opened — tell me if you want one.

