diff --git a/apps/server/src/orchestration-v2/ThreadSearch.test.ts b/apps/server/src/orchestration-v2/ThreadSearch.test.ts
index a99e8cda72..a24674f681 100644
--- a/apps/server/src/orchestration-v2/ThreadSearch.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadSearch.test.ts
@@ -1504,6 +1504,7 @@ it.effect("starts snippets a few words before the match so one line shows it", (
snippet(`x${"๐".repeat(200)}needle`, "needle"),
/[\ud800-\udbff](?![\udc00-\udfff])|(?
+ Effect.scoped(
+ Effect.gen(function* () {
+ const cwd = yield* makeTmpDir();
+ yield* initRepoWithCommit(cwd);
+ const remote = yield* makeTmpDir("git-remote-");
+ yield* git(remote, ["init", "--bare"]);
+ yield* git(cwd, ["branch", "-M", "trunk"]);
+ yield* git(cwd, ["remote", "add", "upstream", remote]);
+ yield* git(cwd, ["push", "upstream", "trunk"]);
+ yield* git(cwd, [
+ "symbolic-ref",
+ "refs/remotes/upstream/HEAD",
+ "refs/remotes/upstream/trunk",
+ ]);
+ yield* git(cwd, ["checkout", "-b", "other"]);
+ // "other" sorts ahead of "trunk" by name when their commit times tie.
+ yield* git(cwd, ["commit", "--allow-empty", "-m", "newer"]);
+ yield* git(cwd, ["checkout", "-b", "feature", "trunk"]);
+ const driver = yield* GitVcsDriver.GitVcsDriver;
+
+ const status = yield* driver.statusDetailsLocal(cwd);
+ yield* git(cwd, ["checkout", "trunk"]);
+ assert.isTrue((yield* driver.statusDetailsLocal(cwd)).isDefaultBranch);
+ yield* git(cwd, ["checkout", "feature"]);
+ assert.isFalse(status.isDefaultBranch);
+
+ const refs = (yield* driver.listRefs({ cwd, refresh: true, includeMatchingRemoteRefs: true }))
+ .refs;
+ assert.isTrue(refs.find((ref) => ref.name === "trunk")?.isDefault);
+ assert.isTrue(refs.find((ref) => ref.name === "upstream/trunk")?.isDefault);
+ const names = refs.map((ref) => ref.name);
+ assert.isBelow(names.indexOf("trunk"), names.indexOf("other"));
+ }),
+ ).pipe(Effect.provide(layerTest)),
+);
+
it.effect.each(["branch", "detached", "nested", "aliased-root", "aliased-nested"] as const)(
"discovers only the common directory during worktree creation from %s",
(location) =>
diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts
index e98e1322c5..b83a808305 100644
--- a/apps/server/src/vcs/GitVcsDriverCore.ts
+++ b/apps/server/src/vcs/GitVcsDriverCore.ts
@@ -5679,6 +5679,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
{ concurrency: 2 },
);
+ const remoteNamesInGitOrder =
+ remoteNamesResult.exitCode === 0 ? parseRemoteNamesInGitOrder(remoteNamesResult.stdout) : [];
const remoteNames =
remoteNamesResult.exitCode === 0 ? parseRemoteNames(remoteNamesResult.stdout) : [];
if (remoteNamesResult.exitCode !== 0 && remoteNamesResult.stderr.trim().length > 0) {
@@ -5686,10 +5688,23 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
`GitVcsDriver.listRefs: remote name lookup returned code ${remoteNamesResult.exitCode} for ${gitCommonDir}: ${remoteNamesResult.stderr.trim()}. Falling back to an empty remote name list.`,
);
}
- const defaultBranch =
+ const originDefaultBranch =
defaultRefResult.exitCode === 0
? parseDefaultBranchFromRemoteHeadRef(defaultRefResult.stdout, "origin")
: null;
+ // Same fallback as resolvePrimaryDefaultBranchName: without an origin, the first remote is primary.
+ const [firstRemoteName] = remoteNamesInGitOrder;
+ const fallbackRemoteName =
+ originDefaultBranch === null &&
+ firstRemoteName !== undefined &&
+ !remoteNamesInGitOrder.includes("origin")
+ ? firstRemoteName
+ : null;
+ const defaultBranch =
+ fallbackRemoteName === null
+ ? originDefaultBranch
+ : yield* resolveDefaultBranchName(fetchCwd, fallbackRemoteName, gitDirArgs);
+ const defaultRemoteName = fallbackRemoteName ?? "origin";
const localBranches: Array<{ readonly ref: VcsRef; readonly lastCommit: number }> = [];
const remoteBranches: Array<{ readonly ref: VcsRef; readonly lastCommit: number }> = [];
@@ -5725,7 +5740,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
isRemote: true,
isDefault:
defaultBranch !== null &&
- parsedRemoteRef?.remoteName === "origin" &&
+ parsedRemoteRef?.remoteName === defaultRemoteName &&
parsedRemoteRef.branchName === defaultBranch,
worktreePath: null,
...(parsedRemoteRef ? { remoteName: parsedRemoteRef.remoteName } : {}),
diff --git a/apps/web/src/components/chat/BackgroundWorkDetails.tsx b/apps/web/src/components/chat/BackgroundWorkDetails.tsx
index b96f7c5b58..d7412dabdf 100644
--- a/apps/web/src/components/chat/BackgroundWorkDetails.tsx
+++ b/apps/web/src/components/chat/BackgroundWorkDetails.tsx
@@ -11,7 +11,7 @@ import {
import { T, useGT } from "gt-react";
import { useState } from "react";
-import { InlineButton } from "../ui/button";
+import { Button, InlineButton } from "../ui/button";
import {
Dialog,
DialogHeader,
@@ -98,14 +98,16 @@ export function BackgroundWorkDetails(props: {
) : null}
{childThreadId ? (
- {
setOpen(false);
props.onOpenThread(childThreadId);
}}
>
Open subagent
-
+
) : null}
);
diff --git a/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx b/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
index 36696e1c20..80c546f4c2 100644
--- a/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
+++ b/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
@@ -2,7 +2,8 @@ import { EnvironmentId, ProviderDriverKind, type AcpRegistrySearchAgent } from "
import { expect, it, vi } from "vite-plus/test";
import { page, userEvent } from "vite-plus/test/browser";
-import { render } from "../../../test/render";
+import { act, render } from "../../../test/render";
+import { Dialog, DialogPopup } from "../ui/dialog";
const state = vi.hoisted(() => ({
result: null as { readonly agents: ReadonlyArray } | null,
@@ -142,3 +143,51 @@ it("leaves out Registry agents that Onicode supports as their own providers", as
expect(page.getByRole("button", { name: "Add Gemini CLI" }).query()).not.toBeNull();
expect(page.getByRole("button", { name: "Add Codex" }).query()).toBeNull();
});
+
+it("Escape in the search clears it without closing Add provider", async () => {
+ setup();
+ const onOpenChange = vi.fn();
+ await using _screen = await render(
+ ,
+ );
+ const search = page.getByRole("searchbox", { name: "Search ACP Registry" });
+ await userEvent.fill(search, "gemini");
+ for (const composition of [
+ { key: "Escape", isComposing: true, keyCode: 27 },
+ { key: "Escape", isComposing: false, keyCode: 229 },
+ ]) {
+ // Safari ends the composition just before the Escape keydown.
+ await act(() => {
+ search.element().dispatchEvent(new CompositionEvent("compositionend", { bubbles: true }));
+ search
+ .element()
+ .dispatchEvent(
+ new KeyboardEvent("keydown", { ...composition, bubbles: true, cancelable: true }),
+ );
+ });
+ await expect.element(search).toHaveValue("gemini");
+ }
+
+ await userEvent.keyboard("{Escape}");
+ await expect.element(search).toHaveValue("");
+ await expect.element(search).toHaveFocus();
+ // Holding Escape repeats the keydown, which must not also close the dialog.
+ await act(() => {
+ search.element().dispatchEvent(
+ new KeyboardEvent("keydown", {
+ key: "Escape",
+ repeat: true,
+ bubbles: true,
+ cancelable: true,
+ }),
+ );
+ });
+ expect(onOpenChange).not.toHaveBeenCalled();
+
+ await userEvent.keyboard("{Escape}");
+ expect(onOpenChange.mock.calls.map(([open]) => open)).toEqual([false]);
+});
diff --git a/apps/web/src/components/settings/AcpRegistrySearchStep.tsx b/apps/web/src/components/settings/AcpRegistrySearchStep.tsx
index aae3d963a4..63f6c6800b 100644
--- a/apps/web/src/components/settings/AcpRegistrySearchStep.tsx
+++ b/apps/web/src/components/settings/AcpRegistrySearchStep.tsx
@@ -183,6 +183,7 @@ export function AcpRegistrySearchStep({
aria-label={gt("Search ACP Registry")}
maxLength={ACP_REGISTRY_SEARCH_QUERY_MAX_LENGTH}
disabled={preparingId !== null}
+ enterKeyHint="search"
onChange={(event) => registry.type(event.currentTarget.value)}
onKeyDown={(event) => clearSearchOnEscape(event, query, () => registry.type(""))}
placeholder={gt("Search agentsโฆ")}
diff --git a/packages/client-runtime/src/pullRequestMarkdown.test.ts b/packages/client-runtime/src/pullRequestMarkdown.test.ts
index 52eab97fff..05bd44d57e 100644
--- a/packages/client-runtime/src/pullRequestMarkdown.test.ts
+++ b/packages/client-runtime/src/pullRequestMarkdown.test.ts
@@ -147,6 +147,11 @@ describe("pull request body segmentation", () => {
expect(split(body)).toEqual([
{ id: "markdown:0", kind: "markdown", text: body, sourceOffset: 0 },
]);
+ const captioned = ' Before the fix\n\nIt opens.';
+ expect(split(`${captioned}\n\n`)).toEqual([
+ { id: "markdown:0", kind: "markdown", text: captioned, sourceOffset: 0 },
+ { id: "attachment:1", kind: "attachment", url: "https://example.com/b.mp4", media: "video" },
+ ]);
});
it("treats an info-string fence as a nested opener, not a close", () => {
diff --git a/packages/client-runtime/src/pullRequestMarkdown.ts b/packages/client-runtime/src/pullRequestMarkdown.ts
index 6e3b6d87a2..993eaf283e 100644
--- a/packages/client-runtime/src/pullRequestMarkdown.ts
+++ b/packages/client-runtime/src/pullRequestMarkdown.ts
@@ -51,6 +51,7 @@ const VIDEO_TAG_SRC_PATTERN = /<(?:video|source)\b[^<>]*\bsrc\s*=\s*["']([^"']+)
const STANDALONE_VIDEO_TAG_PATTERN = /^\s*