Skip to content

fix(shared): send inline-code examples of context links literally - #46723

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-9b459fff9f
Dec 1, 2026
Merged

juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-9b459fff9f

Conversation

@saphid

@saphid saphid commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Problem

When a user shows a context link's syntax inside inline code, the provider receives a rewritten marker and an extra unavailable context entry instead of the code example. The scanner skips closed fenced blocks but not inline code spans.

Deterministic repro on origin/main (8eac85d87ce9): send a turn with the text Show the literal syntax: `[example](t3-context://v1/file/demo)` and no context records. ProviderTurnStartService.ts:1353-1359 builds the provider text with projectComposerContextForProvider({ text, records: [] }) from packages/shared/src/composerContextReferences.ts. A normal send then passes that string on as message.text (ProviderTurnStartService.ts:2541-2554). Codex makes it the text input item (CodexAdapterV2.ts:4265-4266) and sends it with turn/start (CodexAdapterV2.ts:8375). This repro has no attachments and no handoff, so nothing in between removes the marker or the envelope.

  • Observed: Show the literal syntax: `[File: example; ref=demo]` followed by a <t3_context version="1"> envelope that contains <context kind="file" id="demo" unavailable="true"/>.
  • Expected: the input comes back unchanged. The same link written outside backticks is still projected.

Change

fencedCodeRanges takes an optional inline flag. With the flag set, it also returns remark inlineCode ranges, using the same BOM offset and walk. The collector still collects only closed fences, with the same triple-backtick fast path. Provider projection now sends a link literally, with no envelope entry, when the link sits entirely inside inline code and no record is bound to its id. A chip the user wrapped in backticks still carries its record, and a backtick inside a chip label cannot hide that chip. Web, desktop, mobile and CLI prompts all go through this shared projection.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md. Production diff: 16 added and 9 deleted lines (git diff --numstat, whitespace counted). The marker callback gets a ternary. Passing filtered occurrences into replaceComposerContextReferences instead would mean a third argument after the inline callback, and the formatter would then re-indent the whole call (checked with vp fmt). That would cost more lines than the ternary.

Verification

  • New case keeps inline-code context link examples literal while projecting prose references in packages/shared/src/composerContextReferences.test.ts. It covers the inline example, a prose control, two cases with a backtick in a chip label, and a bound chip inside backticks.
    • Base 8eac85d87ce9: fails. expected 'Show the literal syntax: [File: exam…' to be 'Show the literal syntax: [example](t…', and the received text includes the unavailable="true" envelope.
    • Head: passes; the full file passes 47/47.
  • vp run check:changed exit 0 on HEAD 7c9750b72335 (format, lint, knip, typecheck, affected tests). The summary is in the gist below.
  • Node before/after transcript of projectComposerContextForProvider covering the example, the prose control and the bound chip, plus the path to the provider request and the check:changed summary: https://gist.github.com/saphid/56906a2955f5130b43534ea20117f9d2

Not shown: no turn was sent to a real or Replay provider, no scenarios:prove fixture was run, and the composer was not checked in a real client. The path to the provider request is traced from the source above rather than captured from a live request.

Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • .github/pull_request_template.md:27 — ADVISORY: The evidence gist contains the before/after transcript but not the claimed check:changed summary for 7c9750b72335. Attach the summary or say that the exit status is reported but its log is not linked.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 1, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Dec 1, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b47521e

Macroscope's review found this PR approvable — Inline-code examples of unbound context links now reach providers literally instead of becoming context markers. Attached context retains its existing behavior, keeping the change narrowly scoped to prompt formatting.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change detects inline-code ranges during provider projection. Unbound references inside inline code remain literal and are excluded from envelope entries. References with matching records continue to use provider markers.

Changes: Inline-code context references

Layer / File(s) Summary
Inline-code range detection
packages/shared/src/composerContextReferences.ts
codeRanges can include inline-code node ranges when enabled. Reference collection uses the helper without enabling inline-code ranges.
Provider projection and tests
packages/shared/src/composerContextReferences.ts, packages/shared/src/composerContextReferences.test.ts
Unbound references inside inline code remain unchanged and are excluded from envelope entries. References with matching records continue to use provider markers. Tests cover inline-code references, chip labels with backticks, and wrapped chips with attached mention records and paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge, stienswout

Merge Risk: Minimal · up to b4752

This change keeps context-link examples written in inline code from being rewritten, while links in normal prose are still projected. No merge-blocking risk is evident from the supplied evidence.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(shared): send inline-code examples of context links literally" names the main change: projection leaves unbound context links inside inline code as literal text. It follows the conventi…
Description check Passed The description covers the problem, the change, scope, and verification. It has a clear repro on the base commit, names the affected files, and explains why no issue is needed. Its Problem, Change, Sc…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(shared): send inline-code examples of context links literally" names the main change: projection leaves unbound context links inside inline code as literal text. It follows the conventional commit format and matches the raw summary and PR objectives. It is 65 characters, within a typical length.

Full details: Description check

Explanation

The description covers the problem, the change, scope, and verification. It has a clear repro on the base commit, names the affected files, and explains why no issue is needed. Its Problem, Change, Scope, and Verification sections map to the template. The Verification section is detailed and states what was not checked. The description gaps are minor. The check:changed summary is not attached or linked to a log, which the template asks for in the evidence. The template also asks for the model and harness used. The author lists Claude Opus 5.5 as the author, so the template's model line is present. The reviewer's "Not shown" note flags the missing summary log.

Resolution

Optional: attach the vp run check:changed log, or state that only the exit status is reported and its log is not linked. The description otherwise meets the template.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bc0c147 and b47521e.

Files selected for processing: 1

  • packages/shared/src/composerContextReferences.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 1, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review December 1, 2026 11:22

Dismissing prior approval to re-evaluate b47521e

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Real web app, Chromium at 1280×800 CSS pixels (scale 2), light theme, fresh synthetic state per commit. Sent the inline example [example](t3-context://v1/file/demo) inside backticks, then the same link in prose as a control. A transparent recorder forwards every frame unchanged to the repository's existing Replay (dev) agent; replies are recorded fixtures, not evidence of model reasoning.

Base rewrites the inline example and appends an unavailable context envelope. Head forwards the complete inline message byte for byte with no envelope. The prose control projects normally on both sides. Screenshots were stable across two captures at least 500 ms apart.

Before After
97d727c236 b47521ef35
Before: literal user bubble differs from provider input After: literal input preserved; prose control still projects
Before recording After recording
Observed provider input before Observed provider input after

Seed and transparent recorder · Browser driver and exact reproduction · Attempted scenario

The scenario reached the bug but encountered model-catalog and evidence-view navigation/timing races; after three driver corrections, the final evidence above was captured manually on both commits.

Not shown:

  • Attached-record chips wrapped in backticks were not exercised; this comparison covers unbound inline examples and prose references.
  • Native desktop/mobile clients and Claude's generated answer were not exercised; the proof observes shared projection through the real web app and existing replay provider.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 1, 2026
@juliusmarminge
juliusmarminge merged commit e5528df into pingdotgg:main Dec 1, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants