Skip to content

test(opencode): wait for the picker's settings write, not a fixed 600 ms - #1452

Merged
amiddavid merged 1 commit into
mainfrom
test/fix-opencode-picker
Nov 26, 2026
Merged

amiddavid merged 1 commit into
mainfrom
test/fix-opencode-picker

Conversation

@amiddavid

Copy link
Copy Markdown
Collaborator

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

  • Confirm check: polls until settings.env exists and holds strategy=none. The bound is 30 s. The failure names what it waited for.
  • Cancel check: runs at once, with no wait. The cancel handler in tui.js is synchronous and starts no write, so the file is absent when it returns.
  • waitFor moves from failopen.test.mjs to helpers.mjs. Both files use that one copy.
  • settle() is removed. The line is removed from scripts/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.mjs 10 times in a loop: 10 of 10 pass.
  • Vacuity, confirm: made the save a no-op. The test failed with "timed out waiting for settings.env to hold strategy=none". Reverted.
  • Vacuity, cancel: made cancel write settings.env. The test failed on the absence check. Reverted.
  • go test ./internal/timingguard/: pass.

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
amiddavid force-pushed the test/fix-opencode-picker branch from 4b46890 to c1b32a8 Compare November 26, 2026 11:12
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Local tests: waived (owner rule)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 inside waitFor fails 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 imports existsSync directly. Pre-existing inconsistency, made slightly more visible by this change.
  • opencode-plugin/test/tui.test.mjs:145 — the test directory /tmp/context-guru-tui-cancel is fixed, so a leftover settings.env from an earlier failed run can fail line 161. Pre-existing; the old settle() 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's onCancel) only calls api.ui.dialog.clear(). It is synchronous and starts no write. No set script runs before it in the test flow, so settings.env is absent when onCancel returns. The test comment at tui.test.mjs:160 states this correctly.
  • Confirm check is sound. tui.js:72 awaits runCommandScript for set none, so the write finishes before onConfirm resolves. The waitFor at tui.test.mjs:169 polls a real condition (file exists and holds strategy=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.
  • waitFor move is exact. The copy in helpers.mjs:121-127 matches the removed local copy in failopen.test.mjs: same signature, same 25 s default, same loop. assert is imported at helpers.mjs:1. All three failopen.test.mjs call 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 the settle() 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 amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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:70 makes 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 — waitFor polls 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 in failopen.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.
  • waitFor moved to helpers.mjs is byte-identical to the copy removed from failopen.test.mjs. helpers.mjs already imports assert (line 1). All three call sites in failopen.test.mjs (lines 358, 458, 520) keep working.
  • No settle() use remains in opencode-plugin/test/ (grep). No other file defines or imports a conflicting waitFor; signals.test.mjs has its own waitForRecord, 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 at tui.test.mjs:161 is sound.
    • The save path: onConfirm awaits runCommandScript(state, "context-guru-strategy", ["set", "none"]). The script writes settings.env with an atomic mv (index.js:705) before it exits, and runCommandScript (index.js:851-860) resolves only on child close. So the new waitFor at tui.test.mjs:169 either passes at once or covers a slow child. On failure it names what it waited for.
  • pending-timing-fixes.txt says "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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant