MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / appendEntry

Method appendEntry

src/utils/sessionStorage.ts:1151–1292  ·  view source on GitHub ↗
(entry: Entry, sessionId: UUID = getSessionId() as UUID)

Source from the content-addressed store, hash-verified

1149 }
1150
1151 async appendEntry(entry: Entry, sessionId: UUID = getSessionId() as UUID) {
1152 if (this.shouldSkipPersistence()) {
1153 return
1154 }
1155
1156 const currentSessionId = getSessionId() as UUID
1157 const isCurrentSession = sessionId === currentSessionId
1158
1159 let sessionFile: string
1160 if (isCurrentSession) {
1161 // Buffer until materializeSessionFile runs (first user/assistant message).
1162 if (this.sessionFile === null) {
1163 this.pendingEntries.push(entry)
1164 return
1165 }
1166 sessionFile = this.sessionFile
1167 } else {
1168 const existing = await this.getExistingSessionFile(sessionId)
1169 if (!existing) {
1170 logError(
1171 new Error(
1172 `appendEntry: session file not found for other session ${sessionId}`,
1173 ),
1174 )
1175 return
1176 }
1177 sessionFile = existing
1178 }
1179
1180 // Only load current session messages if needed
1181 if (entry.type === 'summary') {
1182 // Summaries can always be appended
1183 void this.enqueueWrite(sessionFile, entry)
1184 } else if (entry.type === 'custom-title') {
1185 // Custom titles can always be appended
1186 void this.enqueueWrite(sessionFile, entry)
1187 } else if (entry.type === 'ai-title') {
1188 // AI titles can always be appended
1189 void this.enqueueWrite(sessionFile, entry)
1190 } else if (entry.type === 'last-prompt') {
1191 void this.enqueueWrite(sessionFile, entry)
1192 } else if (entry.type === 'task-summary') {
1193 void this.enqueueWrite(sessionFile, entry)
1194 } else if (entry.type === 'tag') {
1195 // Tags can always be appended
1196 void this.enqueueWrite(sessionFile, entry)
1197 } else if (entry.type === 'agent-name') {
1198 // Agent names can always be appended
1199 void this.enqueueWrite(sessionFile, entry)
1200 } else if (entry.type === 'agent-color') {
1201 // Agent colors can always be appended
1202 void this.enqueueWrite(sessionFile, entry)
1203 } else if (entry.type === 'agent-setting') {
1204 // Agent settings can always be appended
1205 void this.enqueueWrite(sessionFile, entry)
1206 } else if (entry.type === 'pr-link') {
1207 // PR links can always be appended
1208 void this.enqueueWrite(sessionFile, entry)

Calls 12

shouldSkipPersistenceMethod · 0.95
enqueueWriteMethod · 0.95
persistToRemoteMethod · 0.95
getSessionIdFunction · 0.85
getAgentTranscriptPathFunction · 0.85
asAgentIdFunction · 0.85
isTranscriptMessageFunction · 0.85
logErrorFunction · 0.70
pushMethod · 0.45
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected