Skip to content

fix: recover Markdown attachment file links through Files - #187662

Merged
shakkernerd merged 3 commits into
mainfrom
attachment-file-link-recovery
Oct 29, 2026
Merged

shakkernerd merged 3 commits into
mainfrom
attachment-file-link-recovery

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #187647.

What Problem This Solves

Following a relative file link in a Markdown attachment can leave the current conversation and open a missing-chat page. For example, an attachment containing [Read dependency report](snapshot-2/dependencies-v2.csv) navigated to /chat/main/snapshot-2/dependencies-v2.csv instead of opening a file or helping the user find it.

User Impact

Relative file links in a chat attachment now offer Browse files. The user chooses an accessible file from the existing Files catalog, while the conversation, original attachment tab and unsent message remain available. Cancel returns to the reference. Keyboard activation moves through the recovery controls into Files, and ordinary search can distinguish files with the same basename.

This is explicit file selection. The attachment does not acquire an inferred source folder or bundle relationship, and the current workspace file is not asserted to contain the bytes that existed when the attachment was sent. Existing source-bound workspace links, external URLs, fragment links and Download retain their behavior. There is no new file grant, storage representation or Gateway API.

Why This Change Was Made

Detached attachment previews have media identity but no authoritative source directory. Leaving their authored relative links as browser hrefs resolves them against the chat URL. The existing Markdown decorator now supports authored document links independently of prose scanning, allowing this reader to present a file action without guessing a target. Its explicit selection mode also accepts query-bearing relative URLs; source-bound readers retain their existing query behavior.

A narrow callback takes the user to the existing Files catalog. The catalog owner retains its previews and owns focus after the transition; its normal selected-row path and current session read authority still govern the eventual read. The attachment renderer holds only a temporary reference cue. Canonical chat documentation explains this distinction.

Evidence

The actual guest attachment-card Open route reproduced the missing-conversation navigation on the baseline. The owner regression failed specifically because the original anchor retained its relative href; the other 33 tests in that file passed. A real source-browser card/reader scenario also reproduced navigation for a relative URL with ?download=1; the corrected tree now keeps the query-free control and query-bearing destinations, including literal and encoded URLs inside query values, in the conversation and offers recovery.

The candidate live journey reached the existing Files catalog, explicitly selected the intended CSV, displayed its expected contents, and returned to the retained attachment without changing the conversation URL. Search showed two same-named CSVs separately, and deliberately selecting the other row displayed that row’s different contents. Cancel and an unmatched search issued no file read and retained the unsent message. External, fragment and original-download controls also passed.

Remote changed-file formatting, lint, English-copy verification and affected production/test types passed on the exact committed tree. All 25 related test files passed: 452 unit tests and 126 browser tests, including attachment recovery, catalog focus, source-bound links and existing read-failure/draft-retention controls. The runtime batch took 29.53 seconds. The regression allocation covers 79 net added test lines without changing the shared ceiling.

The committed-head live recording below exercises the recovery controls, catalog focus, explicit selection, expected CSV contents and return to the original attachment. It asserts that the conversation URL and unsent text survive and that only the selected row causes a file read. Query-specific behavior is additionally covered by the actual attachment-card/reader/router scenario.

Visual evidence

Open preview

Before After
Following the attachment link leaves a missing-conversation error Explicit Files selection opens the intended CSV beside the original conversation and retained attachment tab

Keyboard recovery, explicit file selection and return to the retained attachment

proof.mp4

Visual verification

  • Baseline: eb6ba5c
  • Exact head: 4a97fec5aac26f3c4741da2255ad9fa8097f72a5
  • Scenario: Activate a relative file link in an opened Markdown attachment, browse Files, select the intended CSV, then return to the attachment.
  • Runtime/build: UI 2026.10.8-4a97fec5aac2; Gateway 2026.10.8-9065e918c40b-2026-10-29T12-40-21.572Z; fresh document qualified before interaction
  • Capture framing: 1440×1000 browser, light theme, scale 1; identical 1130×900 crop excludes unrelated navigation and model controls.
  • File identity: Two same-named CSVs remain distinct; the selected snapshot-2 row opens its expected contents.
  • Authority and retention: No file read before explicit selection; conversation URL, unsent text and original attachment element preserved.
  • Actual attachment-card Open and keyboard activation on the exact committed UI
  • Catalog focus and keyboard search asserted; only the selected row caused a file read
  • Real Gateway and synthetic guest workspace; no inferred source directory or new file grant
  • Baseline and candidate share the same fixture and framing; compatible Gateway update left consumed file/media/session contracts unchanged

@shakkernerd shakkernerd self-assigned this Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M labels Oct 29, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Relative file links in Markdown attachments offer explicit selection through Files while retaining the conversation and attachment.

Example: Open index.md and activate Read dependency report.

  • Before: The browser navigates to /chat/main/snapshot-2/dependencies-v2.csv and displays a missing-conversation error.
  • After: Browse files opens the existing catalog, where selecting snapshot-2/dependencies-v2.csv displays its contents beside the retained conversation.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, source-supported repair with shipped-entry-point evidence, distinct regression coverage, and no identified merge-blocking defect.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The supplied exact-head live verification exercises the actual attachment-card Open route against a real Gateway and synthetic guest workspace, records recovery through Files and explicit CSV selection, and is supported by directly inspected before/after screenshots showing the resulting document beside the retained conversation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Following a relative file link in an opened Markdown attachment replaces the conversation with a missing-chat page.
Reason: The maintainer-authored direction provides useful in-product recovery without inventing attachment provenance, automatic matching, permissions, or configuration.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current attachment-navigation bug through the existing Files owner; no actionable introduced defect was found, and required CI remains in progress.

Priority: P2
Reviewed head: 4a97fec5aac26f3c4741da2255ad9fa8097f72a5

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Control UI attachment reader renders sanitized Markdown, intercepts authored relative references, and hands presentation back to the Files catalog; the existing selected-row path continues to own file reads.

flowchart LR
 A[Markdown attachment] --> B[Shared Markdown parser]
 B --> C[Relative reference action]
 C --> D[Browse files or Cancel]
 D --> E[Existing Files catalog]
 E --> F[Explicit row selection]
 F --> G[Existing session file reader]
Loading

Technical review

Best possible solution:

Use attachment-local recovery controls to reach the existing Files catalog, leaving target selection and authorized reads with their current owners.

Do we have a high-confidence way to reproduce the issue?

The linked report supplies an exact attachment fixture and failing route, and fetched-main source confirms the undecorated relative anchor; this review ran no target code.

Is this the best way to solve the issue?

The patch fixes the violated navigation invariant at the attachment boundary, reuses the shared decorator and catalog, and preserves the intentionally different source-bound reader contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6c672d42f2de.

Provenance checked

  • Shared Markdown document-link parsing keeps the original intent (f0401d5: Source-bound workspace readers require document context before resolving relative links; this PR adds selection-only decoration while retaining that read contract.)
  • Markdown attachment rendering and lifecycle keeps the original intent (fix(ui): render Markdown attachments in the sidebar #145555: Attachments became readable sanitized documents while retaining bounded reads, downloads, cancellation, remote-image restrictions, and shared Markdown controls.)
  • Files catalog and retained previews keeps the original intent (ebff161: The workspace owns selection and file order while the panel retains reader DOM and local catalog geometry; recovery uses that same selection operation.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Shakker: Raw commit f0401d5 adds ui/src/components/markdown-file-links.ts:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f0401d55f085; files: ui/src/components/markdown-file-links.ts)
  • Peter Steinberger: Raw commit 0ee5e4e adds ui/src/pages/chat/components/chat-text-attachment.tsx:202 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0ee5e4e375dd; files: ui/src/pages/chat/components/chat-text-attachment.tsx)
  • Vyctor H. Brzezowski: Raw commit ebff161 adds ui/src/pages/chat/components/chat-files-panel.tsx:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ebff1618f74b; files: ui/src/pages/chat/components/chat-files-panel.tsx)

PR surface

Source +119, Tests +79, Docs +6, Other +2. Total +206 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 13 145 26 +119
Tests 2 83 4 +79
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 17 236 30 +206

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #187647
Summary: This PR repairs detached-attachment navigation; the merged workspace-document repair has a distinct source-binding contract.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: A specific document-reading interaction leaves the conversation, but the existing Files browser provides recovery without affecting general chat availability.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-29T13:11:50.492Z sha 107b990 :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 10:24 AM ET / 14:24 UTC (Revision 2).

@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 29, 2026
@shakkernerd
shakkernerd merged commit 8bc3a82 into main Oct 29, 2026
169 of 172 checks passed
@shakkernerd
shakkernerd deleted the attachment-file-link-recovery branch October 29, 2026 14:48
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Markdown attachment file links now offer Files selection while preserving the conversation and original attachment.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…87662)

Recover relative links in Markdown attachments through explicit Files selection while retaining the conversation and original attachment.

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

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Markdown attachment file links navigate to missing conversations

1 participant