Skip to content

feat(chat): attachments as preview tiles in the composer - #526

Merged
Leo310 merged 8 commits into
mainfrom
feat/chat-image-attachment-previews
Sep 27, 2026
Merged

Leo310 merged 8 commits into
mainfrom
feat/chat-image-attachment-previews

Conversation

@Leo310

@Leo310 Leo310 commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

What

Attachments in the chat composer show as tiles on their own row above the context chips instead of filename pills. The tiles are 120px on desktop and 56px on a phone:

  • Images show a thumbnail.
  • PDFs show page 1, rendered through Obsidian's pdfjs and cropped to the top, with a "PDF" badge.
  • Text files, and anything whose preview fails, show a file card with an icon, the name, and the extension.

Clicking a tile opens the file. The corner × removes it; it's always visible because an opacity-0 hover reveal turns into a double tap on mobile. Previews are the object URLs Input already makes when you attach, so a file the vault hasn't indexed yet can't race them. The attachment-chip styling is gone.

Also fixes two things found while testing this:

  • Composer creep: removing a tile made the editor jump up and then slide back down. The card's min-height floor (feat(chat): composer grows to two thirds of the pane, Enter continues lists; drop the fullscreen editor #521) was derived from the card's own height, so it held the card open and only fell ~7px per resize tick. It is now summed from the rows around the editor.
  • Drag autoscroll: dragging a file into the composer scrolled the thread to the bottom. That's Chromium's built-in autoscroll near a scroller's edge, and the thread's bottom edge sits right above the composer. The thread is now non-user-scrollable while a drag is in progress.

How I tested it

bun run check, format, lint, and test pass, and the dev build succeeds. Live in a slot vault (desktop, macOS) using the Obsidian CLI: dropped an image and sampled the card geometry per frame on removal (before: 11 frames of creep; after: the first painted frame is final). Replayed a real file drag over CDP Input.dispatchDragEvent, held at the thread's bottom edge (before: scrollTop 200 → 928; after: stays at 200, and scrolling works again after the drag). Leo will do the hands-on test.

AI assistance: Claude Code (Opus) wrote the change from Leo's one-line request ("show attached images as preview instead of the pill", then "bigger on desktop, what about PDFs and other files"); Leo reviews and tests it live.

Checklist

  • bun run check, bun run format, bun run lint, and bun run test pass locally
  • I tried the change in a real Obsidian vault (or explained above why that isn't applicable)
  • I read CONTRIBUTING.md, including the section on AI assistance
  • If this adds a provider, a bundled skill, a built-in tool, or changes manifest.json: I noted that the docs site needs updating (see "Documentation" in CONTRIBUTING.md)

Image attachments in the context tray render as 56px thumbnails on their
own row (click opens the image, the corner × removes it) instead of a
filename chip. Non-image attachments, and images whose file isn't in the
vault, keep the chip.

Co-Authored-By: Claude <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Chat composer now shows attachment previews as tiles.

The PR appears safe to merge, with a non-blocking keyboard-focus visibility issue on the jump-to-bottom button.

Summary

The PR replaces attachment chips with image, PDF, or file-card tiles and adjusts composer sizing and drag scrolling. The change since the previous review flattens the jump-to-bottom button’s normal and hover appearance.

Reviews (8) · Last reviewed commit: "Merge branch 'main' into feat/chat-image..."

Comment thread src/components/chat/ContextTray.svelte Outdated
Leo310 and others added 2 commits September 27, 2026 15:05
…okup

A pasted or dropped image is written through the adapter, so the vault
may not have indexed it yet when the tray looked it up, leaving a chip
that never upgraded. Input already keeps an object URL per image
attachment; pass that down instead.

Co-Authored-By: Claude <noreply@anthropic.com>
Tiles are 80px on desktop (56px on a phone). PDFs render page 1 through
Obsidian's pdfjs with a PDF badge; text files and anything without a
preview show a file card (icon, name, extension). Attachment chips are
gone, along with their filled-pill styling.

Co-Authored-By: Claude <noreply@anthropic.com>
@Leo310 Leo310 changed the title feat(chat): show image attachments as thumbnails in the composer feat(chat): attachments as preview tiles in the composer Sep 27, 2026
Comment thread src/utils/pdfExtractor.ts Outdated
Comment thread src/components/chat/Input.svelte
… don't scroll the thread

- The card's min-height floor was derived from the card's own height, so
  when the tray shrank (removing an attachment tile) the floor held it
  open and only fell ~7px per resize tick: the editor jumped up, then the
  card slid down. Sum the floor from the tray and action rows instead.
- Chromium auto-scrolls a scroller whose edge a drag hovers near, and the
  thread's bottom edge sits right above the composer, so dragging a file
  in ran the thread to the bottom. Make it non-user-scrollable while a
  drag is in progress.
- Review: cap the PDF thumbnail canvas at a square; don't store a preview
  URL once the composer is destroyed.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread src/components/chat/MessageContainer.svelte Outdated
Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread src/components/chat/MessageContainer.svelte
Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread src/components/chat/ContextTray.svelte
@Leo310
Leo310 merged commit 53ff0b5 into main Sep 27, 2026
3 checks passed
@Leo310
Leo310 deleted the feat/chat-image-attachment-previews branch September 27, 2026 13:56
@greptile-apps

greptile-apps Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P2 Focus ring may disappear src/components/chat/MessageContainer.svelte:1288 ▶

    If the active theme shows keyboard focus with a box shadow, this new box-shadow: none can hide the jump-to-bottom button’s focus ring. The button has no replacement :focus-visible style, so keyboard users may be unable to tell when it has focus. Keep the flat appearance without removing visible focus.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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