Skip to content

Studio: stop dropping the page text after a menu with no closing tag - #13489

Merged
danielhanchen merged 14 commits into
unslothai:mainfrom
NilayYadav:html-skip-implicit-close
Oct 13, 2026
Merged

danielhanchen merged 14 commits into
unslothai:mainfrom
NilayYadav:html-skip-implicit-close

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

When the model fetched a page whose menu or footer is closed by the end tag of the element around it, instead of its own end tag, Studio dropped everything after that menu. Every go.dev page (Effective Go, the language spec, the install guide, the tutorials, the downloads page) came back as "(page returned no readable text)", so the model could not read Go's official docs at all. Browsers close the menu at that point and show the rest of the page.

Skipped page parts such as navigation, footers, icons and buttons now also end when the element that contains them ends, the same way browsers read the page. The skipped parts stay out of what the model reads, and pages whose menus close normally convert exactly as before.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T16:22:17.312108Z bbe1e5c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

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

Review + reproduction evidence

Pinned review: 574aa89c518f6fdd52a0f86955eca979fed9c3da. 4 findings, fixed in 52c9826 and 574aa89; 2 minor items open (below).

I reproduced the bug in Studio chat on fresh upstream main (Linux, NVIDIA L4, Chrome 1440x900, Qwen3-4B-Instruct-2507 GGUF UD-Q4_K_XL, Search on): ask the model to read https://go.dev/doc/install with the web tool.

  • main 5f38afb: the tool card shows (page returned no readable text) (32 chars) and the model answers "The tool returned no readable text." Same for https://go.dev/doc/effective_go. Converting the saved pages directly: effective_go, ref/spec, doc/install, the getting-started tutorial and dl/ all come out as 0 chars.
  • PR head 574aa89: the tool returns the page (2757 chars, starting # Download and install), and the model quotes "Download and install Go quickly with the steps described here." Effective Go returns 16162 chars, cut to the fetch budget. The direct conversions come out at 102964 / 254099 / 2757 / 6071 / 1548626 chars.

PR 13489 before/after

  • Unchanged pages: docs.python.org and kubernetes.io return byte-identical tool output on main and head (15741 and 10684 chars). Across 68 saved real pages (Wikipedia, MDN, GitHub, Rust, Node, Hugging Face, news sites, readthedocs and others), each converted with and without main-content scoping, head matches main on every page except the go.dev ones.
  • Tests: test_web_fetch_extraction.py runs 1273 tests. The 8 new cases fail on main and pass on head; the rest pass on both.
  • Fixes pushed:
    • The first version made end-tag lookup inside a skipped subtree quadratic. With 10k <li> and stray </a> inside a <nav>, a conversion took 6.6 s on head against 0.09 s on main. The skip stack and the open-tag stack are now indexed, so the same input takes 0.09 s. Large real pages stay within 5% of main.
    • End tags from outside a <template> no longer reveal its inert content.
    • Regression tests cover both fixes.

Still open (minor, only on misnested markup, and no real page in the set above hits them): an end tag of an open ancestor ends the skip even when browsers keep the text inside the skipped element. This covers </form>, inline end tags such as </span>, </a> and </b>, a </div> crossing a <select>, and a table cell boundary. I checked each against the DOM in Chrome and WebKit. When that happens the leftover menu or option text shows up in the output; no page text is lost. The tight fix is to end the skip only on block and list end tags (div, li, ul, section, headings, table parts and similar) whose ancestor is in scope.

Conclusion: the bug is real and the fix works. Every go.dev doc page was unreadable to the model, and now it reads them; pages whose menus close normally convert exactly as before. Ready once CI is green on 574aa89. The misnested-markup item above can be a small follow-up.

@mahiatlinux mahiatlinux self-assigned this Oct 13, 2026
@mahiatlinux

mahiatlinux commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review/fix evidence

I reviewed this at merge base 5f38afbc2d, repaired the original PR branch, and pushed final head 91f64172cd (7d30d5aee0 scope fix, 3971008563 comment cleanup, a4d9d66fb1 recovery-state fix, 42b479b2d4 parser-context fix, c3893f10c9 start-tag recovery fix, 7435f1ec15 special-start/end recovery fix, 0de35080b6 remaining parser-context fix, and 91f64172cd paragraph/heading-scope fix).

Findings repaired

  • Kept suppression active for form, inline formatting, select, body, and table-scope end tags that do not pop the skipped element under HTML tree-construction rules.
  • Recovered only for structural end tags whose target is in the matching HTML parser scope, including mismatched-heading handling.
  • Unwound buffered descendants before closing a recovered ancestor, so blockquotes, preformatted text, links, and lists land in the correct main-content segment.
  • Tracked SVG and MathML scope barriers with namespace and HTML-integration context; HTML elements with lookalike names do not become foreign barriers.
  • Applied active scope checks to matching skipped roots, closed paragraphs before a skipped dialog, and ignored table-only recovery targets outside a real table context.
  • Completed paragraph-start recovery for center, dir, listing, search, and summary; reconciled caption/cell/row/section state before table-only starts; and applied browser-style nested-button recovery.
  • Kept nested SVG and MathML tokens in their foreign namespaces while recovering HTML buttons, including integration-point handling.
  • Matched scoped block, list-item, nested-form, datalist, heading, table, and caption recovery to browser tree construction, including paragraph button-scope barriers and mismatched heading ends outside suppression.
  • Preserved the standard's current-node rule for heading starts after a Chrome 153 DOM probe disproved a review claim that headings pop through an intervening inline element.
  • Added indexed open/skip-tag positions so recovery and malformed-tag handling remain constant-time per tag.
  • Added browser-derived regression cases for the scope boundaries above plus structural recovery, nested/template cases, and adversarial malformed input.

The first scope tests were run against the original PR head dfed759d1c; eight form/inline/select/table/body/heading cases failed there. Later negative controls failed 21 cases on 3971008563, 18 on a4d9d66fb1, 14 on 42b479b2d4, 22 on c3893f10c9, 16 on 7435f1ec15, and the four final paragraph/heading cases on 0de35080b6. These negative controls confirm the regressions exercise each repair.

Verification

  • studio/backend/tests/test_web_fetch_extraction.py: 1411 passed on final head.
  • Final paragraph/heading regression selection: 6 passed; four of those failed on the prior head while the browser-standard counterexample already passed.
  • Ruff: passed for the implementation and regression-test files; canonical formatter was rerun and byte-idempotent; git diff --check passed.
  • Supported-Python probes passed on CPython 3.9.25 and 3.14.4.
  • Chromium 153 DOM probes agreed with the recovery matrix for form, formatting, anchors, select, body, table scope, structural blocks, lists, cells, mismatched headings, paragraph button scope, caption-in-cell recovery, and HTML versus foreign nested buttons.
  • Adversarial 8x-input probes stayed about 7.9x in runtime, well below the 24x guard, and real-document benchmarks stayed in the same range as base/original head.
  • Exact live A/B: https://go.dev/doc/install produced 0 main-content characters at merge base and 2,757 at final head. The unaffected Python tutorial remained byte-identical at 13,753 characters and SHA-256 ccd64065588c... across base and final head.
  • Pure CPU parser path; no GPU/runtime-backend boundary is involved. Verified on Linux x86_64.

Studio before/after

The Studio UI was installed independently from the recorded merge base and pushed repaired head (explicit refs above). The same local model invoked the real web_search tool for https://go.dev/doc/install on both sides. Structured facts moved from no_readable_text to readable_page, 32 → 2,757 tool-result characters, and download-heading false → true. I opened the composite and confirmed it shows the expected visible change.

Studio before/after: Go fetch changes from no readable text to a readable Download and install Go result

The recovery rules were checked against the HTML parsing standard.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@mahiatlinux

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3893f10c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@mahiatlinux

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0de35080b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 13, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 13, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 13, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@unslothai unslothai deleted a comment from mahiatlinux Oct 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbe1e5c3f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1635 to +1639
self._skip_tags
and tag in _TABLE_ONLY_START_TAGS
and self._last_skip_position("table", "html") < 0
):
self._prepare_table_start(tag)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid reconciling foreign table tags as HTML cells

For <table><tr><td>Outer<svg><g><td>SVG SECRET</td></g></svg>Visible</td></tr></table>, the inner td remains in the SVG namespace because it is not a foreign-content breakout tag, so it should stay suppressed with the SVG. Here _in_table is true and there is no HTML table in _skip_tags, so this branch calls _prepare_table_start, which clears the SVG skip and closes the outer cell; SVG SECRET is emitted and the table layout is corrupted. Require the pending tag's skipped namespace to be html before performing table recovery.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Below the bar: an HTML start tag nested inside an inline within a table cell is not markup real pages ship; SVG has no td element.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: bbe1e5c3f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants