Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07aeefa9f3
ℹ️ 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".
| let mut depth = 0i32; | ||
| while pos < b.len() { | ||
| match b[pos] { | ||
| b'\\' => pos += 2, |
There was a problem hiding this comment.
Bound escape advances before slicing the destination
When a definition-shaped line ends with a single backslash, such as [x]: https://example.com/\, the bare-destination loop advances pos past the end of tail. The subsequent tail[start..pos] slice panics. This is reproducible with or without a final newline and makes the Markdown document fail to open through markdown_to_prosemirror. Handle a trailing backslash without advancing beyond the buffer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b260dc8 (task 14704, lane code-m): the bare-destination escape advance is now clamped at the buffer end, so a trailing backslash cannot panic the slice. Regression test: test_trailing_backslash_destination_does_not_panic. Full web::markdown suite: 276 passed.
| if raw[j..].starts_with("```") || raw[j..].starts_with("~~~") { | ||
| in_fence = !in_fence; |
There was a problem hiding this comment.
Recognize container prefixes before tracking code fences
For a fenced code block inside a blockquote, every fence line starts with >, so this check never enters in_fence. The later strip_container_prefixes call nevertheless exposes definition-shaped code such as > [x]: /url, which is collected and appended as a real top-level definition. Saving therefore adds content that was only literal code in the original document. Track fences using the container-stripped lines so quoted code cannot synthesize definitions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b260dc8 (task 14704, lane code-m): fence tracking in both the definition collector and the used-labels scan now runs on container-stripped lines, so fences inside blockquotes are tracked and quoted code cannot synthesize definitions. Regression test: test_link_reference_definition_in_blockquote_fence_not_synthesized.
| let dest = if url.is_empty() || url.chars().any(char::is_whitespace) { | ||
| format!("<{url}>") | ||
| } else { | ||
| url.to_owned() |
There was a problem hiding this comment.
Escape destination punctuation when emitting definitions
A valid unused definition such as [x]: <foo)> is collected with URL foo), but this branch writes it back as [x]: foo). The unmatched closing parenthesis is invalid in a bare destination, so reopening turns the preserved definition into ordinary paragraph text and it can no longer resolve reference links. Render destinations with appropriate Markdown escaping or safely escaped angle syntax, rather than selecting angle syntax only for whitespace and empty URLs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b260dc8 (task 14704, lane code-m): destinations that are empty or contain whitespace or ( ) < > backslash are now emitted in angle form with backslash escapes for the angle-unsafe characters, so the collected url round-trips exactly. Regression test: test_link_reference_definition_paren_destination_uses_angle_form.
| url: { default: "" }, | ||
| title: { default: null }, | ||
| }, | ||
| parseDOM: [{ tag: "div[data-link-ref-def]" }], |
There was a problem hiding this comment.
Preserve definition attributes through clipboard HTML
When a user cuts and pastes a definition atom in the rich editor, ProseMirror serializes it through toDOM and reparses the clipboard HTML through this rule. The rendered element carries no label, URL, or title attributes, and the rule has no getAttrs, so the pasted node receives the empty defaults and saving replaces the original definition with []: <>. Encode and recover all three attributes in the DOM representation, as the adjacent html_inline node does for its payload.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f342c4b (task 14704, lane code-m): toDOM now encodes label/url/title as data-link-ref-* attributes (mirroring html_inline) and the parse rule recovers them via getAttrs, so clipboard cut/paste preserves the definition. Caveat: bun run typecheck in pkgs/id/web currently fails before file checking on a pre-existing tsconfig error (baseUrl removed in the installed TypeScript); the change mirrors the adjacent html_inline pattern exactly.
| let Some(close) = close else { | ||
| i = open + 1; | ||
| continue; |
There was a problem hiding this comment.
Avoid rescanning unmatched bracket suffixes
When Markdown contains many unmatched opening brackets and at least one reference definition, each failed match restarts at the next [ and rescans the remaining document, making the new preservation pass quadratic. An optimized build of these helpers took 43 ms for 10,000 brackets, 690 ms for 40,000, and 2.81 seconds for 80,000 using input consisting of repeated [ characters followed by a blank line and [x]: /url. Avoid restarting the full suffix scan for each unmatched opener so modest bracket-heavy files do not stall document loading.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b260dc8 (task 14704, lane code-m): bracket matching is precomputed in one stack pass (same pairing the depth scan found) and the second-bracket scan uses a precomputed next-close table, so unmatched brackets no longer rescan the suffix per opener. Regression test: test_many_unmatched_brackets_still_preserve_definition (5000 unmatched brackets; the whole 276-test markdown suite runs in 0.05s).
|
agent-note:v1 Shepherd triage on PR #7170 (task 14704, lane code-w): the PR is REAL and still needed — issue #1004 is OPEN (definitions-only documents save as empty files) and no equivalent fix is on main — but it cannot be finished responsibly in this shift's remaining window. Parking with the full work inventory so the next shepherd starts from evidence: REBASE (probed 2026-11-11): merging current origin/main conflicts ONLY in pkgs/id/src/web/markdown.rs (pkgs/id/web/src/editor.ts merges clean). Probe worktree was aborted; the branch is untouched at 07aeefa. CODEX FINDINGS — all five verified present on the PR and undispositioned; each needs a fix (or a reasoned rebuttal) before merge:
RESUME PLAN: resolve the markdown.rs merge, fix 1-5 with regression tests in the PR's existing test module, run cargo test -p id --lib web::markdown (expect a long first compile; heartbeat through it), push, reply to each Codex thread, then merge when CI is green or park as a CI wait. Task 14704 parked 3600s. |
…ation pass (#7170) P1: clamp the bare-destination escape advance at the buffer end so a trailing backslash cannot panic the destination slice. P2: track fences on container-stripped lines in both the definition collector and the used-labels scan, so definition-shaped lines inside quoted code are not synthesized as definitions. P2: emit destinations containing whitespace or ( ) < > backslash in angle form with escapes, so a collected <foo)> round-trips as a definition. P2: replace the per-opener bracket rescan with a one-pass stack match plus a next-close table (was quadratic on unmatched brackets). Four regression tests added; cargo test --lib --features web web::markdown: 276 passed. Rebase fallout vs current main: main added its own strip_container_prefixes (superset: blockquote + list markers) and a different collect_link_reference_definitions for #1565 footnote synthesis after this branch was cut; the PR copies are removed/renamed (scan_link_reference_definitions) to resolve the duplicate definitions.
Pre-existing break on current main under the web+world feature combination (web implies world): serve.rs referenced _started_server_config, which does not exist; the compiler names started_server_config. This blocked every web-feature build, including the #7170 markdown tests. One-token fix, separate commit for easy revert.
…ipboard HTML (#7170) Codex P2: the atom toDOM carried no label/url/title and the parse rule had no getAttrs, so cut/paste reparsed the definition with empty defaults and saving replaced it with []: <>. Encode all three attributes as data-* in toDOM (mirroring html_inline) and recover them in getAttrs. Note: bun run typecheck in pkgs/id/web currently fails on a pre-existing tsconfig error (baseUrl removed in the installed TypeScript) before any file is checked.
07aeefa to
f342c4b
Compare
|
Shepherd complete — ready to merge (task 14704, lane code-m) State: merge_ready. PR #7170 was rebased onto current main (2103e06) — the markdown.rs conflict was a union of the #1565 footnote recovery and this PR's #1004 link-reference recovery, both kept. All five Codex findings are fixed and each review thread has a reply naming the commit and regression test:
Rebase fallout, disclosed: main added its own strip_container_prefixes (superset) and a different collect_link_reference_definitions for #1565 after this branch was cut; the PR copies were removed/renamed (scan_link_reference_definitions). Also, current main has a pre-existing web+world build break (serve.rs referenced _started_server_config); fixed as a separate one-token commit de759ec so the web-feature tests can run at all — easy to revert independently. Verification: cargo test --lib --features web web::markdown on the laptop — 276 passed, 0 failed (includes the four new regression tests). pkgs/id/web typecheck is currently blocked by a pre-existing tsconfig error (baseUrl removed in the installed TypeScript) before any file is checked. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f342c4bfd4
ℹ️ 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".
| let stripped = strip_container_prefixes(raw); | ||
| let Some(rest) = stripped.strip_prefix('[') else { |
There was a problem hiding this comment.
Check block context before recovering a definition
For input such as Body text\n[x]: /url\n, the second line continues the paragraph rather than defining a reference. This scanner nevertheless collects it and appends a link_reference_definition node, so saving adds a real definition alongside the original paragraph text. Definition-shaped lines inside HTML comments are similarly promoted. Check block-start eligibility and HTML context before collecting candidates; the existing collect_link_reference_definitions helper already tracks these distinctions.
Useful? React with 👍 / 👎.
| if fence_line[j..].starts_with("```") || fence_line[j..].starts_with("~~~") { | ||
| in_fence = !in_fence; |
There was a problem hiding this comment.
Match closing fences against the opening delimiter
When a four-backtick fenced block contains a three-backtick line followed by [x]: /url, the shorter run is literal code, but this toggle treats it as the closing fence. The scanner then collects the code's definition-shaped line and saving appends it as a real top-level definition. A tilde run inside a backtick fence has the same problem. Track the opening delimiter character and run length, preferably using the existing FenceTracker, and apply the same correction to the usage scanner.
Useful? React with 👍 / 👎.
| // Shortcut reference: a usage only when the label is defined. | ||
| mark_used(&mut used, normalize_link_label(&inner)); |
There was a problem hiding this comment.
Exclude literal regions from reference-usage detection
For [x]\n\n[x]: /url\n, the bracketed text is indented code, but this scan marks x as used and the preservation loop consequently discards its unused definition. HTML comments containing [x] and inline-link destinations such as [actual](https://example.com/[x]) also produce false usages. Exclude these literal contexts, or determine usage from resolved parser links, so saving retains definitions that no actual reference link consumes.
Useful? React with 👍 / 👎.
| match parse_link_ref_tail(&tail) { | ||
| TailParse::Parsed { url, title, end } => { | ||
| break Some((url, title, tail[..end].matches('\n').count())); |
There was a problem hiding this comment.
Look ahead for a title before accepting a destination-only line
For a valid unused definition such as [x]: /url\n "The Title"\n, parsing the first line already returns Parsed, so this branch stops before inspecting the following title line. Comrak consumes both lines as a definition, leaving no paragraph containing the title, while the recovered atom has title: null; saving therefore silently removes the title. Inspect the following line for a valid title before finalizing a destination-only definition, and include that line in the definition's recorded range.
Useful? React with 👍 / 👎.
| let line_text: Vec<&str> = lines | ||
| .iter() | ||
| .map(|l| l.strip_suffix('\n').unwrap_or(l)) |
There was a problem hiding this comment.
Strip CRLF endings before parsing definition lines
For Windows-style input such as [x]: /url "Title"\r\n, removing only \n leaves a trailing \r, which parse_link_ref_tail rejects after the closing title quote. Comrak consumes the valid definition, but recovery finds nothing, so saving deletes it. Untitled bare destinations instead absorb the carriage return into the URL because the destination loop does not treat it as whitespace. Strip the complete CRLF line ending before passing each line to the tail parser.
Useful? React with 👍 / 👎.
|
Parked — CI wait (task 14704, lane code-m) State: parked (CI pending on PR #7170 @f342c4bfd4). All work is done and pushed: rebase resolved, five Codex findings fixed with regression tests and thread replies, local verification 276/276 web::markdown tests pass. PR checks were still QUEUED/IN_PROGRESS after the polling window (no failures). Resume: when PR #7170 checks are green, merge it, confirm issue #1004 closes, and complete task 14704 with outcome fixed_merged. If checks fail, read the failing check first — the id-relevant one is covered locally; the serve.rs commit de759ec is a separate pre-existing main break fix and can be reverted independently if it is implicated. |
|
Closed as superseded by merged canonical PR #5949. Fresh content-level comparison found no unique behavior to salvage; the comparison and reason are recorded on #5949 in the salvage note posted immediately before this close. PR #7170's independent scanner/ProseMirror-node approach duplicates the already-landed #5949 behavior and is not carried forward; its separate serve.rs correction is already present on main. Issue #1004 was closed by #5949. No archive branch was deleted. |
Opened by the branch-disposition execution (2026-11-07) from branch
queue/4638-1004-link-ref-defs.Branch origin: queue branch for issue #4638.
This branch was laptop-local work (or a stranded remote branch) with real changes ahead of
mainand no PR. Per Drew's 2026-11-07 branch-disposition ruling, ahead branches with real changes get a PR; this PR surfaces the work for triage instead of leaving it stranded on a branch.Triage owner: batch issue in developing-today/code, "Unowned PR batch from branch disposition (2026-11-07)". Outcome per batch triage: close with reason, or route to impl/finish/merge as a follow-on fix task.
Evidence: branch-ahead review
~/workspace/scratch/branch-ahead-review-2026-11-07.md; execution log~/workspace/scratch/branch-disposition-2026-11-07.md.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.