MCPcopy Index your code
hub / github.com/codehamr/codehamr / queuePrompt

Method queuePrompt

internal/tui/keys.go:267–297  ·  view source on GitHub ↗

queuePrompt stashes the textarea contents to auto-submit when the running turn finishes (see fireQueued), then clears the input so the next prompt can be typed. A second call appends newline-joined, so a multi-part instruction builds up in one slot and fires as a single turn. Empty input is a no-op,

()

Source from the content-addressed store, hash-verified

265// (chips expanded), DisplayValue() the visible echo (chips collapsed), the same
266// split submit uses. Slash text queues like any prompt and routes through submit
267// when it fires.
268func (m Model) queuePrompt() (tea.Model, tea.Cmd) {
269 send := strings.TrimSpace(m.ta.Value())
270 echo := strings.TrimSpace(m.ta.DisplayValue())
271 if send == "" {
272 return m, nil
273 }
274 if m.queued == nil {
275 m.queued = &queuedPrompt{send: send, echo: echo}
276 } else {
277 // Never newline-join across a slash boundary. The joined text either
278 // starts with "/" and fires as ONE slash command whose Fields-split
279 // swallows the appended prose as bogus args (a queued "/clear" plus a
280 // follow-up instruction wipes the conversation and silently drops the
281 // instruction), or it ships the slash line to the LLM as prose. Refuse
282 // the append and keep the draft in the textarea so nothing is lost.
283 if strings.HasPrefix(m.queued.send, "/") || strings.HasPrefix(send, "/") {
284 m.status = queueSlashHint
285 return m, nil
286 }
287 // A fresh pointer, not an in-place edit: Model is copied by value across
288 // bubbletea, so mutating *m.queued would also reach through the discarded
289 // prior copy that still aliases the same struct.
290 m.queued = &queuedPrompt{
291 send: m.queued.send + "\n" + send,
292 echo: m.queued.echo + "\n" + echo,
293 }
294 }
295 m.ta.Reset()
296 m.closePopover()
297 return m, nil
298}
299
300// unqueuePrompt pulls the queued prompt back into the textarea and clears the

Callers 1

handleEnterMethod · 0.95

Calls 4

closePopoverMethod · 0.95
ValueMethod · 0.80
DisplayValueMethod · 0.80
ResetMethod · 0.80

Tested by

no test coverage detected