[PR #2712] [MERGED] fix(cli): refuse scenario steps on passive native UI observation #5335

Closed
opened 2026-10-31 01:05:49 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2712
Author: @kaoru0822-kitauji
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/issue-2674


📝 Commits (3)

  • 8fd0ecc fix(cli): refuse scenario steps on passive native UI observation
  • 6975210 Merge remote-tracking branch 'origin/main' into fix/issue-2674
  • 44ceceb Merge remote-tracking branch 'origin/main' into fix/issue-2674

📊 Changes

2 files changed (+130 additions, -80 deletions)

View changed files

📝 src/cli/utilityCommands.ts (+107 -80)
📝 tests/boundary/cli/nativeUiScenarioInputCli.test.ts (+23 -0)

📄 Description

Fixes #2674.

Problem

src/cli/utilityCommands.ts registered observe-native-ui and capture-native-ui-scenario in a single loop, with one shared option schema and one description ("Observe or run a scenario in one exact native application window"). As a result:

  • rea observe-native-ui --help advertised --steps <string> JSON array of declarative AX actions or waits.
  • The passive command accepted any --steps value, including non-JSON. It then dispatched observe_native_ui with only pid, window_id, screenshot, accessibility and max_nodes, silently dropping the steps.

A caller who picked the wrong command got a passive observation with no sign that their scenario never ran. The MCP contracts were already separate (nativeUiObservationInputSchema versus nativeUiScenarioInputSchema); only the CLI adapter merged them.

Fix

  • Each command is now registered against its own contract.
    • observe-native-ui declares only the shared passive scope options, so --steps is rejected by the CLI parser (Unknown flag: --steps) before any provider runs.
    • capture-native-ui-scenario keeps its JSON step decoding and nativeUiScenarioInputSchema validation unchanged.
  • The passive scope options and their mapping to contract parameters are defined once and shared.
  • Each command has its own description:
    • observe-native-ui — "Observe one already-running native application window by PID and window ID"
    • capture-native-ui-scenario — "Run declarative AX actions or waits in one exact native application window"

Validation

  • New boundary test, nativeUiScenarioInputCli.test.ts > refuses scenario steps on passive observation instead of dropping them, runs the real CLI: observe-native-ui … --steps '[{"kind":"wait","milliseconds":0}]' must fail with Unknown flag: --steps. It fails on main (the command accepted the flag) and passes here.
  • The existing scenario-input tests (missing steps, malformed JSON, empty steps) and NativeUiObservation.test.ts pass: 24 tests.
  • npm run check:fast, format:check and docs:check pass.
  • Not run: real macOS window capture, which needs an Accessibility-permitted app window.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2712 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/issue-2674` --- ### 📝 Commits (3) - [`8fd0ecc`](https://github.com/morluto/rea/commit/8fd0ecc18074066b6cc97ae061127c6e98449c64) fix(cli): refuse scenario steps on passive native UI observation - [`6975210`](https://github.com/morluto/rea/commit/69752104ff724c588ed6e74e65d7e9385777482f) Merge remote-tracking branch 'origin/main' into fix/issue-2674 - [`44ceceb`](https://github.com/morluto/rea/commit/44ceceb2242582c210b45fad1515f3a8164db661) Merge remote-tracking branch 'origin/main' into fix/issue-2674 ### 📊 Changes **2 files changed** (+130 additions, -80 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/utilityCommands.ts` (+107 -80) 📝 `tests/boundary/cli/nativeUiScenarioInputCli.test.ts` (+23 -0) </details> ### 📄 Description Fixes #2674. ## Problem `src/cli/utilityCommands.ts` registered `observe-native-ui` and `capture-native-ui-scenario` in a single loop, with one shared option schema and one description ("Observe or run a scenario in one exact native application window"). As a result: - `rea observe-native-ui --help` advertised `--steps <string> JSON array of declarative AX actions or waits`. - The passive command accepted any `--steps` value, including non-JSON. It then dispatched `observe_native_ui` with only `pid`, `window_id`, `screenshot`, `accessibility` and `max_nodes`, silently dropping the steps. A caller who picked the wrong command got a passive observation with no sign that their scenario never ran. The MCP contracts were already separate (`nativeUiObservationInputSchema` versus `nativeUiScenarioInputSchema`); only the CLI adapter merged them. ## Fix - Each command is now registered against its own contract. - `observe-native-ui` declares only the shared passive scope options, so `--steps` is rejected by the CLI parser (`Unknown flag: --steps`) before any provider runs. - `capture-native-ui-scenario` keeps its JSON step decoding and `nativeUiScenarioInputSchema` validation unchanged. - The passive scope options and their mapping to contract parameters are defined once and shared. - Each command has its own description: - `observe-native-ui` — "Observe one already-running native application window by PID and window ID" - `capture-native-ui-scenario` — "Run declarative AX actions or waits in one exact native application window" ## Validation - New boundary test, `nativeUiScenarioInputCli.test.ts > refuses scenario steps on passive observation instead of dropping them`, runs the real CLI: `observe-native-ui … --steps '[{"kind":"wait","milliseconds":0}]'` must fail with `Unknown flag: --steps`. It fails on main (the command accepted the flag) and passes here. - The existing scenario-input tests (missing steps, malformed JSON, empty steps) and `NativeUiObservation.test.ts` pass: 24 tests. - `npm run check:fast`, `format:check` and `docs:check` pass. - Not run: real macOS window capture, which needs an Accessibility-permitted app window. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:05:49 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5335
No description provided.