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

Method appendEntry

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

Source from the content-addressed store, hash-verified

1126 }
1127
1128 async appendEntry(entry: Entry, sessionId: UUID = getSessionId() as UUID) {
1129 if (this.shouldSkipPersistence()) {
1130 return
1131 }
1132
1133 const currentSessionId = getSessionId() as UUID
1134 const isCurrentSession = sessionId === currentSessionId
1135
1136 let sessionFile: string
1137 if (isCurrentSession) {
1138 // Buffer until materializeSessionFile runs (first user/assistant message).
1139 if (this.sessionFile === null) {
1140 this.pendingEntries.push(entry)
1141 return
1142 }
1143 sessionFile = this.sessionFile
1144 } else {
1145 const existing = await this.getExistingSessionFile(sessionId)
1146 if (!existing) {
1147 logError(
1148 new Error(
1149 `appendEntry: session file not found for other session ${sessionId}`,
1150 ),
1151 )
1152 return
1153 }
1154 sessionFile = existing
1155 }
1156
1157 // Only load current session messages if needed
1158 if (entry.type === 'summary') {
1159 // Summaries can always be appended
1160 void this.enqueueWrite(sessionFile, entry)
1161 } else if (entry.type === 'custom-title') {
1162 // Custom titles can always be appended
1163 void this.enqueueWrite(sessionFile, entry)
1164 } else if (entry.type === 'ai-title') {
1165 // AI titles can always be appended
1166 void this.enqueueWrite(sessionFile, entry)
1167 } else if (entry.type === 'last-prompt') {
1168 void this.enqueueWrite(sessionFile, entry)
1169 } else if (entry.type === 'task-summary') {
1170 void this.enqueueWrite(sessionFile, entry)
1171 } else if (entry.type === 'tag') {
1172 // Tags can always be appended
1173 void this.enqueueWrite(sessionFile, entry)
1174 } else if (entry.type === 'agent-name') {
1175 // Agent names can always be appended
1176 void this.enqueueWrite(sessionFile, entry)
1177 } else if (entry.type === 'agent-color') {
1178 // Agent colors can always be appended
1179 void this.enqueueWrite(sessionFile, entry)
1180 } else if (entry.type === 'agent-setting') {
1181 // Agent settings can always be appended
1182 void this.enqueueWrite(sessionFile, entry)
1183 } else if (entry.type === 'pr-link') {
1184 // PR links can always be appended
1185 void this.enqueueWrite(sessionFile, entry)

Calls 12

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

Tested by

no test coverage detected