MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / processInitialMessage

Function processInitialMessage

source code/screens/REPL.tsx:3037–3141  ·  view source on GitHub ↗
(initialMsg: NonNullable<typeof pending>)

Source from the content-addressed store, hash-verified

3035 // Mark as processing to prevent re-entry
3036 initialMessageRef.current = true;
3037 async function processInitialMessage(initialMsg: NonNullable<typeof pending>) {
3038 // Clear context if requested (plan mode exit)
3039 if (initialMsg.clearContext) {
3040 // Preserve the plan slug before clearing context, so the new session
3041 // can access the same plan file after regenerateSessionId()
3042 const oldPlanSlug = initialMsg.message.planContent ? getPlanSlug() : undefined;
3043 const {
3044 clearConversation
3045 } = await import('../commands/clear/conversation.js');
3046 await clearConversation({
3047 setMessages,
3048 readFileState: readFileState.current,
3049 discoveredSkillNames: discoveredSkillNamesRef.current,
3050 loadedNestedMemoryPaths: loadedNestedMemoryPathsRef.current,
3051 getAppState: () => store.getState(),
3052 setAppState,
3053 setConversationId
3054 });
3055 haikuTitleAttemptedRef.current = false;
3056 setHaikuTitle(undefined);
3057 bashTools.current.clear();
3058 bashToolsProcessedIdx.current = 0;
3059
3060 // Restore the plan slug for the new session so getPlan() finds the file
3061 if (oldPlanSlug) {
3062 setPlanSlug(getSessionId(), oldPlanSlug);
3063 }
3064 }
3065
3066 // Atomically: clear initial message, set permission mode and rules, and store plan for verification
3067 const shouldStorePlanForVerification = initialMsg.message.planContent && "external" === 'ant' && isEnvTruthy(undefined);
3068 setAppState(prev => {
3069 // Build and apply permission updates (mode + allowedPrompts rules)
3070 let updatedToolPermissionContext = initialMsg.mode ? applyPermissionUpdates(prev.toolPermissionContext, buildPermissionUpdates(initialMsg.mode, initialMsg.allowedPrompts)) : prev.toolPermissionContext;
3071 // For auto, override the mode (buildPermissionUpdates maps
3072 // it to 'default' via toExternalPermissionMode) and strip dangerous rules
3073 if (feature('TRANSCRIPT_CLASSIFIER') && initialMsg.mode === 'auto') {
3074 updatedToolPermissionContext = stripDangerousPermissionsForAutoMode({
3075 ...updatedToolPermissionContext,
3076 mode: 'auto',
3077 prePlanMode: undefined
3078 });
3079 }
3080 return {
3081 ...prev,
3082 initialMessage: null,
3083 toolPermissionContext: updatedToolPermissionContext,
3084 ...(shouldStorePlanForVerification && {
3085 pendingPlanVerification: {
3086 plan: initialMsg.message.planContent!,
3087 verificationStarted: false,
3088 verificationCompleted: false
3089 }
3090 })
3091 };
3092 });
3093
3094 // 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