|
| 1 | +<template> |
| 2 | + <div class="collapsed-question-turn" :class="{ expanded }"> |
| 3 | + <template v-if="!expanded"> |
| 4 | + <div |
| 5 | + v-for="(entry, index) in turn.entries" |
| 6 | + :key="index" |
| 7 | + class="folded-question" |
| 8 | + data-el="folded-question" |
| 9 | + > |
| 10 | + <button |
| 11 | + type="button" |
| 12 | + class="question-text" |
| 13 | + data-action="toggle-turn" |
| 14 | + title="Show the full question card" |
| 15 | + @click="expanded = true" |
| 16 | + > |
| 17 | + {{ entry.question }} |
| 18 | + </button> |
| 19 | + <div class="folded-answers"> |
| 20 | + <button |
| 21 | + v-for="(chip, chipIndex) in chipsFor(entry)" |
| 22 | + :key="chipIndex" |
| 23 | + type="button" |
| 24 | + class="answer-chip" |
| 25 | + data-action="edit-answer" |
| 26 | + title="Load this answer into the composer to correct it" |
| 27 | + @click="editAnswer(entry)" |
| 28 | + > |
| 29 | + <span class="chip-label">{{ chip }}</span> |
| 30 | + <span class="chip-remove" aria-hidden="true">×</span> |
| 31 | + </button> |
| 32 | + <span v-if="chipsFor(entry).length === 0" class="skipped-marker">Skipped</span> |
| 33 | + </div> |
| 34 | + </div> |
| 35 | + </template> |
| 36 | + <div v-else class="expanded-messages"> |
| 37 | + <button |
| 38 | + type="button" |
| 39 | + class="question-text" |
| 40 | + data-action="toggle-turn" |
| 41 | + title="Collapse this step" |
| 42 | + @click="expanded = false" |
| 43 | + > |
| 44 | + Collapse this step |
| 45 | + </button> |
| 46 | + <AiMessage v-bind="{ ...turn.questionsMessage }" /> |
| 47 | + <HumanMessage v-if="turn.replyMessage" v-bind="{ ...turn.replyMessage }" /> |
| 48 | + </div> |
| 49 | + </div> |
| 50 | +</template> |
| 51 | + |
| 52 | +<script> |
| 53 | +import { mapActions } from 'pinia' |
| 54 | +
|
| 55 | +import AiMessage from './AiMessage.vue' |
| 56 | +import HumanMessage from './HumanMessage.vue' |
| 57 | +
|
| 58 | +import { useProductExpertStore } from '@/stores/product-expert.js' |
| 59 | +
|
| 60 | +export default { |
| 61 | + name: 'CollapsedQuestionTurn', |
| 62 | + components: { |
| 63 | + AiMessage, |
| 64 | + HumanMessage |
| 65 | + }, |
| 66 | + props: { |
| 67 | + turn: { |
| 68 | + type: Object, |
| 69 | + required: true |
| 70 | + } |
| 71 | + }, |
| 72 | + data () { |
| 73 | + return { |
| 74 | + expanded: false |
| 75 | + } |
| 76 | + }, |
| 77 | + computed: { |
| 78 | + // A hand-typed or edited reply doesn't match the question lines, so |
| 79 | + // every entry resolves to null; fall back to the raw reply text once. |
| 80 | + hasMatchedAnswers () { |
| 81 | + return this.turn.entries.some(entry => entry.answer !== null) |
| 82 | + } |
| 83 | + }, |
| 84 | + methods: { |
| 85 | + ...mapActions(useProductExpertStore, ['setPendingInput']), |
| 86 | + // One chip per pick: QuestionsList composes multi-select answers as a |
| 87 | + // comma-separated list, so split for display only. Editing any chip |
| 88 | + // loads the whole answer line, since a resend replaces the full turn. |
| 89 | + chipsFor (entry) { |
| 90 | + if (entry.answer) { |
| 91 | + return entry.answer.split(', ') |
| 92 | + } |
| 93 | + if (!this.hasMatchedAnswers && this.turn.replyMessage?.content) { |
| 94 | + return [this.turn.replyMessage.content] |
| 95 | + } |
| 96 | + return [] |
| 97 | + }, |
| 98 | + editAnswer (entry) { |
| 99 | + if (entry.answer) { |
| 100 | + this.setPendingInput(`${entry.question} ${entry.answer}`) |
| 101 | + } else if (this.turn.replyMessage?.content) { |
| 102 | + this.setPendingInput(this.turn.replyMessage.content) |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | +} |
| 107 | +</script> |
| 108 | +
|
| 109 | +<style scoped lang="scss"> |
| 110 | +.collapsed-question-turn { |
| 111 | + display: flex; |
| 112 | + flex-direction: column; |
| 113 | + gap: 1rem; |
| 114 | +} |
| 115 | +
|
| 116 | +.folded-question { |
| 117 | + display: flex; |
| 118 | + flex-direction: column; |
| 119 | + align-items: flex-start; |
| 120 | + gap: 0.5rem; |
| 121 | + padding: 0.125rem 0 0.125rem 0.875rem; |
| 122 | + border-left: 2px solid var(--ff-color-border); |
| 123 | +} |
| 124 | +
|
| 125 | +.question-text { |
| 126 | + font-size: 0.8125rem; |
| 127 | + color: var(--ff-color-text-subtle); |
| 128 | + text-align: left; |
| 129 | + cursor: pointer; |
| 130 | +
|
| 131 | + &:hover { |
| 132 | + color: var(--ff-color-text-strong); |
| 133 | + } |
| 134 | +} |
| 135 | +
|
| 136 | +.folded-answers { |
| 137 | + display: flex; |
| 138 | + flex-wrap: wrap; |
| 139 | + gap: 0.5rem; |
| 140 | +} |
| 141 | +
|
| 142 | +.answer-chip { |
| 143 | + display: inline-flex; |
| 144 | + align-items: center; |
| 145 | + gap: 0.5rem; |
| 146 | + font-size: 0.875rem; |
| 147 | + font-weight: 600; |
| 148 | + color: var(--ff-color-text-strong); |
| 149 | + background: var(--ff-color-bg-surface); |
| 150 | + border: 1px solid var(--ff-color-border); |
| 151 | + border-radius: 9999px; |
| 152 | + padding: 0.25rem 0.75rem; |
| 153 | + cursor: pointer; |
| 154 | + max-width: 100%; |
| 155 | +
|
| 156 | + &:hover { |
| 157 | + border-color: var(--ff-color-accent); |
| 158 | + } |
| 159 | +} |
| 160 | +
|
| 161 | +.chip-label { |
| 162 | + overflow: hidden; |
| 163 | + text-overflow: ellipsis; |
| 164 | + white-space: nowrap; |
| 165 | + max-width: 22rem; |
| 166 | +} |
| 167 | +
|
| 168 | +.chip-remove { |
| 169 | + font-weight: 400; |
| 170 | + color: var(--ff-color-text-subtle); |
| 171 | + line-height: 1; |
| 172 | +} |
| 173 | +
|
| 174 | +.skipped-marker { |
| 175 | + font-size: 0.875rem; |
| 176 | + font-style: italic; |
| 177 | + color: var(--ff-color-text-subtle); |
| 178 | +} |
| 179 | +
|
| 180 | +.expanded-messages { |
| 181 | + display: flex; |
| 182 | + flex-direction: column; |
| 183 | + align-items: flex-start; |
| 184 | + gap: 0.75rem; |
| 185 | + padding-left: 0.875rem; |
| 186 | + border-left: 2px solid var(--ff-color-accent); |
| 187 | +} |
| 188 | +</style> |
0 commit comments