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
1 change: 1 addition & 0 deletions apps/server/src/orchestration-v2/ThreadSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])|(?<![\ud800-\udbff])[\udc00-\udfff]/,
);
assert.equal(snippet(`needle${" ".repeat(473)}🚀 tail`, "needle"), "needle 🚀…");
// Emphasis and code marks go, as the thread shows the text.
assert.equal(
ThreadSearch.buildSearchSnippet("Use **bold** and `code` here", 0),
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/orchestration-v2/ThreadSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ export function buildSearchSnippet(text: string, matchStart: number): string {
// Cut between characters, not inside an emoji's surrogate pair.
if (isLowSurrogate(text.charCodeAt(start))) start++;
// Collapsing whitespace shortens the text, so read more of it.
const rawEnd = Math.min(text.length, start + SNIPPET_LENGTH * 2);
let rawEnd = Math.min(text.length, start + SNIPPET_LENGTH * 2);
if (isLowSurrogate(text.charCodeAt(rawEnd))) rawEnd++;
// Emphasis and code marks do not show in a thread either.
const shown = text
.slice(start, rawEnd)
Expand Down
37 changes: 37 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,43 @@ it.effect.each([
).pipe(Effect.provide(layerTest)),
);

it.effect("marks the default branch of a primary remote that is not named origin", () =>
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) =>
Expand Down
19 changes: 17 additions & 2 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5679,17 +5679,32 @@ 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) {
yield* Effect.logWarning(
`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 }> = [];

Expand Down Expand Up @@ -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 } : {}),
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/components/chat/BackgroundWorkDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -98,14 +98,16 @@ export function BackgroundWorkDetails(props: {
</div>
) : null}
{childThreadId ? (
<InlineButton
<Button
size="sm"
variant="outline"
onClick={() => {
setOpen(false);
props.onOpenThread(childThreadId);
}}
>
<T>Open subagent</T>
</InlineButton>
</Button>
) : null}
</section>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AcpRegistrySearchAgent> } | null,
Expand Down Expand Up @@ -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(
<Dialog open onOpenChange={onOpenChange}>
<DialogPopup>
<Step />
</DialogPopup>
</Dialog>,
);
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]);
});
1 change: 1 addition & 0 deletions apps/web/src/components/settings/AcpRegistrySearchStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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…")}
Expand Down
5 changes: 5 additions & 0 deletions packages/client-runtime/src/pullRequestMarkdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ describe("pull request body segmentation", () => {
expect(split(body)).toEqual([
{ id: "markdown:0", kind: "markdown", text: body, sourceOffset: 0 },
]);
const captioned = '<video src="https://example.com/a.mp4"></video> Before the fix\n\nIt opens.';
expect(split(`${captioned}\n\n<video src="https://example.com/b.mp4"></video>`)).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", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/client-runtime/src/pullRequestMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const VIDEO_TAG_SRC_PATTERN = /<(?:video|source)\b[^<>]*\bsrc\s*=\s*["']([^"']+)

const STANDALONE_VIDEO_TAG_PATTERN = /^\s*<video\b/iu;
const VIDEO_TAG_END_PATTERN = /<\/video>\s*$/iu;
const VIDEO_TAG_CLOSE_PATTERN = /<\/video>/iu;

/** Bounded like `VIDEO_TAG_MAX_LINES`; room for a before/after table with several rows. */
const TABLE_MAX_LINES = 64;
Expand Down Expand Up @@ -327,7 +328,7 @@ function splitBodyAt(body: string, baseOffset: number): ReadonlyArray<PullReques
}
const lastCandidate = Math.min(index + VIDEO_TAG_MAX_LINES, lines.length) - 1;
let cursor = index;
while (cursor < lastCandidate && !VIDEO_TAG_END_PATTERN.test(lines[cursor]!)) {
while (cursor < lastCandidate && !VIDEO_TAG_CLOSE_PATTERN.test(lines[cursor]!)) {
cursor += 1;
}
const source = VIDEO_TAG_END_PATTERN.test(lines[cursor]!)
Expand Down
5 changes: 5 additions & 0 deletions scripts/upstream-sync.ledger.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3735,3 +3735,8 @@ fc92aefd26 take adopted upstream's acquireUseRelease over Onicode's onError + ti
4f1dc5db12 take taken as is
26c21a86cf take taken as is
94190c63f9 take taken as is
0c13b2b8fc take kept Onicode's clearSearchOnEscape over upstream's inline handler: one helper with the same guards serves every Settings search; took the browser test and enterKeyHint
20b97f2cc3 take taken as is
a7a6126a7d take taken as is
e5dfa6ee0c take taken as is
7c42bb1c5c take taken as is