mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-02 08:33:16 +00:00
* fix: make plan view mobile friendly (#1636) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit7ee3e05724) * fix: return to thread after plan approval (#1637) Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commitf32e492ab4) * feat: reviews block agenda, sticky headers, accurate diff scroll (#1653) Rework the AI-sorted blocks experience on the PR reviews page into a Google-Docs-style outline: the left sidebar is now a clean number+title agenda with scroll-spy highlighting of the active block; each block shows its title + description (sticky) above its diff; and diff rows are pinned to a uniform height so scroll-to lands precisely via the virtualizer's own geometry instead of an estimate-driven correction loop. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 0b76afdc955e33805c7623d1502a75a9c7c9c1b7) * fix: jump + ResizeObserver settle for review scroll-to (#1655) Replace smooth-scroll plus frame-count correction loops on the PR reviews page with an instant jump that re-asserts its target via a ResizeObserver (the real "layout settled" signal). Block/file navigation and finding/comment centering now land deterministically as off-screen cards mount, files expand, and annotation cards measure, instead of racing a smooth-scroll animation against height reconciliation. Holds bail on user wheel/touch input and after a short ceiling, and a new navigation cancels the previous hold. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Johannes du Plessis <johannes@langchain.dev> (cherry picked from commit 7530653bba7774d66a54b8bef0d2bbc25f519942) * fix: purge expired thread_wakeup crons (#1656) * fix: purge expired thread_wakeup crons One-shot wakeup crons set an end_time that stops re-firing but the cron row is never deleted, so dead rows accumulate (86 in prod). Add a purge that deletes thread_wakeup crons past their end_time, called opportunistically before scheduling a new wakeup, plus a one-time backfill script. Conservative: matches only kind=thread_wakeup with a past end_time. * chore: retrigger Open SWE review --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 9e5a1924ef306269322c31342a1831e57831cfee) * fix: add top padding to sticky review block header (#1660) * fix: add top padding to sticky review block header The sticky per-block header on the reviews page had padding below but none above, so the block number badge sat glued against the top edge when pinned. Add matching top padding for breathing room. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * chore: use py-2 shorthand for review block header padding Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 23bd4a63fc5ba0fe853babf79ed33feb866cc8b2) * fix: use global tokens for sidebar filter popover border (#1661) The filter popover renders via base-ui Menu.Portal into document.body, outside the .agents-ui container where the --ui-* CSS variables are scoped. As a result border-[var(--ui-border)] resolved to an undefined variable and border-color fell back to currentColor, producing a strong near-black border (separators/hover/labels were similarly off). Switch the portaled popup styling to the same global shadcn tokens the theme/settings popover (SidebarUserMenu) already uses (border-border, bg-border, bg-muted, text-muted-foreground). These are defined at :root so they resolve inside portals too, and match the settings popover. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 63eb9a08209f683016abf01cdcc548bc5905f158) * fix: preserve dashboard redirect after login (#1668) * fix: preserve dashboard redirect after login Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * test: cover plan login redirect in e2e Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit bc7ce59169b5350da7286164afb83a7b037b528d) * Disable React StrictMode (#1654) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 6575c327a3ac2b107a6e79a04fa61168d779dbf0) * docs(upstream-sync): add cherry-pick runbook Repo-specific runbook for bringing upstream (langchain-ai/open-swe) commits into the fork: triage-sync discovery, the git cp workflow, the triage ledger, themed-branch layout, and conflict/regression handling. --------- Co-authored-by: Johannes du Plessis <johannes@langchain.dev> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Ramon Nogueira <ramon.nogueira@langchain.dev> Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: Caroline di Vittorio <43390382+carolinedivittorio@users.noreply.github.com>
204 lines
8.2 KiB
TypeScript
204 lines
8.2 KiB
TypeScript
import {
|
|
test,
|
|
expect,
|
|
type APIRequestContext,
|
|
type Page,
|
|
} from "@playwright/test";
|
|
|
|
// Full plan-review flow, driven through the mock Slack UI + the real dashboard:
|
|
// user asks Open SWE in Slack to PLAN something ->
|
|
// agent calls enter_plan_mode, posts the plan-review link to Slack, writes the
|
|
// plan as a markdown file (save_plan), and posts "ready" back to Slack ->
|
|
// owner (user1) and a collaborator (user2) open the plan and leave whole-document
|
|
// comments over plain HTTP (each polls and sees the other's) ->
|
|
// only the owner can approve -> on approval the agent implements, opens a PR,
|
|
// and replies in Slack with the link, echoing the reviewers' comments (which the
|
|
// server harvested from the comment store).
|
|
// Only the LLM is faked; all agent + dashboard code runs for real.
|
|
|
|
const OWNER = { login: "alice", email: "alice@example.com" };
|
|
const COLLABORATOR = { login: "bob", email: "bob@example.com" };
|
|
|
|
async function botMessages(request: APIRequestContext): Promise<Array<string>> {
|
|
const res = await request.get("/mock/slack/messages");
|
|
const msgs = (await res.json()) as Array<{ text: string; is_bot: boolean }>;
|
|
return msgs.filter((m) => m.is_bot).map((m) => m.text);
|
|
}
|
|
|
|
async function addComment(page: Page, text: string) {
|
|
await page.getByTestId("comment-input").fill(text);
|
|
await page.getByTestId("comment-submit").click();
|
|
}
|
|
|
|
test.describe("Plan review (HTTP comments)", () => {
|
|
test("Slack plan request → comments → owner approves → PR", async ({
|
|
browser,
|
|
request,
|
|
}) => {
|
|
// 1. A user asks the bot to PLAN something in Slack.
|
|
await request.post("/control/reset");
|
|
const send = await request.post("/mock/slack/send", {
|
|
data: {
|
|
text: "<@U0BOT> plan how to add a greet() helper",
|
|
mention_bot: true,
|
|
},
|
|
});
|
|
const { thread_id: threadId } = (await send.json()) as {
|
|
thread_id: string;
|
|
};
|
|
expect(threadId).toBeTruthy();
|
|
const planPath = `/agents/${threadId}/plan`;
|
|
|
|
// 1a. enter_plan_mode must actually engage, not error out. Its Command must
|
|
// carry a terminating ToolMessage; without it the tool call fails and is
|
|
// swallowed into an error tool message while the agent silently proceeds
|
|
// as a normal run. Assert the tool's success message landed in the thread.
|
|
await expect
|
|
.poll(
|
|
async () => {
|
|
const res = await request.get(`/threads/${threadId}/state`);
|
|
const state = (await res.json()) as {
|
|
values?: { messages?: Array<{ content?: unknown }> };
|
|
};
|
|
return (state.values?.messages ?? [])
|
|
.map((m) =>
|
|
typeof m.content === "string"
|
|
? m.content
|
|
: JSON.stringify(m.content),
|
|
)
|
|
.some((c) => c.includes("Plan mode is active"));
|
|
},
|
|
{ timeout: 60_000 },
|
|
)
|
|
.toBe(true);
|
|
|
|
// 2. The agent shares the plan-review link, then announces the plan is ready.
|
|
await expect
|
|
.poll(async () => (await botMessages(request)).join("\n"), {
|
|
timeout: 60_000,
|
|
})
|
|
.toMatch(/\/agents\/[^/]+\/plan\b/);
|
|
await expect
|
|
.poll(async () => (await botMessages(request)).join("\n"), {
|
|
timeout: 60_000,
|
|
})
|
|
.toMatch(/ready for review/i);
|
|
|
|
// 3. A logged-out user follows the plan deep link, signs in through the fake
|
|
// GitHub OAuth simulator, and lands back on the same plan page.
|
|
const loggedOutCtx = await browser.newContext();
|
|
const loggedOut = await loggedOutCtx.newPage();
|
|
await loggedOut.goto(planPath);
|
|
await expect(loggedOut).toHaveURL(
|
|
new RegExp(`/login\\?redirect=.*${threadId}.*plan`),
|
|
);
|
|
await expect(loggedOut.getByText("Sign in to open-swe")).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await loggedOut.getByRole("link", { name: "Continue with GitHub" }).click();
|
|
await expect(loggedOut).toHaveURL(/\/fake-gh\/login\/oauth\/authorize/);
|
|
await expect(loggedOut.getByTestId("fake-github-login")).toBeVisible();
|
|
await loggedOut.getByLabel("GitHub user").selectOption(OWNER.login);
|
|
await loggedOut.getByRole("button", { name: "Authorize open-swe" }).click();
|
|
await expect(loggedOut).toHaveURL(new RegExp(`/agents/${threadId}/plan$`));
|
|
await expect(loggedOut.getByTestId("plan-review")).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await expect(loggedOut.getByTestId("plan-document")).toContainText(
|
|
"greet",
|
|
{
|
|
timeout: 30_000,
|
|
},
|
|
);
|
|
await loggedOutCtx.close();
|
|
|
|
// 4. The OWNER opens the conversation, follows the "Review plan" banner, and
|
|
// sees the rendered plan.
|
|
const ownerCtx = await browser.newContext({
|
|
permissions: ["clipboard-read", "clipboard-write"],
|
|
});
|
|
await ownerCtx.request.post("/control/login", { data: OWNER });
|
|
const owner = await ownerCtx.newPage();
|
|
await owner.goto(`/agents/${threadId}`);
|
|
const reviewLink = owner.getByTestId("review-plan-link");
|
|
await expect(reviewLink).toBeVisible({ timeout: 30_000 });
|
|
await reviewLink.click();
|
|
await expect(owner).toHaveURL(new RegExp(`/agents/${threadId}/plan$`));
|
|
await expect(owner.getByTestId("plan-review")).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await expect(owner.getByText("Back to conversation")).toBeVisible();
|
|
await expect(owner.getByTestId("plan-document")).toContainText("greet", {
|
|
timeout: 30_000,
|
|
});
|
|
await expect(owner.getByTestId("approve-plan")).toBeVisible();
|
|
// "Request changes" is meaningless with no feedback → disabled until a
|
|
// comment exists.
|
|
await expect(owner.getByTestId("reject-plan")).toBeDisabled();
|
|
|
|
// Copy the whole plan as markdown.
|
|
await owner.getByTestId("copy-plan").click();
|
|
await expect(owner.getByTestId("copy-plan")).toContainText("Copied!");
|
|
const clipboard = await owner.evaluate(() =>
|
|
navigator.clipboard.readText(),
|
|
);
|
|
expect(clipboard).toContain("## Plan: Add greet() helper");
|
|
expect(clipboard).toContain("### Verification");
|
|
|
|
// Owner leaves a comment.
|
|
await addComment(owner, "Owner: looks solid, ship it.");
|
|
await expect(owner.getByTestId("plan-comment")).toHaveCount(1);
|
|
await expect(owner.getByTestId("reject-plan")).toBeEnabled();
|
|
|
|
// 5. A COLLABORATOR opens the same plan: sees it AND the owner's comment
|
|
// (fetched over HTTP), but has NO approve button.
|
|
const collabCtx = await browser.newContext();
|
|
await collabCtx.request.post("/control/login", { data: COLLABORATOR });
|
|
const collab = await collabCtx.newPage();
|
|
await collab.goto(planPath);
|
|
await expect(collab.getByTestId("plan-review")).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await expect(collab.getByTestId("plan-document")).toContainText("greet", {
|
|
timeout: 30_000,
|
|
});
|
|
await expect(collab.getByTestId("plan-comment")).toHaveCount(1, {
|
|
timeout: 30_000,
|
|
});
|
|
await expect(collab.getByTestId("plan-comment")).toContainText(
|
|
"looks solid",
|
|
);
|
|
await expect(collab.getByTestId("approve-plan")).toHaveCount(0);
|
|
await expect(collab.getByTestId("reject-plan")).toBeVisible();
|
|
|
|
// Collaborator leaves feedback.
|
|
await addComment(collab, "Reviewer: please also add a docstring.");
|
|
await expect(collab.getByTestId("plan-comment")).toHaveCount(2);
|
|
|
|
// 6. The owner sees the collaborator's comment (polled), then approves and
|
|
// returns to the main conversation while implementation starts.
|
|
await expect(owner.getByTestId("plan-comment")).toHaveCount(2, {
|
|
timeout: 30_000,
|
|
});
|
|
await owner.getByTestId("approve-plan").click();
|
|
await expect(owner).toHaveURL(new RegExp(`/agents/${threadId}$`));
|
|
|
|
// 7. The agent implements, opens a PR, and links it back in the Slack thread,
|
|
// echoing the reviewers' feedback — which proves the comments were stored
|
|
// and harvested server-side on approve.
|
|
await expect
|
|
.poll(async () => (await botMessages(request)).join("\n"), {
|
|
timeout: 90_000,
|
|
})
|
|
.toMatch(/\/pull\//);
|
|
expect((await botMessages(request)).join("\n")).toMatch(/docstring/);
|
|
|
|
const prs = (await (
|
|
await request.get("/mock/github/data")
|
|
).json()) as Array<unknown>;
|
|
expect(prs.length).toBeGreaterThan(0);
|
|
|
|
await ownerCtx.close();
|
|
await collabCtx.close();
|
|
});
|
|
});
|