MCPcopy Create free account
hub / github.com/freecodexyz/free-code / UltraplanChoiceDialog

Function UltraplanChoiceDialog

src/components/UltraplanChoiceDialog.tsx:31–114  ·  view source on GitHub ↗
({
  plan,
  sessionId,
  taskId,
  setMessages,
}: Props)

Source from the content-addressed store, hash-verified

29}
30
31export function UltraplanChoiceDialog({
32 plan,
33 sessionId,
34 taskId,
35 setMessages,
36}: Props): React.ReactNode {
37 const setAppState = useSetAppState()
38
39 const handleChoice = useCallback(
40 (choice: UltraplanChoice) => {
41 if (choice === 'execute') {
42 setMessages(prev => [
43 ...prev,
44 createSystemMessage(
45 'Ultraplan approved. Executing the following plan:',
46 'info',
47 ),
48 createUserMessage({
49 content: prepareUserContent({ inputString: plan }),
50 }),
51 ])
52 }
53
54 // Mark task completed
55 updateTaskState<RemoteAgentTaskState>(taskId, setAppState, t =>
56 t.status !== 'running'
57 ? t
58 : { ...t, status: 'completed', endTime: Date.now() },
59 )
60
61 // Clear ultraplan state
62 setAppState(prev => ({
63 ...prev,
64 ultraplanPendingChoice: undefined,
65 ultraplanSessionUrl: undefined,
66 }))
67
68 // Archive the remote session
69 void archiveRemoteSession(sessionId).catch(e =>
70 logForDebugging(`ultraplan choice archive failed: ${String(e)}`),
71 )
72 },
73 [plan, sessionId, taskId, setMessages, setAppState],
74 )
75
76 const displayPlan =
77 plan.length > 2000 ? plan.slice(0, 2000) + '\n\n... (truncated)' : plan
78
79 return (
80 <Dialog
81 title="Ultraplan ready"
82 onCancel={() => handleChoice('dismiss')}
83 >
84 <Box flexDirection="column" gap={1}>
85 <Box
86 flexDirection="column"
87 borderStyle="single"
88 borderColor="gray"

Callers

nothing calls this directly

Calls 7

useSetAppStateFunction · 0.85
createSystemMessageFunction · 0.85
createUserMessageFunction · 0.85
prepareUserContentFunction · 0.85
archiveRemoteSessionFunction · 0.85
logForDebuggingFunction · 0.85
updateTaskStateFunction · 0.50

Tested by

no test coverage detected