Merge latest origin/main into t3code/codex-turn-mapping
Co-authored-by: codex <[email protected]>
This commit is contained in:
commit
4e200e4de4
8 files changed
+59
-24
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
resolveDraftEnvModeAfterBranchChange,
|
||||
resolveEffectiveEnvMode,
|
||||
resolveEnvModeLabel,
|
||||
resolveBranchToolbarPrBranch,
|
||||
resolveBranchToolbarValue,
|
||||
resolveLockedWorkspaceLabel,
|
||||
resolveWorkspaceDisplayName,
|
||||
@@ -174,6 +175,35 @@ describe("resolveBranchToolbarValue", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveBranchToolbarPrBranch", () => {
|
||||
it("uses the explicit thread branch when it matches the displayed branch", () => {
|
||||
expect(
|
||||
resolveBranchToolbarPrBranch({
|
||||
activeThreadBranch: "feature/current",
|
||||
resolvedActiveBranch: "feature/current",
|
||||
}),
|
||||
).toBe("feature/current");
|
||||
});
|
||||
|
||||
it("hides PR state while an optimistic branch switch is in flight", () => {
|
||||
expect(
|
||||
resolveBranchToolbarPrBranch({
|
||||
activeThreadBranch: "feature/current",
|
||||
resolvedActiveBranch: "feature/next",
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("does not infer PR state without an explicit thread branch", () => {
|
||||
expect(
|
||||
resolveBranchToolbarPrBranch({
|
||||
activeThreadBranch: null,
|
||||
resolvedActiveBranch: "feature/current",
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveLocalCheckoutBranchMismatch", () => {
|
||||
it("detects when a local thread is associated with a different branch than the checkout", () => {
|
||||
expect(
|
||||
|
||||
@@ -163,6 +163,13 @@ export function resolveBranchToolbarValue(input: {
|
||||
return currentGitBranch ?? activeThreadBranch;
|
||||
}
|
||||
|
||||
export function resolveBranchToolbarPrBranch(input: {
|
||||
activeThreadBranch: string | null;
|
||||
resolvedActiveBranch: string | null;
|
||||
}): string | null {
|
||||
return input.activeThreadBranch === input.resolvedActiveBranch ? input.activeThreadBranch : null;
|
||||
}
|
||||
|
||||
export function resolveLocalCheckoutBranchMismatch(input: {
|
||||
effectiveEnvMode: EnvMode;
|
||||
activeWorktreePath: string | null;
|
||||
|
||||
@@ -41,6 +41,7 @@ import { parsePullRequestReference } from "../pullRequestReference";
|
||||
import { getSourceControlPresentation } from "../sourceControlPresentation";
|
||||
import {
|
||||
deriveLocalBranchNameFromRemoteRef,
|
||||
resolveBranchToolbarPrBranch,
|
||||
resolveBranchSelectionTarget,
|
||||
resolveBranchToolbarValue,
|
||||
resolveDraftEnvModeAfterBranchChange,
|
||||
@@ -599,9 +600,11 @@ export function BranchToolbarBranchSelector({
|
||||
|
||||
// PR pill shown next to the branch selector when the active branch has one.
|
||||
const branchPr = resolveThreadPr({
|
||||
threadBranch: resolvedActiveBranch,
|
||||
threadBranch: resolveBranchToolbarPrBranch({
|
||||
activeThreadBranch,
|
||||
resolvedActiveBranch,
|
||||
}),
|
||||
gitStatus: branchStatusQuery.data ?? null,
|
||||
hasDedicatedWorktree: activeWorktreePath !== null,
|
||||
});
|
||||
const branchPrStatus = prStatusIndicator(branchPr, branchStatusQuery.data?.sourceControlProvider);
|
||||
// Action-oriented tooltip (the pill opens the PR), distinct from the sidebar's
|
||||
|
||||
@@ -3972,7 +3972,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
const activeThreadPr = resolveThreadPr({
|
||||
threadBranch: activeThread?.branch ?? null,
|
||||
gitStatus: gitStatusQuery.data ?? null,
|
||||
hasDedicatedWorktree: (activeThread?.worktreePath ?? null) !== null,
|
||||
});
|
||||
const supportsSettlement = serverConfig?.environment.capabilities.threadSettlement === true;
|
||||
const supportsSnooze = serverConfig?.environment.capabilities.threadSnooze === true;
|
||||
|
||||
@@ -456,7 +456,6 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
|
||||
const pr = resolveThreadPr({
|
||||
threadBranch: thread.branch,
|
||||
gitStatus: gitStatus.data,
|
||||
hasDedicatedWorktree: thread.worktreePath !== null,
|
||||
});
|
||||
const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider);
|
||||
const terminalStatus = terminalStatusFromRunningIds(runningTerminalIds);
|
||||
|
||||
@@ -502,7 +502,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
||||
const pr = resolveThreadPr({
|
||||
threadBranch: thread.branch,
|
||||
gitStatus: gitStatus.data,
|
||||
hasDedicatedWorktree: thread.worktreePath !== null,
|
||||
});
|
||||
const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider);
|
||||
const settledPrHoverClass = pr ? settledPrHoverColorClass(pr.state) : undefined;
|
||||
|
||||
@@ -36,31 +36,35 @@ describe("resolveThreadPr", () => {
|
||||
resolveThreadPr({
|
||||
threadBranch: "feature/other",
|
||||
gitStatus: status(),
|
||||
hasDedicatedWorktree: false,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("shows PR indicators for dedicated worktree threads even when branch metadata is stale", () => {
|
||||
const gitStatus = status();
|
||||
|
||||
it("hides PR indicators when a dedicated worktree has switched away from the thread branch", () => {
|
||||
expect(
|
||||
resolveThreadPr({
|
||||
threadBranch: "feature/old-name",
|
||||
gitStatus,
|
||||
hasDedicatedWorktree: true,
|
||||
threadBranch: "stack/base",
|
||||
gitStatus: status(),
|
||||
}),
|
||||
).toBe(gitStatus.pr);
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("shows PR indicators for dedicated worktree threads even when branch metadata is missing", () => {
|
||||
const gitStatus = status();
|
||||
|
||||
it("hides PR indicators when thread branch metadata is missing", () => {
|
||||
expect(
|
||||
resolveThreadPr({
|
||||
threadBranch: null,
|
||||
gitStatus: status(),
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("shows the PR when the live checkout matches the stored thread branch", () => {
|
||||
const gitStatus = status();
|
||||
|
||||
expect(
|
||||
resolveThreadPr({
|
||||
threadBranch: "feature/current",
|
||||
gitStatus,
|
||||
hasDedicatedWorktree: true,
|
||||
}),
|
||||
).toBe(gitStatus.pr);
|
||||
});
|
||||
|
||||
@@ -113,17 +113,12 @@ export function PrStatusTooltipContent({ status }: { status: PrStatusIndicator }
|
||||
export function resolveThreadPr(input: {
|
||||
threadBranch: string | null;
|
||||
gitStatus: VcsStatusResult | null;
|
||||
hasDedicatedWorktree: boolean;
|
||||
}): ThreadPr | null {
|
||||
const { threadBranch, gitStatus, hasDedicatedWorktree } = input;
|
||||
const { threadBranch, gitStatus } = input;
|
||||
if (gitStatus === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (hasDedicatedWorktree) {
|
||||
return gitStatus.pr ?? null;
|
||||
}
|
||||
|
||||
if (threadBranch === null || gitStatus.refName !== threadBranch) {
|
||||
return null;
|
||||
}
|
||||
@@ -258,7 +253,6 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar
|
||||
const pr = resolveThreadPr({
|
||||
threadBranch: thread.branch,
|
||||
gitStatus: gitStatus.data,
|
||||
hasDedicatedWorktree: thread.worktreePath !== null,
|
||||
});
|
||||
const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider);
|
||||
const threadStatus = resolveThreadStatusPill({
|
||||
|
||||
Reference in new issue
Block a user