endProcessingLifecycle reverses startProcessingLifecycle, then drains any message the user queued while the prior turn was running. The recursive re-entry is bounded by the queue cap (10 messages); when the queue is empty it restores the idle prompt.
(ctx context.Context, stopSpinner func())
| 114 | // re-entry is bounded by the queue cap (10 messages); when the queue is |
| 115 | // empty it restores the idle prompt. |
| 116 | func (cli *ChatCLI) endProcessingLifecycle(ctx context.Context, stopSpinner func()) { |
| 117 | defer cli.animation.SetSuppressed(false) |
| 118 | stopSpinner() |
| 119 | |
| 120 | if nextMsg := cli.dequeueMessage(); nextMsg != "" { |
| 121 | cli.announceQueueDrain() |
| 122 | cli.processLLMRequest(ctx, nextMsg) |
| 123 | return |
| 124 | } |
| 125 | cli.isExecuting.Store(false) |
| 126 | cli.interactionState = StateNormal |
| 127 | fmt.Print("\033[0m") |
| 128 | _ = os.Stdout.Sync() |
| 129 | cli.forceRefreshPrompt() |
| 130 | } |
| 131 | |
| 132 | // announceQueueDrain prints either the "processing remaining N" or |
| 133 | // "processing" notice before recursing into the queued turn. |