fix(web): distinguish merged PR settlement

This commit is contained in:
t3-code[bot] authored and GitHub committed 2026-07-30 16:50:53 +00:00
1 parent 4ba4871af7
commit de780b2669
7 files changed
+61 -6

No files matched your search

@@ -22,6 +22,7 @@ import {
getStartedThreadModelChangeBlockReason,
hasServerAcknowledgedLocalDispatch,
isBranchMismatchDismissedForSession,
isMergedPrAutoSettlement,
reconcileMountedTerminalThreadIds,
reconcileRetainedMountedThreadIds,
resolveThreadMetadataUpdateForNextTurn,
@@ -86,6 +87,23 @@ const readySession = {
updatedAt: "2026-03-29T00:00:10.000Z",
};
describe("isMergedPrAutoSettlement", () => {
it("identifies an automatically settled merged PR", () => {
expect(isMergedPrAutoSettlement({ changeRequestState: "merged", settledOverride: null })).toBe(
true,
);
});
it("does not relabel manual settlements or non-merged PRs", () => {
expect(
isMergedPrAutoSettlement({ changeRequestState: "merged", settledOverride: "settled" }),
).toBe(false);
expect(isMergedPrAutoSettlement({ changeRequestState: "closed", settledOverride: null })).toBe(
false,
);
});
});
describe("buildLoadingThreadFromShell", () => {
it("preserves shell metadata and supplies empty detail collections", () => {
const shell = {
@@ -28,6 +28,13 @@ export const MAX_HIDDEN_MOUNTED_PREVIEW_THREADS = 3;
export const LastInvokedScriptByProjectSchema = Schema.Record(ProjectId, Schema.String);
export function isMergedPrAutoSettlement(input: {
changeRequestState: "open" | "closed" | "merged" | null;
settledOverride: "settled" | "active" | null | undefined;
}): boolean {
return input.changeRequestState === "merged" && input.settledOverride === null;
}
export function startNewThreadForProject(
projectRef: ScopedProjectRef | null,
handleNewThread: (projectRef: ScopedProjectRef) => Promise<void>,
+19 -5
View File
@@ -149,6 +149,7 @@ import {
CheckCircle2Icon,
ChevronDownIcon,
GitBranchIcon,
GitMergeIcon,
TriangleAlertIcon,
WifiOffIcon,
} from "lucide-react";
@@ -260,6 +261,7 @@ import {
dismissBranchMismatchForSession,
hasServerAcknowledgedLocalDispatch,
isBranchMismatchDismissedForSession,
isMergedPrAutoSettlement,
shouldShowBranchMismatchBanner,
getStartedThreadModelChangeBlockReason,
LAST_INVOKED_SCRIPT_BY_PROJECT_KEY,
@@ -4158,14 +4160,24 @@ function ChatViewContent(props: ChatViewProps) {
return null;
}
const isSnoozed = activeThreadSnoozed;
const isMergedPr =
!isSnoozed &&
isMergedPrAutoSettlement({
changeRequestState: activeThreadPr?.state ?? null,
settledOverride: activeThreadShell?.settledOverride,
});
return {
id: `thread-${isSnoozed ? "snoozed" : "settled"}:${activeThread?.id ?? "unknown"}`,
variant: "info",
icon: isSnoozed ? <AlarmClockIcon /> : <CheckCircle2Icon />,
title: `This thread is ${isSnoozed ? "snoozed" : "settled"}`,
id: `thread-${isSnoozed ? "snoozed" : isMergedPr ? "merged" : "settled"}:${activeThread?.id ?? "unknown"}`,
variant: isMergedPr ? "merged" : "info",
icon: isSnoozed ? <AlarmClockIcon /> : isMergedPr ? <GitMergeIcon /> : <CheckCircle2Icon />,
title: isMergedPr
? "Pull request merged"
: `This thread is ${isSnoozed ? "snoozed" : "settled"}`,
description: isSnoozed
? "Sending a message wakes it and moves it back to Active in the sidebar."
: "Sending a message moves it back to Active in the sidebar.",
: isMergedPr
? "This thread settled automatically because its pull request was merged."
: "Sending a message moves it back to Active in the sidebar.",
actions: (
<Button
size="xs"
@@ -4187,7 +4199,9 @@ function ChatViewContent(props: ChatViewProps) {
};
}, [
activeThread?.id,
activeThreadPr?.state,
activeThreadSettled,
activeThreadShell?.settledOverride,
activeThreadSnoozed,
handleUnsnoozeActiveThread,
handleUnsettleActiveThread,
@@ -39,6 +39,16 @@ describe("ComposerBannerStack", () => {
expect(markup).not.toContain("will-change:transform");
});
it("renders merged banners with the pull request violet treatment", () => {
const markup = renderToStaticMarkup(
<ComposerBannerStack items={[{ ...banner("merged"), variant: "merged" }]} />,
);
expect(markup).toContain('data-variant="merged"');
expect(markup).toContain("border-violet-500/32");
expect(markup).toContain("text-violet-600");
});
it("applies item-specific surface and action layout classes", () => {
const markup = renderToStaticMarkup(
<ComposerBannerStack
@@ -24,7 +24,7 @@ const exitTransitionStyle = {
export interface ComposerBannerStackItem {
readonly id: string;
readonly variant: "default" | "error" | "info" | "success" | "warning";
readonly variant: "default" | "error" | "info" | "merged" | "success" | "warning";
readonly icon: ReactNode;
readonly title: ReactNode;
readonly description?: ReactNode;
+2
View File
@@ -14,6 +14,8 @@ const alertVariants = cva("relative rounded-xl border px-3.5 py-3 text-card-fore
error:
"border-destructive/32 bg-destructive/4 text-destructive-foreground [&_[data-slot=alert-description]]:text-destructive-foreground/80 [&_svg]:text-destructive",
info: "border-info/32 bg-info/4 [&_svg]:text-info",
merged:
"border-violet-500/32 bg-violet-500/4 [&_svg]:text-violet-600 dark:[&_svg]:text-violet-300/90",
success: "border-success/32 bg-success/4 [&_svg]:text-success",
warning: "border-warning/32 bg-warning/4 [&_svg]:text-warning",
},
+4
View File
@@ -572,6 +572,10 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--alert-glass-tint: var(--info);
}
.alert-glass[data-variant="merged"] {
--alert-glass-tint: var(--color-violet-500);
}
.alert-glass[data-variant="success"] {
--alert-glass-tint: var(--success);
}