chore: generate
This commit is contained in:
@@ -905,26 +905,26 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
|
"esbuild",
|
||||||
"tree-sitter-powershell",
|
"tree-sitter-powershell",
|
||||||
|
"protobufjs",
|
||||||
|
"electron",
|
||||||
"web-tree-sitter",
|
"web-tree-sitter",
|
||||||
"tree-sitter-bash",
|
"tree-sitter-bash",
|
||||||
"esbuild",
|
|
||||||
"electron",
|
|
||||||
"protobufjs",
|
|
||||||
],
|
],
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"solid-js@1.9.10": "patches/solid-js@1.9.10.patch",
|
|
||||||
"@pierre/trees@1.0.0-beta.4": "patches/@pierre%2Ftrees@1.0.0-beta.4.patch",
|
"@pierre/trees@1.0.0-beta.4": "patches/@pierre%2Ftrees@1.0.0-beta.4.patch",
|
||||||
"@ai-sdk/xai@3.0.82": "patches/@ai-sdk%2Fxai@3.0.82.patch",
|
|
||||||
"pacote@21.5.0": "patches/pacote@21.5.0.patch",
|
|
||||||
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
|
||||||
"@modelcontextprotocol/sdk@1.29.0": "patches/@modelcontextprotocol%2Fsdk@1.29.0.patch",
|
"@modelcontextprotocol/sdk@1.29.0": "patches/@modelcontextprotocol%2Fsdk@1.29.0.patch",
|
||||||
"gcp-metadata@8.1.2": "patches/gcp-metadata@8.1.2.patch",
|
"gcp-metadata@8.1.2": "patches/gcp-metadata@8.1.2.patch",
|
||||||
"@ai-sdk/google@3.0.73": "patches/@ai-sdk%2Fgoogle@3.0.73.patch",
|
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
||||||
|
"@npmcli/agent@4.0.2": "patches/@npmcli%2Fagent@4.0.2.patch",
|
||||||
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
|
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
|
||||||
"@tanstack/solid-virtual@3.13.28": "patches/@tanstack%2Fsolid-virtual@3.13.28.patch",
|
"@tanstack/solid-virtual@3.13.28": "patches/@tanstack%2Fsolid-virtual@3.13.28.patch",
|
||||||
|
"solid-js@1.9.10": "patches/solid-js@1.9.10.patch",
|
||||||
|
"@ai-sdk/google@3.0.73": "patches/@ai-sdk%2Fgoogle@3.0.73.patch",
|
||||||
|
"@ai-sdk/xai@3.0.82": "patches/@ai-sdk%2Fxai@3.0.82.patch",
|
||||||
"@tanstack/virtual-core@3.17.0": "patches/@tanstack%2Fvirtual-core@3.17.0.patch",
|
"@tanstack/virtual-core@3.17.0": "patches/@tanstack%2Fvirtual-core@3.17.0.patch",
|
||||||
"@npmcli/agent@4.0.2": "patches/@npmcli%2Fagent@4.0.2.patch",
|
"pacote@21.5.0": "patches/pacote@21.5.0.patch",
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@opentui/core": "catalog:",
|
"@opentui/core": "catalog:",
|
||||||
|
|||||||
@@ -196,7 +196,8 @@ test.describe("regression: session timeline local row state", () => {
|
|||||||
const events: EventPayload[] = []
|
const events: EventPayload[] = []
|
||||||
const lines = Array.from({ length: 1_000 }, (_, index) => `export const value${index} = ${index}\n`).join("")
|
const lines = Array.from({ length: 1_000 }, (_, index) => `export const value${index} = ${index}\n`).join("")
|
||||||
const after = [100, 300, 500, 700, 900].reduce(
|
const after = [100, 300, 500, 700, 900].reduce(
|
||||||
(result, index) => result.replace(`export const value${index} = ${index}`, `export const value${index} = compute(${index})`),
|
(result, index) =>
|
||||||
|
result.replace(`export const value${index} = ${index}`, `export const value${index} = compute(${index})`),
|
||||||
lines,
|
lines,
|
||||||
)
|
)
|
||||||
const part = {
|
const part = {
|
||||||
@@ -385,11 +386,7 @@ function readExpanded(element: Element) {
|
|||||||
return !!content && content.getBoundingClientRect().height > 0
|
return !!content && content.getBoundingClientRect().height > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mockServer(
|
async function mockServer(page: Page, events: EventPayload[], messages = [userMessage, assistantMessage]) {
|
||||||
page: Page,
|
|
||||||
events: EventPayload[],
|
|
||||||
messages = [userMessage, assistantMessage],
|
|
||||||
) {
|
|
||||||
await mockOpenCodeServer(page, {
|
await mockOpenCodeServer(page, {
|
||||||
directory,
|
directory,
|
||||||
project: project(),
|
project: project(),
|
||||||
|
|||||||
@@ -172,7 +172,9 @@ test.describe("smoke: session timeline", () => {
|
|||||||
})
|
})
|
||||||
.map((element) => element.dataset.messageId!)
|
.map((element) => element.dataset.messageId!)
|
||||||
.filter((id) => ids.has(id))
|
.filter((id) => ids.has(id))
|
||||||
const bottom = root.querySelector<HTMLElement>('[data-timeline-row="bottom-spacer"]')?.getBoundingClientRect()
|
const bottom = root
|
||||||
|
.querySelector<HTMLElement>('[data-timeline-row="bottom-spacer"]')
|
||||||
|
?.getBoundingClientRect()
|
||||||
samples.push({ ids: visible, last: visible.includes(last), bottomError: bottom?.bottom - view.bottom })
|
samples.push({ ids: visible, last: visible.includes(last), bottomError: bottom?.bottom - view.bottom })
|
||||||
if (!firstPaint && visible.includes(last) && Math.abs((bottom?.bottom ?? Infinity) - view.bottom) <= 1) {
|
if (!firstPaint && visible.includes(last) && Math.abs((bottom?.bottom ?? Infinity) - view.bottom) <= 1) {
|
||||||
firstPaint = true
|
firstPaint = true
|
||||||
@@ -187,9 +189,11 @@ test.describe("smoke: session timeline", () => {
|
|||||||
requestAnimationFrame(sample)
|
requestAnimationFrame(sample)
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
;(window as Window & {
|
;(
|
||||||
|
window as Window & {
|
||||||
__sessionTabPaint?: { samples: typeof samples; removed: () => number; stop: () => void }
|
__sessionTabPaint?: { samples: typeof samples; removed: () => number; stop: () => void }
|
||||||
}).__sessionTabPaint = {
|
}
|
||||||
|
).__sessionTabPaint = {
|
||||||
samples,
|
samples,
|
||||||
removed: () => removedFirstPaintNodes,
|
removed: () => removedFirstPaintNodes,
|
||||||
stop: () => {
|
stop: () => {
|
||||||
@@ -203,19 +207,21 @@ test.describe("smoke: session timeline", () => {
|
|||||||
|
|
||||||
await switchTitlebarSession(page, fixture.targetID, fixture.expected.targetTitle)
|
await switchTitlebarSession(page, fixture.targetID, fixture.expected.targetTitle)
|
||||||
await page.waitForFunction(() =>
|
await page.waitForFunction(() =>
|
||||||
(window as Window & { __sessionTabPaint?: { samples: Array<{ ids: string[] }> } }).__sessionTabPaint?.samples.some(
|
(
|
||||||
(sample) => sample.ids.length > 0,
|
window as Window & { __sessionTabPaint?: { samples: Array<{ ids: string[] }> } }
|
||||||
),
|
).__sessionTabPaint?.samples.some((sample) => sample.ids.length > 0),
|
||||||
)
|
)
|
||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
const first = await page.evaluate(() => {
|
const first = await page.evaluate(() => {
|
||||||
const probe = (window as Window & {
|
const probe = (
|
||||||
|
window as Window & {
|
||||||
__sessionTabPaint?: {
|
__sessionTabPaint?: {
|
||||||
samples: Array<{ ids: string[]; last: boolean; bottomError?: number }>
|
samples: Array<{ ids: string[]; last: boolean; bottomError?: number }>
|
||||||
removed: () => number
|
removed: () => number
|
||||||
stop: () => void
|
stop: () => void
|
||||||
}
|
}
|
||||||
}).__sessionTabPaint!
|
}
|
||||||
|
).__sessionTabPaint!
|
||||||
probe.stop()
|
probe.stop()
|
||||||
return { first: probe.samples.find((sample) => sample.ids.length > 0), removed: probe.removed() }
|
return { first: probe.samples.find((sample) => sample.ids.length > 0), removed: probe.removed() }
|
||||||
})
|
})
|
||||||
@@ -253,7 +259,8 @@ test.describe("smoke: session timeline", () => {
|
|||||||
await expectSessionTitle(page, fixture.expected.sourceTitle)
|
await expectSessionTitle(page, fixture.expected.sourceTitle)
|
||||||
const last = fixture.expected.targetMessageIDs.at(-1)!
|
const last = fixture.expected.targetMessageIDs.at(-1)!
|
||||||
const destination = fixture.messages[fixture.targetID].map((message) => message.info.id)
|
const destination = fixture.messages[fixture.targetID].map((message) => message.info.id)
|
||||||
await page.evaluate(({ destination, last }) => {
|
await page.evaluate(
|
||||||
|
({ destination, last }) => {
|
||||||
const ids = new Set(destination)
|
const ids = new Set(destination)
|
||||||
const samples: Array<{ destination: boolean; last: boolean; bottomError?: number }> = []
|
const samples: Array<{ destination: boolean; last: boolean; bottomError?: number }> = []
|
||||||
const sample = () => {
|
const sample = () => {
|
||||||
@@ -262,7 +269,9 @@ test.describe("smoke: session timeline", () => {
|
|||||||
)
|
)
|
||||||
if (root) {
|
if (root) {
|
||||||
const view = root.getBoundingClientRect()
|
const view = root.getBoundingClientRect()
|
||||||
const spacer = root.querySelector<HTMLElement>('[data-timeline-row="bottom-spacer"]')?.getBoundingClientRect()
|
const spacer = root
|
||||||
|
.querySelector<HTMLElement>('[data-timeline-row="bottom-spacer"]')
|
||||||
|
?.getBoundingClientRect()
|
||||||
const messages = [...root.querySelectorAll<HTMLElement>("[data-message-id]")].filter((element) => {
|
const messages = [...root.querySelectorAll<HTMLElement>("[data-message-id]")].filter((element) => {
|
||||||
const rect = element.getBoundingClientRect()
|
const rect = element.getBoundingClientRect()
|
||||||
return rect.bottom > view.top && rect.top < view.bottom
|
return rect.bottom > view.top && rect.top < view.bottom
|
||||||
@@ -277,7 +286,9 @@ test.describe("smoke: session timeline", () => {
|
|||||||
}
|
}
|
||||||
;(window as Window & { __coldTabSamples?: typeof samples }).__coldTabSamples = samples
|
;(window as Window & { __coldTabSamples?: typeof samples }).__coldTabSamples = samples
|
||||||
requestAnimationFrame(() => setTimeout(sample, 0))
|
requestAnimationFrame(() => setTimeout(sample, 0))
|
||||||
}, { destination, last })
|
},
|
||||||
|
{ destination, last },
|
||||||
|
)
|
||||||
|
|
||||||
await switchTitlebarSession(page, fixture.targetID, fixture.expected.targetTitle)
|
await switchTitlebarSession(page, fixture.targetID, fixture.expected.targetTitle)
|
||||||
await page.waitForFunction(() =>
|
await page.waitForFunction(() =>
|
||||||
@@ -286,9 +297,11 @@ test.describe("smoke: session timeline", () => {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
const result = await page.evaluate(() => {
|
const result = await page.evaluate(() => {
|
||||||
const samples = (window as Window & {
|
const samples = (
|
||||||
|
window as Window & {
|
||||||
__coldTabSamples?: Array<{ destination: boolean; last: boolean; bottomError?: number }>
|
__coldTabSamples?: Array<{ destination: boolean; last: boolean; bottomError?: number }>
|
||||||
}).__coldTabSamples!
|
}
|
||||||
|
).__coldTabSamples!
|
||||||
return samples.find((sample) => sample.destination)!
|
return samples.find((sample) => sample.destination)!
|
||||||
})
|
})
|
||||||
expect(result.last).toBe(true)
|
expect(result.last).toBe(true)
|
||||||
|
|||||||
@@ -82,10 +82,7 @@ type FramedTimelineRow = Exclude<TimelineRow.TimelineRow, { _tag: "TurnGap" }>
|
|||||||
type TimelineRowByTag<T extends TimelineRow.TimelineRow["_tag"]> = Extract<TimelineRow.TimelineRow, { _tag: T }>
|
type TimelineRowByTag<T extends TimelineRow.TimelineRow["_tag"]> = Extract<TimelineRow.TimelineRow, { _tag: T }>
|
||||||
|
|
||||||
const timelineFallbackItemSize = 60
|
const timelineFallbackItemSize = 60
|
||||||
const timelineCache = new Map<
|
const timelineCache = new Map<string, { measurements: VirtualItem[]; toolOpen: Record<string, boolean | undefined> }>()
|
||||||
string,
|
|
||||||
{ measurements: VirtualItem[]; toolOpen: Record<string, boolean | undefined> }
|
|
||||||
>()
|
|
||||||
|
|
||||||
const taskDescription = (part: PartType, sessionID: string) => {
|
const taskDescription = (part: PartType, sessionID: string) => {
|
||||||
if (part.type !== "tool" || part.tool !== "task") return
|
if (part.type !== "tool" || part.tool !== "task") return
|
||||||
|
|||||||
@@ -55,11 +55,7 @@ export function createTimelineModel(input: {
|
|||||||
const id = input.sessionID()
|
const id = input.sessionID()
|
||||||
return !id || sync().data.message[id] !== undefined
|
return !id || sync().data.message[id] !== undefined
|
||||||
})
|
})
|
||||||
const userMessages = createMemo(
|
const userMessages = createMemo(() => selectUserMessages(messages()), emptyUserMessages, { equals: same })
|
||||||
() => selectUserMessages(messages()),
|
|
||||||
emptyUserMessages,
|
|
||||||
{ equals: same },
|
|
||||||
)
|
|
||||||
const visibleUserMessages = createMemo(
|
const visibleUserMessages = createMemo(
|
||||||
() => {
|
() => {
|
||||||
return selectVisibleUserMessages(userMessages(), input.revertMessageID())
|
return selectVisibleUserMessages(userMessages(), input.revertMessageID())
|
||||||
|
|||||||
@@ -27,8 +27,11 @@ export function createTimelineProjection(input: {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
const activeMessageID = createMemo(() => {
|
const activeMessageID = createMemo(() => {
|
||||||
const parentID = input.messages().findLast(
|
const parentID = input
|
||||||
(message): message is AssistantMessage => message.role === "assistant" && typeof message.time.completed !== "number",
|
.messages()
|
||||||
|
.findLast(
|
||||||
|
(message): message is AssistantMessage =>
|
||||||
|
message.role === "assistant" && typeof message.time.completed !== "number",
|
||||||
)?.parentID
|
)?.parentID
|
||||||
if (parentID) {
|
if (parentID) {
|
||||||
const messages = input.messages()
|
const messages = input.messages()
|
||||||
|
|||||||
@@ -123,8 +123,12 @@ describe("markdown stream", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test("only reuses pending blocks with compatible identity and content", () => {
|
test("only reuses pending blocks with compatible identity and content", () => {
|
||||||
expect(canReusePendingBlock({ mode: "full", raw: "First\n\n" }, { mode: "full", raw: "# Inserted\n\n", src: "", })).toBe(false)
|
expect(
|
||||||
expect(canReusePendingBlock({ mode: "code", raw: "```ts\none" }, { mode: "code", raw: "```ts\none two", src: "" })).toBe(true)
|
canReusePendingBlock({ mode: "full", raw: "First\n\n" }, { mode: "full", raw: "# Inserted\n\n", src: "" }),
|
||||||
|
).toBe(false)
|
||||||
|
expect(
|
||||||
|
canReusePendingBlock({ mode: "code", raw: "```ts\none" }, { mode: "code", raw: "```ts\none two", src: "" }),
|
||||||
|
).toBe(true)
|
||||||
expect(canReusePendingBlock({ mode: "code", raw: "```ts\none" }, { mode: "live", raw: "one", src: "" })).toBe(false)
|
expect(canReusePendingBlock({ mode: "code", raw: "```ts\none" }, { mode: "live", raw: "one", src: "" })).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { expect, test } from "bun:test"
|
import { expect, test } from "bun:test"
|
||||||
import { applyMarkdownWorkerResponse, markdownBlockKey, shouldReleaseMarkdownWorkerState } from "./markdown-worker-protocol"
|
import {
|
||||||
|
applyMarkdownWorkerResponse,
|
||||||
|
markdownBlockKey,
|
||||||
|
shouldReleaseMarkdownWorkerState,
|
||||||
|
} from "./markdown-worker-protocol"
|
||||||
|
|
||||||
const token = (content: string): [string, string] => [content, ""]
|
const token = (content: string): [string, string] => [content, ""]
|
||||||
const response = (id: number, reset: boolean, stable: [string, string][], unstable: [string, string][]) => ({
|
const response = (id: number, reset: boolean, stable: [string, string][], unstable: [string, string][]) => ({
|
||||||
|
|||||||
@@ -3,7 +3,16 @@ import { useI18n } from "../context/i18n"
|
|||||||
import DOMPurify from "dompurify"
|
import DOMPurify from "dompurify"
|
||||||
import morphdom from "morphdom"
|
import morphdom from "morphdom"
|
||||||
import { checksum } from "@opencode-ai/core/util/encode"
|
import { checksum } from "@opencode-ai/core/util/encode"
|
||||||
import { ComponentProps, createEffect, createMemo, createResource, createSignal, createUniqueId, onCleanup, splitProps } from "solid-js"
|
import {
|
||||||
|
ComponentProps,
|
||||||
|
createEffect,
|
||||||
|
createMemo,
|
||||||
|
createResource,
|
||||||
|
createSignal,
|
||||||
|
createUniqueId,
|
||||||
|
onCleanup,
|
||||||
|
splitProps,
|
||||||
|
} from "solid-js"
|
||||||
import { isServer } from "solid-js/web"
|
import { isServer } from "solid-js/web"
|
||||||
import { bundledLanguages } from "shiki"
|
import { bundledLanguages } from "shiki"
|
||||||
import { canReusePendingBlock, project, type Block, type Projection } from "./markdown-stream"
|
import { canReusePendingBlock, project, type Block, type Projection } from "./markdown-stream"
|
||||||
@@ -439,9 +448,9 @@ export function Markdown(
|
|||||||
nextCodeKeys.forEach((key) => activeCodeKeys.add(key))
|
nextCodeKeys.forEach((key) => activeCodeKeys.add(key))
|
||||||
content.forEach((block, index) => updateBlock(container, index, block, labels))
|
content.forEach((block, index) => updateBlock(container, index, block, labels))
|
||||||
while (container.children.length > content.length) container.lastElementChild?.remove()
|
while (container.children.length > content.length) container.lastElementChild?.remove()
|
||||||
container.querySelectorAll<HTMLButtonElement>('[data-slot="markdown-copy-button"]').forEach((button) =>
|
container
|
||||||
setCopyState(button, labels, button.dataset.copied === "true"),
|
.querySelectorAll<HTMLButtonElement>('[data-slot="markdown-copy-button"]')
|
||||||
)
|
.forEach((button) => setCopyState(button, labels, button.dataset.copied === "true"))
|
||||||
if (!copyCleanup)
|
if (!copyCleanup)
|
||||||
copyCleanup = setupCodeCopy(container, () => ({
|
copyCleanup = setupCodeCopy(container, () => ({
|
||||||
copy: i18n.t("ui.message.copy"),
|
copy: i18n.t("ui.message.copy"),
|
||||||
@@ -549,8 +558,7 @@ function updateCodeBlock(
|
|||||||
block: Extract<RenderedBlock, { mode: "code" }>,
|
block: Extract<RenderedBlock, { mode: "code" }>,
|
||||||
labels: CopyLabels,
|
labels: CopyLabels,
|
||||||
) {
|
) {
|
||||||
const existing =
|
const existing = current instanceof HTMLDivElement && current.dataset.markdownKey === block.key ? current : undefined
|
||||||
current instanceof HTMLDivElement && current.dataset.markdownKey === block.key ? current : undefined
|
|
||||||
const next = existing ?? document.createElement("div")
|
const next = existing ?? document.createElement("div")
|
||||||
next.dataset.markdownBlock = ""
|
next.dataset.markdownBlock = ""
|
||||||
next.dataset.markdownKey = block.key
|
next.dataset.markdownKey = block.key
|
||||||
@@ -574,7 +582,10 @@ function updateCodeBlock(
|
|||||||
const prefix = prior.findIndex((token, index) => !sameToken(token, tail[index]))
|
const prefix = prior.findIndex((token, index) => !sameToken(token, tail[index]))
|
||||||
const keep = stableCount + (prefix < 0 ? Math.min(prior.length, tail.length) : prefix)
|
const keep = stableCount + (prefix < 0 ? Math.min(prior.length, tail.length) : prefix)
|
||||||
while (code.children.length > keep) code.lastElementChild?.remove()
|
while (code.children.length > keep) code.lastElementChild?.remove()
|
||||||
tail.slice(keep - stableCount).map(createTokenSpan).forEach((span) => code.appendChild(span))
|
tail
|
||||||
|
.slice(keep - stableCount)
|
||||||
|
.map(createTokenSpan)
|
||||||
|
.forEach((span) => code.appendChild(span))
|
||||||
renderedCodeTokens.set(next, {
|
renderedCodeTokens.set(next, {
|
||||||
language: block.language,
|
language: block.language,
|
||||||
generation: block.generation,
|
generation: block.generation,
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ export function scrollTopFromThumbPointer(input: {
|
|||||||
const padding = 8
|
const padding = 8
|
||||||
const maxThumbTop = input.clientHeight - padding * 2 - input.thumbHeight
|
const maxThumbTop = input.clientHeight - padding * 2 - input.thumbHeight
|
||||||
if (maxThumbTop <= 0) return 0
|
if (maxThumbTop <= 0) return 0
|
||||||
const thumbTop = Math.max(
|
const thumbTop = Math.max(0, Math.min(input.pointer - input.viewportTop - padding - input.grabOffset, maxThumbTop))
|
||||||
0,
|
|
||||||
Math.min(input.pointer - input.viewportTop - padding - input.grabOffset, maxThumbTop),
|
|
||||||
)
|
|
||||||
return (thumbTop / maxThumbTop) * Math.max(0, input.scrollHeight - input.clientHeight)
|
return (thumbTop / maxThumbTop) * Math.max(0, input.scrollHeight - input.clientHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user