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

Function writeMessages

source code/bridge/remoteBridgeCore.ts:769–814  ·  view source on GitHub ↗
(messages)

Source from the content-addressed store, hash-verified

767 environmentId: '',
768 sessionIngressUrl: credentials.api_base_url,
769 writeMessages(messages) {
770 const filtered = messages.filter(
771 m =>
772 isEligibleBridgeMessage(m) &&
773 !initialMessageUUIDs.has(m.uuid) &&
774 !recentPostedUUIDs.has(m.uuid),
775 )
776 if (filtered.length === 0) return
777
778 // Fire onUserMessage for title derivation. Scan before the flushGate
779 // check — prompts are title-worthy even if they queue. Keeps calling
780 // on every title-worthy message until the callback returns true; the
781 // caller owns the policy (derive at 1st and 3rd, skip if explicit).
782 if (!userMessageCallbackDone) {
783 for (const m of filtered) {
784 const text = extractTitleText(m)
785 if (text !== undefined && onUserMessage?.(text, sessionId)) {
786 userMessageCallbackDone = true
787 break
788 }
789 }
790 }
791
792 if (flushGate.enqueue(...filtered)) {
793 logForDebugging(
794 `[remote-bridge] Queued ${filtered.length} message(s) during flush`,
795 )
796 return
797 }
798
799 for (const msg of filtered) recentPostedUUIDs.add(msg.uuid)
800 const events = toSDKMessages(filtered).map(m => ({
801 ...m,
802 session_id: sessionId,
803 }))
804 // v2 does not derive worker_status from events server-side (unlike v1
805 // session-ingress session_status_updater.go). Push it from here so the
806 // CCR web session list shows Running instead of stuck on Idle. A user
807 // message in the batch marks turn start. CCRClient.reportState dedupes
808 // consecutive same-state pushes.
809 if (filtered.some(m => m.type === 'user')) {
810 transport.reportState('running')
811 }
812 logForDebugging(`[remote-bridge] Sending ${filtered.length} message(s)`)
813 void transport.writeBatch(events)
814 },
815 writeSdkMessages(messages: SDKMessage[]) {
816 const filtered = messages.filter(
817 m => !m.uuid || !recentPostedUUIDs.has(m.uuid),

Callers

nothing calls this directly

Calls 10

isEligibleBridgeMessageFunction · 0.85
extractTitleTextFunction · 0.85
onUserMessageFunction · 0.85
logForDebuggingFunction · 0.85
toSDKMessagesFunction · 0.85
reportStateMethod · 0.80
writeBatchMethod · 0.80
hasMethod · 0.45
enqueueMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected