Advanced design extension — not implemented in the pinned app
Imagine a “Make takeaways” action that turns a completed conversation into a short set of editable notes. The model should return a bounded data structure, not arbitrary UI markup. The current PocketChat app saves plain answer snapshots; it has no structured-takeaway integration.
Separate parsing from validation
A JSON schema can constrain shape, but a structurally valid object can still contain empty, duplicate, or misleading takeaways. Parse first, then apply application rules before enabling Save. Keep invalid output visible as a recoverable failure rather than persisting it as trusted content.
// Proposed domain policy; not part of the baseline.
data class Takeaways(val title: String, val items: List<String>)
fun Takeaways.isUsable(): Boolean =
title.isNotBlank() && title.length <= 80 &&
items.size in 1..5 &&
items.all { it.isNotBlank() && it.length <= 240 } &&
items.map { it.trim().lowercase() }.distinct().size == items.size
This validation says nothing about factual truth. A human should be able to edit the result; evaluation should check that each item actually follows from the conversation. Unknown JSON fields, malformed JSON, and unsupported schema features need separate decisions at the parser/API boundary.
Design the states
Idle → generating → parsing → validating → editable preview → saved. Any failure should preserve the source conversation. Allow explicit retry with a bounded policy; do not generate forever until a response happens to pass. Cancellation must not later populate a stale preview.
Check your understanding
Why not treat schema compliance as truth? A model can produce five perfectly shaped false statements. Your structural validation, semantic evaluation, and user review address different risks. Describe all three and keep this proposal separate from the app's implemented plain-text saving.