mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
Dependencies and build for dev's toolchain (released solid-start, nitro 3.0.260903-beta, @typescript/native, no nitro patch), the textjs package, link preview cards (script/og.ts, with the source frames it crops) and the server-bundle guard in the build. Middleware (redirects for /go, /zen, /black, /enterprise, /pricing, /models, /teams, /download, /products, plus dev's iOS pairing, server-action sanitizing and /auth, /workspace), robots.txt, humans.txt, security.txt, llms.txt (ours), sitemaps with the V2 docs at /v2/sitemap.xml, Markdown twins, link preview cards, the site header (our nav including Enterprise), footer, settings, search, voice, i18n in 18 locales with RTL, and the 404 arcade. Docs stay on dev's proxy: docsBase is /v2/docs. consoleMarketingEnabled is kept for dev's test. Zen is renamed OpenCode Models in our copy. Middleware sends heavy media to the CDN (src/lib/media.ts). Vite keeps one environments block. The mono font is OpenTUI Mono (Anomaly's, SIL OFL 1.1): the files and licence are in src/asset/fonts, built by script/opentui-mono.py. The legal library has the Privacy Policy and the Terms only; the legal drafts are not in this branch.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { staleValue } from "~/lib/edge-cache"
|
|
|
|
describe("staleValue", () => {
|
|
test("answers from the fallback when the source is slow, then from the source", async () => {
|
|
let finish = (_value: string) => {}
|
|
const read = staleValue<string>({
|
|
key: "test/slow",
|
|
freshFor: 60_000,
|
|
wait: 20,
|
|
load: () => new Promise((resolve) => (finish = resolve)),
|
|
fallback: () => "snapshot",
|
|
})
|
|
expect(await read()).toEqual({ value: "snapshot", standIn: true })
|
|
// A read while the refresh runs doesn't wait for it.
|
|
const started = Date.now()
|
|
expect(await read()).toEqual({ value: "snapshot", standIn: true })
|
|
expect(Date.now() - started).toBeLessThan(20)
|
|
finish("live")
|
|
await Bun.sleep(0)
|
|
expect(await read()).toEqual({ value: "live", standIn: false })
|
|
})
|
|
|
|
test("keeps the last good value when a refresh fails", async () => {
|
|
const answers = ["first", undefined]
|
|
const read = staleValue<string>({
|
|
key: "test/fails",
|
|
freshFor: 0,
|
|
wait: 100,
|
|
load: async () => answers.shift(),
|
|
fallback: () => "snapshot",
|
|
})
|
|
expect(await read()).toEqual({ value: "first", standIn: false })
|
|
expect(await read()).toEqual({ value: "first", standIn: false })
|
|
await Bun.sleep(0)
|
|
expect(await read()).toEqual({ value: "first", standIn: false })
|
|
})
|
|
})
|