Skip to content

Commit 6618ccb

Browse files
chore(lint): enforce runEffectInsideEffect (pingdotgg#25096)
1 parent 931bd53 commit 6618ccb

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

‎apps/server/src/preview/ServerBrowser.ts‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ const make = Effect.gen(function* () {
457457
const desktopChannel = yield* DesktopBrowserChannel.DesktopBrowserChannel;
458458
const agentTurns = yield* (yield* PreviewAgentActivity.PreviewAgentActivity).changes;
459459
const runFork = Effect.runForkWith(yield* Effect.context<never>());
460+
const runPromise = Effect.runPromiseWith(yield* Effect.context<never>());
460461
const launchServices = yield* Effect.context<ChildProcessSpawner.ChildProcessSpawner>();
461462
const setupCommand = yield* resolveRootCliCommand(PreviewBrowserHost.SETUP_SUBCOMMAND);
462463

@@ -471,7 +472,7 @@ const make = Effect.gen(function* () {
471472

472473
const contexts = new ServerBrowserContexts({
473474
profilesDir: NodePath.join(config.stateDir, "server-browser", "profiles"),
474-
executable: () => Effect.runPromise(previewBrowser.executable),
475+
executable: () => runPromise(previewBrowser.executable),
475476
// Playwright's launch error drops Chrome's own output; its sandbox note survives.
476477
diagnose: (executable, cause) =>
477478
Effect.runPromiseWith(launchServices)(
@@ -677,7 +678,7 @@ const make = Effect.gen(function* () {
677678

678679
const desktopRenders = (snapshot: PreviewSessionSnapshot) =>
679680
desktopChannel.available
680-
? Effect.runPromise(
681+
? runPromise(
681682
desktopChannel.awaitAttached(
682683
{ threadId: snapshot.threadId, tabId: snapshot.tabId },
683684
DESKTOP_ATTACH_TIMEOUT,
@@ -686,9 +687,9 @@ const make = Effect.gen(function* () {
686687
: Promise.resolve(false);
687688

688689
const connectDesktop = async (snapshot: PreviewSessionSnapshot) => {
689-
const scope = await Effect.runPromise(Scope.make());
690+
const scope = await runPromise(Scope.make());
690691
try {
691-
const endpoint = await Effect.runPromise(
692+
const endpoint = await runPromise(
692693
desktopChannel
693694
.endpoint({ threadId: snapshot.threadId, tabId: snapshot.tabId })
694695
.pipe(Scope.provide(scope)),
@@ -698,11 +699,11 @@ const make = Effect.gen(function* () {
698699
page: connected.page,
699700
close: async () => {
700701
await connected.browser.close().catch(constVoid);
701-
await Effect.runPromise(Scope.close(scope, Exit.void));
702+
await runPromise(Scope.close(scope, Exit.void));
702703
},
703704
};
704705
} catch (cause) {
705-
await Effect.runPromise(Scope.close(scope, Exit.void));
706+
await runPromise(Scope.close(scope, Exit.void));
706707
throw cause;
707708
}
708709
};
@@ -1184,7 +1185,7 @@ const make = Effect.gen(function* () {
11841185
const controller = [...opener.viewers].find(
11851186
(viewer) => viewer.id === opener.control.controller,
11861187
);
1187-
await Effect.runPromise(
1188+
await runPromise(
11881189
manager.open({
11891190
threadId: opener.threadId,
11901191
...(/^https?:/i.test(url) ? { url } : {}),
@@ -1677,7 +1678,7 @@ const make = Effect.gen(function* () {
16771678
const tab =
16781679
request.tabId === undefined
16791680
? latestThreadTab(request.threadId, request.agentSessionId)
1680-
: await Effect.runPromise(
1681+
: await runPromise(
16811682
findTab(request.threadId, request.tabId).pipe(Effect.orElseSucceed(constVoid)),
16821683
);
16831684
if (!tab) {
@@ -1741,7 +1742,7 @@ const make = Effect.gen(function* () {
17411742

17421743
const found =
17431744
reuse && request.tabId !== undefined
1744-
? await Effect.runPromise(
1745+
? await runPromise(
17451746
findTab(request.threadId, request.tabId).pipe(
17461747
Effect.catchTags({
17471748
ServerBrowserTabNotFoundError: () => Effect.void,
@@ -1750,7 +1751,7 @@ const make = Effect.gen(function* () {
17501751
)
17511752
: undefined;
17521753
if (reuse && request.tabIdExplicit && !found) {
1753-
const { sessions } = await Effect.runPromise(
1754+
const { sessions } = await runPromise(
17541755
manager.list({ threadId: ThreadId.make(request.threadId) }),
17551756
);
17561757
const desktop = sessions.some(
@@ -1777,7 +1778,7 @@ const make = Effect.gen(function* () {
17771778
const tab =
17781779
existing ??
17791780
(await ensureTab(
1780-
await Effect.runPromise(
1781+
await runPromise(
17811782
manager.open({
17821783
threadId: request.threadId,
17831784
...(url ? { url } : {}),
@@ -1808,7 +1809,7 @@ const make = Effect.gen(function* () {
18081809
}
18091810
const reveal = open.open ?? open.show;
18101811
if (reveal !== false) {
1811-
await Effect.runPromise(
1812+
await runPromise(
18121813
manager.requestReveal({
18131814
threadId: tab.threadId,
18141815
tabId: tab.tabId,
@@ -1872,7 +1873,7 @@ const make = Effect.gen(function* () {
18721873
if (tab.control.controller !== null)
18731874
throw new BrowserControlInterrupted("A human controls this tab.", "humanControl");
18741875
void tab.control.close().catch(constVoid);
1875-
await Effect.runPromise(manager.close({ threadId: tab.threadId, tabId: tab.tabId }));
1876+
await runPromise(manager.close({ threadId: tab.threadId, tabId: tab.tabId }));
18761877
dropTab(tab, false);
18771878
return {};
18781879
}
@@ -1939,7 +1940,7 @@ const make = Effect.gen(function* () {
19391940
}
19401941
case "resize": {
19411942
const setting = resolvePreviewViewport(input as PreviewAutomationResizeInput);
1942-
await Effect.runPromise(
1943+
await runPromise(
19431944
manager.resize({ threadId: tab.threadId, tabId: tab.tabId, viewport: setting }),
19441945
);
19451946
await applySetting(tab, setting);
@@ -1951,7 +1952,7 @@ const make = Effect.gen(function* () {
19511952
}
19521953
case "setColorScheme": {
19531954
const { colorScheme } = input as PreviewAutomationSetColorSchemeInput;
1954-
const snapshot = await Effect.runPromise(
1955+
const snapshot = await runPromise(
19551956
manager.adjust({ threadId: tab.threadId, tabId: tab.tabId, colorScheme }),
19561957
);
19571958
await applyRendering(tab, snapshot);
@@ -2197,7 +2198,7 @@ const make = Effect.gen(function* () {
21972198
}
21982199
case "viewport": {
21992200
const setting = decodeViewportSetting(message.setting);
2200-
await Effect.runPromise(
2201+
await runPromise(
22012202
manager.resize({ threadId: tab.threadId, tabId: tab.tabId, viewport: setting }),
22022203
);
22032204
await applySetting(tab, setting);

‎packages/provider-cursor/src/server/credentialStore.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ export const makeCursorCredentialStore = Effect.fn("makeCursorCredentialStore")(
5050
),
5151
);
5252
}
53+
const runPromise = Effect.runPromiseWith(yield* Effect.context<never>());
5354
const store: SdkCredentialStore = {
5455
load: () =>
55-
Effect.runPromise(
56+
runPromise(
5657
credentials.get.pipe(
5758
Effect.flatMap(
5859
Option.match({
@@ -67,7 +68,7 @@ export const makeCursorCredentialStore = Effect.fn("makeCursorCredentialStore")(
6768
),
6869
),
6970
save: (value) =>
70-
Effect.runPromise(
71+
runPromise(
7172
encodeCredentials(value).pipe(
7273
Effect.mapError(
7374
() =>
@@ -80,7 +81,7 @@ export const makeCursorCredentialStore = Effect.fn("makeCursorCredentialStore")(
8081
Effect.flatMap((encoded) => credentials.set(new TextEncoder().encode(encoded))),
8182
),
8283
),
83-
clear: () => Effect.runPromise(credentials.remove),
84+
clear: () => runPromise(credentials.remove),
8485
};
8586
return { store, binding: credentials.binding };
8687
});

‎tsconfig.base.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"namespaceImportPackages": ["@effect/platform-node", "effect"],
2525
"effectFn": ["span", "inferred-span", "suggested-span"],
2626
"diagnosticSeverity": {
27+
"runEffectInsideEffect": "error",
2728
"flatMapConditionalToFilterOrFail": "error",
2829
"catchConditionalRefailToCatchIf": "error",
2930
"tryCatchInEffectGen": "error",

0 commit comments

Comments
 (0)