(messages)
| 795 | environmentId: '', |
| 796 | sessionIngressUrl: credentials.api_base_url, |
| 797 | writeMessages(messages) { |
| 798 | const filtered = messages.filter( |
| 799 | m => |
| 800 | isEligibleBridgeMessage(m) && |
| 801 | !initialMessageUUIDs.has(m.uuid) && |
| 802 | !recentPostedUUIDs.has(m.uuid), |
| 803 | ) |
| 804 | if (filtered.length === 0) return |
| 805 | |
| 806 | // Fire onUserMessage for title derivation. Scan before the flushGate |
| 807 | // check — prompts are title-worthy even if they queue. Keeps calling |
| 808 | // on every title-worthy message until the callback returns true; the |
| 809 | // caller owns the policy (derive at 1st and 3rd, skip if explicit). |
| 810 | if (!userMessageCallbackDone) { |
| 811 | for (const m of filtered) { |
| 812 | const text = extractTitleText(m) |
| 813 | if (text !== undefined && onUserMessage?.(text, sessionId)) { |
| 814 | userMessageCallbackDone = true |
| 815 | break |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | if (flushGate.enqueue(...filtered)) { |
| 821 | logForDebugging( |
| 822 | `[remote-bridge] Queued ${filtered.length} message(s) during flush`, |
| 823 | ) |
| 824 | return |
| 825 | } |
| 826 | |
| 827 | for (const msg of filtered) recentPostedUUIDs.add(msg.uuid) |
| 828 | const events: TransportMessage[] = toSDKMessages(filtered).map(m => ({ |
| 829 | ...m, |
| 830 | session_id: sessionId, |
| 831 | })) as TransportMessage[] |
| 832 | // v2 does not derive worker_status from events server-side (unlike v1 |
| 833 | // session-ingress session_status_updater.go). Push it from here so the |
| 834 | // CCR web session list shows Running instead of stuck on Idle. Only |
| 835 | // work-starting user messages mark turn start; hidden local-command |
| 836 | // scaffolding and pure reminders should not re-open a completed turn. |
| 837 | // CCRClient.reportState dedupes consecutive same-state pushes. |
| 838 | if (shouldReportRunningForMessages(filtered)) { |
| 839 | transport.reportState('running') |
| 840 | } |
| 841 | logForDebugging(`[remote-bridge] Sending ${filtered.length} message(s)`) |
| 842 | void transport.writeBatch(events as StdoutMessage[]) |
| 843 | }, |
| 844 | writeSdkMessages(messages: SDKMessage[]) { |
| 845 | const filtered = messages.filter( |
| 846 | m => !m.uuid || !recentPostedUUIDs.has(m.uuid as string), |
nothing calls this directly
no test coverage detected