Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
8a9e103
fix(agent): let the canvas track a standalone agent's edits
skishore23 Sep 10, 2026
21d067c
fix(agent): one socket for chat and canvas on the standalone agent
skishore23 Sep 11, 2026
32958b8
fix(agent): the standalone harness enables the panel without the Post…
skishore23 Sep 11, 2026
4128daa
fix(agent): a turn from a tab with no workflow mints one instead of r…
skishore23 Sep 11, 2026
13ef516
fix(agent): re-drive a dropped subscribe when the standalone socket o…
skishore23 Sep 11, 2026
88de4d3
Merge origin/main into kishore/standalone-agent-canvas-sync
skishore23 Sep 11, 2026
8fb28c7
fix(agent): resolve identity through the rest client and hold the fol…
skishore23 Sep 11, 2026
92b1b4e
fix(agent): treat a standalone socket open as a reconnect and resubsc…
skishore23 Sep 11, 2026
0bc9524
fix(agent): a standalone panel has no cloud workflow index to fetch
skishore23 Sep 12, 2026
e10c264
[automated] Apply ESLint and Oxfmt fixes
actions-user Sep 12, 2026
3ff5da6
fix(agent): on a standalone target, the workflow picker selects a tab…
skishore23 Sep 12, 2026
6e3d3aa
Merge origin/main into kishore/standalone-agent-canvas-sync
skishore23 Sep 12, 2026
b655c4d
Merge origin/main into kishore/standalone-agent-canvas-sync
skishore23 Sep 13, 2026
2c71c47
fix(agent): seed the draft again once the follower has given up on it…
Sep 14, 2026
f4012b3
fix(agent): retry the standalone identity lookup on the socket's conn…
Sep 14, 2026
2b2c8e4
fix(agent): mint human canvas edits only while the follower is active
Sep 14, 2026
2756d4f
build: refuse VITE_AGENT_STANDALONE in a cloud distribution
Sep 14, 2026
48d8614
test(agent): harness spec covers the flag-less render and a node land…
Sep 14, 2026
377f91b
Merge remote-tracking branch 'pr/17469' into HEAD
Sep 18, 2026
240856c
fix: resolve #17469 onto nightly 45bd3c8b (thread baseTransport into …
Sep 18, 2026
9b09ecf
Merge origin/main into kishore/standalone-agent-canvas-sync
skishore23 Sep 21, 2026
20294b6
refactor(agent): resolve tabs through the saved-workflow index on eve…
skishore23 Sep 24, 2026
fbcfd1b
fix(agent): refuse to send a saved tab the saved-workflow index has n…
skishore23 Sep 24, 2026
a54a198
refactor(agent): one agent socket and one identity lookup on every ba…
skishore23 Sep 24, 2026
fa36926
fix(agent): back off agent socket reconnects and never drop an identi…
skishore23 Sep 24, 2026
18fbf27
test(agent): serve agent and doc frames on the agent socket in e2e
skishore23 Sep 24, 2026
a6ec8e0
test(agent): keep the e2e agent user id local to its fixture
skishore23 Sep 24, 2026
96876d0
test(agent): forget a closed agent socket route in the e2e tracker
skishore23 Sep 24, 2026
ac27d90
feat(agent): hand the agent the signed-in credential, as partner node…
skishore23 Sep 25, 2026
4be2e72
fix(agent): open the events socket at the api path
skishore23 Sep 25, 2026
26d3248
fix(agent): follow account switches on the agent socket; retry a fail…
skishore23 Sep 25, 2026
4f56157
fix(agent): register new node types after the agent restarts ComfyUI
skishore23 Sep 28, 2026
f1515db
Merge origin/main into the agent backend contract branch
skishore23 Oct 5, 2026
99b9eab
fix(agent): refuse a send whose id-less origin tab closes during prepare
skishore23 Oct 5, 2026
a51b6a8
fix(agent): make a silent subscribe give-up terminal for the draft seed
skishore23 Oct 5, 2026
d8d8beb
fix(agent): clear the follower's terminal state when a reconnect retries
skishore23 Oct 5, 2026
2972bfd
fix(agent): retry a node catalog refresh that failed during a restart
skishore23 Oct 5, 2026
d0dbb32
fix(agent): fence the agent socket on API key account changes too
skishore23 Oct 5, 2026
b21e197
docs(agent): describe the events socket contract in the feature README
skishore23 Oct 5, 2026
4fcbf61
test(agent): take the doc_update receipt from the agent socket
skishore23 Oct 5, 2026
dd7af84
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 6, 2026
9a37be3
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 6, 2026
bdff123
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 13, 2026
44305e1
fix(agent): forward every server doc frame and back off accept-then-c…
skishore23 Oct 13, 2026
611b07a
test(agent): give the agent socket route one owner in the e2e suites
skishore23 Oct 13, 2026
726ebe8
fix(agent): retry identity on its own and keep the draft off a docume…
skishore23 Oct 13, 2026
fc82511
docs(agent): record the one-socket contract in ADR-0025 and the dev p…
skishore23 Oct 13, 2026
08fdea8
refactor(agent): drop explanatory comments from the agent contract ch…
skishore23 Oct 13, 2026
e4fdd5e
fix(agent): authenticate cloud agent traffic the way fetchApi and /ws do
skishore23 Oct 13, 2026
19d51f0
revert(agent): leave the unresolved saved-tab policy to #19998
skishore23 Oct 13, 2026
8c4fef0
refactor(agent): move the follower terminal state and draft-seed guar…
skishore23 Oct 13, 2026
4a3146c
refactor(agent): move the node-catalog refresh after restart_comfyui …
skishore23 Oct 13, 2026
1f50805
refactor(agent): move the standalone panel force-on and cloud-build r…
skishore23 Oct 13, 2026
e8114ef
docs(agent): describe the cloud credential path and the dev proxy sig…
skishore23 Oct 13, 2026
597f2a9
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 13, 2026
92da85c
fix(agent): reconnect promptly after a long-lived socket and stop ret…
skishore23 Oct 13, 2026
9275347
fix(agent): open the cloud agent socket only when /ws could, and keep…
skishore23 Oct 13, 2026
a8a5934
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 13, 2026
362a873
test(api): pin socketAuthParams' null when no one can open the socket
skishore23 Oct 13, 2026
4d9adba
docs(agent): align the follower-boundary check and README with the on…
skishore23 Oct 13, 2026
8091d3e
test(agent): stop counting a refused subscribe as an accepted one in …
skishore23 Oct 13, 2026
6eea89c
refactor(agent): drop the test-only AGENT_WS_EVENT_TYPES export and s…
skishore23 Oct 13, 2026
3423bb5
fix(agent): treat a failed socket auth read as a failed connect, not …
skishore23 Oct 13, 2026
761a7d2
fix(agent): withhold the draft while the follower holds the bound doc…
skishore23 Oct 13, 2026
e2ae250
fix(agent): seed the draft again once the bound document can no longe…
skishore23 Oct 13, 2026
75e58a1
test(agent): cover a refusal that turns terminal without a give-up no…
skishore23 Oct 13, 2026
bbbebda
refactor(agent): drop the unread unavailable identity state
skishore23 Oct 13, 2026
dcaa98f
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 14, 2026
c9a03ae
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 14, 2026
b8108b0
fix(agent): drop deleted event-source files from the architecture rec…
skishore23 Oct 14, 2026
9ba45c5
fix(agent): keep the branch's new imports inside the domain boundaries
skishore23 Oct 14, 2026
4603647
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 15, 2026
6a191f9
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 15, 2026
89ddb25
test(agent): pin that the cloud panel never refreshes the credential …
skishore23 Oct 15, 2026
0893665
Merge remote-tracking branch 'origin/main' into kishore/standalone-ag…
skishore23 Oct 15, 2026
b167cec
Merge origin/main into kishore/standalone-agent-canvas-sync
skishore23 Oct 16, 2026
a4627cd
test: add missing unified remint provider mock
Oct 16, 2026
2b6ded0
test(agent): drive the reply image URL spec over the agent socket
skishore23 Oct 16, 2026
4fe2bfd
fix(agent): settle a failing identity lookup instead of retrying forever
skishore23 Oct 17, 2026
80c4d17
Merge remote-tracking branch 'origin/main' into fix17469
skishore23 Oct 17, 2026
b799142
test(agent): expect the delete_approval ask kind on an unbound-tab turn
skishore23 Oct 17, 2026
e893e28
Merge main into kishore/standalone-agent-canvas-sync
skishore23 Oct 17, 2026
de2271c
test(agent): move main's new follower specs onto the agent socket
skishore23 Oct 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .agents/checks/follower-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,34 @@ Flag:
- **Branch-pinned catalog/vocabulary citation** — referencing the widget catalog by moving
branch instead of a pinned SHA.

## Priority 4: distribution seam — one boundary, unified auth
## Priority 4: distribution seam — one socket, one credential branch

Per FOLLOWER the follower APPLY path is distribution-agnostic; surface differences
(endpoint, ingest-vs-direct route, auth) live behind one small distribution-resolved
boundary keyed on `DISTRIBUTION`.
Per the FOLLOWER amendment (2026-10-12) the follower APPLY path is
distribution-agnostic. Cloud ingest and the local agent serve the same contract:
agent events and document frames share `/api/agent/events`, whose path comes from
`api.apiURL`. The only distribution branch is the credential choice in `agentAuth.ts`.

Flag:

- **`DISTRIBUTION` / `isCloud` / `isDesktop` checks scattered through follower core** —
distribution conditionals inside the CRDT apply seam, `DocFrameClient`, or rendering.
They belong only in the agent connection/configuration boundary.
- **Auth reduced to `isCloud`** — resolving credentials by distribution instead of
delegating to the unified chain `authStore.getAuthHeader()`. Local and Desktop are
authenticated product surfaces, not "anonymous / model-key-only".
distribution conditionals inside the CRDT apply seam, `DocFrameClient`, the agent
socket transport, or rendering. They belong only in the credential branch in
`agentAuth.ts`.
- **A credential path other than the one `isCloud` branch** — in the cloud, agent REST
requests authenticate through `fetchApi` alone and the socket takes
`api.socketAuthParams()` (no socket when no one is signed in); adding the user's own
header there moves a request out of its workspace. Off-cloud, REST requests carry
`getUserAuthHeader()` and the socket carries the same credential as `?token=`. Flag
credential resolution outside `agentAuth.ts`, or any branch that leaves Local or
Desktop unauthenticated: they are authenticated product surfaces, not
"anonymous / model-key-only".
- **Dev/Vite behavior treated as Local product behavior** — Vite proxy or dev credentials
placed in the Local or Desktop path. Dev-only wiring stays in Vite/dev config.
- **A hardcoded agent base URL** — an agent HTTP/WS endpoint string literal instead of a
centralized distribution-resolved resolver (the `AGENT_BASE_URL`-style seam). Today the
follower rides the centralized `api.socket`; a new direct-to-agent connection must
resolve its endpoint through the seam, not a literal.
placed in the Local or Desktop path. Dev-only wiring stays in Vite/dev config; the
browser learns only the build-time flag `VITE_DEV_AGENT_PROXY_CREDENTIAL`, never the
token.
- **A hardcoded agent base URL or a second agent socket** — an agent HTTP/WS endpoint
string literal instead of `api.apiURL`, or a transport other than
`/api/agent/events` (such as agent traffic on `/ws` or a separate local-agent socket).

## Enforcement expectation

Expand Down
47 changes: 11 additions & 36 deletions browser_tests/fixtures/agentAskTurnFixture.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Locator, Page, WebSocketRoute } from '@playwright/test'
import type { Locator, Page } from '@playwright/test'
import { expect } from '@playwright/test'

import type { WidgetCatalog, WorkflowJSON } from '@comfyorg/comfy-multi-player'
Expand All @@ -16,6 +16,7 @@ import {
bootAgentApp,
mockWorkflowPersistence
} from '@e2e/fixtures/agentPanelFixture'
import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import type { HostFrame } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
Expand All @@ -27,7 +28,6 @@ import {
import { AGENT_COMPOSER_LABEL } from '@e2e/fixtures/utils/agentComposerLabel'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'

const SOCKET_SID = '8e2f3a4b-5c6d-4e7f-9a01-2b3c4d5e6f70'
const CATALOG: WidgetCatalog = { types: {} }
const SEED: WorkflowJSON = { nodes: [], links: [] }

Expand All @@ -46,10 +46,6 @@ export interface AskTurn {
answer: (prompt: string, option: string) => Promise<void>
}

function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null
}

function isAnswerTo(askId: string): (url: URL) => boolean {
return (url) => decodeURIComponent(url.pathname) === answerPath(askId)
}
Expand All @@ -59,12 +55,13 @@ async function startAskTurn(
prompt: string,
storedMode: AgentRunMode['mode']
): Promise<AskTurn> {
const host = new HostDoc(ASK_WORKFLOW_ID, SEED, CATALOG)
let socket: WebSocketRoute | null = null
const send = (frame: AgentWsEvent | AgentAskServerFrame | HostFrame) => {
if (!socket) throw new Error('the app has not opened /ws yet')
socket.send(JSON.stringify(frame))
}
const hostSocket = new AgentFollowerHostSocket(
page,
ASK_WORKFLOW_ID,
new HostDoc(ASK_WORKFLOW_ID, SEED, CATALOG)
)
const send = (frame: AgentWsEvent | AgentAskServerFrame | HostFrame) =>
hostSocket.send(frame)
const answerCalls: AnswerCall[] = []

const runMode: AgentRunMode = { mode: storedMode, credit_limit: null }
Expand Down Expand Up @@ -92,29 +89,7 @@ async function startAskTurn(
}
return route.fulfill(jsonRoute([]))
})
await page.routeWebSocket(/\/ws/, (ws) => {
socket = ws
ws.send(
JSON.stringify({
type: 'status',
data: { status: { exec_info: { queue_remaining: 0 } }, sid: SOCKET_SID }
})
)
ws.onMessage((raw) => {
const frame: unknown = JSON.parse(raw.toString())
if (!isRecord(frame)) return
const { type, data } = frame
if (type !== 'doc_subscribe' || !isRecord(data)) return
const { workflow_id, state_vector_b64 } = data
if (
workflow_id !== ASK_WORKFLOW_ID ||
typeof state_vector_b64 !== 'string'
)
return
send(host.subscribed())
send(host.catchUp(state_vector_b64))
})
})
await hostSocket.install()

await bootAgentApp(page, true, {
settings: { 'Comfy.Graph.CanvasInfo': false }
Expand All @@ -138,7 +113,7 @@ async function startAskTurn(
.getByRole('menuitemradio', { name: 'Unsaved Workflow', exact: true })
.click()
await expect(picker).toHaveText('Unsaved Workflow')
await expect.poll(() => socket !== null).toBe(true)
await expect.poll(() => hostSocket.connectionCount()).toBeGreaterThan(0)

await panel.getByRole('textbox', { name: AGENT_COMPOSER_LABEL }).fill(prompt)
await panel.getByRole('button', { name: enMessages.agent.send }).click()
Expand Down
2 changes: 0 additions & 2 deletions browser_tests/fixtures/agentAutogrowHandWiredLinkFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const AGENT_RECONNECT_LINK_ID = 9004
const WORKFLOW_ID = '6a1c9f3e-4d2b-4a7c-8e1f-3b5d7c9a1f6b'
const THREAD_ID = 'c3d4e5f6-1a2b-4c3d-8e4f-5a6b7c8d9e0f'
const MESSAGE_ID = 'a1b2c3d4-5e6f-4a1b-8c2d-3e4f5a6b7c8d'
const SOCKET_SID = 'f1e2d3c4-b5a6-4978-8a9b-0c1d2e3f4a5b'

// Trimmed `/object_info` entries: a plain IMAGE source, and an API node whose
// only input is a `COMFY_AUTOGROW_V3` group named `model.images`, mirroring
Expand Down Expand Up @@ -214,7 +213,6 @@ async function setUpFixture(page: Page) {
page,
WORKFLOW_ID,
host,
SOCKET_SID,
'apply'
)
await hostSocket.install()
Expand Down
7 changes: 1 addition & 6 deletions browser_tests/fixtures/agentAutogrowSpareInputFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,7 @@ async function wireAutogrowNodeAndSwitchTabs(page: Page) {
)

const host = new HostDoc(WORKFLOW_ID, seed, catalog)
const hostSocket = new AgentFollowerHostSocket(
page,
WORKFLOW_ID,
host,
'autogrow-e2e'
)
const hostSocket = new AgentFollowerHostSocket(page, WORKFLOW_ID, host)
await hostSocket.install()

await bootAgentApp(page, true, {
Expand Down
41 changes: 25 additions & 16 deletions browser_tests/fixtures/agentConversationFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import { ComfyPage } from '@e2e/fixtures/ComfyPage'
import type { HostFrame } from '@e2e/fixtures/agentConversationHostDoc'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import {
AGENT_FRAME_HANDLED_EVENT,
announceHandledAgentFrames
} from '@e2e/fixtures/agentSocket'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import type {
ClientDocFrame,
Expand Down Expand Up @@ -62,7 +66,6 @@ const THREAD_ID = 'e9a2f3d1-7c44-4b2e-9a01-5f6d8c7b3a10'
// One synthetic message id per turn; the recorded ids never reach the page.
const turnId = (turn: number): string =>
`0c5b1e77-2d4a-4f9e-8b63-1a2c3d4e5${turn.toString(16).padStart(3, '0')}`
const SOCKET_SID = '7d1f2e3a-4b5c-4d6e-8f90-1a2b3c4d5e6f'
const VUE_NODES_TAG = '@vue-nodes'
const PANEL_MOUNT_TIMEOUT = 30_000
const CANCEL_TIMEOUT = 10_000
Expand Down Expand Up @@ -200,7 +203,6 @@ interface ReplayResponseOptions {
waitForGraphOpsDelivery?: (ops: readonly RecordedGraphOperation[]) => boolean
}

// Runs one recorded prompt/response through the real panel over a routed /ws socket.
export class AgentConversationHarness {
readonly panel: Locator
readonly vueNodes: VueNodeHelpers
Expand Down Expand Up @@ -235,7 +237,6 @@ export class AgentConversationHarness {
page,
workflow.id,
this.host,
SOCKET_SID,
humanOpsHost
)
this.seenIds = new Set(workflow.seed.nodes.map((node) => String(node.id)))
Expand Down Expand Up @@ -298,6 +299,7 @@ export class AgentConversationHarness {
): Promise<void> {
await this.mockAgentApi()
await this.hostSocket.install()
await announceHandledAgentFrames(this.page)
const objectInfo = this.page.waitForResponse((response) =>
new URL(response.url()).pathname.endsWith('/api/object_info')
)
Expand Down Expand Up @@ -1206,35 +1208,42 @@ export class AgentConversationHarness {

const receipt = crypto.randomUUID()
await this.page.evaluate(
({ receipt, workflowId, seq }) => {
const api = window.app!.api
({ receipt, workflowId, seq, handledEvent }) => {
const attribute = 'data-agent-crdt-update-receipt'
const cleanupType = `agent-crdt-update-cleanup-${receipt}`
const removeReceiptListener = () => {
api.removeCustomEventListener('doc_update', recordReceipt)
function removeReceiptListener() {
document.removeEventListener(handledEvent, recordReceipt)
document.removeEventListener(cleanupType, removeReceiptListener)
}
const recordReceipt = (event: CustomEvent<unknown>) => {
if (typeof event.detail !== 'object' || event.detail === null) return
if (
!('workflow_id' in event.detail) ||
event.detail.workflow_id !== workflowId ||
!('seq' in event.detail) ||
event.detail.seq !== seq
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null
}
function isThisUpdate(detail: unknown): boolean {
if (typeof detail !== 'string') return false
const frame: unknown = JSON.parse(detail)
if (!isRecord(frame) || frame.type !== 'doc_update') return false
return (
isRecord(frame.data) &&
frame.data.workflow_id === workflowId &&
frame.data.seq === seq
)
}
function recordReceipt(event: Event) {
if (!(event instanceof CustomEvent) || !isThisUpdate(event.detail))
return
document.documentElement.setAttribute(attribute, receipt)
removeReceiptListener()
}
api.addCustomEventListener('doc_update', recordReceipt)
document.addEventListener(handledEvent, recordReceipt)
document.addEventListener(cleanupType, removeReceiptListener, {
once: true
})
},
{
receipt,
workflowId: parsedFrame.data.workflowId,
seq: parsedFrame.data.seq
seq: parsedFrame.data.seq,
handledEvent: AGENT_FRAME_HANDLED_EVENT
}
)
try {
Expand Down
1 change: 0 additions & 1 deletion browser_tests/fixtures/agentCrdtIdCollisionFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export class IdCollisionHarness {
page,
WORKFLOW_ID,
this.host,
'id-collision-repro-sid',
'hold'
)
}
Expand Down
64 changes: 58 additions & 6 deletions browser_tests/fixtures/agentFollowerHostSocket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'

const WORKFLOW_ID = 'wf-1'
const AGENT_EVENTS_URL = 'ws://127.0.0.1:8188/api/agent/events?token=abc'

// A fake `Page` whose `routeWebSocket` hands back a fake `WebSocketRoute`
// synchronously, so `AgentFollowerHostSocket` runs against the real class
Expand All @@ -27,10 +28,11 @@ function fakeRoutedPage(): {
})
const page = fromPartial<Page>({
routeWebSocket: async (
_url: string | RegExp,
url: string | RegExp,
handler: (route: WebSocketRoute) => unknown
) => {
handler(socket)
if (url instanceof RegExp && url.test(AGENT_EVENTS_URL)) handler(socket)
else handler(fromPartial<WebSocketRoute>({ send: () => {} }))
}
})
return {
Expand All @@ -40,6 +42,59 @@ function fakeRoutedPage(): {
}
}

describe('AgentFollowerHostSocket transport', () => {
it('answers a doc_subscribe with doc_subscribed and a catch-up doc_update', async () => {
const host = new HostDoc(
WORKFLOW_ID,
{ nodes: [], links: [] },
{ types: {} }
)
const { page, emitClientFrame, sentFrames } = fakeRoutedPage()
const hostSocket = new AgentFollowerHostSocket(page, WORKFLOW_ID, host)
await hostSocket.install()

emitClientFrame({
type: 'doc_subscribe',
data: { workflow_id: WORKFLOW_ID, state_vector_b64: 'AA==' }
})

expect(sentFrames().map((frame) => frame.type)).toEqual([
'doc_subscribed',
'doc_update'
])
expect(hostSocket.subscribeCount()).toBe(1)
})
})

describe('AgentFollowerHostSocket subscribe counts', () => {
it('counts a refused subscribe only as refused, then the accepted retry as a subscribe', async () => {
const host = new HostDoc(
WORKFLOW_ID,
{ nodes: [], links: [] },
{ types: {} }
)
const { page, emitClientFrame, sentFrames } = fakeRoutedPage()
const hostSocket = new AgentFollowerHostSocket(page, WORKFLOW_ID, host)
await hostSocket.install()
hostSocket.refuseSubscribes('overloaded', 1)
const subscribe = {
type: 'doc_subscribe',
data: { workflow_id: WORKFLOW_ID, state_vector_b64: 'AA==' }
}

emitClientFrame(subscribe)

expect(sentFrames().map((frame) => frame.type)).toEqual(['doc_subscribed'])
expect(hostSocket.refusedSubscribeCount()).toBe(1)
expect(hostSocket.subscribeCount()).toBe(0)

emitClientFrame(subscribe)

expect(hostSocket.refusedSubscribeCount()).toBe(1)
expect(hostSocket.subscribeCount()).toBe(1)
})
})

describe('AgentFollowerHostSocket human doc_ops handling', () => {
it('answers a malformed doc_ops batch with ok:false and never reaches the applier', async () => {
const host = new HostDoc(
Expand All @@ -52,7 +107,6 @@ describe('AgentFollowerHostSocket human doc_ops handling', () => {
page,
WORKFLOW_ID,
host,
'sid-1',
'apply'
)
await hostSocket.install()
Expand Down Expand Up @@ -87,7 +141,6 @@ describe('AgentFollowerHostSocket human doc_ops handling', () => {
page,
WORKFLOW_ID,
host,
'sid-1',
'apply'
)
await hostSocket.install()
Expand Down Expand Up @@ -115,7 +168,7 @@ describe('AgentFollowerHostSocket human doc_ops handling', () => {
expect(hostSocket.humanOpOutcomes()).toEqual([
{ op_id: 'a'.repeat(32), outcome: 'applied' }
])
expect(sentFrames().slice(1)).toEqual([
expect(sentFrames()).toEqual([
{
type: 'doc_ops_result',
data: expect.objectContaining({ ok: true })
Expand Down Expand Up @@ -156,7 +209,6 @@ describe('AgentFollowerHostSocket human doc_ops handling', () => {
page,
WORKFLOW_ID,
host,
'sid-1',
'apply'
)
await hostSocket.install()
Expand Down
Loading
Loading