Repository navigation
test(tui): bound diff viewer mount readiness before selected-request polling - #840
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
| async function renderWithin(app: Awaited<ReturnType<typeof testRender>>, deadline: number) { | ||
| const remaining = deadline - performance.now() | ||
| if (remaining <= 0) throw new Error("Timed out waiting for the diff viewer to mount") | ||
| // Promise.race below subscribes to render, so a late rejection after expiry is observed. |
There was a problem hiding this comment.
SUGGESTION: Incorrect comment about Promise.race behavior
Promise.race settles on the first promise to settle; it does not "subscribe" to observe late rejections of the losing promise. The losing promise's rejection becomes unhandled unless separately awaited.
| timer = setTimeout(() => reject(new Error("Timed out waiting for the diff viewer to mount")), remaining) | ||
| }) | ||
| try { | ||
| await Promise.race([render, expiry]) |
There was a problem hiding this comment.
WARNING: Potential unhandled promise rejection when deadline expires
When expiry wins the race, the render promise is left pending. If it later rejects (as simulated in the test at line 382), the rejection is unhandled. Consider attaching a .catch() to render or awaiting it in the finally block to prevent unhandled rejections.
| expect(destroyCount).toBe(1) | ||
| }) | ||
|
|
||
| test("diff viewer mount deadline bounds a pending render and observes its late rejection", async () => { |
There was a problem hiding this comment.
SUGGESTION: Test name claims to "observe late rejection" but doesn't assert on it
The test triggers a late rejection at line 382 but only verifies that renderCount and destroyCount don't change. It doesn't assert that the late rejection is observed or handled. Consider renaming to "diff viewer mount deadline bounds a pending render and cleans up once" or adding an assertion for the late rejection.
| } | ||
| }) | ||
|
|
||
| const MOUNT_DEADLINE_MS = 2000 // Deadline for the KV provider to mount children (real lock + read settle); a 400ms held lock mounts in about 0.55s. Leaves most of Bun's test host budget for the unchanged post-mount loop and cleanup. |
There was a problem hiding this comment.
SUGGESTION: Comment references Bun's default test timeout
The comment states "well before Bun's default 5000ms test timeout". Bun's default test timeout is indeed 5000ms, but this is an implementation detail that could change. Consider referencing the actual timeout configuration or removing the specific version-dependent number.
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (1 file)
Fix these issues in Kilo Cloud Reviewed by free · Input: 45.8K · Output: 12.3K · Cached: 162.2K |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #839
Type of change
What does this PR do?
Test harness only: observe the viewer mount below KVProvider before starting the existing selected-request readiness loop. A 2000 ms monotonic mount deadline bounds asynchronous render waits, clears its timer, and observes late render rejection. Keep the post-mount 10 attempts with 25 ms waits and all host/CI limits unchanged.
The real 400 ms KV lock test waits for acquisition before rendering and propagates acquisition failure. Added deadline tests cover instant renders and a pending render that rejects after expiry, including one destroy and no further polling.
How did you verify your code works?
Ran the affected Linux tests: 12 pass, 0 fail, 41 expectations. Also ran the existing repository 30000 ms invocation, two failing controls, and the real KV-lock diagnostic described below.
Exact qualification
Final CI: https://github.com/mdev34-lab/silvercode/actions/runs/42965958786
The same Arena reviewer explicitly adjudicated all four later Kilo findings against the public PR head and kept CLEAN: Promise.race installs rejection handlers on all inputs; awaiting the losing render in finally would reintroduce an unbounded wait. The late-rejection test is adequate with source semantics, and the quoted 5000 ms comment is absent from V4. Kilo itself reported four findings, not a clean review.
Head: 8b73484
Tree: aee73451214300397147cb02b2bc93d39917f0b6
Base: ef8e500
Full one-file patch independently reviewed by the same Arena reviewer after the earlier must-fix findings. Final result: CLEAN, no remaining must-fix.
Review: https://arena.ai/agent/01a1c89d-fb30-7ae6-8f25-2dc4247e3a11
Local Linux: 12 pass, 0 fail, 41 expectations, including the existing repository 30000 ms invocation.
Controls: removing the mount wait fails the acquired-KV-lock regression; removing the render deadline race fails the pending-render regression.
Diagnostic using the real renderDiffViewer path and a 3500 ms acquired KV lock: mount rejection at 2034 ms; 3 pass, 0 fail, no extra Bun unhandled error. This diagnostic did not directly instrument real renderer destruction. The cleanup wrapper source and fake-app regression tests cover the one-destroy/no-further-polling contract.
Limits and merge gate
The deadline is cooperative, not a hard real-time guarantee or synchronous event-loop preemption. The 25 ms polling sleep can add a small overshoot. No render-duration cap is claimed.
The controlled KV-lock failure establishes a pre-mount mechanism on the base and #836, not the actual cause of the two Windows CI failures. Exact-head CI is now green: Linux units (22 minutes), Windows units, typecheck and all policy checks passed on 8b73484. This PR does not waive #835 or #836 gates. The independent review remains applicable to this unchanged head.
Screenshots / recordings
Not a production UI change. Test-harness-only readiness and cleanup correction.
Checklist