MCPcopy Create free account
hub / github.com/WJX20/claude-code / extractReviewTagFromLog

Function extractReviewTagFromLog

src/tasks/RemoteAgentTask/RemoteAgentTask.tsx:302–326  ·  view source on GitHub ↗

* Tag-only variant of extractReviewFromLog for delta scanning. * * Returns non-null ONLY when an explicit tag is found. * Unlike extractReviewFromLog, this does NOT fall back to concatenated * assistant text. This is critical for the delta scan: in prompt mode, * early untagged

(log: SDKMessage[])

Source from the content-addressed store, hash-verified

300 * completing the review before the actual tagged output arrives.
301 */
302function extractReviewTagFromLog(log: SDKMessage[]): string | null {
303 // hook_progress / hook_response per-message scan (bughunter path)
304 for (let i = log.length - 1; i >= 0; i--) {
305 const msg = log[i];
306 if (msg?.type === 'system' && ((msg as SDKSystemMessageWithFields).subtype === 'hook_progress' || (msg as SDKSystemMessageWithFields).subtype === 'hook_response')) {
307 const tagged = extractTag((msg as SDKSystemMessageWithFields).stdout, REMOTE_REVIEW_TAG);
308 if (tagged?.trim()) return tagged.trim();
309 }
310 }
311
312 // assistant text per-message scan (prompt mode)
313 for (let i = log.length - 1; i >= 0; i--) {
314 const msg = log[i];
315 if (msg?.type !== 'assistant') continue;
316 const fullText = extractTextContent((msg as unknown as SDKMessageWithMessage).message.content, '\n');
317 const tagged = extractTag(fullText, REMOTE_REVIEW_TAG);
318 if (tagged?.trim()) return tagged.trim();
319 }
320
321 // Hook-stdout concat fallback for split tags
322 const hookStdout = log.filter(msg => msg.type === 'system' && ((msg as SDKSystemMessageWithFields).subtype === 'hook_progress' || (msg as SDKSystemMessageWithFields).subtype === 'hook_response')).map(msg => (msg as SDKSystemMessageWithFields).stdout).join('');
323 const hookTagged = extractTag(hookStdout, REMOTE_REVIEW_TAG);
324 if (hookTagged?.trim()) return hookTagged.trim();
325 return null;
326}
327
328/**
329 * Enqueue a remote-review completion notification. Injects the review text

Callers 1

pollFunction · 0.85

Calls 2

extractTagFunction · 0.85
extractTextContentFunction · 0.85

Tested by

no test coverage detected