openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Files in this chat — persistent per-chat artifact registry

Open oxoxDev opened this issue 6 months ago • 3 comments

Summary

A persistent "Files in this chat" surface inside the chat view that lists every artifact the agent has generated in the current thread, with per-row Download / Reveal-in-folder / Delete affordances. Survives app restarts (for files created in-session) so the user can return to a chat and still grab a deck they made earlier.

Problem

The inline ArtifactCard shipped in #2779 (PR #3017) sits above the composer as a single ephemeral card per artifact:

  • Scrolling, sending the next turn, or restarting the app loses the card.
  • The artifactsByThread Redux slice is in-memory only (app/src/store/index.ts:158 registers chatRuntimeReducer directly, no persistReducer), so files vanish across app restarts even though the underlying payload is still on disk under <workspace>/artifacts/<uuid>/.
  • There is no place to enlist all files involved in a chat.

User feedback (live dev:app test, 2026-05-30): "there should be a place to enlist all the files involved in a chat" — flagged after a generated climate-change-an-overview.pptx was visible once, then the user couldn't find it again after a new turn was sent.

Solution

Frontend-only addition layered on top of the artifact pipeline already shipped in #2779:

  1. ChatFilesChip (new component) — header chip with paperclip icon + count badge. Hidden when artifact count = 0. Owns popover open/close + click-outside + Esc.
  2. ChatFilesPanel (new component) — popover panel listing per-thread artifacts (title + kind icon + size + Download + Reveal + Delete with confirm modal). Uses useT() + Tailwind + inline SVGs (mirrors ArtifactCard.tsx style — no new icon dep).
  3. Persistence — wrap chatRuntimeReducer with persistReducer + a createTransform that keeps only status === 'ready' entries on storage write (in_progress / failed stay session-scoped — should not survive a restart).
  4. Delete flow — frontend deleteArtifact() service + removeArtifactForThread reducer; optimistic FE removal with rollback on RPC error. RPC openhuman.ai_delete_artifact already exists.
  5. Above-composer card on ready — filter status === 'ready' OUT of the existing above-composer block (delegated to the panel). in_progress / failed keep showing there for live feedback.

Known backend gap (deferred to a follow-up)

ArtifactMeta (src/openhuman/artifacts/types.rs:80-102) has no thread_id field, and openhuman.ai_list_artifacts is workspace-scoped (only offset / limit). So a true cold-load-from-RPC for a single thread is not possible today. This issue ships persisted-slice + RPC fetch for the artifacts the slice knows about; a follow-up should persist thread_id into ArtifactMeta + add a thread_id filter param on ai_list_artifacts for full cold-load support.

Files (estimated)

File New/Modified Est. LOC
app/src/components/chat/ChatFilesPanel.tsx NEW 200
app/src/components/chat/ChatFilesChip.tsx NEW 90
app/src/components/chat/__tests__/ChatFilesPanel.test.tsx NEW 220
app/src/components/chat/__tests__/ChatFilesChip.test.tsx NEW 90
app/src/store/__tests__/chatRuntimeSlice.test.ts MODIFIED +80
app/src/services/__tests__/artifactDownloadService.test.ts NEW 120
app/src/pages/Conversations.tsx MODIFIED +30 / -20
app/src/store/chatRuntimeSlice.ts MODIFIED +35
app/src/store/index.ts MODIFIED +40
app/src/services/artifactDownloadService.ts MODIFIED +35
app/src/lib/i18n/en.ts MODIFIED +12
app/src/lib/i18n/{ar,bn,de,es,fr,hi,id,it,ko,pl,pt,ru,zh-CN}.ts × 13 MODIFIED +156

Total estimated: 1100–1700 LOC (FE-only; 0 Rust, 0 Tauri).

Acceptance criteria

  • [ ] ChatFilesChip in header — paperclip + count badge appears in the chat header when at least one artifact exists for the active thread; hidden when count = 0; aria-label chat.files.chip.aria ("{count} files in this chat").
  • [ ] ChatFilesPanel popover — opens on chip click; closes on Esc + click-outside; each row shows kind icon + title + human-readable size; Download / Reveal / Delete buttons per row.
  • [ ] Delete with confirm — Delete row → confirm modal → optimistic remove from slice + RPC openhuman.ai_delete_artifact → on RPC error, re-insert + show toast chat.files.delete.failed.
  • [ ] Cross-restart persistence — generated .pptx survives app quit + relaunch; only status === 'ready' entries are persisted (in_progress / failed are session-only via createTransform outbound filter).
  • [ ] Above-composer card delegates ready to panel — the existing ArtifactCard render block keeps in_progress / failed cards visible there but hides ready cards (they live in the panel only). No double-rendering.
  • [ ] Empty state — panel shows chat.files.panel.empty ("No files yet. Ask the agent to generate one.") when count = 0 (chip is hidden, so this is only seen if the panel is open while the last artifact is deleted).
  • [ ] i18n parity — 12 new keys × 14 locales; pnpm i18n:check (parity) and pnpm i18n:english:check (no English leaks) both green for the new keys.
  • [ ] Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate per .github/workflows/pr-ci.yml. New Vitest suites cover: panel populated render, optimistic delete + RPC rollback, download/reveal delegation, confirm-modal cancel path, chip hidden-when-zero, chip count badge, slice persist-transform filter.

Related

  • Parent epic: #1535 "Add multimodal support for files and PPT generation"
  • Sub-tasks of #1535:
    • #2776 ✅ merged (artifact storage / artifacts domain)
    • #2777 (multimodal file attachments) — PR #2954 open
    • #2778 (presentation tool backed by python-pptx) — PR #3016 open
    • #2779 (inline ArtifactCard + Tauri download) — PR #3017 open ← this issue extends that work
    • #2780 (orchestrator wiring) — pending
  • Backend follow-up (separate, not part of this issue): persist thread_id into ArtifactMeta + add thread_id filter param on openhuman.ai_list_artifacts so artifacts from old sessions (pre-persistence) become listable.

oxoxDev avatar May 30 '26 14:05 oxoxDev

Interested in picking this up. Holding off on opening a PR until #3017 merges — the substrate this layers on (the ArtifactCard, the artifactsByThread slice, artifactDownloadService, and the openhuman.ai_delete_artifact RPC) all live in that PR's branch rather than main today, so any work here would be unmergeable until then. Will start once #3017 lands. If anyone else wants to grab this in the meantime, no objection.

hemanth1999k avatar May 30 '26 21:05 hemanth1999k

@hemanth1999k thanks for flagging — this is already in flight as #3026, stacked on #3017 for exactly the reasons you called out (artifactsByThread slice, ArtifactCard, artifactDownloadService, openhuman.ai_delete_artifact RPC all live in #3017's branch, not on main). Your dependency analysis matches mine; PR will rebase onto main once #3017 lands.

If you're looking for adjacent #1535 work, a few unclaimed follow-ups surfaced during implementation:

  1. ArtifactMeta.thread_id field + ai_list_artifacts thread filter param — flagged in #3026's PR body. Today the persisted Redux slice covers per-thread cold-load on app restart; this would close the gap for true cold-load-from-RPC (e.g. iOS client, cross-device sync).
  2. Image embedding in slides via ppt-rs::add_image — pairs a Composio file fetch / artifact marker with a slide image placeholder. Useful for 'deck with chart screenshots' requests.
  3. Per-slide source attribution (SlideSpec.sources: Vec<String> rendered as a 'Sources:' footer in speaker notes) — pairs with the grounding rule in #2780 / #3029.

Happy to open any of those as separate issues if you want to pick one up. Closing #3024 in favor of #3026.

oxoxDev avatar May 30 '26 22:05 oxoxDev

Thanks @oxoxDev — appreciate the unblock + the clean writeup on #3026.

I'd like to pick up #1 (ArtifactMeta.thread_id field + ai_list_artifacts thread filter param). The scope is well-bounded — types.rs field add, store.rs plumbing through the write path, ops.rs filter param, and a JSON-RPC E2E case — and it closes the cold-load-from-RPC gap your slice persistence intentionally left open, which is the part that becomes relevant for the iOS client transport (LanHttpTransport / TunnelTransport).

Couple of pre-flight questions before I file an issue + branch:

  1. Migration story for existing rows. Existing ArtifactMeta records on disk won't have thread_id. Plan was Option<String> on the type + a default None from any old row; ai_list_artifacts's new thread_id filter would simply not match them. Acceptable, or do you want a one-shot backfill?
  2. Scope of writer-side capture. Today the only place a thread_id is set on the spawning side is the APPROVAL_CHAT_CONTEXT task-local that #3017 uses for artifact events. I was going to read the same task-local inside create_artifact so CLI / cron / sub-agent callers leave thread_id = None for free. Match #3017's contract or do you want it explicit-arg?
  3. Filing. Happy to either file it myself as a fresh issue (feat(artifacts): persist thread_id on ArtifactMeta + add thread_id filter to ai_list_artifacts) referencing #3026's body, or open the PR directly with closes #3026 (follow-up) if you'd rather skip the issue. Whichever fits your workflow.

Will hold off on writing code until you confirm. (No rush — #3017 + #3026 going in first makes sense.)

hemanth1999k avatar May 31 '26 01:05 hemanth1999k