Skip to content

Add cross-platform debugger input control - #156

Closed
bjdodson-openai wants to merge 1 commit into
bjd/debugger-explicit-portfrom
bjd/debugger-input
Closed

Add cross-platform debugger input control#156
bjdodson-openai wants to merge 1 commit into
bjd/debugger-explicit-portfrom
bjd/debugger-input

Conversation

@bjdodson-openai

Copy link
Copy Markdown
Collaborator

Description

Adds bounded, target-scoped debugger input routing across the CLI, browser panel, runtime handler, and macOS text input path.

  • Generation-isolates deferred operations so input cannot cross targets or replaced elements.
  • Bounds direct-ID, selector, parent-chain, and virtual-tree traversal.
  • Adds multiline keyboard behavior and lifecycle cancellation coverage.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Documentation improvement
  • Performance optimization
  • Test improvement
  • Other (new debugger capability)

Testing

  • Tests pass locally (bazel test //...)
  • Added/updated tests for changes (if applicable)
  • Tested on multiple platforms (iOS/Android/Web/macOS as applicable)
  • Manual testing performed (describe below)

Testing Details

  • Incremental branch: CLI/browser 160/160 and runtime-handler 31/31 passed; macOS Objective-C syntax, TypeScript, ESLint, and formatting checks passed.
  • Assembled debugger stack: npm test passed 436/436; the CLI production build passed.
  • Focused //src/valdi_modules/src/valdi/web_renderer:test passed.
  • bazel query //... passed.
  • The broad Valdi suite reproduced the established 12 unrelated failures; all new debugger specs passed.

Checklist

  • Code follows project style guidelines
  • Documentation updated (if needed)
  • No breaking changes (or documented in description)
  • Commit messages follow conventional format
  • No secrets, API keys, or internal URLs included

Related Issues

Relates to #154

Additional Context

Stack 3/22. Stacked on #155 (bjd/debugger-explicit-port). Review this PR as the single incremental commit 7a4b9710 against that base; do not merge it before its parent.

@github-actions

Copy link
Copy Markdown

📊 PR Size: size/XL

Total changes: 6692 lines (28 files)

Top files changed:

  • src/valdi_modules/src/valdi/valdi_test/test/DebuggerInputMessageHandler.spec.ts: +1328 -0
  • src/valdi_modules/src/valdi/valdi_core/src/debugging/DebuggerInputMessageHandler.ts: +1232 -0
  • npm_modules/cli/src/core/packageFiles.spec.ts: +958 -1
  • npm_modules/cli/src/debugger/inputClient.ts: +505 -0
  • valdi/test/macos/SCValdiMacOSViewManagerTests.mm: +384 -0
  • npm_modules/cli/debugger/debugger-preview-html.js: +364 -16
  • valdi/src/valdi/macos/Views/SCValdiMacOSTextField.m: +268 -12
  • npm_modules/cli/src/debugger/inputClient.spec.ts: +279 -0
  • npm_modules/cli/src/commands/inspect_commands/input.ts: +225 -0
  • npm_modules/cli/src/commands/inspect_commands/input.spec.ts: +203 -0

...and 18 more files

Size calculated as additions + deletions. Labels: XS (<10), S (<50), M (<250), L (<1000), XL (1000+)

@github-actions github-actions Bot added the area/docs Documentation label Aug 26, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Bazel & CI Test Results

Test Suite Result
Valdi Smoke Tests ✅ success
API Surface Check ✅ success
Linux: C++ Tests ✅ success
Linux: Module Tests ✅ success
Snapshot Tests ✅ success
Test Coverage Delta ✅ success
Linux: Registry Validation ✅ success
Linux: Build Compiler ✅ success
valdi_web Integration Test ✅ success
macOS: C++ & Platform Tests ❌ failure
Linux: Build & Export ✅ success
Linux: Hotreload Smoke ✅ success

Some tests failed. Please check the workflow logs for details.

🚀 Bazel remote cache is now enabled - future builds will be faster!

Workflow: Valdi CI

@clholgat clholgat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of the cross-platform debugger input control. Overall this is solid: request/response validation is thorough, the debugger HTTP server enforces loopback Host/Origin/Sec-Fetch-Site checks, and the input handler is correctly gated behind runtime.isDebugEnabled. Two medium items are inline; one low is below.

NOTE: This 24-PR stack is being squashed into ~3 PRs — please carry this feedback into the squashed PR(s).

🟢 Low — valdi/src/valdi/macos/Views/SCValdiMacOSTextField.m (~L235-236): inside textDidChange:, the onWillChange replacement path reassigns both self.stringValue = replacementText and editor.string = replacementText while the field editor is active. Reassigning stringValue mid-edit can disturb the field editor / insertion state; the following selectedRange set mostly compensates but is fragile relative to the iOS reference path it replaces. Prefer updating only the field editor's contents while editing.

message: `Unsupported debugger input type '${request.type ?? ''}'.`,
};
} catch (error) {
if (error instanceof DebuggerTraversalFailure) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟠 Med — This catch converts only DebuggerTraversalFailure into a structured result and rethrows everything else, but the target app's own event handlers (onTap, onChange, onWillChange, onReturn, onWillDelete) are invoked inside this same try block. Any exception they throw escapes as a rejected messageReceived promise.

Failure: a component whose onChange throws turns a debugger text/tap request into an unhandled rejection in the runtime and a 5s client-side timeout instead of a clean error response.

Suggested fix: wrap the app-callback invocations (or the whole dispatch) so app-thrown errors are returned as { handled: false, message } rather than propagating.

const absoluteY = request.y === undefined ? position.y + tapTarget.element.frame.height / 2 : request.y;
const localX = absoluteX - position.x;
const localY = absoluteY - position.y;
tapTarget.callback({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟠 Med — tap invokes the resolved onTap unconditionally with no hit-test / visibility / bounds check, and the selector resolves against the entire render tree (collectElements from root, L533), so off-screen or occluded elements are reachable. Supplied x/y are passed straight through without validating they fall inside the element frame.

Failure: a debugger tap can fire a handler a real user could never reach — e.g. a destructive button covered by a modal, or an element scrolled off-screen — a scope escape beyond what a user can actually touch.

Suggested fix: validate the tap point against the element's absolute frame and skip elements that aren't hit-testable / visible.

@clholgat clholgat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of the cross-platform debugger input control. Overall this is solid: request/response validation is thorough, the debugger HTTP server enforces loopback Host/Origin/Sec-Fetch-Site checks, and the input handler is correctly gated behind runtime.isDebugEnabled. Two medium items are inline; one low is below.

NOTE: This 24-PR stack is being squashed into ~3 PRs — please carry this feedback into the squashed PR(s).

🟢 Low — valdi/src/valdi/macos/Views/SCValdiMacOSTextField.m (~L235-236): inside textDidChange:, the onWillChange replacement path reassigns both self.stringValue = replacementText and editor.string = replacementText while the field editor is active. Reassigning stringValue mid-edit can disturb the field editor / insertion state; the following selectedRange set mostly compensates but is fragile relative to the iOS reference path it replaces. Prefer updating only the field editor's contents while editing.

@bjdodson-openai

Copy link
Copy Markdown
Collaborator Author

Superseded by #180, which consolidates this patch into the reviewed debugger capabilities landing unit. The replacement carries forward the feedback and fixes discussed here. Closing this draft to reduce the active stack; this PR and its discussion remain the historical review record.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants