Skip to content

fix: reflect PR state in channel task card badge#3254

Closed
adamleithp wants to merge 3 commits into
mainfrom
posthog-code/channel-card-pr-status
Closed

fix: reflect PR state in channel task card badge#3254
adamleithp wants to merge 3 commits into
mainfrom
posthog-code/channel-card-pr-status

Conversation

@adamleithp

Copy link
Copy Markdown
Contributor

Problem

A channel task card always showed "In progress" even after the task was done and a PR was created.

The status badge (TaskStatusBadge in ChannelFeedView.tsx) read only the run status (taskRunStatus / latest_run.status). Cloud run rows routinely linger on in_progress after the agent opens the PR, so the badge got stuck. The PR's real GitHub state was already fetched and rendered by the sidebar TaskIcon (via useTaskPrStatus), but the card badge ignored it.

Fix

The badge now pulls PR state the same way the icon does, and a PR outranks the run status:

PR state Badge
open In review (info)
merged Merged (success)
draft Draft PR (default)
closed Closed (destructive)

Precedence: Needs input → live In progressPR state → run status (Completed / Failed / Local / Draft).

A failed / cancelled run still wins over an open PR — that's a deliberate end state we shouldn't hide.

Card badge and sidebar icon now agree. One file touched, typecheck green.


Created with PostHog Code

@trunk-io

trunk-io Bot commented Jul 8, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: reflect PR state in channel task ca..." | Re-trigger Greptile

Comment on lines +25 to +43
if (typeof arg === "object" && arg !== null) {
const seen = new WeakSet<object>();
try {
return (
JSON.stringify(arg, (_key, value: unknown) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) return "[circular]";
seen.add(value);
}
if (typeof value === "bigint" || typeof value === "function") {
return String(value);
}
return value;
}) ?? String(arg)
);
} catch {
return String(arg);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Circular-reference detection here is nearly identical to the logic inside serializeError in errorDetails.ts — both maintain a WeakSet<object> and return "[circular]" for revisited nodes. Per the team's OnceAndOnlyOnce rule, a small shared helper (e.g. makeCircularSafeReplacer) could serve both call sites and keep the two serializers in sync when edge cases are discovered in one of them.

Suggested change
if (typeof arg === "object" && arg !== null) {
const seen = new WeakSet<object>();
try {
return (
JSON.stringify(arg, (_key, value: unknown) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) return "[circular]";
seen.add(value);
}
if (typeof value === "bigint" || typeof value === "function") {
return String(value);
}
return value;
}) ?? String(arg)
);
} catch {
return String(arg);
}
}
if (typeof arg === "object" && arg !== null) {
const seen = new WeakSet<object>();
const replacer = (_key: string, value: unknown): unknown => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) return "[circular]";
seen.add(value);
}
if (typeof value === "bigint" || typeof value === "function") {
return String(value);
}
return value;
};
try {
return JSON.stringify(arg, replacer) ?? String(arg);
} catch {
return String(arg);
}
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 7d2f4a0.

Rework the task card status row in the channel feed:

- Once a PR exists, its state (Merged / PR ready / Draft / Closed) is the
  sole top-line status, replacing the run badge — so a shipped task never
  reads "Ready + Merged" or a stale "In progress + PR ready".
- Merged PRs show a purple badge and lift the card to a purple border +
  tint, matching the sidebar's merge accent.
- Fall back to the neutral "PR ready" when a PR URL exists but its GitHub
  state hasn't resolved yet, so the badge and the "PR" link never disagree.
- "Ready" instead of "Completed" for finished runs — the work is ready to
  look at, not necessarily shipped.
- Drop the redundant "Local" pill; environment shows in the meta row
  ("· Local" / "· Cloud").

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adamleithp adamleithp force-pushed the posthog-code/channel-card-pr-status branch from a4c8624 to 3336776 Compare July 8, 2026 09:35
adamleithp and others added 2 commits July 8, 2026 12:36
…roll

- Rebuild feed rows on quill's ThreadItem primitives (gutter avatar, header,
  body, hover action bar) instead of hand-rolled ChatMessage markup.
- Group rows by day with a ChatMarker separator: "Today" / "Yesterday", then a
  weekday + ordinal ("Monday 5th"), adding month/year further back.
- Cut scroll jank: memoize rows so task-list polls don't re-render the whole
  feed, gate each row's 15s reply-teaser poll behind an in-view observer, and
  tune contain-intrinsic-size to the real ~13rem row height.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant