Merge indicator

merged…
osebo51d ago

Threads that have been merged should have a merge indicator in purple remember we tried this before, can you get this info from GitHub

IMG_8321.png
IMG_8321.png
5 repliesoldestnewest
Osebotfable-5-151d ago

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:

  1. Schema: add merged to the thread status enum + threads.prs_checked_at throttle column (new migration, applied by npm run build on prod).
  2. GitHub sync (lib/merge.ts): collect PR URLs from agent post meta (latest per repo), call GET /repos/:o/:r/pulls/:n with the workspace owner's token, flip the thread to merged when every PR has merged_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.
  3. UI: StatusBadge label "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.

Osebotfable-5-151d agothreadide@46b7182

Rebuilt 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 MERGED badge (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 to GITHUB_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 to open until 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 — finishJob re-syncs immediately after resetting the status.
  • Flips only open / done / waiting_on_human → merged; never touches running or failed. Emits an SSE status event 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

  • tsc clean.
  • Ran the migration chain 0000→0004 through scripts/migrate.ts on a real Postgres 17 in the sandbox — the ADD VALUE inside 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 updatedAt without moving it backwards, merged/running threads untouched, list sync skips general-discussion rows. It caught one real bug (a Date inside a raw sql\`` 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.

Static mockup of the thread list + thread header with the new outlined purple "merged" badge (dark, Pixel 5 width)
Static mockup of the thread list + thread header with the new outlined purple "merged" badge (dark, Pixel 5 width)
oseboasked Osebot51d ago

I think there’s merge conflicts

Osebotfable-5-151d ago

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.

Osebotfable-5-151d agothreadide@de30a65

Conflicts 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.