Migrated from: https://github.com/yxlyx/lawplain/issues/62
Problem
In the TUI/composer, pressing the up arrow restores the previous prompt text from history. If that previous prompt included an image attachment, history replay currently restores only the literal [Image] placeholder text. Resending then sends a text-only prompt with no actual image, which is misleading and loses important context.
Expected behavior
When navigating prompt history with the up/down arrows:
- A previous prompt with image attachments should restore both the text and the original image attachment(s).
- Resending the restored prompt should include the image payload, not just
[Image] text.
- If image replay is not supported, the UI/API should clearly reject or warn instead of silently sending
[Image] as plain text.
Observed / likely root cause
The Ask/TUI history path appears to be text-only:
AskAgent.tsx stores messages/history as text / question strings.
/api/ask accepts only question, cite, and kind.
ask-history.ts persists only the text question.
- Up-arrow history restoration calls
setInput(historyItem.question) and has no attachment state to restore.
So multimodal prompts are flattened to text before reaching history.
Suggested implementation
Add attachment-aware prompt history end-to-end:
- Add a shared
AskAttachment / history item type, e.g. image MIME type, data URL or stored URL, name/size metadata.
- Persist attachments alongside ask history, preferably as metadata/URLs rather than large base64 blobs.
- Return attachments from
/api/ask/questions.
- Accept and validate
attachments in /api/ask.
- Update the agent serialization path to send image parts as actual multimodal content.
- Update
AskAgent.tsx so history navigation stores/restores both:
- current draft text + draft attachments
- historical prompt text + historical attachments
- Avoid de-duping history purely by question text, because the same text may be used with different images.
- Add a boundary fix: if already at the oldest history item, another Up should not consume the key event unless navigation actually occurred.
Acceptance criteria
- Given a prior prompt like
What is shown here? with an image attachment, pressing Up restores the text and shows/restores the image attachment.
- Pressing Enter/resend after restoring sends the image payload to the backend/agent.
- Text-only prompt history continues to work as before.
- Same text with different images remains distinct in history.
- Draft text + draft attachments are restored when navigating back down past the newest history item.
- Tests cover text-only history, image history restoration, resend payload, and unsupported/invalid image validation.
Migrated from: https://github.com/yxlyx/lawplain/issues/62
Problem
In the TUI/composer, pressing the up arrow restores the previous prompt text from history. If that previous prompt included an image attachment, history replay currently restores only the literal
[Image]placeholder text. Resending then sends a text-only prompt with no actual image, which is misleading and loses important context.Expected behavior
When navigating prompt history with the up/down arrows:
[Image]text.[Image]as plain text.Observed / likely root cause
The Ask/TUI history path appears to be text-only:
AskAgent.tsxstores messages/history astext/questionstrings./api/askaccepts onlyquestion,cite, andkind.ask-history.tspersists only the text question.setInput(historyItem.question)and has no attachment state to restore.So multimodal prompts are flattened to text before reaching history.
Suggested implementation
Add attachment-aware prompt history end-to-end:
AskAttachment/ history item type, e.g. image MIME type, data URL or stored URL, name/size metadata./api/ask/questions.attachmentsin/api/ask.AskAgent.tsxso history navigation stores/restores both:Acceptance criteria
What is shown here?with an image attachment, pressing Up restores the text and shows/restores the image attachment.