Skip to content

Add a scenario harness to test the apps against a real opencode server - #714

Merged
ivanfenenko merged 2 commits into
mainfrom
feature/scenario-harness
Oct 17, 2026
Merged

ivanfenenko merged 2 commits into
mainfrom
feature/scenario-harness

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

A local harness for running the iOS and Android apps against a real opencode serve (classic v1 or v2) where the only model is a scripted fake, so behaviour is repeatable and costs nothing.

  • Real server, scripted model (scripts/scenario-harness/): launches v1 (installed binary) or v2 (from an opencode checkout) in isolated data/config dirs against a throwaway git project. The fake OpenAI-compatible model plays the armed scenario, auto-answers title and summary/compaction requests, and routes calls by session id so subagent child sessions get their own scripts.
  • Fault proxy on :4096 for the apps: drop SSE, go offline, 401 everything or only event streams, stall, heartbeats-only, latency.
  • Web UI on :4500: arm or run scenarios and variants, answer asks and act as another client, inject faults, and watch app requests, server events and model calls on one timeline.
  • check.mjs: plays scenarios headless and reports model calls, tool states and event types per play.
  • 40 scenarios (13 P0, 17 P1, 10 P2) covering streaming, tool rows, permissions/questions answered in the app or from outside, subagents, retries, errors, aborts, reconnects, compaction, revert, rename, delete, concurrent sessions and unicode edge cases.
  • HarnessSeedTest (androidTest): seeds an Android Connection Profile via am instrument.
  • scenario-harness skill: setup, device seeding, control API, traps, and known app gaps.

No app code changes.

Verification

  • check.mjs --variants: 51/51 plays pass on v1 1.19.1, 50/50 on v2 dev (todo-list-progress is v1-only).
  • P0 scenarios run by hand on iOS (iPhone 17 simulator) and Android (Pixel 9a emulator) on both protocols; P1/P2 spot-checked on both apps.
  • On main: all modules load (node --check, 40 scenarios) and :app:compileDebugAndroidTestKotlin passes.

App gaps the harness found (not fixed here)

  • A subagent's permission doesn't set Needs approval on the parent Home row (both apps); iOS shows no card in parent or child.
  • v2 patch renders as a generic row on both apps (v1 apply_patch is fine).
  • A session deleted by another client stays open in Session Chat (both apps).
  • After an event-stream 401 the apps stay on "Authentication failed" after auth recovers (both apps, both protocols).
  • Revert from another client renders differently on iOS and Android.
  • v1 tool rows show absolute paths.

Usage

node scripts/scenario-harness/harness.mjs --protocol v1 --fresh

See .agents/skills/scenario-harness/SKILL.md or --help.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith with what you need.


Note

Low Risk
Adds dev/test tooling and androidTest seeding only; no production app or server runtime paths are modified.

Overview
Adds a scenario harness under scripts/scenario-harness/ so iOS and Android can be exercised against a real opencode serve (v1 or v2) with a scripted fake model instead of a paid provider.

The harness launches isolated server state and a throwaway git project, exposes a fault proxy on :4096 for apps (SSE drops, offline, auth faults, stall), and a web UI/control API on :4500 to arm or run scenarios, act as another client, and inspect traffic. check.mjs replays scenarios headlessly for CI-style verification.

40 scripted scenarios (P0–P2) cover streaming, tools, permissions, questions, subagents, errors, aborts, reconnects, and session lifecycle, with v1/v2 differences encoded in the scenario definitions. A small project-template and fixtures support tool scenarios (shell streaming, webfetch, patch).

Android-only test support: new HarnessSeedTest instruments a connection profile, worktree, and onboarding flags for emulator runs (documented in .agents/skills/scenario-harness/SKILL.md). No changes to production app code.

Reviewed by Cursor Bugbot for commit b865434. Bugbot is set up for automated code reviews on this repo. Configure here.

scripts/scenario-harness runs a real `opencode serve` (classic v1 or v2 from
an opencode checkout) whose only model is a scripted OpenAI-compatible fake,
puts a fault proxy in front of it for the apps, and serves a web UI to arm
scenarios, act as another client, inject SSE faults, and watch app requests,
server events and model calls on one timeline. check.mjs plays scenarios
headless and reports what each produced.

The catalog has 40 scenarios (13 P0, 17 P1, 10 P2): streaming, tool rows,
permissions and questions answered in the app or from outside, subagents,
retries and errors, aborts, reconnects, compaction, revert, rename, delete,
concurrent sessions and unicode edge cases. All plays pass headless on v1
1.19.1 and v2 dev.

HarnessSeedTest seeds an Android Connection Profile for the harness; the
scenario-harness skill documents setup, device seeding and known traps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b865434. Configure here.

Comment thread scripts/scenario-harness/client.mjs Resolved
Comment thread scripts/scenario-harness/check.mjs Resolved
Comment thread scripts/scenario-harness/proxy.mjs Resolved
…h exemption.

- Observer restarts clear the busy map and release idle waiters, so a protocol
  switch doesn't leave old sessions busy forever.
- check.mjs exits 1 when any non-skipped play fails, not only on timeouts.
- The all-requests 401 fault exempts every health probe (/global/health,
  /api/health, /api/info), so v1 and v2 behave the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit f64cc16 into main Oct 17, 2026
@ivanfenenko
ivanfenenko deleted the feature/scenario-harness branch October 17, 2026 13:29
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