attachments: inline PDF chip cannot be opened after send

未关闭
#310 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, kotlin
领域
mobile

调研方向

Start in feature/session/src/main/kotlin/ai/opencode/feature/session/SessionFeatureAttachments.kt (lines 58-81) and ComposerAttachmentsFeature.kt (lines 170-176), where the staged PDF bytes are read and then discarded. Trace how SessionFeatureOutbox.kt (244-257) and server/.../Payloads.kt (488-513) drop the source, then check UserAttachmentViews.kt (103-130) for the opener. The fix must keep a readable source for the sent attachment and needs a regression test in FileAttachmentTests.kt (265-292) that opens an inline PDF after send.

由索引模型根据 Issue 内容生成。

描述

Summary

For an inline PDF attachment, Android reads the staged bytes and immediately deletes the staged file. The sent transcript row keeps neither those PDF bytes nor a server path. Unless the server returns a media:<hash> reference, the PDF chip has no opener and cannot be read after sending.

Environment

  • Android app: reporter's build not provided; behavior confirmed in v0.8.8 (c2311a60337e2a2128baba7c6eccb61b22bdb3f7) and dev (cab26e54c453fbaf8683ec456e628539d64b325f) source.
  • OpenCode server: version not provided; affects inline PDF responses without mediaHash.
  • Device/OS: not provided.
  • Terminal/shell: not applicable.
  • Active plugins: none required.

Reproduction

  1. Select a model whose catalog entry advertises PDF input.
  2. Attach a PDF no larger than 20 MiB.
  3. Send a prompt containing the PDF.
  4. Tap the PDF chip in the sent message.

Expected Behavior

The attachment opens in the PDF viewer, and the user can read or save the same PDF that was sent.

Actual Behavior

The chip is display-only and does not respond to taps. There is no click or drag action because the transcript file has no path or mediaViewerReference.

Additional Context

  • Inline handling is selected in feature/session/src/main/kotlin/ai/opencode/feature/session/SessionFeatureAttachments.kt:58-81.
  • ComposerAttachmentsFeature.kt:170-176 reads the bytes into memory, emits AttachmentAdded, then discards the staged copy.
  • Optimistic transcript projection drops the bytes (SessionFeatureOutbox.kt:244-257). Server decoding keeps text only for plain text and records no PDF path (server/src/main/kotlin/ai/opencode/server/live/Payloads.kt:488-513).
  • UserAttachmentViews.kt:103-130 creates an opener only from file.path or file.mediaViewerReference; otherwise the chip is inert.
  • PDF rendering already exists in feature/media/src/main/kotlin/ai/opencode/feature/media/agentfiles/AgentFileViewerModel.kt:353-359; the missing piece is a readable source reference.
  • FileAttachmentTests.kt:265-292 covers inline sending but not opening the sent PDF chip.
  • Suggested fix: retain a local or server-readable source for the lifetime of the sent attachment, then add a transcript regression test that opens an inline PDF after send.
  • Static source reproduction only; no device screenshot or log was provided.
主要语言
Kotlin
星标
146
派生
35
平均合并
7 小时 41 分钟
30 天内合并 PR
221

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode-android 的其他 Issue

查看 anomalyco/opencode-android 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。