MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / processInitialMessage

Function processInitialMessage

src/screens/REPL.tsx:3067–3171  ·  view source on GitHub ↗
(initialMsg: NonNullable<typeof pending>)

Source from the content-addressed store, hash-verified

3065 // Mark as processing to prevent re-entry
3066 initialMessageRef.current = true;
3067 async function processInitialMessage(initialMsg: NonNullable<typeof pending>) {
3068 // Clear context if requested (plan mode exit)
3069 if (initialMsg.clearContext) {
3070 // Preserve the plan slug before clearing context, so the new session
3071 // can access the same plan file after regenerateSessionId()
3072 const oldPlanSlug = initialMsg.message.planContent ? getPlanSlug() : undefined;
3073 const {
3074 clearConversation
3075 } = await import('../commands/clear/conversation.js');
3076 await clearConversation({
3077 setMessages,
3078 readFileState: readFileState.current,
3079 discoveredSkillNames: discoveredSkillNamesRef.current,
3080 loadedNestedMemoryPaths: loadedNestedMemoryPathsRef.current,
3081 getAppState: () => store.getState(),
3082 setAppState,
3083 setConversationId
3084 });
3085 haikuTitleAttemptedRef.current = false;
3086 setHaikuTitle(undefined);
3087 bashTools.current.clear();
3088 bashToolsProcessedIdx.current = 0;
3089
3090 // Restore the plan slug for the new session so getPlan() finds the file
3091 if (oldPlanSlug) {
3092 setPlanSlug(getSessionId(), oldPlanSlug);
3093 }
3094 }
3095
3096 // Atomically: clear initial message, set permission mode and rules, and store plan for verification
3097 const shouldStorePlanForVerification = initialMsg.message.planContent && "external" === 'ant' && isEnvTruthy(undefined);
3098 setAppState(prev => {
3099 // Build and apply permission updates (mode + allowedPrompts rules)
3100 let updatedToolPermissionContext = initialMsg.mode ? applyPermissionUpdates(prev.toolPermissionContext, buildPermissionUpdates(initialMsg.mode, initialMsg.allowedPrompts)) : prev.toolPermissionContext;
3101 // For auto, override the mode (buildPermissionUpdates maps
3102 // it to 'default' via toExternalPermissionMode) and strip dangerous rules
3103 if (feature('TRANSCRIPT_CLASSIFIER') && initialMsg.mode === 'auto') {
3104 updatedToolPermissionContext = stripDangerousPermissionsForAutoMode({
3105 ...updatedToolPermissionContext,
3106 mode: 'auto',
3107 prePlanMode: undefined
3108 });
3109 }
3110 return {
3111 ...prev,
3112 initialMessage: null,
3113 toolPermissionContext: updatedToolPermissionContext,
3114 ...(shouldStorePlanForVerification && {
3115 pendingPlanVerification: {
3116 plan: initialMsg.message.planContent!,
3117 verificationStarted: false,
3118 verificationCompleted: false
3119 }
3120 })
3121 };
3122 });
3123
3124 // Create file history snapshot for code rewind

Callers 1

REPLFunction · 0.85

Calls 13

getPlanSlugFunction · 0.85
clearConversationFunction · 0.85
setPlanSlugFunction · 0.85
getSessionIdFunction · 0.85
isEnvTruthyFunction · 0.85
applyPermissionUpdatesFunction · 0.85
buildPermissionUpdatesFunction · 0.85
fileHistoryEnabledFunction · 0.85
fileHistoryMakeSnapshotFunction · 0.85
onSubmitFunction · 0.85
createAbortControllerFunction · 0.85

Tested by

no test coverage detected