mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-09 19:29:41 +00:00
Add viewport-driven paging with layout acknowledgements, bounded retries, cancellation gates, and epoch-safe history retention. Preserve transcript anchors and expansion state, fix tool-group identity collisions, and serialize Android history coordination on Main. Reduce per-scroll composition and layout work; add native regression tests, CI coverage, and profiling guidance.
25 lines
880 B
Swift
25 lines
880 B
Swift
import HapiUI
|
|
import Testing
|
|
|
|
@Suite("Chat markdown cache")
|
|
struct MarkdownRenderCacheTests {
|
|
@Test func prewarmingMatchesTheExistingRenderer() async {
|
|
let cache = MarkdownRenderCache()
|
|
let text = "## History\n\n```swift\nlet stable = true\n```"
|
|
await cache.prepare([text])
|
|
#expect(cache.cached(text) == MarkdownBlockTree.build(from: text))
|
|
await cache.prepare([text])
|
|
#expect(cache.cached(text) != nil)
|
|
}
|
|
|
|
@Test func retentionIsBoundedAndHugeEntriesDoNotEvictNormalOnes() async {
|
|
let cache = MarkdownRenderCache(maxCost: 32)
|
|
await cache.prepare(["one"])
|
|
await cache.prepare([String(repeating: "x", count: 100)])
|
|
#expect(cache.cached("one") != nil)
|
|
await cache.prepare(["second"])
|
|
#expect(cache.cached("one") == nil)
|
|
#expect(cache.cached("second") != nil)
|
|
}
|
|
}
|