Repository navigation
perf(macos): smooth chat rendering and unify composer controls - #12941
Conversation
There was a problem hiding this comment.
1 issue found across 10 files
Confidence score: 4/5
desktop/macos/Desktop/Tests/ChatProseRenderCacheTests.swiftdoes not reach the cache’s 1,024-entry limit, so it never exercises the claimed guarantee that streaming avoids evicting and reparsing mounted history; adjust the workload to exceed the limit and verify eviction behavior.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/macos/Desktop/Tests/ChatProseRenderCacheTests.swift">
<violation number="1" location="desktop/macos/Desktop/Tests/ChatProseRenderCacheTests.swift:145">
P3: The test's asserted guarantee 'Streaming must not evict and reparse the mounted history' is never actually exercised. Its workload (500 rows + 8 stream keys = 508 unique keys) stays far below maximumEntries (1,024), so the LRU never evicts and productions == 500 holds no matter what. Realistic streaming mints a new key per flush (per the source comment, 'the cache turns over during an answer'), so an answer with more than ~524 flushes would evict history rows — a scenario this test can't catch. Also, the stream-frame produce closure never increments `productions`, so the test measures nothing about whether the stream frames themselves stay warm. Either push the test past the eviction boundary or narrow the assertion message to what it actually verifies (capacity > 500+frames).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| NSAttributedString(string: "stream frame \(frame)") | ||
| } | ||
| } | ||
| XCTAssertEqual(productions, 500, "Streaming must not evict and reparse the mounted history") |
There was a problem hiding this comment.
P3: The test's asserted guarantee 'Streaming must not evict and reparse the mounted history' is never actually exercised. Its workload (500 rows + 8 stream keys = 508 unique keys) stays far below maximumEntries (1,024), so the LRU never evicts and productions == 500 holds no matter what. Realistic streaming mints a new key per flush (per the source comment, 'the cache turns over during an answer'), so an answer with more than ~524 flushes would evict history rows — a scenario this test can't catch. Also, the stream-frame produce closure never increments productions, so the test measures nothing about whether the stream frames themselves stay warm. Either push the test past the eviction boundary or narrow the assertion message to what it actually verifies (capacity > 500+frames).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Tests/ChatProseRenderCacheTests.swift, line 145:
<comment>The test's asserted guarantee 'Streaming must not evict and reparse the mounted history' is never actually exercised. Its workload (500 rows + 8 stream keys = 508 unique keys) stays far below maximumEntries (1,024), so the LRU never evicts and productions == 500 holds no matter what. Realistic streaming mints a new key per flush (per the source comment, 'the cache turns over during an answer'), so an answer with more than ~524 flushes would evict history rows — a scenario this test can't catch. Also, the stream-frame produce closure never increments `productions`, so the test measures nothing about whether the stream frames themselves stay warm. Either push the test past the eviction boundary or narrow the assertion message to what it actually verifies (capacity > 500+frames).</comment>
<file context>
@@ -128,6 +128,23 @@ final class ChatProseRenderCacheTests: XCTestCase {
+ NSAttributedString(string: "stream frame \(frame)")
+ }
+ }
+ XCTAssertEqual(productions, 500, "Streaming must not evict and reparse the mounted history")
+ }
+
</file context>
What changed and why
Long transcripts repeatedly evicted rendered prose and reparsed unchanged Markdown as chat updated. Cache immutable Markdown at the rendering boundary and use constant-time LRU bookkeeping with room for the 500-row transcript window. The prose cache grows from 192 to 1,024 entries, trading bounded additional memory for fewer repeated parses. Unify Send/Stop controls across chat composers, reduce nested chrome and spacing, and keep the stopping indicator and draft geometry stable.
Product invariants affected
INV-CHAT-1. Existing streaming reveal and reader-controlled scrolling behavior is preserved.
How it was verified
OMI_PR_BODY_FILE=/tmp/omi-chat-polish-pr.md make preflight: all 24 checks passed. Required pre-push checks and desktop debug compilation passed; formatting and SwiftLint passed.Tests
Added regression coverage for 500-row cache reuse, LRU eviction and release, partial rich Markdown equivalence, and draft/geometry preservation through Send/Stop/Stopping. Existing mounted gesture tests cover reading older messages during streaming, following the live edge, and preserving anchors while loading history.
Failure class (fixes)
Failure-Class: none