Skip to content

perf(macos): smooth chat rendering and unify composer controls - #12941

Merged
Git-on-my-level merged 1 commit into
mainfrom
codex/macos-chat-polish
Sep 8, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
codex/macos-chat-polish

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

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

  • Native mounted chat/composer views visually inspected with synthetic settled, streaming, and stopping states. Scroll/streaming/cache focused run: 54 tests passed, including 21 transcript gesture tests. Expanded cache/composer/shell/drift run: 86 passed.
  • Isolated optimized render-cache benchmark, 500 rows across eight passes: 4,000 to 500 Markdown parses; 3.09s to 0.40s. This measures the cache workload, not end-to-end app latency.
  • Cross-surface smoke passed, including 72 Swift tests and Node/Python contracts. Desktop Python tests: 240 passed. Launcher/formatter fixture checks passed; worktree fixtures used the approved scratch root.
  • Named ad-hoc dev bundle built and launched. Development health returned 200; API and auth routing explicitly target development. Authenticated dev-provider chat was not exercised because no usable dev session was available.
  • Broad Swift verification: all 801 parallel suites passed; all 22 auth/state suites passed via the same runner in separate processes with fresh runtime homes. The full wrapper stopped on a transient build-cache copy race after 804 passes; the entire serial group was completed separately, with one build-lock collision retried after the push compile finished. No test assertion failures remained.
  • Final composer run: 18 passed; final native visual probe passed. 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

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 10 files

Confidence score: 4/5

  • desktop/macos/Desktop/Tests/ChatProseRenderCacheTests.swift does 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")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@Git-on-my-level
Git-on-my-level merged commit 0f44fa4 into main Sep 8, 2026
33 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/macos-chat-polish branch September 8, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant