Skip to content

fix: label image references with filenames - #1958

Merged
kristofferremback merged 1 commit into
mainfrom
fix/attachment-filename-labels
Aug 24, 2026
Merged

fix: label image references with filenames#1958
kristofferremback merged 1 commit into
mainfrom
fix/attachment-filename-labels

Conversation

@kristofferremback

@kristofferremback kristofferremback commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Problem

Image references used generated labels such as Image #3, while the attachment tray showed filenames such as pasted-image-4.png. Removing an earlier image or inserting the same image twice left both labels factually valid but visually contradictory, and users had no visible numbered list to reconcile them against.

Solution

Image references now use the attachment filename everywhere users encounter the pointer: editor chips, plain-text copy, serialized markdown, sent-message links, and agent-authored attachment links. Images now follow the same naming rule as PDFs and other files, so a tray item and each reference to it share one stable label.

attachmentReferenceLabel in @threa/prosemirror owns the filename-first rule for both markdown and TipTap. Existing [Image #N](attachment:...) content still parses. When old content has metadata, it renders the stored filename; metadata-free legacy image links retain Image #N as a fallback. No migration or attachment ID behavior changes.

The companion prompt and design-system examples now document filename labels. Opus independently recommended this choice because filenames remain stable under tray mutation and give screen readers the same identifier visible elsewhere.

Verification

  • 143 focused frontend tests, 109 markdown tests, 35 backend prompt tests, and 7/7 inline-upload browser tests; full monorepo typecheck and lint clean
  • Browser coverage includes paste, mobile multi-pick, sent-message lightbox, hover linking, and duplicate copied references

Residual risk

imageIndex remains in contentJson and clipboard HTML for backward compatibility, but it no longer overrides an available filename.


🤖 PR by Pi using GPT-5.6 Sol


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 27 days. After that, they cost $0.25 per reviewed file.

Or wait 41 minutes for your next included review.

View limit details

Limit details: You’ve used the included review currently available. Your 70 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 324b7d93-689c-4391-94d0-7c6709fab8fe

📥 Commits

Reviewing files that changed from the base of the PR and between 958443c and 462b83d.

📒 Files selected for processing (14)
  • apps/backend/src/features/agents/companion/prompt/system-prompt.test.ts
  • apps/backend/src/features/agents/companion/prompt/system-prompt.ts
  • apps/backend/src/features/messaging/handlers.ts
  • apps/frontend/src/components/editor/attachment-reference-extension.test.ts
  • apps/frontend/src/components/editor/attachment-reference-extension.ts
  • apps/frontend/src/components/editor/attachment-reference-view.tsx
  • apps/frontend/src/components/editor/editor-markdown.test.ts
  • apps/frontend/src/components/timeline/pending-attachments.tray-drag.test.tsx
  • docs/design-system-kitchen-sink.html
  • docs/design-system.md
  • packages/prosemirror/src/index.ts
  • packages/prosemirror/src/markdown.test.ts
  • packages/prosemirror/src/markdown.ts
  • tests/browser/inline-file-upload.spec.ts

Comment @coderabbitai help to get the list of available commands.

@kristofferremback
kristofferremback merged commit 42712c2 into main Aug 24, 2026
42 of 43 checks passed
@kristofferremback
kristofferremback deleted the fix/attachment-filename-labels branch August 24, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant