mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-23 18:55:37 -04:00
9e0d3976e1
Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: starptech <starptech@starptechs-MBP.fritz.box> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <little-frank@opencord.local> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: runvip <164729189+runvip@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Julian Coy <julian@ex-machina.co> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Jay <air@live.ca> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com>
114 lines
3.6 KiB
TypeScript
114 lines
3.6 KiB
TypeScript
import { expect, test } from "@playwright/test"
|
|
import {
|
|
defineVisualRegions,
|
|
reportVisualStability,
|
|
startVisualProbe,
|
|
stopVisualProbe,
|
|
visualPlan,
|
|
} from "../../utils/visual-stability"
|
|
import {
|
|
assistantMessage,
|
|
partUpdated,
|
|
setupTimeline,
|
|
textPart,
|
|
toolPart,
|
|
userMessage,
|
|
waitForVisualSettle,
|
|
} from "./fixture"
|
|
|
|
test("adds patch files incrementally without resetting outer expansion", async ({ page }, testInfo) => {
|
|
const patchID = "prt_incremental_01_patch"
|
|
const followingID = "prt_incremental_02_following"
|
|
const first = patchFile("src/a.ts", "update")
|
|
const timeline = await setupTimeline(page, {
|
|
messages: [
|
|
userMessage(),
|
|
assistantMessage(
|
|
[
|
|
toolPart(patchID, "apply_patch", "running", { files: [first.filePath] }, { metadata: { files: [first] } }),
|
|
textPart(followingID, "Following incremental patch"),
|
|
],
|
|
{ completed: false },
|
|
),
|
|
],
|
|
settings: { editToolPartsExpanded: true },
|
|
cpuRate: 4,
|
|
seedHistory: true,
|
|
})
|
|
const trigger = page.locator(`[data-timeline-part-id="${patchID}"] [data-slot="collapsible-trigger"]`).first()
|
|
await expect(trigger).toHaveAttribute("aria-expanded", "true")
|
|
await waitForVisualSettle(page, [`[data-timeline-part-id="${patchID}"]`, `[data-timeline-part-id="${followingID}"]`])
|
|
const regions = defineVisualRegions({
|
|
patch: { selector: `[data-timeline-part-id="${patchID}"]`, closest: '[data-timeline-row="AssistantPart"]' },
|
|
following: { selector: `[data-timeline-part-id="${followingID}"]`, closest: '[data-timeline-row="AssistantPart"]' },
|
|
})
|
|
await startVisualProbe(page, regions)
|
|
const second = patchFile("src/b.ts", "add")
|
|
const third = patchFile("src/old.ts", "delete")
|
|
await timeline.send(
|
|
partUpdated(
|
|
toolPart(
|
|
patchID,
|
|
"apply_patch",
|
|
"running",
|
|
{ files: [first.filePath, second.filePath] },
|
|
{ metadata: { files: [first, second] } },
|
|
),
|
|
),
|
|
240,
|
|
)
|
|
await timeline.send(
|
|
partUpdated(
|
|
toolPart(
|
|
patchID,
|
|
"apply_patch",
|
|
"completed",
|
|
{ files: [first.filePath, second.filePath, third.filePath] },
|
|
{ metadata: { files: [first, second, third] } },
|
|
),
|
|
),
|
|
800,
|
|
)
|
|
const trace = await stopVisualProbe<keyof typeof regions>(page)
|
|
await reportVisualStability(
|
|
testInfo,
|
|
"incremental-patch",
|
|
trace,
|
|
visualPlan(
|
|
regions,
|
|
[
|
|
{ type: "required", regions: ["patch", "following"] },
|
|
{ type: "unique", regions: ["patch", "following"] },
|
|
{ type: "stable", regions: ["patch", "following"] },
|
|
{ type: "opacity", regions: "all" },
|
|
{ type: "continuity", regions: "all" },
|
|
{ type: "motion", regions: ["following"], maxPositionReversals: 0 },
|
|
{ type: "label-stability", regions: "all" },
|
|
{ type: "preserve-bottom-anchor" },
|
|
{ type: "flow", regions: ["patch", "following"] },
|
|
],
|
|
{ perMarker: true },
|
|
),
|
|
)
|
|
await expect(trigger).toHaveAttribute("aria-expanded", "true")
|
|
await expect(page.locator('[data-scope="apply-patch"] [data-type="delete"]')).toBeVisible()
|
|
})
|
|
|
|
function patchFile(filePath: string, type: "add" | "update" | "delete") {
|
|
return {
|
|
filePath,
|
|
relativePath: filePath,
|
|
type,
|
|
additions: type === "delete" ? 0 : 4,
|
|
deletions: type === "add" ? 0 : 3,
|
|
before: type === "add" ? undefined : source(false),
|
|
after: type === "delete" ? undefined : source(true),
|
|
}
|
|
}
|
|
|
|
function source(changed: boolean) {
|
|
return Array.from({ length: 12 }, (_, index) => `export const value${index} = ${changed ? index + 1 : index}\n`).join(
|
|
"",
|
|
)
|
|
}
|