Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd0cd27d4b | ||
|
|
c10530288c |
No files matched your search
@@ -348,10 +348,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
const workspaceMode = selectedProjectDraft.workspaceSelection?.mode ?? "local";
|
||||
const selectedBranchName = selectedProjectDraft.workspaceSelection?.branch ?? null;
|
||||
const selectedWorktreePath = selectedProjectDraft.workspaceSelection?.worktreePath ?? null;
|
||||
const startFromOrigin =
|
||||
selectedProjectDraft.workspaceSelection?.startFromOrigin ??
|
||||
selectedEnvironmentServerConfig?.settings.newWorktreesStartFromOrigin ??
|
||||
true;
|
||||
const startFromOrigin = selectedProjectDraft.workspaceSelection?.startFromOrigin ?? false;
|
||||
const runtimeMode = selectedProjectDraft.runtimeMode ?? DEFAULT_RUNTIME_MODE;
|
||||
const interactionMode = selectedProjectDraft.interactionMode ?? DEFAULT_PROVIDER_INTERACTION_MODE;
|
||||
|
||||
@@ -601,8 +598,8 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
return;
|
||||
}
|
||||
const preferredBranch =
|
||||
availableBranches.find((branch) => branch.isDefault) ??
|
||||
availableBranches.find((branch) => branch.current) ??
|
||||
availableBranches.find((branch) => branch.isDefault) ??
|
||||
null;
|
||||
if (preferredBranch) {
|
||||
selectBranch(preferredBranch);
|
||||
|
||||
@@ -523,26 +523,6 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("marks the origin default ref as default when no local copy exists", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
const remote = yield* makeTmpDir("git-vcs-driver-remote-");
|
||||
const { initialBranch } = yield* initRepoWithCommit(cwd);
|
||||
yield* git(remote, ["init", "--bare"]);
|
||||
yield* git(cwd, ["remote", "add", "origin", remote]);
|
||||
yield* git(cwd, ["push", "-u", "origin", initialBranch]);
|
||||
yield* git(cwd, ["remote", "set-head", "origin", initialBranch]);
|
||||
yield* git(cwd, ["checkout", "-b", "feature/only-local"]);
|
||||
yield* git(cwd, ["branch", "-D", initialBranch]);
|
||||
const driver = yield* GitVcsDriver.GitVcsDriver;
|
||||
|
||||
const refs = yield* driver.listRefs({ cwd });
|
||||
const remoteDefault = refs.refs.find((ref) => ref.name === `origin/${initialBranch}`);
|
||||
assert.equal(remoteDefault?.isRemote, true);
|
||||
assert.equal(remoteDefault?.isDefault, true);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("creates, checks out, renames, and lists refs", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
|
||||
@@ -2202,12 +2202,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
name: refName.name,
|
||||
current: false,
|
||||
isRemote: true,
|
||||
// origin/HEAD's target is the repo default even when no local
|
||||
// copy of the default branch exists.
|
||||
isDefault:
|
||||
defaultBranch !== null &&
|
||||
parsedRemoteRef?.remoteName === "origin" &&
|
||||
parsedRemoteRef.branchName === defaultBranch,
|
||||
isDefault: false,
|
||||
worktreePath: null,
|
||||
};
|
||||
if (parsedRemoteRef) {
|
||||
|
||||
@@ -422,32 +422,17 @@ export function BranchToolbarBranchSelector({
|
||||
});
|
||||
};
|
||||
|
||||
// Default the worktree base to the repo default branch (origin/HEAD), only
|
||||
// falling back to the checked-out branch when no default is known.
|
||||
const defaultBranchName = useMemo(
|
||||
() => refs.find((refName) => refName.isDefault)?.name ?? null,
|
||||
[refs],
|
||||
);
|
||||
const worktreeBaseBranchCandidate = isInitialBranchesLoadPending
|
||||
? null
|
||||
: (defaultBranchName ?? currentGitBranch);
|
||||
useEffect(() => {
|
||||
if (
|
||||
effectiveEnvMode !== "worktree" ||
|
||||
activeWorktreePath ||
|
||||
activeThreadBranch ||
|
||||
!worktreeBaseBranchCandidate
|
||||
!currentGitBranch
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setThreadBranch(worktreeBaseBranchCandidate, null);
|
||||
}, [
|
||||
activeThreadBranch,
|
||||
activeWorktreePath,
|
||||
effectiveEnvMode,
|
||||
setThreadBranch,
|
||||
worktreeBaseBranchCandidate,
|
||||
]);
|
||||
setThreadBranch(currentGitBranch, null);
|
||||
}, [activeThreadBranch, activeWorktreePath, currentGitBranch, effectiveEnvMode, setThreadBranch]);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Combobox / list plumbing
|
||||
|
||||
@@ -38,33 +38,75 @@ function latestProviderCheckedAt(
|
||||
);
|
||||
}
|
||||
|
||||
interface SidebarProviderUpdatePillContentProps {
|
||||
readonly providers: ReadonlyArray<ServerProvider>;
|
||||
readonly onOpenProviderSettings: () => void;
|
||||
}
|
||||
|
||||
interface ProviderUpdatePillExitState {
|
||||
readonly view: ProviderUpdateSidebarPillView;
|
||||
readonly dismissAfterExitKey: string | null;
|
||||
}
|
||||
|
||||
function useProviderUpdatePillAutoDismiss({
|
||||
displayedView,
|
||||
exitingKey,
|
||||
startExit,
|
||||
}: {
|
||||
readonly displayedView: ProviderUpdateSidebarPillView | null;
|
||||
readonly exitingKey: string | null;
|
||||
readonly startExit: (view: ProviderUpdateSidebarPillView, dismissKey?: string) => void;
|
||||
}) {
|
||||
const dismissAfterVisibleMs = displayedView?.dismissAfterVisibleMs;
|
||||
const viewKey = displayedView?.key ?? null;
|
||||
|
||||
useEffect(() => {
|
||||
if (!displayedView || !dismissAfterVisibleMs || !viewKey) {
|
||||
return;
|
||||
}
|
||||
if (exitingKey === viewKey) {
|
||||
return;
|
||||
}
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
startExit(displayedView, viewKey);
|
||||
}, dismissAfterVisibleMs);
|
||||
|
||||
return () => window.clearTimeout(timeoutId);
|
||||
}, [dismissAfterVisibleMs, displayedView, exitingKey, startExit, viewKey]);
|
||||
}
|
||||
|
||||
export function SidebarProviderUpdatePill() {
|
||||
const navigate = useNavigate();
|
||||
const providers = useAtomValue(primaryServerProvidersAtom);
|
||||
const [dismissedKeys, setDismissedKeys] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const [renderedView, setRenderedView] = useState<ProviderUpdateSidebarPillView | null>(null);
|
||||
const [pendingView, setPendingView] = useState<ProviderUpdateSidebarPillView | null>(null);
|
||||
const [exitingKey, setExitingKey] = useState<string | null>(null);
|
||||
const [dismissAfterExitKey, setDismissAfterExitKey] = useState<string | null>(null);
|
||||
const [visibleAfterIso, setVisibleAfterIso] = useState<string | undefined>();
|
||||
const effectiveVisibleAfterIso = visibleAfterIso ?? latestProviderCheckedAt(providers);
|
||||
const view = getProviderUpdateSidebarPillView(providers, {
|
||||
...(effectiveVisibleAfterIso !== undefined
|
||||
? { visibleAfterIso: effectiveVisibleAfterIso }
|
||||
: {}),
|
||||
dismissedKeys,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (visibleAfterIso === undefined && effectiveVisibleAfterIso !== undefined) {
|
||||
setVisibleAfterIso(effectiveVisibleAfterIso);
|
||||
}
|
||||
}, [effectiveVisibleAfterIso, visibleAfterIso]);
|
||||
|
||||
const openProviderSettings = useCallback(() => {
|
||||
void navigate({ to: "/settings/providers" });
|
||||
}, [navigate]);
|
||||
const displayedView = renderedView ?? view;
|
||||
|
||||
if (providers.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarProviderUpdatePillContent
|
||||
providers={providers}
|
||||
onOpenProviderSettings={openProviderSettings}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function SidebarProviderUpdatePillContent({
|
||||
providers,
|
||||
onOpenProviderSettings,
|
||||
}: SidebarProviderUpdatePillContentProps) {
|
||||
const [dismissedKeys, setDismissedKeys] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const [visibleAfterIso] = useState(() => latestProviderCheckedAt(providers));
|
||||
const view = getProviderUpdateSidebarPillView(providers, {
|
||||
...(visibleAfterIso !== undefined ? { visibleAfterIso } : {}),
|
||||
dismissedKeys,
|
||||
});
|
||||
const [exitState, setExitState] = useState<ProviderUpdatePillExitState | null>(null);
|
||||
const displayedView = exitState?.view ?? view;
|
||||
const exitingKey = exitState?.view.key ?? null;
|
||||
const dismissAfterVisibleMs = displayedView?.dismissAfterVisibleMs;
|
||||
const viewKey = displayedView?.key ?? null;
|
||||
const showDismissProgress =
|
||||
@@ -72,51 +114,15 @@ export function SidebarProviderUpdatePill() {
|
||||
displayedView?.tone !== "loading" &&
|
||||
exitingKey !== viewKey;
|
||||
|
||||
const startExit = useCallback(
|
||||
(key: string, nextView: ProviderUpdateSidebarPillView | null, dismissKey?: string) => {
|
||||
if (exitingKey === key) {
|
||||
return;
|
||||
}
|
||||
setPendingView(nextView);
|
||||
setExitingKey(key);
|
||||
setDismissAfterExitKey(dismissKey ?? null);
|
||||
},
|
||||
[exitingKey],
|
||||
);
|
||||
const startExit = useCallback((exitView: ProviderUpdateSidebarPillView, dismissKey?: string) => {
|
||||
setExitState((current) =>
|
||||
current?.view.key === exitView.key
|
||||
? current
|
||||
: { view: exitView, dismissAfterExitKey: dismissKey ?? null },
|
||||
);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (exitingKey !== null) {
|
||||
return;
|
||||
}
|
||||
if (!renderedView) {
|
||||
if (view) {
|
||||
setRenderedView(view);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!view) {
|
||||
startExit(renderedView.key, null);
|
||||
return;
|
||||
}
|
||||
if (view.key !== renderedView.key) {
|
||||
startExit(renderedView.key, view);
|
||||
return;
|
||||
}
|
||||
}, [exitingKey, renderedView, startExit, view]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!dismissAfterVisibleMs || !viewKey) {
|
||||
return;
|
||||
}
|
||||
if (exitingKey === viewKey) {
|
||||
return;
|
||||
}
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
startExit(viewKey, null, viewKey);
|
||||
}, dismissAfterVisibleMs);
|
||||
|
||||
return () => window.clearTimeout(timeoutId);
|
||||
}, [dismissAfterVisibleMs, exitingKey, startExit, viewKey]);
|
||||
useProviderUpdatePillAutoDismiss({ displayedView, exitingKey, startExit });
|
||||
|
||||
if (!displayedView) {
|
||||
return null;
|
||||
@@ -138,13 +144,10 @@ export function SidebarProviderUpdatePill() {
|
||||
if (!displayedView || exitingKey !== displayedView.key) {
|
||||
return;
|
||||
}
|
||||
if (dismissAfterExitKey === displayedView.key) {
|
||||
if (exitState?.dismissAfterExitKey === displayedView.key) {
|
||||
setDismissedKeys((previous) => new Set(previous).add(displayedView.key));
|
||||
}
|
||||
setRenderedView(pendingView);
|
||||
setPendingView(null);
|
||||
setExitingKey(null);
|
||||
setDismissAfterExitKey(null);
|
||||
setExitState(null);
|
||||
}}
|
||||
>
|
||||
{showDismissProgress ? (
|
||||
@@ -169,7 +172,7 @@ export function SidebarProviderUpdatePill() {
|
||||
type="button"
|
||||
aria-label={displayedView.description}
|
||||
className="provider-update-main relative z-[1] flex h-full flex-1 items-center gap-2 px-2 text-left"
|
||||
onClick={openProviderSettings}
|
||||
onClick={onOpenProviderSettings}
|
||||
>
|
||||
{displayedView.tone === "loading" ? (
|
||||
<LoaderIcon className="size-3.5 animate-spin" />
|
||||
@@ -194,7 +197,7 @@ export function SidebarProviderUpdatePill() {
|
||||
type="button"
|
||||
aria-label="Dismiss provider update notice"
|
||||
className="relative z-[1] mr-1 inline-flex size-5 items-center justify-center rounded-md opacity-70 transition-opacity hover:opacity-100"
|
||||
onClick={() => startExit(displayedView.key, null, displayedView.key)}
|
||||
onClick={() => startExit(displayedView, displayedView.key)}
|
||||
>
|
||||
<XIcon className="size-3.5" />
|
||||
</button>
|
||||
|
||||
@@ -88,14 +88,14 @@ describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
|
||||
});
|
||||
|
||||
describe("ServerSettings worktree defaults", () => {
|
||||
it("defaults start-from-origin on for legacy configs", () => {
|
||||
expect(decodeServerSettings({}).newWorktreesStartFromOrigin).toBe(true);
|
||||
it("defaults start-from-origin off for legacy configs", () => {
|
||||
expect(decodeServerSettings({}).newWorktreesStartFromOrigin).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts start-from-origin updates", () => {
|
||||
expect(
|
||||
decodeServerSettingsPatch({ newWorktreesStartFromOrigin: false }).newWorktreesStartFromOrigin,
|
||||
).toBe(false);
|
||||
decodeServerSettingsPatch({ newWorktreesStartFromOrigin: true }).newWorktreesStartFromOrigin,
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ export const ServerSettings = Schema.Struct({
|
||||
Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
|
||||
),
|
||||
newWorktreesStartFromOrigin: Schema.Boolean.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||
Schema.withDecodingDefault(Effect.succeed(false)),
|
||||
),
|
||||
addProjectBaseDirectory: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
||||
textGenerationModelSelection: ModelSelection.pipe(
|
||||
|
||||
Reference in new issue
Block a user