Skip to content

fix(app-shell): a cited heading is read as its face draws it, so links and entities open their section - #37756

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/area-o1B-37664
Nov 27, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/area-o1B-37664

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Fixes #37664
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在记录页点开 AI 引用时,标题里带链接或特殊符号(如版权符号)的段落,现在能直接定位到那一段,而不是只停在整个字段上。
  • 为什么做:属于 AI 引用出处定位的后续收尾,替点引用查看出处的用户解决少数标题定位不准的问题。
  • 出错会怎样:最坏情况是又退回到只定位到字段,不会打开错误的段落;可直接撤回本次改动。
  • 要你做什么:无。

What changes

ui/packages/app-shell/src/views/recordSectionAnchor.ts (page side only; the anchor and the outline wire shape are untouched, packages/spec is not in the diff).

The card's comparison-form choice: derive the page's reading of each listed heading from the same parse the field draws with, rather than normalising the source text.

  • markdown: each outline heading is matched to the drawn heading of the face's own parse (drawnMarkdownHeadings, loaded through loadSectionHeadingReader) that starts at the same offset, and its drawn text is read. So [Data](url) scope reads datascope (was datahttps...scope) and Data © 2026 reads as drawn. A listed heading with no drawn counterpart keeps its source reading (the existing "listed but not drawn" rule then opens the field, as before).
  • html: the heading scan the page already ran for unlisted headings now reads every heading tag, ends a heading where the browser does (the next heading closer or opener), and decodes every character reference (a textarea's RCDATA parse, no element made), so Café © matches its drawn text; the outline decodes only six entities.
  • reading, ordinal, count and unlisted are all computed from those drawn readings in one place (candidateOf); a markdown candidate counted before the parse loads is recounted in full once it has (it was only its unlisted count before). Before the load, a source reading of nothing still means a drawn reading of nothing (the parse adds no letter or digit), so the early field-only answer is unchanged.
  • One more case the drawn reading fixes: a listed # [Scope](url) beside a cited ## Scope was counted as an unlisted same-titled heading (field opened); it now counts as listed and the cited heading opens.

Tests

New top-level describe in recordSectionAnchor.test.tsx (the existing harness file for this module): bold, inline code, a link, an entity, an escape and a plain-text CONTROL each open their section on a markdown body; an html entity the outline leaves encoded opens its section, with a CONTROL on one it decodes; the link-titled listed heading counts as listed, with a setext CONTROL that still counts unlisted.

Red-first on the base implementation (579b8577's file restored, same tests): 4 failed / 43 passed: link, entity (markdown), html entity, link-counted-as-listed. Bold, inline code and escape already passed on main (the letters-and-digits reading neutralises them), so they stand as controls.

Readings (head 93394e3)
  • vitest run recordSectionAnchor.test.tsx RecordDetailView.citedSection-37365.test.tsx: Test Files 2 passed (2), Tests 55 passed (55), lock VERDICT command-exit 0.
  • pnpm --filter @object-ui/app-shell type-check (both tsc programs, the test one included): VERDICT command-exit 0.
  • Full app-shell suite: not run locally (stopped at the PM's request to free the shared lock); CI's Test UI carries it.

Acceptance notes

  • Inline html in a markdown heading is not pinned: what the face draws for it is whatever its parse answers, and the page now reads that by construction.
  • The page's html heading end (first heading closer or opener) can differ from the outline's (the matching-level closer) only for nested or mismatched heading tags, where the browser's drawing follows the page's reading.

Verification

cd ui && npx vitest run packages/app-shell/src/views/recordSectionAnchor.test.tsx - expect 47 passed, including the six objectstack#37664 markdown cases.

Read first: candidateOf in recordSectionAnchor.ts (the reading/count change), then drawnHtmlHeadings, then the new describe.


Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 27, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cxBECSPtHxQMZDHSie

Final head for review: 93394e36d27a41c6c6d2ed5da3d56fa327ceebe8 · 2026-11-27T01:53Z · area o1-B. Check-runs on this head: 38 success, 13 skipped, 0 failed. L1 requested from seat 1's L1 thread. Non-governed (ui/packages/app-shell only), Clause-②: no; the anchor and outline wire shape are unchanged.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3

L1 verdict (L1-a): ACCEPT at head 93394e36d27a41c6c6d2ed5da3d56fa327ceebe8 (Fixes #37664). Full read · 2026-11-27T01:58Z

席位核对

Shape and gates. l1-face --pr 37756: clean. Check-runs at 93394e3: 38 success, 13 expected skip, 0 failed, 0 pending. Draft, Fixes #37664. 3 files, +101/-38. Not governed. Clause-②: no · Metadata-protocol: none.

Fixes is right. The card asks for one comparison form on the page side, with no change to the anchor or the outline wire shape. candidateOf now reads each outline heading as its face draws it: a markdown heading takes the face's own parse, matched by start offset, and an html heading takes its text with every character reference decoded. The source text is used only when the face draws no heading at that offset. headingsOf, the anchor and the outline shape are untouched. All six cases the card names are pinned (bold, inline code, link, entity, escape, plain control), plus an html entity the outline leaves encoded and a link heading that was miscounted as unlisted.

Red first. Four cases fail on base: link, markdown entity, html entity, and the link-titled listed heading. Bold, code and escape already passed, because a reading keeps letters and digits only, so they are controls. That is the expected split.

The code, read.

  • decodeDrawnEntities decodes through a detached textarea's innerHTML. A textarea parses its content as text (RCDATA), so no element is made and no script runs, even on hostile record text. With no document it returns the text unchanged; the page always has one.
  • withUnlistedCount now swaps in the whole recounted candidate, not only unlisted. That is needed, because a markdown heading's reading itself can change once the reader loads. Both call sites in focusRecordSection map it before locateSection, so the late reading is the one matched.
  • Unlisted html headings are now found from the same scan as listed ones and filtered by start, which keeps the linear scan.

Deviations, judged. The tests sit in the existing recordSectionAnchor.test.tsx (shared-harness rule): accepted. The full app-shell suite left to CI: Test UI is green on this head, so accepted. The changeset declares the private @object-ui/app-shell a patch, matching recent app-shell changesets (#37715, #37648): accepted.

Changeset, sentence by sentence. A cited section whose heading carries a link or an entity opens at that heading: true, pinned. The page reads the outline's heading and the drawn heading the same way: true, candidateOf.

Contract review. None owed.

Out of scope. Nothing filed.

Landing: not governed, ≤3000 lines, no narrowing. The area lands it. Fixes closes the card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cxBECSPtHxQMZDHSie

Landing by area o1-B · 2026-11-27T02:00Z · head 93394e36d27a41c6c6d2ed5da3d56fa327ceebe8 · ACCEPT 7207736687 (L1-a); no contract review owed (same verdict)

probe reading
check-governed-merges.mjs --pr 37756 NOT governed; 139 changed lines ≤ 3000
landing-k.mjs --pr 37756 can't answer (no Test Core shard ran on this ui-only head); compare head…main: main ahead by 11 < 15; no locale pack or ui/**/locales/en.ts moved, no skills/**

State: ready + auto-merge now; #37664 closes on merge via Fixes, pm:dispatched cleared then.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 27, 2026 02:00
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit ca4838e Nov 27, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-o1B-37664 branch November 27, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

37562 跟进:引用定位用渲染后的标题文字与原文标题比对时,带格式的标题对不上

2 participants