MCPcopy Create free account
hub / github.com/tiann/hapi / handleGoalCommand

Method handleGoalCommand

cli/src/codex/codexRemoteLauncher.ts:2815–2889  ·  view source on GitHub ↗
(message: QueuedMessage)

Source from the content-addressed store, hash-verified

2813 });
2814
2815 const handleGoalCommand = async (message: QueuedMessage): Promise<boolean> => {
2816 const command = parseGoalCommand(message.message);
2817 if (!command) {
2818 return false;
2819 }
2820
2821 await interruptActiveTurn();
2822 resetCurrentTurnState();
2823
2824 if (command.error) {
2825 sendVisibleStatus(command.error);
2826 return true;
2827 }
2828
2829 if (!supportsGoals) {
2830 sendVisibleStatus(CODEX_GOALS_UNSUPPORTED_MESSAGE);
2831 return true;
2832 }
2833
2834 const threadId = await ensureThreadForGoal(message.mode);
2835 if (!threadId) {
2836 return true;
2837 }
2838
2839 try {
2840 if (command.action === 'show') {
2841 const response = await appServerClient.getThreadGoal({ threadId }, {
2842 signal: this.abortController.signal
2843 });
2844 const goal = response.goal ? normalizeGoal(response.goal) : null;
2845 if (!goal) {
2846 sendVisibleStatus('Usage: /goal <objective>');
2847 sendGoalEvent({ type: 'thread_goal_cleared', thread_id: threadId });
2848 return true;
2849 }
2850 sendVisibleStatus(formatGoalUsage(goal));
2851 sendGoalEvent({ type: 'thread_goal_updated', thread_id: threadId, goal });
2852 return true;
2853 }
2854
2855 if (command.action === 'clear') {
2856 const response = await appServerClient.clearThreadGoal({ threadId }, {
2857 signal: this.abortController.signal
2858 });
2859 if (response.cleared) {
2860 sendVisibleStatus('Goal cleared');
2861 } else {
2862 sendVisibleStatus('No goal to clear');
2863 }
2864 sendGoalEvent({ type: 'thread_goal_cleared', thread_id: threadId });
2865 return true;
2866 }
2867
2868 const status: ThreadGoalStatus = command.action === 'pause' ? 'paused' : 'active';
2869 const response = await appServerClient.setThreadGoal({
2870 threadId,
2871 ...(command.action === 'set' ? { objective: command.objective } : {}),
2872 status

Callers

nothing calls this directly

Calls 4

formatGoalUsageFunction · 0.85
getThreadGoalMethod · 0.45
clearThreadGoalMethod · 0.45
setThreadGoalMethod · 0.45

Tested by

no test coverage detected