Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/web/src/components/GitActionsControl.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ describe("when: ref has a merged PR", () => {

it("resolveQuickAction opens the merged PR when the ref is idle", () => {
const quick = resolveQuickAction(status({ pr: mergedPr }), false);
assert.deepInclude(quick, { kind: "open_pr", label: "View PR", disabled: false });
assert.deepInclude(quick, { kind: "open_pr", label: "Merged", disabled: false });
});

it("resolveQuickAction prefers viewing the merged PR over re-creating one after a squash merge", () => {
const quick = resolveQuickAction(status({ pr: mergedPr, aheadOfDefaultCount: 2 }), false);
assert.deepInclude(quick, { kind: "open_pr", label: "View PR", disabled: false });
assert.deepInclude(quick, { kind: "open_pr", label: "Merged", disabled: false });
});

it("resolveQuickAction opens the merged PR when the upstream ref is gone", () => {
const quick = resolveQuickAction(status({ pr: mergedPr, hasUpstream: false }), false);
assert.deepInclude(quick, { kind: "open_pr", label: "View PR", disabled: false });
assert.deepInclude(quick, { kind: "open_pr", label: "Merged", disabled: false });
});

it("resolveQuickAction still offers the commit flow for new changes", () => {
Expand Down
9 changes: 6 additions & 3 deletions apps/web/src/components/GitActionsControl.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ export function resolveQuickAction(
const isBehind = gitStatus.behindCount > 0;
const isDiverged = isAhead && isBehind;
const terminology = resolveChangeRequestTerminology(gitStatus);
// A merged PR still opens on click, but the label reports the state rather
// than the action - the purple tint and "Merged" read as one status chip.
const viewPrLabel = hasMergedPr ? "Merged" : `View ${terminology.shortLabel}`;

if (!hasBranch) {
return {
Expand Down Expand Up @@ -252,7 +255,7 @@ export function resolveQuickAction(
if (!gitStatus.hasUpstream) {
if (!hasPrimaryRemote) {
if ((hasOpenPr || hasMergedPr) && !isAhead) {
return { label: `View ${terminology.shortLabel}`, disabled: false, kind: "open_pr" };
return { label: viewPrLabel, disabled: false, kind: "open_pr" };
}
return {
label: "Publish repository",
Expand All @@ -262,7 +265,7 @@ export function resolveQuickAction(
}
if (!isAhead) {
if (hasOpenPr || hasMergedPr) {
return { label: `View ${terminology.shortLabel}`, disabled: false, kind: "open_pr" };
return { label: viewPrLabel, disabled: false, kind: "open_pr" };
}
return {
label: "Push",
Expand Down Expand Up @@ -325,7 +328,7 @@ export function resolveQuickAction(
// branch still reads as ahead of default, but re-creating a PR for commits
// that already landed is never the right offer.
if (hasOpenPr || hasMergedPr) {
return { label: `View ${terminology.shortLabel}`, disabled: false, kind: "open_pr" };
return { label: viewPrLabel, disabled: false, kind: "open_pr" };
}

if (hasDefaultBranchDelta && !isDefaultRef) {
Expand Down