Skip to content

Restore paste/drop and inline-bytes attachments on hosts without Home's picker (A1+A2) - #105

Merged
QuickMythril merged 2 commits into
mainfrom
feat/attach-fallback
Sep 1, 2026
Merged

Restore paste/drop and inline-bytes attachments on hosts without Home's picker (A1+A2)#105
QuickMythril merged 2 commits into
mainfrom
feat/attach-fallback

Conversation

@QuickMythril

@QuickMythril QuickMythril commented Sep 1, 2026

Copy link
Copy Markdown
Member

Why

User feedback: after Chat 2.0 you can no longer drag or paste images into the composer. PR #88 (2.0 P4) made Home's native picker the only source of publishable bytes, which (a) disabled the paperclip on every host without SELECT_QDN_PUBLISH_SOURCE — Qortal Hub, and Home 1.x older than 1.3.0 — and (b) left paste/drag-drop showing a "use the attach button" notice on every host, including Home 2, because the app had no way to hand bytes to Home.

Review + evidence: ~/AGENTS/projects/qortium-chat-v2/attachments-matrix/ (SYNTHESIS.md, TRACKER.md). This PR is Phase A1+A2 — chat app only, no Home change.

What

  • src/attachmentCapabilities.ts (new): per-host attachment source, feature-detected from advertised actions — picker (token flow, unchanged) or bytes (app reads the File). PUBLISH_CHAT_ATTACHMENT doubles as the "refuses inline bytes" marker since Home 2 desktop is the only host that both denylists inline fields and advertises it. No probe request.
  • src/attachments.ts: local File staging is back — prepareLocalAttachment (WebP re-encode at 1200px / q0.6 for non-GIF images, strips metadata; base64). Staged shapes are now a kind: 'source' | 'local' union.
  • src/coreApi.ts: publishQdnResourceBytes replaces the always-throwing shim; sends the pre-P4 {base64, filename, identifier, name, service} shape that every Home 1.x (data64||base64), Home 2 Android, and Hub (data64||base64||file) accept.
  • App.tsx / ChatComposer.tsx: paperclip → picker where offered (Home 1.3+/2), else hidden <input type="file">; paste and drop stage the file wherever inline bytes are accepted, and keep the notice on Home 2 desktop; drop overlay text follows. Send path publishes a local stage inline; the token path and private-attachment flow are unchanged.
  • Two new i18n keys (label.composer.dropFileHere, status.attachment.selecting) mirrored into all 22 locales; docs/CHAT_ATTACHMENTS.md gets the per-host source table; README updated.

Resulting matrix

Host Open-group paperclip Paste / drop Private
Home 1.x ≤1.2 (no picker) bytes ✅ (was ✗) ✅ (was ✗)
Home 1.x ≥1.3 (picker since home#100) picker (unchanged) ✅ bytes (was notice)
Home 2 desktop picker notice (needs Home B1) picker
Home 2 Android picker ✅ bytes (was notice)
Qortal Hub bytes ✅ (was ✗) ✅ (was ✗)

Correction (2nd commit)

An earlier revision of this description said Home ≤1.7.1 lacks the picker; that was a bad grep. git grep across tags: the picker exists in every Home 1.x from 1.3.0, all 1.x accept inline bytes, none advertise PUBLISH_CHAT_ATTACHMENT. Code behaviour was already feature-detected and is unchanged; comments/tests/docs corrected.

Verification

  • npx tsc --noEmit clean; npx vitest run: 55 files, 757 tests pass (baseline on main before this change: 11 files failed to load only because node_modules lacked tweetnaclnpm ci fixed it).
  • New tests: attachmentCapabilities.test.ts (ladder per host), coreApi.test.ts (wire shape, Hub-style result, {accepted:false} → error, validation), attachments.test.ts (File routing).
  • npm run build succeeds.
  • Not yet exercised against a live Home 1.7 / Hub — the wire shape matches what those hosts read (verified in their source), but a manual smoke on Hub and a Home 1.x is the remaining gate before publishing 2.0.8.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E9yvpqkVaKzM9MUh5zoCmG

QuickMythril and others added 2 commits September 1, 2026 14:17
…'s picker (attachments-matrix A1+A2)

Chat 2.0 P4 (#88) made Home's native picker the only source of publishable
bytes. That broke attachments on every host that does not offer the picker
(Home <=1.7.1, Qortal Hub) and left paste/drag-drop dead everywhere, since
the app could no longer hand bytes to Home.

- attachmentCapabilities.ts: feature-detect the attachment source per host
  from advertised actions (picker vs inline bytes); PUBLISH_CHAT_ATTACHMENT
  doubles as the token-only (Home 2 desktop) marker.
- attachments.ts: bring back local File staging (WebP re-encode, base64).
- coreApi.ts: publishQdnResourceBytes sends the pre-P4 inline shape
  (base64 + filename) that Home <=1.8, Home 2 Android and Hub accept.
- App.tsx / ChatComposer.tsx: paperclip opens the picker where offered, else
  a hidden <input type=file>; paste and drop stage the file wherever inline
  bytes are accepted, and keep the use-the-attach-button notice on Home 2
  desktop. Send path publishes local stages inline; token path unchanged.
- Two new i18n keys mirrored into all 22 locales; docs + README updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E9yvpqkVaKzM9MUh5zoCmG
…rs SELECT_QDN_PUBLISH_SOURCE

The earlier note that Home <=1.7.1 lacks the picker came from a bad grep;
git grep across tags shows the picker (home#100) in v1.3.0+ and inline
bytes accepted on every 1.x. Behaviour is unchanged (feature-detected);
only comments, test host labels, and docs are corrected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E9yvpqkVaKzM9MUh5zoCmG
@QuickMythril
QuickMythril merged commit 66f59d4 into main Sep 1, 2026
4 checks passed
@QuickMythril
QuickMythril deleted the feat/attach-fallback branch September 1, 2026 18:30
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