[PR #1085] [MERGED] fix(browser): advertise zero-based units for runtime source coordinates #2633

Closed
opened 2026-10-17 21:08:26 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/web-runtime-location-units


📝 Commits (4)

  • 5c8eb02 fix(browser): advertise zero-based units for runtime source coordinates
  • c61715c fix(browser): describe runtime positions relative to the enclosing resource
  • e8e48b0 Merge remote-tracking branch 'origin/main' into fix/web-runtime-location-units
  • 9b49cc5 docs(browser): clarify runtime-to-source coordinate conversion

📊 Changes

3 files changed (+55 additions, -5 deletions)

View changed files

📝 docs/web-runtime.md (+3 -1)
➕ src/domain/webRuntime.test.ts (+34 -0)
📝 src/domain/webRuntime.ts (+18 -4)

📄 Description

Problem

inspect_web_event_listeners and observe_web_execution return CDP source coordinates without converting them: listener location, request callsites and script resource_start line_number/column_number. These are zero-based lines and zero-based UTF-16 columns. The advertised output schemas and docs/web-runtime.md never say so. Only a code comment on the Zod schema mentioned it.

Sibling browser tools state their units. observe_web_execution coverage carries offset_units: "utf16-code-units", and trace_web_source_location documents and takes one-based lines. A caller chaining a listener location into trace_web_source_location therefore lands one line early.

I observed this on a headless Chromium 155 page served from loopback. The click listener on app.js line 2 (1-based), column 57, came back as {"line_number":1,"column_number":56}, with no unit information in the result or schema.

Change

  • Add .describe() text to webRuntimeLocationSchema.line_number/column_number and webRuntimeSourceSchema.resource_start. Positions are zero-based lines and UTF-16 columns in the script's enclosing resource: the script file for an external script, or the HTML document for an inline <script>. resource_start is where the script text starts in that resource. Both tools' advertised outputSchemas carry these descriptions; I checked this with an MCP listTools probe.
  • docs/web-runtime.md gives the conversion for trace_web_source_location, which takes one-based, script-relative lines. For an external script, add one to the line. For an inline script, first subtract resource_start (and its column on the script's first line), then add one.
  • Values are unchanged. Only descriptions are added to the output schema, and npm run docs:generate produced no generated-file changes.

I verified the inline case against real headless Chromium 155: a listener on HTML line 6 of an inline script (whose <script> is on line 4) returned location {line_number: 5, column_number: 58} with resource_start {line_number: 3, column_number: 8}.

Verification

  • npm run test:focused -- src/domain/webRuntime.test.ts tests/acceptance/webRuntimeCli.test.ts: passed. The new contract test fails without the schema change.
  • npm run check:fast, npm run docs:check
  • Ran rea inspect-web-event-listeners and rea observe-web-execution against a loopback page in headless Brave (Chromium 155). Values are unchanged, and the advertised schemas now carry the unit descriptions.

No real Hopper or Ghidra verification was run, because this change does not touch those providers.

🤖 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/1085 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/web-runtime-location-units` --- ### 📝 Commits (4) - [`5c8eb02`](https://github.com/morluto/rea/commit/5c8eb029d4951d22312f99f0979896c95b8fcf04) fix(browser): advertise zero-based units for runtime source coordinates - [`c61715c`](https://github.com/morluto/rea/commit/c61715cdf8d10cd391f149648b4e027de2cdb0fa) fix(browser): describe runtime positions relative to the enclosing resource - [`e8e48b0`](https://github.com/morluto/rea/commit/e8e48b0e166c30401919fdcebdbfe7856424b192) Merge remote-tracking branch 'origin/main' into fix/web-runtime-location-units - [`9b49cc5`](https://github.com/morluto/rea/commit/9b49cc57105af34790ead35c31c720ddb6729238) docs(browser): clarify runtime-to-source coordinate conversion ### 📊 Changes **3 files changed** (+55 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/web-runtime.md` (+3 -1) ➕ `src/domain/webRuntime.test.ts` (+34 -0) 📝 `src/domain/webRuntime.ts` (+18 -4) </details> ### 📄 Description ## Problem `inspect_web_event_listeners` and `observe_web_execution` return CDP source coordinates without converting them: listener `location`, request `callsites` and script `resource_start` `line_number`/`column_number`. These are zero-based lines and zero-based UTF-16 columns. The advertised output schemas and `docs/web-runtime.md` never say so. Only a code comment on the Zod schema mentioned it. Sibling browser tools state their units. `observe_web_execution` coverage carries `offset_units: "utf16-code-units"`, and `trace_web_source_location` documents and takes **one-based** lines. A caller chaining a listener location into `trace_web_source_location` therefore lands one line early. I observed this on a headless Chromium 155 page served from loopback. The click listener on `app.js` line 2 (1-based), column 57, came back as `{"line_number":1,"column_number":56}`, with no unit information in the result or schema. ## Change - Add `.describe()` text to `webRuntimeLocationSchema.line_number`/`column_number` and `webRuntimeSourceSchema.resource_start`. Positions are zero-based lines and UTF-16 columns in the script's **enclosing resource**: the script file for an external script, or the HTML document for an inline `<script>`. `resource_start` is where the script text starts in that resource. Both tools' advertised `outputSchema`s carry these descriptions; I checked this with an MCP `listTools` probe. - `docs/web-runtime.md` gives the conversion for `trace_web_source_location`, which takes one-based, script-relative lines. For an external script, add one to the line. For an inline script, first subtract `resource_start` (and its column on the script's first line), then add one. - Values are unchanged. Only descriptions are added to the output schema, and `npm run docs:generate` produced no generated-file changes. I verified the inline case against real headless Chromium 155: a listener on HTML line 6 of an inline script (whose `<script>` is on line 4) returned `location {line_number: 5, column_number: 58}` with `resource_start {line_number: 3, column_number: 8}`. ## Verification - `npm run test:focused -- src/domain/webRuntime.test.ts tests/acceptance/webRuntimeCli.test.ts`: passed. The new contract test fails without the schema change. - `npm run check:fast`, `npm run docs:check` - Ran `rea inspect-web-event-listeners` and `rea observe-web-execution` against a loopback page in headless Brave (Chromium 155). Values are unchanged, and the advertised schemas now carry the unit descriptions. No real Hopper or Ghidra verification was run, because this change does not touch those providers. 🤖 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-17 21:08:26 +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#2633
No description provided.