-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add per-project settings #2567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add per-project settings #2567
Changes from all commits
f795100
c5048e6
2d09e73
63c54ff
fc9d5ac
048f9d6
9936e01
64c695d
0dbfb1b
78d4b8b
f87111b
ee12985
b335cad
926a605
4f7b8c0
2640720
74f5678
0f2ff8c
d232e07
50a5460
6792721
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { | |
| type ServerProvider, | ||
| type ServerProviderSlashCommand, | ||
| type ServerSettings as ContractServerSettings, | ||
| type ServerSettingsPatch, | ||
| } from "@t3tools/contracts"; | ||
| import * as PlatformError from "effect/PlatformError"; | ||
| import { HttpClient, HttpClientResponse } from "effect/unstable/http"; | ||
|
|
@@ -278,19 +279,47 @@ function makeMutableServerSettingsService( | |
| const settingsRef = yield* Ref.make(initial); | ||
| const changes = yield* PubSub.unbounded<ContractServerSettings>(); | ||
|
|
||
| const commitSettings = (makePatch: (current: ContractServerSettings) => ServerSettingsPatch) => | ||
| Effect.gen(function* () { | ||
| const current = yield* Ref.get(settingsRef); | ||
| const next = decodeServerSettings( | ||
| encodeServerSettings(applyServerSettingsPatch(current, makePatch(current))), | ||
| ); | ||
| yield* Ref.set(settingsRef, next); | ||
| yield* PubSub.publish(changes, next); | ||
| return next; | ||
| }); | ||
|
cursor[bot] marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test helper lacks write semaphore unlike production codeLow Severity The Reviewed by Cursor Bugbot for commit 50a5460. Configure here. |
||
|
|
||
| return { | ||
| start: Effect.void, | ||
| ready: Effect.void, | ||
| getSettings: Ref.get(settingsRef), | ||
| updateSettings: (patch) => | ||
| Effect.gen(function* () { | ||
| const current = yield* Ref.get(settingsRef); | ||
| const next = applyServerSettingsPatch(current, patch); | ||
| encodeServerSettings(next); | ||
| yield* Ref.set(settingsRef, next); | ||
| yield* PubSub.publish(changes, next); | ||
| return next; | ||
| }), | ||
| updateSettings: (patch) => commitSettings(() => patch), | ||
| updateProjectSettings: (projectId, patch) => | ||
| commitSettings((settings) => ({ | ||
| projectSettings: { | ||
| ...settings.projectSettings, | ||
| [projectId]: { | ||
| ...(settings.projectSettings[projectId] ?? { | ||
| remoteOverride: null, | ||
| automaticGitFetchInterval: null, | ||
| actionEnvironment: {}, | ||
| disabledProviderInstanceIds: [], | ||
| }), | ||
| ...patch, | ||
| }, | ||
| }, | ||
| })).pipe( | ||
| Effect.map( | ||
| (settings) => | ||
| settings.projectSettings[projectId] ?? { | ||
| remoteOverride: null, | ||
| automaticGitFetchInterval: null, | ||
| actionEnvironment: {}, | ||
| disabledProviderInstanceIds: [], | ||
| }, | ||
| ), | ||
| ), | ||
| get streamChanges() { | ||
| return Stream.fromPubSub(changes); | ||
| }, | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.