Skip to content

fix(code): show unified PR badge for externally-created PRs#1995

Open
richardsolomou wants to merge 3 commits intomainfrom
posthog-code/fix-pr-badge-external-creation
Open

fix(code): show unified PR badge for externally-created PRs#1995
richardsolomou wants to merge 3 commits intomainfrom
posthog-code/fix-pr-badge-external-creation

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

@richardsolomou richardsolomou commented May 4, 2026

Problem

The unified PR badge in the task header depends on workspace.linkedBranch being set. #1963 made the link reliable for PRs created through the in-app flow, but skills that run gh pr create via bash never go through GitService.createPr — so linkedBranch stays unset and the badge falls back to the old "View PR" button. The dropdown next to it also surfaces disabled Commit / Push entries even when there's nothing to commit or push, which is just noise.

This pattern is common: a /commit-and-pr skill that only shells out to git/gh, no in-app buttons involved.

Closes #1959

Changes

  • TaskActionsMenu: fall back to gitState.prUrl (populated by getPrStatus against the current branch) when linkedBranch is unset, so the badge appears for any worktree whose current branch has a PR. Comment notes the agent emit is the primary path and this fallback only covers the unfocused-on-worktree case.
  • TaskActionsMenu: when a PR exists, drop the work-shipping slots (commit / push / sync / publish) from the adjacent dropdown when they're disabled — those flip to disabled solely to signal "nothing to do," which is noise next to a PR badge. Other disabled actions stay so their disabledReason tooltip can still explain why they're unavailable. NO_WORK_SLOTS lives at module scope.
  • AgentService.detectAndAttachPrUrl: when a PR URL is detected in bash output, also emit AgentFileActivity so WorkspaceService.handleAgentFileActivity records the current feature branch as linkedBranch. Keeps the rest of the PR-aware UI (branch mismatch warning, diff source resolution) in sync without waiting for the next file edit.
  • AgentService: extracted emitAgentFileActivityForCurrentBranch so detectAndAttachPrUrl and trackAgentFileActivity share a single branch-resolve-and-emit path.

How did you test this?

  • pnpm --filter code typecheck — clean.
  • pnpm --filter code test — 1007 tests pass.
  • pnpm lint — clean.
  • Need a manual pass: in a local/worktree task with a PR created via a bash skill, confirm the unified badge appears (with PR number) and that the adjacent dropdown only lists actionable git items, with disabled non-work-shipping actions still surfaced via tooltip.

Publish to changelog?

no


Created with PostHog Code

The unified badge depended on `workspace.linkedBranch`, which only got
set when the in-app create-PR flow ran. Skills that run `gh pr create`
via bash never went through that flow, so the badge fell back to the
old "View PR" button (and a dropdown of disabled commit/push items)
even though `getPrStatus` had already discovered the PR on the current
branch.

- TaskActionsMenu: fall back to `gitState.prUrl` when no `linkedBranch`
  is recorded so the badge appears for any worktree whose current
  branch has a PR.
- TaskActionsMenu: when a PR exists, drop disabled commit/push entries
  from the adjacent dropdown so it only surfaces actionable items.
- AgentService: when a PR URL is detected in bash output, emit
  `AgentFileActivity` so `WorkspaceService` records the current branch
  as `linkedBranch`. Keeps PR-aware UI (branch mismatch, diff source)
  in sync without waiting for the next file edit.

Generated-By: PostHog Code
Task-Id: 66a40920-2b25-40b6-983e-1a489353431d
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 4, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/git-interaction/components/TaskActionsMenu.tsx:101-107
**Hiding disabled actions may obscure actionable context**

When a PR exists, all disabled git actions (not just `view-pr`/`create-pr`) are now silently dropped from the dropdown. This means a disabled `sync` or `branch-here` entry — which normally carries a `disabledReason` tooltip — disappears entirely rather than appearing greyed-out with an explanation. A user who needs to know *why* sync is unavailable (e.g. network issue, diverged branch) gets no signal at all.

The existing `GitDropdownItem` already renders disabled items with a tooltip via `action.disabledReason`, so the infrastructure to surface context while keeping items disabled is in place. Keeping non-PR-specific items visible but disabled preserves that signal without cluttering the menu with truly-redundant entries like `commit` when there's nothing to commit.

Reviews (1): Last reviewed commit: "fix(code): show unified PR badge for ext..." | Re-trigger Greptile

@richardsolomou richardsolomou requested a review from a team May 4, 2026 11:55
…ions

Narrow the dropdown filter to only drop disabled commit / push / sync /
publish entries — these slots flip to disabled solely to signal "no
work to do," so they're noise next to a PR badge. Other disabled
actions stay visible so their disabledReason tooltip can still explain
why they're unavailable (network issues, diverged branch, etc).

Generated-By: PostHog Code
Task-Id: 66a40920-2b25-40b6-983e-1a489353431d
@richardsolomou richardsolomou added the Create release This will trigger a new release label May 4, 2026
- Extract emitAgentFileActivityForCurrentBranch helper so detectAndAttachPrUrl and trackAgentFileActivity share a single branch-link path.
- Hoist NO_WORK_SLOTS to module scope.
- Tighten the fallback comment to acknowledge the agent emit is the primary path and that gitState.prUrl only covers the unfocused-on-worktree case.

Generated-By: PostHog Code
Task-Id: 285de649-2c86-45de-8919-0521f6344cc7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inconsistent PR status / git operation buttons

1 participant