(
host: SlashCommandHost,
parsed: Extract<ParsedGoalCommand, { kind: 'next-add' }>,
)
| 174 | } |
| 175 | |
| 176 | async function queueNextGoal( |
| 177 | host: SlashCommandHost, |
| 178 | parsed: Extract<ParsedGoalCommand, { kind: 'next-add' }>, |
| 179 | ): Promise<void> { |
| 180 | const session = host.requireSession(); |
| 181 | let hasCurrentGoal: boolean; |
| 182 | try { |
| 183 | const { goal } = await session.getGoal(); |
| 184 | hasCurrentGoal = goal !== null; |
| 185 | } catch (error) { |
| 186 | host.showError(`Failed to inspect current goal: ${formatErrorMessage(error)}`); |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | if (!hasCurrentGoal && !isBusy(host)) { |
| 191 | host.showStatus(START_NEXT_GOAL_NOW_MESSAGE); |
| 192 | await createGoal( |
| 193 | host, |
| 194 | { kind: 'create', objective: parsed.objective, replace: false }, |
| 195 | `next ${parsed.objective}`, |
| 196 | ); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | try { |
| 201 | await appendGoalQueueItem(session, { objective: parsed.objective }); |
| 202 | } catch (error) { |
| 203 | host.showError(formatErrorMessage(error)); |
| 204 | return; |
| 205 | } |
| 206 | host.track('goal_queue_append'); |
| 207 | if (!hasCurrentGoal) host.requestQueuedGoalPromotion?.(); |
| 208 | host.state.transcriptContainer.addChild( |
| 209 | new UpcomingGoalAddedMessageComponent(), |
| 210 | ); |
| 211 | host.state.ui.requestRender(); |
| 212 | } |
| 213 | |
| 214 | async function showGoalQueueManager( |
| 215 | host: SlashCommandHost, |
no test coverage detected