Repository navigation
test(opencode): wait for the picker's settings write, not a fixed 600 ms - #1452
Merged
Merged
Conversation
The picker confirm-and-cancel test used a fixed 600 ms wait twice. The confirm check now polls until settings.env holds strategy=none, with a 30 s bound and a named failure. The cancel check runs at once, because the cancel handler is synchronous and starts no write. The waitFor helper moves from failopen.test.mjs to helpers.mjs, so both files share one copy. The pending-timing-fixes line is removed. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5
amiddavid
force-pushed
the
test/fix-opencode-picker
branch
from
November 26, 2026 11:12
4b46890 to
c1b32a8
Compare
Collaborator
Author
|
Local tests: waived (owner rule) |
amiddavid
commented
Nov 26, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | c1b32a8b89ee |
approve |
Verdict: approve
Findings
None.
Non-blocking
opencode-plugin/test/helpers.mjs:121— a condition that throws insidewaitForfails the test with the raw error, not the "timed out waiting for" message. The current call sites cannot throw. Note only.opencode-plugin/test/tui.test.mjs:123— this line still uses(await import("node:fs")).existsSync, while line 3 now importsexistsSyncdirectly. Pre-existing inconsistency, made slightly more visible by this change.opencode-plugin/test/tui.test.mjs:145— the test directory/tmp/context-guru-tui-cancelis fixed, so a leftoversettings.envfrom an earlier failed run can fail line 161. Pre-existing; the oldsettle()version had the same exposure.
What I checked
- Read the full diff (4 files) and the code around each change:
tui.js,helpers.mjs, both test files. - Cancel check is sound.
tui.js:70(confirmSwitch'sonCancel) only callsapi.ui.dialog.clear(). It is synchronous and starts no write. Nosetscript runs before it in the test flow, sosettings.envis absent whenonCancelreturns. The test comment attui.test.mjs:160states this correctly. - Confirm check is sound.
tui.js:72awaitsrunCommandScriptforset none, so the write finishes beforeonConfirmresolves. ThewaitForattui.test.mjs:169polls a real condition (file exists and holdsstrategy=none) with a 30 s bound, and its failure message names what it waited for. This satisfies the repo rule that tests wait on a condition, not on time. waitFormove is exact. The copy inhelpers.mjs:121-127matches the removed local copy infailopen.test.mjs: same signature, same 25 s default, same loop.assertis imported athelpers.mjs:1. All threefailopen.test.mjscall sites (lines 358, 458, 520) pass the same arguments as before.settle()is gone. No remaining reference in any test file.pending-timing-fixes.txt— the removed line names exactly thesettle()usage this PR deletes. The other lines are untouched.- Rules. Test-only change: no host-package logic, no client rule, no data-dependence row needed, no behavior change. The PR body states test results, including two vacuity checks, and says where they ran.
amiddavid
commented
Nov 26, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | c1b32a8b89ee |
approve |
Verdict: approve
Findings
None.
Non-blocking
tui.test.mjs:161— the immediate absence check is weaker than the old delayed one against a write that starts later. The comment states why this is safe:tui.js:70makes the cancel handler synchronous with no write. No change needed. The old 600 ms wait proved no more than this: a delay can never show that no write will ever start.helpers.mjs:121—waitForpolls with a 100 ms sleep between condition checks. This is a condition wait with a deadline, not a fixed sleep, so it fits the repo rule. It is the same loop that already lived infailopen.test.mjs.
What I checked
- Read the full diff of all 4 files:
failopen.test.mjs,helpers.mjs,tui.test.mjs,pending-timing-fixes.txt. waitFormoved tohelpers.mjsis byte-identical to the copy removed fromfailopen.test.mjs.helpers.mjsalready importsassert(line 1). All three call sites infailopen.test.mjs(lines 358, 458, 520) keep working.- No
settle()use remains inopencode-plugin/test/(grep). No other file defines or imports a conflictingwaitFor;signals.test.mjshas its ownwaitForRecord, untouched. - Verified the test's new claims against the code:
- Cancel writes nothing:
opencode-plugin/tui.js:70—onCancel: () => api.ui.dialog.clear(). Synchronous, no write. So the immediate absence check attui.test.mjs:161is sound. - The save path:
onConfirmawaitsrunCommandScript(state, "context-guru-strategy", ["set", "none"]). The script writessettings.envwith an atomicmv(index.js:705) before it exits, andrunCommandScript(index.js:851-860) resolves only on child close. So the newwaitForattui.test.mjs:169either passes at once or covers a slow child. On failure it names what it waited for.
- Cancel writes nothing:
pending-timing-fixes.txtsays "A PR that fixes a listed test removes its line in the same PR". This PR fixes the listed picker test and removes its line. Consistent.- Repo rules: test-only change, so no data-dependence row, no client rule, no host-boundary question, no behavior change. The PR body states this and lists the test runs and the two vacuity checks, which match the two new assertion forms.
- CI scope: the changed files are node tests plus a release-list text file. No Go code touched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The picker confirm-and-cancel test no longer uses a fixed 600 ms wait. Test-only. No behavior change. No data dependence change.
Refs the pending timing-fix list. PR #1171 also edits
opencode-plugin/test/tui.test.mjs. This PR does not wait for it.What changed
settings.envexists and holdsstrategy=none. The bound is 30 s. The failure names what it waited for.tui.jsis synchronous and starts no write, so the file is absent when it returns.waitFormoves fromfailopen.test.mjstohelpers.mjs. Both files use that one copy.settle()is removed. The line is removed fromscripts/release/pending-timing-fixes.txt.How it was tested
Tests ran on macOS, Go 1.27.4.
cd opencode-plugin && node --test: 114 pass, 0 fail, 7 skipped.tui.test.mjs10 times in a loop: 10 of 10 pass.settings.env. The test failed on the absence check. Reverted.go test ./internal/timingguard/: pass.