MCPcopy Index your code
hub / github.com/anomalyco/opencode / questionSave

Function questionSave

packages/opencode/src/cli/cmd/run/question.shared.ts:258–306  ·  view source on GitHub ↗
(state: QuestionBodyState, request: QuestionRequest)

Source from the content-addressed store, hash-verified

256}
257
258export function questionSave(state: QuestionBodyState, request: QuestionRequest): QuestionStep {
259 const info = questionInfo(request, state)
260 if (!info) {
261 return { state }
262 }
263
264 const value = questionInput(state).trim()
265 const prev = state.custom[state.tab]
266 if (!value) {
267 if (!prev) {
268 return {
269 state: questionSetEditing(state, false),
270 }
271 }
272
273 const next = questionStoreCustom(state, state.tab, "")
274 return {
275 state: questionSetEditing(
276 storeAnswers(
277 next,
278 state.tab,
279 (state.answers[state.tab] ?? []).filter((item) => item !== prev),
280 ),
281 false,
282 ),
283 }
284 }
285
286 if (info.multiple) {
287 const answers = [...(state.answers[state.tab] ?? [])]
288 if (prev) {
289 const idx = answers.indexOf(prev)
290 if (idx !== -1) {
291 answers.splice(idx, 1)
292 }
293 }
294
295 if (!answers.includes(value)) {
296 answers.push(value)
297 }
298
299 const next = questionStoreCustom(state, state.tab, value)
300 return {
301 state: questionSetEditing(storeAnswers(next, state.tab, answers), false),
302 }
303 }
304
305 return questionPick(state, request, value, true)
306}
307
308export function questionSubmit(request: QuestionRequest, state: QuestionBodyState): QuestionReply {
309 return {

Callers 2

saveCustomFunction · 0.90

Calls 7

questionInfoFunction · 0.85
questionInputFunction · 0.85
questionSetEditingFunction · 0.85
questionStoreCustomFunction · 0.85
storeAnswersFunction · 0.85
questionPickFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected