Skip to content

feat(composer): show attachments as inline badges in the text - #200

Merged
nixuuu merged 1 commit into
feat/inline-attachments-1from
feat/inline-attachments-2
Nov 5, 2026
Merged

nixuuu merged 1 commit into
feat/inline-attachments-1from
feat/inline-attachments-2

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Stage 2 of 3, inline attachments: badges in the composer text (web).

Composer

  • Adding a file: every way of adding one (the "+" button, paste, drag and drop, the file picker) inserts its badge at the caret.
  • The badge: shows a file-type icon and the name, truncated at 16rem with the full name in a tooltip. It also shows upload progress (spinner and bar) and failure (icon plus the reason).
  • Preview: clicking an image badge opens the Lightbox; other files show name and size.
  • A file lives with its badge:
    • Backspace, Delete and Remove take both;
    • Undo restores both;
    • cut and paste inside the composer keep the badge.
  • No tray: the attachment tray is gone; its status is on the badges. A badge appearing does not change the composer's height.
  • Shell mode (!): attachments are not allowed. The hint by "+" says: "Remove attachments, quotes and mentions to send a shell command."

Timeline: user messages show the badges at the same positions, clickable to preview or download.

Checked in a browser, light and dark, desktop and phone width:

  • typical, very long and many attachments;
  • an upload in progress and a failed upload;
  • caret movement, Backspace and Delete, Undo, cut and paste;
  • the Lightbox, and shell mode with a badge.

Copy audit (§8)

  • "Remove", "Uploading, 42%", "Upload failed.", "Open ‹name›" and "Download ‹name›".
  • Tooltip: "‹name› · 2.0 KB".
  • State is never shown by colour alone.

@nixuuu
nixuuu added this pull request to stack #202 November 5, 2026 16:21
@nixuuu
nixuuu marked this pull request as ready for review November 5, 2026 16:21
@nixuuu
nixuuu force-pushed the feat/inline-attachments-2 branch from 3f8c36f to 1ecc67e Compare November 5, 2026 16:24
Files added by the paperclip, a drop or a paste become badges at the caret
(the end without one), using the composer's chip mechanism. Each badge shows
its upload (spinner and bar, red when it failed) without moving the text; a
tap opens an image in the Lightbox or a file's card with Remove.

A file lives with its badge: Backspace, Delete and Remove take both, Undo
brings both back, and cut and paste in the composer keep the badge. The tray
above the text is gone. Sent messages show the badges at the same places.
@nixuuu
nixuuu force-pushed the feat/inline-attachments-2 branch from 1ecc67e to 2dda5ac Compare November 5, 2026 16:26
@nixuuu
nixuuu merged commit b4efdbd into dev Nov 5, 2026
9 checks passed
@nixuuu
nixuuu deleted the feat/inline-attachments-2 branch November 5, 2026 16:35
nixuuu added a commit that referenced this pull request Nov 5, 2026
…231)

Stage 5 of 5, mobile UX: catch up with recent web features in the thread
view.

**Done**
- Full access with confirmation.
- The work group is open while the agent works and collapsed after the
turn (the default fold behaviour from #195).
- Tighter work rows in the `work` scale; commands in monospace.
- The shell command card and `!` mode in the composer (#194).
- "Starting" for a dispatched queued turn (#197).
- File badges in the message bubble.
- Finished subagents collapse into one count that opens the lineage
panel (#182).
- The type scale for overlays, chrome, work rows and the context row
(#174/#193).
- Rejected messages show their reason, instead of a generic retry note.

**Deferred**
- The work fold settings (per device on the web).
- Badges placed inline in the text and queue editing (#200/#201); files
stay as chips.
- Linked computers in pickers (needs `LinkedComputerSnapshot` merging).
- Worktree and ref in a new thread.
- Approval countdown and expiry cards.
- Connector errors.
- Mentions, side threads and goal editing.

**Checked** on the Android emulator, light and dark. `check:tmp`: 1425
passed, 0 failed. `expo lint` and `tsc` are clean.

**Copy audit (§8):**
- "Runs as a shell command when delivered."
- "Starting"
- "N finished subagents"
- "Set and manage goals in Canopy on the web."
nixuuu added a commit that referenced this pull request Nov 6, 2026
…ges (#237)

Stage 2 of 4, mobile parity round 2: the composer.

**Changed**
- **Inline badges:** a picked file goes into the text as a badge
`[name]` at the caret (an ATTACHMENT mention, as on the web since #200).
The text field renders mentions as tinted spans, so the characters stay
plain text.
- An edit that touches a badge removes all of it and its file; text
typed inside a badge lands after it.
  - Removing a file removes its badge.
- The field cannot show progress, so files that are uploading or failed
keep a chip above the text with the state and Remove. A stored file has
only its badge.
- Messages send `mentions` with the stored attachment ids; new threads
send `initial_mentions`.
- **Sent messages** show badges at their places (`Turn.mentions`); chips
remain only for files not placed in the text.
- **Queued messages** (as the web queue editor, #201): a "…" next to
"Queued" offers Edit message and Delete.
- The editor uses the same badges; deleting one shows "‹name› leaves the
message when you save." (or "N files leave …").
- Save sends `EditQueuedTurn` with the full positions and
`mentions_complete`; Delete sends `DeleteQueuedTurn`.
- The text and mentions model is `features/composer/message-value.ts`,
shared by the composer and the queue editor.

**Keyboard gap fix** (reported from a real Galaxy Z Fold, folded,
gesture navigation)
- **Bug:** with the keyboard open, the composer floated well above it,
with an empty band under it. Seen in bot chats and threads.
- **Cause, measured on the emulator** at phone width: window 841 dp,
keyboard top at y = 538, status bar 24 dp, nav-bar inset 32 dp.
  - The app runs edge-to-edge, so the window never resizes.
- `KeyboardAvoidingView` sat inside a `SafeAreaView` that kept the 32 dp
bottom inset, and `keyboardVerticalOffset={insets.top}` counted the
status bar again, since frames are already in window coordinates.
- The composer ended 24 dp plus its padding above the keyboard here,
more with a taller status bar.
- **Fix,** no new dependency: `ui/KeyboardArea.tsx` measures how far the
keyboard reaches up from the window's bottom edge (window height minus
the keyboard's `screenY`; on Android `height` leaves out the nav bar
under the keyboard).
- With the keyboard open, the composer sits directly on it with its
normal padding. With the keyboard closed, it keeps the bottom safe-area
inset.
- Applied to the thread screen, bot chat, New thread and Pair, whose
`SafeAreaView` now leaves out the bottom edge.
- The same gap was in `Overlay`'s bottom sheets (Rename, queue editor,
goal and side-thread forms): the sheet now sits on the keyboard and
drops its bottom inset while the keyboard is open.
- New thread on Android had no avoidance at all (the lower pills were
under the keyboard); it now shrinks and scrolls.
- On iOS the area follows `keyboardWillShow`/`Hide` with the keyboard's
own animation timing (instant with reduced motion). **iOS was not
checked on a device:** there is no iOS dev build, and building one did
not fit the Mac's disk budget.
- **Checked** on Canopy_Fold with the stock keyboard: phone width
(folded) and unfolded, keyboard open and closed, a four-line draft.
Thread, bot chat, New thread, Pair and a bottom-sheet form all sit flush
on the keyboard; with the keyboard closed, the composer keeps its inset
above the gesture bar.

**Not done**
- Undo: React Native's text field has no undo stack.
- Tapping a badge to preview the file, and moving queued messages or
switching queueing from the menu.

**Checked**
- Gates clean, as in stage 1.
- Android emulator, light and dark, unfolded and phone width:
  - a badge inserted after typed text, and a long file name wrapping;
  - Backspace into a badge removes the badge and its file;
- a message with a badge in the queue, then sent and shown with the
badge in place;
  - edit and save of a queued message;
- a badge removed in the editor with the "leaves the message" line,
saved without the file.

**Copy audit (§8)**
- "Edit message", "Delete", "Queued message actions", "Edit queued
message", "Cancel", "Save": verbs first; the web's labels.
- "‹name› leaves the message when you save." / "N files leave the
message when you save.": the web's text, one idea, present tense.
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