feat: use configuration service API as a single source of truth - #3273
Open
MartinCupela wants to merge 5 commits into
Open
feat: use configuration service API as a single source of truth#3273MartinCupela wants to merge 5 commits into
MartinCupela wants to merge 5 commits into
Conversation
# Conflicts: # examples/tutorial/src/3-channel-list/App.tsx # examples/tutorial/src/7-livestream/App.tsx # examples/vite/src/App.tsx # examples/vite/src/ChatLayout/SwitchableChannelNavigation.tsx # examples/vite/src/SingleChannel/SingleChannelApp.tsx # src/components/ChannelList/ChannelList.tsx # src/components/Chat/Chat.tsx # src/context/ChatContext.tsx
# Conflicts: # ai-docs/ai-migration-v14-v15.md # examples/vite/src/AppSettings/tabs/General/GeneralTab.tsx # src/components/Channel/hooks/useChannelConfig.ts # src/components/Thread/ThreadHeader.tsx
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The React side of the LLC configuration work (companion to
stream-chat-js#…). Depends on GetStream/stream-chat-js#1831.Two things: components now read the resolved configuration instead of the channel type's raw server
flags, and the per-component request-handler props are gone in favour of registering handlers once on
client.config.Reading resolved configuration
The LLC now combines each server flag with whatever is registered through
client.config, and thatcombined value is what it enforces. Components were reading only the server's half, so a menu could offer
an action the composer had already disabled.
useChannelConfignow returns the channel's resolved configuration rather than the raw server config, sofield names change with it:
useAttachmentManagerStategained the composer-resolved gates —attachmentsEnabled,locationEnabled,pollsEnabled,customCdn— which letAttachmentSelectordrop a duplicate selector of its own.Both hooks subscribe to the configuration. These values are getters on the LLC instances, so nothing
re-rendered when they changed; a
client.config.set()did not reach the screen.useMarkReadmoved fromchannel.getConfig()?.read_eventsto the resolvedreadEvents.enabled, so itnow honours a client-side disable and re-runs when it changes — a plain method call could not, being
outside React's dependency graph.
After this, no component reads
channel.serverConfig.Removing the request-handler props
doSendMessageRequest,doUpdateMessageRequest,doDeleteMessageRequestanddoMarkReadRequestareremoved from
ChannelandThread, along with the two hooks and the ownership coordinator behind them.The props and
client.configwrote to the same slot, so the SDK carried a coordinator that tracked whichmounted component owned each handler, restored the previous owner on unmount, and re-applied everything
whenever the LLC re-derived. All of that existed to reconcile two ways of doing one thing. With one owner
there is nothing to arbitrate — 827 deletions against 17 insertions.
useChannelEditMessageHandlerwent with them: it existed to applydoUpdateMessageRequestto the editpath and wrapped nothing once that prop was gone.
Also removed, in its own commit:
adaptMessageSendErrorToErrorFromResponse. It normalised a network errorinto a
StreamAPIErrorwhenChannel.tsxdid the sending. The send path moved into the LLC, whichproduces that shape itself, and the call site went with it — leaving the function with no callers, no
tests, and no reachable import path.
Details in
ai-docs/ai-migration-v14-v15.md.Request handlers move to
client.config:Three differences: handlers take a single params object and return
{ message }; thread flows registerunder the
threadkey; and registration is per client, not per mounted subtree — the one thing theprops could do that this cannot. Different behaviour per channel now needs a branch inside one handler on
the
cidit receives.Also:
useChannelConfig's field names (above);useAttachmentManagerStatereplaceshasCustomDoUploadRequestwithcustomCdn, which answers the question that flag was only ever a proxyfor;
useChannelEditMessageHandlerremoved.Note for tests:
channel.getConfig()is now thechannel.serverConfiggetter, sovi.spyOn(channel, 'getConfig')has no equivalent — set the channel type's config onclient.channelConfigsByTypeStoreinstead, which also drives the derivation sochannel.configiscorrect.
Example app
examples/vitegains a Configuration tab (+1803 lines): the resolved tree per scope, inline editors,a reference of every configurable path, and a view of what is actually registered versus what resolved.
It was the main tool for exercising this end to end. Also a fullscreen toggle for the settings modal and a
contrast fix on its buttons.
Not ready to merge yet
stream-chatis pinned to10.0.0-rc.2inpackage.json(peer and dev) andexamples/vite/package.json.That tag predates this API, so CI will fail to typecheck — it installs from npm, whereas this passes
locally through a symlink to the LLC worktree. Needs the LLC PR merged, a new rc published, and a
chore(deps)bump.