mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-24 04:01:10 -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>
95 lines
4.1 KiB
TypeScript
95 lines
4.1 KiB
TypeScript
import { expect, test } from "@playwright/test"
|
|
import {
|
|
assistantMessage,
|
|
completedAssistantInfo,
|
|
messageUpdated,
|
|
partUpdated,
|
|
reasoningPart,
|
|
setupTimeline,
|
|
shell,
|
|
status,
|
|
textPart,
|
|
userMessage,
|
|
} from "../performance/timeline-stability/fixture"
|
|
|
|
for (const expanded of [false, true]) {
|
|
test(`preserves shell user intent from a ${expanded ? "expanded" : "collapsed"} default`, async ({ page }) => {
|
|
const id = `prt_shell_default_${expanded}`
|
|
const timeline = await setupTimeline(page, {
|
|
messages: [userMessage(), assistantMessage([shell(id, "completed", lines(3))])],
|
|
settings: { shellToolPartsExpanded: expanded },
|
|
})
|
|
const trigger = page.locator(`[data-timeline-part-id="${id}"] [data-slot="collapsible-trigger"]`)
|
|
await expect(trigger).toHaveAttribute("aria-expanded", String(expanded))
|
|
await trigger.click()
|
|
await expect(trigger).toHaveAttribute("aria-expanded", String(!expanded))
|
|
|
|
await timeline.send(partUpdated(shell(id, "completed", lines(6))), 180)
|
|
await timeline.send(partUpdated(textPart(`prt_sibling_${expanded}`, "Sibling content")), 180)
|
|
await timeline.send(status("busy"), 100)
|
|
await timeline.send(status("idle"), 250)
|
|
await expect(trigger).toHaveAttribute("aria-expanded", String(!expanded))
|
|
})
|
|
}
|
|
|
|
test("transitions thinking and hidden reasoning through busy to idle", async ({ page }) => {
|
|
const reasoningID = "prt_reasoning_hidden"
|
|
const assistant = assistantMessage([reasoningPart(reasoningID, "## Inspecting stability")], { completed: false })
|
|
const timeline = await setupTimeline(page, {
|
|
messages: [userMessage(), assistant],
|
|
settings: { showReasoningSummaries: false },
|
|
cpuRate: 4,
|
|
})
|
|
await timeline.send(status("busy"), 150)
|
|
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toBeVisible()
|
|
await expect(page.getByText("Inspecting stability", { exact: true })).toBeVisible()
|
|
await expect(page.locator(`[data-timeline-part-id="${reasoningID}"]`)).toHaveCount(0)
|
|
await timeline.send(partUpdated(shell("prt_reasoning_shell", "running")), 160)
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toBeVisible()
|
|
await timeline.send(partUpdated(shell("prt_reasoning_shell", "completed", "done")), 180)
|
|
await timeline.send(messageUpdated(completedAssistantInfo(assistant.info)), 100)
|
|
await timeline.send(status("idle"), 300)
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
|
|
await expect(page.locator(`[data-timeline-part-id="${reasoningID}"]`)).toHaveCount(0)
|
|
})
|
|
|
|
test("moves busy through retry and recovery to final idle content", async ({ page }) => {
|
|
const assistant = assistantMessage([], { completed: false })
|
|
const timeline = await setupTimeline(page, {
|
|
messages: [
|
|
userMessage(undefined, {
|
|
summary: {
|
|
diffs: [
|
|
{
|
|
file: "src/retry.ts",
|
|
additions: 1,
|
|
deletions: 1,
|
|
patch: "@@ -1 +1 @@\n-export const retry = false\n+export const retry = true",
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
assistant,
|
|
],
|
|
})
|
|
await timeline.send(status("busy"), 140)
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toBeVisible()
|
|
await expect(page.locator('[data-timeline-row="DiffSummary"]')).toHaveCount(0)
|
|
await timeline.send(status("retry"), 180)
|
|
await expect(page.locator('[data-timeline-row="Retry"]')).toBeVisible()
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
|
|
await timeline.send(status("busy", 2), 180)
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toBeVisible()
|
|
await timeline.send(partUpdated(textPart("prt_recovered", "Recovered response")), 140)
|
|
await timeline.send(messageUpdated(completedAssistantInfo(assistant.info)), 100)
|
|
await timeline.send(status("idle"), 350)
|
|
await expect(page.locator('[data-timeline-row="Retry"]')).toHaveCount(0)
|
|
await expect(page.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
|
|
await expect(page.locator('[data-timeline-row="DiffSummary"]')).toBeVisible()
|
|
})
|
|
|
|
function lines(count: number) {
|
|
return Array.from({ length: count }, (_, index) => `line ${index + 1}`).join("\n")
|
|
}
|