Skip to content

feat(cli): support custom WebSocket query params in collaboration config (SD-2543)#2799

Merged
caio-pizzol merged 5 commits intomainfrom
caio/sd-2543-support-custom-websocket-query-parameters-in-collaboration
Apr 13, 2026
Merged

feat(cli): support custom WebSocket query params in collaboration config (SD-2543)#2799
caio-pizzol merged 5 commits intomainfrom
caio/sd-2543-support-custom-websocket-query-parameters-in-collaboration

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol commented Apr 13, 2026

Adds an optional params: Record<string, string> to the CLI collaboration config, forwarded onto the y-websocket / Hocuspocus WebSocket URL so customers can attach per-session metadata (activity tracking, tenant identifiers, etc.) without wrapping the provider themselves.

  • y-websocket: merges params with the auth token into providerOptions.params. Hocuspocus: passed as its native parameters option.
  • String values only; reserved token key rejected with a pointer to tokenEnv.
  • normalizeWebSocketProfile preserves params across session reloads; profileToFingerprint uses a recursive stable stringify so the session pool distinguishes profiles that differ only in nested params.
  • Fixed a latent crash in validateValueAgainstTypeSpec on type: 'object' schemas without an explicit properties map — activated by the new params schema and would have broken all --collaboration-json usage with websocket providers.
  • Unit tests across parse, runtime (mocked providers), session pool, context rehydration, and the validator; end-to-end verified against a real @hocuspocus/server — custom params arrived at its onConnect hook intact.
  • Docs: new section in apps/docs/document-engine/sdks.mdx.

Resolves SD-2543, unblocks IT-915.

SD-2543: Adds an optional `params` field to the CLI collaboration config,
forwarded as query parameters on the y-websocket URL and as `parameters`
on the Hocuspocus provider. Validates that values are strings and rejects
the reserved `token` key (set automatically from `tokenEnv`). The field
is omitted from the public collaboration summary since it may contain
identifying metadata.
@linear
Copy link
Copy Markdown

linear Bot commented Apr 13, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0bc8cee0c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/cli/src/lib/collaboration/resolve.ts
…ed fields

Follow-up to SD-2543 addressing two correctness bugs surfaced in review:

1. normalizeWebSocketProfile in context.ts dropped params when rehydrating
   persisted collab metadata from disk, so the reconnect reopened without
   the user-supplied query params.

2. profileToFingerprint in session-pool.ts used JSON.stringify's array
   replacer as a sort helper, but that filter applies at every depth and
   silently stripped nested objects. Two profiles differing only in params
   hashed identically, causing the pool to reuse the wrong session.

Replaces the fingerprint helper with a recursive stable-stringify and adds
params validation/preservation to the context normalizer. Adds mocked
runtime tests covering the y-websocket and hocuspocus provider handoffs,
the params+token merge order, and fingerprint key-order independence.
Adds a "Forward custom WebSocket query parameters" section to the SDK guide
covering the new `params` field: scope (y-websocket and Hocuspocus only,
not Liveblocks), the string-only shape, and the reserved `token` key.
The CLI's JSON schema validator crashed on `type: 'object'` schemas that
omitted the `properties` map (e.g. schemas that only declare
`additionalProperties`). `Object.entries(schema.properties)` threw
`Cannot convert undefined or null to object` before reaching the
downstream parser.

Default `schema.properties` to `{}` in both the request and response
validators so these schemas pass through to the layer that can actually
validate their contents. Exposed by SD-2543's collaboration.params
schema, which is the first schema in the repo to use this shape.
@caio-pizzol caio-pizzol self-assigned this Apr 13, 2026
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 13, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 13, 2026
@caio-pizzol caio-pizzol enabled auto-merge April 13, 2026 21:22
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit d2d0b0f Apr 13, 2026
6 checks passed
@caio-pizzol caio-pizzol deleted the caio/sd-2543-support-custom-websocket-query-parameters-in-collaboration branch April 13, 2026 21:29
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in superdoc-cli v0.7.0-next.9

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in superdoc-sdk v1.6.0-next.6

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 17, 2026

🎉 This PR is included in superdoc-cli v0.7.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc-sdk v1.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant